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
|
||||
}
|
||||
@@ -96,6 +96,7 @@ function plot(event){
|
||||
request['limit'] = parseInt($('#search-limit-value').val());
|
||||
request['dateFrom'] = $('#search-date-from').val();
|
||||
request['dateRange'] = $('#search-date-range').val();
|
||||
request['axisScale'] = $('#search-y-axis-scale').val();
|
||||
|
||||
|
||||
var success = function(response){
|
||||
|
||||
@@ -46,6 +46,13 @@
|
||||
<option value="1 month">
|
||||
</datalist>
|
||||
|
||||
<label for="search-y-axis-scale">y-axis:</label>
|
||||
<select id="search-y-axis-scale">
|
||||
<option value="LINEAR" selected="selected">linear</option>
|
||||
<option value="LOG10">log 10</option>
|
||||
<option value="LOG2">log 2</option>
|
||||
</select>
|
||||
|
||||
<button id="search-submit"><i class="fa fa-area-chart"> Plot</i></button>
|
||||
</div>
|
||||
<div id="result-view">
|
||||
|
||||
Reference in New Issue
Block a user