ejectamenta
ejectamenta

Reputation: 1097

Why highstock charts have two yAxis?

if you examine the number of Highstock yAxis objects there are two however for a standard bar chart there is one

I am a bit confused why the two yAxis objects and what they relate to, the existence of the two yAxes can be seen in the jsfiddle by adding the alert call

alert(chart.yAxis.length);

at line 93 just before the click handler

It also seems that when you add data series there are always 1 more yAxis than data series.

Upvotes: 1

Views: 144

Answers (2)

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

For simple Highstock charts there will be two of each axis. The first one is for the chart, as usual, and the second one is for the navigator which comes with Highstock and appears below the chart.

  • If you add more axis in the constructor options the navigator will be the last index in the chart.xAxis and chart.yAxis arrays.

  • If you add more axis dynamically after creation (using chart.addAxis) they will be added to the end of the array, so navigator will remain at it's original index.

Settings for the navigator axis is usually set through navigator.xAxis and navigator.yAxis.

Upvotes: 3

ejectamenta
ejectamenta

Reputation: 1097

By looking at the yAxis height it seems that the second yAxis (yAxis[1]) is for the navigator window below the chart. So the chart yAxis relating to the data series are at yAxis[0], yAxis[2] yAxis[3] ... etc.

debugger output

line.plot.yAxis[0].height
229
line.plot.yAxis[1].height
40
line.plot.yAxis[2].height
229

Upvotes: 1

Related Questions