make plot for parallel requests easier to digest

1. draw it below the scatter plot, so that you can see both
2. make the color lighter, so that you can see both
This commit is contained in:
2018-08-10 09:27:19 +02:00
parent 6c091c673d
commit 786570503a
9 changed files with 84 additions and 35 deletions

View File

@@ -19,7 +19,9 @@ public interface AggregateHandler {
builder.append(String.format(format + "\n", args));
}
void addPlots(StringBuilder result, Collection<DataSeries> dataSeries);
void addPlotsBeforeScatter(StringBuilder result, Collection<DataSeries> dataSeries);
void addPlotsAfterScatter(StringBuilder result, Collection<DataSeries> dataSeries);
CustomAggregator createCustomAggregator(Path tmpDir, long fromEpochMilli, long toEpochMilli);

View File

@@ -14,7 +14,12 @@ public class NullAggregate implements AggregateHandler {
}
@Override
public void addPlots(final StringBuilder result, final Collection<DataSeries> dataSeries) {
public void addPlotsBeforeScatter(final StringBuilder result, final Collection<DataSeries> dataSeries) {
// nothing to do; this is a Null-Object
}
@Override
public void addPlotsAfterScatter(final StringBuilder result, final Collection<DataSeries> dataSeries) {
// nothing to do; this is a Null-Object
}

View File

@@ -15,18 +15,24 @@ public class ParallelRequestsAggregate implements AggregateHandler {
}
@Override
public void addPlots(final StringBuilder result, final Collection<DataSeries> dataSeries) {
public void addPlotsBeforeScatter(final StringBuilder result, final Collection<DataSeries> dataSeries) {
for (final DataSeries dataSerie : dataSeries) {
final AggregatedData aggregatedData = dataSerie.getAggregatedData();
if (aggregatedData != null) {
appendfln(result, "'%s' using 1:2 notitle with filledcurve axes x1y2 lw 1 %s, \\", //
aggregatedData.getDataFile().getAbsolutePath(), //
dataSerie.getStyle()//
dataSerie.getStyle().brighter().asGnuplotLineStyle()//
);
}
}
}
@Override
public void addPlotsAfterScatter(final StringBuilder result, final Collection<DataSeries> dataSeries) {
// nothing to do: the parallel line plots shall be drawn below the scatter plot,
// so that you can see both. Therefore it must be drawn first.
}
@Override
public CustomAggregator createCustomAggregator(final Path tmpDir, final long fromEpochMilli,
final long toEpochMilli) {

View File

@@ -27,7 +27,13 @@ public class PercentileAggregate implements AggregateHandler {
}
@Override
public void addPlots(final StringBuilder result, final Collection<DataSeries> dataSeries) {
public void addPlotsBeforeScatter(final StringBuilder result, final Collection<DataSeries> dataSeries) {
// nothing to do: the percentile line should be drawn on the scatter plots and
// must therefore be rendered after the scatter
}
@Override
public void addPlotsAfterScatter(final StringBuilder result, final Collection<DataSeries> dataSeries) {
for (final DataSeries dataSerie : dataSeries) {
final AggregatedData aggregatedData = dataSerie.getAggregatedData();
if (aggregatedData != null) {

View File

@@ -1,18 +1,21 @@
package org.lucares.recommind.logs;
import java.util.Arrays;
import java.util.List;
public enum DashTypes {
public class DashTypes {
public static final List<String> DEFAULT = Arrays.asList("1", //
"2", //
"3", //
"4", //
"5", //
"6", //
"\".\"", //
"\"-\"", //
"\"._\"", //
"\"..- \""//
);
DASH_TYPE_2("2"), DASH_TYPE_3("3"), DASH_TYPE_4("4"), DASH_TYPE_5("5"), DASH_TYPE_6("6"), DASH_TYPE_DOT(
"\".\""), DASH_TYPE_DASH("\"-\""), DASH_TYPE_DOT_DASH("\"._\""), DASH_TYPE_DOT_DOT_DASH("\"..- \"");
private final String gnuplotDashType;
private DashTypes(final String gnuplotDashType) {
this.gnuplotDashType = gnuplotDashType;
}
public String toGnuplotDashType() {
return gnuplotDashType;
}
static DashTypes get(final int i) {
return values()[i % values().length];
}
}

View File

@@ -36,9 +36,9 @@ public interface DataSeries {
public double getAverage();
public void setStyle(String style);
public void setStyle(LineStyle style);
public String getStyle();
public LineStyle getStyle();
public AggregatedData getAggregatedData();
@@ -97,18 +97,12 @@ public interface DataSeries {
for (final DataSeries dataSerie : dataSeries) {
final int numColors = GnuplotColorPalettes.DEFAULT.size();
final int numDashTypes = DashTypes.DEFAULT.size();
final GnuplotColor color = GnuplotColorPalettes.DEFAULT.get(i % numColors);
if (dataSerie.getAggregatedData() != null) {
// color = color.brighter();
}
final String dashType = DashTypes.DEFAULT.get((i / numColors) % numDashTypes);
final String style = String.format("lt %s dt %s ", //
color.getColor(), //
dashType//
);
dataSerie.setStyle(style);
final DashTypes dashType = DashTypes.get(i / numColors);
final LineStyle lineStyle = new LineStyle(color, dashType);
dataSerie.setStyle(lineStyle);
i++;
}
}

View File

@@ -14,7 +14,7 @@ public class FileBackedDataSeries implements DataSeries {
private final GnuplotLineType linetype;
private String style;
private LineStyle style;
public FileBackedDataSeries(final int id, final String title, final CsvSummary csvSummary,
final GnuplotLineType linetype) {
@@ -35,12 +35,12 @@ public class FileBackedDataSeries implements DataSeries {
}
@Override
public void setStyle(final String style) {
public void setStyle(final LineStyle style) {
this.style = style;
}
@Override
public String getStyle() {
public LineStyle getStyle() {
return style;
}

View File

@@ -80,10 +80,11 @@ public class GnuplotFileGenerator {
appendf(result, "plot ");
settings.getAggregate().addPlotsBeforeScatter(result, dataSeries);
for (final DataSeries dataSerie : dataSeries) {
appendfln(result, dataSerie.getGnuplotPlotDefinition());
}
settings.getAggregate().addPlots(result, dataSeries);
settings.getAggregate().addPlotsAfterScatter(result, dataSeries);
return result.toString();
}

View File

@@ -0,0 +1,32 @@
package org.lucares.recommind.logs;
public class LineStyle {
private final GnuplotColor color;
private final DashTypes dashType;
public LineStyle(final GnuplotColor color, final DashTypes dashType) {
this.color = color;
this.dashType = dashType;
}
public String asGnuplotLineStyle() {
return String.format("lt %s dt %s ", //
color.getColor(), //
dashType.toGnuplotDashType()//
);
}
@Override
public String toString() {
return asGnuplotLineStyle();
}
public LineStyle brighter() {
return new LineStyle(color.brighter(), dashType);
}
public LineStyle darker() {
return new LineStyle(color.darker(), dashType);
}
}