@antv/g2plot 2.4.8 → 2.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/g2plot.min.js +4 -4
- package/dist/g2plot.min.js.map +1 -1
- package/esm/core/plot.d.ts +2 -2
- package/esm/core/plot.js +4 -3
- package/esm/core/plot.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +2 -2
- package/esm/index.js.map +1 -1
- package/esm/plots/area/types.d.ts +35 -10
- package/esm/plots/area/types.js.map +1 -1
- package/esm/plots/bar/types.d.ts +16 -3
- package/esm/plots/bar/types.js.map +1 -1
- package/esm/plots/bidirectional-bar/types.d.ts +21 -6
- package/esm/plots/bidirectional-bar/types.js.map +1 -1
- package/esm/plots/box/types.d.ts +20 -6
- package/esm/plots/box/types.js.map +1 -1
- package/esm/plots/bullet/types.d.ts +36 -9
- package/esm/plots/bullet/types.js.map +1 -1
- package/esm/plots/chord/types.d.ts +14 -10
- package/esm/plots/chord/types.js.map +1 -1
- package/esm/plots/circle-packing/types.d.ts +25 -8
- package/esm/plots/circle-packing/types.js.map +1 -1
- package/esm/plots/column/types.d.ts +57 -16
- package/esm/plots/column/types.js.map +1 -1
- package/esm/plots/dual-axes/types.d.ts +31 -6
- package/esm/plots/dual-axes/types.js.map +1 -1
- package/esm/plots/facet/types.d.ts +54 -34
- package/esm/plots/facet/types.js.map +1 -1
- package/esm/plots/funnel/types.d.ts +40 -11
- package/esm/plots/funnel/types.js.map +1 -1
- package/esm/plots/gauge/types.d.ts +83 -21
- package/esm/plots/gauge/types.js.map +1 -1
- package/esm/plots/heatmap/types.d.ts +47 -12
- package/esm/plots/heatmap/types.js.map +1 -1
- package/esm/plots/histogram/types.d.ts +17 -6
- package/esm/plots/histogram/types.js.map +1 -1
- package/esm/plots/line/types.d.ts +42 -12
- package/esm/plots/line/types.js.map +1 -1
- package/esm/plots/liquid/index.d.ts +1 -0
- package/esm/plots/liquid/index.js +1 -0
- package/esm/plots/liquid/index.js.map +1 -1
- package/esm/plots/liquid/shapes/liquid.d.ts +16 -1
- package/esm/plots/liquid/shapes/liquid.js +13 -8
- package/esm/plots/liquid/shapes/liquid.js.map +1 -1
- package/esm/plots/liquid/types.d.ts +56 -16
- package/esm/plots/liquid/types.js.map +1 -1
- package/esm/plots/mix/types.d.ts +31 -22
- package/esm/plots/mix/types.js.map +1 -1
- package/esm/plots/pie/types.d.ts +27 -10
- package/esm/plots/pie/types.js.map +1 -1
- package/esm/plots/progress/types.d.ts +13 -4
- package/esm/plots/progress/types.js.map +1 -1
- package/esm/plots/radar/types.d.ts +39 -12
- package/esm/plots/radar/types.js.map +1 -1
- package/esm/plots/radial-bar/types.d.ts +39 -12
- package/esm/plots/radial-bar/types.js.map +1 -1
- package/esm/plots/ring-progress/types.d.ts +18 -6
- package/esm/plots/ring-progress/types.js.map +1 -1
- package/esm/plots/rose/types.d.ts +32 -12
- package/esm/plots/rose/types.js.map +1 -1
- package/esm/plots/sankey/types.d.ts +51 -32
- package/esm/plots/sankey/types.js.map +1 -1
- package/esm/plots/scatter/types.d.ts +76 -22
- package/esm/plots/scatter/types.js.map +1 -1
- package/esm/plots/stock/types.d.ts +20 -7
- package/esm/plots/stock/types.js.map +1 -1
- package/esm/plots/sunburst/types.d.ts +40 -12
- package/esm/plots/sunburst/types.js.map +1 -1
- package/esm/plots/tiny-area/types.d.ts +16 -5
- package/esm/plots/tiny-area/types.js.map +1 -1
- package/esm/plots/tiny-column/types.d.ts +10 -3
- package/esm/plots/tiny-column/types.js.map +1 -1
- package/esm/plots/tiny-line/types.d.ts +17 -5
- package/esm/plots/tiny-line/types.js.map +1 -1
- package/esm/plots/treemap/types.d.ts +17 -6
- package/esm/plots/treemap/types.js.map +1 -1
- package/esm/plots/venn/types.d.ts +20 -6
- package/esm/plots/venn/types.js.map +1 -1
- package/esm/plots/violin/types.d.ts +52 -17
- package/esm/plots/violin/types.js.map +1 -1
- package/esm/plots/waterfall/types.d.ts +42 -10
- package/esm/plots/waterfall/types.js.map +1 -1
- package/esm/plots/word-cloud/types.d.ts +91 -44
- package/esm/plots/word-cloud/types.js.map +1 -1
- package/esm/types/button.d.ts +8 -4
- package/esm/types/button.js.map +1 -1
- package/esm/types/common.d.ts +145 -33
- package/esm/types/common.js.map +1 -1
- package/esm/types/drill-down.d.ts +28 -7
- package/esm/types/drill-down.js.map +1 -1
- package/esm/types/interaction.d.ts +26 -6
- package/esm/types/interaction.js.map +1 -1
- package/esm/types/label.d.ts +11 -3
- package/esm/types/label.js.map +1 -1
- package/esm/types/meta.d.ts +4 -7
- package/esm/types/meta.js.map +1 -1
- package/esm/types/pattern.d.ts +58 -18
- package/esm/types/pattern.js.map +1 -1
- package/esm/types/state.d.ts +11 -3
- package/esm/types/state.js.map +1 -1
- package/esm/types/statistic.d.ts +38 -6
- package/esm/types/statistic.js.map +1 -1
- package/esm/types/tooltip.d.ts +7 -2
- package/esm/types/tooltip.js.map +1 -1
- package/lib/core/plot.d.ts +2 -2
- package/lib/core/plot.js +4 -3
- package/lib/core/plot.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/plots/area/types.d.ts +35 -10
- package/lib/plots/area/types.js.map +1 -1
- package/lib/plots/bar/types.d.ts +16 -3
- package/lib/plots/bar/types.js.map +1 -1
- package/lib/plots/bidirectional-bar/types.d.ts +21 -6
- package/lib/plots/bidirectional-bar/types.js.map +1 -1
- package/lib/plots/box/types.d.ts +20 -6
- package/lib/plots/box/types.js.map +1 -1
- package/lib/plots/bullet/types.d.ts +36 -9
- package/lib/plots/bullet/types.js.map +1 -1
- package/lib/plots/chord/types.d.ts +14 -10
- package/lib/plots/chord/types.js.map +1 -1
- package/lib/plots/circle-packing/types.d.ts +25 -8
- package/lib/plots/circle-packing/types.js.map +1 -1
- package/lib/plots/column/types.d.ts +57 -16
- package/lib/plots/column/types.js.map +1 -1
- package/lib/plots/dual-axes/types.d.ts +31 -6
- package/lib/plots/dual-axes/types.js.map +1 -1
- package/lib/plots/facet/types.d.ts +54 -34
- package/lib/plots/facet/types.js.map +1 -1
- package/lib/plots/funnel/types.d.ts +40 -11
- package/lib/plots/funnel/types.js.map +1 -1
- package/lib/plots/gauge/types.d.ts +83 -21
- package/lib/plots/gauge/types.js.map +1 -1
- package/lib/plots/heatmap/types.d.ts +47 -12
- package/lib/plots/heatmap/types.js.map +1 -1
- package/lib/plots/histogram/types.d.ts +17 -6
- package/lib/plots/histogram/types.js.map +1 -1
- package/lib/plots/line/types.d.ts +42 -12
- package/lib/plots/line/types.js.map +1 -1
- package/lib/plots/liquid/index.d.ts +1 -0
- package/lib/plots/liquid/index.js +2 -0
- package/lib/plots/liquid/index.js.map +1 -1
- package/lib/plots/liquid/shapes/liquid.d.ts +16 -1
- package/lib/plots/liquid/shapes/liquid.js +14 -7
- package/lib/plots/liquid/shapes/liquid.js.map +1 -1
- package/lib/plots/liquid/types.d.ts +56 -16
- package/lib/plots/liquid/types.js.map +1 -1
- package/lib/plots/mix/types.d.ts +31 -22
- package/lib/plots/mix/types.js.map +1 -1
- package/lib/plots/pie/types.d.ts +27 -10
- package/lib/plots/pie/types.js.map +1 -1
- package/lib/plots/progress/types.d.ts +13 -4
- package/lib/plots/progress/types.js.map +1 -1
- package/lib/plots/radar/types.d.ts +39 -12
- package/lib/plots/radar/types.js.map +1 -1
- package/lib/plots/radial-bar/types.d.ts +39 -12
- package/lib/plots/radial-bar/types.js.map +1 -1
- package/lib/plots/ring-progress/types.d.ts +18 -6
- package/lib/plots/ring-progress/types.js.map +1 -1
- package/lib/plots/rose/types.d.ts +32 -12
- package/lib/plots/rose/types.js.map +1 -1
- package/lib/plots/sankey/types.d.ts +51 -32
- package/lib/plots/sankey/types.js.map +1 -1
- package/lib/plots/scatter/types.d.ts +76 -22
- package/lib/plots/scatter/types.js.map +1 -1
- package/lib/plots/stock/types.d.ts +20 -7
- package/lib/plots/stock/types.js.map +1 -1
- package/lib/plots/sunburst/types.d.ts +40 -12
- package/lib/plots/sunburst/types.js.map +1 -1
- package/lib/plots/tiny-area/types.d.ts +16 -5
- package/lib/plots/tiny-area/types.js.map +1 -1
- package/lib/plots/tiny-column/types.d.ts +10 -3
- package/lib/plots/tiny-column/types.js.map +1 -1
- package/lib/plots/tiny-line/types.d.ts +17 -5
- package/lib/plots/tiny-line/types.js.map +1 -1
- package/lib/plots/treemap/types.d.ts +17 -6
- package/lib/plots/treemap/types.js.map +1 -1
- package/lib/plots/venn/types.d.ts +20 -6
- package/lib/plots/venn/types.js.map +1 -1
- package/lib/plots/violin/types.d.ts +52 -17
- package/lib/plots/violin/types.js.map +1 -1
- package/lib/plots/waterfall/types.d.ts +42 -10
- package/lib/plots/waterfall/types.js.map +1 -1
- package/lib/plots/word-cloud/types.d.ts +91 -44
- package/lib/plots/word-cloud/types.js.map +1 -1
- package/lib/types/button.d.ts +8 -4
- package/lib/types/button.js.map +1 -1
- package/lib/types/common.d.ts +145 -33
- package/lib/types/common.js.map +1 -1
- package/lib/types/drill-down.d.ts +28 -7
- package/lib/types/drill-down.js.map +1 -1
- package/lib/types/interaction.d.ts +26 -6
- package/lib/types/interaction.js.map +1 -1
- package/lib/types/label.d.ts +11 -3
- package/lib/types/label.js.map +1 -1
- package/lib/types/meta.d.ts +4 -7
- package/lib/types/meta.js.map +1 -1
- package/lib/types/pattern.d.ts +58 -18
- package/lib/types/pattern.js.map +1 -1
- package/lib/types/state.d.ts +11 -3
- package/lib/types/state.js.map +1 -1
- package/lib/types/statistic.d.ts +38 -6
- package/lib/types/statistic.js.map +1 -1
- package/lib/types/tooltip.d.ts +7 -2
- package/lib/types/tooltip.js.map +1 -1
- package/package.json +1 -1
- package/src/core/plot.ts +5 -4
- package/src/index.ts +2 -2
- package/src/plots/area/types.ts +35 -10
- package/src/plots/bar/types.ts +16 -3
- package/src/plots/bidirectional-bar/types.ts +21 -6
- package/src/plots/box/types.ts +20 -6
- package/src/plots/bullet/types.ts +36 -17
- package/src/plots/chord/types.ts +14 -11
- package/src/plots/circle-packing/types.ts +25 -14
- package/src/plots/column/types.ts +57 -20
- package/src/plots/dual-axes/types.ts +31 -16
- package/src/plots/facet/types.ts +54 -49
- package/src/plots/funnel/types.ts +40 -13
- package/src/plots/gauge/types.ts +86 -27
- package/src/plots/heatmap/types.ts +49 -14
- package/src/plots/histogram/types.ts +17 -9
- package/src/plots/line/types.ts +42 -14
- package/src/plots/liquid/index.ts +2 -0
- package/src/plots/liquid/shapes/liquid.ts +16 -8
- package/src/plots/liquid/types.ts +56 -16
- package/src/plots/mix/types.ts +31 -35
- package/src/plots/pie/types.ts +27 -10
- package/src/plots/progress/types.ts +13 -4
- package/src/plots/radar/types.ts +39 -12
- package/src/plots/radial-bar/types.ts +39 -12
- package/src/plots/ring-progress/types.ts +18 -6
- package/src/plots/rose/types.ts +32 -12
- package/src/plots/sankey/types.ts +52 -32
- package/src/plots/scatter/types.ts +77 -24
- package/src/plots/stock/types.ts +21 -8
- package/src/plots/sunburst/types.ts +42 -12
- package/src/plots/tiny-area/types.ts +16 -5
- package/src/plots/tiny-column/types.ts +10 -3
- package/src/plots/tiny-line/types.ts +17 -5
- package/src/plots/treemap/types.ts +17 -7
- package/src/plots/venn/types.ts +21 -6
- package/src/plots/violin/types.ts +52 -17
- package/src/plots/waterfall/types.ts +42 -10
- package/src/plots/word-cloud/types.ts +91 -44
- package/src/types/button.ts +8 -4
- package/src/types/common.ts +145 -37
- package/src/types/drill-down.ts +28 -7
- package/src/types/interaction.ts +26 -6
- package/src/types/label.ts +11 -3
- package/src/types/meta.ts +4 -7
- package/src/types/pattern.ts +58 -18
- package/src/types/state.ts +11 -3
- package/src/types/statistic.ts +38 -6
- package/src/types/tooltip.ts +7 -2
|
@@ -3,66 +3,128 @@ import { Axis } from '../../types/axis';
|
|
|
3
3
|
import { PERCENT, RANGE_TYPE, RANGE_VALUE } from './constants';
|
|
4
4
|
/** 指标指标的配置 */
|
|
5
5
|
export declare type Indicator = {
|
|
6
|
+
/**
|
|
7
|
+
* @title 指针
|
|
8
|
+
* @description 只允许静态的 object
|
|
9
|
+
*/
|
|
6
10
|
readonly pointer?: {
|
|
7
11
|
readonly style?: ShapeStyle;
|
|
8
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* @title 圆环
|
|
15
|
+
* @description 只允许静态的 object
|
|
16
|
+
*/
|
|
9
17
|
readonly pin?: {
|
|
10
18
|
readonly style?: ShapeStyle;
|
|
11
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* @title 自定义指针 shape
|
|
22
|
+
* @default 'gauge-indicator'
|
|
23
|
+
*/
|
|
12
24
|
readonly shape?: string;
|
|
13
25
|
};
|
|
14
26
|
export declare type Range = {
|
|
15
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* @title 辅助的刻度值
|
|
29
|
+
* @description 0 ~ 1 的数字
|
|
30
|
+
*/
|
|
16
31
|
readonly ticks?: number[];
|
|
17
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* @title 辅助刻度的颜色配置
|
|
34
|
+
*/
|
|
18
35
|
readonly color?: string | string[];
|
|
19
|
-
/**
|
|
36
|
+
/**
|
|
37
|
+
* @title 仪表盘辅助背景的宽度
|
|
38
|
+
*/
|
|
20
39
|
readonly width?: number;
|
|
21
40
|
};
|
|
22
41
|
/**
|
|
23
|
-
* 仪表盘辅助生成的 rangeData
|
|
42
|
+
* @title 仪表盘辅助生成的 rangeData
|
|
24
43
|
*/
|
|
25
44
|
export declare type GaugeRangeData = {
|
|
26
45
|
readonly [RANGE_VALUE]?: number;
|
|
27
46
|
readonly [RANGE_TYPE]: string;
|
|
28
47
|
readonly [PERCENT]: number;
|
|
29
48
|
}[];
|
|
30
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* @title 仪表盘配置类型定义
|
|
51
|
+
*/
|
|
31
52
|
export interface GaugeOptions extends Omit<Options, 'data' | 'tooltip' | 'legend' | 'xAxis' | 'yAxis' | 'xField' | 'yField' | 'color'> {
|
|
32
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* @title 指标的比例
|
|
55
|
+
* @description 范围0 ~ 1
|
|
56
|
+
*/
|
|
33
57
|
readonly percent: number;
|
|
34
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* @title 外弧度
|
|
60
|
+
* @description 范围0 ~ 1
|
|
61
|
+
*/
|
|
35
62
|
readonly radius?: number;
|
|
36
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* @title 内弧度
|
|
65
|
+
* @description 范围0 ~ 1
|
|
66
|
+
*/
|
|
37
67
|
readonly innerRadius?: number;
|
|
38
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* @title 弧度起始
|
|
70
|
+
*/
|
|
39
71
|
readonly startAngle?: number;
|
|
40
|
-
/**
|
|
72
|
+
/**
|
|
73
|
+
* @title 弧度结束
|
|
74
|
+
*/
|
|
41
75
|
readonly endAngle?: number;
|
|
42
|
-
/**
|
|
76
|
+
/**
|
|
77
|
+
* @title 辅助的 range 组件
|
|
78
|
+
*/
|
|
43
79
|
readonly range?: Range;
|
|
44
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* @title 坐标轴配置
|
|
82
|
+
*/
|
|
45
83
|
readonly axis?: Axis;
|
|
46
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* @title 指针的配置
|
|
86
|
+
*/
|
|
47
87
|
readonly indicator?: false | Indicator;
|
|
48
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* @title 统计文本
|
|
90
|
+
*/
|
|
49
91
|
readonly statistic?: Statistic;
|
|
50
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* @title 仪表盘样式
|
|
94
|
+
*/
|
|
51
95
|
readonly gaugeStyle?: StyleAttr;
|
|
52
|
-
/**
|
|
96
|
+
/**
|
|
97
|
+
* @title meter gauge 相关配置
|
|
98
|
+
*/
|
|
99
|
+
/**
|
|
100
|
+
* @title 仪表盘类型
|
|
101
|
+
* @description 可选项: 'meter', default 为空
|
|
102
|
+
*/
|
|
53
103
|
readonly type?: string;
|
|
54
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* @title 仪表盘配置
|
|
106
|
+
* @description 当仪表盘类型 = 'meter' 生效
|
|
107
|
+
*/
|
|
55
108
|
readonly meter?: {
|
|
56
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* @title 仪表盘总步数
|
|
111
|
+
* @default "50"
|
|
112
|
+
*/
|
|
57
113
|
readonly steps?: number;
|
|
58
|
-
/**
|
|
114
|
+
/**
|
|
115
|
+
* @title step 与 gap 的宽度占比
|
|
116
|
+
* @default "0.5"
|
|
117
|
+
*/
|
|
59
118
|
readonly stepRatio?: number;
|
|
60
119
|
};
|
|
61
120
|
}
|
|
62
121
|
/**
|
|
63
|
-
* 仪表盘
|
|
122
|
+
* @title 仪表盘
|
|
123
|
+
* @description 自定义 shape 使用的 customInfo
|
|
64
124
|
*/
|
|
65
125
|
export declare type GaugeCustomInfo = {
|
|
66
|
-
/**
|
|
126
|
+
/**
|
|
127
|
+
* @title 仪表盘 meter 类型的相关配置
|
|
128
|
+
*/
|
|
67
129
|
readonly meter?: GaugeOptions['meter'];
|
|
68
130
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/gauge/types.ts"],"names":[],"mappings":";;AAEA,yCAA+D","sourcesContent":["import { Options, ShapeStyle, Statistic, StyleAttr } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { PERCENT, RANGE_TYPE, RANGE_VALUE } from './constants';\n\n/** 指标指标的配置 */\nexport type Indicator = {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/gauge/types.ts"],"names":[],"mappings":";;AAEA,yCAA+D","sourcesContent":["import { Options, ShapeStyle, Statistic, StyleAttr } from '../../types';\nimport { Axis } from '../../types/axis';\nimport { PERCENT, RANGE_TYPE, RANGE_VALUE } from './constants';\n\n/** 指标指标的配置 */\nexport type Indicator = {\n /**\n * @title 指针\n * @description 只允许静态的 object\n */\n readonly pointer?: {\n readonly style?: ShapeStyle;\n };\n /**\n * @title 圆环\n * @description 只允许静态的 object\n */\n readonly pin?: {\n readonly style?: ShapeStyle;\n };\n /**\n * @title 自定义指针 shape\n * @default 'gauge-indicator'\n */\n readonly shape?: string;\n};\n\nexport type Range = {\n /**\n * @title 辅助的刻度值\n * @description 0 ~ 1 的数字\n */\n readonly ticks?: number[];\n /**\n * @title 辅助刻度的颜色配置\n */\n readonly color?: string | string[];\n /**\n * @title 仪表盘辅助背景的宽度\n */\n readonly width?: number;\n};\n\n/**\n * @title 仪表盘辅助生成的 rangeData\n */\nexport type GaugeRangeData = {\n readonly [RANGE_VALUE]?: number;\n readonly [RANGE_TYPE]: string;\n readonly [PERCENT]: number;\n}[];\n\n/**\n * @title 仪表盘配置类型定义\n */\nexport interface GaugeOptions\n extends Omit<Options, 'data' | 'tooltip' | 'legend' | 'xAxis' | 'yAxis' | 'xField' | 'yField' | 'color'> {\n /**\n * @title 指标的比例\n * @description 范围0 ~ 1\n */\n readonly percent: number;\n /**\n * @title 外弧度\n * @description 范围0 ~ 1\n */\n readonly radius?: number;\n /**\n * @title 内弧度\n * @description 范围0 ~ 1\n */\n readonly innerRadius?: number;\n /**\n * @title 弧度起始\n */\n readonly startAngle?: number;\n /**\n * @title 弧度结束\n */\n readonly endAngle?: number;\n /**\n * @title 辅助的 range 组件\n */\n readonly range?: Range;\n /**\n * @title 坐标轴配置\n */\n readonly axis?: Axis;\n /**\n * @title 指针的配置\n */\n readonly indicator?: false | Indicator;\n /**\n * @title 统计文本\n */\n readonly statistic?: Statistic;\n /**\n * @title 仪表盘样式\n */\n readonly gaugeStyle?: StyleAttr;\n\n /**\n * @title meter gauge 相关配置\n */\n\n /**\n * @title 仪表盘类型\n * @description 可选项: 'meter', default 为空\n */\n readonly type?: string;\n /**\n * @title 仪表盘配置\n * @description 当仪表盘类型 = 'meter' 生效\n */\n readonly meter?: {\n /**\n * @title 仪表盘总步数\n * @default \"50\"\n */\n readonly steps?: number;\n /**\n * @title step 与 gap 的宽度占比\n * @default \"0.5\"\n */\n readonly stepRatio?: number;\n };\n}\n\n/**\n * @title 仪表盘\n * @description 自定义 shape 使用的 customInfo\n */\nexport type GaugeCustomInfo = {\n /**\n * @title 仪表盘 meter 类型的相关配置\n */\n readonly meter?: GaugeOptions['meter'];\n};\n"]}
|
|
@@ -1,28 +1,63 @@
|
|
|
1
1
|
import { Types } from '@antv/g2';
|
|
2
2
|
import { Options, StyleAttr } from '../../types';
|
|
3
3
|
export interface HeatmapOptions extends Options {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @title 热力图类型
|
|
6
|
+
* @description 'polygon' | 'density'
|
|
7
|
+
*/
|
|
5
8
|
readonly type?: 'polygon' | 'density';
|
|
6
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @title x轴字段
|
|
11
|
+
*/
|
|
7
12
|
readonly xField: string;
|
|
8
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @title y轴字段
|
|
15
|
+
*/
|
|
9
16
|
readonly yField: string;
|
|
10
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* @title 颜色字段
|
|
19
|
+
*/
|
|
11
20
|
readonly colorField?: string;
|
|
12
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* @title 热力格子中的形状
|
|
23
|
+
*/
|
|
13
24
|
readonly shape?: string;
|
|
14
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @title 热力格子中图形的尺寸比例
|
|
27
|
+
* @description 只有当 shape 和 sizeField 至少指定一项后才生效
|
|
28
|
+
*/
|
|
15
29
|
readonly sizeRatio?: number;
|
|
16
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* @title 坐标轴映射
|
|
32
|
+
* @description 坐标轴映射 'x' | 'y'
|
|
33
|
+
*/
|
|
17
34
|
readonly reflect?: 'x' | 'y';
|
|
18
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* @title 极坐标属性
|
|
37
|
+
*/
|
|
19
38
|
readonly coordinate?: Types.CoordinateOption;
|
|
20
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* @title 图例相关
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* @title 数据字段名
|
|
44
|
+
* @description 点大小映射对应的数据字段名
|
|
45
|
+
*/
|
|
21
46
|
readonly sizeField?: string;
|
|
22
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* @title size 对应的图例
|
|
49
|
+
*/
|
|
23
50
|
readonly sizeLegend?: Options['legend'];
|
|
24
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* @title 样式相关
|
|
53
|
+
*/
|
|
54
|
+
/**
|
|
55
|
+
* @title 热力图形样式
|
|
56
|
+
*/
|
|
25
57
|
readonly heatmapStyle?: StyleAttr;
|
|
26
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* @title 贴图图案
|
|
60
|
+
* @description 在 type="density" 时不支持
|
|
61
|
+
*/
|
|
27
62
|
readonly pattern?: Options['pattern'];
|
|
28
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/heatmap/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface HeatmapOptions extends Options {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/heatmap/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Types } from '@antv/g2';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface HeatmapOptions extends Options {\n /**\n * @title 热力图类型\n * @description 'polygon' | 'density'\n */\n readonly type?: 'polygon' | 'density';\n /**\n * @title x轴字段\n */\n readonly xField: string;\n /**\n * @title y轴字段\n */\n readonly yField: string;\n /**\n * @title 颜色字段\n */\n readonly colorField?: string;\n /**\n * @title 热力格子中的形状\n */\n readonly shape?: string;\n /**\n * @title 热力格子中图形的尺寸比例\n * @description 只有当 shape 和 sizeField 至少指定一项后才生效\n */\n readonly sizeRatio?: number;\n /**\n * @title 坐标轴映射\n * @description 坐标轴映射 'x' | 'y'\n */\n readonly reflect?: 'x' | 'y';\n /**\n * @title 极坐标属性\n */\n readonly coordinate?: Types.CoordinateOption;\n\n /**\n * @title 图例相关\n */\n\n /**\n * @title 数据字段名\n * @description 点大小映射对应的数据字段名\n */\n readonly sizeField?: string;\n /**\n * @title size 对应的图例\n */\n readonly sizeLegend?: Options['legend'];\n\n /**\n * @title 样式相关\n */\n\n /**\n * @title 热力图形样式\n */\n readonly heatmapStyle?: StyleAttr;\n /**\n * @title 贴图图案\n * @description 在 type=\"density\" 时不支持\n */\n readonly pattern?: Options['pattern'];\n}\n"]}
|
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
import { Options, StyleAttr } from '../../types';
|
|
2
2
|
export interface HistogramOptions extends Options {
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* @title 直方图绘制字段
|
|
5
|
+
* @description 设置直方图绘制 (进行分箱) 的字段
|
|
6
|
+
*/
|
|
4
7
|
readonly binField: string;
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
9
|
+
* @title 设置直方图的分箱宽度
|
|
10
|
+
* @description binWidth 影响直方图分成多少箱,不能与binNumber一起使用
|
|
8
11
|
*/
|
|
9
12
|
readonly binWidth?: number;
|
|
10
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* @title 设置直方图的分箱数量
|
|
15
|
+
* @description binNumber 影响直方图分箱后每个柱子的宽度
|
|
16
|
+
*/
|
|
11
17
|
readonly binNumber?: number;
|
|
12
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* @title 指定层叠字段
|
|
20
|
+
* @description 通过该字段的值,柱子将会被分割为多个部分,通过颜色进行区分
|
|
21
|
+
*/
|
|
13
22
|
readonly stackField?: string;
|
|
14
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* @title 柱子样式配置
|
|
25
|
+
*/
|
|
15
26
|
readonly columnStyle?: StyleAttr;
|
|
16
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/histogram/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Options, StyleAttr } from '../../types';\n\nexport interface HistogramOptions extends Options {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/histogram/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Options, StyleAttr } from '../../types';\n\nexport interface HistogramOptions extends Options {\n /**\n * @title 直方图绘制字段\n * @description 设置直方图绘制 (进行分箱) 的字段\n */\n readonly binField: string;\n\n /**\n * @title 设置直方图的分箱宽度\n * @description binWidth 影响直方图分成多少箱,不能与binNumber一起使用\n */\n readonly binWidth?: number;\n /**\n * @title 设置直方图的分箱数量\n * @description binNumber 影响直方图分箱后每个柱子的宽度\n */\n readonly binNumber?: number;\n /**\n * @title 指定层叠字段\n * @description 通过该字段的值,柱子将会被分割为多个部分,通过颜色进行区分\n */\n readonly stackField?: string;\n /**\n * @title 柱子样式配置\n */\n readonly columnStyle?: StyleAttr;\n}\n"]}
|
|
@@ -1,28 +1,58 @@
|
|
|
1
1
|
import { GeometryOptions, AreaGeometryOptions, LineGeometryOptions, PointGeometryOptions } from '../../adaptor/geometries';
|
|
2
2
|
import { Options, StyleAttr } from '../../types';
|
|
3
3
|
export interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* @title 阶梯折线图类型
|
|
6
|
+
*/
|
|
5
7
|
readonly stepType?: string;
|
|
6
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* @title x轴字段
|
|
10
|
+
*/
|
|
7
11
|
readonly xField?: string;
|
|
8
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* @title y轴字段
|
|
14
|
+
*/
|
|
9
15
|
readonly yField?: string;
|
|
10
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* @title 分组字段
|
|
18
|
+
*/
|
|
11
19
|
readonly seriesField?: string;
|
|
12
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* @title 是否堆积
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
13
24
|
readonly isStack?: boolean;
|
|
14
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* @title 是否平滑
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
15
29
|
readonly smooth?: boolean;
|
|
16
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* @title 是否连接空数据
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
17
34
|
readonly connectNulls?: boolean;
|
|
18
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* @title 折线图形样式
|
|
37
|
+
*/
|
|
19
38
|
readonly lineStyle?: StyleAttr;
|
|
20
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* @title 折线 shape 配置
|
|
41
|
+
*/
|
|
21
42
|
readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];
|
|
22
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* @title 折线数据点
|
|
45
|
+
* @description 1、图形映射属性 2、状态样式
|
|
46
|
+
*/
|
|
23
47
|
readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
|
|
24
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* @title 折线趋势填充色
|
|
50
|
+
* @description 1、图形映射属性
|
|
51
|
+
*/
|
|
25
52
|
readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;
|
|
26
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* @title 坐标轴反转配置
|
|
55
|
+
* @description 坐标轴反转配置 'x' | 'y' | ['x', 'y']
|
|
56
|
+
*/
|
|
27
57
|
readonly reflect?: 'x' | 'y' | ['x', 'y'];
|
|
28
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/line/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n GeometryOptions,\n AreaGeometryOptions,\n LineGeometryOptions,\n PointGeometryOptions,\n} from '../../adaptor/geometries';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {\n
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/plots/line/types.ts"],"names":[],"mappings":"","sourcesContent":["import {\n GeometryOptions,\n AreaGeometryOptions,\n LineGeometryOptions,\n PointGeometryOptions,\n} from '../../adaptor/geometries';\nimport { Options, StyleAttr } from '../../types';\n\nexport interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {\n /**\n * @title 阶梯折线图类型\n */\n readonly stepType?: string;\n /**\n * @title x轴字段\n */\n readonly xField?: string;\n /**\n * @title y轴字段\n */\n readonly yField?: string;\n /**\n * @title 分组字段\n */\n readonly seriesField?: string;\n /**\n * @title 是否堆积\n * @default false\n */\n readonly isStack?: boolean;\n /**\n * @title 是否平滑\n * @default false\n */\n readonly smooth?: boolean;\n /**\n * @title 是否连接空数据\n * @default false\n */\n readonly connectNulls?: boolean;\n /**\n * @title 折线图形样式\n */\n readonly lineStyle?: StyleAttr;\n /**\n * @title 折线 shape 配置\n */\n readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];\n /**\n * @title 折线数据点\n * @description 1、图形映射属性 2、状态样式\n */\n readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;\n /**\n * @title 折线趋势填充色\n * @description 1、图形映射属性\n */\n readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;\n /**\n * @title 坐标轴反转配置\n * @description 坐标轴反转配置 'x' | 'y' | ['x', 'y']\n */\n readonly reflect?: 'x' | 'y' | ['x', 'y'];\n}\n"]}
|
|
@@ -9,6 +9,8 @@ var constants_1 = require("./constants");
|
|
|
9
9
|
var utils_1 = require("./utils");
|
|
10
10
|
// register liquid shape
|
|
11
11
|
require("./shapes/liquid");
|
|
12
|
+
var liquid_1 = require("./shapes/liquid");
|
|
13
|
+
Object.defineProperty(exports, "addWaterWave", { enumerable: true, get: function () { return liquid_1.addWaterWave; } });
|
|
12
14
|
/**
|
|
13
15
|
* 传说中的水波图
|
|
14
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/liquid/index.ts"],"names":[],"mappings":";;;;AAAA,+BAAmD;AACnD,wCAAuC;AAGvC,qCAA+C;AAC/C,yCAA8C;AAC9C,iCAAwC;AACxC,wBAAwB;AACxB,2BAAyB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plots/liquid/index.ts"],"names":[],"mappings":";;;;AAAA,+BAAmD;AACnD,wCAAuC;AAGvC,qCAA+C;AAC/C,yCAA8C;AAC9C,iCAAwC;AACxC,wBAAwB;AACxB,2BAAyB;AAEzB,0CAA+C;AAAtC,sGAAA,YAAY,OAAA;AAIrB;;GAEG;AACH;IAA4B,kCAAmB;IAA/C;QAAA,qEA6CC;QApCC,WAAW;QACJ,UAAI,GAAW,QAAQ,CAAC;;IAmCjC,CAAC;IA5CC;;;OAGG;IACI,wBAAiB,GAAxB;QACE,OAAO,2BAAe,CAAC;IACzB,CAAC;IAKD;;OAEG;IACO,kCAAiB,GAA3B;QACE,OAAO,MAAM,CAAC,iBAAiB,EAAE,CAAC;IACpC,CAAC;IAED;;;OAGG;IACI,2BAAU,GAAjB,UAAkB,OAAe;QAC/B,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,qBAAgB,CAAC,kBAAkB,EACnC,UAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,qBAAgB,CAAC,kBAAkB,EAAE,IAAI,CAAC,CACtE,CAAC;QACF,IAAI,CAAC,YAAY,CAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAC;QAE/B,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,qBAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QACxC,mBAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;QAE9D,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,qBAAgB,CAAC,iBAAiB,EAClC,UAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,qBAAgB,CAAC,iBAAiB,EAAE,IAAI,CAAC,CACrE,CAAC;IACJ,CAAC;IAED;;OAEG;IACO,iCAAgB,GAA1B;QACE,OAAO,iBAAO,CAAC;IACjB,CAAC;IACH,aAAC;AAAD,CAAC,AA7CD,CAA4B,WAAI,GA6C/B;AA7CY,wBAAM","sourcesContent":["import { VIEW_LIFE_CIRCLE, Event } from '@antv/g2';\nimport { Plot } from '../../core/plot';\nimport { Adaptor } from '../../core/adaptor';\nimport { LiquidOptions } from './types';\nimport { adaptor, statistic } from './adaptor';\nimport { DEFAULT_OPTIONS } from './constants';\nimport { getLiquidData } from './utils';\n// register liquid shape\nimport './shapes/liquid';\n\nexport { addWaterWave } from './shapes/liquid';\n\nexport type { LiquidOptions };\n\n/**\n * 传说中的水波图\n */\nexport class Liquid extends Plot<LiquidOptions> {\n /**\n * 获取 饼图 默认配置项\n * 供外部使用\n */\n static getDefaultOptions(): Partial<LiquidOptions> {\n return DEFAULT_OPTIONS;\n }\n\n /** 图表类型 */\n public type: string = 'liquid';\n\n /**\n * 获取 水波图 默认配置项, 供 base 获取\n */\n protected getDefaultOptions(): Partial<LiquidOptions> {\n return Liquid.getDefaultOptions();\n }\n\n /**\n * 更新数据\n * @param percent\n */\n public changeData(percent: number) {\n this.chart.emit(\n VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA,\n Event.fromData(this.chart, VIEW_LIFE_CIRCLE.BEFORE_CHANGE_DATA, null)\n );\n this.updateOption({ percent });\n\n this.chart.data(getLiquidData(percent));\n statistic({ chart: this.chart, options: this.options }, true);\n\n this.chart.emit(\n VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA,\n Event.fromData(this.chart, VIEW_LIFE_CIRCLE.AFTER_CHANGE_DATA, null)\n );\n }\n\n /**\n * 获取适配器\n */\n protected getSchemaAdaptor(): Adaptor<LiquidOptions> {\n return adaptor;\n }\n}\n"]}
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { IGroup, IShape } from '@antv/g-base';
|
|
2
|
+
import { ShapeStyle } from '../../../types';
|
|
3
|
+
import { LiquidOptions } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* 添加水波
|
|
6
|
+
* @param x 中心x
|
|
7
|
+
* @param y 中心y
|
|
8
|
+
* @param level 水位等级 0~1
|
|
9
|
+
* @param waveCount 水波数
|
|
10
|
+
* @param waveAttrs 色值
|
|
11
|
+
* @param group 图组
|
|
12
|
+
* @param clip 用于剪切的图形
|
|
13
|
+
* @param radius 绘制图形的高度
|
|
14
|
+
* @param waveLength 波的长度
|
|
15
|
+
*/
|
|
16
|
+
export declare function addWaterWave(x: number, y: number, level: number, waveCount: number, waveAttrs: ShapeStyle, group: IGroup, clip: IShape, radius: number, waveLength: number, animation: LiquidOptions['animation']): void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addWaterWave = void 0;
|
|
3
4
|
var tslib_1 = require("tslib");
|
|
4
5
|
var g2_1 = require("@antv/g2");
|
|
5
6
|
var util_1 = require("@antv/util");
|
|
@@ -181,15 +182,19 @@ function getWaterWavePath(radius, waterLevel, waveLength, phase, amplitude, cx,
|
|
|
181
182
|
* @param waveLength 波的长度
|
|
182
183
|
*/
|
|
183
184
|
function addWaterWave(x, y, level, waveCount, waveAttrs, group, clip, radius, waveLength, animation) {
|
|
185
|
+
// 盒子属性 颜色 宽高
|
|
184
186
|
var fill = waveAttrs.fill, opacity = waveAttrs.opacity;
|
|
185
187
|
var bbox = clip.getBBox();
|
|
186
188
|
var width = bbox.maxX - bbox.minX;
|
|
187
189
|
var height = bbox.maxY - bbox.minY;
|
|
190
|
+
// 循环 waveCount 个数
|
|
188
191
|
for (var idx = 0; idx < waveCount; idx++) {
|
|
189
192
|
var factor = waveCount <= 1 ? 0 : idx / (waveCount - 1);
|
|
193
|
+
// 画波
|
|
190
194
|
var wave = group.addShape('path', {
|
|
191
195
|
name: "waterwave-path",
|
|
192
196
|
attrs: {
|
|
197
|
+
// 波形路径配置
|
|
193
198
|
path: getWaterWavePath(radius, bbox.minY + height * level, waveLength, 0, width / 32, // 波幅高度
|
|
194
199
|
x, y),
|
|
195
200
|
fill: fill,
|
|
@@ -197,6 +202,7 @@ function addWaterWave(x, y, level, waveCount, waveAttrs, group, clip, radius, wa
|
|
|
197
202
|
},
|
|
198
203
|
});
|
|
199
204
|
try {
|
|
205
|
+
// 默认 underfind 开启动画
|
|
200
206
|
if (animation === false)
|
|
201
207
|
return;
|
|
202
208
|
var matrix = matrix_1.transform([['t', waveLength, 0]]);
|
|
@@ -212,6 +218,7 @@ function addWaterWave(x, y, level, waveCount, waveAttrs, group, clip, radius, wa
|
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
220
|
}
|
|
221
|
+
exports.addWaterWave = addWaterWave;
|
|
215
222
|
/**
|
|
216
223
|
*
|
|
217
224
|
* @param x 中心 x
|
|
@@ -286,6 +293,13 @@ function rect(x, y, width, height) {
|
|
|
286
293
|
var w = (width / 2) * GOLDEN_SECTION_RATIO;
|
|
287
294
|
return "\n M " + (x - w) + " " + (y - h) + "\n L " + (x + w) + " " + (y - h) + "\n L " + (x + w) + " " + (y + h) + "\n L " + (x - w) + " " + (y + h) + "\n Z\n ";
|
|
288
295
|
}
|
|
296
|
+
var builtInShapeByName = {
|
|
297
|
+
pin: pin,
|
|
298
|
+
circle: circle,
|
|
299
|
+
diamond: diamond,
|
|
300
|
+
triangle: triangle,
|
|
301
|
+
rect: rect,
|
|
302
|
+
};
|
|
289
303
|
g2_1.registerShape('interval', 'liquid-fill-gauge', {
|
|
290
304
|
draw: function (cfg, container) {
|
|
291
305
|
var cx = 0.5;
|
|
@@ -308,13 +322,6 @@ g2_1.registerShape('interval', 'liquid-fill-gauge', {
|
|
|
308
322
|
var waveAttrs = getFillAttrs(cfg);
|
|
309
323
|
var outlineAttrs = getLineAttrs(util_1.mix({}, cfg, outline));
|
|
310
324
|
var innerRadius = radius - border / 2;
|
|
311
|
-
var builtInShapeByName = {
|
|
312
|
-
pin: pin,
|
|
313
|
-
circle: circle,
|
|
314
|
-
diamond: diamond,
|
|
315
|
-
triangle: triangle,
|
|
316
|
-
rect: rect,
|
|
317
|
-
};
|
|
318
325
|
var buildPath = typeof shape === 'function' ? shape : builtInShapeByName[shape] || builtInShapeByName['circle'];
|
|
319
326
|
var shapePath = buildPath(center.x, center.y, innerRadius * 2, innerRadius * 2);
|
|
320
327
|
// 1. 绘制一个波
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquid.js","sourceRoot":"","sources":["../../../../src/plots/liquid/shapes/liquid.ts"],"names":[],"mappings":";;;AAAA,+BAAyC;AAEzC,mCAAmD;AACnD,gDAAkD;AAIlD,IAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB;;;;;GAKG;AACH,SAAS,IAAI,CAAC,GAAW,EAAE,GAAW,EAAE,MAAc;IACpD,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAe;IACnC,IAAM,KAAK,sBAAK,OAAO,EAAE,CAAC,IAAK,GAAG,CAAC,KAAK,CAAE,CAAC;IAE3C,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAC5B,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,KAAK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EACT,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,CAAC,EACV,UAAU,EACV,SAAS,CACV,CAAC;QAEF,6BAA6B;QAC7B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,CAAC;gBAChC,MAAM,EAAE,UAAU,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU;aAC3D;SACF,CAAC,CAAC;QAEH,2BAA2B;QAC3B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,UAAG,CAAC,YAAY,EAAE;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;SACH,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { registerShape } from '@antv/g2';\nimport { IGroup, IShape } from '@antv/g-base';\nimport { reduce, isNumber, mix } from '@antv/util';\nimport { transform } from '../../../utils/matrix';\nimport { Point, ShapeStyle } from '../../../types';\nimport { LiquidOptions, CustomInfo } from '../types';\n\nconst DURATION = 5000;\n\n/**\n * 一个线性映射的函数\n * @param min\n * @param max\n * @param factor\n */\nfunction lerp(min: number, max: number, factor: number) {\n return min + (max - min) * factor;\n}\n\n/**\n * 波浪的 attrs\n * @param cfg\n */\nfunction getFillAttrs(cfg: ShapeStyle) {\n const attrs = { opacity: 1, ...cfg.style };\n\n if (cfg.color && !attrs.fill) {\n attrs.fill = cfg.color;\n }\n\n return attrs;\n}\n\n/**\n * shape 的 attrs\n * @param cfg\n */\nfunction getLineAttrs(cfg: ShapeStyle) {\n const defaultAttrs = {\n fill: '#fff',\n fillOpacity: 0,\n lineWidth: 4,\n };\n const attrs = mix({}, defaultAttrs, cfg.style);\n\n if (cfg.color && !attrs.stroke) {\n attrs.stroke = cfg.color;\n }\n if (isNumber(cfg.opacity)) {\n attrs.opacity = attrs.strokeOpacity = cfg.opacity;\n }\n\n return attrs;\n}\n\n/**\n * 用贝塞尔曲线模拟正弦波\n * Using Bezier curves to fit sine wave.\n * There is 4 control points for each curve of wave,\n * which is at 1/4 wave length of the sine wave.\n *\n * The control points for a wave from (a) to (d) are a-b-c-d:\n * c *----* d\n * b *\n * |\n * ... a * ..................\n *\n * whose positions are a: (0, 0), b: (0.5, 0.5), c: (1, 1), d: (PI / 2, 1)\n *\n * @param x x position of the left-most point (a)\n * @param stage 0-3, stating which part of the wave it is\n * @param waveLength wave length of the sine wave\n * @param amplitude wave amplitude\n * @return 正弦片段曲线\n */\nfunction getWaterWavePositions(x: number, stage: number, waveLength: number, amplitude: number) {\n if (stage === 0) {\n return [\n [x + ((1 / 2) * waveLength) / Math.PI / 2, amplitude / 2],\n [x + ((1 / 2) * waveLength) / Math.PI, amplitude],\n [x + waveLength / 4, amplitude],\n ];\n }\n if (stage === 1) {\n return [\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 2), amplitude],\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 1), amplitude / 2],\n [x + waveLength / 4, 0],\n ];\n }\n if (stage === 2) {\n return [\n [x + ((1 / 2) * waveLength) / Math.PI / 2, -amplitude / 2],\n [x + ((1 / 2) * waveLength) / Math.PI, -amplitude],\n [x + waveLength / 4, -amplitude],\n ];\n }\n return [\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 2), -amplitude],\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 1), -amplitude / 2],\n [x + waveLength / 4, 0],\n ];\n}\n/**\n * 获取水波路径\n * @param radius 半径\n * @param waterLevel 水位\n * @param waveLength 波长\n * @param phase 相位\n * @param amplitude 震幅\n * @param cx 圆心x\n * @param cy 圆心y\n * @return path 路径\n * @reference http://gitlab.alipay-inc.com/datavis/g6/blob/1.2.0/src/graph/utils/path.js#L135\n */\nfunction getWaterWavePath(\n radius: number,\n waterLevel: number,\n waveLength: number,\n phase: number,\n amplitude: number,\n cx: number,\n cy: number\n) {\n const curves = Math.ceil(((2 * radius) / waveLength) * 4) * 4;\n const path = [];\n let _phase = phase;\n\n // map phase to [-Math.PI * 2, 0]\n while (_phase < -Math.PI * 2) {\n _phase += Math.PI * 2;\n }\n while (_phase > 0) {\n _phase -= Math.PI * 2;\n }\n _phase = (_phase / Math.PI / 2) * waveLength;\n\n const left = cx - radius + _phase - radius * 2;\n /**\n * top-left corner as start point\n *\n * draws this point\n * |\n * \\|/\n * ~~~~~~~~\n * | |\n * +------+\n */\n path.push(['M', left, waterLevel]);\n\n /**\n * top wave\n *\n * ~~~~~~~~ <- draws this sine wave\n * | |\n * +------+\n */\n let waveRight = 0;\n for (let c = 0; c < curves; ++c) {\n const stage = c % 4;\n const pos = getWaterWavePositions((c * waveLength) / 4, stage, waveLength, amplitude);\n path.push([\n 'C',\n pos[0][0] + left,\n -pos[0][1] + waterLevel,\n pos[1][0] + left,\n -pos[1][1] + waterLevel,\n pos[2][0] + left,\n -pos[2][1] + waterLevel,\n ]);\n\n if (c === curves - 1) {\n waveRight = pos[2][0];\n }\n }\n\n /**\n * top-right corner\n *\n * ~~~~~~~~\n * 3. draws this line -> | | <- 1. draws this line\n * +------+\n * ^\n * |\n * 2. draws this line\n */\n path.push(['L', waveRight + left, cy + radius]);\n path.push(['L', left, cy + radius]);\n path.push(['Z']);\n // path.push(['L', left, waterLevel]);\n return path;\n}\n\n/**\n * 添加水波\n * @param x 中心x\n * @param y 中心y\n * @param level 水位等级 0~1\n * @param waveCount 水波数\n * @param waveAttrs 色值\n * @param group 图组\n * @param clip 用于剪切的图形\n * @param radius 绘制图形的高度\n * @param waveLength 波的长度\n */\nfunction addWaterWave(\n x: number,\n y: number,\n level: number,\n waveCount: number,\n waveAttrs: ShapeStyle,\n group: IGroup,\n clip: IShape,\n radius: number,\n waveLength: number,\n animation: LiquidOptions['animation']\n) {\n const { fill, opacity } = waveAttrs;\n const bbox = clip.getBBox();\n const width = bbox.maxX - bbox.minX;\n const height = bbox.maxY - bbox.minY;\n\n for (let idx = 0; idx < waveCount; idx++) {\n const factor = waveCount <= 1 ? 0 : idx / (waveCount - 1);\n const wave = group.addShape('path', {\n name: `waterwave-path`,\n attrs: {\n path: getWaterWavePath(\n radius,\n bbox.minY + height * level,\n waveLength,\n 0,\n width / 32, // 波幅高度\n x,\n y\n ),\n fill,\n opacity: lerp(0.2, 0.9, factor) * opacity,\n },\n });\n\n try {\n if (animation === false) return;\n const matrix = transform([['t', waveLength, 0]]);\n\n wave.stopAnimate();\n wave.animate(\n { matrix },\n {\n duration: lerp(0.5 * DURATION, DURATION, factor),\n repeat: true,\n }\n );\n } catch (e) {\n // TODO off-screen canvas 中动画会找不到 canvas\n console.warn('off-screen group animate error!');\n }\n }\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction pin(x: number, y: number, width: number, height: number) {\n const w = (width * 2) / 3;\n const h = Math.max(w, height);\n const r = w / 2;\n\n // attrs of the upper circle\n const cx = x;\n const cy = r + y - h / 2;\n const theta = Math.asin(r / ((h - r) * 0.85));\n const dy = Math.sin(theta) * r;\n const dx = Math.cos(theta) * r;\n\n // the start point of the path\n const x0 = cx - dx;\n const y0 = cy + dy;\n\n // control point\n const cpX = x;\n const cpY = cy + r / Math.sin(theta);\n\n return `\n M ${x0} ${y0}\n A ${r} ${r} 0 1 1 ${x0 + dx * 2} ${y0}\n Q ${cpX} ${cpY} ${x} ${y + h / 2}\n Q ${cpX} ${cpY} ${x0} ${y0}\n Z \n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction circle(x: number, y: number, width: number, height: number) {\n const rx = width / 2;\n const ry = height / 2;\n return `\n M ${x} ${y - ry} \n a ${rx} ${ry} 0 1 0 0 ${ry * 2}\n a ${rx} ${ry} 0 1 0 0 ${-ry * 2}\n Z\n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction diamond(x: number, y: number, width: number, height: number) {\n const h = height / 2;\n const w = width / 2;\n return `\n M ${x} ${y - h}\n L ${x + w} ${y}\n L ${x} ${y + h}\n L ${x - w} ${y}\n Z\n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction triangle(x: number, y: number, width: number, height: number) {\n const h = height / 2;\n const w = width / 2;\n return `\n M ${x} ${y - h}\n L ${x + w} ${y + h}\n L ${x - w} ${y + h}\n Z\n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction rect(x: number, y: number, width: number, height: number) {\n const GOLDEN_SECTION_RATIO = 0.618;\n const h = height / 2;\n const w = (width / 2) * GOLDEN_SECTION_RATIO;\n return `\n M ${x - w} ${y - h}\n L ${x + w} ${y - h}\n L ${x + w} ${y + h}\n L ${x - w} ${y + h}\n Z\n `;\n}\n\nregisterShape('interval', 'liquid-fill-gauge', {\n draw(cfg: any, container: IGroup) {\n const cx = 0.5;\n const cy = 0.5;\n\n const { customInfo } = cfg;\n const { radius: radio, shape, background, animation } = customInfo as CustomInfo;\n const outline: LiquidOptions['outline'] = customInfo.outline;\n const wave: LiquidOptions['wave'] = customInfo.wave;\n const { border, distance } = outline;\n const { count: waveCount, length: waveLength } = wave;\n\n // 获取最小 minX\n const minX = reduce(\n cfg.points as Point[],\n (r: number, p: Point) => {\n return Math.min(r, p.x);\n },\n Infinity\n );\n\n const center = this.parsePoint({ x: cx, y: cy });\n const minXPoint = this.parsePoint({ x: minX, y: cy });\n const halfWidth = center.x - minXPoint.x;\n\n // 保证半径是 画布宽高最小值的 radius 值\n const radius = Math.min(halfWidth, minXPoint.y * radio);\n const waveAttrs = getFillAttrs(cfg);\n const outlineAttrs = getLineAttrs(mix({}, cfg, outline));\n const innerRadius = radius - border / 2;\n const builtInShapeByName = {\n pin,\n circle,\n diamond,\n triangle,\n rect,\n };\n const buildPath = typeof shape === 'function' ? shape : builtInShapeByName[shape] || builtInShapeByName['circle'];\n const shapePath = buildPath(center.x, center.y, innerRadius * 2, innerRadius * 2);\n\n // 1. 绘制一个波\n const waves = container.addGroup({\n name: 'waves',\n });\n\n // 3. 波对应的 clip 裁剪形状\n const clipPath = waves.setClip({\n type: 'path',\n attrs: {\n path: shapePath,\n },\n });\n\n // 4. 绘制波形\n addWaterWave(\n center.x,\n center.y,\n 1 - (cfg.points[1] as Point).y,\n waveCount,\n waveAttrs,\n waves,\n clipPath,\n radius * 2,\n waveLength,\n animation\n );\n\n // 2. 绘制一个 distance 宽的 border\n container.addShape('path', {\n name: 'distance',\n attrs: {\n path: shapePath,\n fill: 'transparent',\n lineWidth: border + distance * 2,\n stroke: background === 'transparent' ? '#fff' : background,\n },\n });\n\n // 3. 绘制一个 border 宽的 border\n container.addShape('path', {\n name: 'wrap',\n attrs: mix(outlineAttrs, {\n path: shapePath,\n fill: 'transparent',\n lineWidth: border,\n }),\n });\n\n return container;\n },\n});\n"]}
|
|
1
|
+
{"version":3,"file":"liquid.js","sourceRoot":"","sources":["../../../../src/plots/liquid/shapes/liquid.ts"],"names":[],"mappings":";;;;AAAA,+BAAyC;AAEzC,mCAAmD;AACnD,gDAAkD;AAIlD,IAAM,QAAQ,GAAG,IAAI,CAAC;AAEtB;;;;;GAKG;AACH,SAAS,IAAI,CAAC,GAAW,EAAE,GAAW,EAAE,MAAc;IACpD,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,MAAM,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,GAAe;I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QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC;YAC7B,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;aAChB;SACF,CAAC,CAAC;QAEH,UAAU;QACV,YAAY,CACV,MAAM,CAAC,CAAC,EACR,MAAM,CAAC,CAAC,EACR,CAAC,GAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAW,CAAC,CAAC,EAC9B,SAAS,EACT,SAAS,EACT,KAAK,EACL,QAAQ,EACR,MAAM,GAAG,CAAC,EACV,UAAU,EACV,SAAS,CACV,CAAC;QAEF,6BAA6B;QAC7B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,IAAI,EAAE,UAAU;YAChB,KAAK,EAAE;gBACL,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,MAAM,GAAG,QAAQ,GAAG,CAAC;gBAChC,MAAM,EAAE,UAAU,KAAK,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU;aAC3D;SACF,CAAC,CAAC;QAEH,2BAA2B;QAC3B,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE;YACzB,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,UAAG,CAAC,YAAY,EAAE;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,aAAa;gBACnB,SAAS,EAAE,MAAM;aAClB,CAAC;SACH,CAAC,CAAC;QAEH,OAAO,SAAS,CAAC;IACnB,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { registerShape } from '@antv/g2';\nimport { IGroup, IShape } from '@antv/g-base';\nimport { reduce, isNumber, mix } from '@antv/util';\nimport { transform } from '../../../utils/matrix';\nimport { Point, ShapeStyle } from '../../../types';\nimport { LiquidOptions, CustomInfo } from '../types';\n\nconst DURATION = 5000;\n\n/**\n * 一个线性映射的函数\n * @param min\n * @param max\n * @param factor\n */\nfunction lerp(min: number, max: number, factor: number) {\n return min + (max - min) * factor;\n}\n\n/**\n * 波浪的 attrs\n * @param cfg\n */\nfunction getFillAttrs(cfg: ShapeStyle) {\n const attrs = { opacity: 1, ...cfg.style };\n\n if (cfg.color && !attrs.fill) {\n attrs.fill = cfg.color;\n }\n\n return attrs;\n}\n\n/**\n * shape 的 attrs\n * @param cfg\n */\nfunction getLineAttrs(cfg: ShapeStyle) {\n const defaultAttrs = {\n fill: '#fff',\n fillOpacity: 0,\n lineWidth: 4,\n };\n const attrs = mix({}, defaultAttrs, cfg.style);\n\n if (cfg.color && !attrs.stroke) {\n attrs.stroke = cfg.color;\n }\n if (isNumber(cfg.opacity)) {\n attrs.opacity = attrs.strokeOpacity = cfg.opacity;\n }\n\n return attrs;\n}\n\n/**\n * 用贝塞尔曲线模拟正弦波\n * Using Bezier curves to fit sine wave.\n * There is 4 control points for each curve of wave,\n * which is at 1/4 wave length of the sine wave.\n *\n * The control points for a wave from (a) to (d) are a-b-c-d:\n * c *----* d\n * b *\n * |\n * ... a * ..................\n *\n * whose positions are a: (0, 0), b: (0.5, 0.5), c: (1, 1), d: (PI / 2, 1)\n *\n * @param x x position of the left-most point (a)\n * @param stage 0-3, stating which part of the wave it is\n * @param waveLength wave length of the sine wave\n * @param amplitude wave amplitude\n * @return 正弦片段曲线\n */\nfunction getWaterWavePositions(x: number, stage: number, waveLength: number, amplitude: number) {\n if (stage === 0) {\n return [\n [x + ((1 / 2) * waveLength) / Math.PI / 2, amplitude / 2],\n [x + ((1 / 2) * waveLength) / Math.PI, amplitude],\n [x + waveLength / 4, amplitude],\n ];\n }\n if (stage === 1) {\n return [\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 2), amplitude],\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 1), amplitude / 2],\n [x + waveLength / 4, 0],\n ];\n }\n if (stage === 2) {\n return [\n [x + ((1 / 2) * waveLength) / Math.PI / 2, -amplitude / 2],\n [x + ((1 / 2) * waveLength) / Math.PI, -amplitude],\n [x + waveLength / 4, -amplitude],\n ];\n }\n return [\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 2), -amplitude],\n [x + (((1 / 2) * waveLength) / Math.PI / 2) * (Math.PI - 1), -amplitude / 2],\n [x + waveLength / 4, 0],\n ];\n}\n/**\n * 获取水波路径\n * @param radius 半径\n * @param waterLevel 水位\n * @param waveLength 波长\n * @param phase 相位\n * @param amplitude 震幅\n * @param cx 圆心x\n * @param cy 圆心y\n * @return path 路径\n * @reference http://gitlab.alipay-inc.com/datavis/g6/blob/1.2.0/src/graph/utils/path.js#L135\n */\nfunction getWaterWavePath(\n radius: number,\n waterLevel: number,\n waveLength: number,\n phase: number,\n amplitude: number,\n cx: number,\n cy: number\n) {\n const curves = Math.ceil(((2 * radius) / waveLength) * 4) * 4;\n const path = [];\n let _phase = phase;\n\n // map phase to [-Math.PI * 2, 0]\n while (_phase < -Math.PI * 2) {\n _phase += Math.PI * 2;\n }\n while (_phase > 0) {\n _phase -= Math.PI * 2;\n }\n _phase = (_phase / Math.PI / 2) * waveLength;\n\n const left = cx - radius + _phase - radius * 2;\n /**\n * top-left corner as start point\n *\n * draws this point\n * |\n * \\|/\n * ~~~~~~~~\n * | |\n * +------+\n */\n path.push(['M', left, waterLevel]);\n\n /**\n * top wave\n *\n * ~~~~~~~~ <- draws this sine wave\n * | |\n * +------+\n */\n let waveRight = 0;\n for (let c = 0; c < curves; ++c) {\n const stage = c % 4;\n const pos = getWaterWavePositions((c * waveLength) / 4, stage, waveLength, amplitude);\n path.push([\n 'C',\n pos[0][0] + left,\n -pos[0][1] + waterLevel,\n pos[1][0] + left,\n -pos[1][1] + waterLevel,\n pos[2][0] + left,\n -pos[2][1] + waterLevel,\n ]);\n\n if (c === curves - 1) {\n waveRight = pos[2][0];\n }\n }\n\n /**\n * top-right corner\n *\n * ~~~~~~~~\n * 3. draws this line -> | | <- 1. draws this line\n * +------+\n * ^\n * |\n * 2. draws this line\n */\n path.push(['L', waveRight + left, cy + radius]);\n path.push(['L', left, cy + radius]);\n path.push(['Z']);\n // path.push(['L', left, waterLevel]);\n return path;\n}\n\n/**\n * 添加水波\n * @param x 中心x\n * @param y 中心y\n * @param level 水位等级 0~1\n * @param waveCount 水波数\n * @param waveAttrs 色值\n * @param group 图组\n * @param clip 用于剪切的图形\n * @param radius 绘制图形的高度\n * @param waveLength 波的长度\n */\nexport function addWaterWave(\n x: number,\n y: number,\n level: number,\n waveCount: number,\n waveAttrs: ShapeStyle,\n group: IGroup,\n clip: IShape,\n radius: number,\n waveLength: number,\n animation: LiquidOptions['animation']\n) {\n // 盒子属性 颜色 宽高\n const { fill, opacity } = waveAttrs;\n const bbox = clip.getBBox();\n const width = bbox.maxX - bbox.minX;\n const height = bbox.maxY - bbox.minY;\n\n // 循环 waveCount 个数\n for (let idx = 0; idx < waveCount; idx++) {\n const factor = waveCount <= 1 ? 0 : idx / (waveCount - 1);\n\n // 画波\n const wave = group.addShape('path', {\n name: `waterwave-path`,\n attrs: {\n // 波形路径配置\n path: getWaterWavePath(\n radius,\n bbox.minY + height * level,\n waveLength,\n 0,\n width / 32, // 波幅高度\n x,\n y\n ),\n fill,\n opacity: lerp(0.2, 0.9, factor) * opacity,\n },\n });\n\n try {\n // 默认 underfind 开启动画\n if (animation === false) return;\n const matrix = transform([['t', waveLength, 0]]);\n\n wave.stopAnimate();\n wave.animate(\n { matrix },\n {\n duration: lerp(0.5 * DURATION, DURATION, factor),\n repeat: true,\n }\n );\n } catch (e) {\n // TODO off-screen canvas 中动画会找不到 canvas\n console.warn('off-screen group animate error!');\n }\n }\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction pin(x: number, y: number, width: number, height: number) {\n const w = (width * 2) / 3;\n const h = Math.max(w, height);\n const r = w / 2;\n\n // attrs of the upper circle\n const cx = x;\n const cy = r + y - h / 2;\n const theta = Math.asin(r / ((h - r) * 0.85));\n const dy = Math.sin(theta) * r;\n const dx = Math.cos(theta) * r;\n\n // the start point of the path\n const x0 = cx - dx;\n const y0 = cy + dy;\n\n // control point\n const cpX = x;\n const cpY = cy + r / Math.sin(theta);\n\n return `\n M ${x0} ${y0}\n A ${r} ${r} 0 1 1 ${x0 + dx * 2} ${y0}\n Q ${cpX} ${cpY} ${x} ${y + h / 2}\n Q ${cpX} ${cpY} ${x0} ${y0}\n Z \n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction circle(x: number, y: number, width: number, height: number) {\n const rx = width / 2;\n const ry = height / 2;\n return `\n M ${x} ${y - ry} \n a ${rx} ${ry} 0 1 0 0 ${ry * 2}\n a ${rx} ${ry} 0 1 0 0 ${-ry * 2}\n Z\n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction diamond(x: number, y: number, width: number, height: number) {\n const h = height / 2;\n const w = width / 2;\n return `\n M ${x} ${y - h}\n L ${x + w} ${y}\n L ${x} ${y + h}\n L ${x - w} ${y}\n Z\n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction triangle(x: number, y: number, width: number, height: number) {\n const h = height / 2;\n const w = width / 2;\n return `\n M ${x} ${y - h}\n L ${x + w} ${y + h}\n L ${x - w} ${y + h}\n Z\n `;\n}\n\n/**\n *\n * @param x 中心 x\n * @param y 中心 y\n * @param width 外接矩形的宽\n * @param height 外接矩形的高\n */\nfunction rect(x: number, y: number, width: number, height: number) {\n const GOLDEN_SECTION_RATIO = 0.618;\n const h = height / 2;\n const w = (width / 2) * GOLDEN_SECTION_RATIO;\n return `\n M ${x - w} ${y - h}\n L ${x + w} ${y - h}\n L ${x + w} ${y + h}\n L ${x - w} ${y + h}\n Z\n `;\n}\n\nconst builtInShapeByName = {\n pin,\n circle,\n diamond,\n triangle,\n rect,\n};\n\nregisterShape('interval', 'liquid-fill-gauge', {\n draw(cfg: any, container: IGroup) {\n const cx = 0.5;\n const cy = 0.5;\n\n const { customInfo } = cfg;\n const { radius: radio, shape, background, animation } = customInfo as CustomInfo;\n const outline: LiquidOptions['outline'] = customInfo.outline;\n const wave: LiquidOptions['wave'] = customInfo.wave;\n const { border, distance } = outline;\n const { count: waveCount, length: waveLength } = wave;\n\n // 获取最小 minX\n const minX = reduce(\n cfg.points as Point[],\n (r: number, p: Point) => {\n return Math.min(r, p.x);\n },\n Infinity\n );\n\n const center = this.parsePoint({ x: cx, y: cy });\n const minXPoint = this.parsePoint({ x: minX, y: cy });\n const halfWidth = center.x - minXPoint.x;\n\n // 保证半径是 画布宽高最小值的 radius 值\n const radius = Math.min(halfWidth, minXPoint.y * radio);\n const waveAttrs = getFillAttrs(cfg);\n const outlineAttrs = getLineAttrs(mix({}, cfg, outline));\n const innerRadius = radius - border / 2;\n\n const buildPath = typeof shape === 'function' ? shape : builtInShapeByName[shape] || builtInShapeByName['circle'];\n const shapePath = buildPath(center.x, center.y, innerRadius * 2, innerRadius * 2);\n\n // 1. 绘制一个波\n const waves = container.addGroup({\n name: 'waves',\n });\n\n // 3. 波对应的 clip 裁剪形状\n const clipPath = waves.setClip({\n type: 'path',\n attrs: {\n path: shapePath,\n },\n });\n\n // 4. 绘制波形\n addWaterWave(\n center.x,\n center.y,\n 1 - (cfg.points[1] as Point).y,\n waveCount,\n waveAttrs,\n waves,\n clipPath,\n radius * 2,\n waveLength,\n animation\n );\n\n // 2. 绘制一个 distance 宽的 border\n container.addShape('path', {\n name: 'distance',\n attrs: {\n path: shapePath,\n fill: 'transparent',\n lineWidth: border + distance * 2,\n stroke: background === 'transparent' ? '#fff' : background,\n },\n });\n\n // 3. 绘制一个 border 宽的 border\n container.addShape('path', {\n name: 'wrap',\n attrs: mix(outlineAttrs, {\n path: shapePath,\n fill: 'transparent',\n lineWidth: border,\n }),\n });\n\n return container;\n },\n});\n"]}
|