put y axis definition into its own object
This commit is contained in:
@@ -193,13 +193,11 @@ export class PlotRequest {
|
||||
thumbnailMaxHeight : number = 200;
|
||||
groupBy : Array<string>;
|
||||
limitBy : string;
|
||||
axisScale : string;
|
||||
limit : number;
|
||||
y1:YAxisDefinition;
|
||||
y2:YAxisDefinition;
|
||||
dateRange : string;
|
||||
aggregates : Array<string>;
|
||||
yRangeMin : number;
|
||||
yRangeMax : number;
|
||||
yRangeUnit : string;
|
||||
keyOutside : boolean = false;
|
||||
generateThumbnail : boolean;
|
||||
|
||||
@@ -208,6 +206,13 @@ export class PlotRequest {
|
||||
}
|
||||
}
|
||||
|
||||
export class YAxisDefinition {
|
||||
axisScale : string;
|
||||
yRangeMin : number;
|
||||
yRangeMax : number;
|
||||
yRangeUnit : string;
|
||||
}
|
||||
|
||||
export class PlotResponse {
|
||||
imageUrl : string;
|
||||
stats : PlotResponseStats;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { PlotService, PlotType, PlotRequest, PlotResponse, TagField, FilterDefaults, DataType, AxesTypes } from '../plot.service';
|
||||
import { PlotService, PlotType, PlotRequest, PlotResponse, TagField, FilterDefaults, DataType, YAxisDefinition, AxesTypes } from '../plot.service';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import { FormControl, Validators } from '@angular/forms';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
@@ -139,6 +139,12 @@ export class VisualizationPageComponent implements OnInit {
|
||||
const aggregates = [];
|
||||
this.selectedPlotType.forEach(a => aggregates.push(a.id));
|
||||
|
||||
const y1 = new YAxisDefinition();
|
||||
y1.axisScale = this.yAxisDefinitionComponent.yAxisScale;
|
||||
y1.yRangeMin = this.yAxisDefinitionComponent.minYValue;
|
||||
y1.yRangeMax = this.yAxisDefinitionComponent.maxYValue;
|
||||
y1.yRangeUnit = this.yAxisDefinitionComponent.yAxisUnit;
|
||||
|
||||
const request = new PlotRequest();
|
||||
request.query = this.query.query;
|
||||
request.height = document.getElementById("results").offsetHeight-1;
|
||||
@@ -146,14 +152,11 @@ export class VisualizationPageComponent implements OnInit {
|
||||
request.groupBy = this.groupBy.map(o => o.name);
|
||||
request.limitBy = this.limitbycomponent.limitBy;
|
||||
request.limit = this.limitbycomponent.limit;
|
||||
request.y1 = y1;
|
||||
request.dateRange = this.dateRangeAsString();
|
||||
request.aggregates = aggregates;
|
||||
request.keyOutside = false;
|
||||
request.generateThumbnail = this.enableGallery;
|
||||
request.axisScale = this.yAxisDefinitionComponent.yAxisScale;
|
||||
request.yRangeMin = this.yAxisDefinitionComponent.minYValue;
|
||||
request.yRangeMax = this.yAxisDefinitionComponent.maxYValue;
|
||||
request.yRangeUnit = this.yAxisDefinitionComponent.yAxisUnit;
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class PlotSettings {
|
||||
|
||||
private int yRangeMin;
|
||||
private int yRangeMax;
|
||||
private TimeRangeUnitInternal yRangeUnit = TimeRangeUnitInternal.AUTOMATIC;
|
||||
private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC;
|
||||
|
||||
private boolean keyOutside;
|
||||
|
||||
@@ -186,11 +186,11 @@ public class PlotSettings {
|
||||
this.yRangeMax = yRangeMax;
|
||||
}
|
||||
|
||||
public TimeRangeUnitInternal getYRangeUnit() {
|
||||
public TimeRangeUnit getYRangeUnit() {
|
||||
return yRangeUnit;
|
||||
}
|
||||
|
||||
public void setYRangeUnit(final TimeRangeUnitInternal yRangeUnit) {
|
||||
public void setYRangeUnit(final TimeRangeUnit yRangeUnit) {
|
||||
this.yRangeUnit = yRangeUnit;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ public class ScatterAggregator implements CustomAggregator {
|
||||
plotAreaHeightInPx = plotSettings.getHeight() - GnuplotSettings.GNUPLOT_TOP_BOTTOM_MARGIN;
|
||||
epochMillisPerPixel = Math.max(1, (toEpochMilli - fromEpochMilli) / plotAreaWidthInPx);
|
||||
|
||||
minValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? 0
|
||||
minValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? 0
|
||||
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMin());
|
||||
maxValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? Long.MAX_VALUE
|
||||
maxValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? Long.MAX_VALUE
|
||||
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
|
||||
durationMillisPerPixel = plotSettings.getYAxisScale() == AxisScale.LINEAR
|
||||
? Math.max(1, (maxValue - minValue) / plotAreaHeightInPx)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.lucares.pdb.plot.api;
|
||||
|
||||
public enum TimeRangeUnitInternal {
|
||||
public enum TimeRangeUnit {
|
||||
AUTOMATIC, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS;
|
||||
|
||||
public int toMilliSeconds(final int value) {
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.lucares.pdb.plot.api;
|
||||
|
||||
public class YAxisDefinition {
|
||||
private AxisScale yAxisScale = AxisScale.LINEAR;
|
||||
|
||||
private int yRangeMin = 0;
|
||||
private int yRangeMax = 300;
|
||||
private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC;
|
||||
|
||||
public AxisScale getAxisScale() {
|
||||
return yAxisScale;
|
||||
}
|
||||
|
||||
public void setAxisScale(final AxisScale yAxis) {
|
||||
this.yAxisScale = yAxis;
|
||||
}
|
||||
|
||||
public int getyRangeMin() {
|
||||
return yRangeMin;
|
||||
}
|
||||
|
||||
public void setyRangeMin(final int yRangeMin) {
|
||||
this.yRangeMin = yRangeMin;
|
||||
}
|
||||
|
||||
public int getyRangeMax() {
|
||||
return yRangeMax;
|
||||
}
|
||||
|
||||
public void setyRangeMax(final int yRangeMax) {
|
||||
this.yRangeMax = yRangeMax;
|
||||
}
|
||||
|
||||
public TimeRangeUnit getyRangeUnit() {
|
||||
return yRangeUnit;
|
||||
}
|
||||
|
||||
public void setyRangeUnit(final TimeRangeUnit yRangeUnit) {
|
||||
this.yRangeUnit = yRangeUnit;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.lucares.pdb.api.Tags;
|
||||
import org.lucares.pdb.plot.api.AggregatorCollection;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdb.plot.api.TimeRangeUnitInternal;
|
||||
import org.lucares.pdb.plot.api.TimeRangeUnit;
|
||||
import org.lucares.performance.db.PerformanceDb;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -149,9 +149,9 @@ public class Plotter {
|
||||
}
|
||||
|
||||
private void defineYRange(final GnuplotSettings gnuplotSettings, final int yRangeMin, final int yRangeMax,
|
||||
final TimeRangeUnitInternal yRangeUnit) {
|
||||
final TimeRangeUnit yRangeUnit) {
|
||||
|
||||
if (yRangeUnit != TimeRangeUnitInternal.AUTOMATIC) {
|
||||
if (yRangeUnit != TimeRangeUnit.AUTOMATIC) {
|
||||
final int min = yRangeUnit.toMilliSeconds(yRangeMin);
|
||||
final int max = yRangeUnit.toMilliSeconds(yRangeMax);
|
||||
gnuplotSettings.setYRange(min, max);
|
||||
@@ -169,9 +169,9 @@ public class Plotter {
|
||||
final long toEpochMilli = dateTo.toInstant().toEpochMilli();
|
||||
final boolean useMillis = (toEpochMilli - fromEpochMilli) < TimeUnit.MINUTES.toMillis(5);
|
||||
|
||||
final long minValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? 0
|
||||
final long minValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? 0
|
||||
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMin());
|
||||
final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnitInternal.AUTOMATIC ? Long.MAX_VALUE
|
||||
final long maxValue = plotSettings.getYRangeUnit() == TimeRangeUnit.AUTOMATIC ? Long.MAX_VALUE
|
||||
: plotSettings.getYRangeUnit().toMilliSeconds(plotSettings.getYRangeMax());
|
||||
|
||||
final AggregatorCollection aggregator = plotSettings.getAggregates().createCustomAggregator(tmpDir,
|
||||
|
||||
@@ -9,9 +9,8 @@ import org.lucares.pdb.plot.api.HistogramHandler;
|
||||
import org.lucares.pdb.plot.api.ParallelRequestsAggregate;
|
||||
import org.lucares.pdb.plot.api.PlotSettings;
|
||||
import org.lucares.pdb.plot.api.ScatterAggregateHandler;
|
||||
import org.lucares.pdb.plot.api.TimeRangeUnitInternal;
|
||||
import org.lucares.pdb.plot.api.TimeRangeUnit;
|
||||
import org.lucares.pdbui.domain.PlotRequest;
|
||||
import org.lucares.pdbui.domain.TimeRangeUnit;
|
||||
|
||||
class PlotSettingsTransformer {
|
||||
static PlotSettings toSettings(final PlotRequest request) {
|
||||
@@ -25,40 +24,40 @@ class PlotSettingsTransformer {
|
||||
result.setLimit(request.getLimit());
|
||||
result.setLimitBy(request.getLimitBy());
|
||||
result.setDateRange(request.getDateRange());
|
||||
result.setYAxisScale(request.getAxisScale());
|
||||
result.setYAxisScale(request.getY1().getAxisScale());
|
||||
result.setKeyOutside(request.isKeyOutside());
|
||||
result.setThumbnailMaxWidth(request.getThumbnailMaxWidth());
|
||||
result.setThumbnailMaxHeight(request.getThumbnailMaxHeight());
|
||||
result.setGenerateThumbnail(request.isGenerateThumbnail());
|
||||
result.setYRangeMin(request.getyRangeMin());
|
||||
result.setYRangeMax(request.getyRangeMax());
|
||||
result.setYRangeUnit(toTimeRangeUnitInternal(request.getyRangeUnit()));
|
||||
result.setYRangeMin(request.getY1().getyRangeMin());
|
||||
result.setYRangeMax(request.getY1().getyRangeMax());
|
||||
result.setYRangeUnit(toTimeRangeUnitInternal(request.getY1().getyRangeUnit()));
|
||||
result.setAggregates(
|
||||
toAggregateInternal(result.getYRangeUnit(), result.getYAxisScale(), request.getAggregates()));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static TimeRangeUnitInternal toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
|
||||
private static TimeRangeUnit toTimeRangeUnitInternal(final TimeRangeUnit yRangeUnit) {
|
||||
switch (yRangeUnit) {
|
||||
case AUTOMATIC:
|
||||
return TimeRangeUnitInternal.AUTOMATIC;
|
||||
return TimeRangeUnit.AUTOMATIC;
|
||||
case MILLISECONDS:
|
||||
return TimeRangeUnitInternal.MILLISECONDS;
|
||||
return TimeRangeUnit.MILLISECONDS;
|
||||
case SECONDS:
|
||||
return TimeRangeUnitInternal.SECONDS;
|
||||
return TimeRangeUnit.SECONDS;
|
||||
case MINUTES:
|
||||
return TimeRangeUnitInternal.MINUTES;
|
||||
return TimeRangeUnit.MINUTES;
|
||||
case HOURS:
|
||||
return TimeRangeUnitInternal.HOURS;
|
||||
return TimeRangeUnit.HOURS;
|
||||
case DAYS:
|
||||
return TimeRangeUnitInternal.DAYS;
|
||||
return TimeRangeUnit.DAYS;
|
||||
}
|
||||
throw new IllegalStateException("unhandled enum value: " + yRangeUnit);
|
||||
}
|
||||
|
||||
static AggregateHandlerCollection toAggregateInternal(final TimeRangeUnitInternal yRangeUnit,
|
||||
final AxisScale yAxisScale, final Iterable<Aggregate> aggregates) {
|
||||
static AggregateHandlerCollection toAggregateInternal(final TimeRangeUnit yRangeUnit, final AxisScale yAxisScale,
|
||||
final Iterable<Aggregate> aggregates) {
|
||||
final AggregateHandlerCollection aggregateHandlerCollection = new AggregateHandlerCollection();
|
||||
|
||||
for (final Aggregate aggregate : aggregates) {
|
||||
@@ -71,7 +70,7 @@ class PlotSettingsTransformer {
|
||||
aggregateHandlerCollection.addAggregateHandler(new ParallelRequestsAggregate());
|
||||
break;
|
||||
case SCATTER:
|
||||
if (yRangeUnit == TimeRangeUnitInternal.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
|
||||
if (yRangeUnit == TimeRangeUnit.AUTOMATIC && yAxisScale == AxisScale.LINEAR) {
|
||||
// TODO need a second ScatterAggregateHandler for YRangeUnit() ==
|
||||
// TimeRangeUnitInternal.AUTOMATIC
|
||||
throw new UnsupportedOperationException(
|
||||
|
||||
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lucares.pdb.plot.api.Aggregate;
|
||||
import org.lucares.pdb.plot.api.AxisScale;
|
||||
import org.lucares.pdb.plot.api.Limit;
|
||||
import org.lucares.pdb.plot.api.YAxisDefinition;
|
||||
|
||||
public class PlotRequest {
|
||||
private String query;
|
||||
@@ -22,18 +22,15 @@ public class PlotRequest {
|
||||
|
||||
private Limit limitBy = Limit.NO_LIMIT;
|
||||
|
||||
private AxisScale yAxisScale = AxisScale.LINEAR;
|
||||
|
||||
private int limit = Integer.MAX_VALUE;
|
||||
|
||||
private YAxisDefinition y1 = new YAxisDefinition();
|
||||
private YAxisDefinition y2 = new YAxisDefinition();
|
||||
|
||||
private String dateRange;
|
||||
|
||||
private List<Aggregate> aggregates = new ArrayList<>();
|
||||
|
||||
private int yRangeMin;
|
||||
private int yRangeMax;
|
||||
private TimeRangeUnit yRangeUnit = TimeRangeUnit.AUTOMATIC;
|
||||
|
||||
private boolean keyOutside;
|
||||
|
||||
private boolean generateThumbnail;
|
||||
@@ -115,14 +112,6 @@ public class PlotRequest {
|
||||
this.dateRange = dateRange;
|
||||
}
|
||||
|
||||
public AxisScale getAxisScale() {
|
||||
return yAxisScale;
|
||||
}
|
||||
|
||||
public void setAxisScale(final AxisScale yAxis) {
|
||||
this.yAxisScale = yAxis;
|
||||
}
|
||||
|
||||
public void setAggregate(final List<Aggregate> aggregates) {
|
||||
this.aggregates = aggregates;
|
||||
}
|
||||
@@ -147,27 +136,19 @@ public class PlotRequest {
|
||||
this.generateThumbnail = generateThumbnail;
|
||||
}
|
||||
|
||||
public int getyRangeMin() {
|
||||
return yRangeMin;
|
||||
public YAxisDefinition getY1() {
|
||||
return y1;
|
||||
}
|
||||
|
||||
public void setyRangeMin(final int yRangeMin) {
|
||||
this.yRangeMin = yRangeMin;
|
||||
public void setY1(final YAxisDefinition y1) {
|
||||
this.y1 = y1;
|
||||
}
|
||||
|
||||
public int getyRangeMax() {
|
||||
return yRangeMax;
|
||||
public YAxisDefinition getY2() {
|
||||
return y2;
|
||||
}
|
||||
|
||||
public void setyRangeMax(final int yRangeMax) {
|
||||
this.yRangeMax = yRangeMax;
|
||||
}
|
||||
|
||||
public TimeRangeUnit getyRangeUnit() {
|
||||
return yRangeUnit;
|
||||
}
|
||||
|
||||
public void setyRangeUnit(final TimeRangeUnit yRangeUnit) {
|
||||
this.yRangeUnit = yRangeUnit;
|
||||
public void setY2(final YAxisDefinition y2) {
|
||||
this.y2 = y2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package org.lucares.pdbui.domain;
|
||||
|
||||
public enum TimeRangeUnit {
|
||||
AUTOMATIC, MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS
|
||||
}
|
||||
Reference in New Issue
Block a user