@antv/g2plot 2.3.38 → 2.4.1
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 +60 -0
- package/README.en-US.md +0 -1
- package/README.md +0 -1
- package/dist/g2plot.min.js +3 -3
- 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/adaptor/geometries/base.d.ts +2 -0
- package/esm/adaptor/geometries/base.js +7 -1
- package/esm/adaptor/geometries/base.js.map +1 -1
- package/esm/adaptor/geometries/index.d.ts +1 -0
- package/esm/adaptor/geometries/index.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/plots/area/adaptor.js +2 -2
- package/esm/plots/area/adaptor.js.map +1 -1
- package/esm/plots/area/types.d.ts +2 -3
- package/esm/plots/area/types.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 +6 -2
- package/esm/plots/line/adaptor.js.map +1 -1
- package/esm/plots/line/types.d.ts +5 -2
- package/esm/plots/line/types.js.map +1 -1
- package/esm/plots/sankey/helper.js +16 -2
- package/esm/plots/sankey/helper.js.map +1 -1
- package/esm/plots/sankey/types.d.ts +51 -8
- package/esm/plots/sankey/types.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/lib/adaptor/conversion-tag.js +3 -3
- package/lib/adaptor/conversion-tag.js.map +1 -1
- package/lib/adaptor/geometries/base.d.ts +2 -0
- package/lib/adaptor/geometries/base.js +7 -1
- package/lib/adaptor/geometries/base.js.map +1 -1
- package/lib/adaptor/geometries/index.d.ts +1 -0
- package/lib/adaptor/geometries/index.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/plots/area/adaptor.js +2 -2
- package/lib/plots/area/adaptor.js.map +1 -1
- package/lib/plots/area/types.d.ts +2 -3
- package/lib/plots/area/types.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 +5 -1
- package/lib/plots/line/adaptor.js.map +1 -1
- package/lib/plots/line/types.d.ts +5 -2
- package/lib/plots/line/types.js.map +1 -1
- package/lib/plots/sankey/helper.js +16 -2
- package/lib/plots/sankey/helper.js.map +1 -1
- package/lib/plots/sankey/types.d.ts +51 -8
- package/lib/plots/sankey/types.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/package.json +8 -7
- package/src/adaptor/conversion-tag.ts +3 -3
- package/src/adaptor/geometries/base.ts +23 -2
- package/src/adaptor/geometries/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/plots/area/adaptor.ts +2 -2
- package/src/plots/area/types.ts +2 -3
- package/src/plots/bar/adaptor.ts +94 -47
- package/src/plots/bar/index.ts +1 -2
- package/src/plots/line/adaptor.ts +9 -2
- package/src/plots/line/types.ts +11 -3
- package/src/plots/sankey/helper.ts +26 -9
- package/src/plots/sankey/types.ts +52 -8
- 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/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
|
/**
|
|
@@ -3,7 +3,7 @@ import { each, isArray } 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
5
|
import { findGeometry, transformLabel, deepAssign } from '../../utils';
|
|
6
|
-
import { point, line } from '../../adaptor/geometries';
|
|
6
|
+
import { point, line, area } from '../../adaptor/geometries';
|
|
7
7
|
import { flow } from '../../utils';
|
|
8
8
|
import { adjustYMetaByZero } from '../../utils/data';
|
|
9
9
|
import { LineOptions } from './types';
|
|
@@ -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, seriesField } = options;
|
|
17
|
+
const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, seriesField } = options;
|
|
18
18
|
const pointState = pointMapping?.state;
|
|
19
19
|
|
|
20
20
|
chart.data(data);
|
|
@@ -35,14 +35,21 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
|
|
|
35
35
|
shape: 'circle',
|
|
36
36
|
...pointMapping,
|
|
37
37
|
},
|
|
38
|
+
// 面积配置
|
|
39
|
+
area: areaMapping && {
|
|
40
|
+
color,
|
|
41
|
+
...areaMapping,
|
|
42
|
+
},
|
|
38
43
|
// label 不传递给各个 geometry adaptor,由 label adaptor 处理
|
|
39
44
|
label: undefined,
|
|
40
45
|
},
|
|
41
46
|
});
|
|
42
47
|
const second = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
48
|
+
const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
|
|
43
49
|
|
|
44
50
|
line(primary);
|
|
45
51
|
point(second);
|
|
52
|
+
area(areaParams);
|
|
46
53
|
|
|
47
54
|
return params;
|
|
48
55
|
}
|
package/src/plots/line/types.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
GeometryOptions,
|
|
3
|
+
AreaGeometryOptions,
|
|
4
|
+
LineGeometryOptions,
|
|
5
|
+
PointGeometryOptions,
|
|
6
|
+
} from '../../adaptor/geometries';
|
|
2
7
|
import { Options, StyleAttr } from '../../types';
|
|
3
8
|
|
|
4
|
-
export interface LineOptions extends Options {
|
|
9
|
+
export interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'> {
|
|
5
10
|
/** 阶梯折线图类型 */
|
|
6
11
|
readonly stepType?: string;
|
|
7
12
|
/** x 轴字段 */
|
|
@@ -22,7 +27,10 @@ export interface LineOptions extends Options {
|
|
|
22
27
|
readonly lineShape?: Required<LineGeometryOptions>['line']['shape'];
|
|
23
28
|
/** 折线数据点:1、图形映射属性 2、状态样式 */
|
|
24
29
|
readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
|
|
30
|
+
/** 折线趋势填充色:1、图形映射属性 */
|
|
31
|
+
readonly area?: AreaGeometryOptions['area'];
|
|
25
32
|
|
|
26
|
-
//
|
|
33
|
+
// 其他
|
|
34
|
+
/** 坐标轴反转配置 */
|
|
27
35
|
readonly reflect?: 'x' | 'y' | ['x', 'y'];
|
|
28
36
|
}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import { isRealNumber, pick } from '../../utils';
|
|
2
2
|
import { transformDataToNodeLinkData } from '../../utils/data';
|
|
3
|
-
import {
|
|
3
|
+
import { Data } from '../../types';
|
|
4
|
+
import { sankeyLayout, SankeyLayoutInputData } from './layout';
|
|
4
5
|
import { cutoffCircle } from './circle';
|
|
5
6
|
import { SankeyOptions } from './types';
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* 是否是 node-link 类型的数据结构
|
|
10
|
+
* @param dataTyp
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
function isNodeLink(dataType: string) {
|
|
14
|
+
return dataType === 'node-link';
|
|
15
|
+
}
|
|
16
|
+
|
|
7
17
|
export function getNodeWidthRatio(nodeWidth: number, nodeWidthRatio: number, width: number) {
|
|
8
18
|
return isRealNumber(nodeWidth) ? nodeWidth / width : nodeWidthRatio;
|
|
9
19
|
}
|
|
@@ -20,6 +30,7 @@ export function getNodePaddingRatio(nodePadding: number, nodePaddingRatio: numbe
|
|
|
20
30
|
*/
|
|
21
31
|
export function transformToViewsData(options: SankeyOptions, width: number, height: number) {
|
|
22
32
|
const {
|
|
33
|
+
dataType,
|
|
23
34
|
data,
|
|
24
35
|
sourceField,
|
|
25
36
|
targetField,
|
|
@@ -34,13 +45,19 @@ export function transformToViewsData(options: SankeyOptions, width: number, heig
|
|
|
34
45
|
rawFields = [],
|
|
35
46
|
} = options;
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
let sankeyLayoutInputData: unknown;
|
|
49
|
+
|
|
50
|
+
if (!isNodeLink(dataType)) {
|
|
51
|
+
sankeyLayoutInputData = transformDataToNodeLinkData(
|
|
52
|
+
cutoffCircle(data as Data, sourceField, targetField),
|
|
53
|
+
sourceField,
|
|
54
|
+
targetField,
|
|
55
|
+
weightField,
|
|
56
|
+
rawFields
|
|
57
|
+
);
|
|
58
|
+
} else {
|
|
59
|
+
sankeyLayoutInputData = data;
|
|
60
|
+
}
|
|
44
61
|
|
|
45
62
|
// 3. layout 之后的数据
|
|
46
63
|
const { nodes, links } = sankeyLayout(
|
|
@@ -51,7 +68,7 @@ export function transformToViewsData(options: SankeyOptions, width: number, heig
|
|
|
51
68
|
nodeSort,
|
|
52
69
|
nodeDepth,
|
|
53
70
|
},
|
|
54
|
-
sankeyLayoutInputData
|
|
71
|
+
sankeyLayoutInputData as SankeyLayoutInputData
|
|
55
72
|
);
|
|
56
73
|
|
|
57
74
|
// 4. 生成绘图数据
|
|
@@ -1,20 +1,64 @@
|
|
|
1
1
|
import { Data, Options, State, StyleAttr } from '../../types';
|
|
2
2
|
import { NodeDepth, NodeSort } from './layout';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* node-link 数据类型的结构
|
|
6
|
+
*/
|
|
7
|
+
export type NodeLinkData = {
|
|
8
|
+
/**
|
|
9
|
+
* 节点数据
|
|
10
|
+
*/
|
|
11
|
+
readonly nodes: {
|
|
12
|
+
/**
|
|
13
|
+
* id 唯一即可,一般可以直接等于 name
|
|
14
|
+
*/
|
|
15
|
+
readonly id: string;
|
|
16
|
+
/**
|
|
17
|
+
* 节点的名称,用于 UI 上的现实
|
|
18
|
+
*/
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/**
|
|
21
|
+
* 节点的值,不传则节点大小有来源求和决定
|
|
22
|
+
*/
|
|
23
|
+
readonly fixedValue?: number;
|
|
24
|
+
}[];
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
readonly links: {
|
|
29
|
+
/**
|
|
30
|
+
* 来源节点在 nodes 中的 index
|
|
31
|
+
*/
|
|
32
|
+
readonly source: number;
|
|
33
|
+
/**
|
|
34
|
+
* 目标节点在 nodes 中的 index
|
|
35
|
+
*/
|
|
36
|
+
readonly target: number;
|
|
37
|
+
/**
|
|
38
|
+
* 边的值
|
|
39
|
+
*/
|
|
40
|
+
readonly value: number;
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
43
|
+
|
|
4
44
|
/** 配置类型定义 */
|
|
5
|
-
export interface SankeyOptions extends Omit<Options, 'xField' | 'yField' | 'xAxis' | 'yAxis'> {
|
|
45
|
+
export interface SankeyOptions extends Omit<Options, 'data' | 'xField' | 'yField' | 'xAxis' | 'yAxis'> {
|
|
46
|
+
/**
|
|
47
|
+
* 数据集的类型,默认为 detail
|
|
48
|
+
*/
|
|
49
|
+
readonly dataType?: 'node-link' | 'detail';
|
|
6
50
|
/**
|
|
7
|
-
*
|
|
51
|
+
* 来源字段,dataType = 'node-link' 的时候,不用传
|
|
8
52
|
*/
|
|
9
|
-
readonly sourceField
|
|
53
|
+
readonly sourceField?: string;
|
|
10
54
|
/**
|
|
11
|
-
*
|
|
55
|
+
* 去向字段,dataType = 'node-link' 的时候,不用传
|
|
12
56
|
*/
|
|
13
|
-
readonly targetField
|
|
57
|
+
readonly targetField?: string;
|
|
14
58
|
/**
|
|
15
|
-
*
|
|
59
|
+
* 权重字段,dataType = 'node-link' 的时候,不用传
|
|
16
60
|
*/
|
|
17
|
-
readonly weightField
|
|
61
|
+
readonly weightField?: string;
|
|
18
62
|
/**
|
|
19
63
|
* 附加的 元字段
|
|
20
64
|
*/
|
|
@@ -22,7 +66,7 @@ export interface SankeyOptions extends Omit<Options, 'xField' | 'yField' | 'xAxi
|
|
|
22
66
|
/**
|
|
23
67
|
* 数据
|
|
24
68
|
*/
|
|
25
|
-
readonly data: Data;
|
|
69
|
+
readonly data: Data | NodeLinkData;
|
|
26
70
|
/**
|
|
27
71
|
* 节点宽度的比如,参考画布的宽度,默认值为 0.008
|
|
28
72
|
*/
|
|
@@ -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/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"]}
|