@antv/g2 5.3.4-beta.2 → 5.3.4
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/dist/g2.lite.min.js +11 -11
- package/dist/g2.min.js +11 -11
- package/esm/component/legendCategory.js +42 -0
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/composition/geoPath.js +2 -1
- package/esm/composition/geoPath.js.map +1 -1
- package/esm/data/cluster.d.ts +1 -1
- package/esm/index.d.ts +2 -0
- package/esm/label-transform/contrastReverse.js +1 -31
- package/esm/label-transform/contrastReverse.js.map +1 -1
- package/esm/label-transform/exceedAdjust.d.ts +7 -2
- package/esm/label-transform/exceedAdjust.js +31 -7
- package/esm/label-transform/exceedAdjust.js.map +1 -1
- package/esm/label-transform/index.d.ts +2 -0
- package/esm/label-transform/index.js +1 -0
- package/esm/label-transform/index.js.map +1 -1
- package/esm/label-transform/overflowStroke.d.ts +8 -0
- package/esm/label-transform/overflowStroke.js +57 -0
- package/esm/label-transform/overflowStroke.js.map +1 -0
- package/esm/label-transform/utils.d.ts +10 -0
- package/esm/label-transform/utils.js +32 -0
- package/esm/label-transform/utils.js.map +1 -0
- package/esm/lib/core.d.ts +1 -0
- package/esm/lib/core.js +2 -1
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/std.d.ts +1 -0
- package/esm/mark/sankey.js +13 -2
- package/esm/mark/sankey.js.map +1 -1
- package/esm/mark/treemap.js +2 -4
- package/esm/mark/treemap.js.map +1 -1
- package/esm/shape/gauge/round.js +23 -2
- package/esm/shape/gauge/round.js.map +1 -1
- package/esm/spec/labelTransform.d.ts +27 -1
- package/lib/component/legendCategory.js +42 -0
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/composition/geoPath.js +2 -1
- package/lib/composition/geoPath.js.map +1 -1
- package/lib/data/cluster.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/label-transform/contrastReverse.js +3 -33
- package/lib/label-transform/contrastReverse.js.map +1 -1
- package/lib/label-transform/exceedAdjust.d.ts +7 -2
- package/lib/label-transform/exceedAdjust.js +31 -7
- package/lib/label-transform/exceedAdjust.js.map +1 -1
- package/lib/label-transform/index.d.ts +2 -0
- package/lib/label-transform/index.js +3 -1
- package/lib/label-transform/index.js.map +1 -1
- package/lib/label-transform/overflowStroke.d.ts +8 -0
- package/lib/label-transform/overflowStroke.js +61 -0
- package/lib/label-transform/overflowStroke.js.map +1 -0
- package/lib/label-transform/utils.d.ts +10 -0
- package/lib/label-transform/utils.js +37 -0
- package/lib/label-transform/utils.js.map +1 -0
- package/lib/lib/core.d.ts +1 -0
- package/lib/lib/core.js +1 -0
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/std.d.ts +1 -0
- package/lib/mark/sankey.js +12 -1
- package/lib/mark/sankey.js.map +1 -1
- package/lib/mark/treemap.js +2 -4
- package/lib/mark/treemap.js.map +1 -1
- package/lib/shape/gauge/round.js +23 -2
- package/lib/shape/gauge/round.js.map +1 -1
- package/lib/spec/labelTransform.d.ts +27 -1
- package/package.json +5 -25
- package/src/component/legendCategory.ts +49 -0
- package/src/composition/geoPath.ts +13 -2
- package/src/label-transform/contrastReverse.ts +1 -34
- package/src/label-transform/exceedAdjust.ts +53 -8
- package/src/label-transform/index.ts +2 -0
- package/src/label-transform/overflowStroke.ts +69 -0
- package/src/label-transform/utils.ts +34 -0
- package/src/lib/core.ts +2 -0
- package/src/mark/sankey.ts +16 -2
- package/src/mark/treemap.ts +3 -4
- package/src/shape/gauge/round.ts +24 -2
- package/src/spec/labelTransform.ts +28 -0
package/src/mark/treemap.ts
CHANGED
|
@@ -83,10 +83,9 @@ export const Treemap: CC<TreemapOptions> = (options, context) => {
|
|
|
83
83
|
...resOptions
|
|
84
84
|
} = options;
|
|
85
85
|
|
|
86
|
-
const treemapDrillDown =
|
|
87
|
-
'interaction',
|
|
88
|
-
'treemapDrillDown'
|
|
89
|
-
]);
|
|
86
|
+
const treemapDrillDown =
|
|
87
|
+
get(markOptions, ['interaction', 'treemapDrillDown']) ||
|
|
88
|
+
get(markOptions, ['marks', 0, 'interaction', 'treemapDrillDown']);
|
|
90
89
|
|
|
91
90
|
// Layout
|
|
92
91
|
const layoutOptions = deepMix(
|
package/src/shape/gauge/round.ts
CHANGED
|
@@ -12,6 +12,16 @@ const getR = (point1, point2) => {
|
|
|
12
12
|
);
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
// 计算两点之间的角度
|
|
16
|
+
const getAngle = (start, end, center) => {
|
|
17
|
+
const startAngle = Math.atan2(start[1] - center[1], start[0] - center[0]);
|
|
18
|
+
const endAngle = Math.atan2(end[1] - center[1], end[0] - center[0]);
|
|
19
|
+
let angle = endAngle - startAngle;
|
|
20
|
+
// 确保角度在 0-2π 之间
|
|
21
|
+
if (angle < 0) angle += Math.PI * 2;
|
|
22
|
+
return angle;
|
|
23
|
+
};
|
|
24
|
+
|
|
15
25
|
// Gauge round.
|
|
16
26
|
export const Round: SC<RoundOptions> = (options, context) => {
|
|
17
27
|
if (!context) return;
|
|
@@ -29,6 +39,10 @@ export const Round: SC<RoundOptions> = (options, context) => {
|
|
|
29
39
|
const minR = getR(points[0], points[1]);
|
|
30
40
|
const maxR = getR(points[0], center) * 2;
|
|
31
41
|
|
|
42
|
+
// 计算每个弧段的角度
|
|
43
|
+
// 判断是否需要使用大弧度(角度大于180度)
|
|
44
|
+
const isHalf = getAngle(points[3], points[0], center) > Math.PI;
|
|
45
|
+
|
|
32
46
|
/**
|
|
33
47
|
* MinR small circle radius, maxR big circle radius.
|
|
34
48
|
* Draw four arcs.
|
|
@@ -39,9 +53,17 @@ export const Round: SC<RoundOptions> = (options, context) => {
|
|
|
39
53
|
d: [
|
|
40
54
|
['M', ...points[0]],
|
|
41
55
|
['A', minR, minR, 0, 1, 0, ...points[1]],
|
|
42
|
-
[
|
|
56
|
+
[
|
|
57
|
+
'A',
|
|
58
|
+
maxR + minR * 2,
|
|
59
|
+
maxR + minR * 2,
|
|
60
|
+
0,
|
|
61
|
+
isHalf ? 1 : 0,
|
|
62
|
+
0,
|
|
63
|
+
...points[2],
|
|
64
|
+
],
|
|
43
65
|
['A', minR, minR, 0, 1, index === 0 ? 0 : 1, ...points[3]],
|
|
44
|
-
['A', maxR, maxR, 0, 0, 1, ...points[0]],
|
|
66
|
+
['A', maxR, maxR, 0, isHalf ? 1 : 0, 1, ...points[0]],
|
|
45
67
|
['Z'],
|
|
46
68
|
],
|
|
47
69
|
...defaultCfg,
|
|
@@ -4,6 +4,7 @@ export type LabelTransform =
|
|
|
4
4
|
| OverlapHideLabelTransform
|
|
5
5
|
| OverlapDodgeYLabelTransform
|
|
6
6
|
| ContrastReverseLabelTransform
|
|
7
|
+
| OverflowStrokeTransform
|
|
7
8
|
| OverflowHideLabelTransform;
|
|
8
9
|
|
|
9
10
|
export type OverlapHideLabelTransform = {
|
|
@@ -34,10 +35,37 @@ export type ContrastReverseLabelTransform = {
|
|
|
34
35
|
palette?: string[];
|
|
35
36
|
};
|
|
36
37
|
|
|
38
|
+
export type OverflowStrokeTransform = {
|
|
39
|
+
type?: 'overlapStroke';
|
|
40
|
+
/**
|
|
41
|
+
* Stroke when label overflow more than threshold.
|
|
42
|
+
* Default is `2`.
|
|
43
|
+
*/
|
|
44
|
+
threshold?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The optional color palette, default is [#000, #fff].
|
|
47
|
+
*/
|
|
48
|
+
palette?: string[];
|
|
49
|
+
};
|
|
50
|
+
|
|
37
51
|
export type OverflowHideLabelTransform = {
|
|
38
52
|
type: 'overflowHide';
|
|
39
53
|
};
|
|
40
54
|
|
|
41
55
|
export type ExceedAdjustLabel = {
|
|
42
56
|
type: 'exceedAdjust';
|
|
57
|
+
/**
|
|
58
|
+
* The boundary area to check for label overflow.
|
|
59
|
+
* - 'view': Check against the entire view area (default)
|
|
60
|
+
* - 'main': Check against the main area (excluding margins and paddings)
|
|
61
|
+
*/
|
|
62
|
+
bounds?: 'view' | 'main';
|
|
63
|
+
/**
|
|
64
|
+
* The X-axis offset, default is 0
|
|
65
|
+
*/
|
|
66
|
+
offsetX?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The Y-axis offset, default is 0
|
|
69
|
+
*/
|
|
70
|
+
offsetY?: number;
|
|
43
71
|
};
|