You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
Repository navigation
This repository was archived by the owner on Jul 19, 2019. It is now read-only.
Uncaught TypeError: Chart is not a constructor #100
I'm having trouble getting this working in my project, and I'm hoping I'm missing something obvious.
When I include the dist folder in my React/Reduc project, and open a view that includes some simple example code, I'm getting the following error within the react-chart.js file on the browser:
react-chartjs.js:143 Uncaught TypeError: Chart is not a constructor
Code in question, with > next to line causing issue:
classData.initializeChart = function(nextProps) {
var Chart = __webpack_require__(5);
var el = ReactDOM.findDOMNode(this);
var ctx = el.getContext("2d");
> var chart = new Chart(ctx)[chartType](nextProps.data, nextProps.options || {});
this.state.chart = chart;
};
Chart seems to be getting initialised to the literal integer value 3.
The react-chartjs.js file being downloaded to the browser is the file created by npm run build. I think I'm missing some basic webpack step (which I'm new to) perhaps? Any pointers?
If I butcher the react-chart.js file with some diagnostics, I notice that __WEBPACK_EXTERNAL_MODULE_5__ is getting passed in as the value 3 - I must be doing something wrong with my includes - I'll carry on investigating and update here.
OK, so found seemingly related issue over in angular-chart.js, whereby they tweaked the require calls to work around a requirejs issue - see jtblin/angular-chart.js#194.
I made the following change and the chart is now appearing. I'll carry on investigating - not sure if this is a workaround masking some underlying issue in my code.
Still not 100% sure this isn't a problem with my code, so I won't submit a PR now - but would be interested to hear if others experience this issue - judging by lack of people reporting it, I'm suspecting it's just me.
Another thing - we're starting to think this may be to do with the fact we're using Dojo to load libraries - anyone else whose experiencing this issue, are you using Dojo?
Activity
leighghunt commentedon Apr 10, 2016
If I butcher the react-chart.js file with some diagnostics, I notice that
__WEBPACK_EXTERNAL_MODULE_5__is getting passed in as the value3- I must be doing something wrong with my includes - I'll carry on investigating and update here.leighghunt commentedon Apr 10, 2016
OK, so found seemingly related issue over in angular-chart.js, whereby they tweaked the require calls to work around a requirejs issue - see jtblin/angular-chart.js#194.
I made the following change and the chart is now appearing. I'll carry on investigating - not sure if this is a workaround masking some underlying issue in my code.
leighghunt commentedon Apr 11, 2016
I've confirmed that the following change resolves the issue for me:
venari@f0639fa
Still not 100% sure this isn't a problem with my code, so I won't submit a PR now - but would be interested to hear if others experience this issue - judging by lack of people reporting it, I'm suspecting it's just me.
gor181 commentedon Apr 11, 2016
Same here, same error.
[-]Having trouble incorporating into project[/-][+]Uncaught TypeError: Chart is not a constructor[/+]leighghunt commentedon Apr 12, 2016
Unfortunately, my workaround doesn't appear to work in the chartjs-v2 branch. 😞
austinpray commentedon Apr 14, 2016
Are you trying to use Chartjs v2 with the current release of react-chartjs? The master only works with v1 right now.
gor181 commentedon Apr 14, 2016
Hey @austinpray ,
I apologise I realized that chartJs v1 is required for this to work :)
I think we should add this to readme?
Cheers,
austinpray commentedon Apr 14, 2016
@gor181 shoot a PR over!
This should fix it as well: #104
PolGuixe commentedon Apr 14, 2016
Similar error here:
Can we get this PR: venari@f0639fa in AS SOON AS POSSIBLE. :)
austinpray commentedon Apr 14, 2016
@PolGuixe read the error message. It's telling you exactly what's going on.
Install chartjs 1.x
leighghunt commentedon Apr 15, 2016
Are you trying to use Chartjs v2 with the current release of react-chartjs? The master only works with v1 right now.Hi @austinpray, my intention has been to be matching the two versions - I've been trying the following combinations - see my
package.jsonfile:Version 1 (encountering this issue):
And then my fork, which resolved this issue for me:
Version 2 (encountering the same symptoms as this issue):
leighghunt commentedon Apr 15, 2016
Another thing - we're starting to think this may be to do with the fact we're using Dojo to load libraries - anyone else whose experiencing this issue, are you using Dojo?