add logarithmic scaling for the y-axis
Often we have a few very high values and a lot low values. With a linearly scaled y-axis the plot is mostly useless.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package org.lucares.pdbui;
|
||||
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdbui.domain.LimitBy;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.YAxis;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
@@ -18,10 +20,24 @@ class PlotSettingsTransformer {
|
||||
result.setLimitBy(toLimit(request.getLimitBy()));
|
||||
result.setDateFrom(request.getDateFrom());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(toAxisScale(request.getAxisScale()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static AxisScale toAxisScale(final YAxis yAxis) {
|
||||
switch (yAxis) {
|
||||
case LINEAR:
|
||||
return AxisScale.LINEAR;
|
||||
case LOG10:
|
||||
return AxisScale.LOG10;
|
||||
case LOG2:
|
||||
return AxisScale.LOG2;
|
||||
default:
|
||||
throw new IllegalStateException("unhandled enum: " + yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
private static Limit toLimit(final LimitBy limitBy) {
|
||||
switch (limitBy) {
|
||||
case NO_LIMIT:
|
||||
|
||||
@@ -13,6 +13,8 @@ public class PlotRequest {
|
||||
|
||||
private LimitBy limitBy = LimitBy.NO_LIMIT;
|
||||
|
||||
private YAxis yAxis = YAxis.LINEAR;
|
||||
|
||||
private int limit = Integer.MAX_VALUE;
|
||||
|
||||
private String dateFrom;
|
||||
@@ -91,4 +93,11 @@ public class PlotRequest {
|
||||
this.dateRange = dateRange;
|
||||
}
|
||||
|
||||
public YAxis getAxisScale() {
|
||||
return yAxis;
|
||||
}
|
||||
|
||||
public void setAxisScale(final YAxis yAxis) {
|
||||
this.yAxis = yAxis;
|
||||
}
|
||||
}
|
||||
|
||||
5
pdb-ui/src/main/java/org/lucares/pdbui/domain/YAxis.java
Normal file
5
pdb-ui/src/main/java/org/lucares/pdbui/domain/YAxis.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
public enum YAxis {
|
||||
LINEAR, LOG10, LOG2
|
||||
}
|
||||
Reference in New Issue
Block a user