chart.js load totally new data

前端 未结 20 1470
有刺的猬
有刺的猬 2020-11-28 21:12

The API for chart.js allows one to edit points of the datasets loaded into it, for example:

.update( )

Calling update() on

20条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 21:40

    Not is necesary destroy the chart. Try with this

    function removeData(chart) {
    
            let total = chart.data.labels.length;
    
            while (total >= 0) {
                chart.data.labels.pop();
                chart.data.datasets[0].data.pop();
                total--;
            }
    
            chart.update();
        }
    

提交回复
热议问题