aboutsummaryrefslogtreecommitdiff
path: root/src/client/northstar/dash-nodes
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2019-03-29 18:49:22 -0400
committerbob <bcz@cs.brown.edu>2019-03-29 18:49:22 -0400
commit6e993fb5817e8ddce756396e53883a42530f52bb (patch)
treeaeda672a6181aa50400be258285570f725c1a7b1 /src/client/northstar/dash-nodes
parent6e0439f36216af6ee25ff9a65d296e6f9ff28fd3 (diff)
brushes mostly working - some problems with cycles.
Diffstat (limited to 'src/client/northstar/dash-nodes')
-rw-r--r--src/client/northstar/dash-nodes/HistogramBox.tsx27
-rw-r--r--src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx14
2 files changed, 27 insertions, 14 deletions
diff --git a/src/client/northstar/dash-nodes/HistogramBox.tsx b/src/client/northstar/dash-nodes/HistogramBox.tsx
index b464e125c..9976ff6ad 100644
--- a/src/client/northstar/dash-nodes/HistogramBox.tsx
+++ b/src/client/northstar/dash-nodes/HistogramBox.tsx
@@ -1,5 +1,5 @@
import React = require("react")
-import { action, computed, observable, reaction, runInAction } from "mobx";
+import { action, computed, observable, reaction, runInAction, trace } from "mobx";
import { observer } from "mobx-react";
import Measure from "react-measure";
import { FieldWaiting, Opt } from "../../../fields/Field";
@@ -8,7 +8,7 @@ import { KeyStore } from "../../../fields/KeyStore";
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 { AggregateBinRange, AggregateFunction, BinRange, Catalog, DoubleValueAggregateResult, HistogramResult, Result } from "../../northstar/model/idea/idea";
import { ModelHelpers } from "../../northstar/model/ModelHelpers";
import { HistogramOperation } from "../../northstar/operations/HistogramOperation";
import { SizeConverter } from "../../northstar/utils/SizeConverter";
@@ -39,10 +39,10 @@ export class HistogramBox extends React.Component<FieldViewProps> {
@observable public HistoOp: HistogramOperation = HistogramOperation.Empty;
@observable public VisualBinRanges: VisualBinRange[] = [];
@observable public ValueRange: number[] = [];
+ @observable public HistogramResult: HistogramResult = new HistogramResult();
@observable public SizeConverter: SizeConverter = new SizeConverter();
- @computed get createOperationParamsCache() { return this.HistoOp.CreateOperationParameters(); }
- @computed get HistogramResult() { return this.HistoOp ? this.HistoOp.Result as HistogramResult : undefined; }
+ @computed get createOperationParamsCache() { trace(); 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 ?
@@ -123,12 +123,21 @@ export class HistogramBox extends React.Component<FieldViewProps> {
this.props.doc.GetTAsync(this.props.fieldKey, HistogramField).then((histoOp: Opt<HistogramField>) => runInAction(() => {
this.HistoOp = histoOp ? histoOp.Data : HistogramOperation.Empty;
if (this.HistoOp != HistogramOperation.Empty) {
- reaction(() => this.props.doc.GetList(KeyStore.LinkedFromDocs, []),
- (docs: Document[]) => {
+ this.HistoOp.YieldResult = (r: Result) => action(() => this.HistogramResult = r as HistogramResult)();
+ reaction(() => this.props.doc.GetList(KeyStore.LinkedFromDocs, []), (docs: Document[]) => this.HistoOp.Links.splice(0, this.HistoOp.Links.length, ...docs), { fireImmediately: true });
+ reaction(() => this.props.doc.GetList(KeyStore.BrushingDocs, []).length,
+ () => {
+ let brushingDocs = this.props.doc.GetList(KeyStore.BrushingDocs, [] as Document[]);
var availableColors = StyleConstants.BRUSH_COLORS.map(c => c);
- docs.map((brush, i) => brush.SetNumber(KeyStore.BackgroundColor, availableColors[i % availableColors.length]));
- this.HistoOp.BrushLinks.splice(0, this.HistoOp.BrushLinks.length, ...docs);
- //this.HistoOp.Links.splice(0, this.HistoOp.Links.length, ...docs)
+ let proto = this.props.doc.GetPrototype() as Document;
+ let brushingLinks = brushingDocs.map((brush, i) => {
+ // brush.SetNumber(KeyStore.BackgroundColor, availableColors[i % availableColors.length]);
+ let brushed = brush.GetList(KeyStore.BrushingDocs, [] as Document[]);
+ if (!brushed || brushed.length < 2)
+ return undefined;
+ return { l: brush, b: brushed[0].Id == proto.Id ? brushed[1] : brushed[0] }
+ }).filter(x => x != undefined) as { l: Document, b: Document }[];
+ this.HistoOp.BrushLinks.splice(0, this.HistoOp.BrushLinks.length, ...brushingLinks);
}, { fireImmediately: true });
reaction(() => this.createOperationParamsCache, () => this.HistoOp.Update(), { fireImmediately: true });
}
diff --git a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
index 648070241..c97acb064 100644
--- a/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
+++ b/src/client/northstar/dash-nodes/HistogramBoxPrimitives.tsx
@@ -1,5 +1,5 @@
import React = require("react")
-import { computed, observable, runInAction, reaction } from "mobx";
+import { computed, observable, runInAction, reaction, untracked, trace } from "mobx";
import { observer } from "mobx-react";
import { Utils as DashUtils } from '../../../Utils';
import { AttributeTransformationModel } from "../../northstar/core/attribute/AttributeTransformationModel";
@@ -20,7 +20,7 @@ export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesP
private get histoOp() { return this.props.HistoBox.HistoOp; }
private get renderDimension() { return this.props.HistoBox.SizeConverter.RenderDimension; }
componentDidMount() {
- reaction(() => this.props.HistoBox.HistogramResult, () => this._selectedPrims.length = 0);
+ reaction(() => this.props.HistoBox.HistoOp.FilterString, () => this._selectedPrims.length = this.histoOp.FilterModels.length = 0);
}
@observable _selectedPrims: HistogramBinPrimitive[] = [];
@computed get xaxislines() { return this.renderGridLinesAndLabels(0); }
@@ -30,10 +30,10 @@ export class HistogramBoxPrimitives extends React.Component<HistogramPrimitivesP
let histoResult = this.props.HistoBox.HistogramResult;
if (!histoResult || !histoResult.bins || !this.props.HistoBox.VisualBinRanges.length)
return (null);
+ trace();
let allBrushIndex = ModelHelpers.AllBrushIndex(histoResult);
return Object.keys(histoResult.bins).reduce((prims, key) => {
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 =>
@@ -327,6 +327,7 @@ export class HistogramBinPrimitiveCollection {
}
private baseColorFromBrush(brush: Brush): number {
+ let bc = StyleConstants.BRUSH_COLORS;
if (brush.brushIndex == ModelHelpers.RestBrushIndex(this.histoResult)) {
return StyleConstants.HIGHLIGHT_COLOR;
}
@@ -336,9 +337,12 @@ export class HistogramBinPrimitiveCollection {
else if (brush.brushIndex == ModelHelpers.AllBrushIndex(this.histoResult)) {
return 0x00ff00;
}
- else if (this.histoOp.BrushColors.length > 0) {
- return this.histoOp.BrushColors[brush.brushIndex! % this.histoOp.BrushColors.length];
+ 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;
}
} \ No newline at end of file