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

Synchronizer plugin - selectClosest option #1035

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

n-gist
Copy link

@n-gist n-gist commented Apr 9, 2023

Adds selectClosest option to synchronizer plugin so it selects values closest to desired. Defaults to false.
It can be helpful when graphs have not identical x axes data. (For example, when a graph has only one of each n values of another, or the values are different, but are close visually)

As the added search method closestIdx() is a bit slower (about 3 time slower than getRowForX()), I have added some optimization logic:
If the option is turned on, it checks graphs rows lengths first. If they are equal, it assumes that axes have identical values and thus tries to use getRowForX(). Otherwise, or if the value was not found, it uses new closestIdx() search function (uses binary search algorithm).

Copy link
Author

@n-gist n-gist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to use layout_.points instead of graph.getValue() for closest point search. Tested on two synchronized graphs (of 1000 and 100 rows resp) with 1mil iterations, got about 50% performance improvement when unzoomed and more if zoomed in

@n-gist
Copy link
Author

n-gist commented May 16, 2023

Also filtered when the found point is out of graph view. This should be done for crosshair plugin too, I'll open separate pr for it

@mirabilos
Copy link
Collaborator

mirabilos commented May 16, 2023 via email

@n-gist
Copy link
Author

n-gist commented May 16, 2023 via email

@n-gist
Copy link
Author

n-gist commented Jul 3, 2023

When searching for closest point on synced graphs, x axis values are compared. Fine for default graphs, but for those which are in stepPlot mode, left point should be selected, as it represents actual strict value for corresponding selection on the first graph

For example, selecting 4 on one graph, and having values on another such as [...,2,5,...], 5 is selected as closest by value. Good for default mode as closest for interpolated value, but for stepPlot graph 2 should be selected, since it is 2 for whole 2 -> 5 period

This can be done as a separate option, but it seems logical to make it the default

@n-gist
Copy link
Author

n-gist commented Jan 30, 2024

Adding small fix for stepPlot mode graphs. If synchronizing graph has exact x axis value, return it, even if it is ending point of a step period

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