From 763e2e3b71b7b2976b49f321d92aad60adfc4080 Mon Sep 17 00:00:00 2001 From: Marco Vettorello Date: Fri, 3 Dec 2021 18:17:35 +0100 Subject: [PATCH] fix(waffle): use descend sortPredicate by default (#1510) --- ...render-cells-in-ascending-order-1-snap.png | Bin 0 -> 22276 bytes integration/tests/waffle_stories.test.ts | 17 +++++++++++++++ .../layout/viewmodel/hierarchy_of_arrays.ts | 4 ++-- storybook/stories/waffle/1_simple.story.tsx | 20 ++++++++++-------- 4 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 integration/tests/__image_snapshots__/waffle-stories-test-ts-waffle-should-render-cells-in-ascending-order-1-snap.png create mode 100644 integration/tests/waffle_stories.test.ts diff --git a/integration/tests/__image_snapshots__/waffle-stories-test-ts-waffle-should-render-cells-in-ascending-order-1-snap.png b/integration/tests/__image_snapshots__/waffle-stories-test-ts-waffle-should-render-cells-in-ascending-order-1-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..beb49af27e77be8b8a7b702e18d5ec86b4bac728 GIT binary patch literal 22276 zcmd43XH-<()-_m)pooBofD%O>L_l)RDoPHLGf2)k#}dg|6eNR^bC8@R=bUp6Mb5dZ zdY8|=ec!j=d%v$okM1#=A9AQV=hQxX?={z)bFDJygN!Kled7BN2n1VP?43LWavKJL z+%ma`0bbeqZMY47-LjV#eG4hjGv}-sy@u>KoLDNx?M!BT{a(rz zSJSkrIl5X@lC4iJeAo`o%0}O~-YI1t6L)D@MH6hamYv9L!>noX&>)5C;2Mo5_yM}r z(ZTNV4HftK#q5Nq&gzP1q5a&s+}is3`g7lhZ|_n1GCvWKt-XahdiXZ*^Iz#$sDpdD zAOC-N6eU-=2fv4n&15$hp5z|K?K&+qn;Kkx5wiA5tKul9LKpTcIz2sIaE$W?|L@^1 zL&twmQkg7m$SNvId9P84)=OgvK^b+bm32GLEDs*Quj@bPo?`dq;|dzJwD-xbO~PPL zL&=ahNwudxwE{L=VPiw2d5+#ZhFr2BG{l!kJK+NN16vH8Y{G(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(3y7WcU+lh}TE0lE<@JMfo zN%|^*FkNeH^bp+6)Yz{{vH}i-pJwmTsH4^85yJuQF4gY=>)f=M7)GI z4!TPdNbLo+5iu9r%wyC2uLTNK4sm5v$U&t@FO1qe0mEC={?J3vLLh-90_wZDvF@%3 z;dFk3iHx6k`1<;`$g|FQZ9f}3lDcn@Cy^Vk1^T7U`nO6m?mkHUNaoMA0XUDN0Zsrp zaXAOM1}|)z8%M`f3&%Q}PB9lbK7?KQ;=!|LwG-E@v*y|kFQk0d4{71`h3Q5E8fKH4 z?mvJH)N_iSf8jMoY?SnL5Lkf%R=)Z*edaAw$SZyvA0JmnTz?_+A0mY4T0%AUx z6`~nwS=`n|cyp-T92bFeI#9eo?3@e+_Fp;4wzdX7UYx!gbQm){%ZFDvoXvyeQ-h*N z&>r3NFjn12tJxmY`wC+iPqi)il=Q-bLIFB{0-21t=h7wZdI4c z@+vsrvVZd{4{N7TGK6RTk;0@;f7U+_T)7idLO-JF$15%}+uR*i65-Z{o%HEYLFf(y z|J4P!^W9*bC~_^V>FfHmrjd%M^hFR0g}L}TPiThgZMQ`cP>i)rtjt>>;7#8KAQH{| zZ@~CeR9TX0xcS4*7I-{e_fNV6V_`Hq=loI~yb$3y_9@Ro)-7 z4^UKjsv-54r?+*P1l;>}3ldfeFY>KUZOP&~$~T~l%qdx|85cqu;3 z-lBGWfpnp*OnndUa{3*sqtc{RUI6nA1`-DRW%})wsmeSHh>3?SoBJ|=l?$dgf1h7* zXo4GfJ3>tY5;)>AQ}S+Z^*k{A<O-aj2@!uAvrOMw$&D64zYRA*lpdIT>AyS@ALQyS(dpRi@c+qPV~v?Nn~=I>l(Uw zYyiS_a?RQ%6J dC;0u95%;n|>XrZ)_^hqjAwSfC>is7#{0sUzZhHU# literal 0 HcmV?d00001 diff --git a/integration/tests/waffle_stories.test.ts b/integration/tests/waffle_stories.test.ts new file mode 100644 index 0000000000..b5b7e80733 --- /dev/null +++ b/integration/tests/waffle_stories.test.ts @@ -0,0 +1,17 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { common } from '../page_objects/common'; + +describe('Waffle', () => { + it('should render cells in ascending order', async () => { + await common.expectChartAtUrlToMatchScreenshot( + 'http://localhost:9001/?path=/story/waffle-alpha--simple&globals=theme:light&knob-show table for debugging=&knob-ascending sort=true', + ); + }); +}); diff --git a/packages/charts/src/chart_types/partition_chart/layout/viewmodel/hierarchy_of_arrays.ts b/packages/charts/src/chart_types/partition_chart/layout/viewmodel/hierarchy_of_arrays.ts index 66ed92433c..c005e071ca 100644 --- a/packages/charts/src/chart_types/partition_chart/layout/viewmodel/hierarchy_of_arrays.ts +++ b/packages/charts/src/chart_types/partition_chart/layout/viewmodel/hierarchy_of_arrays.ts @@ -25,7 +25,7 @@ import { NodeSorter, Sorter, } from '../utils/group_by_rollup'; -import { isMosaic, isSunburst, isTreemap } from './viewmodel'; +import { isMosaic, isSunburst, isTreemap, isWaffle } from './viewmodel'; function aggregateComparator(accessor: (v: any) => any, sorter: Sorter): NodeSorter { return (a, b) => sorter(accessor(a), accessor(b)); @@ -72,7 +72,7 @@ export function getHierarchyOfArrays( const sorter = (layout: PartitionLayout) => ({ sortPredicate }: Layer, i: number) => sortPredicate || - (isTreemap(layout) || isSunburst(layout) + (isTreemap(layout) || isSunburst(layout) || isWaffle(layout) ? descendingValueNodes : isMosaic(layout) ? i === 2 diff --git a/storybook/stories/waffle/1_simple.story.tsx b/storybook/stories/waffle/1_simple.story.tsx index c8e01a98a6..341ad7570a 100644 --- a/storybook/stories/waffle/1_simple.story.tsx +++ b/storybook/stories/waffle/1_simple.story.tsx @@ -13,17 +13,21 @@ import { Chart, Datum, Partition, PartitionLayout, Settings, ShapeTreeNode } fro import { config } from '@elastic/charts/src/chart_types/partition_chart/layout/config'; import { mocks } from '@elastic/charts/src/mocks/hierarchical'; +import { ArrayEntry } from '../../../packages/charts/src/chart_types/partition_chart/layout/utils/group_by_rollup'; import { useBaseTheme } from '../../use_base_theme'; -import { discreteColor, colorBrewerCategoricalStark9, productLookup } from '../utils/utils'; +import { colorBrewerCategoricalStark9, discreteColor, productLookup } from '../utils/utils'; export const Example = () => { const showDebug = boolean('show table for debugging', false); + const ascendingSort = boolean('ascending sort', false); + // this is used to test the sorting capabilities + const data = mocks.pie.slice(0, 4).sort(() => (Math.random() > 0.5 ? 1 : -1)); return ( d.exportVal as number} valueFormatter={(d: number) => `$${config.fillLabel.valueFormatter(Math.round(d / 1000000000))}\u00A0Bn`} layers={[ @@ -33,13 +37,11 @@ export const Example = () => { shape: { fillColor: (d: ShapeTreeNode) => discreteColor(colorBrewerCategoricalStark9.slice(1))(d.sortIndex), }, - }, - { - groupByRollup: (d: Datum) => d.sitc1, - nodeLabel: (d: Datum) => productLookup[d].name, - shape: { - fillColor: (d: ShapeTreeNode) => discreteColor(colorBrewerCategoricalStark9.slice(1))(d.sortIndex), - }, + sortPredicate: ascendingSort + ? ([, node1]: ArrayEntry, [, node2]: ArrayEntry) => { + return node1.value - node2.value; + } + : undefined, // the descending sort is applied by default }, ]} config={{