File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 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
8585Chart.js instance can be accessed by placing a ref to the element as:
8686
8787``` js
88- chartReference = {};
88+ class MyComponent extends React .Component {
89+ constructor (props ) {
90+ super (props);
91+ this .chartReference = React .createRef ();
92+ }
8993
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+ }
9397
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+ }
96101}
97102```
98103
You can’t perform that action at this time.
0 commit comments