React-chartjs-2: TypeError when rendering a Pie chart

Created on 11 Apr 2017  路  1Comment  路  Source: reactchartjs/react-chartjs-2

I'm getting the following error:

Chart.js:30 Uncaught TypeError: Cannot read property 'offsetWidth' of undefined
    at computeDimension (Chart.js:30)
    at new Chart (Chart.js:40)
    at ChartComponent.renderChart (index.js:227)
    at ChartComponent.componentDidMount (index.js:77)
    at ReactCompositeComponent.js:265
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponent.js:264
    at CallbackQueue.notifyAll (CallbackQueue.js:76)
    at ReactReconcileTransaction.close (ReactReconcileTransaction.js:80)
    at ReactReconcileTransaction.closeAll (Transaction.js:206)

Looking through the functions referenced in the stack trace, it looks like the canvas element couldn't be found in the dom.

I'm using the chart exactly as in the examples, and I have no idea what might be different between my app and the examples app that might be causing this difference. Could the way webpack bundles things cause issues?

Most helpful comment

Turns out I had an older version of chartjs installed. Upgraded to the latest version, and now it works.

>All comments

Turns out I had an older version of chartjs installed. Upgraded to the latest version, and now it works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

souuu picture souuu  路  4Comments

justinmasse picture justinmasse  路  3Comments

alphakennyn picture alphakennyn  路  3Comments

jbbae picture jbbae  路  5Comments

davidcalhoun picture davidcalhoun  路  5Comments