Marius Seiceanu
Posts: 2
Joined: Wed Sep 29, 2021 11:16 am

Chart.update with oneToOne removes series when updating axes

Hello,

I've upgraded Highcharts from 8.1 to the latest 9.2.2 and the flip axes usecase fails.
Calling `chart.update(updatedConfig, true, true, false)` updates the axis information, but it also removes the series. This is unexpected becase the `updatedConfig` object does not have the `series` field.

It turns out that the problem is related to the axis `id` field. `chart.update` removes the series (and sometimes the axes) if the `axis.id` is not empty.

The minimal code to reproduce the problem:
https://jsfiddle.net/mariusseiceanu/kuozy207/9/

Test results with different configurations
1. Initial Config
xAxis - no id
yAxis - no id
Update with
xAxis - no id
yAxis - no id
OK - Axis updated
OK - series untouched

2. Initial Config
xAxis - no id
yAxis - no id
Update with
xAxis - id: 'x1'
yAxis - id: 'y'
OK - Axis updated
OK - series untouched

3. Initial Config
xAxis - id: 'x'
yAxis - id: 'y'
Update with
xAxis - no id
yAxis - no id
OK - Axis updated
OK - series untouched

4. Initial Config
xAxis - id: 'x'
yAxis - id: 'y'
Update with
xAxis - id: 'x'
yAxis - id: 'y'
OK - Axis updated
OK - series untouched

5. Initial Config
xAxis - id: 'x'
yAxis - id: 'y'
Update with different axis id
xAxis - id: 'x1'
yAxis - id: 'y1'
OK - Axis updated
ERR - series removed

6. Initial Config
xAxis - id: 'x'
yAxis - id: 'y'
Update with flipped axis id
xAxis - id: 'y'
yAxis - id: 'x'
ERR - Axis removed
ERR - series removed
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Chart.update with oneToOne removes series when updating axes

Hello Marius Seiceanu,

Welcome to our forum and thanks for contacting us with your issue!

In the beginning I just wanted to say huge thanks for that demo and elaborated tests with results, that was really helpful.

Regarding the issue itself, there are two crucial things that I need to point out.
First one is the order of events when chart is being updated:
1. Firstly all new elements (axes, series, etc) are added to the chart.
2. Then all old elements are being removed.

Second crucial thing to know is that series in most cases cannot exist without axes.

Having said that, in your fifth example, firstly your new axes are added and then old axes are being removed with linked to them series. It is not a bug, but it is not explicitly stated in our documentation, so some users might find it confusing. In this case, you should not only add new axes, but also update the config of initial series making sure that they are linked to new axes.
Demo: https://jsfiddle.net/BlackLabel/pgjr5h17/

In sixth example event order is even more important, because you try to add new axes with IDs that already exist. It should be said in documentation too, but new axes require unique ID, regardless if it is X or Y axis. What happens here is new axes are not added because of IDs conflict and old ones are being removed with linked series.

I hope it makes a bit more sense now. As I have already said it is not a bug, documentation should be more specific though.

Let me know if you have any further questions!
Best regards!
Mateusz Bernacik
Highcharts Developer
Marius Seiceanu
Posts: 2
Joined: Wed Sep 29, 2021 11:16 am

Re: Chart.update with oneToOne removes series when updating axes

Hello mateusz.b,

Thank you for the clarifications. I really missed this information in the chart.update documentation (it would have saved me a day of debugging :) ).

Although I posted all the examples above, I'm trying to implement the scenario from example six. xAxis.id contains the UUID of the Temperature signal and yAxis.id the UUID of the other signal, and I'm trying to flip them.
Is it possible to do this with chart.update?

I'm not saying the problem I reported above this is a bug or not but from my perspective, as a user, the function seems unreliable.
It requires knowing internal implementation details which are not mentioned in the documentation.
* elements are not added because of conflicting IDs but no error is raised. The unique ID across axes rule is not mentioned.
* the function behaves differently when the elements don't have ids (example 1, 2) - the series is not deleted. I understand it now because you mentioned "series in most cases cannot exist without axes" - but this introduces more confusion

Without updated documentation or function changes, other users may have the same problem.

Best Regards,
Marius.
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Chart.update with oneToOne removes series when updating axes

Hello Marius,

Flipping axes like in your example might be hard to achieve. You should try to split your code and update only one axis per chart.update in this case. Something like that should do the trick.

When it comes to the documentation I completely agree that it should be more clear and contain all crucial informations. I will create a githube issue for this purpose and soon we should see docks updated.

Best regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Usage”