From ca9bd0bc5f42df11c44a39bc472d838fd52d6f93 Mon Sep 17 00:00:00 2001 From: tangying1027 <33517362+tangying1027@users.noreply.github.com> Date: Mon, 26 Feb 2024 13:43:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20selection=20=E5=A2=9E=E5=8A=A0=20onChan?= =?UTF-8?q?ge=20(#1931)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: selection增加onchange * chore: 修改单测 --------- Co-authored-by: xuying.xu --- .../f2/src/components/geometry/selection.ts | 8 ++- ...16\257\345\275\242\345\233\276-2-snap.png" | Bin 11520 -> 11958 bytes .../interval/example/doughnut.test.tsx | 4 +- .../components/interval/selected.test.tsx | 52 ++++++++++++++++++ 4 files changed, 61 insertions(+), 3 deletions(-) diff --git a/packages/f2/src/components/geometry/selection.ts b/packages/f2/src/components/geometry/selection.ts index 3799847c7..23c8d95ca 100644 --- a/packages/f2/src/components/geometry/selection.ts +++ b/packages/f2/src/components/geometry/selection.ts @@ -25,6 +25,7 @@ export interface SelectionProps { selectedStyle?: ShapeStyleProps | StyleType; unSelectedStyle?: ShapeStyleProps | StyleType; cancelable?: boolean; + onChange?: Function; }; } @@ -50,7 +51,7 @@ class Selection< const { selection, chart } = props; if (!selection) return; // 默认为 click - const { triggerOn = 'click' } = selection; + const { triggerOn = 'click', onChange } = selection; chart.on(triggerOn, (ev) => { const { points, canvasX: x, canvasY: y } = ev; const point = triggerOn === 'click' ? { x, y } : points[0]; @@ -59,6 +60,7 @@ class Selection< if (!records || !records.length) { if (cancelable) { + onChange && onChange({ selected: null }) this.setState({ selected: null, } as S); @@ -69,6 +71,7 @@ class Selection< const { selected } = state; const origins = records.map((record) => record.origin); if (!selected || !selected.length) { + onChange && onChange({ selected: origins }) this.setState({ selected: origins, } as S); @@ -76,6 +79,7 @@ class Selection< if (type === 'single') { if (!cancelable) { + onChange && onChange({ selected: origins }) this.setState({ selected: origins, } as S); @@ -87,6 +91,7 @@ class Selection< newSelected.push(record.origin); } }); + onChange && onChange({ selected: newSelected }) this.setState({ selected: newSelected, } as S); @@ -111,6 +116,7 @@ class Selection< .map((key) => selectedMap[key]) .filter(Boolean); + onChange && onChange({ selected: newSelected }) this.setState({ selected: newSelected, } as S); diff --git "a/packages/f2/test/components/interval/example/__image_snapshots__/doughnut-test-tsx-\347\216\257\345\275\242\345\233\276-\347\216\253\347\221\260\347\216\257\345\275\242\345\233\276-2-snap.png" "b/packages/f2/test/components/interval/example/__image_snapshots__/doughnut-test-tsx-\347\216\257\345\275\242\345\233\276-\347\216\253\347\221\260\347\216\257\345\275\242\345\233\276-2-snap.png" index 4e6835782f80ebdf5e66ace8ab6557c9cda7db52..34433968cf3fd9e786c188e8590e3d08e4464df6 100644 GIT binary patch literal 11958 zcmdVA^;?_I6D}M=C{`rsr+9-q#ic-i;Op;9jgypcHp6?jDM^lmfvCuEn89 zaV;nPzVH8Vu9F{f?Q-^|6wo^lLE;|B}UX3EkPdvYIVPv`G5)x!XULe zt0{fkGB6*I#psgo-~Xu5qxwA#fob$CQZ9e&k0Ib_0u0isInR`5j-ZbrxT&3(3OzXA zBSUZvoDoA$g@6h@py3q^v|uZ_9uTLnnN1`W`YFujI0P-W{<&osc~%X-TpaqTx52vy z=fBW7V!qxOb;FDTw48Lyc?q;iP-pb0|4SuO3oQq&9_{~S_3#QRPs`U8nSb73GPq*; zP=~e3_?SYEML&6C__ZqaZ{bp^PIT8L+pbjJa6JpnWJMd<$604kw>w6z_aF{Z{ZKbe zep5=E%7S;!@W63pi)CYEz)0+mURw-!LG<|bA6^$-rK*)}&f^ttq%!CB>NvhWFL|FV zm`j6+Bw@U&gYGbbzZ!>;*cd%U@;B9Xn)D@|0j-++j%ClXF?12oPz`Otu%`yL^e#wW zY*k2^->+#0y}rkgtn%9!z^V;BVfgSe41s88vFy~C!+V;6_7)ax4;P&C&r+}6C%Lt8 z8R8p~kU&nh!sKShu;zm2VbY)8w}&80W^Q=(9ZR=FfZAvuHfPY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rG> z#IKN1M<65#J=G3Z`+YsKUTYbv1kO5^|E?eG#WlZMHVdcWFD=(pn*UXw>35 zRG`Lg*Q}nYdXEd)g{u8%*(R*1Obct6$$IZ}6XsEAZMpN6l;m98+XwniJs<-7Q7#U} zC&`%ODmyu4dYlu^O3ko{#{!1YA)(9!|GUHIf+{KZsW5~}3Dxjur(0D6D0H20C2W!n zQtH_L;{Rg>ylNd}2Hdb7f8;(V2(x06rJ7`R4ht79(mh)6WWWuxpfjrC1>eS7&@qbZ z1g!%?{r}Fwg}ONYrwQq%(m^O%)|0s8UDsf9f!|)}hp^C0_O1w^o404PT~NMmF3_oX zCUybyR|v|3mHul~5(;5g3U2G^4NT zsF&sACG|G3G}xlx$-xoOkFZLD=siUjE&V|(_oEh?H)g!o`3lI_1bi%e!Wbcm=Vpj% zW;?X7A)>L;M9)U4VHIkN@icfI)skr-(JrhWBfE;~Aw*yP2n!-Ap+QMrw{BlM1qS{9 essC?j;7%r2t!vHH7 { const context = createContext('基础环形图'); const chartRef = { current: null }; const { type, props } = ( - + { await delay(20); await gestureSimulator(context.canvas, 'click', { x: 133, y: 64 }); - await delay(100); + await delay(200); expect(context).toMatchImageSnapshot(); }); }); diff --git a/packages/f2/test/components/interval/selected.test.tsx b/packages/f2/test/components/interval/selected.test.tsx index ce77c4717..e1721ea4c 100644 --- a/packages/f2/test/components/interval/selected.test.tsx +++ b/packages/f2/test/components/interval/selected.test.tsx @@ -372,3 +372,55 @@ describe('改变默认值', () => { expect(context).toMatchImageSnapshot(); }); }); + +describe('select onChange', () => { + it('select onChange', async () => { + const context = createContext(); + const onChange = jest.fn(); + const { props } = ( + + + { + const { yMax, yMin } = record; + return { + r: (yMax - yMin) * 1.1, + }; + }, + cancelable: true, + onChange: onChange, + }} + /> + + + ); + + const canvas = new Canvas(props); + await canvas.render(); + await delay(200); + + // 选中 + await gestureSimulator(context.canvas, 'click', { x: 144, y: 68 }); + await delay(200); + expect(onChange.mock.calls.length).toBe(1); + expect(onChange.mock.calls[0][0].selected[0]).toEqual({ a: '1', genre: 'Other', sold: 110 }); + + // 反选 + await gestureSimulator(context.canvas, 'click', { x: 213, y: 166 }); + await delay(200); + expect(onChange.mock.calls.length).toBe(2); + }); +});