react-chartjs-2: Defaults creating error
I’m trying to use the { defaults } provided by your wrapper but when I pass these into a <Bar /> I get all kinds of errors. (I am not yet modifying these defaults)
My Code
import { Bar, defaults } from 'react-chartjs-2';
// component level
<Bar redraw data={this.props.chartData} height={300} options={defaults} />
Error in console
core.controller.js:443 Uncaught TypeError: Cannot set property '_data' of undefined
at Chart.Controller.update (core.controller.js:443)
at Chart.Controller.resize (core.controller.js:306)
at eval (core.controller.js:224)
at eval (core.helpers.js:982)
update @ core.controller.js:443
resize @ core.controller.js:306
(anonymous) @ core.controller.js:224
(anonymous) @ core.helpers.js:982
scale.radialLinear.js:113 Uncaught (in promise) TypeError: Cannot read property 'callback' of undefined
at ChartElement.convertTicksToLabels (scale.radialLinear.js:113)
at ChartElement.update (core.scale.js:94)
at getMinimumBoxSize (core.layoutService.js:144)
at Object.helpers.each (core.helpers.js:23)
at Object.update (core.layoutService.js:155)
at Chart.Controller.updateLayout (core.controller.js:381)
at Chart.Controller.initialize (core.controller.js:250)
at new Chart.Controller (core.controller.js:231)
at new Chart (core.js:7)
at ChartComponent.renderChart (index.js:212)
Version Chartjs: v2.4.0
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 40
got the same issue. solve it by change the
"chart.js": "^2.9.4",
in your package.json then delete node modules folder, then in terminal runnpm install
.I was having the same issue, i fixed it going back to version “chart.js”: “^2.9.4” and keeping “react-chartjs-2”: “^2.11.1” @isailaoctavian
Recently i have updated the chart.js and react-chartjs-2 library to the latest version 3.0.0-beta. and i am trying this in my code. import { Doughnut, Line } from ‘react-chartjs-2’; toolDatacli: { labels: [ 'SourceClear ', ‘Hawkeye’, 'Sonarqube ', ’ Glair ', 'Coverity ’
<div class="column">CLI Tools Usage
{toolDatacli && <Doughnut data={toolDatacli} /> } </div>when i start the application i am getting error like TypeError: Cannot read property ‘defaults’ of undefined (anonymous function) D:/GoLang/GoProject/src/git02.ae.sda.corp.telstra.com/pip/svc-dashboard-web/node_modules/react-chartjs-2/es/index.js:643 640 | }(_react[“default”].Component); 641 | 642 | exports.Scatter = Scatter;
I am facing the same issue even with “chart.js”: “^2.9.4”, and “react-chartjs-2”: “^2.11.1”, Cannot read property ‘defaults’ of undefined
It worked, love you man !
solve it by change the “chart.js”: “^2.9.4”
Mee too ! I just downgraded chart.js to ^2.9.4, and it worked, - but the issue is not solved. Please reopen this issue. cheers!
Thanks man!
same issue for me @zeyker tried installing the older version of chart.js but still the same problem