@antv/g2plot 2.4.7 → 2.4.8
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 +26 -0
- package/dist/g2plot.min.js +3 -3
- package/dist/g2plot.min.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/dual-axes/util/render-sider.js +1 -1
- package/esm/plots/dual-axes/util/render-sider.js.map +1 -1
- package/esm/plots/sankey/adaptor.js +31 -2
- package/esm/plots/sankey/adaptor.js.map +1 -1
- package/esm/plots/sankey/types.d.ts +8 -0
- package/esm/plots/sankey/types.js.map +1 -1
- package/esm/utils/transform/percent.js +2 -2
- package/esm/utils/transform/percent.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/dual-axes/util/render-sider.js +1 -1
- package/lib/plots/dual-axes/util/render-sider.js.map +1 -1
- package/lib/plots/sankey/adaptor.js +30 -1
- package/lib/plots/sankey/adaptor.js.map +1 -1
- package/lib/plots/sankey/types.d.ts +8 -0
- package/lib/plots/sankey/types.js.map +1 -1
- package/lib/utils/transform/percent.js +2 -2
- package/lib/utils/transform/percent.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/plots/dual-axes/util/render-sider.ts +1 -1
- package/src/plots/sankey/adaptor.ts +35 -2
- package/src/plots/sankey/types.ts +8 -0
- package/src/utils/transform/percent.ts +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uniq } from '@antv/util';
|
|
2
|
-
import {
|
|
2
|
+
import { theme } from '../../adaptor/common';
|
|
3
3
|
import { Params } from '../../core/adaptor';
|
|
4
|
-
import { deepAssign, flow } from '../../utils';
|
|
4
|
+
import { deepAssign, findViewById, flow } from '../../utils';
|
|
5
5
|
import { polygon, edge } from '../../adaptor/geometries';
|
|
6
6
|
import { transformToViewsData } from './helper';
|
|
7
7
|
import { SankeyOptions } from './types';
|
|
@@ -146,6 +146,39 @@ export function nodeDraggable(params: Params<SankeyOptions>): Params<SankeyOptio
|
|
|
146
146
|
return params;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Interaction 配置
|
|
151
|
+
* @param params
|
|
152
|
+
*/
|
|
153
|
+
function interaction(params: Params<SankeyOptions>): Params<SankeyOptions> {
|
|
154
|
+
const { chart, options } = params;
|
|
155
|
+
const { interactions = [] } = options;
|
|
156
|
+
|
|
157
|
+
const nodeInteractions = [].concat(interactions, options.nodeInteractions || []);
|
|
158
|
+
const edgeInteractions = [].concat(interactions, options.edgeInteractions || []);
|
|
159
|
+
|
|
160
|
+
const nodeView = findViewById(chart, NODES_VIEW_ID);
|
|
161
|
+
const edgeView = findViewById(chart, EDGES_VIEW_ID);
|
|
162
|
+
|
|
163
|
+
nodeInteractions.forEach((i) => {
|
|
164
|
+
if (i?.enable === false) {
|
|
165
|
+
nodeView.removeInteraction(i.type);
|
|
166
|
+
} else {
|
|
167
|
+
nodeView.interaction(i.type, i.cfg || {});
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
edgeInteractions.forEach((i) => {
|
|
172
|
+
if (i?.enable === false) {
|
|
173
|
+
edgeView.removeInteraction(i.type);
|
|
174
|
+
} else {
|
|
175
|
+
edgeView.interaction(i.type, i.cfg || {});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
return params;
|
|
180
|
+
}
|
|
181
|
+
|
|
149
182
|
/**
|
|
150
183
|
* 图适配器
|
|
151
184
|
* @param chart
|
|
@@ -115,4 +115,12 @@ export interface SankeyOptions extends Omit<Options, 'data' | 'xField' | 'yField
|
|
|
115
115
|
* 节点位置是否可以拖拽,默认为 false
|
|
116
116
|
*/
|
|
117
117
|
readonly nodeDraggable?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* 边交互
|
|
120
|
+
*/
|
|
121
|
+
readonly edgeInteractions?: Options['interactions'];
|
|
122
|
+
/**
|
|
123
|
+
* 节点交互
|
|
124
|
+
*/
|
|
125
|
+
readonly nodeInteractions?: Options['interactions'];
|
|
118
126
|
}
|
|
@@ -31,7 +31,7 @@ export function percent(data: Data, measure: string, groupField: string, as: str
|
|
|
31
31
|
return map(data, (datum: Datum) => {
|
|
32
32
|
const v = datum[measure];
|
|
33
33
|
const groupValue = datum[groupField];
|
|
34
|
-
const percentage = isRealNumber(v) ? v / sumMap.get(groupValue) : 0;
|
|
34
|
+
const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;
|
|
35
35
|
|
|
36
36
|
return {
|
|
37
37
|
...datum,
|
|
@@ -72,7 +72,7 @@ export function getDeepPercent(data: Record<string, any>[], measure: string, fie
|
|
|
72
72
|
// 获取分组得到的枚举key值
|
|
73
73
|
const groupValue = reduce(fields, (value, field) => `${value}${datum[field]}`, '');
|
|
74
74
|
|
|
75
|
-
const percentage = isRealNumber(v) ? v / sumMap.get(groupValue) : 0;
|
|
75
|
+
const percentage = isRealNumber(v) && sumMap.get(groupValue) !== 0 ? v / sumMap.get(groupValue) : 0;
|
|
76
76
|
|
|
77
77
|
return {
|
|
78
78
|
...datum,
|