Explantation
This is a tricky one. If data is set async it can actually happen that one sets an invalid object for the chart data. This leads to errors flooding the console when hovering over the chart or at least throws when chart.js tries to set up the labels. AFAIK what happens is that hasData is bypassed:
Set valid chart data. Everything is fine. The element set's hasData to true and queues the async update callback.
Immediately set data to an empty object. The internal async update callback hasn't run at this point.
The update callback is eventually executed and sets the modified empty data object => error
The solution in my tests seems to be that we need to check hasData in the last async callback again to make sure.
Demo of the issue Load and look at console. It should produce errors when you hover over the chart. Maybe need some tries to reproduce. https://jsbin.com/gequnosihe/1/edit?html,output
Explantation This is a tricky one. If
data
is set async it can actually happen that one sets an invalid object for the chart data. This leads to errors flooding the console when hovering over the chart or at least throws when chart.js tries to set up the labels. AFAIK what happens is thathasData
is bypassed:hasData
to true and queues theasync
update callback.data
to an empty object. The internal async update callback hasn't run at this point.The solution in my tests seems to be that we need to check
hasData
in the last async callback again to make sure.Can you guys confirm? /@robdodson /@Stormsys