diff options
| author | bob <bcz@cs.brown.edu> | 2020-02-06 15:37:58 -0500 |
|---|---|---|
| committer | bob <bcz@cs.brown.edu> | 2020-02-06 15:37:58 -0500 |
| commit | 696d8c769424e4c5ff85147ecd60571a254527fd (patch) | |
| tree | 90953a59d7057926c5887157f58c7caa323aeab8 /src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx | |
| parent | 045233f2a8b8e79e6a3255ed594218929db1b042 (diff) | |
fixed indexing bug in pivot drill down
Diffstat (limited to 'src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx')
| -rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormLayoutEngines.tsx | 14 |
1 files changed, 10 insertions, 4 deletions
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, []); } |
