Reputation: 43
How to display the same data points in the same series in highcharts ?
Please refer below example
https://jsfiddle.net/skoormala/1wq603rs/3/
series: [{
name: 'Property',
data: [{"name":"Property 1", "x":1,"y":2},
**{"name":"Property 2", "x":2,"y":5}**,
**{"name":"Property 5", "x":2,"y":5},**
{"name":"Property 3", "x":3,"y":6},
{"name":"Property 4", "x":4,"y":8}]
}]
In the above series property 2 and property 5 has the same coordinates please advise how to display them in a tooltip on mouse hover
Upvotes: 0
Views: 58
Reputation: 39069
The tooltip.shared
property works only for points with different series, for a single series you can use the pointFormatter
function to build a tooltip according to your requirements, for example:
tooltip: {
pointFormatter: function() {
const x = this.x,
y = this.y;
const points = this.series.points.filter(p => p.x === x && p.y === y);
const pointNames = points.reduce(
(result, point) => ((result ? result + ', ' : '') + point.name),
''
);
return pointNames + '<br/>' + 'x: ' + x + '<br/>y: ' + y
}
}
Live demo: https://jsfiddle.net/BlackLabel/og2jwms0/
API Reference: https://api.highcharts.com/highcharts/tooltip.pointFormatter
Upvotes: 1