From ad38d32042ea8eb06742e32e1a596733e2178239 Mon Sep 17 00:00:00 2001 From: xuying <33517362+tangying1027@users.noreply.github.com> Date: Thu, 16 May 2024 19:56:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20image=E3=80=81tag=E3=80=81rect=20guide?= =?UTF-8?q?=20=E8=A1=A5=E5=85=85=E5=AD=97=E6=AE=B5=20(#1962)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: image guide宽高支持px单位 * feat: tag guide透传animation * feat: rect gudie 增加offsetXoffsetY --------- Co-authored-by: xuying.xu --- .../f2/src/components/guide/views/Image.tsx | 13 +-- .../f2/src/components/guide/views/Rect.tsx | 19 +++-- .../f2/src/components/guide/views/Tag.tsx | 19 +++-- ...\201px\344\274\240\345\205\245-1-snap.png" | Bin 0 -> 10173 bytes ...guide-test-tsx-guide-rect-guide-1-snap.png | Bin 0 -> 9305 bytes .../f2/test/components/guide/guide.test.tsx | 79 +++++++++++++++++- 6 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 "packages/f2/test/components/guide/__image_snapshots__/guide-test-tsx-guide-image-guide\346\224\257\346\214\201px\344\274\240\345\205\245-1-snap.png" create mode 100644 packages/f2/test/components/guide/__image_snapshots__/guide-test-tsx-guide-rect-guide-1-snap.png diff --git a/packages/f2/src/components/guide/views/Image.tsx b/packages/f2/src/components/guide/views/Image.tsx index 028a64d65..bc5f6c5c8 100644 --- a/packages/f2/src/components/guide/views/Image.tsx +++ b/packages/f2/src/components/guide/views/Image.tsx @@ -1,5 +1,5 @@ import { jsx, ImageStyleProps } from '@antv/f-engine'; -import { deepMix } from '@antv/util'; +import { deepMix, isNumber } from '@antv/util'; import { GuideProps } from '../withGuide'; export interface ImageGuideProps extends GuideProps { @@ -11,7 +11,7 @@ export interface ImageGuideProps extends GuideProps { offsetY?: number | string; } -const defaultProps: Omit = { +const defaultProps: Omit = { offsetX: 0, offsetY: 0, points: [], @@ -22,11 +22,12 @@ export default (props: ImageGuideProps, context) => { const cfg = deepMix({}, defaultProps, props); const { points, style, attrs, offsetX, offsetY, src, animation } = cfg; const { x, y } = points[0] || {}; - if(isNaN(x) || isNaN(y)) return null; - + if (isNaN(x) || isNaN(y)) return null; + const { height = 0, width = 0 } = { ...attrs, ...style }; - const heightNum = context.px2hd(height + 'px'); - const widthNum = context.px2hd(width + 'px'); + + const heightNum = isNumber(height) ? context.px2hd(height + 'px') : context.px2hd(height); + const widthNum = isNumber(width) ? context.px2hd(width + 'px') : context.px2hd(width); const offsetXNum = context.px2hd(offsetX); const offsetYNum = context.px2hd(offsetY); diff --git a/packages/f2/src/components/guide/views/Rect.tsx b/packages/f2/src/components/guide/views/Rect.tsx index ed18174f9..f96bd6b11 100644 --- a/packages/f2/src/components/guide/views/Rect.tsx +++ b/packages/f2/src/components/guide/views/Rect.tsx @@ -8,21 +8,26 @@ export interface RectGuideProps extends GuideProps { theme?: any; } -export default (props: RectGuideProps) => { +export default (props: RectGuideProps, context) => { const { theme = {} } = props; - const { points, style, animation } = deepMix({ ...theme.rect }, props); - const checkNaN = points.some((d)=> isNaN(d.x) || isNaN(d.y)); - if(checkNaN) return null; - + const { points, style, animation, offsetX, offsetY } = deepMix({ ...theme.rect }, props); + const checkNaN = points.some((d) => isNaN(d.x) || isNaN(d.y)); + if (checkNaN) return null; + const start = points[0] || {}; const end = points[1] || {}; + const offsetXNum = context.px2hd(offsetX); + const offsetYNum = context.px2hd(offsetY); + const posX = Math.min(start.x, end.x) + (offsetXNum || 0); + const posY = Math.min(start.y, end.y) + (offsetYNum || 0); + return ( = { +const defaultProps: Omit = { offsetX: 0, offsetY: 0, points: [], @@ -54,7 +54,7 @@ const defaultStyle = { }, }; -const Label = ({ content, background, textStyle }) => { +const Label = ({ content, background, textStyle, animation = {} }) => { return ( { radius: defaultStyle.container.radius, ...background, }} + animation={animation} > { fill: defaultStyle.text.fill, ...textStyle, }} + animation={animation} /> ); @@ -93,10 +95,11 @@ export default class Tag extends Component { canvasHeight, background, textStyle, + animation, } = px2hd(cfg); const { x, y } = points[0] || {}; - if(isNaN(x) || isNaN(y)) return null; - + if (isNaN(x) || isNaN(y)) return null; + const offsetXNum = context.px2hd(offsetX); const offsetYNum = context.px2hd(offsetY); let posX = x + (offsetXNum || 0); @@ -220,12 +223,18 @@ export default class Tag extends Component { y: posY, }} > - ); diff --git "a/packages/f2/test/components/guide/__image_snapshots__/guide-test-tsx-guide-image-guide\346\224\257\346\214\201px\344\274\240\345\205\245-1-snap.png" "b/packages/f2/test/components/guide/__image_snapshots__/guide-test-tsx-guide-image-guide\346\224\257\346\214\201px\344\274\240\345\205\245-1-snap.png" new file mode 100644 index 0000000000000000000000000000000000000000..4bb6c08814fade02402cafecc9399845cc02ced4 GIT binary patch literal 10173 zcmeIY^;eW%^fo+$0}M!qgfudM2tx@&*C1We-5?+(Al;)hC@~1qAq^uT-6c{ZElNoW z0@AI|&FA|(>v?~8*Lwefmmg-a?z7Li&pG!#dtdvyPK>su5-}k?AqWH_R#8Si1%bei zfd5yZc);(Apy&z^hy|pAl+*LG*v%#g(wjaR4BZ@kzzW5Swp)bg>FIeWOqG|W6*Q?; z-N&{pN8DH5&?qmp;+baSd*@Htwa_y2(8Tb%wUDK%;T}z8Ahm0_e=pO$-sF*s&^@&X zaJU^TC8IIx>f#Rp>)E2$*qK>~zmV5>JH$y|777KYld+_qbGs3OSy><~5gc*1&t}QU zx?gCN_vrx7kQh5+D42Db9*51SS|ttf5P}MWqAPFB%@kxI!;i}-lwO4a9g-ij08K8? zXsc$J{?Ae}GN3~(9x9B?gBVQyXtqd|ff`3%7NRx-7~@p4vP7(B>ctdZz`91_(nyhd zXm`tNXG_R%O-6dtBwN==5-+3lizfQ|Ny;-BIppSt$Kl>%gkbW@N~=_rHubO!{DarT zXM9XS0q)d}-|mn9jUv1Y=O}1wV`!wbrR;uTW6;MrNM_|g+%;uSlh|z2`y=UjCn2dc zSuv?*^WCmAWa^9fI%y9iWEfusO(w+IHPR~*a@t>?w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Xi_2JeB8twCg#0{uvBeA^WQbH zG-Rr8oUiA9Uv(_#2o|3;V)x4<$~m5gtW}qD{5aVDntSi}_cKwXFr2ihzbNYV`y(>S z(H?u(^J498=ev8~0An2wVQ-y?URfF&Z`VtS)GgubUvu|}l#U@x(-uADG5XpKs8L+C zX$o|F&DzgNEuH%|OKx$DbUe44+=eGo!|?-`3Od(-$_7Nc3!BdHP|081BLxB84gJL` zc2l#w$dX^12@$&30sfggrPg_`!_xXnt>uZKk4H*b<%x^6d+D8{KR%p3cMoTAe!>jd zZIlQSaa`B$gfCd|TF(xN^6?_9a;2ZD%?+qu1T_JUMgtN$dv2jNcdb&?o0n@lhEY{N zua&r0+&X9;bGHz$OZBSab=oH^*UDFVh;mFK1$~0HE@|b&woW0$F__mGZINc6GFWHOA=xu0|~Td`yl;`Q<4t0%pxS3HsO?nvQXoPauSt8O3 zQ|IB?8zF5*&IC>>iErZQNGZs=zvw&#;Lf?nw`d*wfOa&$5~4p|3pnWOTn8bg93$ka z0;{&S-lWB#vz;DSj~3OxTVxRD&Vh-Es^XUV#JYa^}Mf#QSw0PZLZyV6mH zz6whM#<@UTP_&SF+y_+gMtk*ZY8+|cUcmb5n%b6pmn-n?exL;o459!3p#L9xy8I8! X_0_e0>UV`Y2>4S`)I?UxTSfdYsOTag literal 0 HcmV?d00001 diff --git a/packages/f2/test/components/guide/__image_snapshots__/guide-test-tsx-guide-rect-guide-1-snap.png b/packages/f2/test/components/guide/__image_snapshots__/guide-test-tsx-guide-rect-guide-1-snap.png new file mode 100644 index 0000000000000000000000000000000000000000..b0194fcfd2d4777ee5a3ac140297fb62025a5c6a GIT binary patch literal 9305 zcmd^lRalf!+wROTz#us^h@^CfAV^9%bTf!_ib{7gj&unEf|P`S3@~(eNedDJ(n@zX zd-%S6y3h7?{RjUXyw|+%TI*T$)Vl8#p{1cr_<;5S001C_y-?5r0DwH0|4R@Y%+u9B zychsr1i%#J^t?@XGVt8>6eoM{YRO1Rk`!OG5$d6^ALO3b@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L*_Ij@0yy7^ z0P~0|fm4EnI$ganFX9AxgLuGHi~pY`VuR?%_?SB$kPvG;>vy3^Z?kpGFc(bz_uVx4 de_eywzbpC?9EQYIu>@d#Fhvc8(&y%g{{z?L7!Lpd literal 0 HcmV?d00001 diff --git a/packages/f2/test/components/guide/guide.test.tsx b/packages/f2/test/components/guide/guide.test.tsx index e19760aff..afad0e818 100644 --- a/packages/f2/test/components/guide/guide.test.tsx +++ b/packages/f2/test/components/guide/guide.test.tsx @@ -5,6 +5,7 @@ import { LineGuide, PointGuide, TextGuide, + RectGuide, withGuide, LottieGuide, withLegend, @@ -131,6 +132,56 @@ describe('Guide ', () => { expect(context).toMatchImageSnapshot(); }); + it('image guide支持px传入', async () => { + const context = createContext(); + const { props } = ( + + + + + {data.map((item) => { + const { sold } = item; + return ( + { + return { + height: 24, + width: 24, + }; + }} + /> + ); + })} + + {/* 图片Guide */} + {data.map((item, key) => { + return ( + { + return { + height: '24px', + width: '24px', + }; + }} + offsetX="0px" + offsetY="-24px" + /> + ); + })} + + + ); + const chart = new Canvas(props); + await chart.render(); + + await delay(500); + expect(context).toMatchImageSnapshot(); + }); + it('point', async () => { const context = createContext(); const { props } = ( @@ -189,13 +240,37 @@ describe('Guide ', () => { }); it('tag', () => {}); - it('guide 超出范围', async() => { + it('rect guide', async () => { const context = createContext(); const { props } = ( - + + + + ); + const chart = new Canvas(props); + chart.render(); + await delay(50); + expect(context).toMatchImageSnapshot(); + }); + it('guide 超出范围', async () => { + const context = createContext(); + const { props } = ( + + + + );