aboutsummaryrefslogtreecommitdiff
path: root/src/client/northstar/dash-nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/northstar/dash-nodes')
-rw-r--r--src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts240
-rw-r--r--src/client/northstar/dash-nodes/HistogramBox.scss40
-rw-r--r--src/client/northstar/dash-nodes/HistogramBox.tsx175
-rw-r--r--src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss42
-rw-r--r--src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx122
-rw-r--r--src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss13
-rw-r--r--src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx80
7 files changed, 0 insertions, 712 deletions
diff --git a/src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts b/src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts
deleted file mode 100644
index 6b36ffc9e..000000000
--- a/src/client/northstar/dash-nodes/HistogramBinPrimitiveCollection.ts
+++ /dev/null
@@ -1,240 +0,0 @@
-import React = require("react");
-import { AttributeTransformationModel } from "../../northstar/core/attribute/AttributeTransformationModel";
-import { ChartType } from '../../northstar/model/binRanges/VisualBinRange';
-import { AggregateFunction, Bin, Brush, DoubleValueAggregateResult, HistogramResult, MarginAggregateParameters, MarginAggregateResult } from "../../northstar/model/idea/idea";
-import { ModelHelpers } from "../../northstar/model/ModelHelpers";
-import { LABColor } from '../../northstar/utils/LABColor';
-import { PIXIRectangle } from "../../northstar/utils/MathUtil";
-import { StyleConstants } from "../../northstar/utils/StyleContants";
-import { HistogramBox } from "./HistogramBox";
-import "./HistogramBoxPrimitives.scss";
-
-export class HistogramBinPrimitive {
- constructor(init?: Partial<HistogramBinPrimitive>) {
- Object.assign(this, init);
- }
- public DataValue: number = 0;
- public Rect: PIXIRectangle = PIXIRectangle.EMPTY;
- public MarginRect: PIXIRectangle = PIXIRectangle.EMPTY;
- public MarginPercentage: number = 0;
- public Color: number = StyleConstants.WARNING_COLOR;
- public Opacity: number = 1;
- public BrushIndex: number = 0;
- public BarAxis: number = -1;
-}
-
-export class HistogramBinPrimitiveCollection {
- private static TOLERANCE: number = 0.0001;
-
- private _histoBox: HistogramBox;
- private get histoOp() { return this._histoBox.HistoOp; }
- private get histoResult() { return this.histoOp.Result as HistogramResult; }
- private get sizeConverter() { return this._histoBox.SizeConverter; }
- public BinPrimitives: Array<HistogramBinPrimitive> = new Array<HistogramBinPrimitive>();
- public HitGeom: PIXIRectangle = PIXIRectangle.EMPTY;
-
- constructor(bin: Bin, histoBox: HistogramBox) {
- this._histoBox = histoBox;
- let brushing = this.setupBrushing(bin, this.histoOp.Normalization); // X= 0, Y = 1, V = 2
-
- brushing.orderedBrushes.reduce((brushFactorSum, brush) => {
- switch (histoBox.ChartType) {
- case ChartType.VerticalBar: return this.createVerticalBarChartBinPrimitives(bin, brush, brushing.maxAxis, this.histoOp.Normalization);
- case ChartType.HorizontalBar: return this.createHorizontalBarChartBinPrimitives(bin, brush, brushing.maxAxis, this.histoOp.Normalization);
- case ChartType.SinglePoint: return this.createSinglePointChartBinPrimitives(bin, brush);
- case ChartType.HeatMap: return this.createHeatmapBinPrimitives(bin, brush, brushFactorSum);
- }
- }, 0);
-
- // adjust brush rects (stacking or not)
- var allBrushIndex = ModelHelpers.AllBrushIndex(this.histoResult);
- var filteredBinPrims = this.BinPrimitives.filter(b => b.BrushIndex !== allBrushIndex && b.DataValue !== 0.0);
- filteredBinPrims.reduce((sum, fbp) => {
- if (histoBox.ChartType === ChartType.VerticalBar) {
- if (this.histoOp.Y.AggregateFunction === AggregateFunction.Count) {
- fbp.Rect = new PIXIRectangle(fbp.Rect.x, fbp.Rect.y - sum, fbp.Rect.width, fbp.Rect.height);
- fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x, fbp.MarginRect.y - sum, fbp.MarginRect.width, fbp.MarginRect.height);
- return sum + fbp.Rect.height;
- }
- if (this.histoOp.Y.AggregateFunction === AggregateFunction.Avg) {
- var w = fbp.Rect.width / 2.0;
- fbp.Rect = new PIXIRectangle(fbp.Rect.x + sum, fbp.Rect.y, fbp.Rect.width / filteredBinPrims.length, fbp.Rect.height);
- fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x - w + sum + (fbp.Rect.width / 2.0), fbp.MarginRect.y, fbp.MarginRect.width, fbp.MarginRect.height);
- return sum + fbp.Rect.width;
- }
- }
- else if (histoBox.ChartType === ChartType.HorizontalBar) {
- if (this.histoOp.X.AggregateFunction === AggregateFunction.Count) {
- fbp.Rect = new PIXIRectangle(fbp.Rect.x + sum, fbp.Rect.y, fbp.Rect.width, fbp.Rect.height);
- fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x + sum, fbp.MarginRect.y, fbp.MarginRect.width, fbp.MarginRect.height);
- return sum + fbp.Rect.width;
- }
- if (this.histoOp.X.AggregateFunction === AggregateFunction.Avg) {
- var h = fbp.Rect.height / 2.0;
- fbp.Rect = new PIXIRectangle(fbp.Rect.x, fbp.Rect.y + sum, fbp.Rect.width, fbp.Rect.height / filteredBinPrims.length);
- fbp.MarginRect = new PIXIRectangle(fbp.MarginRect.x, fbp.MarginRect.y - h + sum + (fbp.Rect.height / 2.0), fbp.MarginRect.width, fbp.MarginRect.height);
- return sum + fbp.Rect.height;
- }
- }
- return 0;
- }, 0);
- this.BinPrimitives = this.BinPrimitives.reverse();
- var f = this.BinPrimitives.filter(b => b.BrushIndex === allBrushIndex);
- this.HitGeom = f.length > 0 ? f[0].Rect : PIXIRectangle.EMPTY;
- }
-
- private setupBrushing(bin: Bin, normalization: number) {
- var overlapBrushIndex = ModelHelpers.OverlapBrushIndex(this.histoResult);
- var orderedBrushes = [this.histoResult.brushes![0], this.histoResult.brushes![overlapBrushIndex]];
- this.histoResult.brushes!.map(brush => brush.brushIndex !== 0 && brush.brushIndex !== overlapBrushIndex && orderedBrushes.push(brush));
- return {
- orderedBrushes,
- maxAxis: orderedBrushes.reduce((prev, Brush) => {
- let aggResult = this.getBinValue(normalization, bin, Brush.brushIndex!);
- return aggResult !== undefined && aggResult > prev ? aggResult : prev;
- }, Number.MIN_VALUE)
- };
- }
-
- private createHeatmapBinPrimitives(bin: Bin, brush: Brush, brushFactorSum: number): number {
-
- let unNormalizedValue = this.getBinValue(2, bin, brush.brushIndex!);
- if (unNormalizedValue === undefined) {
- return brushFactorSum;
- }
-
- var normalizedValue = (unNormalizedValue - this._histoBox.ValueRange[0]) / (Math.abs((this._histoBox.ValueRange[1] - this._histoBox.ValueRange[0])) < HistogramBinPrimitiveCollection.TOLERANCE ?
- unNormalizedValue : this._histoBox.ValueRange[1] - this._histoBox.ValueRange[0]);
-
- let allUnNormalizedValue = this.getBinValue(2, bin, ModelHelpers.AllBrushIndex(this.histoResult));
-
- // bcz: are these calls needed?
- let [xFrom, xTo] = this.sizeConverter.DataToScreenXAxisRange(this._histoBox.VisualBinRanges, 0, bin);
- let [yFrom, yTo] = this.sizeConverter.DataToScreenYAxisRange(this._histoBox.VisualBinRanges, 1, bin);
-
- var returnBrushFactorSum = brushFactorSum;
- if (allUnNormalizedValue !== undefined) {
- var brushFactor = (unNormalizedValue / allUnNormalizedValue);
- returnBrushFactorSum += brushFactor;
- returnBrushFactorSum = Math.min(returnBrushFactorSum, 1.0);
-
- var tempRect = new PIXIRectangle(xFrom, yTo, xTo - xFrom, yFrom - yTo);
- var ratio = (tempRect.width / tempRect.height);
- var newHeight = Math.sqrt((1.0 / ratio) * ((tempRect.width * tempRect.height) * returnBrushFactorSum));
- var newWidth = newHeight * ratio;
-
- xFrom = (tempRect.x + (tempRect.width - newWidth) / 2.0);
- yTo = (tempRect.y + (tempRect.height - newHeight) / 2.0);
- xTo = (xFrom + newWidth);
- yFrom = (yTo + newHeight);
- }
- var alpha = 0.0;
- var color = this.baseColorFromBrush(brush);
- var lerpColor = LABColor.Lerp(
- LABColor.FromColor(StyleConstants.MIN_VALUE_COLOR),
- LABColor.FromColor(color),
- (alpha + Math.pow(normalizedValue, 1.0 / 3.0) * (1.0 - alpha)));
- var dataColor = LABColor.ToColor(lerpColor);
-
- this.createBinPrimitive(-1, brush, PIXIRectangle.EMPTY, 0, xFrom, xTo, yFrom, yTo, dataColor, 1, unNormalizedValue);
- return returnBrushFactorSum;
- }
-
- private createSinglePointChartBinPrimitives(bin: Bin, brush: Brush): number {
- let unNormalizedValue = this.getBinValue(2, bin, brush.brushIndex!);
- if (unNormalizedValue !== undefined) {
- let [xFrom, xTo] = this.sizeConverter.DataToScreenPointRange(0, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, this.histoOp.X, this.histoResult, brush.brushIndex!));
- let [yFrom, yTo] = this.sizeConverter.DataToScreenPointRange(1, bin, ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, this.histoOp.Y, this.histoResult, brush.brushIndex!));
-
- if (xFrom !== undefined && yFrom !== undefined && xTo !== undefined && yTo !== undefined) {
- this.createBinPrimitive(-1, brush, PIXIRectangle.EMPTY, 0, xFrom, xTo, yFrom, yTo, this.baseColorFromBrush(brush), 1, unNormalizedValue);
- }
- }
- return 0;
- }
-
- private createVerticalBarChartBinPrimitives(bin: Bin, brush: Brush, binBrushMaxAxis: number, normalization: number): number {
- let dataValue = this.getBinValue(1, bin, brush.brushIndex!);
- if (dataValue !== undefined) {
- let [yFrom, yValue, yTo] = this.sizeConverter.DataToScreenNormalizedRange(dataValue, normalization, 1, binBrushMaxAxis);
- let [xFrom, xTo] = this.sizeConverter.DataToScreenXAxisRange(this._histoBox.VisualBinRanges, 0, bin);
-
- var yMarginAbsolute = this.getMargin(bin, brush, this.histoOp.Y);
- var marginRect = new PIXIRectangle(xFrom + (xTo - xFrom) / 2.0 - 1,
- this.sizeConverter.DataToScreenY(yValue + yMarginAbsolute), 2,
- this.sizeConverter.DataToScreenY(yValue - yMarginAbsolute) - this.sizeConverter.DataToScreenY(yValue + yMarginAbsolute));
-
- this.createBinPrimitive(1, brush, marginRect, 0, xFrom, xTo, yFrom, yTo,
- this.baseColorFromBrush(brush), normalization !== 0 ? 1 : 0.6 * binBrushMaxAxis / this.sizeConverter.DataRanges[1] + 0.4, dataValue);
- }
- return 0;
- }
-
- private createHorizontalBarChartBinPrimitives(bin: Bin, brush: Brush, binBrushMaxAxis: number, normalization: number): number {
- let dataValue = this.getBinValue(0, bin, brush.brushIndex!);
- if (dataValue !== undefined) {
- let [xFrom, xValue, xTo] = this.sizeConverter.DataToScreenNormalizedRange(dataValue, normalization, 0, binBrushMaxAxis);
- let [yFrom, yTo] = this.sizeConverter.DataToScreenYAxisRange(this._histoBox.VisualBinRanges, 1, bin);
-
- var xMarginAbsolute = this.sizeConverter.IsSmall ? 0 : this.getMargin(bin, brush, this.histoOp.X);
- var marginRect = new PIXIRectangle(this.sizeConverter.DataToScreenX(xValue - xMarginAbsolute),
- yTo + (yFrom - yTo) / 2.0 - 1,
- this.sizeConverter.DataToScreenX(xValue + xMarginAbsolute) - this.sizeConverter.DataToScreenX(xValue - xMarginAbsolute),
- 2.0);
-
- this.createBinPrimitive(0, brush, marginRect, 0, xFrom, xTo, yFrom, yTo,
- this.baseColorFromBrush(brush), normalization !== 1 ? 1 : 0.6 * binBrushMaxAxis / this.sizeConverter.DataRanges[0] + 0.4, dataValue);
- }
- return 0;
- }
-
- public getBinValue(axis: number, bin: Bin, brushIndex: number) {
- var aggregateKey = ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, axis === 0 ? this.histoOp.X : axis === 1 ? this.histoOp.Y : this.histoOp.V, this.histoResult, brushIndex);
- let dataValue = ModelHelpers.GetAggregateResult(bin, aggregateKey) as DoubleValueAggregateResult;
- return dataValue !== null && dataValue.hasResult ? dataValue.result : undefined;
- }
-
- private getMargin(bin: Bin, brush: Brush, axis: AttributeTransformationModel) {
- var marginParams = new MarginAggregateParameters();
- marginParams.aggregateFunction = axis.AggregateFunction;
- var marginAggregateKey = ModelHelpers.CreateAggregateKey(this.histoOp.Schema!.distinctAttributeParameters, axis, this.histoResult, brush.brushIndex!, marginParams);
- let aggResult = ModelHelpers.GetAggregateResult(bin, marginAggregateKey);
- return aggResult instanceof MarginAggregateResult && aggResult.absolutMargin ? aggResult.absolutMargin : 0;
- }
-
- private createBinPrimitive(barAxis: number, brush: Brush, marginRect: PIXIRectangle,
- marginPercentage: number, xFrom: number, xTo: number, yFrom: number, yTo: number, color: number, opacity: number, dataValue: number) {
- var binPrimitive = new HistogramBinPrimitive(
- {
- Rect: new PIXIRectangle(xFrom, yTo, xTo - xFrom, yFrom - yTo),
- MarginRect: marginRect,
- MarginPercentage: marginPercentage,
- BrushIndex: brush.brushIndex,
- Color: color,
- Opacity: opacity,
- DataValue: dataValue,
- BarAxis: barAxis
- });
- this.BinPrimitives.push(binPrimitive);
- }
-
- private baseColorFromBrush(brush: Brush): number {
- let bc = StyleConstants.BRUSH_COLORS;
- if (brush.brushIndex === ModelHelpers.RestBrushIndex(this.histoResult)) {
- return StyleConstants.HIGHLIGHT_COLOR;
- }
- else if (brush.brushIndex === ModelHelpers.OverlapBrushIndex(this.histoResult)) {
- return StyleConstants.OVERLAP_COLOR;
- }
- else if (brush.brushIndex === ModelHelpers.AllBrushIndex(this.histoResult)) {
- return 0x00ff00;
- }
- else if (bc.length > 0) {
- return bc[brush.brushIndex! % bc.length];
- }
- // else if (this.histoOp.BrushColors.length > 0) {
- // return this.histoOp.BrushColors[brush.brushIndex! % this.histoOp.BrushColors.length];
- // }
- return StyleConstants.HIGHLIGHT_COLOR;
- }
-}
diff --git a/src/client/northstar/dash-nodes/HistogramBox.scss b/src/client/northstar/dash-nodes/HistogramBox.scss
deleted file mode 100644
index 06d781263..000000000
--- a/src/client/northstar/dash-nodes/HistogramBox.scss
+++ /dev/null
@@ -1,40 +0,0 @@
-.histogrambox-container {
- padding: 0vw;
- position: absolute;
- top: -50%;
- left:-50%;
- text-align: center;
- width: 100%;
- height: 100%;
- background: black;
- }
- .histogrambox-xaxislabel {
- position:absolute;
- left:0;
- width:100%;
- text-align: center;
- bottom:0;
- background: lightgray;
- font-size: 14;
- font-weight: bold;
- }
- .histogrambox-yaxislabel {
- position:absolute;
- height:100%;
- width: 25px;
- left:0;
- bottom:0;
- background: lightgray;
- }
- .histogrambox-yaxislabel-text {
- position:absolute;
- left:0;
- width: 1000px;
- transform-origin: 10px 10px;
- transform: rotate(-90deg);
- text-align: left;
- font-size: 14;
- font-weight: bold;
- bottom: calc(50% - 25px);
- }
- \ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramBox.tsx b/src/client/northstar/dash-nodes/HistogramBox.tsx
deleted file mode 100644
index 8fee53fb9..000000000
--- a/src/client/northstar/dash-nodes/HistogramBox.tsx
+++ /dev/null
@@ -1,175 +0,0 @@
-import React = require("react");
-import { action, computed, observable, reaction, runInAction, trace } from "mobx";
-import { observer } from "mobx-react";
-import { CurrentUserUtils } from "../../../server/authentication/models/current_user_utils";
-import { ChartType, VisualBinRange } from '../../northstar/model/binRanges/VisualBinRange';
-import { VisualBinRangeHelper } from "../../northstar/model/binRanges/VisualBinRangeHelper";
-import { AggregateBinRange, AggregateFunction, BinRange, Catalog, DoubleValueAggregateResult, HistogramResult } from "../../northstar/model/idea/idea";
-import { ModelHelpers } from "../../northstar/model/ModelHelpers";
-import { HistogramOperation } from "../../northstar/operations/HistogramOperation";
-import { SizeConverter } from "../../northstar/utils/SizeConverter";
-import { DragManager } from "../../util/DragManager";
-import { FieldView, FieldViewProps } from "../../views/nodes/FieldView";
-import { AttributeTransformationModel } from "../core/attribute/AttributeTransformationModel";
-import { HistogramField } from "../dash-fields/HistogramField";
-import "../utils/Extensions";
-import "./HistogramBox.scss";
-import { HistogramBoxPrimitives } from './HistogramBoxPrimitives';
-import { HistogramLabelPrimitives } from "./HistogramLabelPrimitives";
-import { StyleConstants } from "../utils/StyleContants";
-import { Cast } from "../../../new_fields/Types";
-import { Doc, DocListCast, DocListCastAsync } from "../../../new_fields/Doc";
-import { Id } from "../../../new_fields/FieldSymbols";
-
-
-@observer
-export class HistogramBox extends React.Component<FieldViewProps> {
- public static LayoutString(fieldStr: string) { return FieldView.LayoutString(HistogramBox, fieldStr); }
- private _dropXRef = React.createRef<HTMLDivElement>();
- private _dropYRef = React.createRef<HTMLDivElement>();
- private _dropXDisposer?: DragManager.DragDropDisposer;
- private _dropYDisposer?: DragManager.DragDropDisposer;
-
- @observable public HistoOp: HistogramOperation = HistogramOperation.Empty;
- @observable public VisualBinRanges: VisualBinRange[] = [];
- @observable public ValueRange: number[] = [];
- @computed public get HistogramResult(): HistogramResult { return this.HistoOp.Result as HistogramResult; }
- @observable public SizeConverter: SizeConverter = new SizeConverter();
-
- @computed get createOperationParamsCache() { return this.HistoOp.CreateOperationParameters(); }
- @computed get BinRanges() { return this.HistogramResult ? this.HistogramResult.binRanges : undefined; }
- @computed get ChartType() {
- return !this.BinRanges ? ChartType.SinglePoint : this.BinRanges[0] instanceof AggregateBinRange ?
- (this.BinRanges[1] instanceof AggregateBinRange ? ChartType.SinglePoint : ChartType.HorizontalBar) :
- this.BinRanges[1] instanceof AggregateBinRange ? ChartType.VerticalBar : ChartType.HeatMap;
- }
-
- @action
- dropX = (e: Event, de: DragManager.DropEvent) => {
- if (de.complete.docDragData) {
- let h = Cast(de.complete.docDragData.draggedDocuments[0].data, HistogramField);
- if (h) {
- this.HistoOp.X = h.HistoOp.X;
- }
- e.stopPropagation();
- e.preventDefault();
- }
- }
- @action
- dropY = (e: Event, de: DragManager.DropEvent) => {
- if (de.complete.docDragData) {
- let h = Cast(de.complete.docDragData.draggedDocuments[0].data, HistogramField);
- if (h) {
- this.HistoOp.Y = h.HistoOp.X;
- }
- e.stopPropagation();
- e.preventDefault();
- }
- }
-
- @action
- xLabelPointerDown = (e: React.PointerEvent) => {
- this.HistoOp.X = new AttributeTransformationModel(this.HistoOp.X.AttributeModel, this.HistoOp.X.AggregateFunction === AggregateFunction.None ? AggregateFunction.Count : AggregateFunction.None);
- }
- @action
- yLabelPointerDown = (e: React.PointerEvent) => {
- this.HistoOp.Y = new AttributeTransformationModel(this.HistoOp.Y.AttributeModel, this.HistoOp.Y.AggregateFunction === AggregateFunction.None ? AggregateFunction.Count : AggregateFunction.None);
- }
-
- componentDidMount() {
- if (this._dropXRef.current) {
- this._dropXDisposer = DragManager.MakeDropTarget(this._dropXRef.current, this.dropX.bind(this));
- }
- if (this._dropYRef.current) {
- this._dropYDisposer = DragManager.MakeDropTarget(this._dropYRef.current, this.dropY.bind(this));
- }
- reaction(() => CurrentUserUtils.NorthstarDBCatalog, (catalog?: Catalog) => this.activateHistogramOperation(catalog), { fireImmediately: true });
- reaction(() => [this.VisualBinRanges && this.VisualBinRanges.slice()], () => this.SizeConverter.SetVisualBinRanges(this.VisualBinRanges));
- reaction(() => [this.props.PanelWidth(), this.props.PanelHeight()], (size: number[]) => this.SizeConverter.SetIsSmall(size[0] < 40 && size[1] < 40));
- reaction(() => this.HistogramResult ? this.HistogramResult.binRanges : undefined,
- (binRanges: BinRange[] | undefined) => {
- if (binRanges) {
- this.VisualBinRanges.splice(0, this.VisualBinRanges.length, ...binRanges.map((br, ind) =>
- VisualBinRangeHelper.GetVisualBinRange(this.HistoOp.Schema!.distinctAttributeParameters, br, this.HistogramResult, ind ? this.HistoOp.Y : this.HistoOp.X, this.ChartType)));
-
- let valueAggregateKey = ModelHelpers.CreateAggregateKey(this.HistoOp.Schema!.distinctAttributeParameters, this.HistoOp.V, this.HistogramResult, ModelHelpers.AllBrushIndex(this.HistogramResult));
- this.ValueRange = Object.values(this.HistogramResult.bins!).reduce((prev, cur) => {
- let value = ModelHelpers.GetAggregateResult(cur, valueAggregateKey) as DoubleValueAggregateResult;
- return value && value.hasResult ? [Math.min(prev[0], value.result!), Math.max(prev[1], value.result!)] : prev;
- }, [Number.MAX_VALUE, Number.MIN_VALUE]);
- }
- });
- }
-
- componentWillUnmount() {
- if (this._dropXDisposer) {
- this._dropXDisposer();
- }
- if (this._dropYDisposer) {
- this._dropYDisposer();
- }
- }
-
- async activateHistogramOperation(catalog?: Catalog) {
- if (catalog) {
- let histoOp = await Cast(this.props.Document[this.props.fieldKey], HistogramField);
- runInAction(() => {
- this.HistoOp = histoOp ? histoOp.HistoOp : HistogramOperation.Empty;
- if (this.HistoOp !== HistogramOperation.Empty) {
- reaction(() => DocListCast(this.props.Document.linkedFromDocs), (docs) => this.HistoOp.Links.splice(0, this.HistoOp.Links.length, ...docs), { fireImmediately: true });
- reaction(() => DocListCast(this.props.Document.brushingDocs).length,
- async () => {
- let brushingDocs = await DocListCastAsync(this.props.Document.brushingDocs);
- const proto = this.props.Document.proto;
- if (proto && brushingDocs) {
- let mapped = brushingDocs.map((brush, i) => {
- brush.backgroundColor = StyleConstants.BRUSH_COLORS[i % StyleConstants.BRUSH_COLORS.length];
- let brushed = DocListCast(brush.brushingDocs);
- if (!brushed.length) return null;
- return { l: brush, b: brushed[0][Id] === proto[Id] ? brushed[1] : brushed[0] };
- });
- runInAction(() => this.HistoOp.BrushLinks.splice(0, this.HistoOp.BrushLinks.length, ...mapped.filter(m => m) as { l: Doc, b: Doc }[]));
- }
- }, { fireImmediately: true });
- reaction(() => this.createOperationParamsCache, () => this.HistoOp.Update(), { fireImmediately: true });
- }
- });
- }
- }
-
- @action
- private onScrollWheel = (e: React.WheelEvent) => {
- this.HistoOp.DrillDown(e.deltaY > 0);
- e.stopPropagation();
- }
-
- render() {
- let labelY = this.HistoOp && this.HistoOp.Y ? this.HistoOp.Y.PresentedName : "<...>";
- let labelX = this.HistoOp && this.HistoOp.X ? this.HistoOp.X.PresentedName : "<...>";
- let loff = this.SizeConverter.LeftOffset;
- let toff = this.SizeConverter.TopOffset;
- let roff = this.SizeConverter.RightOffset;
- let boff = this.SizeConverter.BottomOffset;
- return (
- <div className="histogrambox-container" onWheel={this.onScrollWheel}>
- <div className="histogrambox-yaxislabel" onPointerDown={this.yLabelPointerDown} ref={this._dropYRef} >
- <span className="histogrambox-yaxislabel-text">
- {labelY}
- </span>
- </div>
- <div className="histogrambox-primitives" style={{
- transform: `translate(${loff + 25}px, ${toff}px)`,
- width: `calc(100% - ${loff + roff + 25}px)`,
- height: `calc(100% - ${toff + boff}px)`,
- }}>
- <HistogramLabelPrimitives HistoBox={this} />
- <HistogramBoxPrimitives HistoBox={this} />
- </div>
- <div className="histogrambox-xaxislabel" onPointerDown={this.xLabelPointerDown} ref={this._dropXRef} >
- {labelX}
- </div>
- </div>
- );
- }
-}
-
diff --git a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
deleted file mode 100644
index 26203612a..000000000
--- a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.scss
+++ /dev/null
@@ -1,42 +0,0 @@
-.histogramboxprimitives-container {
- width: 100%;
- height: 100%;
-}
-.histogramboxprimitives-border {
- border: 3px;
- pointer-events: none;
- position: absolute;
- fill:"transparent";
- stroke: white;
- stroke-width: 1px;
-}
-.histogramboxprimitives-bar {
- position: absolute;
- border: 1px;
- border-style: solid;
- border-color: #282828;
- pointer-events: all;
-}
-
-.histogramboxprimitives-placer {
- position: absolute;
- pointer-events: none;
- width: 100%;
- height: 100%;
-}
-.histogramboxprimitives-svgContainer {
- position: absolute;
- top:0;
- left:0;
- width:100%;
- height: 100%;
-}
-.histogramboxprimitives-line {
- position: absolute;
- background: darkGray;
- stroke: darkGray;
- stroke-width: 1px;
- width:100%;
- height:100%;
- opacity: 0.4;
-} \ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
deleted file mode 100644
index 66d91cc1d..000000000
--- a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
+++ /dev/null
@@ -1,122 +0,0 @@
-import React = require("react");
-import { computed, observable, reaction, runInAction, trace, action } from "mobx";
-import { observer } from "mobx-react";
-import { Utils as DashUtils, emptyFunction } from '../../../Utils';
-import { FilterModel } from "../../northstar/core/filter/FilterModel";
-import { ModelHelpers } from "../../northstar/model/ModelHelpers";
-import { ArrayUtil } from "../../northstar/utils/ArrayUtil";
-import { LABColor } from '../../northstar/utils/LABColor';
-import { PIXIRectangle } from "../../northstar/utils/MathUtil";
-import { StyleConstants } from "../../northstar/utils/StyleContants";
-import { HistogramBinPrimitiveCollection, HistogramBinPrimitive } from "./HistogramBinPrimitiveCollection";
-import { HistogramBox } from "./HistogramBox";
-import "./HistogramBoxPrimitives.scss";
-
-export interface HistogramPrimitivesProps {
- HistoBox: HistogramBox;
-}
-@observer
-export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesProps> {
- private get histoOp() { return this.props.HistoBox.HistoOp; }
- private get renderDimension() { return this.props.HistoBox.SizeConverter.RenderDimension; }
- @observable _selectedPrims: HistogramBinPrimitive[] = [];
- @computed get xaxislines() { return this.renderGridLinesAndLabels(0); }
- @computed get yaxislines() { return this.renderGridLinesAndLabels(1); }
- @computed get selectedPrimitives() { return this._selectedPrims.map(bp => this.drawRect(bp.Rect, bp.BarAxis, undefined, "border")); }
- @computed get barPrimitives() {
- let histoResult = this.props.HistoBox.HistogramResult;
- if (!histoResult || !histoResult.bins || !this.props.HistoBox.VisualBinRanges.length) {
- return (null);
- }
- let allBrushIndex = ModelHelpers.AllBrushIndex(histoResult);
- return Object.keys(histoResult.bins).reduce((prims: JSX.Element[], key: string) => {
- let drawPrims = new HistogramBinPrimitiveCollection(histoResult.bins![key], this.props.HistoBox);
- let toggle = this.getSelectionToggle(drawPrims.BinPrimitives, allBrushIndex,
- ModelHelpers.GetBinFilterModel(histoResult.bins![key], allBrushIndex, histoResult, this.histoOp.X, this.histoOp.Y));
- drawPrims.BinPrimitives.filter(bp => bp.DataValue && bp.BrushIndex !== allBrushIndex).map(bp =>
- prims.push(...[{ r: bp.Rect, c: bp.Color }, { r: bp.MarginRect, c: StyleConstants.MARGIN_BARS_COLOR }].map(pair => this.drawRect(pair.r, bp.BarAxis, pair.c, "bar", toggle))));
- return prims;
- }, [] as JSX.Element[]);
- }
-
- componentDidMount() {
- reaction(() => this.props.HistoBox.HistoOp.FilterString, () => this._selectedPrims.length = this.histoOp.FilterModels.length = 0);
- }
-
- private getSelectionToggle(binPrimitives: HistogramBinPrimitive[], allBrushIndex: number, filterModel: FilterModel) {
- let rawAllBrushPrim = ArrayUtil.FirstOrDefault(binPrimitives, bp => bp.BrushIndex === allBrushIndex);
- if (!rawAllBrushPrim) {
- return emptyFunction;
- }
- let allBrushPrim = rawAllBrushPrim;
- return () => runInAction(() => {
- if (ArrayUtil.Contains(this.histoOp.FilterModels, filterModel)) {
- this._selectedPrims.splice(this._selectedPrims.indexOf(allBrushPrim), 1);
- this.histoOp.RemoveFilterModels([filterModel]);
- }
- else {
- this._selectedPrims.push(allBrushPrim);
- this.histoOp.AddFilterModels([filterModel]);
- }
- });
- }
-
- private renderGridLinesAndLabels(axis: number) {
- if (!this.props.HistoBox.SizeConverter.Initialized) {
- return (null);
- }
- let labels = this.props.HistoBox.VisualBinRanges[axis].GetLabels();
- return <svg className="histogramboxprimitives-svgContainer">
- {labels.reduce((prims, binLabel, i) => {
- let r = this.props.HistoBox.SizeConverter.DataToScreenRange(binLabel.minValue!, binLabel.maxValue!, axis);
- prims.push(this.drawLine(r.xFrom, r.yFrom, axis === 0 ? 0 : r.xTo - r.xFrom, axis === 0 ? r.yTo - r.yFrom : 0));
- if (i === labels.length - 1) {
- prims.push(this.drawLine(axis === 0 ? r.xTo : r.xFrom, axis === 0 ? r.yFrom : r.yTo, axis === 0 ? 0 : r.xTo - r.xFrom, axis === 0 ? r.yTo - r.yFrom : 0));
- }
- return prims;
- }, [] as JSX.Element[])}
- </svg>;
- }
-
- drawLine(xFrom: number, yFrom: number, width: number, height: number) {
- if (height < 0) {
- yFrom += height;
- height = -height;
- }
- if (width < 0) {
- xFrom += width;
- width = -width;
- }
- let trans2Xpercent = `${(xFrom + width) / this.renderDimension * 100}%`;
- let trans2Ypercent = `${(yFrom + height) / this.renderDimension * 100}%`;
- let trans1Xpercent = `${xFrom / this.renderDimension * 100}%`;
- let trans1Ypercent = `${yFrom / this.renderDimension * 100}%`;
- return <line className="histogramboxprimitives-line" key={DashUtils.GenerateGuid()} x1={trans1Xpercent} x2={`${trans2Xpercent}`} y1={trans1Ypercent} y2={`${trans2Ypercent}`} />;
- }
- drawRect(r: PIXIRectangle, barAxis: number, color: number | undefined, classExt: string, tapHandler: () => void = emptyFunction) {
- if (r.height < 0) {
- r.y += r.height;
- r.height = -r.height;
- }
- if (r.width < 0) {
- r.x += r.width;
- r.width = -r.width;
- }
- let transXpercent = `${r.x / this.renderDimension * 100}%`;
- let transYpercent = `${r.y / this.renderDimension * 100}%`;
- let widthXpercent = `${r.width / this.renderDimension * 100}%`;
- let heightYpercent = `${r.height / this.renderDimension * 100}%`;
- return (<rect className={`histogramboxprimitives-${classExt}`} key={DashUtils.GenerateGuid()} onPointerDown={(e: React.PointerEvent) => { if (e.button === 0) tapHandler(); }}
- x={transXpercent} width={`${widthXpercent}`} y={transYpercent} height={`${heightYpercent}`} fill={color ? `${LABColor.RGBtoHexString(color)}` : "transparent"} />);
- }
- render() {
- return <div className="histogramboxprimitives-container">
- {this.xaxislines}
- {this.yaxislines}
- <svg className="histogramboxprimitives-svgContainer">
- {this.barPrimitives}
- {this.selectedPrimitives}
- </svg>
- </div>;
- }
-}
diff --git a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
deleted file mode 100644
index 304d33771..000000000
--- a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.scss
+++ /dev/null
@@ -1,13 +0,0 @@
-
- .histogramLabelPrimitives-gridlabel {
- position:absolute;
- transform-origin: left top;
- font-size: 11;
- color:white;
- }
- .histogramLabelPrimitives-placer {
- position:absolute;
- width:100%;
- height:100%;
- pointer-events: none;
- } \ No newline at end of file
diff --git a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
deleted file mode 100644
index 62aebd3c6..000000000
--- a/src/client/northstar/dash-nodes/HistogramLabelPrimitives.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-import React = require("react");
-import { action, computed, reaction } from "mobx";
-import { observer } from "mobx-react";
-import { Utils as DashUtils } from '../../../Utils';
-import { NominalVisualBinRange } from "../model/binRanges/NominalVisualBinRange";
-import "../utils/Extensions";
-import { StyleConstants } from "../utils/StyleContants";
-import { HistogramBox } from "./HistogramBox";
-import "./HistogramLabelPrimitives.scss";
-import { HistogramPrimitivesProps } from "./HistogramBoxPrimitives";
-
-@observer
-export class HistogramLabelPrimitives extends React.Component<HistogramPrimitivesProps> {
- componentDidMount() {
- reaction(() => [this.props.HistoBox.props.PanelWidth(), this.props.HistoBox.SizeConverter.LeftOffset, this.props.HistoBox.VisualBinRanges.length],
- (fields) => HistogramLabelPrimitives.computeLabelAngle(fields[0], fields[1], this.props.HistoBox), { fireImmediately: true });
- }
-
- @action
- static computeLabelAngle(panelWidth: number, leftOffset: number, histoBox: HistogramBox) {
- const textWidth = 30;
- if (panelWidth > 0 && histoBox.VisualBinRanges.length && histoBox.VisualBinRanges[0] instanceof NominalVisualBinRange) {
- let space = (panelWidth - leftOffset * 2) / histoBox.VisualBinRanges[0].GetBins().length;
- histoBox.SizeConverter.SetLabelAngle(Math.min(Math.PI / 2, Math.max(Math.PI / 6, textWidth / space * Math.PI / 2)));
- } else if (histoBox.SizeConverter.LabelAngle) {
- histoBox.SizeConverter.SetLabelAngle(0);
- }
- }
- @computed get xaxislines() { return this.renderGridLinesAndLabels(0); }
- @computed get yaxislines() { return this.renderGridLinesAndLabels(1); }
-
- private renderGridLinesAndLabels(axis: number) {
- let sc = this.props.HistoBox.SizeConverter;
- let vb = this.props.HistoBox.VisualBinRanges;
- if (!vb.length || !sc.Initialized) {
- return (null);
- }
- let dim = (axis === 0 ? this.props.HistoBox.props.PanelWidth() : this.props.HistoBox.props.PanelHeight()) / ((axis === 0 && vb[axis] instanceof NominalVisualBinRange) ?
- (12 + 5) : // (<number>FontStyles.AxisLabel.fontSize + 5)));
- sc.MaxLabelSizes[axis].coords[axis] + 5);
-
- let labels = vb[axis].GetLabels();
- return labels.reduce((prims, binLabel, i) => {
- let r = sc.DataToScreenRange(binLabel.minValue!, binLabel.maxValue!, axis);
- if (i % Math.ceil(labels.length / dim) === 0 && binLabel.label) {
- const label = binLabel.label.Truncate(StyleConstants.MAX_CHAR_FOR_HISTOGRAM_LABELS, "...");
- const textHeight = 14; const textWidth = 30;
- let xStart = (axis === 0 ? r.xFrom + (r.xTo - r.xFrom) / 2.0 : r.xFrom - 10 - textWidth);
- let yStart = (axis === 1 ? r.yFrom - textHeight / 2 : r.yFrom);
-
- if (axis === 0 && vb[axis] instanceof NominalVisualBinRange) {
- let space = (r.xTo - r.xFrom) / sc.RenderDimension * this.props.HistoBox.props.PanelWidth();
- xStart += Math.max(textWidth / 2, (1 - textWidth / space) * textWidth / 2) - textHeight / 2;
- }
-
- let xPercent = axis === 1 ? `${xStart}px` : `${xStart / sc.RenderDimension * 100}%`;
- let yPercent = axis === 0 ? `${this.props.HistoBox.props.PanelHeight() - sc.BottomOffset - textHeight}px` : `${yStart / sc.RenderDimension * 100}%`;
-
- prims.push(
- <div className="histogramLabelPrimitives-placer" key={DashUtils.GenerateGuid()} style={{ transform: `translate(${xPercent}, ${yPercent})` }}>
- <div className="histogramLabelPrimitives-gridlabel" style={{ transform: `rotate(${axis === 0 ? sc.LabelAngle : 0}rad)` }}>
- {label}
- </div>
- </div>
- );
- }
- return prims;
- }, [] as JSX.Element[]);
- }
-
- render() {
- let xaxislines = this.xaxislines;
- let yaxislines = this.yaxislines;
- return <div className="histogramLabelPrimitives-container">
- {xaxislines}
- {yaxislines}
- </div>;
- }
-
-} \ No newline at end of file