2

when i run the server..this component is loaded ...no errors found on server side...but browser console gives back a following error :

Uncaught TypeError: (intermediate value)[chartType] is not a function

my code is as follows :

var React = require('react');
var ReactDOM = require('react-dom');
var chart = require('chart.js');
var DoughnutChart = require("react-chartjs").Doughnut;
var Tempvshum = React.createClass({
  render() {
    var chartOptions = {
    segmentShowStroke : true
  };
var chartData = [{
    value: 300,
    color:"#F7464A",
    highlight: "#FF5A5E",
    label: "Red"
  }];
   return(<DoughnutChart data={chartData} options={chartOptions} />);
   }
  });
module.exports = Tempvshum;
1
  • I am working on a react-chartjs component right now as well and am receiving this same error....I've confirmed that both react-chart and its dependency chart.js are loaded, and have tried different versions as well. Does anyone have any idea? var chart = new Chart(ctx)[chartType](nextProps.data, nextProps.options || {}); Seems that this is the line that is causing the problem from react-chart Commented Apr 10, 2016 at 19:38

1 Answer 1

5

I think the issue is related to chart.js.

https://www.npmjs.com/package/chart.js says that the package has been uploaded 2 days ago and it is now in version 2.0.0-beta2. I modified my package.json to use the older version 1.1.1 and everything works.

Sign up to request clarification or add additional context in comments.

3 Comments

interesting, i'll try that. This could be related to the recent release of React 15.0.1, 4/8/2016 according to npm view [email protected] time
I was also experiencing this issue and when I went back down to 1.1.1 everything was fine. Currently react-chartjs does not support chartjs v 2.0, but there is an active branch for v2.0 development that will be merged when ready: github.com/jhudson8/react-chartjs/tree/chartjs-v2
github.com/jerairrest/react-chartjs-2 This will save you lots of hair pulling hours.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.