From 7bc9ce86910df3241bdc8334960f4f9abd99ae6d Mon Sep 17 00:00:00 2001 From: zengyue Date: Mon, 23 Oct 2023 20:19:44 +0800 Subject: [PATCH] =?UTF-8?q?fix(Area):=20=E4=BF=AE=E5=A4=8D=E9=9D=A2?= =?UTF-8?q?=E7=A7=AF=E5=9B=BE=20x=20=E4=B8=BA=E7=A9=BA=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E5=9B=BE=E5=BD=A2=E4=B8=8D=E7=BB=98=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/f2/src/components/line/withLine.tsx | 12 +++- packages/f2/test/issues/1867.test.tsx | 66 ++++++++++++++++++ ...70\215\345\255\230\345\234\250-1-snap.png" | Bin 0 -> 10839 bytes 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 packages/f2/test/issues/1867.test.tsx create mode 100644 "packages/f2/test/issues/__image_snapshots__/1867-test-tsx-x-\350\275\264\345\255\227\346\256\265\344\270\215\345\255\230\345\234\250-x-\350\275\264\345\255\227\346\256\265\344\270\215\345\255\230\345\234\250-1-snap.png" diff --git a/packages/f2/src/components/line/withLine.tsx b/packages/f2/src/components/line/withLine.tsx index 51abc2c14..bf31a41df 100644 --- a/packages/f2/src/components/line/withLine.tsx +++ b/packages/f2/src/components/line/withLine.tsx @@ -29,7 +29,11 @@ export default (View) => { const tmpPoints = []; for (let i = 0, len = points.length; i < len; i++) { const point = points[i]; - const { y } = point; + const { x, y } = point; + // 过滤 x 为 NaN 的点 + if (isNaN(x)) { + continue; + } if (isArray(y)) { if (isNaN(y[0])) { continue; @@ -51,7 +55,11 @@ export default (View) => { let tmpPoints = []; for (let i = 0, len = points.length; i < len; i++) { const point = points[i]; - const { y } = point; + const { x, y } = point; + // 过滤 x 为 NaN 的点 + if (isNaN(x)) { + continue; + } if (isArray(y)) { if (isNaN(y[0])) { if (tmpPoints.length) { diff --git a/packages/f2/test/issues/1867.test.tsx b/packages/f2/test/issues/1867.test.tsx new file mode 100644 index 000000000..2241ce78c --- /dev/null +++ b/packages/f2/test/issues/1867.test.tsx @@ -0,0 +1,66 @@ +import { jsx, Canvas, Chart, Axis, Area } from '../../src'; +import { createContext, delay } from '../util'; + +const data = [ + { + dt: '20231008', + date: '10-08', + value: 1.31, + }, + { + dt: '20231009', + date: '10-09', + value: 57.5, + }, + { + dt: '20231010', + // date: '10-10', + value: 151.83, + }, + { + dt: '20231011', + date: '10-11', + value: 291.6, + }, + { + dt: '20231012', + date: '10-12', + value: 45.62, + }, + { + dt: '20231013', + date: '10-13', + value: 7.4, + }, + { + dt: '20231007', + // data: '10-07', + value: 9, + }, +]; + +describe('x 轴字段不存在', () => { + it('x 轴字段不存在', async () => { + const context = createContext(); + const { props } = ( + + + + + + + ); + + const canvas = new Canvas(props); + canvas.render(); + + await delay(1000); + + expect(context).toMatchImageSnapshot(); + }); +}); diff --git "a/packages/f2/test/issues/__image_snapshots__/1867-test-tsx-x-\350\275\264\345\255\227\346\256\265\344\270\215\345\255\230\345\234\250-x-\350\275\264\345\255\227\346\256\265\344\270\215\345\255\230\345\234\250-1-snap.png" "b/packages/f2/test/issues/__image_snapshots__/1867-test-tsx-x-\350\275\264\345\255\227\346\256\265\344\270\215\345\255\230\345\234\250-x-\350\275\264\345\255\227\346\256\265\344\270\215\345\255\230\345\234\250-1-snap.png" new file mode 100644 index 0000000000000000000000000000000000000000..f8dcf5dd421c38ec2685f2bbd12b4e66d6bbdb95 GIT binary patch literal 10839 zcmb7qcRZYJ*X>9Uy(GHmMDGMa^d7wpf{Yd|Bw83X+6WSz=p_h78AOEWorw~?mxww< z?}l^pyytnp@4s{Y;bN|Pepgw0t+n^P-|J|p5aQ9`fj}TaHC07D5D0?@7%$;q13%sT zBH$npBS=kA&cNGZ+u!$-jiKkx^wDOCzPTa#lS?66nQ&Vyj$kX2gsP`esLtLdk>vd| zzNb2T&m+7Qf+rLciJ@W->fDalMl=&A8M%7N7ZF?G(RX@IaPI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