You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by Stephen Rich <st...@bri-associates.com> on 2020/03/07 20:55:14 UTC

Question about saving interactive chart state

Hello,

I am using echarts and wanted to be able to save the interactive state of the chart.  For example, I present a chart to my user with a lot of data one it.  I want them to be able to select which data to see, which echarts supports today.  However, I want the user to hit a save button to save the current state of the chart so that the user does not have to interact with the chart each time it is rendered.  Is there a way to do that?

Thanks for the help!

Stephen

Re: Question about saving interactive chart state

Posted by Yi Shen <sh...@gmail.com>.
Hi Stephen,

You can use chart.getOption[1] method to get the full configuration json.
It includes all the current interactive states except mouse hover.  So you
can use this json in setOption next time.

If you also want the mouse hover state. You can listen to the
`mouseover`[2] events and save the dataIndex and seriesIndex in the event
parameter. Next time you can use dispatchAction({ type: 'highlight' }) [3]
to highlight the hovered elements.

[1] https://echarts.apache.org/en/api.html#echartsInstance.getOption
[2] https://echarts.apache.org/en/api.html#events.Mouse%20events.mouseover
[3] https://echarts.apache.org/en/api.html#echartsInstance.dispatchAction

On Sun, Mar 8, 2020 at 5:54 AM Stephen Rich <st...@bri-associates.com>
wrote:

> Hello,
>
> I am using echarts and wanted to be able to save the interactive state of
> the chart.  For example, I present a chart to my user with a lot of data
> one it.  I want them to be able to select which data to see, which echarts
> supports today.  However, I want the user to hit a save button to save the
> current state of the chart so that the user does not have to interact with
> the chart each time it is rendered.  Is there a way to do that?
>
> Thanks for the help!
>
> Stephen
>


-- 
Yi Shen
Apache ECharts(incubating) PPMC