chart.js load totally new data

前端 未结 20 1467
有刺的猬
有刺的猬 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:31

    When creating the chart object you need to save the instance in a variable.

    var currentChart = new Chart(ctx, ...);
    

    And before loading new data, you need to destroy it:

    currentChart.destroy();
    

提交回复
热议问题