Incubator-echarts: how do I clear a chart? Basically I need to re-initialize it.

Created on 13 Apr 2018  ·  4Comments  ·  Source: apache/incubator-echarts

I have several charts on a single page, and each chart changes based on what the user selects. I have an ajax call that retrieves the data, so the data varies and is dynamic based on users selection. I'm having a problem clearing out old data. Basically, I just want after each selection to re-initialize the chart and start from scratch. How can I do that?

It seems that now, when the user deselects a metric, the chart retains that old information. I've tried setting data to null, or empty array, but nothing seems to work.

Most helpful comment

setOption(newOption, true) will clear the previous data and use the new one.

All 4 comments

setOption(newOption, true) will clear the previous data and use the new one.

。。。老大你怎么只回答老外的问题

setOption(newOption, true) is still leaving old data on the chart.

mychart.clear()

Was this page helpful?
0 / 5 - 0 ratings