Skip to content

Commit c15fc5b

Browse files
authored
Updated README
- Added documentation for the `defaults` object. - Updated naming references to Chart.js from Chart and ChartJS
1 parent 5ce6084 commit c15fc5b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# react-chartjs-2
44

5-
React wrapper for [ChartJs 2](http://www.chartjs.org/docs/#getting-started)
5+
React wrapper for [Chart.js 2](http://www.chartjs.org/docs/#getting-started)
66
Open for PR's and contributions!
77

88

@@ -61,8 +61,8 @@ In order for Chart.js to obey the custom size you need to set `maintainAspectRat
6161
/>
6262
```
6363

64-
### Chart instance
65-
Chart instance can be accessed by placing a ref to the element as:
64+
### Chart.js instance
65+
Chart.js instance can be accessed by placing a ref to the element as:
6666

6767
```
6868
render() {
@@ -75,6 +75,34 @@ render() {
7575
}
7676
```
7777

78+
### Chart.js Defaults
79+
Chart.js defaults can be set by importing the `defaults` object:
80+
81+
```javascript
82+
import { defaults } from 'react-chartjs-2';
83+
84+
// Disable animating charts by default.
85+
defaults.global.animation = false;
86+
```
87+
88+
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.
89+
90+
```javascript
91+
import { defaults } from 'react-chartjs-2';
92+
import merge from 'lodash.merge';
93+
// or
94+
// import { merge } from 'lodash';
95+
96+
merge(defaults, {
97+
global: {
98+
animation: false,
99+
line: {
100+
borderColor: '#F85F73',
101+
},
102+
},
103+
});
104+
```
105+
78106
### Events
79107

80108
#### onElementsClick (function)

0 commit comments

Comments
 (0)