add histogram plots

This commit is contained in:
2019-12-27 12:25:25 +01:00
parent 2268ab40b3
commit 19e6dd1102
8 changed files with 207 additions and 24 deletions

View File

@@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class AxisSettings {
public enum Type {
Number, Time, Duration, Percent
Number, Time, Duration, Percent, HistogramBin, HistogramCount
}
private String format = "";
@@ -38,7 +38,7 @@ public class AxisSettings {
return format;
}
public void setFormat(String format) {
public void setFormat(final String format) {
this.format = format;
}
@@ -46,7 +46,7 @@ public class AxisSettings {
return label;
}
public void setLabel(String label) {
public void setLabel(final String label) {
this.label = label;
}
@@ -54,7 +54,7 @@ public class AxisSettings {
return rotateLabel;
}
public void setRotateLabel(int rotateLabel) {
public void setRotateLabel(final int rotateLabel) {
this.rotateLabel = rotateLabel;
}
@@ -62,7 +62,7 @@ public class AxisSettings {
return from;
}
public void setFrom(String from) {
public void setFrom(final String from) {
this.from = from;
}
@@ -70,7 +70,7 @@ public class AxisSettings {
return to;
}
public void setTo(String to) {
public void setTo(final String to) {
this.to = to;
}
@@ -78,7 +78,7 @@ public class AxisSettings {
return type;
}
public void setType(Type type) {
public void setType(final Type type) {
this.type = type;
}
@@ -86,11 +86,11 @@ public class AxisSettings {
return axis;
}
public void setAxis(GnuplotAxis axis) {
public void setAxis(final GnuplotAxis axis) {
this.axis = axis;
}
public void setTicIncrement(double ticIncrement) {
public void setTicIncrement(final double ticIncrement) {
this.ticIncrement = ticIncrement;
}
@@ -98,7 +98,7 @@ public class AxisSettings {
return ticIncrement;
}
public void setTicsEnabled(boolean ticsEnabled) {
public void setTicsEnabled(final boolean ticsEnabled) {
this.ticsEnabled = ticsEnabled;
}
@@ -106,7 +106,7 @@ public class AxisSettings {
return ticsEnabled;
}
public void setLogscale(boolean logscale) {
public void setLogscale(final boolean logscale) {
this.logscale = logscale;
}
@@ -114,7 +114,7 @@ public class AxisSettings {
return logscale;
}
public void setTics(List<String> ticsLabels) {
public void setTics(final List<String> ticsLabels) {
this.ticsLabels = ticsLabels;
}
@@ -122,8 +122,8 @@ public class AxisSettings {
return ticsLabels;
}
public String toGnuplotDefinition(boolean renderLabels) {
StringBuilder result = new StringBuilder();
public String toGnuplotDefinition(final boolean renderLabels) {
final StringBuilder result = new StringBuilder();
if (type == Type.Time) {
appendfln(result, "set %sdata time", axis);
}
@@ -171,10 +171,10 @@ public class AxisSettings {
@Override
public String toString() {
ObjectMapper mapper = new ObjectMapper();
final ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(this);
} catch (JsonProcessingException e) {
} catch (final JsonProcessingException e) {
return e.getMessage();
}
}

View File

@@ -24,7 +24,7 @@ public class GnuplotFileGenerator implements Appender {
appendfln(result, "set timefmt '%s'", settings.getTimefmt());
final List<AxisSettings> xAxisDefinitions = settings.getAggregates().getXAxisDefinitions(settings, dataSeries);
for (AxisSettings axisSettings : xAxisDefinitions) {
for (final AxisSettings axisSettings : xAxisDefinitions) {
appendln(result, axisSettings.toGnuplotDefinition(settings.isRenderLabels()));
}
@@ -34,10 +34,9 @@ public class GnuplotFileGenerator implements Appender {
// Workaround is to explicitly specify the y-axis range.
// We choose a range for which no ticks are defined. This creates an empty
// y-axis.
yAxisDefinitions.forEach(s -> s.setFrom("0"));
yAxisDefinitions.forEach(s -> s.setFrom("-1"));
}
for (AxisSettings axisSettings : yAxisDefinitions) {
for (final AxisSettings axisSettings : yAxisDefinitions) {
appendln(result, axisSettings.toGnuplotDefinition(settings.isRenderLabels()));
}