custom ticks when using no-unit y-axis

This commit is contained in:
2023-02-08 16:46:41 +01:00
parent 760a6dd60e
commit 45d3639292

View File

@@ -45,6 +45,16 @@ class YAxisTicks {
default:
throw new IllegalStateException("unhandled value: " + yAxisDefinition.getRangeUnit());
}
} else {
switch (yAxisDefinition.getAxisScale()) {
case LINEAR:
break;
case LOG10:
result = computeLog10YTicksNoUnit(height, yRangeMin, yRangeMax);
break;
default:
throw new IllegalStateException("unhandled value: " + yAxisDefinition.getRangeUnit());
}
}
return result;
}
@@ -70,6 +80,7 @@ class YAxisTicks {
"\"2m\" 120000", //
"\"5m\" 300000", //
"\"10m\" 600000", //
// "\"15m\" 900000", //
"\"30m\" 1800000", //
"\"1h\" 3600000", //
"\"2h\" 7200000", //
@@ -106,6 +117,25 @@ class YAxisTicks {
return ticsLabels;
}
private static List<String> computeLog10YTicksNoUnit(final int height, final long yRangeMin, final long yRangeMax) {
final List<String> ticsLabels = Arrays.asList(//
"\"1\" 1", //
"\"10\" 10", //
"\"100\" 100", //
"\"1000\" 1000", //
"\"10k\" 10000", //
"\"100k\" 100000", //
"\"1m\" 1000000", //
"\"10m\" 10000000", //
"\"100m\" 100000000", //
"\"1b\" 1000000000.0", //
"\"10b\" 10000000000.0" //
);
return ticsLabels;
}
private static long roundToLinearLabelSteps(final long msPerLabel) {
final List<Long> steps = Arrays.asList(2L, 5L, 10L, 20L, 50L, 100L, 200L, 500L, 1000L, 2000L, 5000L, 10_000L,
20_000L, MINUTES.toMillis(1), MINUTES.toMillis(2), MINUTES.toMillis(5), MINUTES.toMillis(10),