File tree 1 file changed +11
-6
lines changed
1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change @@ -85,14 +85,19 @@ In order for Chart.js to obey the custom size you need to set `maintainAspectRat
85
85
Chart.js instance can be accessed by placing a ref to the element as:
86
86
87
87
``` js
88
- chartReference = {};
88
+ class MyComponent extends React .Component {
89
+ constructor (props ) {
90
+ super (props);
91
+ this .chartReference = React .createRef ();
92
+ }
89
93
90
- componentDidMount () {
91
- console .log (this .chartReference ); // returns a Chart.js instance reference
92
- }
94
+ componentDidMount () {
95
+ console .log (this .chartReference ); // returns a Chart.js instance reference
96
+ }
93
97
94
- render () {
95
- return (< Doughnut ref= {(reference ) => this .chartReference = reference } data= {data} / > )
98
+ render () {
99
+ return (< Doughnut ref= {this .chartReference } data= {data} options= {options} / > )
100
+ }
96
101
}
97
102
```
98
103
You can’t perform that action at this time.
0 commit comments