Skip to content
Advertisement

How to render a vertical line when the mouse cursor is on the chart using highcharts?

I have been working on a web application which used Highcharts for charting data. As such, one of the requirement is that when I hover my mouse on the chart (screenshot below – assuming the arrow is the mouse cursor), a vertical line will automatically display of where the mouse cursor was. Aside from that, the vertical line will also move along the x-axis as the mouse cursor moves sideways within the chart.

This is the sample chart.

enter image description here

This is my highchart configuration script:

JavaScript

I browsed through the Highcharts API and I can’t find the exact method or configuration to make that happen. Is this doable in Highchart? How can I achieve this?

Advertisement

Answer

Try setting your tooltip crosshairs

JavaScript

Or as @IronGeek wrote, use xAxis.CrossHairs

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement