score: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);

Related Query

More Query from same tag