ehcarts Uncaught Error: series.type should be specified

最近在看echarts.js,有个实例是做动态曲线图的。结果碰到下面的问题:Uncaught Error: series.type should be specified

ehcarts Uncaught Error: series.type should be specified

明明没加定时器的时候,静态数据是好的呀。

ehcarts Uncaught Error: series.type should be specified

怎么加上之后反而报错?仔细查看定时器那部分代码,发现原来问题出在更新数据上。

ehcarts Uncaught Error: series.type should be specified

这里数据只是将data更新了,但是option其余的设置并没有,所以需要先执行一遍:myChart.setOption(option);

ehcarts Uncaught Error: series.type should be specified

可以正常展示了,over!

ehcarts Uncaught Error: series.type should be specified

原demo地址:https://www.echartsjs.com/gallery/editor.html?c=doc-example/tutorial-dynamic-data