File tree Expand file tree Collapse file tree 5 files changed +84
-0
lines changed
@sensoro-design/plots/src/components
packages/storybook/stories/Charts Expand file tree Collapse file tree 5 files changed +84
-0
lines changed Original file line number Diff line number Diff line change
1
+ import type { StyleConfig } from './types' ;
2
+
3
+ export const DEFAULT_STYLE_CONFIG : StyleConfig = {
4
+ // TODO: 黑色主题的颜色配置
5
+ stroke : 'white' ,
6
+ lineWidth : 2 ,
7
+ } ;
Original file line number Diff line number Diff line change
1
+ import React , { forwardRef } from 'react' ;
2
+ import { Funnel as AntFunnel } from '@ant-design/plots' ;
3
+ import type { Chart } from '@ant-design/plots/es/interface' ;
4
+ import { Renderer as SVGRenderer } from '@antv/g-svg' ;
5
+ import type { FunnelConfig as AntFunnelConfig } from '@ant-design/plots' ;
6
+ import { getItemConfig } from '../../helpers/utils' ;
7
+ import { DEFAULT_INSET_LEFT , DEFAULT_INSET_RIGHT } from '../../config' ;
8
+ import { DEFAULT_STYLE_CONFIG } from './config' ;
9
+ import type { StyleConfig } from './types' ;
10
+
11
+ export interface FunnelConfig extends Omit < AntFunnelConfig , 'style' > {
12
+ style ?: AntFunnelConfig [ 'style' ] | boolean ;
13
+ }
14
+
15
+ export const Funnel = forwardRef < Chart , FunnelConfig > (
16
+ ( props , ref ) => {
17
+ const {
18
+ insetLeft = DEFAULT_INSET_LEFT ,
19
+ insetRight = DEFAULT_INSET_RIGHT ,
20
+ label = false ,
21
+ style = true ,
22
+ ...rest
23
+ } = props ;
24
+
25
+ const styleConfig = getItemConfig < StyleConfig > ( style , DEFAULT_STYLE_CONFIG ) ;
26
+
27
+ return (
28
+ < AntFunnel
29
+ insetLeft = { insetLeft }
30
+ insetRight = { insetRight }
31
+ label = { label }
32
+ style = { styleConfig }
33
+ { ...rest }
34
+ ref = { ref }
35
+ renderer = { new SVGRenderer ( ) }
36
+ />
37
+ ) ;
38
+ } ,
39
+ ) ;
40
+
41
+ export default Funnel ;
Original file line number Diff line number Diff line change
1
+ import type { FunnelConfig } from '@ant-design/plots' ;
2
+
3
+ export type StyleConfig = NonNullable < FunnelConfig [ 'style' ] > ;
Original file line number Diff line number Diff line change @@ -24,3 +24,6 @@ export type { RadarConfig } from './Radar';
24
24
25
25
export { Rose } from './Rose' ;
26
26
export type { RoseConfig } from './Rose' ;
27
+
28
+ export { Funnel } from './Funnel' ;
29
+ export type { FunnelConfig } from './Funnel' ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { Funnel , type FunnelConfig } from '@sensoro-design/plots' ;
3
+
4
+ const data = [
5
+ { stage : '简历筛选' , number : 253 } ,
6
+ { stage : '初试人数' , number : 151 } ,
7
+ { stage : '复试人数' , number : 113 } ,
8
+ { stage : '录取人数' , number : 87 } ,
9
+ { stage : '入职人数' , number : 59 } ,
10
+ ] ;
11
+
12
+ const meta = {
13
+ title : 'Charts/Funnel' ,
14
+ } ;
15
+
16
+ export default meta ;
17
+
18
+ export function Basic ( ) {
19
+ const config : FunnelConfig = {
20
+ title : '漏斗图' ,
21
+ data,
22
+ xField : 'stage' ,
23
+ yField : 'number' ,
24
+ width : 500 ,
25
+ } ;
26
+
27
+ return (
28
+ < Funnel { ...config } />
29
+ ) ;
30
+ }
You can’t perform that action at this time.
0 commit comments