-
Notifications
You must be signed in to change notification settings - Fork 7
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
[WIP] added closest area and line strategies for tooltip tracking #170
base: main
Are you sure you want to change the base?
Conversation
series: AlignedData; | ||
}; | ||
|
||
export const findClosestLines = ({x, y, series}: FindClosestAreaOptions) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add unit tests for this util, mostly to ensure valid calculation of closest area/line between two X coordinates?
export const findClosestLines = ({x, y, series}: FindClosestAreaOptions) => { | ||
const [timeline, ...areas] = series as number[][]; | ||
|
||
let i1 = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can find i1
and i2
with using uplot.cursor.idx
or something. I think traversing whole timeline on each setCursor
generally is a bad idea, because tooltip.tracking
is function which can be called very frequently.
const x1 = timeline[i1]; | ||
const x2 = timeline[i2]; | ||
|
||
areas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's try to reduce number of possible iterations. I understand that in most cases it doesn't do any issues, but I'd like to keep calculations as fast as possible.
I mean let's do it in single loop
No description provided.