Passing the values to y-axis series like below:
this.chartOptions = {
series: [
{
type: 'line',
data: [
[0,38.6],
[0,49.8],
[1,39.2],
[1,41.1],
[1,46.6],
[2,44]
],
color: '#004191',
showInLegend: false,
name: 'price',
threshold: 40,
negativeColor: '#F34336',
marker: {
enabled: true,
radius: 3,
symbol: 'circle',
},
},
],
title: {
text: '',
},
xAxis: {
title: {
text: 'Days',
},
categories: ["16-Jan", "15-Jan", "14-Jan"],
},
yAxis: {
title: {
text: 'price',
},
gridLineWidth: 1,
min: 10,
max: 100,
tickPixelInterval: 35,
},
exporting: {
enabled: false,
showTable: false,
buttons: {
contextButton: {
menuItems: ['downloadPDF'],
},
},
},
credits: {
enabled: false,
},
};
But the issue is the multiple values are rendering in the view but the values are not displayed in the tooltip on mouse hover of particular value.
Case: When I hover on 49.8 it shows tooltip but won't show for 38.6. Even though they belongs to 1st series of y-axis.
Soution required:
Attaching stackblitz ref
This is possible to achive by following steps:
First, instead of the line series, use scatter type. Set lineWidth: 2
just to simulate line series.
Next, adjust the tooltip via headerFormat
(to use identical as original line series) and more advanced pointFormatter
:
tooltip: {
headerFormat: '<span style="font-size: 0.8em">{point.key}</span><br/>',
pointFormatter() {
let pointFormat = '',
hoveredPoint = this;
this.series.points.forEach(point => {
if (point.x === hoveredPoint.x) {
pointFormat += `<span style=\"color:${point.color}\">●</span> ${point.series.name}: <b>${point.y}</b><br/>`
}
})
return pointFormat
}
},
Demo: https://jsfiddle.net/BlackLabel/ts7bcjwo/
API Reference: https://api.highcharts.com/highcharts/tooltip.pointFormatter