# HG changeset patch # User Andre Heinecke # Date 1385574621 -3600 # Node ID ef99781bcec72901ca2e22f51e28a6980b860ac4 # Parent 424c3d84e119fb16b3910ae8d9d67271788adb3e (issue1667) Remove duplicate points in the same series in Diagram CSV export diff -r 424c3d84e119 -r ef99781bcec7 artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java Wed Nov 27 18:06:04 2013 +0100 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartExportHelper.java Wed Nov 27 18:50:21 2013 +0100 @@ -343,8 +343,28 @@ int series = data.getSeriesCount(); for (int i = 0; i < series; i++) { int items = data.getItemCount(i); + double lastX = java.lang.Double.MAX_VALUE; + double lastY = java.lang.Double.MAX_VALUE; + for (int j = 0; j < items; j++) { - log.debug("write data: " + data.getX(i, j) + ", " + data.getY(i, j)); + Number x = data.getX(i, j); + Number y = data.getY(i, j); + double xVal = data.getXValue(i, j); + double yVal = data.getYValue(i, j); + + if (lastX == xVal && lastY == yVal) { + // comparing equality is ok here as we want + // to find data duplicates like they are added + // for example by the StyledSeriesBuilder in + // addStepPointsKmQ + log.debug("removing duplicate point in series"); + continue; + } + lastX = xVal; + lastY = yVal; + + log.debug("write data: " + x + ", " + y); + /* // Skip (NaN,NaN) datapoints. @@ -358,16 +378,16 @@ String yString; try { - xString = java.lang.Double.isNaN(data.getXValue(i,j)) + xString = java.lang.Double.isNaN(xVal) ? "" - : format.format(data.getX(i, j)); - yString = java.lang.Double.isNaN(data.getYValue(i, j)) + : format.format(x); + yString = java.lang.Double.isNaN(yVal) ? "" - : format.format(data.getY(i, j)); + : format.format(y); } catch (NumberFormatException nfe) { - xString = data.getX(i, j).toString(); - yString = data.getY(i, j).toString(); + xString = x.toString(); + yString = y.toString(); } writer.writeNext(new String[] { xString,