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:
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user