From 57d016245cf763a0949ab0ff11449ded084b9665 Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Sun, 9 Feb 2020 20:14:13 +0100 Subject: [PATCH] use y1/y2 axis definitions --- .../visualization-page.component.html | 4 +- .../visualization-page.component.ts | 6 +- .../y-axis-definition.component.html | 22 ++++-- .../pdb/plot/api/AggregateHandler.java | 2 +- .../plot/api/AggregateHandlerCollection.java | 2 +- .../lucares/pdb/plot/api/BarChartHandler.java | 2 +- .../api/CumulativeDistributionHandler.java | 4 +- .../pdb/plot/api/HistogramHandler.java | 2 +- .../plot/api/ParallelRequestsAggregate.java | 26 +++++-- .../org/lucares/pdb/plot/api/RangeUnit.java | 78 +++++++++++++++++++ .../pdb/plot/api/ScatterAggregateHandler.java | 6 +- .../pdb/plot/api/ScatterAggregator.java | 12 +-- .../lucares/pdb/plot/api/TimeRangeUnit.java | 24 ------ .../lucares/pdb/plot/api/YAxisDefinition.java | 16 ++-- .../lucares/recommind/logs/AxisSettings.java | 4 - .../org/lucares/recommind/logs/AxisTime.java | 22 +++--- .../org/lucares/recommind/logs/Plotter.java | 2 +- .../java/org/lucares/recommind/logs/Type.java | 5 ++ .../lucares/recommind/logs/YAxisTicks.java | 29 +++---- .../pdbui/PlotSettingsTransformer.java | 14 ++-- 20 files changed, 178 insertions(+), 104 deletions(-) create mode 100644 pdb-plotting/src/main/java/org/lucares/pdb/plot/api/RangeUnit.java delete mode 100644 pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnit.java create mode 100644 pdb-plotting/src/main/java/org/lucares/recommind/logs/Type.java 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 2f1ba40..b3abfdb 100644 --- a/pdb-js/src/app/visualization-page/visualization-page.component.html +++ b/pdb-js/src/app/visualization-page/visualization-page.component.html @@ -33,10 +33,8 @@ - - - + Gallery 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 b51f79b..e22d03d 100644 --- a/pdb-js/src/app/visualization-page/visualization-page.component.ts +++ b/pdb-js/src/app/visualization-page/visualization-page.component.ts @@ -49,6 +49,7 @@ export class VisualizationPageComponent implements OnInit { enableGallery = false; splitBy = null; + y2AxisAvailable = false; constructor(private plotService: PlotService, private snackBar: MatSnackBar) { } @@ -83,6 +84,9 @@ export class VisualizationPageComponent implements OnInit { const compatiblePlotTypes = this.plotTypes.filter(pt => pt.compatible(selectedPlotTypes)); this.plotTypes.forEach(pt => pt.active=false); compatiblePlotTypes.forEach(pt => pt.active=true); + + const axesTypes = this.getAxes(); + this.y2AxisAvailable = axesTypes.y.length == 2; } @@ -144,7 +148,7 @@ export class VisualizationPageComponent implements OnInit { this.selectedPlotType.forEach(a => aggregates.push(a.id)); const y1 = this.y1AxisDefinitionComponent.getAxisDefinition(); - const y2 = this.y2AxisDefinitionComponent.getAxisDefinition(); + const y2 = this.y2AxisDefinitionComponent ? this.y2AxisDefinitionComponent.getAxisDefinition() : undefined; const request = new PlotRequest(); request.query = this.query.query; 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 b5faf7c..dfa9f49 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 @@ -10,18 +10,24 @@ Y{{yIndex}}-Axis Range: - automatic - millis - seconds - minutes - hours - days + + auto (number) + no unit + + + auto (time) + millis + seconds + minutes + hours + days + - + - + diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandler.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandler.java index 2f3cb76..0e99cac 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandler.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandler.java @@ -5,11 +5,11 @@ import java.util.Collection; import java.util.Optional; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotSettings; import org.lucares.recommind.logs.LineStyle; +import org.lucares.recommind.logs.Type; public abstract class AggregateHandler implements Appender { diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandlerCollection.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandlerCollection.java index eaeea3e..33cc088 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandlerCollection.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/AggregateHandlerCollection.java @@ -9,10 +9,10 @@ import java.util.List; import java.util.Optional; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotSettings; +import org.lucares.recommind.logs.Type; import org.lucares.utils.CollectionUtils; import org.lucares.utils.Preconditions; 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 d3106a7..28c5050 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 @@ -8,12 +8,12 @@ import java.util.Locale; import java.util.Optional; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotLineType; import org.lucares.recommind.logs.GnuplotSettings; import org.lucares.recommind.logs.LineStyle; +import org.lucares.recommind.logs.Type; public class BarChartHandler extends AggregateHandler { diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java index 57ce13d..4241f63 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/CumulativeDistributionHandler.java @@ -5,12 +5,12 @@ import java.util.Collection; import java.util.Optional; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.AxisTime; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotSettings; import org.lucares.recommind.logs.LineStyle; +import org.lucares.recommind.logs.Type; public class CumulativeDistributionHandler extends AggregateHandler { @@ -39,7 +39,7 @@ public class CumulativeDistributionHandler extends AggregateHandler { @Override public AxisSettings createYAxisSettings(final GnuplotSettings settings, final Collection dataSeries) { - final AxisSettings result = AxisTime.createYAxis(settings, dataSeries); + final AxisSettings result = AxisTime.createYAxis(settings, getyAxis(), dataSeries); result.setAxis(getyAxis()); return result; } diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramHandler.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramHandler.java index 2b2a3e4..5837576 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramHandler.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/HistogramHandler.java @@ -5,11 +5,11 @@ import java.util.Collection; import java.util.Optional; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotSettings; import org.lucares.recommind.logs.LineStyle; +import org.lucares.recommind.logs.Type; public class HistogramHandler extends AggregateHandler { diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregate.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregate.java index 03591da..9ea15c7 100644 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregate.java +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/ParallelRequestsAggregate.java @@ -6,12 +6,12 @@ import java.util.Optional; import java.util.concurrent.TimeUnit; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.AxisTime; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotSettings; import org.lucares.recommind.logs.LineStyle; +import org.lucares.recommind.logs.Type; public class ParallelRequestsAggregate extends AggregateHandler { @@ -31,13 +31,25 @@ public class ParallelRequestsAggregate extends AggregateHandler { @Override public AxisSettings createYAxisSettings(final GnuplotSettings settings, final Collection dataSeries) { - final AxisSettings result = new AxisSettings(); - result.setLabel("Parallel Requests"); - result.setType(Type.Number); - result.setAxis(getyAxis()); - result.setTicsEnabled(true); - result.setFrom("0"); + + final AxisSettings result = AxisTime.createYAxis(settings, getyAxis(), dataSeries); return result; + +// final YAxisDefinition yAxisDefinition = settings.getYAxisDefinition(getyAxis()); +// +// final AxisSettings result = new AxisSettings(); +// result.setLabel("Parallel Requests"); +// result.setType(Type.Number); +// result.setAxis(getyAxis()); +// result.setTicsEnabled(true); +// if (yAxisDefinition.hasRange()) { +// result.setFrom(String.valueOf(yAxisDefinition.getRangeMinForUnit())); +// result.setTo(String.valueOf(yAxisDefinition.getRangeMaxForUnit())); +// } else { +// result.setFrom("0"); +// } +// result.setLogscale(yAxisDefinition.isLogscale()); +// return result; } @Override diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/RangeUnit.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/RangeUnit.java new file mode 100644 index 0000000..19c0213 --- /dev/null +++ b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/RangeUnit.java @@ -0,0 +1,78 @@ +package org.lucares.pdb.plot.api; + +import org.lucares.recommind.logs.Type; + +public enum RangeUnit { + AUTOMATIC_NUMBER(true, Type.Number, "Value"), + + NO_UNIT(false, Type.Number, "Value"), + + BYTES(false, Type.Number, "Value"), + + AUTOMATIC_TIME(true, Type.Duration, "Duration"), + + MILLISECONDS(false, Type.Duration, "Duration"), + + SECONDS(false, Type.Duration, "Duration"), + + MINUTES(false, Type.Duration, "Duration"), + + HOURS(false, Type.Duration, "Duration"), + + DAYS(false, Type.Duration, "Duration"); + + private final boolean isAutomatic; + private final String axisLabel; + private final Type type; + + private RangeUnit(final boolean isAutomatic, final Type type, final String axisLabel) { + this.isAutomatic = isAutomatic; + this.type = type; + this.axisLabel = axisLabel; + } + + public boolean isAutomatic() { + return isAutomatic; + } + + public boolean isTime() { + return type == Type.Duration; + } + + public boolean isNumber() { + return type == Type.Number || type == Type.HistogramCount; + } + + public String getLabel() { + return axisLabel; + } + + public Type getType() { + return type; + } + + public int valueForUnit(final int value) { + + switch (this) { + case AUTOMATIC_NUMBER: + return Integer.MAX_VALUE; + case NO_UNIT: + case BYTES: + return value; + case MILLISECONDS: + return value; + case SECONDS: + return value * 1000; + case MINUTES: + return value * 60 * 1000; + case HOURS: + return value * 60 * 60 * 1000; + case DAYS: + return value * 24 * 60 * 60 * 1000; + case AUTOMATIC_TIME: + return Integer.MAX_VALUE; + } + return Integer.MAX_VALUE; + } + +} 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 a50802b..4e4d88c 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 @@ -5,13 +5,13 @@ import java.util.Collection; import java.util.Optional; import org.lucares.recommind.logs.AxisSettings; -import org.lucares.recommind.logs.AxisSettings.Type; import org.lucares.recommind.logs.AxisTime; import org.lucares.recommind.logs.DataSeries; import org.lucares.recommind.logs.GnuplotAxis; import org.lucares.recommind.logs.GnuplotLineType; import org.lucares.recommind.logs.GnuplotSettings; import org.lucares.recommind.logs.LineStyle; +import org.lucares.recommind.logs.Type; public class ScatterAggregateHandler extends AggregateHandler { @@ -31,8 +31,8 @@ public class ScatterAggregateHandler extends AggregateHandler { @Override public AxisSettings createYAxisSettings(final GnuplotSettings settings, final Collection dataSeries) { - final AxisSettings result = AxisTime.createYAxis(settings, dataSeries); - result.setAxis(getyAxis()); + final AxisSettings result = AxisTime.createYAxis(settings, getyAxis(), dataSeries); + return result; } 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 69cc238..ff9d266 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 @@ -29,7 +29,7 @@ public class ScatterAggregator implements CustomAggregator { private final long minValue; private final long maxValue; - private final long durationMillisPerPixel; + private final long valuesPerPixel; private final Path tmpDir; @@ -44,10 +44,10 @@ public class ScatterAggregator implements CustomAggregator { 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 + final boolean automaticRange = yAxisDefinition.getRangeUnit().isAutomatic(); + minValue = automaticRange ? 0 : yAxisDefinition.getRangeMinForUnit(); + maxValue = automaticRange ? Long.MAX_VALUE : yAxisDefinition.getRangeMaxForUnit(); + valuesPerPixel = yAxisDefinition.getAxisScale() == AxisScale.LINEAR && !automaticRange ? Math.max(1, (maxValue - minValue) / plotAreaHeightInPx) : 1; } @@ -55,7 +55,7 @@ public class ScatterAggregator implements CustomAggregator { @Override public void addValue(final long epochMilli, final long value) { final long roundedEpochMilli = epochMilli - epochMilli % epochMillisPerPixel; - final long roundedValue = value - value % durationMillisPerPixel; + final long roundedValue = value - value % valuesPerPixel; matrix2d.put(roundedEpochMilli, roundedValue, 1); } diff --git a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnit.java b/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnit.java deleted file mode 100644 index 7c4e6c2..0000000 --- a/pdb-plotting/src/main/java/org/lucares/pdb/plot/api/TimeRangeUnit.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.lucares.pdb.plot.api; - -public enum TimeRangeUnit { - AUTOMATIC, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS; - - public int toMilliSeconds(final int value) { - - switch (this) { - case MILLISECONDS: - return value; - case SECONDS: - return value * 1000; - case MINUTES: - return value * 60 * 1000; - case HOURS: - return value * 60 * 60 * 1000; - case DAYS: - return value * 24 * 60 * 60 * 1000; - case AUTOMATIC: - return Integer.MAX_VALUE; - } - return Integer.MAX_VALUE; - } -} 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 5ceb40b..367ff5f 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 @@ -5,7 +5,7 @@ public class YAxisDefinition { private int rangeMin = 0; private int rangeMax = 300; - private TimeRangeUnit rangeUnit = TimeRangeUnit.AUTOMATIC; + private RangeUnit rangeUnit = RangeUnit.AUTOMATIC_TIME; public AxisScale getAxisScale() { return axisScale; @@ -15,12 +15,12 @@ public class YAxisDefinition { this.axisScale = axisScale; } - public long getRangeMinInMs() { - return rangeUnit.toMilliSeconds(rangeMin); + public long getRangeMinForUnit() { + return rangeUnit.valueForUnit(rangeMin); } - public long getRangeMaxInMs() { - return rangeUnit.toMilliSeconds(rangeMax); + public long getRangeMaxForUnit() { + return rangeUnit.valueForUnit(rangeMax); } public int getRangeMin() { @@ -28,7 +28,7 @@ public class YAxisDefinition { } public boolean hasRange() { - return rangeUnit != TimeRangeUnit.AUTOMATIC && rangeMin >= 0 && rangeMax >= 0 && rangeMin < rangeMax; + return !rangeUnit.isAutomatic() && rangeMin >= 0 && rangeMax >= 0 && rangeMin < rangeMax; } public void setRangeMin(final int rangeMin) { @@ -43,11 +43,11 @@ public class YAxisDefinition { this.rangeMax = rangeMax; } - public TimeRangeUnit getRangeUnit() { + public RangeUnit getRangeUnit() { return rangeUnit; } - public void setRangeUnit(final TimeRangeUnit rangeUnit) { + public void setRangeUnit(final RangeUnit rangeUnit) { this.rangeUnit = rangeUnit; } diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisSettings.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisSettings.java index 01e457d..0de39eb 100644 --- a/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisSettings.java +++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/AxisSettings.java @@ -9,10 +9,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; public class AxisSettings { - public enum Type { - Number, Time, Duration, Percent, HistogramBin, HistogramCount, Group - } - private String format = ""; private String label = ""; 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 834c89c..4eafe00 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 @@ -9,7 +9,6 @@ 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 { public static AxisSettings createXAxis(final GnuplotSettings settings) { @@ -40,22 +39,21 @@ public class AxisTime { return result; } - 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(yAxis); - result.setTicsEnabled(true); + public static AxisSettings createYAxis(final GnuplotSettings settings, final GnuplotAxis yAxis, + final Collection dataSeries) { final YAxisDefinition yAxisDefinition = settings.getYAxisDefinition(yAxis); + final AxisSettings result = new AxisSettings(); + result.setLabel(yAxisDefinition.getRangeUnit().getLabel()); + result.setType(yAxisDefinition.getRangeUnit().getType()); + result.setAxis(yAxis); + result.setTicsEnabled(true); + 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(); + final long min = Math.max(yAxisDefinition.getRangeMinForUnit(), graphOffset); + final long max = yAxisDefinition.getRangeMaxForUnit(); result.setFrom(String.valueOf(min)); result.setTo(String.valueOf(max)); } else { 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 16a0131..e8d9861 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 @@ -203,7 +203,7 @@ 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 + // TODO 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()); diff --git a/pdb-plotting/src/main/java/org/lucares/recommind/logs/Type.java b/pdb-plotting/src/main/java/org/lucares/recommind/logs/Type.java new file mode 100644 index 0000000..753dc21 --- /dev/null +++ b/pdb-plotting/src/main/java/org/lucares/recommind/logs/Type.java @@ -0,0 +1,5 @@ +package org.lucares.recommind.logs; + +public enum Type { + Number, Time, Duration, Percent, HistogramBin, HistogramCount, Group +} \ No newline at end of file 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 fed5c62..2e3e1ed 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 @@ -25,28 +25,31 @@ class YAxisTicks { final long yRangeMax; final long yRangeMin; if (yAxisDefinition.hasRange()) { - yRangeMin = yAxisDefinition.getRangeMinInMs(); - yRangeMax = yAxisDefinition.getRangeMaxInMs(); + yRangeMin = yAxisDefinition.getRangeMinForUnit(); + yRangeMax = yAxisDefinition.getRangeMaxForUnit(); } else { yRangeMin = 0; yRangeMax = DataSeries.maxValue(dataSeries); } final int height = settings.getHeight(); - switch (yAxisDefinition.getAxisScale()) { - case LINEAR: - result = computeLinearYTicks(height, yRangeMin, yRangeMax); - break; - case LOG10: - result = computeLog10YTicks(height, yRangeMin, yRangeMax); - break; - default: - // use the default + if (yAxisDefinition.getRangeUnit().isTime()) { + + switch (yAxisDefinition.getAxisScale()) { + case LINEAR: + result = computeLinearYTicksTime(height, yRangeMin, yRangeMax); + break; + case LOG10: + result = computeLog10YTicksTime(height, yRangeMin, yRangeMax); + break; + default: + throw new IllegalStateException("unhandled value: " + yAxisDefinition.getRangeUnit()); + } } return result; } - private static List computeLog10YTicks(final int height, final long yRangeMin, final long yRangeMax) { + private static List computeLog10YTicksTime(final int height, final long yRangeMin, final long yRangeMax) { final List ticsLabels = Arrays.asList(// "\"1ms\" 1", // @@ -86,7 +89,7 @@ class YAxisTicks { return ticsLabels; } - private static List computeLinearYTicks(final long height, final long yRangeMinInMs, + private static List computeLinearYTicksTime(final long height, final long yRangeMinInMs, final long yRangeMaxInMs) { final long plotHeight = height - GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN; 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 868c398..b552623 100644 --- a/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java +++ b/pdb-ui/src/main/java/org/lucares/pdbui/PlotSettingsTransformer.java @@ -4,14 +4,12 @@ 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; import org.lucares.pdb.plot.api.BarChartHandler; import org.lucares.pdb.plot.api.CumulativeDistributionHandler; import org.lucares.pdb.plot.api.HistogramHandler; 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; @@ -69,12 +67,12 @@ 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"); - } +// if (y1.getRangeUnit() == RangeUnit.AUTOMATIC_TIME && 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; }