@antv/g2plot 2.3.40 → 2.4.3
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 +54 -0
- package/README.en-US.md +0 -1
- package/README.md +0 -1
- package/dist/g2plot.min.js +4 -4
- package/dist/g2plot.min.js.map +1 -1
- package/esm/adaptor/conversion-tag.js +3 -3
- package/esm/adaptor/conversion-tag.js.map +1 -1
- package/esm/index.d.ts +9 -1
- package/esm/index.js +9 -1
- package/esm/index.js.map +1 -1
- package/esm/plots/area/adaptor.js +15 -5
- package/esm/plots/area/adaptor.js.map +1 -1
- package/esm/plots/area/constants.d.ts +2 -0
- package/esm/plots/area/constants.js +2 -0
- package/esm/plots/area/constants.js.map +1 -1
- package/esm/plots/area/index.js +11 -4
- package/esm/plots/area/index.js.map +1 -1
- package/esm/plots/bar/adaptor.d.ts +7 -2
- package/esm/plots/bar/adaptor.js +67 -25
- package/esm/plots/bar/adaptor.js.map +1 -1
- package/esm/plots/bar/index.js +1 -2
- package/esm/plots/bar/index.js.map +1 -1
- package/esm/plots/line/adaptor.js +30 -15
- package/esm/plots/line/adaptor.js.map +1 -1
- package/esm/plots/line/constants.d.ts +2 -0
- package/esm/plots/line/constants.js +3 -0
- package/esm/plots/line/constants.js.map +1 -1
- package/esm/plots/line/index.js +8 -1
- package/esm/plots/line/index.js.map +1 -1
- package/esm/plots/line/interactions/marker-active.js +7 -6
- package/esm/plots/line/interactions/marker-active.js.map +1 -1
- package/esm/plots/sunburst/adaptor.js +1 -11
- package/esm/plots/sunburst/adaptor.js.map +1 -1
- package/esm/plots/sunburst/constant.js +1 -0
- package/esm/plots/sunburst/constant.js.map +1 -1
- package/esm/plots/sunburst/types.d.ts +1 -1
- package/esm/plots/sunburst/types.js.map +1 -1
- package/esm/plots/venn/types.d.ts +1 -1
- package/esm/plots/venn/types.js.map +1 -1
- package/esm/utils/data.js +2 -0
- package/esm/utils/data.js.map +1 -1
- package/esm/utils/geometry.js +2 -1
- package/esm/utils/geometry.js.map +1 -1
- package/lib/adaptor/conversion-tag.js +3 -3
- package/lib/adaptor/conversion-tag.js.map +1 -1
- package/lib/index.d.ts +9 -1
- package/lib/index.js +13 -5
- package/lib/index.js.map +1 -1
- package/lib/plots/area/adaptor.js +13 -3
- package/lib/plots/area/adaptor.js.map +1 -1
- package/lib/plots/area/constants.d.ts +2 -0
- package/lib/plots/area/constants.js +3 -1
- package/lib/plots/area/constants.js.map +1 -1
- package/lib/plots/area/index.js +10 -3
- package/lib/plots/area/index.js.map +1 -1
- package/lib/plots/bar/adaptor.d.ts +7 -2
- package/lib/plots/bar/adaptor.js +69 -26
- package/lib/plots/bar/adaptor.js.map +1 -1
- package/lib/plots/bar/index.js +1 -2
- package/lib/plots/bar/index.js.map +1 -1
- package/lib/plots/line/adaptor.js +29 -14
- package/lib/plots/line/adaptor.js.map +1 -1
- package/lib/plots/line/constants.d.ts +2 -0
- package/lib/plots/line/constants.js +4 -1
- package/lib/plots/line/constants.js.map +1 -1
- package/lib/plots/line/index.js +7 -0
- package/lib/plots/line/index.js.map +1 -1
- package/lib/plots/line/interactions/marker-active.js +7 -6
- package/lib/plots/line/interactions/marker-active.js.map +1 -1
- package/lib/plots/sunburst/adaptor.js +1 -11
- package/lib/plots/sunburst/adaptor.js.map +1 -1
- package/lib/plots/sunburst/constant.js +1 -0
- package/lib/plots/sunburst/constant.js.map +1 -1
- package/lib/plots/sunburst/types.d.ts +1 -1
- package/lib/plots/sunburst/types.js.map +1 -1
- package/lib/plots/venn/types.d.ts +1 -1
- package/lib/plots/venn/types.js.map +1 -1
- package/lib/utils/data.js +2 -0
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/geometry.js +2 -1
- package/lib/utils/geometry.js.map +1 -1
- package/package.json +6 -5
- package/src/adaptor/conversion-tag.ts +3 -3
- package/src/index.ts +9 -1
- package/src/plots/area/adaptor.ts +16 -5
- package/src/plots/area/constants.ts +3 -0
- package/src/plots/area/index.ts +10 -3
- package/src/plots/bar/adaptor.ts +94 -47
- package/src/plots/bar/index.ts +1 -2
- package/src/plots/line/adaptor.ts +35 -14
- package/src/plots/line/constants.ts +4 -0
- package/src/plots/line/index.ts +8 -1
- package/src/plots/line/interactions/marker-active.ts +8 -7
- package/src/plots/sunburst/adaptor.ts +9 -13
- package/src/plots/sunburst/constant.ts +1 -0
- package/src/plots/sunburst/types.ts +1 -1
- package/src/plots/venn/types.ts +1 -1
- package/src/utils/data.ts +1 -0
- package/src/utils/geometry.ts +2 -1
- package/esm/plots/bar/utils.d.ts +0 -6
- package/esm/plots/bar/utils.js +0 -8
- package/esm/plots/bar/utils.js.map +0 -1
- package/lib/plots/bar/utils.d.ts +0 -6
- package/lib/plots/bar/utils.js +0 -12
- package/lib/plots/bar/utils.js.map +0 -1
- package/src/plots/bar/utils.ts +0 -9
package/src/plots/bar/adaptor.ts
CHANGED
|
@@ -1,31 +1,62 @@
|
|
|
1
1
|
import { Params } from '../../core/adaptor';
|
|
2
|
+
import { tooltip } from '../../adaptor/common';
|
|
3
|
+
import { deepAssign, flow } from '../../utils';
|
|
4
|
+
import { Axis } from '../../types';
|
|
2
5
|
import { adaptor as columnAdaptor } from '../column/adaptor';
|
|
6
|
+
export { meta } from '../column/adaptor';
|
|
3
7
|
import { BarOptions } from './types';
|
|
4
|
-
import { transformBarData } from './utils';
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
/**
|
|
10
|
+
* 处理默认配置项
|
|
11
|
+
* 1. switch xField、 yField
|
|
12
|
+
* 2. switch xAxis、 yAxis and adjust axis.position configuration
|
|
13
|
+
*/
|
|
14
|
+
function defaultOptions(params: Params<BarOptions>): Params<BarOptions> {
|
|
15
|
+
const { options } = params;
|
|
16
|
+
const { xField, yField, xAxis, yAxis } = options;
|
|
17
|
+
|
|
18
|
+
const position = {
|
|
19
|
+
left: 'bottom',
|
|
20
|
+
right: 'top',
|
|
21
|
+
top: 'left',
|
|
22
|
+
bottom: 'right',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const verticalAxis =
|
|
26
|
+
yAxis !== false
|
|
27
|
+
? {
|
|
28
|
+
position: position[yAxis?.position || 'left'],
|
|
29
|
+
...yAxis,
|
|
30
|
+
}
|
|
31
|
+
: false;
|
|
32
|
+
const horizontalAxis =
|
|
33
|
+
xAxis !== false
|
|
34
|
+
? {
|
|
35
|
+
position: position[xAxis?.position || 'bottom'],
|
|
36
|
+
...xAxis,
|
|
37
|
+
}
|
|
38
|
+
: false;
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...params,
|
|
42
|
+
options: {
|
|
43
|
+
...options,
|
|
44
|
+
xField: yField,
|
|
45
|
+
yField: xField,
|
|
46
|
+
// 条形图 xAxis,yAxis 不可以做 deepAssign
|
|
47
|
+
xAxis: verticalAxis as Axis,
|
|
48
|
+
yAxis: horizontalAxis as Axis,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
7
52
|
|
|
8
53
|
/**
|
|
9
|
-
*
|
|
54
|
+
* label 适配器
|
|
10
55
|
* @param params
|
|
11
56
|
*/
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
const {
|
|
15
|
-
xField,
|
|
16
|
-
yField,
|
|
17
|
-
xAxis,
|
|
18
|
-
yAxis,
|
|
19
|
-
barStyle,
|
|
20
|
-
barWidthRatio,
|
|
21
|
-
label,
|
|
22
|
-
data,
|
|
23
|
-
seriesField,
|
|
24
|
-
isStack,
|
|
25
|
-
minBarWidth,
|
|
26
|
-
maxBarWidth,
|
|
27
|
-
} = options;
|
|
28
|
-
|
|
57
|
+
function label(params: Params<BarOptions>): Params<BarOptions> {
|
|
58
|
+
const { options } = params;
|
|
59
|
+
const { label } = options;
|
|
29
60
|
// label of bar charts default position is left, if plot has label
|
|
30
61
|
if (label && !label.position) {
|
|
31
62
|
label.position = 'left';
|
|
@@ -40,59 +71,75 @@ export function adaptor(params: Params<BarOptions>) {
|
|
|
40
71
|
}
|
|
41
72
|
}
|
|
42
73
|
|
|
74
|
+
return deepAssign({}, params, { options: { label } });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* legend 适配器
|
|
79
|
+
* @param params
|
|
80
|
+
*/
|
|
81
|
+
function legend(params: Params<BarOptions>): Params<BarOptions> {
|
|
82
|
+
const { options } = params;
|
|
83
|
+
|
|
43
84
|
// 默认 legend 位置
|
|
85
|
+
const { seriesField, isStack } = options;
|
|
44
86
|
let { legend } = options;
|
|
45
87
|
if (seriesField) {
|
|
46
88
|
if (legend !== false) {
|
|
47
89
|
legend = {
|
|
48
90
|
position: isStack ? 'top-left' : 'right-top',
|
|
49
|
-
reversed: isStack ? false : true,
|
|
50
91
|
...(legend || {}),
|
|
51
92
|
};
|
|
52
93
|
}
|
|
53
94
|
} else {
|
|
54
95
|
legend = false;
|
|
55
96
|
}
|
|
56
|
-
// @ts-ignore 直接改值
|
|
57
|
-
params.options.legend = legend;
|
|
58
97
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (seriesField) {
|
|
62
|
-
if (tooltip !== false) {
|
|
63
|
-
tooltip = {
|
|
64
|
-
reversed: isStack ? false : true,
|
|
65
|
-
...(tooltip || {}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// @ts-ignore 直接改值
|
|
70
|
-
params.options.tooltip = tooltip;
|
|
98
|
+
return deepAssign({}, params, { options: { legend } });
|
|
99
|
+
}
|
|
71
100
|
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
/**
|
|
102
|
+
* coordinate 适配器
|
|
103
|
+
* @param params
|
|
104
|
+
*/
|
|
105
|
+
function coordinate(params: Params<BarOptions>): Params<BarOptions> {
|
|
106
|
+
const { chart } = params;
|
|
107
|
+
// transpose column to bar 对角变换 & y 方向镜像变换
|
|
108
|
+
chart.coordinate({ actions: [['transpose'], ['reflect', 'y']] });
|
|
109
|
+
return params;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 柱形图适配器
|
|
114
|
+
* @param params
|
|
115
|
+
*/
|
|
116
|
+
export function geometry(params: Params<BarOptions>) {
|
|
117
|
+
const { chart, options } = params;
|
|
118
|
+
|
|
119
|
+
const { barStyle, barWidthRatio, minBarWidth, maxBarWidth, barBackground } = options;
|
|
74
120
|
|
|
75
121
|
return columnAdaptor(
|
|
76
122
|
{
|
|
77
123
|
chart,
|
|
78
124
|
options: {
|
|
79
125
|
...options,
|
|
80
|
-
label,
|
|
81
|
-
// switch xField and yField
|
|
82
|
-
xField: yField,
|
|
83
|
-
yField: xField,
|
|
84
|
-
xAxis: yAxis,
|
|
85
|
-
yAxis: xAxis,
|
|
86
126
|
// rename attrs as column
|
|
87
127
|
columnStyle: barStyle,
|
|
88
128
|
columnWidthRatio: barWidthRatio,
|
|
89
129
|
minColumnWidth: minBarWidth,
|
|
90
130
|
maxColumnWidth: maxBarWidth,
|
|
91
|
-
columnBackground:
|
|
92
|
-
// bar 调整数据顺序
|
|
93
|
-
data: transformBarData(data),
|
|
131
|
+
columnBackground: barBackground,
|
|
94
132
|
},
|
|
95
133
|
},
|
|
96
134
|
true
|
|
97
|
-
)
|
|
135
|
+
) as Params<BarOptions>;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @param chart
|
|
140
|
+
* @param options
|
|
141
|
+
*/
|
|
142
|
+
export function adaptor(params: Params<BarOptions>): Params<BarOptions> {
|
|
143
|
+
// flow 的方式处理所有的配置到 G2 API
|
|
144
|
+
return flow<Params<BarOptions>>(defaultOptions, label, legend, tooltip, coordinate, geometry)(params);
|
|
98
145
|
}
|
package/src/plots/bar/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { getDataWhetherPecentage } from '../../utils/transform/percent';
|
|
|
4
4
|
import { BarOptions } from './types';
|
|
5
5
|
import { adaptor, meta } from './adaptor';
|
|
6
6
|
import { DEFAULT_OPTIONS } from './constants';
|
|
7
|
-
import { transformBarData } from './utils';
|
|
8
7
|
|
|
9
8
|
export type { BarOptions };
|
|
10
9
|
|
|
@@ -32,7 +31,7 @@ export class Bar extends Plot<BarOptions> {
|
|
|
32
31
|
const { xField, yField, isPercent } = options;
|
|
33
32
|
const switchedFieldOptions = { ...options, xField: yField, yField: xField };
|
|
34
33
|
meta({ chart, options: switchedFieldOptions });
|
|
35
|
-
chart.changeData(getDataWhetherPecentage(
|
|
34
|
+
chart.changeData(getDataWhetherPecentage(data, xField, yField, xField, isPercent));
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
/**
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Geometry } from '@antv/g2';
|
|
2
|
-
import { each, isArray } from '@antv/util';
|
|
2
|
+
import { each, isArray, isNil, uniq } from '@antv/util';
|
|
3
3
|
import { Params } from '../../core/adaptor';
|
|
4
4
|
import { tooltip, slider, interaction, animation, theme, scale, annotation, limitInPlot } from '../../adaptor/common';
|
|
5
|
-
import { findGeometry, transformLabel, deepAssign } from '../../utils';
|
|
5
|
+
import { flow, findGeometry, transformLabel, deepAssign, getAllGeometriesRecursively } from '../../utils';
|
|
6
6
|
import { point, line, area } from '../../adaptor/geometries';
|
|
7
|
-
import { flow } from '../../utils';
|
|
8
7
|
import { adjustYMetaByZero } from '../../utils/data';
|
|
8
|
+
import { POINT_VIEW_ID } from './constants';
|
|
9
9
|
import { LineOptions } from './types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -14,7 +14,7 @@ import { LineOptions } from './types';
|
|
|
14
14
|
*/
|
|
15
15
|
function geometry(params: Params<LineOptions>): Params<LineOptions> {
|
|
16
16
|
const { chart, options } = params;
|
|
17
|
-
const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, seriesField } = options;
|
|
17
|
+
const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, yField, seriesField } = options;
|
|
18
18
|
const pointState = pointMapping?.state;
|
|
19
19
|
|
|
20
20
|
chart.data(data);
|
|
@@ -44,13 +44,23 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
|
|
|
44
44
|
label: undefined,
|
|
45
45
|
},
|
|
46
46
|
});
|
|
47
|
-
|
|
47
|
+
|
|
48
48
|
const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
49
49
|
|
|
50
50
|
line(primary);
|
|
51
|
-
point(second);
|
|
52
51
|
area(areaParams);
|
|
53
52
|
|
|
53
|
+
const pointParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
54
|
+
if (pointMapping) {
|
|
55
|
+
const pointView = chart.createView({ id: POINT_VIEW_ID });
|
|
56
|
+
pointView.axis(false);
|
|
57
|
+
pointView.tooltip(false);
|
|
58
|
+
pointView.legend(false);
|
|
59
|
+
// [PERFORMANCE] 🚀 数据为空的 point 标注点都不渲染(不包括:数据为 0)
|
|
60
|
+
pointView.data(data.filter((d) => !isNil(d[yField])));
|
|
61
|
+
point({ ...pointParams, chart: pointView });
|
|
62
|
+
}
|
|
63
|
+
|
|
54
64
|
return params;
|
|
55
65
|
}
|
|
56
66
|
|
|
@@ -60,7 +70,21 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
|
|
|
60
70
|
*/
|
|
61
71
|
export function meta(params: Params<LineOptions>): Params<LineOptions> {
|
|
62
72
|
const { options } = params;
|
|
63
|
-
const { xAxis, yAxis, xField, yField, data } = options;
|
|
73
|
+
const { xAxis, yAxis, xField, yField, data, seriesField } = options;
|
|
74
|
+
const defaultMeta = {
|
|
75
|
+
[xField]: {
|
|
76
|
+
type: 'cat',
|
|
77
|
+
sync: true,
|
|
78
|
+
values: uniq(data.map((d) => d[xField])),
|
|
79
|
+
},
|
|
80
|
+
[yField]: {
|
|
81
|
+
...adjustYMetaByZero(data, yField),
|
|
82
|
+
sync: true,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
if (seriesField) {
|
|
86
|
+
defaultMeta[seriesField] = { sync: true };
|
|
87
|
+
}
|
|
64
88
|
|
|
65
89
|
return flow(
|
|
66
90
|
scale(
|
|
@@ -68,12 +92,7 @@ export function meta(params: Params<LineOptions>): Params<LineOptions> {
|
|
|
68
92
|
[xField]: xAxis,
|
|
69
93
|
[yField]: yAxis,
|
|
70
94
|
},
|
|
71
|
-
|
|
72
|
-
[xField]: {
|
|
73
|
-
type: 'cat',
|
|
74
|
-
},
|
|
75
|
-
[yField]: adjustYMetaByZero(data, yField),
|
|
76
|
-
}
|
|
95
|
+
defaultMeta
|
|
77
96
|
)
|
|
78
97
|
)(params);
|
|
79
98
|
}
|
|
@@ -180,8 +199,10 @@ export function adjust(params: Params<Pick<LineOptions, 'isStack'>>): Params<any
|
|
|
180
199
|
const { chart, options } = params;
|
|
181
200
|
const { isStack } = options;
|
|
182
201
|
|
|
202
|
+
const geometries = getAllGeometriesRecursively(chart);
|
|
203
|
+
|
|
183
204
|
if (isStack) {
|
|
184
|
-
each(
|
|
205
|
+
each(geometries, (g: Geometry) => {
|
|
185
206
|
g.adjust('stack');
|
|
186
207
|
});
|
|
187
208
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Plot } from '../../core/plot';
|
|
2
2
|
import { deepAssign } from '../../utils';
|
|
3
3
|
|
|
4
|
+
/** point 标注点视图 */
|
|
5
|
+
export const POINT_VIEW_ID = 'point-view';
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* 折线图默认配置项
|
|
6
9
|
*/
|
|
7
10
|
export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
|
|
11
|
+
syncViewPadding: true,
|
|
8
12
|
tooltip: {
|
|
9
13
|
shared: true,
|
|
10
14
|
showMarkers: true,
|
package/src/plots/line/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { isNil } from '@antv/util';
|
|
1
2
|
import { Plot } from '../../core/plot';
|
|
2
3
|
import { Adaptor } from '../../core/adaptor';
|
|
4
|
+
import { findViewById } from '../../utils';
|
|
3
5
|
import { LineOptions } from './types';
|
|
4
6
|
import { adaptor, meta } from './adaptor';
|
|
5
|
-
import { DEFAULT_OPTIONS } from './constants';
|
|
7
|
+
import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
|
|
6
8
|
import './interactions';
|
|
7
9
|
|
|
8
10
|
export type { LineOptions };
|
|
@@ -26,8 +28,13 @@ export class Line extends Plot<LineOptions> {
|
|
|
26
28
|
public changeData(data: LineOptions['data']) {
|
|
27
29
|
this.updateOption({ data });
|
|
28
30
|
const { chart, options } = this;
|
|
31
|
+
const { yField } = options;
|
|
29
32
|
meta({ chart, options });
|
|
30
33
|
this.chart.changeData(data);
|
|
34
|
+
const pointView = findViewById(this.chart, POINT_VIEW_ID);
|
|
35
|
+
if (pointView) {
|
|
36
|
+
pointView.changeData(data.filter((d) => !isNil(d[yField])));
|
|
37
|
+
}
|
|
31
38
|
}
|
|
32
39
|
|
|
33
40
|
/**
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { each, findIndex } from '@antv/util';
|
|
2
|
-
import { InteractionAction, View
|
|
2
|
+
import { InteractionAction, View } from '@antv/g2';
|
|
3
|
+
import { findGeometry } from '../../../utils';
|
|
3
4
|
|
|
4
5
|
export class MarkerActiveAction extends InteractionAction {
|
|
5
6
|
public active() {
|
|
@@ -8,24 +9,24 @@ export class MarkerActiveAction extends InteractionAction {
|
|
|
8
9
|
if (evt.data) {
|
|
9
10
|
// items: 数组对象,当前 tooltip 显示的每条内容
|
|
10
11
|
const { items } = evt.data;
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const point = findGeometry(view, 'point');
|
|
13
|
+
if (point) {
|
|
13
14
|
each(point.elements, (element) => {
|
|
14
15
|
const active = findIndex(items, (item) => (item as any).data === element.data) !== -1;
|
|
15
16
|
element.setState('active', active);
|
|
16
17
|
});
|
|
17
|
-
}
|
|
18
|
+
}
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
public reset() {
|
|
22
23
|
const view = this.getView();
|
|
23
|
-
const
|
|
24
|
-
|
|
24
|
+
const point = findGeometry(view, 'point');
|
|
25
|
+
if (point) {
|
|
25
26
|
each(point.elements, (element) => {
|
|
26
27
|
element.setState('active', false);
|
|
27
28
|
});
|
|
28
|
-
}
|
|
29
|
+
}
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
private getView(): View {
|
|
@@ -2,7 +2,15 @@ import { isFunction, get, uniq } from '@antv/util';
|
|
|
2
2
|
import { Types } from '@antv/g2';
|
|
3
3
|
import { Params } from '../../core/adaptor';
|
|
4
4
|
import { polygon as polygonAdaptor } from '../../adaptor/geometries';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
interaction as baseInteraction,
|
|
7
|
+
animation,
|
|
8
|
+
theme,
|
|
9
|
+
annotation,
|
|
10
|
+
scale,
|
|
11
|
+
pattern,
|
|
12
|
+
legend,
|
|
13
|
+
} from '../../adaptor/common';
|
|
6
14
|
import { flow, findGeometry, transformLabel, deepAssign } from '../../utils';
|
|
7
15
|
import { getAdjustAppendPadding } from '../../utils/padding';
|
|
8
16
|
import { Datum } from '../../types';
|
|
@@ -63,18 +71,6 @@ export function axis(params: Params<SunburstOptions>): Params<SunburstOptions> {
|
|
|
63
71
|
return params;
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
/**
|
|
67
|
-
* legend 配置(旭日图暂时不支持图例,后续需要支持的话,得自定义数据筛选)
|
|
68
|
-
* @param params
|
|
69
|
-
* @returns
|
|
70
|
-
*/
|
|
71
|
-
function legend(params: Params<SunburstOptions>): Params<SunburstOptions> {
|
|
72
|
-
const { chart } = params;
|
|
73
|
-
|
|
74
|
-
chart.legend(false);
|
|
75
|
-
return params;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
74
|
/**
|
|
79
75
|
* 数据标签
|
|
80
76
|
* @param params
|
|
@@ -2,7 +2,7 @@ import { ColorAttr, Options, StyleAttr } from '../../types';
|
|
|
2
2
|
import { DrillDownCfg } from '../../types/drill-down';
|
|
3
3
|
import { HierarchyOption } from '../../utils/hierarchy/types';
|
|
4
4
|
|
|
5
|
-
export interface SunburstOptions extends Omit<Options, 'data' | '
|
|
5
|
+
export interface SunburstOptions extends Omit<Options, 'data' | 'slider' | 'scrollbar' | 'xAxis' | 'yAxis'> {
|
|
6
6
|
/** 旭日图数据 */
|
|
7
7
|
readonly data: any;
|
|
8
8
|
/** 径向类型 */
|
package/src/plots/venn/types.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface VennOptions extends Options {
|
|
|
15
15
|
|
|
16
16
|
// 韦恩图 样式
|
|
17
17
|
/** color */
|
|
18
|
-
readonly color?: string | string[] | ((datum: Datum, defaultColor
|
|
18
|
+
readonly color?: string | string[] | ((datum: Datum, defaultColor?: string) => string);
|
|
19
19
|
/** 并集合的颜色混合方式, 可选项: 参考 https://gka.github.io/chroma.js/#chroma-blend, 默认: multiply */
|
|
20
20
|
readonly blendMode?: string;
|
|
21
21
|
/** point 样式 */
|
package/src/utils/data.ts
CHANGED
package/src/utils/geometry.ts
CHANGED
|
@@ -7,7 +7,8 @@ import { reduce, get } from '@antv/util';
|
|
|
7
7
|
* @param type
|
|
8
8
|
*/
|
|
9
9
|
export function findGeometry(view: View, type: string): Geometry {
|
|
10
|
-
|
|
10
|
+
const geometries = getAllGeometriesRecursively(view);
|
|
11
|
+
return geometries.find((g: Geometry) => g.type === type);
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
/**
|
package/esm/plots/bar/utils.d.ts
DELETED
package/esm/plots/bar/utils.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/bar/utils.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAwB;IACvD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC","sourcesContent":["import { BarOptions } from '.';\n\n/**\n * 条形图数据需要进行反转\n * @param data\n */\nexport function transformBarData(data: BarOptions['data']): BarOptions['data'] {\n return data ? data.slice().reverse() : data;\n}\n"]}
|
package/lib/plots/bar/utils.d.ts
DELETED
package/lib/plots/bar/utils.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformBarData = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* 条形图数据需要进行反转
|
|
6
|
-
* @param data
|
|
7
|
-
*/
|
|
8
|
-
function transformBarData(data) {
|
|
9
|
-
return data ? data.slice().reverse() : data;
|
|
10
|
-
}
|
|
11
|
-
exports.transformBarData = transformBarData;
|
|
12
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/plots/bar/utils.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,SAAgB,gBAAgB,CAAC,IAAwB;IACvD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AAC9C,CAAC;AAFD,4CAEC","sourcesContent":["import { BarOptions } from '.';\n\n/**\n * 条形图数据需要进行反转\n * @param data\n */\nexport function transformBarData(data: BarOptions['data']): BarOptions['data'] {\n return data ? data.slice().reverse() : data;\n}\n"]}
|