What problem does this feature solve?
We are using setOption with replaceMerge option to add /remove series and associated axis. The issue is that we do not control the index at which the series or axis will end up after the replaceMerge process. For exemple we realized that when you remove an axis Echarts leaves a holes in the option variable with undefined. The next time we add an axis Echart will use this hole for the new axis. So its index will not be the last axix index + 1 but will be the hole's index. This mecanism is not documented so there is no way to set a proper YAxisIndex.
What does the proposed API look like?
This is why we propose to add YAxisId in the propoertires of series. The same for XAxis index and for GridIndex for XAxix.
In a more general way, references to elements in Echarts should be done by ids instead of indexes.
7条答案
按热度按时间du7egjpx1#
The issue is that we do not control the index at which the series or axis will end up after the replaceMerge process.
Why not? Find axis indexes from IDs, series are replaced by id already - Demo Code
NB: please close issue if problem solved.
v64noz0r2#
Hello,
Thanks for your answer. I undesrtood the sample code but our case is a litte bit different so let me explain better.
If we want to add a new serie to a graph we need first to create the Yaxis then to create the Series and reference the series to the YAxisIndex parameters.
Using the setOption with replaceMerge option the code would be the following:
So you see here the problem we are facing : We need to know before its creation the Yaxis index at which the YAxis will be positionned by Echarts. And we do not know how Echart will decide it.
So it would be much simpler to define yAxisId instead of yAxisIndex in the option object !
This would also improve the architecture of Echart : Ids on the application side, Indexes hidden in the realm of Echarts code.
Thanks for your help.
fkvaft9z3#
First, I agree 100% about a feature request to define yAxisId (or xAxisId) in series, would be useful.
But here and now, we are looking for solutions to present problems. For instance gridIndex and replace_merge_elements are undefined, and I have no idea how many grids and series you want to add. If you expand your code to a real Minimal Reproduction, maybe we can find a workaround that works today.
vdzxcuhz4#
Thank you very much for your response.
For completeness we would need to get :
For the time being we guess that the way Echarts sets grids and axis indexes follows the hereunder rules:
It seems to work. But we would be pleased to know if these rules are exact and if there are or not other rules.
Regards.
fnx2tebb5#
It seems to work.
No way to know how it works for you without sample code...
We see the exact opposite happening - series and axes positions are changing on delete and added elements are appended.
Demo Code - follow title instructions to test.
The example shows how to add/delete pairs of axis/series using only seriesIndex and seriesName.
Please close issue if solution is satisfactory.
j7dteeu86#
The link does not seem to work.
Anyway, this is quite an issue to have an API relying on indexes and not being able to know what the indexes will be when we are setting up a new option object...
For very simple cases as in the examples it works, but as soon as you try to make more elaborate applications (more advanced setOption) you are stucked.
Thanks for your understanding.
ffdz8vbo7#
link fixed