Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts - Draw Crosshairs / Tooltip on Mouse Position Instead of Snapping to Data Point

Here (see this jsfiddle) you can see the 2-dimensional crosshairs are snapping to the datapoint that is closest to it. How would you make the crosshairs and tooltip correspond to the current mouse position on the chart?

tooltip: {
  crosshairs: [true, true]
}
like image 806
idrinkpabst Avatar asked May 29 '13 02:05

idrinkpabst


2 Answers

jsFiddle Solution

I ended up binding my own mousemove event to get the constantly changing mouse position within the graph for the crosshairs. For the tooltip i just used:

tooltip: {
            shared: true,
            followPointer: true
        },

This should be more than enough to get you going.

like image 112
ctb3 Avatar answered Nov 14 '22 22:11

ctb3


Unfortunately crosshair works only in this way, but you can prepare your own solution by mouseOver and mouseOut events and add draw line by renderer.

http://api.highcharts.com/highcharts#plotOptions.series.events.mouseOver http://api.highcharts.com/highcharts#plotOptions.series.events.mouseOut

http://api.highcharts.com/highcharts#Renderer

like image 25
Sebastian Bochan Avatar answered Nov 14 '22 21:11

Sebastian Bochan