make it possible to render any combination of plots
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
package org.lucares.recommind.logs;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregatedData;
|
||||
import org.lucares.pdb.plot.api.AggregatedDataCollection;
|
||||
|
||||
class CsvSummary {
|
||||
private final int values;
|
||||
private final long maxValue;
|
||||
private final AggregatedData aggregatedData;
|
||||
private final AggregatedDataCollection aggregatedData;
|
||||
private final double statsAverage;
|
||||
private final int plottedValues;
|
||||
|
||||
public CsvSummary(final int values, final int plottedValues, final long maxValue,
|
||||
final double statsAverage, final AggregatedData aggregatedData) {
|
||||
final double statsAverage, final AggregatedDataCollection aggregatedData) {
|
||||
super();
|
||||
this.values = values;
|
||||
this.plottedValues = plottedValues;
|
||||
@@ -48,7 +48,7 @@ class CsvSummary {
|
||||
return statsAverage;
|
||||
}
|
||||
|
||||
public AggregatedData getAggregatedData() {
|
||||
public AggregatedDataCollection getAggregatedData() {
|
||||
return aggregatedData;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregatedData;
|
||||
import org.lucares.pdb.plot.api.AggregatedDataCollection;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
|
||||
public interface DataSeries {
|
||||
@@ -41,7 +41,7 @@ public interface DataSeries {
|
||||
|
||||
public LineStyle getStyle();
|
||||
|
||||
public AggregatedData getAggregatedData();
|
||||
public AggregatedDataCollection getAggregatedData();
|
||||
|
||||
public static Map<String, Integer> toMap(final List<DataSeries> dataSeries) {
|
||||
final Map<String, Integer> result = new LinkedHashMap<>();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.lucares.recommind.logs;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregatedData;
|
||||
import org.lucares.pdb.plot.api.AggregatedDataCollection;
|
||||
|
||||
public class FileBackedDataSeries implements DataSeries {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class FileBackedDataSeries implements DataSeries {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AggregatedData getAggregatedData() {
|
||||
public AggregatedDataCollection getAggregatedData() {
|
||||
return csvSummary.getAggregatedData();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class GnuplotFileGenerator {
|
||||
|
||||
appendfln(result, "set datafile separator \"%s\"", settings.getDatafileSeparator());
|
||||
|
||||
settings.getAggregate().addGnuplotDefinitions(result, settings.getDatafileSeparator(), dataSeries);
|
||||
settings.getAggregates().addGnuplotDefinitions(result, settings.getDatafileSeparator(), dataSeries);
|
||||
|
||||
appendfln(result, "set timefmt '%s'", settings.getTimefmt());
|
||||
|
||||
@@ -103,10 +103,8 @@ public class GnuplotFileGenerator {
|
||||
|
||||
appendf(result, "plot ");
|
||||
|
||||
settings.getAggregate().addPlotsBeforeScatter(result, dataSeries);
|
||||
settings.getAggregates().addPlots(result, dataSeries);
|
||||
|
||||
settings.getAggregate().addPlotsAfterScatter(result, dataSeries);
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.lucares.recommind.logs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggregateHandler;
|
||||
import org.lucares.pdb.plot.api.AggregateHandlerCollection;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
|
||||
public class GnuplotSettings {
|
||||
@@ -26,7 +26,7 @@ public class GnuplotSettings {
|
||||
private final Path output;
|
||||
|
||||
private AxisScale yAxisScale;
|
||||
private AggregateHandler aggregate;
|
||||
private AggregateHandlerCollection aggregates;
|
||||
private boolean keyOutside = false;
|
||||
|
||||
private XAxisSettings xAxisSettings = new XAxisSettings();
|
||||
@@ -98,12 +98,12 @@ public class GnuplotSettings {
|
||||
return yAxisScale;
|
||||
}
|
||||
|
||||
public void setAggregate(final AggregateHandler aggregate) {
|
||||
this.aggregate = aggregate;
|
||||
public void setAggregates(final AggregateHandlerCollection aggregates) {
|
||||
this.aggregates = aggregates;
|
||||
}
|
||||
|
||||
public AggregateHandler getAggregate() {
|
||||
return aggregate;
|
||||
public AggregateHandlerCollection getAggregates() {
|
||||
return aggregates;
|
||||
}
|
||||
|
||||
public void setKeyOutside(final boolean keyOutside) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.lucares.pdb.api.GroupResult;
|
||||
import org.lucares.pdb.api.Query;
|
||||
import org.lucares.pdb.api.Result;
|
||||
import org.lucares.pdb.api.Tags;
|
||||
import org.lucares.pdb.plot.api.CustomAggregator;
|
||||
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.TimeRangeUnitInternal;
|
||||
@@ -115,7 +115,7 @@ public class Plotter {
|
||||
defineXAxis(gnuplotSettings, plotSettings.dateRange());
|
||||
|
||||
gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale());
|
||||
gnuplotSettings.setAggregate(plotSettings.getAggregate());
|
||||
gnuplotSettings.setAggregates(plotSettings.getAggregates());
|
||||
defineYRange(gnuplotSettings, plotSettings.getYRangeMin(), plotSettings.getYRangeMax(),
|
||||
plotSettings.getYRangeUnit());
|
||||
gnuplotSettings.setKeyOutside(plotSettings.isKeyOutside());
|
||||
@@ -132,7 +132,7 @@ public class Plotter {
|
||||
defineXAxis(gnuplotSettings, plotSettings.dateRange());
|
||||
|
||||
gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale());
|
||||
gnuplotSettings.setAggregate(plotSettings.getAggregate());
|
||||
gnuplotSettings.setAggregates(plotSettings.getAggregates());
|
||||
defineYRange(gnuplotSettings, plotSettings.getYRangeMin(), plotSettings.getYRangeMax(),
|
||||
plotSettings.getYRangeUnit());
|
||||
gnuplotSettings.setKeyOutside(false);
|
||||
@@ -205,7 +205,7 @@ public class Plotter {
|
||||
final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? Long.MAX_VALUE
|
||||
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
|
||||
|
||||
final CustomAggregator aggregator = plotSettings.getAggregate().createCustomAggregator(tmpDir, plotSettings, fromEpochMilli,
|
||||
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)
|
||||
@@ -228,8 +228,6 @@ public class Plotter {
|
||||
|
||||
final long value = entry.get(i + 1);
|
||||
|
||||
|
||||
|
||||
// compute stats
|
||||
count++;
|
||||
statsMaxValue = Math.max(statsMaxValue, value);
|
||||
@@ -293,7 +291,5 @@ public class Plotter {
|
||||
result.append(")");
|
||||
|
||||
return result.toString();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user