automatically determine which axis a plot needs

This commit is contained in:
2019-11-24 08:18:52 +01:00
parent 3048f67e9a
commit 892d5a6d08
9 changed files with 137 additions and 61 deletions

View File

@@ -10,7 +10,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
public class AxisSettings {
public enum Type {
Number, Time
Number, Time, Duration
}
private String format = "";
@@ -179,7 +179,5 @@ public class AxisSettings {
} catch (JsonProcessingException e) {
return e.getMessage();
}
}
}
}

View File

@@ -40,6 +40,7 @@ public class AxisTime {
public static AxisSettings createYAxis(GnuplotSettings settings, Collection<DataSeries> dataSeries) {
AxisSettings result = new AxisSettings();
result.setLabel("Duration");
result.setType(Type.Duration);
result.setAxis(GnuplotAxis.Y1);
result.setTicsEnabled(true);

View File

@@ -1,28 +1,43 @@
package org.lucares.recommind.logs;
public enum GnuplotAxis {
X1("x", ""),
X2("x2", "x2"),
Y1("y", "y"),
Y2("y2", "y2");
private String axis;
private String axisNameForTics;
X1("x", "x1"),
private GnuplotAxis(String axis, String axisNameForTics) {
this.axis = axis;
this.axisNameForTics = axisNameForTics;
}
@Override
public String toString() {
return axis;
}
public String getAxisNameForTics() {
return axisNameForTics;
X2("x2", "x2"),
Y1("y", "y1"),
Y2("y2", "y2");
private String axis;
private String axisNameForPlots;
private GnuplotAxis(String axis, String axisNameForPlots) {
this.axis = axis;
this.axisNameForPlots = axisNameForPlots;
}
@Override
public String toString() {
return axis;
}
public String getAxisNameForPlots() {
return axisNameForPlots;
}
public GnuplotAxis mirrorAxis() {
switch (this) {
case X1:
return X2;
case X2:
return X1;
case Y1:
return Y2;
case Y2:
return Y1;
default:
throw new IllegalArgumentException("Unexpected value: " + this);
}
}
}