Skip to content

Commit

Permalink
feat: add TreemapChart and BulletChart support
Browse files Browse the repository at this point in the history
  • Loading branch information
kagawagao committed Feb 24, 2020
1 parent 9e125a0 commit eef807b
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ Extra Props:
- [x] [`RoseChart`](https://g2plot.antv.vision/zh/examples/rose/basic)
- [x] [`WordCloudChart`](https://g2plot.antv.vision/zh/examples/word-cloud/basic)
- [x] [`AVAChart`](https://github.com/antvis/AVA)
- [x] [`BulletChart`](https://g2plot.antv.vision/zh/examples/bullet/basic)
- [x] [`TreemapChart`](https://g2plot.antv.vision/zh/examples/treemap/rect)

## Develop

Expand Down
21 changes: 21 additions & 0 deletions __tests__/plots/bullet.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { create } from 'react-test-renderer'
import BulletChart from '../../src/plots/bullet'

describe('BulletChart', () => {
test('should render without crashed', () => {
const renderer = create(
<BulletChart
rangeMax={100}
data={[
{
targets: [90],
measures: [0.9],
},
]}
/>
)

expect(renderer.toJSON()).toMatchSnapshot()
})
})
11 changes: 11 additions & 0 deletions __tests__/plots/treemap.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from 'react'
import { create } from 'react-test-renderer'
import TreemapChart from '../../src/plots/treemap'

describe('TreemapChart', () => {
test('should render without crashed', () => {
const renderer = create(<TreemapChart data={[]} colorField="x" />)

expect(renderer.toJSON()).toMatchSnapshot()
})
})
2 changes: 2 additions & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ export { default as LiquidChart } from './plots/liquid'
export { default as FunnelChart } from './plots/funnel'
export { default as OverlappedComboChart } from './plots/overlapped-combo'
export { default as AVAChart } from './plots/ava'
export { default as BulletChart } from './plots/bullet'
export { default as TreemapChart } from './plots/treemap'
11 changes: 11 additions & 0 deletions src/plots/bullet.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, { FC } from 'react'
import { Bullet, BulletConfig } from '@antv/g2plot'
import BaseChart, { BaseChartProps } from './base'

export type BulletChartProps = Omit<BaseChartProps, 'chart'> & BulletConfig

const BulletChart: FC<BulletChartProps> = props => {
return <BaseChart chart={Bullet} {...props} />
}

export default BulletChart
13 changes: 13 additions & 0 deletions src/plots/treemap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { FC } from 'react'
import { Treemap } from '@antv/g2plot'
import BaseChart, { BaseChartProps } from './base'
// FIXME: fix this after https://github.com/antvis/G2Plot/pull/652 merged
import { TreemapConfig } from '@antv/g2plot/lib/plots/treemap'

export type TreemapChartProps = Omit<BaseChartProps, 'chart'> & TreemapConfig

const TreemapChart: FC<TreemapChartProps> = props => {
return <BaseChart chart={Treemap} {...props} />
}

export default TreemapChart

0 comments on commit eef807b

Please sign in to comment.