HansR
Posts: 62
Joined: Fri Jan 01, 2021 9:44 am
Location: NL
Contact: Website

addAxis issue

Hi,

Main issue:
I am working on some kind of graph compiler which accepts a description like this

Code: Select all

Chart Temperature Title Temperature Inclusive Inside
  PLOT Temperature	As	spLine Colour	Blue zIndex	90
EndCHART

Chart Pressure Title Sealevel Pressure
  PLOT pressure	As	spLine Colour	green zIndex	90
EndCHART
and generates code like in this jsfiddle. It works fine - you can see it work here, use the drop down to change charts - but if you switch between graphs and back, it creates multiple axis. I tried a lot of things but I can not make this effect disappear.

As the chart object is local (assigned with a let statement) I assume it disappears by the garbage collector when a new one is created. Apparently that does not hold for its axis (and other attached objects) or only after some time.

What can I do to prevent this effect? What do I do wrong?
I tried to remove the axis after creating the new chart object but it does not know them so in a way they are ghost-axis.

second issue:
I don't seem to get the opposite axis with the labels. What is the problem here?

Kind regards,
Hans
HansR
HansR
Posts: 62
Joined: Fri Jan 01, 2021 9:44 am
Location: NL
Contact: Website

Re: addAxis issue

Note: I modified the jsfiddle slightly to - if possible - remove the axis before creating a new chart.
That does not help.
HansR
HansR
Posts: 62
Joined: Fri Jan 01, 2021 9:44 am
Location: NL
Contact: Website

Re: addAxis issue

OK. I solved the issue myself.

The problem was in the fact that when you create a chart it ALWAYS already has a yAxis, even if you don't define one. That means that handling the axis (adding/removing/defining) is always is different for the first axis. A bit unexpected but I can live with it.

To clarify: I had expected a chart with no yAxis defined in the original options (my t variable) would indeed have no yAxis at all and would require the user to always define one or get an error condition.
HansR
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: addAxis issue

Hello HansR!

You're right when we create a chart, the yAxis is also created. Congrats on finding the solution.

In case of any further questions, feel free to contact us again.
Dominik Chudy
Highcharts Developer

Return to “Highcharts Stock”