chris.paulusson
Posts: 11
Joined: Mon May 08, 2023 9:58 am

Forcing crosshairs to stay on one marker when multiple markers are active.

Hello!

I want to achieve something similar to this: https://jsfiddle.net/234t7xhj/6/ , except that I want the crosshair to stay on only one of the lines. Right now the crosshair moves to the marker that is closest to the mouse position.

Any suggestions? :)
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Thanks for contacting us with your question!

To prevent the crosshair moving to the marker that is closest to the mouse position, set xAxis.crosshair.snap to false.

Demo: https://jsfiddle.net/BlackLabel/9jsfqu4h/

Feel free to ask any further questions!
Best regards
Jakub
chris.paulusson
Posts: 11
Joined: Mon May 08, 2023 9:58 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

In the provided jsfiddle, the crosshair still selects the series that the mouse is closest to. I want the yAxis crosshair to snap to the values of only one series (say the blue for example), even if my mouse is closer to the green series. Do you understand what I mean? :)
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Hey!

Now, I get your point. If you want the yAxis crosshair snap only to one of the series, I split the series into 2 yAxis. The blue series is on the first yAxis and the other series are on the second one. The first one has the crosshair enabled so that it snaps to the blue series only and the second one has it disabled.

Demo: https://jsfiddle.net/BlackLabel/6s5oquv2/

Let me know if that was what you were looking for!
Best regards
Jakub
chris.paulusson
Posts: 11
Joined: Mon May 08, 2023 9:58 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Hey!

Yes this is exactly what I was looking for, thank you so much!
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

That's great to hear!
In case of any further questions, feel free to contact us again.

Regards
Jakub
chris.paulusson
Posts: 11
Joined: Mon May 08, 2023 9:58 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Hello again!

I have stumbled across another issue. When changing the x-axis interval from 1Y to any other interval in your provided jsfiddle, the line graphs don't all start from 0% anymore. Is it possible to compare them all by percent, while they use different y-axis to keep the y-axis crosshair on only one of the lines? My specific issue is that I have a candlestick chart for my stock and a spline chart for an index to compare with, but I only want the y-axis crosshairs to snap to the candlesticks, not the spline. I managed to do this, however, the spline curve does not start from 0% (I'm assuming since it has its own y-axis?). I attached two images of what my graph looks like and what I want to achieve. Hope my question is clear, let me know otherwise! Thanks in advance :)
Attachments
Screenshot 2023-05-31 at 10.33.52.png
Screenshot 2023-05-31 at 10.33.52.png (34.3 KiB) Viewed 452 times
Screenshot 2023-05-31 at 10.33.35.png
Screenshot 2023-05-31 at 10.33.35.png (66.12 KiB) Viewed 452 times
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Hey!

Could you please send me a demo of your chart, than I will be able to inspect it and tell you what could be done?

Best regards!
Jakub
chris.paulusson
Posts: 11
Joined: Mon May 08, 2023 9:58 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Hello Jakub,

If we take this example https://jsfiddle.net/dxcpgaz5/3/ . I want all the lines to start from 0%, but only the blue line starts at 0%. Does that make sense?

Regards,
Chris
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Hey!

To synchronize tickPositions on both yAxis you should use yAxis.linkedTo. In your case, it's better to link yAxis[1] to yAxis[0] (linkedTo: 1) because than it will inherit yAxis.max from the purple series which is the one with the highest value from all.

Demo: https://jsfiddle.net/BlackLabel/y6n9gsra/

Let me know if that was what you were looking for!
Best regards
Jakub
chris.paulusson
Posts: 11
Joined: Mon May 08, 2023 9:58 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

Yes, exactly what I was looking for! Thanks so much!!
jakub.j
Posts: 1091
Joined: Tue Jan 24, 2023 11:14 am

Re: Forcing crosshairs to stay on one marker when multiple markers are active.

You're welcome!
In case of any further questions, feel free to contact us again.

Kind regards
Jakub

Return to “Highcharts Stock”