Crosshair tracking wrong axis


#1

I am trying to add a simple crosshair to the chart by just enabling the crosshair on my line series with crosshairEnabled.yes

The problem I am having is that the crosshair is not following values on the X axis.  It seems to follow the Y axis.  I know it is difficult to explain, but instead of smoothly sliding along the x axis and tracking the series from that X value, it tracks the Y axis.


#2

I’m not 100% sure I fully understand your question, but have you tried setting the interpolatePoints property to YES? This should get the crosshair smoothly sliding between points.

If I have misunderstood your question, would you be able to post a few pictures or sketches to help with the description of your problem?

Thanks,
Jan


#3

It is quite hard to describe.  I have tried it with and without the interpolatePoints option.  Our chart has enough points that it shouldn’t have to interpolate.  

This might illustrate it better…  This is what I see if I position the crosshairs at the @ signs…

+----------------------------------------+
| |
| |
| |
| ** |
| * |
| ****** |
| ******* * |
| ***** *** |
| ******** |
| * |
| ** |
| ** @ |
| *+-------@@@---------------------+
| ***| @ |
| *** | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+--------+-------------------------------+

This is what I expect to see…

+----------------------------------------+
| |
| |
| |
| ** |
| * |
| *+----------------------+
| ****|*** * |
| **|*** *** |
| **|****** |
| * | |
| ** | |
| ** @ |
| ** @@@ |
| *** @ |
| *** | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
+-----------------+----------------------+

#4

Hey,

Thanks for the ASCII art :laughing:. The crosshair actually tracks the closest point to the users touch. Is this the behaviour you are seeing on your chart?

Jan


#5

Unfortunately, I am not even seeing it track the closest point…  It seems to find the closeset point on the y axis.  Even if I try tapping at the @ in the following ASCII art, it does not provide the expected behavior.

+----------------------------------------+
| |
| |
| |
| ** |
| * |
| ****** |
| ******* * |
| ***** *** |
| ******** |
| +----------------@------------+
| *| |
| **| |
| *+ | |
| *** | |
| *** | |
| | |
| | |
+----------+-----------------------------+

I have looked over the ShniobiF1 sample code becasue it functions correctly (even when I strip away the custom tool tip, etc.), but I can’t find any differences with what I am doing.  

I am just setting “series.crosshairEnabled = YES”


#6

I don’t know if this helps, but I just noticed that if I switch to a OHLC or Candlestick chart, the crosshairs track correctly, but when I switch back to a line chart, they exhibit the incorrect behavior that I mentioned.


#7

Hi Jmonroe,

I think I have managed to replicate your issue. Can I ask, does the crosshair act as expeceted when you slide your finger horizontally after triggering the crosshair to appear (with a long press)?

Jan


#8

Hello again,

Could I ask you to try the following & let me know if this gets you the behaviour you are after?

chart.crosshair.mode = SChartCrosshairModeSingleSeries;

This sets the crosshair to lock onto its closest series. To be even more specific, you can tell your chart to lock onto a specific series, rather than finding the closest series at long press time, like so:

chart.crosshair.trackingSeries = mySeries;

Please try the above, then if your still not having any luck - send us your project  :grin:.

Thanks,
Jan


#9

Neither of those worked, I will see if I can pull together a sample project that demonstrates it.


#10

That would be great. Thanks alot.


#11

To update my post, the issue was with our theme which was incorrectly setting the crosshair tracking to vertical (which did not do what we thought it did).

Thanks for your help.


#12

I’m glad you managed to get to the bottom of your issue. Can I ask the exact property that you misunderstood? I’ll put in a task to review the documentation, so hopefully, we won’t get other users caught in the same trap as you were!

Any feedback would be appreciated.

Jan