vandijkm
Posts: 2
Joined: Tue Jun 28, 2022 1:31 pm

Markers do not follow manually positioned tooltip

Hi All,

We have an application where you can manually move the tooltip through a line chart with two buttons left and right.
This is done by using chart.tooltip.refresh(pointArray);

The tooltip is shown correctly, but the markers do not follow along always. It seems like the current point is remembered, and you can only move in one direction from that point on.

For example:
https://jsfiddle.net/3Lsc2fx1/56/

Scenario:
- Tooltip starts at 2014
- Click left once (go to 2013). This works fine.
- Click right once (back to 2014). Tooltip works, but markers are invisible
- Click left twice (go to 2012): Markers become visible only on 2012
- Click right once (go to 2013). Marker becomes invisible
- Click left twice (go to 2011). Markers become visible only on 2011
- Click right 4 times (go to 2015). Markers become visible only on 2015
- Click left once (go to 2014). Marker becomes invisible
- Click right twice (go to 2016). Marker becomes visible only on 2016.

Does anyone know how I can always show my markers at the current position of the tooltip?
Thanks in advance!
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Markers do not follow manually positioned tooltip

Hello,

Welcome to our forum and thank you for contacting us with your question!

Your logic is correct, just missing a small detail of clearing and setting the point state, with the point.setState method.
I have improved your update function, so now we iterate over all points, set the state to undefined, and then while displaying the tooltip, we also set the state to 'hover' on corresponding points. Also, I have commented out the redraw method since it's not necessary here.

I would also suggest writing a logic that will prevent the possibility of iterating over nonexisting points (i.e when going "too far to the right" with your arrows).

DEMO: https://jsfiddle.net/BlackLabel/20qtkxv9/
API Reference: https://api.highcharts.com/class-refere ... t#setState

Other than that, it's fine!
Best regards
Kamil Musiałowski
Highcharts Developer
vandijkm
Posts: 2
Joined: Tue Jun 28, 2022 1:31 pm

Re: Markers do not follow manually positioned tooltip

Hi Kamil,

Thank you very much for looking into this. I applied it to our project and it works perfectly now.
And of course we check for non existing points in the real code, I just quickly made this demo to isolate the problem.

Thanks again, you really helped us out!
kamil.m
Posts: 892
Joined: Thu May 19, 2022 1:33 pm

Re: Markers do not follow manually positioned tooltip

That's great to hear that! I'm really glad that I could help you.

Do not hesitate to contact us in the future,
Have a good day!
Kamil Musiałowski
Highcharts Developer

Return to “Highcharts Usage”