From 0116b0c1eb6be6c3d112aa1a66e90ebfb5cc249b Mon Sep 17 00:00:00 2001 From: "xuying.xu" Date: Sat, 14 Sep 2024 15:46:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E9=98=B6=E6=A2=AF?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- packages/f2/src/index.ts | 1 - packages/f2/src/theme.ts | 9 ++ ...30\266\346\242\257\345\233\276-1-snap.png" | Bin 0 -> 8307 bytes .../f2/test/components/line/line.test.tsx | 112 ++++++++++++------ 5 files changed, 83 insertions(+), 41 deletions(-) create mode 100644 "packages/f2/test/components/line/__image_snapshots__/line-test-tsx-\346\212\230\347\272\277\345\233\276-\345\237\272\347\241\200\346\212\230\347\272\277\345\233\276-\351\230\266\346\242\257\345\233\276-1-snap.png" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 810146281..6802f0713 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: - node_version: ['16', '18'] + node_version: ['18'] # Steps represent a sequence of tasks that will be executed as part of the job steps: diff --git a/packages/f2/src/index.ts b/packages/f2/src/index.ts index 2b7897bf7..15a68fa4b 100644 --- a/packages/f2/src/index.ts +++ b/packages/f2/src/index.ts @@ -4,6 +4,5 @@ export * from '@antv/f-engine'; export { default as Chart, ChartProps } from './chart'; export { Scale, ScaleConfig } from './deps/f2-scale/src'; export * from './components'; - //@ts-ignore export default { version: VERSION }; diff --git a/packages/f2/src/theme.ts b/packages/f2/src/theme.ts index f4a70e844..e683bca96 100644 --- a/packages/f2/src/theme.ts +++ b/packages/f2/src/theme.ts @@ -117,6 +117,15 @@ export default { smooth: { smooth: true, }, + 'step-start': { + step: 'start', + }, + 'step-middle': { + step: 'middle', + }, + 'step-end': { + step: 'end', + }, dash: { lineDash: ['8px', '8px'], }, diff --git "a/packages/f2/test/components/line/__image_snapshots__/line-test-tsx-\346\212\230\347\272\277\345\233\276-\345\237\272\347\241\200\346\212\230\347\272\277\345\233\276-\351\230\266\346\242\257\345\233\276-1-snap.png" "b/packages/f2/test/components/line/__image_snapshots__/line-test-tsx-\346\212\230\347\272\277\345\233\276-\345\237\272\347\241\200\346\212\230\347\272\277\345\233\276-\351\230\266\346\242\257\345\233\276-1-snap.png" new file mode 100644 index 0000000000000000000000000000000000000000..fb88b7e26c627a4e3698c0a53c6d39847f02d1ef GIT binary patch literal 8307 zcmdUVc{r5q-}g24CHqz>G-M~cQkH6DUm9dz+U&BHn6Z=XjwD-_5e-R5wq#!-*~u0$ zvSrB(ZVV=#bKLjyJKpE{>pkB8-s5mM9Ordj*ZDn{?`Qd*VvP;8m>5noKoG>Fqm4j9 z5DX3eo~5G!zq_58=O9P`(m`A`eQftT8OlX4;QeUgU}zDlHEu^S}aX1rYZv%^eiiBVzJGPtw7)!_P^c;#*d06JCq9iAg^j* z@1#u$(LaO0k0?=}f?WW{u1ybP2-c|KhrN&&+pb*la5Id*QVx*H>Ye4Rji<74% ze?s6ql_*h+UZF;Z+=UapNPdIfvjhCtX0RyqVh^BzCMLOIUg z>*Rh2s$py-R5wsv93gR2&3VX?RA?%7M+=HtnL@>E4 zOU-k-zLQ39U}9pzR6K=w$jVHX4ycGXsIO5Xe;NXU0$#$|dg^j)ak)yr+OaOGN)*{i< z0Zr)yoAZR_zt~48Wj6e{AI6@6yI@@{IXOK&&4jzi7NCn*r;@2{`p%Oi2KNyPwTGP) zgnP0qx|dtjE2MS*aIH&nT~h+VTKoI&-tO(~l_)Nsvmo!&c#?*eR%elcfx)gwn0_x; zFg8$`>yO8xYu48SCj}*?!=mEiRceR>`UVsIyT(6{nMUtaiVV#b+irk zwJEv;ni*!`hSCyf#$D%Y?d^z0V#%6wX;Y<@%Ga>@+oYl1-%YfHP^$yp_L=Qk?U_cTM_Na zCh!sj{XUxCl=&kkdWR4Z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time: '2016-08-08 00:10:00', - tem: 22, - }, - { - time: '2016-08-08 00:30:00', - tem: 20, - }, - { - time: '2016-08-09 00:35:00', - tem: 26, - }, - { - time: '2016-08-09 01:00:00', - tem: 20, - }, - { - time: '2016-08-09 01:20:00', - tem: 26, - }, - { - time: '2016-08-10 01:40:00', - tem: 28, - }, - { - time: '2016-08-10 02:00:00', - tem: 20, - }, - { - time: '2016-08-10 02:20:00', - tem: 18, - }, - ]; const context = createContext('曲线'); const chartRef = { current: null }; const lineRef = { current: null }; @@ -461,6 +422,79 @@ describe('折线图', () => { await delay(1000); expect(context).toMatchImageSnapshot(); }); + + it('阶梯图', async () => { + const context = createContext('阶梯图', { + width: '380px', + }); + const data = []; + [ + { + time: '2016-08-01', + tem: 15, + type: 'start', + }, + { + time: '2016-08-02', + tem: 22, + type: 'start', + }, + { + time: '2016-08-03', + tem: 15, + type: 'start', + }, + { + time: '2016-08-04', + tem: 26, + type: 'start', + }, + { + time: '2016-08-05', + tem: 20, + type: 'start', + }, + { + time: '2016-08-06', + tem: 26, + type: 'start', + }, + ].map((d) => { + data.push(d); + data.push({ ...d, tem: d.tem + 15, type: 'middle' }); + data.push({ ...d, tem: d.tem + 30, type: 'end' }); + }); + + const { type, props } = ( + + + + + + + + ); + const canvas = new Canvas(props); + await canvas.render(); + await delay(500); + expect(context).toMatchImageSnapshot(); + }); }); describe('对比折线图', () => {