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

[WIP] added closest area and line strategies for tooltip tracking #170

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

feelsbadmans
Copy link
Contributor

No description provided.

@feelsbadmans feelsbadmans changed the title feat: added closest area and line strategies for tooltip feat: added closest area and line strategies for tooltip tracking Oct 16, 2023
series: AlignedData;
};

export const findClosestLines = ({x, y, series}: FindClosestAreaOptions) => {
Copy link
Collaborator

@zefirka zefirka Oct 16, 2023

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,
Copy link
Collaborator

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
Copy link
Collaborator

@zefirka zefirka Oct 16, 2023

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

@feelsbadmans feelsbadmans changed the title feat: added closest area and line strategies for tooltip tracking [WIP] added closest area and line strategies for tooltip tracking Oct 17, 2023
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

Successfully merging this pull request may close these issues.

2 participants