Repository: knowm/xchart
Issue: Zoom function improvement: Don't redraw when no points are selected.

When selection an area on the chart between data points the chart should not be redrawn.

Changed files:
xchart/src/main/java/org/knowm/xchart/XYChart.java
xchart/src/main/java/org/knowm/xchart/internal/series/AxesChartSeriesNumericalNoErrorBars.java

diff --git a/xchart/src/main/java/org/knowm/xchart/XYChart.java b/xchart/src/main/java/org/knowm/xchart/XYChart.java
index 30951e3a..64fd98d3 100644
--- a/xchart/src/main/java/org/knowm/xchart/XYChart.java
+++ b/xchart/src/main/java/org/knowm/xchart/XYChart.java
@@ -465,9 +465,15 @@ public class XYChart extends Chart<XYStyler, XYSeries> {
     double minValue = getChartXFromCoordinate(screenXmin);
     double maxValue = getChartXFromCoordinate(screenXmax);
     boolean filtered = false;
-    for (XYSeries series : getSeriesMap().values()) {
-      boolean f = series.filterXByValue(minValue, maxValue);
-      if (f) {
+    if (isOnePointSeleted(minValue, maxValue)) {
+      for (XYSeries series : getSeriesMap().values()) {
+        boolean f = series.filterXByValue(minValue, maxValue);
+        if (f) {
+          filtered = true;
+        }
+      }
+    } else {
+      if (!isAllPointsSelected()) {
         filtered = true;
       }
     }
@@ -480,4 +486,44 @@ public class XYChart extends Chart<XYStyler, XYSeries> {
       series.filterXByIndex(startIndex, endIndex);
     }
   }
+
+  /**
+   * Is there a point selected in all series.
+   *
+   * @param minValue
+   * @param maxValue
+   * @return
+   */
+  private boolean isOnePointSeleted(double minValue, double maxValue) {
+
+    boolean isOnePointSeleted = false;
+    double[] xData = null;
+    for (XYSeries series : getSeriesMap().values()) {
+      xData = series.getXData();
+      for (double x : xData) {
+        if (x >= minValue && x <= maxValue) {
+          isOnePointSeleted = true;
+          break;
+        }
+      }
+    }
+    return isOnePointSeleted;
+  }
+
+  /**
+   * Whether all points are selected in all series.
+   *
+   * @return
+   */
+  private boolean isAllPointsSelected() {
+
+    boolean isAllPointsSelected = true;
+    for (XYSeries series : getSeriesMap().values()) {
+      if (!series.isAllXData()) {
+        isAllPointsSelected = false;
+        break;
+      }
+    }
+    return isAllPointsSelected;
+  }
 }
diff --git a/xchart/src/main/java/org/knowm/xchart/internal/series/AxesChartSeriesNumericalNoErrorBars.java b/xchart/src/main/java/org/knowm/xchart/internal/series/AxesChartSeriesNumericalNoErrorBars.java
index f39fe801..97e64b3d 100644
--- a/xchart/src/main/java/org/knowm/xchart/internal/series/AxesChartSeriesNumericalNoErrorBars.java
+++ b/xchart/src/main/java/org/knowm/xchart/internal/series/AxesChartSeriesNumericalNoErrorBars.java
@@ -233,6 +233,16 @@ public abstract class AxesChartSeriesNumericalNoErrorBars extends MarkerSeries {
     return new double[] {min, max};
   }
 
+  /**
+   * Is xData.length equal to xDataAll.length
+   *
+   * @return true: equal; false: not equal
+   */
+  public boolean isAllXData() {
+
+    return xData.length == xDataAll.length;
+  }
+
   public double[] getXData() {
 
     return xData;