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

Initial zoom in Zoomer is incorrect #660

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -794,11 +794,11 @@
double dataMin;
double dataMax;
if (axis.getSide().isVertical()) {
dataMin = axis.getValueForDisplay(minPlotCoordinate.getY());
dataMax = axis.getValueForDisplay(maxPlotCoordinate.getY());
dataMin = axis.getValueForDisplay(Math.min(axis.getHeight(), minPlotCoordinate.getY()));
dataMax = axis.getValueForDisplay(Math.min(axis.getHeight(), maxPlotCoordinate.getY()));

Check warning on line 798 in chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java

View check run for this annotation

Codecov / codecov/patch

chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java#L797-L798

Added lines #L797 - L798 were not covered by tests
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
dataMax = axis.getValueForDisplay(Math.min(axis.getHeight(), maxPlotCoordinate.getY()));
dataMax = axis.getValueForDisplay(Math.max(0, Math.min(axis.getHeight(), maxPlotCoordinate.getY())));

Is this sufficient or should it also clamp to >0? That would probably the rarer case, but I don't see any fundamental reason for only limiting one direction.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about this case too and would say that it either never occurs or is rare.
I committed you suggested change :-).

} else {
dataMin = axis.getValueForDisplay(minPlotCoordinate.getX());
dataMax = axis.getValueForDisplay(maxPlotCoordinate.getX());
dataMin = axis.getValueForDisplay(Math.min(axis.getWidth(), minPlotCoordinate.getX()));
dataMax = axis.getValueForDisplay(Math.min(axis.getWidth(), maxPlotCoordinate.getX()));

Check warning on line 801 in chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java

View check run for this annotation

Codecov / codecov/patch

chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java#L800-L801

Added lines #L800 - L801 were not covered by tests
}
switch (getAxisMode()) {
case X:
Expand Down
Loading