make computation of mean value optional
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
package org.lucares.pdb.plot.api;
|
||||
|
||||
public enum AggreateInternal {
|
||||
NONE, MEAN
|
||||
}
|
||||
@@ -32,6 +32,8 @@ public class PlotSettings {
|
||||
|
||||
private AxisScale yAxisScale;
|
||||
|
||||
private AggreateInternal aggregate;
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
@@ -156,6 +158,14 @@ public class PlotSettings {
|
||||
public String toString() {
|
||||
return "PlotSettings [query=" + query + ", height=" + height + ", width=" + width + ", groupBy=" + groupBy
|
||||
+ ", limitBy=" + limitBy + ", limit=" + limit + ", dateFrom=" + dateFrom + ", dateRange=" + dateRange
|
||||
+ ", axisScale=" + yAxisScale + "]";
|
||||
+ ", axisScale=" + yAxisScale + ", aggregate="+aggregate+"]";
|
||||
}
|
||||
|
||||
public void setAggregate(AggreateInternal aggregate) {
|
||||
this.aggregate = aggregate;
|
||||
}
|
||||
|
||||
public AggreateInternal getAggregate() {
|
||||
return aggregate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.lucares.recommind.logs;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggreateInternal;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
|
||||
public class GnuplotFileGenerator {
|
||||
@@ -13,7 +14,20 @@ public class GnuplotFileGenerator {
|
||||
appendfln(result, "set terminal %s noenhanced size %d,%d", settings.getTerminal(), settings.getWidth(),
|
||||
settings.getHeight());
|
||||
|
||||
|
||||
|
||||
appendfln(result, "set datafile separator \"%s\"", settings.getDatafileSeparator());
|
||||
|
||||
int count = 1;
|
||||
if (settings.getAggregate() != AggreateInternal.NONE)
|
||||
{
|
||||
for (final DataSeries dataSerie : dataSeries) {
|
||||
|
||||
appendfln(result, "stats '%s' using 2 prefix \"A%d\"", dataSerie.getDataFile(),count);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
appendfln(result, "set timefmt '%s'", settings.getTimefmt());
|
||||
|
||||
appendfln(result, "set xdata time");
|
||||
@@ -21,7 +35,8 @@ public class GnuplotFileGenerator {
|
||||
appendfln(result, "set xlabel \"%s\"", settings.getXlabel());
|
||||
appendfln(result, "set xtics rotate by %d", settings.getRotateXAxisLabel());
|
||||
appendfln(result, "set xrange [\"%s\":\"%s\"]", settings.getDateFrom(), settings.getDateTo());
|
||||
|
||||
appendfln(result, "set yrange [\"1\":]");
|
||||
|
||||
appendfln(result, "set ylabel \"%s\"", settings.getYlabel());
|
||||
if (settings.getYAxisScale() == AxisScale.LOG10) {
|
||||
appendfln(result, "set logscale y");
|
||||
@@ -29,12 +44,19 @@ public class GnuplotFileGenerator {
|
||||
appendfln(result, "set logscale y 2");
|
||||
}
|
||||
|
||||
appendfln(result, "set grid");
|
||||
appendfln(result, "set output \"%s\"", settings.getOutput().toAbsolutePath().toString().replace("\\", "/"));
|
||||
appendf(result, "plot ");
|
||||
|
||||
|
||||
count = 1;
|
||||
for (final DataSeries dataSerie : dataSeries) {
|
||||
appendfln(result, "'%s' using 1:2 title '%s' with points, \\", dataSerie.getDataFile(),
|
||||
dataSerie.getTitle());
|
||||
if (settings.getAggregate() == AggreateInternal.MEAN) {
|
||||
appendfln(result, "A%d_mean title '%s Mean', \\", count, dataSerie.getTitle(),
|
||||
dataSerie.getTitle());
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.lucares.recommind.logs;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.lucares.pdb.plot.api.AggreateInternal;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
|
||||
public class GnuplotSettings {
|
||||
@@ -30,6 +31,7 @@ public class GnuplotSettings {
|
||||
private AxisScale yAxisScale;
|
||||
private String dateFrom;
|
||||
private String dateTo;
|
||||
private AggreateInternal aggregate;
|
||||
|
||||
public GnuplotSettings(final Path output) {
|
||||
this.output = output;
|
||||
@@ -135,6 +137,14 @@ public class GnuplotSettings {
|
||||
return dateTo;
|
||||
}
|
||||
|
||||
public void setAggregate(AggreateInternal aggregate) {
|
||||
this.aggregate = aggregate;
|
||||
}
|
||||
|
||||
public AggreateInternal getAggregate() {
|
||||
return aggregate;
|
||||
}
|
||||
|
||||
// plot 'sample.txt' using 1:2 title 'Bytes' with linespoints 2
|
||||
|
||||
}
|
||||
|
||||
@@ -116,6 +116,7 @@ public class Plotter {
|
||||
defineXAxis(gnuplotSettings, plotSettings.dateFrom(), plotSettings.dateTo());
|
||||
|
||||
gnuplotSettings.setYAxisScale(plotSettings.getYAxisScale());
|
||||
gnuplotSettings.setAggregate(plotSettings.getAggregate());
|
||||
gnuplot.plot(gnuplotSettings, dataSeries);
|
||||
|
||||
return new PlotResult(outputFile.getFileName(), dataSeries);
|
||||
|
||||
Reference in New Issue
Block a user