@antv/g2 5.3.3-beta.0 → 5.3.4-alpha.0
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/README.md +9 -0
- package/README.zh-CN.md +8 -0
- package/dist/g2.lite.min.js +30 -22
- package/dist/g2.min.js +30 -22
- package/esm/api/runtime.d.ts +12 -1
- package/esm/api/runtime.js +89 -6
- package/esm/api/runtime.js.map +1 -1
- package/esm/data/fetch.d.ts +2 -2
- package/esm/data/fetch.js +2 -2
- package/esm/data/fetch.js.map +1 -1
- package/esm/data/utils/venn/fmin/bisect.d.ts +3 -0
- package/esm/data/utils/venn/fmin/bisect.js +30 -0
- package/esm/data/utils/venn/fmin/bisect.js.map +1 -0
- package/esm/data/utils/venn/fmin/blas1.d.ts +7 -0
- package/esm/data/utils/venn/fmin/blas1.js +38 -0
- package/esm/data/utils/venn/fmin/blas1.js.map +1 -0
- package/esm/data/utils/venn/fmin/conjugateGradient.d.ts +6 -0
- package/esm/data/utils/venn/fmin/conjugateGradient.js +91 -0
- package/esm/data/utils/venn/fmin/conjugateGradient.js.map +1 -0
- package/esm/data/utils/venn/fmin/gradientDescent.d.ts +10 -0
- package/esm/data/utils/venn/fmin/gradientDescent.js +66 -0
- package/esm/data/utils/venn/fmin/gradientDescent.js.map +1 -0
- package/esm/data/utils/venn/fmin/index.d.ts +34 -0
- package/esm/data/utils/venn/fmin/index.js +35 -0
- package/esm/data/utils/venn/fmin/index.js.map +1 -0
- package/esm/data/utils/venn/fmin/linesearch.d.ts +1 -0
- package/esm/data/utils/venn/fmin/linesearch.js +60 -0
- package/esm/data/utils/venn/fmin/linesearch.js.map +1 -0
- package/esm/data/utils/venn/fmin/nelderMead.d.ts +5 -0
- package/esm/data/utils/venn/fmin/nelderMead.js +133 -0
- package/esm/data/utils/venn/fmin/nelderMead.js.map +1 -0
- package/esm/data/utils/venn/layout.d.ts +2 -2
- package/esm/data/utils/venn/layout.js +1 -1
- package/esm/data/utils/venn/layout.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/interaction/elementSelect.js +32 -2
- package/esm/interaction/elementSelect.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +57 -0
- package/esm/interaction/tooltip.js +147 -85
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/interaction/utils.d.ts +2 -2
- package/esm/interaction/utils.js +10 -2
- package/esm/interaction/utils.js.map +1 -1
- package/esm/mark/line.js +4 -1
- package/esm/mark/line.js.map +1 -1
- package/esm/runtime/component.js +5 -2
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/plot.js +8 -3
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.d.ts +1 -1
- package/esm/runtime/render.js +4 -2
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/types/common.d.ts +1 -0
- package/esm/shape/connector/connector.js +19 -15
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/spec/transform.d.ts +1 -0
- package/esm/theme/create.d.ts +0 -1
- package/esm/theme/create.js +0 -1
- package/esm/theme/create.js.map +1 -1
- package/esm/transform/group.d.ts +0 -1
- package/esm/transform/group.js.map +1 -1
- package/esm/transform/groupN.d.ts +1 -1
- package/esm/utils/style.js +11 -2
- package/esm/utils/style.js.map +1 -1
- package/esm/utils/traverse-elements.d.ts +2 -0
- package/esm/utils/traverse-elements.js +13 -0
- package/esm/utils/traverse-elements.js.map +1 -0
- package/lib/api/runtime.d.ts +12 -1
- package/lib/api/runtime.js +96 -13
- package/lib/api/runtime.js.map +1 -1
- package/lib/data/fetch.d.ts +2 -2
- package/lib/data/fetch.js +1 -1
- package/lib/data/fetch.js.map +1 -1
- package/lib/data/utils/venn/fmin/bisect.d.ts +3 -0
- package/lib/data/utils/venn/fmin/bisect.js +34 -0
- package/lib/data/utils/venn/fmin/bisect.js.map +1 -0
- package/lib/data/utils/venn/fmin/blas1.d.ts +7 -0
- package/lib/data/utils/venn/fmin/blas1.js +48 -0
- package/lib/data/utils/venn/fmin/blas1.js.map +1 -0
- package/lib/data/utils/venn/fmin/conjugateGradient.d.ts +6 -0
- package/lib/data/utils/venn/fmin/conjugateGradient.js +96 -0
- package/lib/data/utils/venn/fmin/conjugateGradient.js.map +1 -0
- package/lib/data/utils/venn/fmin/gradientDescent.d.ts +10 -0
- package/lib/data/utils/venn/fmin/gradientDescent.js +71 -0
- package/lib/data/utils/venn/fmin/gradientDescent.js.map +1 -0
- package/lib/data/utils/venn/fmin/index.d.ts +34 -0
- package/lib/data/utils/venn/fmin/index.js +49 -0
- package/lib/data/utils/venn/fmin/index.js.map +1 -0
- package/lib/data/utils/venn/fmin/linesearch.d.ts +1 -0
- package/lib/data/utils/venn/fmin/linesearch.js +64 -0
- package/lib/data/utils/venn/fmin/linesearch.js.map +1 -0
- package/lib/data/utils/venn/fmin/nelderMead.d.ts +5 -0
- package/lib/data/utils/venn/fmin/nelderMead.js +137 -0
- package/lib/data/utils/venn/fmin/nelderMead.js.map +1 -0
- package/lib/data/utils/venn/layout.d.ts +2 -2
- package/lib/data/utils/venn/layout.js +1 -1
- package/lib/data/utils/venn/layout.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/interaction/elementSelect.js +32 -2
- package/lib/interaction/elementSelect.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +57 -0
- package/lib/interaction/tooltip.js +150 -85
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/interaction/utils.d.ts +2 -2
- package/lib/interaction/utils.js +10 -2
- package/lib/interaction/utils.js.map +1 -1
- package/lib/mark/line.js +3 -0
- package/lib/mark/line.js.map +1 -1
- package/lib/runtime/component.js +5 -2
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/plot.js +8 -3
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.d.ts +1 -1
- package/lib/runtime/render.js +4 -2
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/types/common.d.ts +1 -0
- package/lib/shape/connector/connector.js +19 -15
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/spec/transform.d.ts +1 -0
- package/lib/theme/create.d.ts +0 -1
- package/lib/theme/create.js +0 -1
- package/lib/theme/create.js.map +1 -1
- package/lib/transform/group.d.ts +0 -1
- package/lib/transform/group.js.map +1 -1
- package/lib/transform/groupN.d.ts +1 -1
- package/lib/utils/style.js +11 -2
- package/lib/utils/style.js.map +1 -1
- package/lib/utils/traverse-elements.d.ts +2 -0
- package/lib/utils/traverse-elements.js +17 -0
- package/lib/utils/traverse-elements.js.map +1 -0
- package/package.json +21 -21
- package/src/api/runtime.ts +136 -6
- package/src/data/fetch.ts +5 -4
- package/src/data/utils/venn/fmin/bisect.ts +32 -0
- package/src/data/utils/venn/fmin/blas1.ts +42 -0
- package/src/data/utils/venn/fmin/conjugateGradient.ts +106 -0
- package/src/data/utils/venn/fmin/gradientDescent.ts +75 -0
- package/src/data/utils/venn/fmin/index.ts +35 -0
- package/src/data/utils/venn/fmin/linesearch.ts +70 -0
- package/src/data/utils/venn/fmin/nelderMead.ts +147 -0
- package/src/data/utils/venn/layout.ts +1 -1
- package/src/index.ts +2 -2
- package/src/interaction/elementSelect.ts +32 -3
- package/src/interaction/tooltip.ts +216 -135
- package/src/interaction/utils.ts +12 -5
- package/src/mark/line.ts +3 -1
- package/src/runtime/component.ts +5 -3
- package/src/runtime/plot.ts +7 -1
- package/src/runtime/render.ts +5 -1
- package/src/runtime/types/common.ts +1 -0
- package/src/shape/connector/connector.ts +30 -19
- package/src/spec/transform.ts +1 -0
- package/src/theme/create.ts +0 -1
- package/src/transform/group.ts +0 -1
- package/src/transform/groupN.ts +1 -1
- package/src/utils/style.ts +11 -1
- package/src/utils/traverse-elements.ts +16 -0
package/src/runtime/component.ts
CHANGED
|
@@ -439,12 +439,14 @@ function inferAxisPositionAndOrientation(
|
|
|
439
439
|
scale.name.startsWith('position'),
|
|
440
440
|
);
|
|
441
441
|
const index = matchPosition(name);
|
|
442
|
-
if (
|
|
443
|
-
return [null, null];
|
|
442
|
+
if (index === null) return [null, null];
|
|
444
443
|
// infer radar axis orientation
|
|
445
444
|
const [startAngle, endAngle] = angleOf(coordinates);
|
|
445
|
+
const positionLength = isRadar(coordinates)
|
|
446
|
+
? positions.length
|
|
447
|
+
: positions.length - 1;
|
|
446
448
|
const angle =
|
|
447
|
-
((endAngle - startAngle) /
|
|
449
|
+
((endAngle - startAngle) / positionLength) * index + startAngle;
|
|
448
450
|
return ['center', angle];
|
|
449
451
|
}
|
|
450
452
|
|
package/src/runtime/plot.ts
CHANGED
|
@@ -789,6 +789,7 @@ function initializeState(
|
|
|
789
789
|
// the same style with JS standard and lodash APIs.
|
|
790
790
|
// @todo More proper way to index scale for different marks.
|
|
791
791
|
const children = [];
|
|
792
|
+
const dataMap = new Map();
|
|
792
793
|
for (const [mark, state] of markState.entries()) {
|
|
793
794
|
const {
|
|
794
795
|
// scale,
|
|
@@ -799,7 +800,9 @@ function initializeState(
|
|
|
799
800
|
dataDomain,
|
|
800
801
|
modifier,
|
|
801
802
|
key: markKey,
|
|
803
|
+
data,
|
|
802
804
|
} = mark;
|
|
805
|
+
dataMap.set(markKey, data);
|
|
803
806
|
const { index, channels, tooltip } = state;
|
|
804
807
|
const scale = Object.fromEntries(
|
|
805
808
|
channels.map(({ name, scale }) => [name, scale]),
|
|
@@ -828,6 +831,7 @@ function initializeState(
|
|
|
828
831
|
index: d,
|
|
829
832
|
markKey,
|
|
830
833
|
viewKey: key,
|
|
834
|
+
data: data[d],
|
|
831
835
|
...(tooltip && {
|
|
832
836
|
title: titleOf(d),
|
|
833
837
|
items: itemsOf(d),
|
|
@@ -867,6 +871,7 @@ function initializeState(
|
|
|
867
871
|
scale: scaleInstance,
|
|
868
872
|
style: framedStyle,
|
|
869
873
|
components,
|
|
874
|
+
data: dataMap,
|
|
870
875
|
labelTransform: compose(labelTransform.map(useLabelTransform)),
|
|
871
876
|
};
|
|
872
877
|
|
|
@@ -1318,7 +1323,7 @@ function normalizeLabelSelector(
|
|
|
1318
1323
|
* transitions together.
|
|
1319
1324
|
*/
|
|
1320
1325
|
function getLocalBounds(element: DisplayObject) {
|
|
1321
|
-
const cloneElement = element.cloneNode();
|
|
1326
|
+
const cloneElement = element.cloneNode(true);
|
|
1322
1327
|
const animations = element.getAnimations();
|
|
1323
1328
|
cloneElement.style.visibility = 'hidden';
|
|
1324
1329
|
animations.forEach((animation) => {
|
|
@@ -1472,6 +1477,7 @@ function selectFacetElements(
|
|
|
1472
1477
|
elementClassName: string,
|
|
1473
1478
|
): DisplayObject[] {
|
|
1474
1479
|
const group = selection.node().parentElement;
|
|
1480
|
+
if (!group || typeof group.findAll !== 'function') return [];
|
|
1475
1481
|
return group
|
|
1476
1482
|
.findAll(
|
|
1477
1483
|
(node) =>
|
package/src/runtime/render.ts
CHANGED
|
@@ -171,13 +171,17 @@ export function destroy<T extends G2ViewTree = G2ViewTree>(
|
|
|
171
171
|
options: T,
|
|
172
172
|
context: G2Context = {},
|
|
173
173
|
isDestroyCanvas = false,
|
|
174
|
+
isClearEvents = true,
|
|
174
175
|
) {
|
|
175
176
|
const { canvas, emitter } = context;
|
|
176
177
|
if (canvas) {
|
|
177
178
|
destroyAllInteractions(canvas);
|
|
178
179
|
isDestroyCanvas ? canvas.destroy() : canvas.destroyChildren();
|
|
179
180
|
}
|
|
180
|
-
|
|
181
|
+
|
|
182
|
+
if (isClearEvents) {
|
|
183
|
+
emitter.off();
|
|
184
|
+
}
|
|
181
185
|
}
|
|
182
186
|
|
|
183
187
|
/**
|
|
@@ -35,40 +35,49 @@ function inferConnectorPath(points: Vector2[]) {
|
|
|
35
35
|
function getPoints(
|
|
36
36
|
coordinate: Coordinate,
|
|
37
37
|
points: Vector2[],
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
sourceOffsetY: number,
|
|
39
|
+
targetOffsetY: number,
|
|
40
|
+
sourceOffsetX: number,
|
|
41
|
+
targetOffsetX: number,
|
|
40
42
|
length1 = 0,
|
|
41
43
|
): Vector2[] {
|
|
42
44
|
const [[x0, y0], [x1, y1]] = points;
|
|
43
45
|
|
|
44
46
|
if (isTranspose(coordinate)) {
|
|
45
|
-
const X0 = x0 +
|
|
46
|
-
const X1 = x1 +
|
|
47
|
+
const X0 = x0 + sourceOffsetY;
|
|
48
|
+
const X1 = x1 + targetOffsetY;
|
|
47
49
|
const X = X0 + length1;
|
|
50
|
+
const Y0 = y0 + sourceOffsetX;
|
|
51
|
+
const Y1 = y1 + targetOffsetX;
|
|
48
52
|
return [
|
|
49
|
-
[X0,
|
|
50
|
-
[X,
|
|
51
|
-
[X,
|
|
52
|
-
[X1,
|
|
53
|
+
[X0, Y0],
|
|
54
|
+
[X, Y0],
|
|
55
|
+
[X, Y1],
|
|
56
|
+
[X1, Y1],
|
|
53
57
|
];
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
const Y0 = y0 -
|
|
57
|
-
const Y1 = y1 -
|
|
60
|
+
const Y0 = y0 - sourceOffsetY;
|
|
61
|
+
const Y1 = y1 - targetOffsetY;
|
|
58
62
|
const Y = Y0 - length1;
|
|
63
|
+
const X0 = x0 - sourceOffsetX;
|
|
64
|
+
const X1 = x1 - targetOffsetX;
|
|
59
65
|
return [
|
|
60
|
-
[
|
|
61
|
-
[
|
|
62
|
-
[
|
|
63
|
-
[
|
|
66
|
+
[X0, Y0],
|
|
67
|
+
[X0, Y],
|
|
68
|
+
[X1, Y],
|
|
69
|
+
[X1, Y1],
|
|
64
70
|
];
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
export const Connector: SC<ConnectorOptions> = (options, context) => {
|
|
68
74
|
const {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
offsetX = 0,
|
|
76
|
+
sourceOffsetX = offsetX,
|
|
77
|
+
targetOffsetX = offsetX,
|
|
78
|
+
offsetY = 0,
|
|
79
|
+
sourceOffsetY = offsetY,
|
|
80
|
+
targetOffsetY = offsetY,
|
|
72
81
|
connectLength1: length1,
|
|
73
82
|
endMarker = true,
|
|
74
83
|
...style
|
|
@@ -81,8 +90,10 @@ export const Connector: SC<ConnectorOptions> = (options, context) => {
|
|
|
81
90
|
const P = getPoints(
|
|
82
91
|
coordinate,
|
|
83
92
|
points,
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
sourceOffsetY,
|
|
94
|
+
targetOffsetY,
|
|
95
|
+
sourceOffsetX,
|
|
96
|
+
targetOffsetX,
|
|
86
97
|
length1 ?? connectLength1,
|
|
87
98
|
);
|
|
88
99
|
const makerStyle = subObject({ ...style, ...defaults }, 'endMarker');
|
package/src/spec/transform.ts
CHANGED
package/src/theme/create.ts
CHANGED
package/src/transform/group.ts
CHANGED
package/src/transform/groupN.ts
CHANGED
package/src/utils/style.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DisplayObject, BaseStyleProps } from '@antv/g';
|
|
2
|
+
import { traverseElements } from './traverse-elements';
|
|
2
3
|
|
|
3
4
|
const defaultStyle: BaseStyleProps = {
|
|
4
5
|
visibility: 'visible',
|
|
@@ -8,7 +9,16 @@ const defaultStyle: BaseStyleProps = {
|
|
|
8
9
|
};
|
|
9
10
|
|
|
10
11
|
export function getStyle(element: DisplayObject, key: string) {
|
|
11
|
-
|
|
12
|
+
let value: any;
|
|
13
|
+
traverseElements(element, (el) => {
|
|
14
|
+
if (el.tagName !== 'g' && el.style?.[key] !== undefined) {
|
|
15
|
+
value = el.style[key];
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return value ?? defaultStyle[key];
|
|
12
22
|
}
|
|
13
23
|
|
|
14
24
|
export function setStyle(
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DisplayObject } from '@antv/g';
|
|
2
|
+
|
|
3
|
+
export function traverseElements(
|
|
4
|
+
element: DisplayObject,
|
|
5
|
+
visitor: (el: DisplayObject) => boolean | void,
|
|
6
|
+
): boolean {
|
|
7
|
+
if (visitor(element)) return true;
|
|
8
|
+
if (element.tagName === 'g') {
|
|
9
|
+
const { childNodes = [] } = element;
|
|
10
|
+
for (const child of childNodes) {
|
|
11
|
+
if (traverseElements(child as DisplayObject, visitor)) return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return false;
|
|
16
|
+
}
|