You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(website): new website
* refactor(website): updates to the unpublished website (#876)
* refactor: change CodeSandbox theme from dark to light to improve look and feel
* refactor: update "Working with events"
* refactor: update "Working with datasets"
* refactor: update "Migration to v4"
* docs: add "Why v2"
* docs: add "Using with Chart.js v2"
* refactor: tune logo size
* refactor: update index page
* style: format svg logo
* fix: fix description for SEO; fix link to section
* docs: dynamic codesandbox theme
Co-authored-by: dangreen <danon0404@gmail.com>
* refactor: add logo and link to Stack Overflow (#877)
* chore: install peer dependencies
* docs: add more links to docs section in footer
Co-authored-by: Igor Lukanin <mail+github@igor.lukanin.name>
The data object that is passed into the Chart.js chart ([more info](https://www.chartjs.org/docs/latest/getting-started/)).
117
-
118
-
This can also be a function, that receives a canvas element and returns the data object.
119
-
120
-
```tsx
121
-
const data =canvas=> {
122
-
const ctx =canvas.getContext('2d');
123
-
const g =ctx.createLinearGradient(...);
124
-
125
-
return {
126
-
datasets: [{
127
-
backgroundColor: g,
128
-
// ...the rest
129
-
}],
130
-
};
131
-
}
132
-
```
133
-
134
-
#### options
135
-
136
-
Type: `Chart.ChartOptions`
137
-
138
-
The options object that is passed into the Chart.js chart ([more info](https://www.chartjs.org/docs/latest/general/options.html))
139
-
140
-
### fallbackContent
141
-
142
-
Type: `React.ReactNode`
143
-
144
-
A fallback for when the canvas cannot be rendered. Can be used for accessible chart descriptions ([more info](https://www.chartjs.org/docs/latest/general/accessibility.html))
145
-
146
-
#### plugins
147
-
148
-
Type: `Chart.PluginServiceRegistrationOptions[]`
149
-
150
-
The plugins array that is passed into the Chart.js chart ([more info](https://www.chartjs.org/docs/latest/developers/plugins.html))
Chart.js defaults can be set by importing the `defaults` object:
226
-
227
-
```tsx
228
-
import { defaults } from'react-chartjs-2';
229
-
230
-
// Disable animating charts by default.
231
-
defaults.animation=false;
232
-
```
233
-
234
-
If you want to bulk set properties, try using the [lodash.merge](https://lodash.com/docs/#merge) function. This function will do a deep recursive merge preserving previously set values that you don't want to update.
235
-
236
-
````tsx
237
-
import { defaults } from'react-chartjs-2';
238
-
importmergefrom'lodash.merge';
239
-
240
-
merge(defaults, {
241
-
animation: false,
242
-
line: {
243
-
borderColor: '#F85F73',
244
-
}
245
-
});
246
-
``` -->
247
-
248
-
<!-- ### Chart.js object
249
-
250
-
You can access the internal Chart.js object to register plugins or extend charts like this:
251
-
252
-
```JavaScript
253
-
import { Chart } from'react-chartjs-2';
254
-
255
-
componentWillMount() {
256
-
Chart.register({
257
-
afterDraw: function (chart, easing) {
258
-
// Plugin code.
259
-
}
260
-
});
261
-
}
262
-
````
263
-
264
-
### Working with Multiple Datasets
265
-
266
-
You will find that any event which causes the chart to re-render, such as hover tooltips, etc., will cause the first dataset to be copied over to other datasets, causing your lines and bars to merge together. This is because to track changes in the dataset series, the library needs a `key` to be specified - if none is found, it can't tell the difference between the datasets while updating. To get around this issue, you can take these two approaches:
267
-
268
-
1. Add a `label` property on each dataset. By default, this library uses the `label` property as the key to distinguish datasets.
269
-
2. Specify a different property to be used as a key by passing a `datasetKeyProvider` prop to your chart component, which would return a unique string value for each dataset.
270
-
271
-
## Development
44
+
# Docs
272
45
273
-
**NOTE:** The source code for the component is in `src`. A transpiled CommonJS version (generated with Babel) is available in `dist` for use with node.js, browserify and webpack. A UMD bundle is also built to `dist`, which can be included without the need for any build system.
46
+
-[Migration to v4](https://react-chartjs-2.netlify.app/docs/migration-to-v4)
47
+
-[Working with datasets](https://react-chartjs-2.netlify.app/docs/working-with-datasets)
48
+
-[Working with events](https://react-chartjs-2.netlify.app/docs/events)
0 commit comments