chart.js load totally new data

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

    It is an old thread, but in the current version (as of 1-feb-2017), it easy to replace datasets plotted on chart.js:

    suppose your new x-axis values are in array x and y-axis values are in array y, you can use below code to update the chart.

    var x = [1,2,3];
    var y = [1,1,1];
    
    chart.data.datasets[0].data = y;
    chart.data.labels = x;
    
    chart.update();
    

提交回复
热议问题