aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbob <bcz@cs.brown.edu>2020-02-06 15:37:58 -0500
committerbob <bcz@cs.brown.edu>2020-02-06 15:37:58 -0500
commit696d8c769424e4c5ff85147ecd60571a254527fd (patch)
tree90953a59d7057926c5887157f58c7caa323aeab8 /src
parent045233f2a8b8e79e6a3255ed594218929db1b042 (diff)
fixed indexing bug in pivot drill down
Diffstat (limited to 'src')
-rw-r--r--src/client/views/collections/CollectionTimeView.tsx2
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx14
-rw-r--r--src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx2
3 files changed, 12 insertions, 6 deletions
diff --git a/src/client/views/collections/CollectionTimeView.tsx b/src/client/views/collections/CollectionTimeView.tsx
index c0e18714e..fb36a1b0c 100644
--- a/src/client/views/collections/CollectionTimeView.tsx
+++ b/src/client/views/collections/CollectionTimeView.tsx
@@ -308,7 +308,7 @@ export class CollectionTimeView extends CollectionSubView(doc => doc) {
}
Scripting.addGlobal(function pivotColumnClick(pivotDoc: Doc, bounds: ViewDefBounds) {
- console.log("filter down to key: " + pivotDoc._pivotField + " val:" + bounds.payload);
+ pivotDoc._docFilter = new List();
(bounds.payload as string[]).map(filterVal =>
Doc.setDocFilter(pivotDoc, StrCast(pivotDoc._pivotField), filterVal, "check"));
}); \ No newline at end of file
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
index 884f3b353..4ef579f27 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx
@@ -66,6 +66,11 @@ function getTextWidth(text: string, font: string): number {
return metrics.width;
}
+interface pivotColumn {
+ docs: Doc[],
+ filters: string[]
+}
+
export function computePivotLayout(
poolData: Map<string, PoolData>,
pivotDoc: Doc,
@@ -75,7 +80,7 @@ export function computePivotLayout(
viewDefsToJSX: (views: any) => ViewDefResult[]
) {
const fieldKey = "data";
- const pivotColumnGroups = new Map<FieldResult<Field>, { docs: Doc[], filters: string[] }>();
+ const pivotColumnGroups = new Map<FieldResult<Field>, pivotColumn>();
const pivotFieldKey = toLabel(pivotDoc._pivotField);
for (const doc of childDocs) {
@@ -129,7 +134,8 @@ export function computePivotLayout(
const expander = 1.05;
const gap = .15;
let x = 0;
- Array.from(pivotColumnGroups.keys()).sort().forEach(key => {
+ const sortedPivotKeys = Array.from(pivotColumnGroups.keys()).sort();
+ sortedPivotKeys.forEach(key => {
const val = pivotColumnGroups.get(key)!;
let y = 0;
let xCount = 0;
@@ -170,8 +176,8 @@ export function computePivotLayout(
});
const maxColHeight = pivotAxisWidth * expander * Math.ceil(maxInColumn / numCols);
- const dividers = Array.from(pivotColumnGroups.values()).map((pkey, i) =>
- ({ type: "div", color: "lightGray", x: i * pivotAxisWidth * (numCols * expander + gap), y: -maxColHeight + pivotAxisWidth, width: pivotAxisWidth * numCols * expander, height: maxColHeight, payload: pkey.filters }));
+ const dividers = sortedPivotKeys.map((key, i) =>
+ ({ type: "div", color: "lightGray", x: i * pivotAxisWidth * (numCols * expander + gap), y: -maxColHeight + pivotAxisWidth, width: pivotAxisWidth * numCols * expander, height: maxColHeight, payload: pivotColumnGroups.get(key)!.filters }));
groupNames.push(...dividers);
return normalizeResults(panelDim, max_text, childPairs, docMap, poolData, viewDefsToJSX, groupNames, 0, []);
}
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
index a34779046..1ac0d28f5 100644
--- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
+++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormView.tsx
@@ -778,7 +778,7 @@ export class CollectionFreeFormView extends CollectionSubView(PanZoomDocument) {
const backgroundColor = Cast(viewDef.color, "string");
return [x, y].some(val => val === undefined) ? undefined :
{
- ele: <div className="collectionFreeform-customDiv" key={"div" + x + y + z} onClick={e => this.onViewDefDivClick(e, viewDef)}
+ ele: <div className="collectionFreeform-customDiv" title={viewDef.payload.join(" ")} key={"div" + x + y + z} onClick={e => this.onViewDefDivClick(e, viewDef)}
style={{ width, height, backgroundColor, transform: `translate(${x}px, ${y}px)` }} />,
bounds: viewDef
};