jspy
jspy

Reputation: 79

Highcharts synchronized charts to show crosshair when snap is false

I noticed that in the synchronized charts example: https://www.highcharts.com/demo/synchronized-charts

If the xAxis.crosshair.snap is set to false, the crosshair no longer shows. Is there a way to make the crosshair show even when the snap is not on? The reason I need this is because I have a case where one of the charts may not have data points where the other chart may, but I still need the sync crosshair to go over the empty area. It seems to work in this fiddle, but I can't determine why:

https://jsfiddle.net/jknipp/g3vr5v44/13/

 xAxis: {
    type: 'datetime',
    crosshair: {
      zIndex: 4,
      snap: false
    },
    events: {
      setExtremes: syncExtremes
    },
  },

Thanks!

Upvotes: 0

Views: 312

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

By default, crosshair position is taken from point position. If snap is disabled, then point doesn't exist for a crosshair. We need to improve the demo a bit:

Replace:

    if (point) {
        point.highlight(e);
    }

With:

    if (point) {
        point.highlight(chart.pointer.normalize(e));
    }

And will work: http://jsfiddle.net/BlackLabel/8ktor0f1/1/

Upvotes: 1

Related Questions