diff --git a/chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java b/chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java index e5c826d41..31a6a099a 100644 --- a/chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java +++ b/chartfx-chart/src/main/java/io/fair_acc/chartfx/plugins/Zoomer.java @@ -794,11 +794,11 @@ private Map getZoomDataWindows() { double dataMin; double dataMax; if (axis.getSide().isVertical()) { - dataMin = axis.getValueForDisplay(minPlotCoordinate.getY()); - dataMax = axis.getValueForDisplay(maxPlotCoordinate.getY()); + dataMin = axis.getValueForDisplay(Math.max(0, Math.min(axis.getHeight(), minPlotCoordinate.getY()))); + dataMax = axis.getValueForDisplay(Math.max(0, Math.min(axis.getHeight(), maxPlotCoordinate.getY()))); } else { - dataMin = axis.getValueForDisplay(minPlotCoordinate.getX()); - dataMax = axis.getValueForDisplay(maxPlotCoordinate.getX()); + dataMin = axis.getValueForDisplay(Math.max(0, Math.min(axis.getWidth(), minPlotCoordinate.getX()))); + dataMax = axis.getValueForDisplay(Math.max(0, Math.min(axis.getWidth(), maxPlotCoordinate.getX()))); } switch (getAxisMode()) { case X: