reactjs / react-chartjs

common react charting components using chart.js
MIT License
2.93k stars 299 forks source link

Cannot read property 'Chart' of undefined #93

Open donnrri opened 8 years ago

donnrri commented 8 years ago

Hi,

I cannot find many details as to why I am getting an error when trying to render a chart using react-chartjs. I'm using react v0.13 and webpack. I use the following code :

var LineChart = require("react-chartjs").Line; var React = require('react');

var LChart = React.createClass({

propTypes: { data: React.PropTypes.object }, render: function() {

return <LineChart data={this.props.data} options={this.props.options} width="600" height="250"/>

} });

module.exports = LChart;

but when I use this component within my app I get the error Cannot read property 'Chart' of undefined line 10 Chart.js . Is this a commonly found error and I am missing the solution somewhere ? Thanks for any comments

danmolitor commented 8 years ago

Did you specifically run "npm install chart.js" in your terminal when you installed react-chartjs?

Qquanwei commented 8 years ago

I installed the chart.js, but the problems still exist

hydrotik commented 8 years ago

Make sure you install npm install chart.js --save not npm install chartjs --save I did that myself and got that error, realizing the package was wrong when trying to manually adjust it in the module.

JamieDixon commented 8 years ago

I'm receiving this same error Uncaught TypeError: Cannot read property 'Chart' of undefined with chart.js@^1.1.1 installed. Any ideas?

jbarata commented 8 years ago

same problem here

yeliex commented 8 years ago

++ @jhudson8

nickstanish commented 8 years ago

Same issue. Excluding node_modules from babel-loader fixed it.

module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules)/,
        loader: 'babel-loader'
      }
    ]
  }
BabOuDev commented 8 years ago

+1

Baluhariharan commented 8 years ago

+1

jakubkoci commented 8 years ago

I had the same problem, but as @nickstanish suggested in his response, node_modules exclusion in Webpack solved this. Thanks.

emirdeliz commented 7 years ago

Thanks @nickstanish works for me!

ismatim commented 6 years ago

In my case was the incorrect version installed 1.1. should be ^2.

UPDATE: The error was quite different Cannot read property 'bar' of undefined