It should be possible to initialize a chart with an empty dataset and then immediately populate it afterward.
The devil of this is that the error will only occur if the speed of the dataset population is done immediately after the chart object is created. I enabled caching on my back end ajax provider and chartjs stopped working – it turns out that the slow speed of my ajax provider was masking this problem.
In Safari the error is:
null is not an object (evaluating 'this.getDatasetMeta(e).controller.transition')
In Chrome the error is:
Cannot read property 'transition' of null
- Disabling animation on the chart solves this error.
- Rendering the chart immediately after populating the dataset also seems to solve the error, but neither should be required.
Steps to Reproduce (for bugs)
- See fiddle: https://jsfiddle.net/s49pmgru/
- Uncomment either the
animation optionsor the
myChart.update()line to make the error go away.