Closed shonsirsha closed 1 year ago
At the moment there isn't a way to enter tracking mode through the API.
Out of interest, what is your use-case for needing this? Your feedback could help us improve the API and enable this functionality in the future.
@SlicedSilver I'm currently experimenting with the library to replace a custom svg chart. I really love the lib so far so great job and many thanks! I came across this issue and i agree with @shonsirsha that it would be great if there's some flexibility in entering the tracking mode.
On mobile, a long press is not always the first thing people try to do when interacting with a Chart. In our current custom solution it works like this: if a user swipes horizontaly for more than x pixel, the tracking mode is activated. Therefore a user could still scroll vertically but activate the chart while swiping horizontally on the chart. It would be really nice if therefore it would be possible to manually activate trackingmode or provide more options to activate it besides long-press
@tomsnep Thanks for the feedback and suggestion.
Sounds like a perfectly valid use case, and something that we will consider adding to a milestone in the future.
For your use-case, would an API method such as chart.setTrackingMode(...)
be sufficient?
@SlicedSilver Thanks for the quick response!
I think having a way to programmatically toggle it would be very nice
Was the problem fixed or does a solution in the internet exist. I have the same issue. I want to enter the trackingMode instantly when the user touches the graph on mobile devices. Any help is much appreciated since the issue is very urgent for me :(
We also have this problem. In our case, we have set both handleScroll
and handleScale
to false as we don't want the scrubbing or scaling feature. In fact, we only want tracking. Users on mobile are expecting to have the chart be immediately interactive on press but I don't see any way to override it.
Whilst not directly the API you requested, we have added a setCrosshairPosition API which meant your requirements.
You could disable both handleScroll
and handleScale
, and then handle the crosshair position yourself with a normal event listener.
Here is an example: https://github.com/tradingview/lightweight-charts/blob/acb80ab74592930012afa8aea393428fa8179460/website/tutorials/how_to/set-crosshair-position-tracking.js
Hey there, how do I enter tracking mode on mobile without a long-press? Is this even possible? If it's not possible by default, does anyone havw an example of a "hack" they used to make this work?
Thanks and congrats on a great project.