I try to format the xAxis crosshair label, but the default one always overlap the formatted one. In the example, how can I have only the RED label? Or in other words, how can we format this xAxis crosshair label with HighStock (the behaviour seems to be different from HighCharts).
Second question: Why do the xAxis labels show 0,1,2,3, and not 1,2,3,4 as specified in the serie?
Highcharts.stockChart('container', {
xAxis: {
title: {
text: 'Price'
},
ordinal: false,
labels: { formatter: function () {return this.value;}},
crosshair: {
width: 0.5,
color: 'black',
label: {
backgroundColor: 'rgb(255,0,0)',
formatter: function (value) {
return 'this is a long label: '+value;
},
enabled: true,
padding: 8
}
}
},
yAxis: {
labels: {
formatter: function () {
return this.value + ' units';
}
}
},
rangeSelector: {
enabled: false
},
navigator: {
enabled: false
},
series: [{
type: 'areaspline',
data: [['1',1],['2',3],['3',1],['4',4]]
}]
});
Here JSFiddle example
The second label is a tooltip header, to disable it set:
As to your second question: strings in your data format are treated as point names, so instead of:
Set:
Live demo: https://jsfiddle.net/BlackLabel/1g4m2ka8/
API Reference: https://api.highcharts.com/highstock/tooltip.headerFormat