0👍
You correctly defined chart_day
globally and even commented it as follows:
global variables – so that chartjs doesn’t show old data on hover
The problem however lies in your dayChart
function. Instead of using the globally defined chart_day
variable, you defined an identically named variable in the local scope of the function.
The solution would be to replace the following code block:
var chart_day = new Chart (ctx_day, config)
if (chart_day) {
chart_day.destroy();
chart_day = new Chart (ctx_day, config);
chart_day.update();
}
…with this one:
if (chart_day) {
chart_day.destroy();
}
chart_day = new Chart (ctx_day, config);
- Chartjs-React-Chartjs-2 and Chartjs v3:Option Property
- Chartjs-Data with x and y data, missing data are not taken into account
Source:stackexchange.com