dorien dorien - 1 year ago 186
Javascript Question

Preventing crosshair from moving on hover with flot

I have a plot drawn with flot in javascript.

I continuously set the crosshair position so that it is in sync with an audioPlayer.

this.crossHairPos = newAudioPosition;
x: this.crossHairPos

However, when I move my mouse over the plot the crosshair moves to my mouse. I think I should maybe use lockCrosshair, but I haven't succeeded yet:

lockCrosshair({x: this.crossHairPos});

Answer Source

This JSFiddle demonstrates setting, locking, and unlocking the crosshair without issue.

You'll want to use both the lockCrosshair and unlockCrosshair function:

$('#lock-crosshair').on('click', function() {
    x: 4

$('#unlock-crosshair').on('click', function() {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download