@antv/g2plot 2.3.39 → 2.4.2
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 +64 -0
- package/README.en-US.md +0 -1
- package/README.md +0 -1
- package/dist/g2plot.min.js +18 -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/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 +8 -11
- package/esm/plots/line/interactions/marker-active.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/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 +8 -11
- package/lib/plots/line/interactions/marker-active.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/lib/utils/geometry.js +2 -1
- package/lib/utils/geometry.js.map +1 -1
- package/package.json +8 -7
- 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 +9 -12
- 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/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
|
@@ -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/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"]}
|