make the drop down for "combine with" dynamic

This commit is contained in:
2019-10-11 09:54:26 +02:00
parent ca8ee7d8f7
commit 020c3b6c39
6 changed files with 102 additions and 33 deletions

View File

@@ -14,18 +14,23 @@ export class PlotService {
constructor(private http: HttpClient) {
this.plotTypes = new Array<PlotType>();
this.plotTypes.push(new PlotType("Scatter", "scatter-chart2", true));
this.plotTypes.push(new PlotType("Heatmap", "heatmap", false));
this.plotTypes.push(new PlotType("Contour", "contour-chart", false));
this.plotTypes.push(new PlotType("Cumulative Distribution", "cumulative-distribution-chart", true));
this.plotTypes.push(new PlotType("Histogram", "histogram", false));
this.plotTypes.push(new PlotType("Ridgelines", "ridgelines", false));
this.plotTypes.push(new PlotType("Quantile-Quantile", "quantile-quantile", false));
this.plotTypes.push(new PlotType("Parallel Requests", "parallel-requests-chart", true));
this.plotTypes.push(new PlotType("Violin", "violin-chart", false));
this.plotTypes.push(new PlotType("Strip", "strip-chart", false));
this.plotTypes.push(new PlotType("Pie", "pie-chart", false));
this.plotTypes.push(new PlotType("Bar", "bar-chart", false));
this.plotTypes.push(new PlotType(
"Scatter",
"scatter-chart2",
true,
DataType.Time,
DataType.Duration));
this.plotTypes.push(new PlotType("Heatmap", "heatmap", false, DataType.Other, DataType.Other));
this.plotTypes.push(new PlotType("Contour", "contour-chart", false, DataType.Time, DataType.Duration));
this.plotTypes.push(new PlotType("Cumulative Distribution", "cumulative-distribution-chart", true, DataType.Percent, DataType.Duration));
this.plotTypes.push(new PlotType("Histogram", "histogram", false, DataType.Group, DataType.Duration));
this.plotTypes.push(new PlotType("Ridgelines", "ridgelines", false, DataType.Other, DataType.Other));
this.plotTypes.push(new PlotType("Quantile-Quantile", "quantile-quantile", false, DataType.Other, DataType.Other));
this.plotTypes.push(new PlotType("Parallel Requests", "parallel-requests-chart", true, DataType.Time, DataType.Count));
this.plotTypes.push(new PlotType("Violin", "violin-chart", false, DataType.Group, DataType.Duration));
this.plotTypes.push(new PlotType("Strip", "strip-chart", false, DataType.Group, DataType.Duration));
this.plotTypes.push(new PlotType("Pie", "pie-chart", false, DataType.Other, DataType.Other));
this.plotTypes.push(new PlotType("Bar", "bar-chart", false, DataType.Other, DataType.Other));
this.tagFields = new Array<TagField>();
@@ -57,12 +62,35 @@ export class PlotType {
name: string;
icon: string
active: boolean;
xAxis: DataType;
yAxis: DataType;
constructor(name: string, icon: string, active: boolean) {
constructor(name: string, icon: string, active: boolean, xAxis: DataType, yAxis: DataType) {
this.name = name;
this.icon = icon;
this.active = active;
this.xAxis = xAxis;
this.yAxis = yAxis;
}
compatible(other: PlotType) : boolean {
const xEqual = this.xAxis === other.xAxis;
const yEqual = this.yAxis === other.yAxis;
const anyIsOther = this.xAxis === DataType.Other
|| this.yAxis === DataType.Other
|| other.xAxis === DataType.Other
|| other.yAxis === DataType.Other;
var result = xEqual || yEqual;
// if either dimension is Other, then this plot is not compatible with any other plot
result = result && !anyIsOther;
// is not the same
result = result && this.name != other.name;
return result;
}
}
export class TagField {
@@ -73,4 +101,13 @@ export class TagField {
}
}
export enum DataType {
Time,
Duration,
Percent,
Count,
Group,
Metric,
Other
}