@antv/g2 5.0.0-beta.5 → 5.0.0-beta.6
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 +4 -4
- package/dist/g2.min.js +4 -4
- package/esm/api/chart.d.ts +4 -0
- package/esm/api/chart.js +26 -4
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/mark.js +1 -0
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -0
- package/esm/component/axis.js +18 -5
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +2 -0
- package/esm/component/index.js +2 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/scrollbar.d.ts +9 -0
- package/esm/component/scrollbar.js +36 -0
- package/esm/component/scrollbar.js.map +1 -0
- package/esm/component/scrollbarX.d.ts +7 -0
- package/esm/component/scrollbarX.js +9 -0
- package/esm/component/scrollbarX.js.map +1 -0
- package/esm/component/scrollbarY.d.ts +7 -0
- package/esm/component/scrollbarY.js +9 -0
- package/esm/component/scrollbarY.js.map +1 -0
- package/esm/component/title.js +46 -22
- package/esm/component/title.js.map +1 -1
- package/esm/data/fold.js +4 -10
- package/esm/data/fold.js.map +1 -1
- package/esm/data/index.d.ts +2 -2
- package/esm/data/index.js +1 -1
- package/esm/data/index.js.map +1 -1
- package/esm/data/pick.js +10 -2
- package/esm/data/pick.js.map +1 -1
- package/esm/data/slice.d.ts +8 -0
- package/esm/data/slice.js +10 -0
- package/esm/data/slice.js.map +1 -0
- package/esm/interaction/index.d.ts +5 -0
- package/esm/interaction/index.js +4 -30
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/esm/interaction/native/brushAxisHighlight.js +159 -0
- package/esm/interaction/native/brushAxisHighlight.js.map +1 -0
- package/esm/interaction/native/brushFilter.d.ts +12 -0
- package/esm/interaction/native/brushFilter.js +147 -0
- package/esm/interaction/native/brushFilter.js.map +1 -0
- package/esm/interaction/native/brushHighlight.d.ts +30 -5
- package/esm/interaction/native/brushHighlight.js +92 -34
- package/esm/interaction/native/brushHighlight.js.map +1 -1
- package/esm/interaction/native/brushXFilter.d.ts +1 -0
- package/esm/interaction/native/brushXFilter.js +6 -0
- package/esm/interaction/native/brushXFilter.js.map +1 -0
- package/esm/interaction/native/brushXHighlight.d.ts +6 -1
- package/esm/interaction/native/brushXHighlight.js +5 -4
- package/esm/interaction/native/brushXHighlight.js.map +1 -1
- package/esm/interaction/native/brushYFilter.d.ts +1 -0
- package/esm/interaction/native/brushYFilter.js +6 -0
- package/esm/interaction/native/brushYFilter.js.map +1 -0
- package/esm/interaction/native/brushYHighlight.d.ts +6 -1
- package/esm/interaction/native/brushYHighlight.js +5 -4
- package/esm/interaction/native/brushYHighlight.js.map +1 -1
- package/esm/interaction/native/tooltip.js +6 -5
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/interaction/native/utils.d.ts +5 -1
- package/esm/interaction/native/utils.js +11 -3
- package/esm/interaction/native/utils.js.map +1 -1
- package/esm/mark/area.js +1 -1
- package/esm/mark/area.js.map +1 -1
- package/esm/mark/boxplot.js +5 -18
- package/esm/mark/boxplot.js.map +1 -1
- package/esm/runtime/component.js +33 -38
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +7 -7
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +5 -1
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.d.ts +0 -1
- package/esm/runtime/render.js +4 -34
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/transform.js +6 -2
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +26 -9
- package/esm/runtime/types/options.d.ts +2 -5
- package/esm/runtime/types/theme.d.ts +2 -5
- package/esm/shape/area/curve.js +15 -8
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/box/box.js +1 -1
- package/esm/shape/box/box.js.map +1 -1
- package/esm/shape/connector/connector.js +2 -2
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/image/image.js +2 -2
- package/esm/shape/image/image.js.map +1 -1
- package/esm/shape/interval/color.js +3 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/label/position/default.d.ts +5 -7
- package/esm/shape/label/position/default.js +14 -40
- package/esm/shape/label/position/default.js.map +1 -1
- package/esm/shape/label/position/outside.d.ts +18 -1
- package/esm/shape/label/position/outside.js +66 -1
- package/esm/shape/label/position/outside.js.map +1 -1
- package/esm/shape/label/position/spider.d.ts +1 -1
- package/esm/shape/label/position/spider.js +12 -18
- package/esm/shape/label/position/spider.js.map +1 -1
- package/esm/shape/label/position/surround.d.ts +1 -1
- package/esm/shape/label/position/surround.js +12 -14
- package/esm/shape/label/position/surround.js.map +1 -1
- package/esm/shape/line/curve.js +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/lineXY/line.js +2 -2
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/link/arc.js +2 -2
- package/esm/shape/link/arc.js.map +1 -1
- package/esm/shape/link/link.js +2 -2
- package/esm/shape/link/link.js.map +1 -1
- package/esm/shape/link/smooth.js +2 -2
- package/esm/shape/link/smooth.js.map +1 -1
- package/esm/shape/link/vhv.js +2 -2
- package/esm/shape/link/vhv.js.map +1 -1
- package/esm/shape/point/color.js +1 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/polygon/polygon.js +3 -3
- package/esm/shape/polygon/polygon.js.map +1 -1
- package/esm/shape/polygon/ribbon.js +3 -3
- package/esm/shape/polygon/ribbon.js.map +1 -1
- package/esm/shape/text/advance.js +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +3 -3
- package/esm/shape/text/badge.js.map +1 -1
- package/esm/shape/text/text.js +1 -1
- package/esm/shape/text/text.js.map +1 -1
- package/esm/shape/utils.d.ts +4 -0
- package/esm/shape/utils.js +6 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/shape/vector/vector.js +3 -3
- package/esm/shape/vector/vector.js.map +1 -1
- package/esm/spec/data.d.ts +24 -9
- package/esm/spec/geometry.d.ts +1 -0
- package/esm/spec/interaction.d.ts +22 -3
- package/esm/stdlib/index.js +5 -5
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.js +11 -15
- package/esm/theme/academy.js.map +1 -1
- package/esm/theme/dark.js +11 -18
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/light.js +25 -19
- package/esm/theme/light.js.map +1 -1
- package/lib/api/chart.d.ts +4 -0
- package/lib/api/chart.js +26 -4
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/mark.js +1 -0
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -0
- package/lib/component/axis.js +18 -5
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +2 -0
- package/lib/component/index.js +5 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/scrollbar.d.ts +9 -0
- package/lib/component/scrollbar.js +40 -0
- package/lib/component/scrollbar.js.map +1 -0
- package/lib/component/scrollbarX.d.ts +7 -0
- package/lib/component/scrollbarX.js +13 -0
- package/lib/component/scrollbarX.js.map +1 -0
- package/lib/component/scrollbarY.d.ts +7 -0
- package/lib/component/scrollbarY.js +13 -0
- package/lib/component/scrollbarY.js.map +1 -0
- package/lib/component/title.js +46 -22
- package/lib/component/title.js.map +1 -1
- package/lib/data/fold.js +4 -10
- package/lib/data/fold.js.map +1 -1
- package/lib/data/index.d.ts +2 -2
- package/lib/data/index.js +3 -3
- package/lib/data/index.js.map +1 -1
- package/lib/data/pick.js +10 -2
- package/lib/data/pick.js.map +1 -1
- package/lib/data/slice.d.ts +8 -0
- package/lib/data/slice.js +14 -0
- package/lib/data/slice.js.map +1 -0
- package/lib/interaction/index.d.ts +5 -0
- package/lib/interaction/index.js +9 -31
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/brushAxisHighlight.d.ts +26 -0
- package/lib/interaction/native/brushAxisHighlight.js +164 -0
- package/lib/interaction/native/brushAxisHighlight.js.map +1 -0
- package/lib/interaction/native/brushFilter.d.ts +12 -0
- package/lib/interaction/native/brushFilter.js +152 -0
- package/lib/interaction/native/brushFilter.js.map +1 -0
- package/lib/interaction/native/brushHighlight.d.ts +30 -5
- package/lib/interaction/native/brushHighlight.js +91 -33
- package/lib/interaction/native/brushHighlight.js.map +1 -1
- package/lib/interaction/native/brushXFilter.d.ts +1 -0
- package/lib/interaction/native/brushXFilter.js +10 -0
- package/lib/interaction/native/brushXFilter.js.map +1 -0
- package/lib/interaction/native/brushXHighlight.d.ts +6 -1
- package/lib/interaction/native/brushXHighlight.js +7 -5
- package/lib/interaction/native/brushXHighlight.js.map +1 -1
- package/lib/interaction/native/brushYFilter.d.ts +1 -0
- package/lib/interaction/native/brushYFilter.js +10 -0
- package/lib/interaction/native/brushYFilter.js.map +1 -0
- package/lib/interaction/native/brushYHighlight.d.ts +6 -1
- package/lib/interaction/native/brushYHighlight.js +7 -5
- package/lib/interaction/native/brushYHighlight.js.map +1 -1
- package/lib/interaction/native/tooltip.js +6 -5
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/interaction/native/utils.d.ts +5 -1
- package/lib/interaction/native/utils.js +14 -5
- package/lib/interaction/native/utils.js.map +1 -1
- package/lib/mark/area.js +1 -1
- package/lib/mark/area.js.map +1 -1
- package/lib/mark/boxplot.js +5 -18
- package/lib/mark/boxplot.js.map +1 -1
- package/lib/runtime/component.js +33 -38
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +7 -7
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +5 -1
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.d.ts +0 -1
- package/lib/runtime/render.js +4 -35
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/transform.js +6 -2
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +26 -9
- package/lib/runtime/types/options.d.ts +2 -5
- package/lib/runtime/types/theme.d.ts +2 -5
- package/lib/shape/area/curve.js +14 -7
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/box/box.js +1 -1
- package/lib/shape/box/box.js.map +1 -1
- package/lib/shape/connector/connector.js +2 -2
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/image/image.js +2 -2
- package/lib/shape/image/image.js.map +1 -1
- package/lib/shape/interval/color.js +3 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/label/position/default.d.ts +5 -7
- package/lib/shape/label/position/default.js +16 -40
- package/lib/shape/label/position/default.js.map +1 -1
- package/lib/shape/label/position/outside.d.ts +18 -1
- package/lib/shape/label/position/outside.js +72 -3
- package/lib/shape/label/position/outside.js.map +1 -1
- package/lib/shape/label/position/spider.d.ts +1 -1
- package/lib/shape/label/position/spider.js +12 -18
- package/lib/shape/label/position/spider.js.map +1 -1
- package/lib/shape/label/position/surround.d.ts +1 -1
- package/lib/shape/label/position/surround.js +11 -13
- package/lib/shape/label/position/surround.js.map +1 -1
- package/lib/shape/line/curve.js +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/lineXY/line.js +2 -2
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/link/arc.js +2 -2
- package/lib/shape/link/arc.js.map +1 -1
- package/lib/shape/link/link.js +2 -2
- package/lib/shape/link/link.js.map +1 -1
- package/lib/shape/link/smooth.js +2 -2
- package/lib/shape/link/smooth.js.map +1 -1
- package/lib/shape/link/vhv.js +2 -2
- package/lib/shape/link/vhv.js.map +1 -1
- package/lib/shape/point/color.js +1 -1
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/polygon/polygon.js +3 -3
- package/lib/shape/polygon/polygon.js.map +1 -1
- package/lib/shape/polygon/ribbon.js +3 -3
- package/lib/shape/polygon/ribbon.js.map +1 -1
- package/lib/shape/text/advance.js +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +3 -3
- package/lib/shape/text/badge.js.map +1 -1
- package/lib/shape/text/text.js +1 -1
- package/lib/shape/text/text.js.map +1 -1
- package/lib/shape/utils.d.ts +4 -0
- package/lib/shape/utils.js +6 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/shape/vector/vector.js +3 -3
- package/lib/shape/vector/vector.js.map +1 -1
- package/lib/spec/data.d.ts +24 -9
- package/lib/spec/geometry.d.ts +1 -0
- package/lib/spec/interaction.d.ts +22 -3
- package/lib/stdlib/index.js +2 -2
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.js +11 -15
- package/lib/theme/academy.js.map +1 -1
- package/lib/theme/dark.js +11 -18
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/light.js +25 -19
- package/lib/theme/light.js.map +1 -1
- package/package.json +1 -1
- package/src/api/chart.ts +29 -8
- package/src/api/mark/mark.ts +1 -0
- package/src/api/mark/types.ts +1 -0
- package/src/component/axis.ts +22 -5
- package/src/component/index.ts +2 -0
- package/src/component/scrollbar.ts +41 -0
- package/src/component/scrollbarX.ts +16 -0
- package/src/component/scrollbarY.ts +16 -0
- package/src/component/title.ts +69 -30
- package/src/data/fold.ts +6 -10
- package/src/data/index.ts +2 -2
- package/src/data/pick.ts +11 -2
- package/src/data/slice.ts +15 -0
- package/src/interaction/index.ts +20 -16
- package/src/interaction/native/brushAxisHighlight.ts +194 -0
- package/src/interaction/native/brushFilter.ts +163 -0
- package/src/interaction/native/brushHighlight.ts +104 -31
- package/src/interaction/native/brushXFilter.ts +9 -0
- package/src/interaction/native/brushXHighlight.ts +6 -4
- package/src/interaction/native/brushYFilter.ts +9 -0
- package/src/interaction/native/brushYHighlight.ts +6 -4
- package/src/interaction/native/tooltip.ts +9 -6
- package/src/interaction/native/utils.ts +15 -6
- package/src/mark/area.ts +1 -1
- package/src/mark/boxplot.ts +3 -1
- package/src/runtime/component.ts +46 -47
- package/src/runtime/layout.ts +6 -6
- package/src/runtime/plot.ts +6 -1
- package/src/runtime/render.ts +6 -58
- package/src/runtime/transform.ts +6 -2
- package/src/runtime/types/common.ts +26 -10
- package/src/runtime/types/options.ts +2 -5
- package/src/runtime/types/theme.ts +2 -5
- package/src/shape/area/curve.ts +15 -8
- package/src/shape/box/box.ts +6 -6
- package/src/shape/connector/connector.ts +2 -3
- package/src/shape/image/image.ts +2 -2
- package/src/shape/interval/color.ts +2 -1
- package/src/shape/label/position/default.ts +15 -55
- package/src/shape/label/position/outside.ts +121 -1
- package/src/shape/label/position/spider.ts +12 -19
- package/src/shape/label/position/surround.ts +13 -15
- package/src/shape/line/curve.ts +1 -1
- package/src/shape/lineXY/line.ts +2 -2
- package/src/shape/link/arc.ts +2 -2
- package/src/shape/link/link.ts +2 -2
- package/src/shape/link/smooth.ts +2 -2
- package/src/shape/link/vhv.ts +2 -2
- package/src/shape/point/color.ts +6 -5
- package/src/shape/polygon/polygon.ts +3 -3
- package/src/shape/polygon/ribbon.ts +3 -3
- package/src/shape/text/advance.ts +4 -1
- package/src/shape/text/badge.ts +8 -3
- package/src/shape/text/text.ts +1 -1
- package/src/shape/utils.ts +6 -5
- package/src/shape/vector/vector.ts +3 -3
- package/src/spec/action.ts +0 -1
- package/src/spec/data.ts +25 -10
- package/src/spec/geometry.ts +1 -0
- package/src/spec/interaction.ts +32 -2
- package/src/stdlib/index.ts +14 -2
- package/src/theme/academy.ts +11 -15
- package/src/theme/dark.ts +11 -18
- package/src/theme/light.ts +25 -19
- package/esm/data/subset.d.ts +0 -7
- package/esm/data/subset.js +0 -26
- package/esm/data/subset.js.map +0 -1
- package/lib/data/subset.d.ts +0 -7
- package/lib/data/subset.js +0 -30
- package/lib/data/subset.js.map +0 -1
- package/src/.DS_Store +0 -0
- package/src/data/.DS_Store +0 -0
- package/src/data/subset.ts +0 -35
- package/src/shape/.DS_Store +0 -0
|
@@ -85,7 +85,7 @@ export function inferRadialStyle(
|
|
|
85
85
|
const [p0, p1] = points;
|
|
86
86
|
const radius = innerRadius + (outerRadius - innerRadius) * 0.5;
|
|
87
87
|
const [x, y] =
|
|
88
|
-
position === 'inside' ?
|
|
88
|
+
position === 'inside' ? pointOfArc(center, angle, radius) : mid(p0, p1);
|
|
89
89
|
return { x, y };
|
|
90
90
|
})();
|
|
91
91
|
|
|
@@ -97,25 +97,21 @@ export function inferRadialStyle(
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function
|
|
100
|
+
export function pointOfArc(center: Vector2, angle, radius): Vector2 {
|
|
101
101
|
return [
|
|
102
102
|
center[0] + Math.sin(angle) * radius,
|
|
103
103
|
center[1] - Math.cos(angle) * radius,
|
|
104
104
|
];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
function inferRotation(
|
|
108
|
-
angle: number,
|
|
109
|
-
autoRotate: boolean,
|
|
110
|
-
rotateToAlignArc: boolean,
|
|
111
|
-
) {
|
|
107
|
+
export function inferRotation(angle, autoRotate, rotateToAlignArc) {
|
|
112
108
|
if (!autoRotate) return 0;
|
|
113
109
|
|
|
114
110
|
const append = rotateToAlignArc ? 0 : Math.sin(angle) < 0 ? 90 : -90;
|
|
115
111
|
return (angle / Math.PI) * 180 + append;
|
|
116
112
|
}
|
|
117
113
|
|
|
118
|
-
|
|
114
|
+
function inferInnerCircularStyle(
|
|
119
115
|
position: LabelPosition,
|
|
120
116
|
points: Vector2[],
|
|
121
117
|
value: Record<string, any>,
|
|
@@ -126,9 +122,6 @@ export function inferCircularStyle(
|
|
|
126
122
|
y1,
|
|
127
123
|
autoRotate,
|
|
128
124
|
rotateToAlignArc,
|
|
129
|
-
connector = true,
|
|
130
|
-
connectorLength2 = 0,
|
|
131
|
-
connectorDistance = 0,
|
|
132
125
|
radius: radiusRatio = 0.5,
|
|
133
126
|
offset = 0,
|
|
134
127
|
} = value;
|
|
@@ -137,55 +130,22 @@ export function inferCircularStyle(
|
|
|
137
130
|
const center = coordinate.getCenter();
|
|
138
131
|
|
|
139
132
|
const angle = (startAngle + endAngle) / 2;
|
|
133
|
+
const rotate = inferRotation(angle, autoRotate, rotateToAlignArc);
|
|
140
134
|
|
|
141
|
-
const textStyle =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
textAlign: sign ? 'start' : 'end',
|
|
147
|
-
textBaseline: 'middle',
|
|
148
|
-
rotate,
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
const [r0, r1] = (() => {
|
|
152
|
-
const ratio = position === 'inside' ? radiusRatio : 1;
|
|
153
|
-
const { innerRadius, outerRadius } = arcObject;
|
|
154
|
-
const r0 = innerRadius + (outerRadius - innerRadius) * ratio;
|
|
155
|
-
const r1 = r0 + offset;
|
|
156
|
-
return [r0, r1];
|
|
157
|
-
})();
|
|
158
|
-
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
159
|
-
|
|
160
|
-
const [p0, p1, ...connectorPoints] = ((
|
|
161
|
-
radius: number,
|
|
162
|
-
finalRadius: number,
|
|
163
|
-
) => {
|
|
164
|
-
const [x0, y0] = arcPoint(center, angle, radius);
|
|
165
|
-
const [x, y] = arcPoint(center, angle, finalRadius);
|
|
166
|
-
const length2 = connector ? sign * connectorLength2 : 0;
|
|
167
|
-
const p0 = [x0, y0];
|
|
168
|
-
const p1 = [x + length2, y];
|
|
169
|
-
return [p0, p1, [-length2, 0]] as Vector2[];
|
|
170
|
-
})(r0, r1);
|
|
171
|
-
|
|
172
|
-
const connectorStyle = {
|
|
173
|
-
connector,
|
|
174
|
-
connectorPoints,
|
|
175
|
-
dx: connector ? +connectorDistance * sign : 0,
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
const toPoint = (v: Vector2, x = 'x', y = 'y') => ({ [x]: v[0], [y]: v[1] });
|
|
135
|
+
const textStyle = { textAlign: 'center', textBaseline: 'middle', rotate };
|
|
136
|
+
const { innerRadius, outerRadius } = arcObject;
|
|
137
|
+
const r0 = innerRadius + (outerRadius - innerRadius) * radiusRatio;
|
|
138
|
+
const r1 = r0 + offset;
|
|
139
|
+
const [x0, y0] = pointOfArc(center, angle, r1);
|
|
179
140
|
|
|
180
141
|
return {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
...textStyle
|
|
184
|
-
...connectorStyle,
|
|
142
|
+
x: x0,
|
|
143
|
+
y: y0,
|
|
144
|
+
...textStyle,
|
|
185
145
|
};
|
|
186
146
|
}
|
|
187
147
|
|
|
188
|
-
function inferIdentityStyle(position, points, value, coordinate) {
|
|
148
|
+
export function inferIdentityStyle(position, points, value, coordinate) {
|
|
189
149
|
const { bounds } = value;
|
|
190
150
|
const [p] = bounds;
|
|
191
151
|
return {
|
|
@@ -212,7 +172,7 @@ export function getDefaultStyle(
|
|
|
212
172
|
const inferDefaultStyle = isRadial(coordinate)
|
|
213
173
|
? inferRadialStyle
|
|
214
174
|
: isCircular(coordinate)
|
|
215
|
-
?
|
|
175
|
+
? inferInnerCircularStyle
|
|
216
176
|
: inferNonCircularStyle;
|
|
217
177
|
|
|
218
178
|
return inferDefaultStyle(position, points, value, coordinate);
|
|
@@ -1 +1,121 @@
|
|
|
1
|
-
|
|
1
|
+
import { Coordinate } from '@antv/coord';
|
|
2
|
+
import { Vector2 } from '../../../runtime';
|
|
3
|
+
import { getArcObject } from '../../../shape/utils';
|
|
4
|
+
import { isCircular, isRadial } from '../../../utils/coordinate';
|
|
5
|
+
|
|
6
|
+
import type { LabelPosition } from './default';
|
|
7
|
+
import {
|
|
8
|
+
pointOfArc,
|
|
9
|
+
inferRotation,
|
|
10
|
+
inferIdentityStyle,
|
|
11
|
+
inferRadialStyle,
|
|
12
|
+
inferNonCircularStyle,
|
|
13
|
+
} from './default';
|
|
14
|
+
|
|
15
|
+
export function linePoints(center: Vector2, angle, radius, radius1, offsetX) {
|
|
16
|
+
const [x0, y0] = pointOfArc(center, angle, radius);
|
|
17
|
+
const [x1, y1] = pointOfArc(center, angle, radius1);
|
|
18
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
19
|
+
return [
|
|
20
|
+
[x0, y0],
|
|
21
|
+
[x1, y1],
|
|
22
|
+
[x1 + sign * offsetX, y1],
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function radiusOf(points, value, coordinate) {
|
|
27
|
+
const arcObject = getArcObject(coordinate, points, [value.y, value.y1]);
|
|
28
|
+
const { innerRadius, outerRadius } = arcObject;
|
|
29
|
+
return innerRadius + (outerRadius - innerRadius);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function angleOf(points, value, coordinate) {
|
|
33
|
+
const arcObject = getArcObject(coordinate, points, [value.y, value.y1]);
|
|
34
|
+
const { startAngle, endAngle } = arcObject;
|
|
35
|
+
|
|
36
|
+
return (startAngle + endAngle) / 2;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function inferOutsideCircularStyle(
|
|
40
|
+
position: LabelPosition,
|
|
41
|
+
points: Vector2[],
|
|
42
|
+
value: Record<string, any>,
|
|
43
|
+
coordinate: Coordinate,
|
|
44
|
+
) {
|
|
45
|
+
const {
|
|
46
|
+
autoRotate,
|
|
47
|
+
rotateToAlignArc,
|
|
48
|
+
offset = 0,
|
|
49
|
+
connector = true,
|
|
50
|
+
connectorLength = offset,
|
|
51
|
+
connectorLength2 = 0,
|
|
52
|
+
connectorDistance = 0,
|
|
53
|
+
} = value;
|
|
54
|
+
const center = coordinate.getCenter();
|
|
55
|
+
|
|
56
|
+
const angle = angleOf(points, value, coordinate);
|
|
57
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
58
|
+
|
|
59
|
+
const rotate = inferRotation(angle, autoRotate, rotateToAlignArc);
|
|
60
|
+
const textStyle = {
|
|
61
|
+
textAlign: sign > 0 || isRadial(coordinate) ? 'start' : 'end',
|
|
62
|
+
textBaseline: 'middle',
|
|
63
|
+
rotate,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const radius = radiusOf(points, value, coordinate);
|
|
67
|
+
const radius1 = radius + (connector ? connectorLength : offset);
|
|
68
|
+
|
|
69
|
+
const [[x0, y0], [x1, y1], [x2, y2]] = linePoints(
|
|
70
|
+
center,
|
|
71
|
+
angle,
|
|
72
|
+
radius,
|
|
73
|
+
radius1,
|
|
74
|
+
connector ? connectorLength2 : 0,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const dx = connector ? +connectorDistance * sign : 0;
|
|
78
|
+
|
|
79
|
+
const x = x2 + dx;
|
|
80
|
+
const y = y2;
|
|
81
|
+
const connectorStyle = {
|
|
82
|
+
connector,
|
|
83
|
+
connectorPoints: [
|
|
84
|
+
[x1 - x, y1 - y],
|
|
85
|
+
[x2 - x, y2 - y],
|
|
86
|
+
],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
x0,
|
|
91
|
+
y0,
|
|
92
|
+
x: x2 + dx,
|
|
93
|
+
y: y2,
|
|
94
|
+
...textStyle,
|
|
95
|
+
...connectorStyle,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function outside(
|
|
100
|
+
position: LabelPosition,
|
|
101
|
+
points: Vector2[],
|
|
102
|
+
value: Record<string, any>,
|
|
103
|
+
coordinate: Coordinate,
|
|
104
|
+
) {
|
|
105
|
+
const { bounds } = value;
|
|
106
|
+
// When bounds.length = 1
|
|
107
|
+
// For series mark, such as line and area.
|
|
108
|
+
// The bounds for text is defined with only one point.
|
|
109
|
+
// Use this point as the label position.
|
|
110
|
+
if (bounds.length === 1) {
|
|
111
|
+
return inferIdentityStyle(position, points, value, coordinate);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const inferDefaultStyle = isRadial(coordinate)
|
|
115
|
+
? inferRadialStyle
|
|
116
|
+
: isCircular(coordinate)
|
|
117
|
+
? inferOutsideCircularStyle
|
|
118
|
+
: inferNonCircularStyle;
|
|
119
|
+
|
|
120
|
+
return inferDefaultStyle(position, points, value, coordinate);
|
|
121
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { sub } from '../../../utils/vector';
|
|
3
2
|
import { Vector2 } from '../../../runtime';
|
|
4
3
|
import { isCircular } from '../../../utils/coordinate';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { LabelPosition } from './default';
|
|
5
|
+
import { inferOutsideCircularStyle, radiusOf, angleOf } from './outside';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
|
|
@@ -13,34 +12,28 @@ export function spider(
|
|
|
13
12
|
points: Vector2[],
|
|
14
13
|
value: Record<string, any>,
|
|
15
14
|
coordinate: Coordinate,
|
|
16
|
-
options,
|
|
17
15
|
) {
|
|
18
16
|
if (!isCircular(coordinate)) return {};
|
|
19
|
-
const {
|
|
17
|
+
const { connectorLength, connectorLength2, connectorDistance } = value;
|
|
20
18
|
|
|
21
|
-
const { ...style }: any =
|
|
19
|
+
const { ...style }: any = inferOutsideCircularStyle(
|
|
22
20
|
'outside',
|
|
23
21
|
points,
|
|
24
22
|
value,
|
|
25
23
|
coordinate,
|
|
26
24
|
);
|
|
27
|
-
const { x: coordX, width } = coordinate.getOptions();
|
|
28
25
|
const center = coordinate.getCenter();
|
|
29
|
-
|
|
30
|
-
const
|
|
26
|
+
const radius = radiusOf(points, value, coordinate);
|
|
27
|
+
const angle = angleOf(points, value, coordinate);
|
|
28
|
+
const radius1 = radius + connectorLength + connectorLength2;
|
|
29
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
31
30
|
|
|
32
|
-
const
|
|
33
|
-
const edgeX1 = coordX + width - margin;
|
|
31
|
+
const newX = center[0] + (radius1 + +connectorDistance) * sign;
|
|
34
32
|
|
|
35
|
-
const { x: originX
|
|
36
|
-
const dx =
|
|
33
|
+
const { x: originX } = style;
|
|
34
|
+
const dx = newX - originX;
|
|
37
35
|
style.x += dx;
|
|
38
|
-
|
|
39
|
-
const { x, y } = style;
|
|
40
|
-
const p0 = sub([x0, y0], center);
|
|
41
|
-
const p1 = sub([0, y], center);
|
|
42
|
-
const p1x = p0[1] ? (p0[0] * p1[1]) / p0[1] + center[0] : x;
|
|
43
|
-
style.connectorPoints = [[p1x - x, 0]];
|
|
36
|
+
style.connectorPoints[0][0] -= dx;
|
|
44
37
|
|
|
45
38
|
return style;
|
|
46
39
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { PolarCoordinate } from 'spec';
|
|
3
2
|
import { Vector2 } from '../../../runtime';
|
|
4
3
|
import { getRadius, isCircular } from '../../../utils/coordinate';
|
|
5
4
|
import { angleWithQuadrant } from '../../../utils/vector';
|
|
6
|
-
import {
|
|
5
|
+
import { LabelPosition, pointOfArc } from './default';
|
|
6
|
+
import { inferOutsideCircularStyle } from './outside';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Surround label transform is used to make labels surround circular.
|
|
@@ -13,30 +13,28 @@ export function surround(
|
|
|
13
13
|
points: Vector2[],
|
|
14
14
|
value: Record<string, any>,
|
|
15
15
|
coordinate: Coordinate,
|
|
16
|
-
options,
|
|
17
16
|
) {
|
|
18
17
|
if (!isCircular(coordinate)) return {};
|
|
18
|
+
const { connectorLength, connectorLength2, connectorDistance } = value;
|
|
19
19
|
|
|
20
|
-
const {
|
|
21
|
-
const { ...style }: any = inferCircularStyle(
|
|
20
|
+
const { ...style }: any = inferOutsideCircularStyle(
|
|
22
21
|
'outside',
|
|
23
22
|
points,
|
|
24
23
|
value,
|
|
25
24
|
coordinate,
|
|
26
25
|
);
|
|
26
|
+
const { x0, y0 } = style;
|
|
27
|
+
|
|
27
28
|
const center = coordinate.getCenter();
|
|
28
|
-
const radius = getRadius(coordinate)
|
|
29
|
+
const radius = getRadius(coordinate);
|
|
30
|
+
const radius1 = radius + connectorLength;
|
|
31
|
+
const angle = angleWithQuadrant([x0 - center[0], y0 - center[1]]);
|
|
32
|
+
const sign = Math.sin(angle) > 0 ? 1 : -1;
|
|
33
|
+
|
|
34
|
+
const [newX, newY] = pointOfArc(center, angle, radius1);
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
const labelAngle = angleWithQuadrant([x0 - center[0], y0 - center[1]]);
|
|
32
|
-
const length2 = connector
|
|
33
|
-
? connectorLength2 * (Math.sin(labelAngle) < 0 ? -1 : 1)
|
|
34
|
-
: 0;
|
|
35
|
-
const newX = center[0] + Math.sin(labelAngle) * radius;
|
|
36
|
-
const newY = center[1] - Math.cos(labelAngle) * radius;
|
|
37
|
-
style.x = newX + length2;
|
|
36
|
+
style.x = newX + (connectorLength2 + connectorDistance) * sign;
|
|
38
37
|
style.y = newY;
|
|
39
|
-
style.connectorPoints = [[-length2, 0]];
|
|
40
38
|
|
|
41
39
|
return style;
|
|
42
40
|
}
|
package/src/shape/line/curve.ts
CHANGED
|
@@ -87,7 +87,7 @@ export const Curve: SC<CurveOptions> = (options) => {
|
|
|
87
87
|
// Compute styles.
|
|
88
88
|
const { mark, shape, defaultShape } = value;
|
|
89
89
|
const {
|
|
90
|
-
|
|
90
|
+
defaultColor,
|
|
91
91
|
lineWidth: defaultSize,
|
|
92
92
|
...defaults
|
|
93
93
|
} = getShapeTheme(theme, mark, shape, defaultShape);
|
package/src/shape/lineXY/line.ts
CHANGED
|
@@ -35,13 +35,13 @@ export const Line: SC<LineOptions> = (options) => {
|
|
|
35
35
|
const { ...style } = options;
|
|
36
36
|
return (points, value, coordinate, theme) => {
|
|
37
37
|
const { mark, shape, defaultShape } = value;
|
|
38
|
-
const {
|
|
38
|
+
const { defaultColor, lineWidth, ...shapeTheme } = getShapeTheme(
|
|
39
39
|
theme,
|
|
40
40
|
mark,
|
|
41
41
|
shape,
|
|
42
42
|
defaultShape,
|
|
43
43
|
);
|
|
44
|
-
const { color =
|
|
44
|
+
const { color = defaultColor, size = lineWidth } = value;
|
|
45
45
|
|
|
46
46
|
const path = getPath(points, coordinate);
|
|
47
47
|
const transform = getTransform(coordinate, value.transform);
|
package/src/shape/link/arc.ts
CHANGED
|
@@ -17,13 +17,13 @@ export const Arc: SC<ArcOptions> = (options) => {
|
|
|
17
17
|
const { ...style } = options;
|
|
18
18
|
return (points, value, coordinate, theme) => {
|
|
19
19
|
const { mark, shape, defaultShape } = value;
|
|
20
|
-
const {
|
|
20
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
21
21
|
theme,
|
|
22
22
|
mark,
|
|
23
23
|
shape,
|
|
24
24
|
defaultShape,
|
|
25
25
|
);
|
|
26
|
-
const { color =
|
|
26
|
+
const { color = defaultColor, transform } = value;
|
|
27
27
|
const [from, to] = points;
|
|
28
28
|
|
|
29
29
|
const path = d3path();
|
package/src/shape/link/link.ts
CHANGED
|
@@ -13,13 +13,13 @@ export const Link: SC<LinkOptions> = (options) => {
|
|
|
13
13
|
const { arrowSize, ...style } = options;
|
|
14
14
|
return (points, value, coordinate, theme) => {
|
|
15
15
|
const { mark, shape, defaultShape } = value;
|
|
16
|
-
const {
|
|
16
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
17
17
|
theme,
|
|
18
18
|
mark,
|
|
19
19
|
shape,
|
|
20
20
|
defaultShape,
|
|
21
21
|
);
|
|
22
|
-
const { color =
|
|
22
|
+
const { color = defaultColor, transform } = value;
|
|
23
23
|
const [from, to] = points;
|
|
24
24
|
|
|
25
25
|
// Draw line
|
package/src/shape/link/smooth.ts
CHANGED
|
@@ -13,13 +13,13 @@ export const Smooth: SC<SmoothOptions> = (options) => {
|
|
|
13
13
|
const { ...style } = options;
|
|
14
14
|
return (points, value, coordinate, theme) => {
|
|
15
15
|
const { mark, shape, defaultShape } = value;
|
|
16
|
-
const {
|
|
16
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
17
17
|
theme,
|
|
18
18
|
mark,
|
|
19
19
|
shape,
|
|
20
20
|
defaultShape,
|
|
21
21
|
);
|
|
22
|
-
const { color =
|
|
22
|
+
const { color = defaultColor, transform } = value;
|
|
23
23
|
const [from, to] = points;
|
|
24
24
|
|
|
25
25
|
const path = d3path();
|
package/src/shape/link/vhv.ts
CHANGED
|
@@ -66,13 +66,13 @@ export const VHV: SC<VHVOptions> = (options) => {
|
|
|
66
66
|
const { cornerRatio = 1 / 3, ...style } = options;
|
|
67
67
|
return (points, value, coordinate, theme) => {
|
|
68
68
|
const { mark, shape, defaultShape } = value;
|
|
69
|
-
const {
|
|
69
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
70
70
|
theme,
|
|
71
71
|
mark,
|
|
72
72
|
shape,
|
|
73
73
|
defaultShape,
|
|
74
74
|
);
|
|
75
|
-
const { color =
|
|
75
|
+
const { color = defaultColor, transform } = value;
|
|
76
76
|
const [from, to] = points;
|
|
77
77
|
|
|
78
78
|
const path = getVHVPath(from, to, coordinate, cornerRatio);
|
package/src/shape/point/color.ts
CHANGED
|
@@ -46,11 +46,12 @@ export const Color: SC<ColorOptions> = (options) => {
|
|
|
46
46
|
const path = Symbols[symbol] || Symbols.point;
|
|
47
47
|
return (points, value, coordinate, theme) => {
|
|
48
48
|
const { mark, shape, defaultShape } = value;
|
|
49
|
-
const {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
const { defaultColor, lineWidth, ...defaults } = getShapeTheme(
|
|
50
|
+
theme,
|
|
51
|
+
mark,
|
|
52
|
+
shape,
|
|
53
|
+
defaultShape,
|
|
54
|
+
);
|
|
54
55
|
const finalLineWidth = style.stroke ? lineWidth || 1 : lineWidth;
|
|
55
56
|
const { color = defaultColor, transform, opacity } = value;
|
|
56
57
|
const [cx, cy] = getOrigin(points);
|
|
@@ -48,7 +48,7 @@ export const Polygon: SC<PolygonOptions> = (options) => {
|
|
|
48
48
|
const { ...style } = options;
|
|
49
49
|
return (points, value, coordinate, theme) => {
|
|
50
50
|
const { mark, shape, defaultShape, color, transform } = value;
|
|
51
|
-
const {
|
|
51
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
52
52
|
theme,
|
|
53
53
|
mark,
|
|
54
54
|
shape,
|
|
@@ -60,8 +60,8 @@ export const Polygon: SC<PolygonOptions> = (options) => {
|
|
|
60
60
|
return select(new GPath())
|
|
61
61
|
.call(applyStyle, shapeTheme)
|
|
62
62
|
.style('d', path.toString())
|
|
63
|
-
.style('stroke', color ||
|
|
64
|
-
.style('fill', color ||
|
|
63
|
+
.style('stroke', color || defaultColor)
|
|
64
|
+
.style('fill', color || defaultColor)
|
|
65
65
|
.style('transform', transform)
|
|
66
66
|
.call(applyStyle, style)
|
|
67
67
|
.node();
|
|
@@ -74,7 +74,7 @@ export const Ribbon: SC<RibbonOptions> = (options) => {
|
|
|
74
74
|
const { ...style } = options;
|
|
75
75
|
return (points, value, coordinate, theme) => {
|
|
76
76
|
const { mark, shape, defaultShape, color, transform } = value;
|
|
77
|
-
const {
|
|
77
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
78
78
|
theme,
|
|
79
79
|
mark,
|
|
80
80
|
shape,
|
|
@@ -86,8 +86,8 @@ export const Ribbon: SC<RibbonOptions> = (options) => {
|
|
|
86
86
|
return select(new GPath())
|
|
87
87
|
.call(applyStyle, shapeTheme)
|
|
88
88
|
.style('d', path.toString())
|
|
89
|
-
.style('fill', color ||
|
|
90
|
-
.style('stroke', color ||
|
|
89
|
+
.style('fill', color || defaultColor)
|
|
90
|
+
.style('stroke', color || defaultColor)
|
|
91
91
|
.style('transform', transform)
|
|
92
92
|
.call(applyStyle, style)
|
|
93
93
|
.node();
|
|
@@ -99,7 +99,10 @@ function inferConnectorPath(
|
|
|
99
99
|
]);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const P: any = [[x0 - x1, y0 - y1]].concat(
|
|
102
|
+
const P: any = [[x0 - x1, y0 - y1]].concat(
|
|
103
|
+
controlPoints.length ? controlPoints : [0, 0],
|
|
104
|
+
);
|
|
105
|
+
|
|
103
106
|
const p0 = [coordCenter[0] - x1, coordCenter[1] - y1] as Vector2;
|
|
104
107
|
const [p1, p2] = P;
|
|
105
108
|
// If angle is smaller than 90, which will cause connector overlap with element.
|
package/src/shape/text/badge.ts
CHANGED
|
@@ -60,13 +60,18 @@ export const Badge: SC<BadgeOptions> = (options) => {
|
|
|
60
60
|
const { ...style } = options;
|
|
61
61
|
return (points, value, coordinate, theme) => {
|
|
62
62
|
const { mark, shape, defaultShape } = value;
|
|
63
|
-
const shapeTheme = getShapeTheme(
|
|
63
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
64
|
+
theme,
|
|
65
|
+
mark,
|
|
66
|
+
shape,
|
|
67
|
+
defaultShape,
|
|
68
|
+
);
|
|
64
69
|
const { color, text = '' } = value;
|
|
65
70
|
|
|
66
71
|
const textStyle = {
|
|
67
72
|
text: String(text),
|
|
68
|
-
stroke: color,
|
|
69
|
-
fill: color,
|
|
73
|
+
stroke: color || defaultColor,
|
|
74
|
+
fill: color || defaultColor,
|
|
70
75
|
};
|
|
71
76
|
|
|
72
77
|
const [[x0, y0]] = points;
|
package/src/shape/text/text.ts
CHANGED
|
@@ -12,7 +12,7 @@ export const Text: SC<TextOptions> = (options) => {
|
|
|
12
12
|
const { ...style } = options;
|
|
13
13
|
return (points, value, coordinate, theme) => {
|
|
14
14
|
const { mark, shape, defaultShape } = value;
|
|
15
|
-
const shapeTheme = getShapeTheme(theme, mark, shape, defaultShape);
|
|
15
|
+
const { ...shapeTheme } = getShapeTheme(theme, mark, shape, defaultShape);
|
|
16
16
|
const { color, text = '', fontSize, rotate = 0, transform = '' } = value;
|
|
17
17
|
|
|
18
18
|
const textStyle = {
|
package/src/shape/utils.ts
CHANGED
|
@@ -193,6 +193,10 @@ export function getArcObject(
|
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Get the mark.shape's style object.
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
196
200
|
export function getShapeTheme(
|
|
197
201
|
theme: G2Theme,
|
|
198
202
|
mark: string,
|
|
@@ -201,12 +205,9 @@ export function getShapeTheme(
|
|
|
201
205
|
) {
|
|
202
206
|
const { defaultColor } = theme;
|
|
203
207
|
const markTheme = theme[mark] || {};
|
|
208
|
+
const shapeTheme = markTheme[shape] || markTheme[defaultShape];
|
|
204
209
|
|
|
205
|
-
return Object.assign(
|
|
206
|
-
{},
|
|
207
|
-
{ fill: defaultColor, stroke: defaultColor },
|
|
208
|
-
markTheme[shape] || markTheme[defaultShape],
|
|
209
|
-
);
|
|
210
|
+
return Object.assign({ defaultColor }, shapeTheme);
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
/**
|
|
@@ -13,7 +13,7 @@ export const Vector: SC<VectorOptions> = (options) => {
|
|
|
13
13
|
const { arrowSize = '40%', ...style } = options;
|
|
14
14
|
return (points, value, coordinate, theme) => {
|
|
15
15
|
const { mark, shape, defaultShape, color, transform } = value;
|
|
16
|
-
const {
|
|
16
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
17
17
|
theme,
|
|
18
18
|
mark,
|
|
19
19
|
shape,
|
|
@@ -38,8 +38,8 @@ export const Vector: SC<VectorOptions> = (options) => {
|
|
|
38
38
|
return select(new Path())
|
|
39
39
|
.call(applyStyle, shapeTheme)
|
|
40
40
|
.style('d', path.toString())
|
|
41
|
-
.style('stroke', color ||
|
|
42
|
-
.style('fill', color ||
|
|
41
|
+
.style('stroke', color || defaultColor)
|
|
42
|
+
.style('fill', color || defaultColor)
|
|
43
43
|
.style('transform', transform)
|
|
44
44
|
.call(applyStyle, style)
|
|
45
45
|
.node();
|
package/src/spec/action.ts
CHANGED