Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we fire the setCursor hook when a cursor becomes locked? #921

Open
jint23 opened this issue Feb 2, 2024 · 5 comments
Open

Can we fire the setCursor hook when a cursor becomes locked? #921

jint23 opened this issue Feb 2, 2024 · 5 comments

Comments

@jint23
Copy link

jint23 commented Feb 2, 2024

I noticed the setCursor hook was not fired after the cursor is locked:
https://github.com/leeoniya/uPlot/blob/master/src/uPlot.js#L3190

More Context:

I'm trying to implement a feature that locks the tooltip like the one in https://leeoniya.github.io/uPlot/demos/candlestick-ohlc.html I'd like the tooltip to be locked and not to be hidden even if the user exits the plot after the cursor is locked.

I'm also considering displaying more detailed information in the tooltip after the cursor is locked.

I'm more than happy to submit a PR if you think this makes sense, thanks!

@leeoniya
Copy link
Owner

leeoniya commented Feb 2, 2024

looking back at the line history i can't find a specific reason for skipping the update during locking. maybe was before hooks existed and this was just a micro-optimization to avoid an unnecessary cursor update to the same position it was already at 🤷. i tried to see if just removing the if broke anything with the different mode toggles here [1], and all still appears to work as before, so this change sounds good to me 👍

it'll be few weeks before next release is out, so feel free to use the dist files until then, or set your package.json dep to "uplot": "leeoniya/uPlot#b0fd072ea34b845be434841e42bf795ab840e210

[1] https://leeoniya.github.io/uPlot/demos/sync-cursor.html

@jint23
Copy link
Author

jint23 commented Feb 2, 2024

@leeoniya Thank you very much for the quick fix. uPlot is an awesome library 👍

@leeoniya
Copy link
Owner

leeoniya commented Feb 2, 2024

thanks :)

@jint23
Copy link
Author

jint23 commented Feb 7, 2024

@leeoniya I just realized this does not work perfectly. If you try to lock a cursor in the Sync Cursor demo then unlock, the unlocked cursor is not synced correctly. You can test reproduce this by either click on the same plot to unlock or unlock in a different plot, these two cases will both have incorrectly synced cursors, but in different ways.

@jint23
Copy link
Author

jint23 commented Feb 7, 2024

I found another minor bug related to locked cursors, u-cursor-y is always visible at the very top of a plot for locked cursors even when they should not be rendered based on cursor.sync.match. Steps to reproduce in the Sync Cursor demo:

  1. click on the RAM plot to lock the cursor
  2. see the Y cursor line appear at the top of the TCP plot

@leeoniya leeoniya reopened this Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants