diff --git a/pdb-js/src/app/plot.service.ts b/pdb-js/src/app/plot.service.ts
index 2816fc2..3fc2774 100644
--- a/pdb-js/src/app/plot.service.ts
+++ b/pdb-js/src/app/plot.service.ts
@@ -208,9 +208,9 @@ export class PlotRequest {
export class YAxisDefinition {
axisScale : string;
- yRangeMin : number;
- yRangeMax : number;
- yRangeUnit : string;
+ rangeMin : number;
+ rangeMax : number;
+ rangeUnit : string;
}
export class PlotResponse {
diff --git a/pdb-js/src/app/visualization-page/visualization-page.component.html b/pdb-js/src/app/visualization-page/visualization-page.component.html
index 0062ea7..2f1ba40 100644
--- a/pdb-js/src/app/visualization-page/visualization-page.component.html
+++ b/pdb-js/src/app/visualization-page/visualization-page.component.html
@@ -34,7 +34,8 @@
-
+
+
Gallery
@@ -77,7 +78,8 @@
#plotView
(zoomRange)="zoomRange($event)"
(zoomWithDateAnchor)="zoomWithDateAnchor($event)">
-
+
diff --git a/pdb-js/src/app/visualization-page/visualization-page.component.ts b/pdb-js/src/app/visualization-page/visualization-page.component.ts
index bf158b0..b51f79b 100644
--- a/pdb-js/src/app/visualization-page/visualization-page.component.ts
+++ b/pdb-js/src/app/visualization-page/visualization-page.component.ts
@@ -28,19 +28,23 @@ export class VisualizationPageComponent implements OnInit {
groupBy = new Array();
- @ViewChild(LimitByComponent, {static: false})
+ @ViewChild('limitbycomponent', {static: false})
private limitbycomponent : LimitByComponent;
- @ViewChild(YAxisDefinitionComponent, {static: false})
- private yAxisDefinitionComponent : YAxisDefinitionComponent;
- @ViewChild(QueryAutocompleteComponent, {static: false})
+ @ViewChild('y1AxisDefinitionComponent', {static: false, read: YAxisDefinitionComponent})
+ private y1AxisDefinitionComponent : YAxisDefinitionComponent;
+
+ @ViewChild('y2AxisDefinitionComponent', {static: false, read: YAxisDefinitionComponent})
+ private y2AxisDefinitionComponent : YAxisDefinitionComponent;
+
+ @ViewChild('query', {static: false})
query: QueryAutocompleteComponent;
- @ViewChild(PlotViewComponent, {static: false})
+ @ViewChild('plotView', {static: false})
plotView: PlotViewComponent;
- @ViewChild(GalleryViewComponent, {static: false})
+ @ViewChild('galleryView', {static: false})
galleryView: GalleryViewComponent;
enableGallery = false;
@@ -139,11 +143,8 @@ export class VisualizationPageComponent implements OnInit {
const aggregates = [];
this.selectedPlotType.forEach(a => aggregates.push(a.id));
- const y1 = new YAxisDefinition();
- y1.axisScale = this.yAxisDefinitionComponent.yAxisScale;
- y1.yRangeMin = this.yAxisDefinitionComponent.minYValue;
- y1.yRangeMax = this.yAxisDefinitionComponent.maxYValue;
- y1.yRangeUnit = this.yAxisDefinitionComponent.yAxisUnit;
+ const y1 = this.y1AxisDefinitionComponent.getAxisDefinition();
+ const y2 = this.y2AxisDefinitionComponent.getAxisDefinition();
const request = new PlotRequest();
request.query = this.query.query;
@@ -153,6 +154,7 @@ export class VisualizationPageComponent implements OnInit {
request.limitBy = this.limitbycomponent.limitBy;
request.limit = this.limitbycomponent.limit;
request.y1 = y1;
+ request.y2 = y2;
request.dateRange = this.dateRangeAsString();
request.aggregates = aggregates;
request.keyOutside = false;
diff --git a/pdb-js/src/app/y-axis-definition/y-axis-definition.component.html b/pdb-js/src/app/y-axis-definition/y-axis-definition.component.html
index 43c1fac..b5faf7c 100644
--- a/pdb-js/src/app/y-axis-definition/y-axis-definition.component.html
+++ b/pdb-js/src/app/y-axis-definition/y-axis-definition.component.html
@@ -1,7 +1,6 @@
-
- Y-Axis:
+ Y{{yIndex}}-Axis:
Logarithm
Linear
@@ -9,7 +8,7 @@
- Y-Axis Range:
+ Y{{yIndex}}-Axis Range:
automatic
millis
diff --git a/pdb-js/src/app/y-axis-definition/y-axis-definition.component.ts b/pdb-js/src/app/y-axis-definition/y-axis-definition.component.ts
index b8adc41..5307b05 100644
--- a/pdb-js/src/app/y-axis-definition/y-axis-definition.component.ts
+++ b/pdb-js/src/app/y-axis-definition/y-axis-definition.component.ts
@@ -1,4 +1,5 @@
import { Component, Input } from '@angular/core';
+import { YAxisDefinition } from '../plot.service';
@Component({
selector: 'pdb-y-axis-definition',
@@ -7,12 +8,23 @@ import { Component, Input } from '@angular/core';
})
export class YAxisDefinitionComponent {
-
yAxisScale: string = "LOG10";
yAxisUnit: string = "SECONDS";
minYValue: number = 0;
maxYValue: number = 300;
+
+ @Input()
+ yIndex: string = "";
constructor() {
}
+
+ getAxisDefinition() {
+ const result = new YAxisDefinition();
+ result.axisScale = this.yAxisScale;
+ result.rangeMin = this.minYValue;
+ result.rangeMax = this.maxYValue;
+ result.rangeUnit = this.yAxisUnit;
+ return result;
+ }
}
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregatorCollection.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregatorCollection.java
index 66c5b26..82c850e 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregatorCollection.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregatorCollection.java
@@ -17,9 +17,9 @@ public class AggregatorCollection {
}
}
- public void addValue(final Tags groupedBy, final boolean valueIsInYRange, final long epochMilli, final long value) {
+ public void addValue(final Tags groupedBy, final long epochMilli, final long value) {
for (final CustomAggregator aggregator : aggregators.values()) {
- aggregator.addValue(valueIsInYRange, epochMilli, value);
+ aggregator.addValue(epochMilli, value);
}
}
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartAggregator.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartAggregator.java
index c0391fe..7f53118 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartAggregator.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartAggregator.java
@@ -42,7 +42,7 @@ public class BarChartAggregator implements CustomAggregator, IndexedAggregator {
}
@Override
- public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
+ public void addValue(final long epochMilli, final long value) {
count++;
}
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartHandler.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartHandler.java
index ca4b650..d3106a7 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartHandler.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/BarChartHandler.java
@@ -58,13 +58,16 @@ public class BarChartHandler extends AggregateHandler {
@Override
AxisSettings createYAxisSettings(final GnuplotSettings settings, final Collection dataSeries) {
+
+ final GnuplotAxis yAxis = getyAxis();
+
final AxisSettings result = new AxisSettings();
result.setLabel("Count");
result.setType(Type.Number);
- result.setAxis(getyAxis());
+ result.setAxis(yAxis);
result.setTicsEnabled(true);
result.setFrom("0");
- result.setLogscale(settings.getYAxisScale() == AxisScale.LOG10);
+ result.setLogscale(settings.getYAxisDefinition(yAxis).isLogscale());
return result;
}
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionCustomAggregator.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionCustomAggregator.java
index 56c77e3..66a92b7 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionCustomAggregator.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionCustomAggregator.java
@@ -79,7 +79,7 @@ public class CumulativeDistributionCustomAggregator implements CustomAggregator
}
@Override
- public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
+ public void addValue(final long epochMilli, final long value) {
map.compute(value, 0, l -> l + 1);
totalValues++;
}
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CustomAggregator.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CustomAggregator.java
index 0c74448..210b3f8 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CustomAggregator.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CustomAggregator.java
@@ -2,7 +2,7 @@ package org.lucares.pdb.plot.api;
public interface CustomAggregator {
- void addValue(boolean valueIsInYRange, long epochMilli, long value);
+ void addValue(long epochMilli, long value);
AggregatedData getAggregatedData();
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramAggregator.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramAggregator.java
index a7748d9..02bb2c1 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramAggregator.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramAggregator.java
@@ -51,7 +51,7 @@ public class HistogramAggregator implements CustomAggregator {
}
@Override
- public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
+ public void addValue(final long epochMilli, final long value) {
map.compute(value, 0, l -> l + 1);
min = min < value ? min : value;
max = max > value ? max : value;
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregator.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregator.java
index b822707..caea650 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregator.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregator.java
@@ -41,7 +41,7 @@ public class ParallelRequestsAggregator implements CustomAggregator {
}
@Override
- public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
+ public void addValue(final long epochMilli, final long value) {
final int endPos = (int) (epochMilli - fromEpochMilli);
increments[endPos]--;
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java
index f8625fe..967a64e 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/PlotSettings.java
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.regex.Pattern;
import org.lucares.pdb.api.DateTimeRange;
+import org.lucares.recommind.logs.GnuplotAxis;
import org.lucares.utils.Preconditions;
public class PlotSettings {
@@ -32,14 +33,11 @@ public class PlotSettings {
private String dateRangeAsString;
- private AxisScale yAxisScale;
+ private YAxisDefinition y1;
+ private YAxisDefinition y2;
private AggregateHandlerCollection aggregates;
- private int yRangeMin;
- private int yRangeMax;
- private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC;
-
private boolean keyOutside;
private boolean generateThumbnail;
@@ -128,21 +126,12 @@ public class PlotSettings {
}
- public void setYAxisScale(final AxisScale axisScale) {
- this.yAxisScale = axisScale;
- }
-
- public AxisScale getYAxisScale() {
- return yAxisScale;
- }
-
@Override
public String toString() {
return "PlotSettings [query=" + query + ", height=" + height + ", width=" + width + ", thumbnailMaxWidth="
+ thumbnailMaxWidth + ", thumbnailMaxHeight=" + thumbnailMaxHeight + ", groupBy=" + groupBy
- + ", limitBy=" + limitBy + ", limit=" + limit + ", dateRangeAsString=" + dateRangeAsString
- + ", yAxisScale=" + yAxisScale + ", aggregates=" + aggregates + ", yRangeMin=" + yRangeMin
- + ", yRangeMax=" + yRangeMax + ", yRangeUnit=" + yRangeUnit + ", keyOutside=" + keyOutside
+ + ", limitBy=" + limitBy + ", limit=" + limit + ", dateRangeAsString=" + dateRangeAsString + ", y1="
+ + y1 + " y2=" + y2 + ", aggregates=" + aggregates + ", keyOutside=" + keyOutside
+ ", generateThumbnail=" + generateThumbnail + "]";
}
@@ -170,28 +159,31 @@ public class PlotSettings {
return generateThumbnail;
}
- public int getYRangeMin() {
- return yRangeMin;
+ public YAxisDefinition getY1() {
+ return y1;
}
- public void setYRangeMin(final int yRangeMin) {
- this.yRangeMin = yRangeMin;
+ public void setY1(final YAxisDefinition y1) {
+ this.y1 = y1;
}
- public int getYRangeMax() {
- return yRangeMax;
+ public YAxisDefinition getY2() {
+ return y2;
}
- public void setYRangeMax(final int yRangeMax) {
- this.yRangeMax = yRangeMax;
+ public void setY2(final YAxisDefinition y2) {
+ this.y2 = y2;
}
- public TimeRangeUnit getYRangeUnit() {
- return yRangeUnit;
- }
+ public YAxisDefinition getyAxisDefinition(final GnuplotAxis yAxis) {
+ switch (yAxis) {
+ case Y1:
+ return y1;
+ case Y2:
+ return y2;
+ default:
+ throw new IllegalArgumentException("Unexpected value: " + yAxis);
+ }
- public void setYRangeUnit(final TimeRangeUnit yRangeUnit) {
- this.yRangeUnit = yRangeUnit;
}
-
}
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregateHandler.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregateHandler.java
index 1cd37e3..a50802b 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregateHandler.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregateHandler.java
@@ -60,7 +60,7 @@ public class ScatterAggregateHandler extends AggregateHandler {
public CustomAggregator createCustomAggregator(final Path tmpDir, final PlotSettings plotSettings,
final long fromEpochMilli, final long toEpochMilli) {
- return new ScatterAggregator(tmpDir, plotSettings, fromEpochMilli, toEpochMilli);
+ return new ScatterAggregator(tmpDir, plotSettings, getyAxis(), fromEpochMilli, toEpochMilli);
}
@Override
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregator.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregator.java
index a7fa227..69cc238 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregator.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ScatterAggregator.java
@@ -13,6 +13,7 @@ import java.util.concurrent.TimeUnit;
import org.lucares.collections.Sparse2DLongArray;
import org.lucares.pdb.api.RuntimeIOException;
+import org.lucares.recommind.logs.GnuplotAxis;
import org.lucares.recommind.logs.GnuplotSettings;
import org.lucares.recommind.logs.LambdaFriendlyWriter;
import org.lucares.recommind.logs.LongUtils;
@@ -32,8 +33,8 @@ public class ScatterAggregator implements CustomAggregator {
private final Path tmpDir;
- public ScatterAggregator(final Path tmpDir, final PlotSettings plotSettings, final long fromEpochMilli,
- final long toEpochMilli) {
+ public ScatterAggregator(final Path tmpDir, final PlotSettings plotSettings, final GnuplotAxis yAxis,
+ final long fromEpochMilli, final long toEpochMilli) {
this.tmpDir = tmpDir;
useMillis = (toEpochMilli - fromEpochMilli) < TimeUnit.MINUTES.toMillis(5);
@@ -41,17 +42,18 @@ public class ScatterAggregator implements CustomAggregator {
plotAreaHeightInPx = plotSettings.getHeight() - GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN;
epochMillisPerPixel = Math.max(1, (toEpochMilli - fromEpochMilli) / plotAreaWidthInPx);
- minValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? 0
- : plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMin());
- maxValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? Long.MAX_VALUE
- : plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
- durationMillisPerPixel = plotSettings.getYAxisScale() == AxisScale.LINEAR
+ final YAxisDefinition yAxisDefinition = plotSettings.getyAxisDefinition(yAxis);
+
+ minValue = yAxisDefinition.getRangeUnit() == TimeRangeUnit.AUTOMATIC ? 0 : yAxisDefinition.getRangeMinInMs();
+ maxValue = yAxisDefinition.getRangeUnit() == TimeRangeUnit.AUTOMATIC ? Long.MAX_VALUE
+ : yAxisDefinition.getRangeMaxInMs();
+ durationMillisPerPixel = yAxisDefinition.getAxisScale() == AxisScale.LINEAR
? Math.max(1, (maxValue - minValue) / plotAreaHeightInPx)
: 1;
}
@Override
- public void addValue(final boolean valueIsInYRange, final long epochMilli, final long value) {
+ public void addValue(final long epochMilli, final long value) {
final long roundedEpochMilli = epochMilli - epochMilli % epochMillisPerPixel;
final long roundedValue = value - value % durationMillisPerPixel;
matrix2d.put(roundedEpochMilli, roundedValue, 1);
diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/YAxisDefinition.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/YAxisDefinition.java
index 041a756..5ceb40b 100644
--- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/YAxisDefinition.java
+++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/YAxisDefinition.java
@@ -1,41 +1,58 @@
package org.lucares.pdb.plot.api;
public class YAxisDefinition {
- private AxisScale yAxisScale = AxisScale.LINEAR;
+ private AxisScale axisScale = AxisScale.LINEAR;
- private int yRangeMin = 0;
- private int yRangeMax = 300;
- private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC;
+ private int rangeMin = 0;
+ private int rangeMax = 300;
+ private TimeRangeUnit rangeUnit = TimeRangeUnit.AUTOMATIC;
public AxisScale getAxisScale() {
- return yAxisScale;
+ return axisScale;
}
- public void setAxisScale(final AxisScale yAxis) {
- this.yAxisScale = yAxis;
+ public void setAxisScale(final AxisScale axisScale) {
+ this.axisScale = axisScale;
}
- public int getyRangeMin() {
- return yRangeMin;
+ public long getRangeMinInMs() {
+ return rangeUnit.toMilliSeconds(rangeMin);
}
- public void setyRangeMin(final int yRangeMin) {
- this.yRangeMin = yRangeMin;
+ public long getRangeMaxInMs() {
+ return rangeUnit.toMilliSeconds(rangeMax);
}
- public int getyRangeMax() {
- return yRangeMax;
+ public int getRangeMin() {
+ return rangeMin;
}
- public void setyRangeMax(final int yRangeMax) {
- this.yRangeMax = yRangeMax;
+ public boolean hasRange() {
+ return rangeUnit != TimeRangeUnit.AUTOMATIC && rangeMin >= 0 && rangeMax >= 0 && rangeMin < rangeMax;
}
- public TimeRangeUnit getyRangeUnit() {
- return yRangeUnit;
+ public void setRangeMin(final int rangeMin) {
+ this.rangeMin = rangeMin;
}
- public void setyRangeUnit(final TimeRangeUnit yRangeUnit) {
- this.yRangeUnit = yRangeUnit;
+ public int getRangeMax() {
+ return rangeMax;
}
+
+ public void setRangeMax(final int rangeMax) {
+ this.rangeMax = rangeMax;
+ }
+
+ public TimeRangeUnit getRangeUnit() {
+ return rangeUnit;
+ }
+
+ public void setRangeUnit(final TimeRangeUnit rangeUnit) {
+ this.rangeUnit = rangeUnit;
+ }
+
+ public boolean isLogscale() {
+ return axisScale == AxisScale.LOG10;
+ }
+
}
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisTime.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisTime.java
index 2979b21..834c89c 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisTime.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisTime.java
@@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import org.lucares.collections.LongList;
import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.plot.api.AxisScale;
+import org.lucares.pdb.plot.api.YAxisDefinition;
import org.lucares.recommind.logs.AxisSettings.Type;
public class AxisTime {
@@ -40,25 +41,30 @@ public class AxisTime {
}
public static AxisSettings createYAxis(final GnuplotSettings settings, final Collection dataSeries) {
+
+ final GnuplotAxis yAxis = GnuplotAxis.Y1; // TODO get yAxis as parameter
+
final AxisSettings result = new AxisSettings();
result.setLabel("Duration");
result.setType(Type.Duration);
- result.setAxis(GnuplotAxis.Y1);
+ result.setAxis(yAxis);
result.setTicsEnabled(true);
- final int graphOffset = settings.getYAxisScale() == AxisScale.LINEAR ? 0 : 1;
- if (settings.hasYRange()) {
- final int min = Math.max(settings.getYRangeMin(), graphOffset);
- final int max = settings.getYRangeMax();
+ final YAxisDefinition yAxisDefinition = settings.getYAxisDefinition(yAxis);
+
+ final int graphOffset = yAxisDefinition.getAxisScale() == AxisScale.LINEAR ? 0 : 1;
+ if (yAxisDefinition.hasRange()) {
+ final long min = Math.max(yAxisDefinition.getRangeMinInMs(), graphOffset);
+ final long max = yAxisDefinition.getRangeMaxInMs();
result.setFrom(String.valueOf(min));
result.setTo(String.valueOf(max));
} else {
result.setFrom(String.valueOf(graphOffset));
}
- result.setLogscale(settings.getYAxisScale() == AxisScale.LOG10);
+ result.setLogscale(yAxisDefinition.isLogscale());
- result.setTics(YAxisTicks.computeYTicks(settings, dataSeries));
+ result.setTics(YAxisTicks.computeYTicks(settings, yAxis, dataSeries));
return result;
}
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/CsvSummary.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/CsvSummary.java
index 41222d5..d01f1bf 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/CsvSummary.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/CsvSummary.java
@@ -7,13 +7,11 @@ class CsvSummary {
private final long maxValue;
private final AggregatorCollection aggregators;
private final double statsAverage;
- private final int plottedValues;
- public CsvSummary(final int values, final int plottedValues, final long maxValue, final double statsAverage,
+ public CsvSummary(final int values, final long maxValue, final double statsAverage,
final AggregatorCollection aggregators) {
super();
this.values = values;
- this.plottedValues = plottedValues;
this.maxValue = maxValue;
this.statsAverage = statsAverage;
this.aggregators = aggregators;
@@ -29,16 +27,6 @@ class CsvSummary {
return values;
}
- /**
- * Number of plotted values in the selected date range and y-range.
- *
- * @see CsvSummary#getValues()
- * @return number of plotted values
- */
- public int getPlottedValues() {
- return plottedValues;
- }
-
public long getMaxValue() {
return maxValue;
}
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/DataSeries.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/DataSeries.java
index 3ad0bab..3fc9514 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/DataSeries.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/DataSeries.java
@@ -31,8 +31,6 @@ public interface DataSeries {
public int getValues();
- public int getPlottedValues();
-
public long getMaxValue();
public double getAverage();
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/FileBackedDataSeries.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/FileBackedDataSeries.java
index 7fc90ec..f9d56f3 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/FileBackedDataSeries.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/FileBackedDataSeries.java
@@ -48,11 +48,6 @@ public class FileBackedDataSeries implements DataSeries {
return csvSummary.getValues();
}
- @Override
- public int getPlottedValues() {
- return csvSummary.getPlottedValues();
- }
-
@Override
public long getMaxValue() {
return csvSummary.getMaxValue();
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java
index a82c00c..6a53893 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/GnuplotSettings.java
@@ -4,7 +4,7 @@ import java.nio.file.Path;
import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.plot.api.AggregateHandlerCollection;
-import org.lucares.pdb.plot.api.AxisScale;
+import org.lucares.pdb.plot.api.YAxisDefinition;
public class GnuplotSettings {
@@ -27,14 +27,13 @@ public class GnuplotSettings {
// set output "datausage.png"
private final Path output;
- private AxisScale yAxisScale;
+ private YAxisDefinition y1;
+ private YAxisDefinition y2;
private AggregateHandlerCollection aggregates;
private boolean keyOutside = false;
private AxisSettings xAxisSettings = new AxisSettings();
private boolean renderLabels = true;
- private int yRangeMin = -1;
- private int yRangeMax = -1;
private DateTimeRange dateTimeRange;
public GnuplotSettings(final Path output) {
@@ -93,14 +92,6 @@ public class GnuplotSettings {
return output;
}
- public void setYAxisScale(final AxisScale yAxisScale) {
- this.yAxisScale = yAxisScale;
- }
-
- public AxisScale getYAxisScale() {
- return yAxisScale;
- }
-
public void setAggregates(final AggregateHandlerCollection aggregates) {
this.aggregates = aggregates;
}
@@ -125,24 +116,23 @@ public class GnuplotSettings {
return renderLabels;
}
- public boolean hasYRange() {
- return yRangeMin >= 0 && yRangeMax >= 0 && yRangeMin < yRangeMax;
+ public YAxisDefinition getY1() {
+ return y1;
}
- public void setYRange(final int yRangeMin, final int yRangeMax) {
- this.yRangeMin = yRangeMin;
- this.yRangeMax = yRangeMax;
+ public void setY1(final YAxisDefinition y1) {
+ this.y1 = y1;
}
- public int getYRangeMin() {
- return yRangeMin;
+ public YAxisDefinition getY2() {
+ return y2;
}
- public int getYRangeMax() {
- return yRangeMax;
+ public void setY2(final YAxisDefinition y2) {
+ this.y2 = y2;
}
- public void setDateTimeRange(DateTimeRange dateTimeRange) {
+ public void setDateTimeRange(final DateTimeRange dateTimeRange) {
this.dateTimeRange = dateTimeRange;
}
@@ -150,6 +140,17 @@ public class GnuplotSettings {
return dateTimeRange;
}
+ public YAxisDefinition getYAxisDefinition(final GnuplotAxis yAxis) {
+ switch (yAxis) {
+ case Y1:
+ return y1;
+ case Y2:
+ return y2;
+ default:
+ throw new IllegalArgumentException("Unexpected value: " + yAxis);
+ }
+ }
+
// plot 'sample.txt' using 1:2 title 'Bytes' with linespoints 2
}
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/Plotter.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/Plotter.java
index 09e1dce..16a0131 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/Plotter.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/Plotter.java
@@ -24,7 +24,6 @@ import org.lucares.pdb.api.Tags;
import org.lucares.pdb.plot.api.AggregatorCollection;
import org.lucares.pdb.plot.api.Limit;
import org.lucares.pdb.plot.api.PlotSettings;
-import org.lucares.pdb.plot.api.TimeRangeUnit;
import org.lucares.performance.db.PerformanceDb;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -108,10 +107,10 @@ public class Plotter {
gnuplotSettings.setWidth(width);
gnuplotSettings.setDateTimeRange(plotSettings.dateRange());
- gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale());
+ gnuplotSettings.setY1(plotSettings.getY1());
+ gnuplotSettings.setY2(plotSettings.getY2());
+
gnuplotSettings.setAggregates(plotSettings.getAggregates());
- defineYRange(gnuplotSettings, plotSettings.getYRangeMin(), plotSettings.getYRangeMax(),
- plotSettings.getYRangeUnit());
gnuplotSettings.setKeyOutside(plotSettings.isKeyOutside());
gnuplot.plot(gnuplotSettings, dataSeries);
}
@@ -124,11 +123,9 @@ public class Plotter {
gnuplotSettings.setHeight(plotSettings.getThumbnailMaxHeight());
gnuplotSettings.setWidth(plotSettings.getThumbnailMaxWidth());
gnuplotSettings.setDateTimeRange(plotSettings.dateRange());
-
- gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale());
+ gnuplotSettings.setY1(plotSettings.getY1());
+ gnuplotSettings.setY2(plotSettings.getY2());
gnuplotSettings.setAggregates(plotSettings.getAggregates());
- defineYRange(gnuplotSettings, plotSettings.getYRangeMin(), plotSettings.getYRangeMax(),
- plotSettings.getYRangeUnit());
gnuplotSettings.setKeyOutside(false);
gnuplotSettings.renderLabels(false);
gnuplot.plot(gnuplotSettings, dataSeries);
@@ -148,16 +145,6 @@ public class Plotter {
}
}
- private void defineYRange(final GnuplotSettings gnuplotSettings, final int yRangeMin, final int yRangeMax,
- final TimeRangeUnit yRangeUnit) {
-
- if (yRangeUnit != TimeRangeUnit.AUTOMATIC) {
- final int min = yRangeUnit.toMilliSeconds(yRangeMin);
- final int max = yRangeUnit.toMilliSeconds(yRangeMax);
- gnuplotSettings.setYRange(min, max);
- }
- }
-
private static CsvSummary toCsvDeduplicated(final GroupResult groupResult, final Path tmpDir,
final OffsetDateTime dateFrom, final OffsetDateTime dateTo, final PlotSettings plotSettings)
throws IOException {
@@ -169,16 +156,11 @@ public class Plotter {
final long toEpochMilli = dateTo.toInstant().toEpochMilli();
final boolean useMillis = (toEpochMilli - fromEpochMilli) < TimeUnit.MINUTES.toMillis(5);
- final long minValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? 0
- : plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMin());
- final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? Long.MAX_VALUE
- : plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
-
final AggregatorCollection aggregator = plotSettings.getAggregates().createCustomAggregator(tmpDir,
plotSettings, fromEpochMilli, toEpochMilli);
int count = 0; // number of values in the x-axis range (used to compute stats)
- int plottedValues = 0;
+ final int plottedValues = 0;
long statsMaxValue = 0;
double statsCurrentAverage = 0.0;
long ignoredValues = 0;
@@ -204,22 +186,14 @@ public class Plotter {
// compute average (important to do this after 'count' has been incremented)
statsCurrentAverage = statsCurrentAverage + (value - statsCurrentAverage) / count;
- // check if value is in the selected y-range
- final boolean valueIsInYRange = value < minValue || value > maxValue;
- if (valueIsInYRange) {
- ignoredValues++;
- } else {
- plottedValues++;
- }
-
- aggregator.addValue(groupedBy, valueIsInYRange, epochMilli, value);
+ aggregator.addValue(groupedBy, epochMilli, value);
}
}
METRICS_LOGGER.debug("wrote {} values to csv in: {}ms (ignored {} values) use millis: {}, grouping={}",
plottedValues, (System.nanoTime() - start) / 1_000_000.0, ignoredValues, Boolean.toString(useMillis),
groupResult.getGroupedBy().asString());
- return new CsvSummary(count, plottedValues, statsMaxValue, statsCurrentAverage, aggregator);
+ return new CsvSummary(count, statsMaxValue, statsCurrentAverage, aggregator);
}
@@ -229,17 +203,13 @@ public class Plotter {
}
static String title(final Tags tags, final CsvSummary csvSummary) {
-
+ // FIXME title must be computed by the AggregateHandler, because it is the only
+ // one knowing how many values are plotted
final StringBuilder result = new StringBuilder(tags.asValueString());
final int values = csvSummary.getValues();
- final int plottedValues = csvSummary.getPlottedValues();
result.append(" (");
- if (plottedValues != values) {
- result.append(String.format("%,d / %,d", plottedValues, values));
- } else {
- result.append(String.format("%,d", values));
- }
+ result.append(String.format("%,d", values));
result.append(")");
return result.toString();
diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/YAxisTicks.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/YAxisTicks.java
index d6c6091..fed5c62 100644
--- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/YAxisTicks.java
+++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/YAxisTicks.java
@@ -12,23 +12,28 @@ import java.util.List;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
+import org.lucares.pdb.plot.api.YAxisDefinition;
+
class YAxisTicks {
- public static List computeYTicks(final GnuplotSettings settings, final Collection dataSeries) {
+ public static List computeYTicks(final GnuplotSettings settings, final GnuplotAxis yAxis,
+ final Collection dataSeries) {
List result = new ArrayList();
+ final YAxisDefinition yAxisDefinition = settings.getYAxisDefinition(yAxis);
+
final long yRangeMax;
final long yRangeMin;
- if (settings.hasYRange()) {
- yRangeMax = settings.getYRangeMax();
- yRangeMin = settings.getYRangeMin();
+ if (yAxisDefinition.hasRange()) {
+ yRangeMin = yAxisDefinition.getRangeMinInMs();
+ yRangeMax = yAxisDefinition.getRangeMaxInMs();
} else {
- yRangeMax = DataSeries.maxValue(dataSeries);
yRangeMin = 0;
+ yRangeMax = DataSeries.maxValue(dataSeries);
}
final int height = settings.getHeight();
- switch (settings.getYAxisScale()) {
+ switch (yAxisDefinition.getAxisScale()) {
case LINEAR:
result = computeLinearYTicks(height, yRangeMin, yRangeMax);
break;
@@ -81,16 +86,17 @@ class YAxisTicks {
return ticsLabels;
}
- private static List computeLinearYTicks(final long height, final long yRangeMin, final long yRangeMax) {
+ private static List computeLinearYTicks(final long height, final long yRangeMinInMs,
+ final long yRangeMaxInMs) {
final long plotHeight = height - GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN;
final long maxLabels = plotHeight / (GnuplotSettings.TICKS_FONT_SIZE * 5);
- final long range = yRangeMax - yRangeMin;
+ final long range = yRangeMaxInMs - yRangeMinInMs;
final long msPerLabel = roundToLinearLabelSteps(range / maxLabels);
final List ticsLabels = new ArrayList<>();
- for (long i = yRangeMin; i <= yRangeMax; i += msPerLabel) {
+ for (long i = yRangeMinInMs; i <= yRangeMaxInMs; i += msPerLabel) {
ticsLabels.add("\"" + msToTic(i, msPerLabel) + "\" " + i);
}
diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java b/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java
index d4ca225..f30d468 100644
--- a/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java
+++ b/pdb-ui/src/main/java/org/lucares/pdbui/PdbController.java
@@ -1,12 +1,9 @@
package org.lucares.pdbui;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.OutputStream;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.EnumSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
@@ -23,9 +20,6 @@ import org.lucares.pdb.api.DateTimeRange;
import org.lucares.pdb.api.QueryWithCaretMarker;
import org.lucares.pdb.api.QueryWithCaretMarker.ResultMode;
import org.lucares.pdb.datastore.Proposal;
-import org.lucares.pdb.plot.api.Aggregate;
-import org.lucares.pdb.plot.api.AxisScale;
-import org.lucares.pdb.plot.api.Limit;
import org.lucares.pdb.plot.api.PlotSettings;
import org.lucares.pdbui.domain.AutocompleteProposal;
import org.lucares.pdbui.domain.AutocompleteProposalByValue;
@@ -48,7 +42,6 @@ import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
-import org.springframework.util.StreamUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@@ -60,7 +53,6 @@ import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
@@ -156,65 +148,64 @@ public class PdbController implements HardcodedValues, PropertyKeys {
}
}
- @RequestMapping(path = "/plots", //
- method = RequestMethod.GET, //
- produces = MediaType.APPLICATION_OCTET_STREAM_VALUE //
- )
- StreamingResponseBody createPlotImage(@RequestParam(name = "query", defaultValue = "") final String query,
- @RequestParam(name = "groupBy[]", defaultValue = "") final List aGroupBy,
- @RequestParam(name = "limitBy.number", defaultValue = "10") final int limit,
- @RequestParam(name = "limitBy.selected", defaultValue = "NO_LIMIT") final Limit limitBy,
- @RequestParam(name = "dateRange") final String dateRange,
- @RequestParam(name = "axisScale", defaultValue = "LINEAR") final AxisScale axisScale,
- @RequestParam(name = "aggregates") final EnumSet aggregate,
- @RequestParam(name = "keyOutside", defaultValue = "false") final boolean keyOutside,
- @RequestParam(name = "width", defaultValue = "1920") final int hidth,
- @RequestParam(name = "height", defaultValue = "1080") final int height) {
- return (final OutputStream outputStream) -> {
-
- if (StringUtils.isBlank(query)) {
- throw new BadRequest("The query must not be empty!");
- }
-
- if (StringUtils.isBlank(dateRange)) {
- throw new BadRequest("The parameter 'dateRange' must be set.");
- }
-
- final PlotSettings plotSettings = new PlotSettings();
- plotSettings.setQuery(query);
- plotSettings.setGroupBy(aGroupBy);
- plotSettings.setHeight(height);
- plotSettings.setWidth(hidth);
- plotSettings.setLimit(limit);
- plotSettings.setLimitBy(limitBy);
- plotSettings.setDateRange(dateRange);
- plotSettings.setYAxisScale(axisScale);
- plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(plotSettings.getYRangeUnit(),
- plotSettings.getYAxisScale(), aggregate));
- plotSettings.setKeyOutside(keyOutside);
- plotSettings.setGenerateThumbnail(false);
-
- if (plotterLock.tryLock()) {
- try {
- final PlotResult result = plotter.plot(plotSettings);
-
- try (FileInputStream in = new FileInputStream(result.getImagePath().toFile())) {
- StreamUtils.copy(in, outputStream);
- }
- } catch (final NoDataPointsException e) {
- throw new NotFoundException(e);
- } catch (final InternalPlottingException e) {
- throw new InternalServerError(e);
- } finally {
- plotterLock.unlock();
- }
-
- } else {
- throw new ServiceUnavailableException("Too many parallel requests!");
- }
- };
- }
-
+ /*
+ * @RequestMapping(path = "/plots", // method = RequestMethod.GET, // produces =
+ * MediaType.APPLICATION_OCTET_STREAM_VALUE // ) StreamingResponseBody
+ * createPlotImage(@RequestParam(name = "query", defaultValue = "") final String
+ * query,
+ *
+ * @RequestParam(name = "groupBy[]", defaultValue = "") final List
+ * aGroupBy,
+ *
+ * @RequestParam(name = "limitBy.number", defaultValue = "10") final int limit,
+ *
+ * @RequestParam(name = "limitBy.selected", defaultValue = "NO_LIMIT") final
+ * Limit limitBy,
+ *
+ * @RequestParam(name = "dateRange") final String dateRange,
+ *
+ * @RequestParam(name = "axisScale", defaultValue = "LINEAR") final AxisScale
+ * axisScale,
+ *
+ * @RequestParam(name = "aggregates") final EnumSet aggregate,
+ *
+ * @RequestParam(name = "keyOutside", defaultValue = "false") final boolean
+ * keyOutside,
+ *
+ * @RequestParam(name = "width", defaultValue = "1920") final int hidth,
+ *
+ * @RequestParam(name = "height", defaultValue = "1080") final int height) {
+ * return (final OutputStream outputStream) -> {
+ *
+ * if (StringUtils.isBlank(query)) { throw new
+ * BadRequest("The query must not be empty!"); }
+ *
+ * if (StringUtils.isBlank(dateRange)) { throw new
+ * BadRequest("The parameter 'dateRange' must be set."); }
+ *
+ * final PlotSettings plotSettings = new PlotSettings();
+ * plotSettings.setQuery(query); plotSettings.setGroupBy(aGroupBy);
+ * plotSettings.setHeight(height); plotSettings.setWidth(hidth);
+ * plotSettings.setLimit(limit); plotSettings.setLimitBy(limitBy);
+ * plotSettings.setDateRange(dateRange); plotSettings.setY1(y1);
+ * plotSettings.setYAxisScale(axisScale);
+ * plotSettings.setAggregates(PlotSettingsTransformer.toAggregateInternal(
+ * plotSettings.getYRangeUnit(), plotSettings.getYAxisScale(), aggregate));
+ * plotSettings.setKeyOutside(keyOutside);
+ * plotSettings.setGenerateThumbnail(false);
+ *
+ * if (plotterLock.tryLock()) { try { final PlotResult result =
+ * plotter.plot(plotSettings);
+ *
+ * try (FileInputStream in = new
+ * FileInputStream(result.getImagePath().toFile())) { StreamUtils.copy(in,
+ * outputStream); } } catch (final NoDataPointsException e) { throw new
+ * NotFoundException(e); } catch (final InternalPlottingException e) { throw new
+ * InternalServerError(e); } finally { plotterLock.unlock(); }
+ *
+ * } else { throw new
+ * ServiceUnavailableException("Too many parallel requests!"); } }; }
+ */
@RequestMapping(path = "/autocomplete", //
method = RequestMethod.GET, //
produces = MediaType.APPLICATION_JSON_VALUE //
diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java b/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java
index a95cfd2..868c398 100644
--- a/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java
+++ b/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java
@@ -1,5 +1,7 @@
package org.lucares.pdbui;
+import java.util.List;
+
import org.lucares.pdb.plot.api.Aggregate;
import org.lucares.pdb.plot.api.AggregateHandlerCollection;
import org.lucares.pdb.plot.api.AxisScale;
@@ -10,6 +12,7 @@ import org.lucares.pdb.plot.api.ParallelRequestsAggregate;
import org.lucares.pdb.plot.api.PlotSettings;
import org.lucares.pdb.plot.api.ScatterAggregateHandler;
import org.lucares.pdb.plot.api.TimeRangeUnit;
+import org.lucares.pdb.plot.api.YAxisDefinition;
import org.lucares.pdbui.domain.PlotRequest;
class PlotSettingsTransformer {
@@ -24,40 +27,20 @@ class PlotSettingsTransformer {
result.setLimit(request.getLimit());
result.setLimitBy(request.getLimitBy());
result.setDateRange(request.getDateRange());
- result.setYAxisScale(request.getY1().getAxisScale());
+
result.setKeyOutside(request.isKeyOutside());
result.setThumbnailMaxWidth(request.getThumbnailMaxWidth());
result.setThumbnailMaxHeight(request.getThumbnailMaxHeight());
result.setGenerateThumbnail(request.isGenerateThumbnail());
- result.setYRangeMin(request.getY1().getyRangeMin());
- result.setYRangeMax(request.getY1().getyRangeMax());
- result.setYRangeUnit(toTimeRangeUnitInternal(request.getY1().getyRangeUnit()));
- result.setAggregates(
- toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates()));
+ result.setY1(request.getY1());
+ result.setY2(request.getY2());
+ result.setAggregates(toAggregateInternal(request.getY1(), request.getY2(), request.getAggregates()));
return result;
}
- private static TimeRangeUnit toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
- switch (yRangeUnit) {
- case AUTOMATIC:
- return TimeRangeUnit.AUTOMATIC;
- case MILLISECONDS:
- return TimeRangeUnit.MILLISECONDS;
- case SECONDS:
- return TimeRangeUnit.SECONDS;
- case MINUTES:
- return TimeRangeUnit.MINUTES;
- case HOURS:
- return TimeRangeUnit.HOURS;
- case DAYS:
- return TimeRangeUnit.DAYS;
- }
- throw new IllegalStateException("unhandled enum value: " + yRangeUnit);
- }
-
- static AggregateHandlerCollection toAggregateInternal(final TimeRangeUnit yRangeUnit, final AxisScale yAxisScale,
- final Iterable aggregates) {
+ static AggregateHandlerCollection toAggregateInternal(final YAxisDefinition y1, final YAxisDefinition y2,
+ final List aggregates) {
final AggregateHandlerCollection aggregateHandlerCollection = new AggregateHandlerCollection();
for (final Aggregate aggregate : aggregates) {
@@ -70,14 +53,7 @@ class PlotSettingsTransformer {
aggregateHandlerCollection.addAggregateHandler(new ParallelRequestsAggregate());
break;
case SCATTER:
- if (yRangeUnit == TimeRangeUnit.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
- // TODO need a second ScatterAggregateHandler for YRangeUnit() ==
- // TimeRangeUnitInternal.AUTOMATIC
- throw new UnsupportedOperationException(
- "linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range");
- } else {
- aggregateHandlerCollection.addAggregateHandler(new ScatterAggregateHandler());
- }
+ aggregateHandlerCollection.addAggregateHandler(new ScatterAggregateHandler());
break;
case HISTOGRAM:
aggregateHandlerCollection.addAggregateHandler(new HistogramHandler());
@@ -92,6 +68,14 @@ class PlotSettingsTransformer {
aggregateHandlerCollection.updateAxisForHandlers();
+ // Note: this check is incomplete -> implement the todo and remove this
+ if (y1.getRangeUnit() == TimeRangeUnit.AUTOMATIC && y1.getAxisScale() == AxisScale.LINEAR) {
+ // TODO need a second ScatterAggregateHandler for YRangeUnit() ==
+ // TimeRangeUnitInternal.AUTOMATIC
+ throw new UnsupportedOperationException(
+ "linear axis with automatic y range does not work, use logarthmic y-axis, or define a y-axis range");
+ }
+
return aggregateHandlerCollection;
}
}
diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/domain/DataSeriesStats.java b/pdb-ui/src/main/java/org/lucares/pdbui/domain/DataSeriesStats.java
index 69628e5..def1afd 100644
--- a/pdb-ui/src/main/java/org/lucares/pdbui/domain/DataSeriesStats.java
+++ b/pdb-ui/src/main/java/org/lucares/pdbui/domain/DataSeriesStats.java
@@ -6,11 +6,9 @@ public class DataSeriesStats {
private final int values;
private final long maxValue;
private final double average;
- private final int plottedValues;
- public DataSeriesStats(final int values, final int plottedValues, final long maxValue, final double average) {
+ public DataSeriesStats(final int values, final long maxValue, final double average) {
this.values = values;
- this.plottedValues = plottedValues;
this.maxValue = maxValue;
this.average = average;
}
@@ -24,15 +22,6 @@ public class DataSeriesStats {
return values;
}
- /**
- * The number of values in the date range and the y-range.
- *
- * @return number of plotted values
- */
- public int getPlottedValues() {
- return plottedValues;
- }
-
public long getMaxValue() {
return maxValue;
}
diff --git a/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotResponseStats.java b/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotResponseStats.java
index add718b..0b4ce99 100644
--- a/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotResponseStats.java
+++ b/pdb-ui/src/main/java/org/lucares/pdbui/domain/PlotResponseStats.java
@@ -12,20 +12,17 @@ public class PlotResponseStats {
private double average;
- private int plottedValues;
-
private List dataSeriesStats;
public PlotResponseStats() {
super();
}
- public PlotResponseStats(final long maxValue, final int values, final int plottedValues, final double average,
+ public PlotResponseStats(final long maxValue, final int values, final double average,
final List dataSeriesStats) {
this.maxValue = maxValue;
this.values = values;
- this.plottedValues = plottedValues;
this.average = average;
this.dataSeriesStats = dataSeriesStats;
}
@@ -46,14 +43,6 @@ public class PlotResponseStats {
this.values = values;
}
- public int getPlottedValues() {
- return plottedValues;
- }
-
- public void setPlottedValues(final int plottedValues) {
- this.plottedValues = plottedValues;
- }
-
public double getAverage() {
return average;
}
@@ -73,27 +62,25 @@ public class PlotResponseStats {
@Override
public String toString() {
return "PlotResponseStats [maxValue=" + maxValue + ", values=" + values + ", average=" + average
- + ", plottedValues=" + plottedValues + ", dataSeriesStats=" + dataSeriesStats + "]";
+ + ", dataSeriesStats=" + dataSeriesStats + "]";
}
public static PlotResponseStats fromDataSeries(final List dataSeries) {
int values = 0;
- int plottedValues = 0;
long maxValue = 0;
final List dataSeriesStats = new ArrayList<>();
for (final DataSeries dataSerie : dataSeries) {
values += dataSerie.getValues();
- plottedValues += dataSerie.getPlottedValues();
maxValue = Math.max(maxValue, dataSerie.getMaxValue());
- dataSeriesStats.add(new DataSeriesStats(dataSerie.getValues(), dataSerie.getPlottedValues(),
- dataSerie.getMaxValue(), dataSerie.getAverage()));
+ dataSeriesStats
+ .add(new DataSeriesStats(dataSerie.getValues(), dataSerie.getMaxValue(), dataSerie.getAverage()));
}
final double average = Math.round(DataSeriesStats.average(dataSeriesStats));
- return new PlotResponseStats(maxValue, values, plottedValues, average, dataSeriesStats);
+ return new PlotResponseStats(maxValue, values, average, dataSeriesStats);
}
}
diff --git a/pdb-ui/src/test/java/org/lucares/pdbui/domain/DataSeriesStatsTest.java b/pdb-ui/src/test/java/org/lucares/pdbui/domain/DataSeriesStatsTest.java
index aa525ad..5f8159f 100644
--- a/pdb-ui/src/test/java/org/lucares/pdbui/domain/DataSeriesStatsTest.java
+++ b/pdb-ui/src/test/java/org/lucares/pdbui/domain/DataSeriesStatsTest.java
@@ -17,14 +17,14 @@ public class DataSeriesStatsTest {
{
final List stats = Arrays.asList(//
- new DataSeriesStats(10, 0, 0, 5.0)//
+ new DataSeriesStats(10, 0, 5.0)//
);
final double expected = 5.0;
result.add(Arguments.of(stats, expected));
}
{
final List stats = Arrays.asList(//
- new DataSeriesStats(0, 0, 0, 5.0)//
+ new DataSeriesStats(0, 0, 5.0)//
);
final double expected = 0.0; // no values
result.add(Arguments.of(stats, expected));
@@ -32,17 +32,17 @@ public class DataSeriesStatsTest {
{
final List stats = Arrays.asList(//
- new DataSeriesStats(10, 0, 0, 5.0), //
- new DataSeriesStats(40, 0, 0, 1.0)//
+ new DataSeriesStats(10, 0, 5.0), //
+ new DataSeriesStats(40, 0, 1.0)//
);
final double expected = 1.8; // 90 / 50
result.add(Arguments.of(stats, expected));
}
{
final List stats = Arrays.asList(//
- new DataSeriesStats(5, 0, 0, 7.0), //
- new DataSeriesStats(0, 0, 0, 5.0), // // no values
- new DataSeriesStats(20, 0, 0, 2.0)//
+ new DataSeriesStats(5, 0, 7.0), //
+ new DataSeriesStats(0, 0, 5.0), // // no values
+ new DataSeriesStats(20, 0, 2.0)//
);
final double expected = 3.0; // (35+40) / 25
result.add(Arguments.of(stats, expected));