I’ve recently started using highcharts javascript library and came across a situation where i’m supposed to add a secondary y-axis to the existing line chart. Here is an example from the highcharts website that is similar to the chart i’m working on ==>
Line chart
What i’m trying to do is to add a 2nd y-axis to the right with color blue and with tick values 0, 1, 2 and 3 on alternate lines. This seems easy and tried in the following way but could not succeed
yAxis: [{
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: 'red'
}]
}, {
title: {
text: 'Temperature (F)'
},
plotLines: [{
value: 0,
width: 1,
color: 'blue'
}]
}],
Pls guide me. Thanks in advance
See this documentation and this demo. Note you do not have to make the axis opposite the chart from each other. You can use offset for same-side axis.
The trick is you need a list of multiple axes settings, and the series needs to identify which zero-based axis it uses:
(edits: Doc needs link to xAxis.opposite since yAxis.opposite is missing, added copy of jsfiddle code, added note about multiple axes.)