TypeError when setting new data that has less labels than original number of labels
If you update data and the new data has less labels than the previous number of labels you get the error:
TypeError: Cannot set property 'value' of undefined
Its related to the line
chart.datasets[setIndex][dataKey][pointIndex].value = val;
Should probably trigger a redraw...
I have had this issue as well, I added redraw as per the docs
if data passed into the component changes, points will animate between values using chart.js' .update(). If you want the chart destroyed and redrawn on every change, pass in redraw as a prop. For example <LineChart data={this.state.chartData} redraw />
If you want to make this dynamic please submit a PR.
I made a component for Chart.js from scratch. I destroy an old instance and re-initialize a chart on componentWillUnmount rather than componentWillReceiveProps. Also, I replace the whole data every time the component is provided with new data. This way, we can keep our code simple. I share with you a simple helper method I wrote to generate a chart component class.
Please check out InteractiveChartComponent.