score:1

Accepted answer

you don't need to call buildchartobject(...) again when you are trying to just update the data for the chart. if you held onto a reference of the chart you would be fine to skip that call. doing this will allow chart.js to just update the chart when you call chart.update() instead of creating a new chart and then updating it.

...

let returnschart = buildchartobject($('#chart'), 'bar', timeaxis, percentaxis);

let loadcharts = function () {
    let params = {
        convertto: $('#convert-to').val()
    };
    loadchartdata('endpoint', returnschart, params);
}

loadcharts();

$('#convert-to').on('change', function() {
    loadcharts();
});

...

Related Query

More Query from same tag