diff --git a/packages/f2/src/components/index.ts b/packages/f2/src/components/index.ts index 176705b17..a7f76163e 100644 --- a/packages/f2/src/components/index.ts +++ b/packages/f2/src/components/index.ts @@ -31,3 +31,4 @@ export { withCandlestick, CandlestickView, } from './candlestick'; +export { default as Pictorial, PictorialProps } from './pictorial'; diff --git a/packages/f2/src/components/pictorial/index.tsx b/packages/f2/src/components/pictorial/index.tsx new file mode 100644 index 000000000..58a55755c --- /dev/null +++ b/packages/f2/src/components/pictorial/index.tsx @@ -0,0 +1,4 @@ +import Pictorial, { PictorialProps } from './pictorial'; + +export { PictorialProps, Pictorial }; +export default Pictorial; diff --git a/packages/f2/src/components/pictorial/pictorial.tsx b/packages/f2/src/components/pictorial/pictorial.tsx new file mode 100644 index 000000000..032ee5ce2 --- /dev/null +++ b/packages/f2/src/components/pictorial/pictorial.tsx @@ -0,0 +1,35 @@ +import { jsx } from '@antv/f-engine'; +import { GeometryProps } from '../geometry'; +import { withInterval } from '../interval'; +import { DataRecord } from '../../chart/Data'; +export interface PictorialProps + extends GeometryProps { + symbol?: any; +} + +export default class Pictorial extends withInterval({}) { + props: PictorialProps; + + render() { + const { props, context } = this; + const { px2hd } = context; + const { symbol: Symbol } = px2hd(props); + const records = this.mapping(); + + return ( + + {records.map((record) => { + const { key, children } = record; + return ( + + {children.map((item) => { + const { xMax, xMin, yMax, yMin } = item; + return ; + })} + + ); + })} + + ); + } +} diff --git a/packages/f2/test/components/pictorial/__image_snapshots__/basic-test-tsx-pictorial-ellipse-symbol-1-snap.png b/packages/f2/test/components/pictorial/__image_snapshots__/basic-test-tsx-pictorial-ellipse-symbol-1-snap.png new file mode 100644 index 000000000..2cf583c43 Binary files /dev/null and b/packages/f2/test/components/pictorial/__image_snapshots__/basic-test-tsx-pictorial-ellipse-symbol-1-snap.png differ diff --git a/packages/f2/test/components/pictorial/__image_snapshots__/basic-test-tsx-pictorial-image-symbol-1-snap.png b/packages/f2/test/components/pictorial/__image_snapshots__/basic-test-tsx-pictorial-image-symbol-1-snap.png new file mode 100644 index 000000000..b8d857893 Binary files /dev/null and b/packages/f2/test/components/pictorial/__image_snapshots__/basic-test-tsx-pictorial-image-symbol-1-snap.png differ diff --git a/packages/f2/test/components/pictorial/basic.test.tsx b/packages/f2/test/components/pictorial/basic.test.tsx new file mode 100644 index 000000000..14d848e43 --- /dev/null +++ b/packages/f2/test/components/pictorial/basic.test.tsx @@ -0,0 +1,124 @@ +import { jsx } from '../../../src'; +import { Canvas, Chart, Pictorial, Axis, Tooltip } from '../../../src'; +import { createContext, delay, gestureSimulator } from '../../util'; +const context = createContext(); + +const data = [ + { + x: '产品1', + value: 4927, + }, + { + x: '产品2', + value: 11607, + }, +]; + +describe('pictorial', () => { + it('image symbol', async () => { + const { props } = ( + + + + + ( + + + + + + )} + /> + + + ); + + const canvas = new Canvas(props); + await canvas.render(); + + await delay(1000); + expect(context).toMatchImageSnapshot(); + }); + + it('ellipse symbol', async () => { + const { props } = ( + + + + ( + + + + + + )} + /> + + + ); + + const canvas = new Canvas(props); + await canvas.render(); + + await delay(1000); + expect(context).toMatchImageSnapshot(); + }); +});