chart.js load totally new data

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

    ChartJS 2.6 supports data reference replacement (see Note in update(config) documentation). So when you have your Chart, you could basically just do this:

    myChart.data.labels = ['1am', '2am', '3am', '4am'];
    myChart.data.datasets[0].data = [0, 12, 35, 36];
    myChart.update();
    

    It doesn't do the animation you'd get from adding points, but existing points on the graph will be animated.

提交回复
热议问题