Access to echarts setOption args #1900
Replies: 9 comments
-
Adding support for all methods might get out of hand. Does it maybe make sense to add a more generic method similar to |
Beta Was this translation helpful? Give feedback.
-
Oh wow, this is a serious bug I think. I didn't expect such problems with updating the chart options. It seems related to #1789 where we have similar problems with Highcharts. We could set Sure, we could also provide access to |
Beta Was this translation helpful? Give feedback.
-
Having A generic Thanks for your replies! |
Beta Was this translation helpful? Give feedback.
-
I just experimented with this more compact reproduction: chart = ui.echart({
'xAxis': {'type': 'category'},
'yAxis': {'type': 'value'},
'series': [{'type': 'line', 'data': [0]}],
})
ui.button('Set two', on_click=lambda: (
chart.options.update(series=[{'type': 'line', 'data': [1]}, {'type': 'line', 'data': [2]}]),
chart.update(),
))
ui.button('Set one', on_click=lambda: (
chart.options.update(series=[{'type': 'line', 'data': [3]}]),
chart.update(),
)) Updating with this.chart.setOption(this.options, { notMerge: true }); seems to help. So what do you think, should we use this option by default? this.chart.setOption(this.options, { notMerge: this.chart.options.series.length != this.options.series.length }); |
Beta Was this translation helpful? Give feedback.
-
Glad to hear setting I think having this default makes the most sense & leads to the most intuitive use of the function. Can't speak to whether having that condition will lead to better performance or not, but I don't think there is a downside to it. |
Beta Was this translation helpful? Give feedback.
-
Ok, I implemented and merged PR #2068 with |
Beta Was this translation helpful? Give feedback.
-
@mq-evan Do you think we can close this feature request after PR #2068 has been released? Or do we still need a more flexible solution? |
Beta Was this translation helpful? Give feedback.
-
The current implementation is now sufficient for my use case, thank you for your help! In my opinion this makes it much more intuitive and easy to use. There definitely could be benefit to having access to a generic |
Beta Was this translation helpful? Give feedback.
-
We just merged PR #2232, which introduces |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
With the existing implementation of echarts, I don't believe it is possible to access args for setOption, which is the echarts API command that is run when changing the options of an existing echart and calling .update().
Access to the args for setOption would allow manipulation of notMerge and replaceMerge, which are described in the echarts documentation here.
Without access to these args, it is impossible to clear existing series of data in a plot without replacing it with a new series. This results in unwanted plots remaining when wanting to plot different things at different times using the same ui.echarts() element.
Below is some code to highlight the issue. Pressing "Add to chart 1" then "Add to chart 2" causes "Add to chart 1"s second data series to remain. Two attempts at clearing the existing data series given, however the first option leaves the legend behind and the second does not clear the chart.
Similarly, it may also be useful to have access to the .clear method of the echarts object, described in the documentation here.
Please let me know if I am missing anything obvious!
Thanks
Beta Was this translation helpful? Give feedback.
All reactions