Skip to content

Commit 2f297bb

Browse files
committed
feat: introduce VennChart
1 parent 237ca5d commit 2f297bb

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`VennChart should render without crashed 1`] = `<div />`;

__tests__/plots/venn.spec.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import { create } from 'react-test-renderer'
3+
import VennChart from '../../src/plots/venn'
4+
5+
describe('VennChart', () => {
6+
test('should render without crashed', () => {
7+
const renderer = create(<VennChart data={[]} />)
8+
9+
expect(renderer.toJSON()).toMatchSnapshot()
10+
})
11+
})

docs/api/venn.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# VennChart
2+
3+
## Usage
4+
5+
```tsx | pure
6+
import { VennChart } from '@opd/g2plot-react'
7+
```
8+
9+
<API src="../../src/plots/venn/index.tsx" />

src/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ import { FacetChartProps as _FacetChartProps } from './plots/facet'
5252

5353
import { CirclePackingChartProps as _CirclePackingChartProps } from './plots/circle-packing'
5454

55+
import { VennChartProps as _VennChartProps } from './plots/venn'
56+
5557
export { default as BaseChart } from './components/base'
5658
export type BaseChartProps<T = any> = _BaseChartProps<T>
5759

@@ -160,3 +162,6 @@ export type FacetChartProps = _FacetChartProps
160162

161163
export { default as CirclePackingChart } from './plots/circle-packing'
162164
export type CirclePackingChartProps = _CirclePackingChartProps
165+
166+
export { default as VennChart } from './plots/venn'
167+
export type VennChartProps = _VennChartProps

src/plots/venn/index.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { forwardRef } from 'react'
2+
import { Venn, VennOptions } from '@antv/g2plot'
3+
import BaseChart, { BaseChartProps } from '../../components/base'
4+
5+
export type VennChartProps = Omit<BaseChartProps<VennOptions>, 'chart'> &
6+
VennOptions
7+
8+
const VennChart = forwardRef<HTMLDivElement | null, VennChartProps>(
9+
(props, ref) => {
10+
return <BaseChart chart={Venn} ref={ref} {...props} />
11+
}
12+
)
13+
14+
export default VennChart

0 commit comments

Comments
 (0)