@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
|
@@ -72,10 +72,6 @@ function hideTooltip(root) {
|
|
|
72
72
|
if (tooltipElement) tooltipElement.hide();
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function unique(data) {
|
|
76
|
-
return Array.from(new Set(data));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
75
|
function filterDefined(obj) {
|
|
80
76
|
return Object.fromEntries(
|
|
81
77
|
Object.entries(obj).filter(([, value]) => defined(value)),
|
|
@@ -135,13 +131,20 @@ function normalizeTooltip(d) {
|
|
|
135
131
|
return isStrictObject(d) ? d : { value: d === undefined ? d : `${d}` };
|
|
136
132
|
}
|
|
137
133
|
|
|
134
|
+
function uniqueTitles(titles) {
|
|
135
|
+
const valueTitle = new Map(
|
|
136
|
+
titles.map((d) => [d instanceof Date ? +d : d, d]),
|
|
137
|
+
);
|
|
138
|
+
return Array.from(valueTitle.values());
|
|
139
|
+
}
|
|
140
|
+
|
|
138
141
|
function groupItems(
|
|
139
142
|
elements,
|
|
140
143
|
item,
|
|
141
144
|
scale,
|
|
142
145
|
data = elements.map((d) => d['__data__']),
|
|
143
146
|
) {
|
|
144
|
-
const T =
|
|
147
|
+
const T = uniqueTitles(data.map((d) => d.title)).filter(defined);
|
|
145
148
|
const items = data.flatMap((datum, i) => {
|
|
146
149
|
const element = elements[i];
|
|
147
150
|
const { title, ...rest } = datum;
|
|
@@ -162,7 +165,7 @@ function groupItems(
|
|
|
162
165
|
name,
|
|
163
166
|
color,
|
|
164
167
|
value,
|
|
165
|
-
...filterDefined(item({ channel: key, value
|
|
168
|
+
...filterDefined(item({ channel: key, value })),
|
|
166
169
|
};
|
|
167
170
|
})
|
|
168
171
|
.filter(({ value }) => value !== undefined);
|
|
@@ -40,19 +40,28 @@ export function mousePosition(target, event) {
|
|
|
40
40
|
return [offsetX - x, offsetY - y];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @todo Pass bbox rather than calc it here.
|
|
45
|
+
*/
|
|
46
|
+
export function brushMousePosition(target, event) {
|
|
44
47
|
const { offsetX, offsetY } = event;
|
|
45
|
-
const
|
|
46
|
-
const {
|
|
47
|
-
min: [x, y],
|
|
48
|
-
max: [x1, y1],
|
|
49
|
-
} = bbox;
|
|
48
|
+
const [x, y, x1, y1] = boundsOfBrushArea(target);
|
|
50
49
|
return [
|
|
51
50
|
Math.min(x1, Math.max(x, offsetX)) - x,
|
|
52
51
|
Math.min(y1, Math.max(y, offsetY)) - y,
|
|
53
52
|
];
|
|
54
53
|
}
|
|
55
54
|
|
|
55
|
+
export function boundsOfBrushArea(target) {
|
|
56
|
+
// Calc bbox after clipping.
|
|
57
|
+
const bbox = target.getRenderBounds();
|
|
58
|
+
const {
|
|
59
|
+
min: [x0, y0],
|
|
60
|
+
max: [x1, y1],
|
|
61
|
+
} = bbox;
|
|
62
|
+
return [x0, y0, x1, y1];
|
|
63
|
+
}
|
|
64
|
+
|
|
56
65
|
export function applyDefaultsHighlightedStyle(
|
|
57
66
|
style: Record<string, any>,
|
|
58
67
|
): Record<string, any> {
|
package/src/mark/area.ts
CHANGED
package/src/mark/boxplot.ts
CHANGED
|
@@ -56,7 +56,7 @@ function OutlierY() {
|
|
|
56
56
|
|
|
57
57
|
export const Boxplot: CC<BoxPlotOptions> = (options) => {
|
|
58
58
|
return () => {
|
|
59
|
-
const { data, encode, style = {} } = options;
|
|
59
|
+
const { data, encode, style = {}, ...rest } = options;
|
|
60
60
|
const { extend = false, ...restStyle } = style;
|
|
61
61
|
const { y } = encode;
|
|
62
62
|
const encodeY = { y, y1: y, y2: y, y3: y, y4: y };
|
|
@@ -79,6 +79,7 @@ export const Boxplot: CC<BoxPlotOptions> = (options) => {
|
|
|
79
79
|
],
|
|
80
80
|
encode: { ...encode, ...encodeY },
|
|
81
81
|
style: restStyle,
|
|
82
|
+
...rest,
|
|
82
83
|
},
|
|
83
84
|
];
|
|
84
85
|
}
|
|
@@ -99,6 +100,7 @@ export const Boxplot: CC<BoxPlotOptions> = (options) => {
|
|
|
99
100
|
],
|
|
100
101
|
encode: { ...encode, ...encodeY },
|
|
101
102
|
style: boxStyle,
|
|
103
|
+
...rest,
|
|
102
104
|
},
|
|
103
105
|
// Draw outliers.
|
|
104
106
|
{
|
package/src/runtime/component.ts
CHANGED
|
@@ -48,20 +48,17 @@ export function inferComponent(
|
|
|
48
48
|
if (guide === null) return false;
|
|
49
49
|
return true;
|
|
50
50
|
});
|
|
51
|
-
const sliders =
|
|
51
|
+
const sliders = inferScrollComponents(partialOptions, scales, library);
|
|
52
52
|
const components = [...partialComponents, ...sliders];
|
|
53
53
|
if (title) {
|
|
54
54
|
const { props } = createGuideComponent('title');
|
|
55
55
|
const { defaultPosition, defaultOrder, defaultSize } = props;
|
|
56
|
-
const titleOptions = typeof title === 'string' ? {
|
|
57
|
-
const size = inferTitleComponentSize(
|
|
58
|
-
deepMix({ size: defaultSize }, theme, titleOptions),
|
|
59
|
-
);
|
|
56
|
+
const titleOptions = typeof title === 'string' ? { title } : title;
|
|
60
57
|
components.push({
|
|
61
58
|
type: 'title',
|
|
62
59
|
position: defaultPosition,
|
|
63
60
|
order: defaultOrder,
|
|
64
|
-
size,
|
|
61
|
+
size: defaultSize,
|
|
65
62
|
...titleOptions,
|
|
66
63
|
});
|
|
67
64
|
}
|
|
@@ -168,7 +165,7 @@ function inferComponentPosition(
|
|
|
168
165
|
'right',
|
|
169
166
|
'top',
|
|
170
167
|
'bottom',
|
|
171
|
-
'
|
|
168
|
+
'centerVertical',
|
|
172
169
|
'center',
|
|
173
170
|
];
|
|
174
171
|
const ordinalPosition = !positions.includes(guide.position)
|
|
@@ -182,9 +179,9 @@ function inferComponentPosition(
|
|
|
182
179
|
if (match === null) return ordinalPosition;
|
|
183
180
|
const index = +match[1];
|
|
184
181
|
if (isTranspose(coordinates)) {
|
|
185
|
-
return index === 0 ? 'top' : '
|
|
182
|
+
return index === 0 ? 'top' : 'centerHorizontal';
|
|
186
183
|
} else {
|
|
187
|
-
return index === 0 ? ordinalPosition : '
|
|
184
|
+
return index === 0 ? ordinalPosition : 'centerVertical';
|
|
188
185
|
}
|
|
189
186
|
} else if (
|
|
190
187
|
(type === 'axisX' && isPolar(coordinates) && !isTranspose(coordinates)) ||
|
|
@@ -214,26 +211,19 @@ function inferComponentPosition(
|
|
|
214
211
|
return ordinalPosition;
|
|
215
212
|
}
|
|
216
213
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// Extra 4px spacing.
|
|
224
|
-
return (text ? titleSize + 4 : 0) + (subtitle ? subtitleSize + spacing : 0);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function inferSliderType(
|
|
228
|
-
name: string,
|
|
229
|
-
coordinates: G2CoordinateOptions[] = [],
|
|
230
|
-
) {
|
|
231
|
-
if (name === 'x') return isTranspose(coordinates) ? 'sliderY' : 'sliderX';
|
|
232
|
-
if (name === 'y') return isTranspose(coordinates) ? 'sliderX' : 'sliderY';
|
|
214
|
+
/**
|
|
215
|
+
* Infer scroll component type.
|
|
216
|
+
*/
|
|
217
|
+
function inferSCType(name: string, type: string, coordinates = []) {
|
|
218
|
+
if (name === 'x') return isTranspose(coordinates) ? `${type}Y` : `${type}X`;
|
|
219
|
+
if (name === 'y') return isTranspose(coordinates) ? `${type}X` : `${type}Y`;
|
|
233
220
|
return null;
|
|
234
221
|
}
|
|
235
222
|
|
|
236
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Infer scroll components, such as slider and scrollbar.
|
|
225
|
+
*/
|
|
226
|
+
function inferScrollComponents(
|
|
237
227
|
partialOptions: G2View,
|
|
238
228
|
scales: G2ScaleOptions[],
|
|
239
229
|
library,
|
|
@@ -244,29 +234,38 @@ function createSliders(
|
|
|
244
234
|
GuideComponent
|
|
245
235
|
>('component', library);
|
|
246
236
|
|
|
247
|
-
const {
|
|
248
|
-
const nameScale = new Map(scales.map((scale) => [scale.name, scale]));
|
|
237
|
+
const { coordinates } = partialOptions;
|
|
249
238
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
239
|
+
function normalized(
|
|
240
|
+
type: string,
|
|
241
|
+
channelName: string,
|
|
242
|
+
scale: G2ScaleOptions,
|
|
243
|
+
options: Record<string, any>,
|
|
244
|
+
) {
|
|
245
|
+
const componentType = inferSCType(channelName, type, coordinates);
|
|
246
|
+
if (!options || !componentType) return;
|
|
258
247
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
248
|
+
const { props } = createGuideComponent(componentType);
|
|
249
|
+
const { defaultPosition, defaultSize, defaultOrder } = props;
|
|
250
|
+
return {
|
|
251
|
+
position: defaultPosition,
|
|
252
|
+
size: defaultSize,
|
|
253
|
+
order: defaultOrder,
|
|
254
|
+
type: componentType,
|
|
255
|
+
...options,
|
|
256
|
+
scale,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
return scales
|
|
261
|
+
.filter((d) => d.slider || d.scrollbar)
|
|
262
|
+
.flatMap((scale) => {
|
|
263
|
+
const { slider, scrollbar, name: channelName } = scale;
|
|
264
|
+
|
|
265
|
+
return [
|
|
266
|
+
normalized('slider', channelName, scale, slider),
|
|
267
|
+
normalized('scrollbar', channelName, scale, scrollbar),
|
|
268
|
+
];
|
|
270
269
|
})
|
|
271
270
|
.filter((d) => !!d);
|
|
272
271
|
}
|
package/src/runtime/layout.ts
CHANGED
|
@@ -123,8 +123,8 @@ export function placeComponents(
|
|
|
123
123
|
right: [width - pr, pt, pr, innerHeight, 1, false, ascending],
|
|
124
124
|
bottom: [pl, height - pb, innerWidth, pb, 0, false, ascending],
|
|
125
125
|
left: [0, pt, pl, innerHeight, 1, true, ascending],
|
|
126
|
-
centerHorizontal: [pl, pt, innerWidth, innerHeight, -1, null, null],
|
|
127
126
|
centerVertical: [pl, pt, innerWidth, innerHeight, -1, null, null],
|
|
127
|
+
centerHorizontal: [pl, pt, innerWidth, innerHeight, -1, null, null],
|
|
128
128
|
arc: [pl, pt, innerWidth, innerHeight, -1, null, null],
|
|
129
129
|
arcY: [pl, pt, innerWidth, innerHeight, -1, null, null],
|
|
130
130
|
arcInner: [pl, pt, innerWidth, innerHeight, -1, null, null],
|
|
@@ -134,10 +134,10 @@ export function placeComponents(
|
|
|
134
134
|
|
|
135
135
|
for (const [key, components] of positionComponents.entries()) {
|
|
136
136
|
const area = section[key];
|
|
137
|
-
if (key === '
|
|
138
|
-
placeCenterHorizontal(components, coordinate, area);
|
|
139
|
-
} else if (key === 'centerVertical') {
|
|
137
|
+
if (key === 'centerVertical') {
|
|
140
138
|
placeCenterVertical(components, coordinate, area);
|
|
139
|
+
} else if (key === 'centerHorizontal') {
|
|
140
|
+
placeCenterHorizontal(components, coordinate, area);
|
|
141
141
|
} else if (key === 'arc') {
|
|
142
142
|
placeArc(components, coordinate, area);
|
|
143
143
|
} else if (key === 'arcY') {
|
|
@@ -152,7 +152,7 @@ export function placeComponents(
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
function
|
|
155
|
+
function placeCenterVertical(
|
|
156
156
|
components: G2GuideComponentOptions[],
|
|
157
157
|
coordinate: Coordinate,
|
|
158
158
|
area: SectionArea,
|
|
@@ -177,7 +177,7 @@ function placeCenterHorizontal(
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
function
|
|
180
|
+
function placeCenterHorizontal(
|
|
181
181
|
components: G2GuideComponentOptions[],
|
|
182
182
|
coordinate: Coordinate,
|
|
183
183
|
area: SectionArea,
|
package/src/runtime/plot.ts
CHANGED
|
@@ -1204,6 +1204,11 @@ function shapeName(mark: G2Mark, name: string): string {
|
|
|
1204
1204
|
*/
|
|
1205
1205
|
function updateLayers(selection: Selection, marks: G2Mark[]) {
|
|
1206
1206
|
const facet = (d) => (d.class !== undefined ? `${d.class}` : '');
|
|
1207
|
+
|
|
1208
|
+
// Skip for empty selection, it can't append nodes.
|
|
1209
|
+
const nodes = selection.nodes();
|
|
1210
|
+
if (nodes.length === 0) return;
|
|
1211
|
+
|
|
1207
1212
|
selection
|
|
1208
1213
|
.selectAll(className(MAIN_LAYER_CLASS_NAME))
|
|
1209
1214
|
.data(marks, (d) => d.key)
|
|
@@ -1231,7 +1236,7 @@ function className(...names: string[]): string {
|
|
|
1231
1236
|
function applyClip(selection, clip?: boolean) {
|
|
1232
1237
|
if (!selection.node()) return;
|
|
1233
1238
|
selection.style('clipPath', (data) => {
|
|
1234
|
-
if (!clip) return;
|
|
1239
|
+
if (!clip) return null;
|
|
1235
1240
|
const {
|
|
1236
1241
|
paddingTop: y,
|
|
1237
1242
|
paddingLeft: x,
|
package/src/runtime/render.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Canvas as GCanvas, DisplayObject, Group } from '@antv/g';
|
|
2
2
|
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
|
|
3
3
|
import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
|
|
4
|
-
import {
|
|
4
|
+
import { deepMix } from '@antv/util';
|
|
5
5
|
import { createLibrary } from '../stdlib';
|
|
6
6
|
import { select } from '../utils/selection';
|
|
7
7
|
import { emitEvent, CHART_LIFE_CIRCLE, offEvent } from '../utils/event';
|
|
8
|
-
import { getChartSize } from '../utils/size';
|
|
9
8
|
import { G2Context, G2ViewTree } from './types/options';
|
|
10
9
|
import { plot } from './plot';
|
|
11
10
|
|
|
@@ -64,18 +63,11 @@ export function render<T extends G2ViewTree = G2ViewTree>(
|
|
|
64
63
|
callback?: () => void,
|
|
65
64
|
): HTMLElement {
|
|
66
65
|
// Initialize the context if it is not provided.
|
|
67
|
-
const { width = 640, height = 480,
|
|
66
|
+
const { width = 640, height = 480, on } = options;
|
|
68
67
|
const keyed = inferKeys(options);
|
|
69
68
|
const { canvas = Canvas(width, height), library = createLibrary() } = context;
|
|
70
69
|
context.canvas = canvas;
|
|
71
70
|
context.library = library;
|
|
72
|
-
|
|
73
|
-
if (autoFit && !context.bindAutoFit) {
|
|
74
|
-
// Bind the autoFit event once.
|
|
75
|
-
bindAutoFit(options, context);
|
|
76
|
-
context.bindAutoFit = true;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
71
|
canvas.resize(width, height);
|
|
80
72
|
|
|
81
73
|
emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_RENDER);
|
|
@@ -104,8 +96,10 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
|
|
|
104
96
|
const keyed = inferKeys(options);
|
|
105
97
|
const { library = createLibrary(), group = new Group() } = context;
|
|
106
98
|
|
|
107
|
-
if (
|
|
108
|
-
throw new Error(
|
|
99
|
+
if (!group?.parentElement) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`renderToMountedElement can't render chart to unmounted group.`,
|
|
102
|
+
);
|
|
109
103
|
}
|
|
110
104
|
|
|
111
105
|
const selection = select(group);
|
|
@@ -132,9 +126,6 @@ export function destroy<T extends G2ViewTree = G2ViewTree>(
|
|
|
132
126
|
if (canvas) {
|
|
133
127
|
canvas.destroy();
|
|
134
128
|
}
|
|
135
|
-
|
|
136
|
-
// Unbind chart events.
|
|
137
|
-
unbindAutoFit(options, context);
|
|
138
129
|
offEvent(on);
|
|
139
130
|
}
|
|
140
131
|
|
|
@@ -143,46 +134,3 @@ function normalizeContainer(container: HTMLElement | string): HTMLElement {
|
|
|
143
134
|
? document.getElementById(container)
|
|
144
135
|
: container;
|
|
145
136
|
}
|
|
146
|
-
|
|
147
|
-
const onResize = <T extends G2ViewTree = G2ViewTree>(
|
|
148
|
-
options: T,
|
|
149
|
-
context: G2Context = {},
|
|
150
|
-
) =>
|
|
151
|
-
debounce(() => {
|
|
152
|
-
// Update size.
|
|
153
|
-
const { width, height, autoFit } = options;
|
|
154
|
-
const { canvas } = context;
|
|
155
|
-
const container = canvas.getConfig().container as HTMLElement;
|
|
156
|
-
const { width: adjustedWidth, height: adjustedHeight } = getChartSize(
|
|
157
|
-
container,
|
|
158
|
-
autoFit,
|
|
159
|
-
width,
|
|
160
|
-
height,
|
|
161
|
-
);
|
|
162
|
-
const newOptions = {
|
|
163
|
-
...options,
|
|
164
|
-
width: adjustedWidth,
|
|
165
|
-
height: adjustedHeight,
|
|
166
|
-
};
|
|
167
|
-
if (newOptions.width && newOptions.height) render(newOptions, context);
|
|
168
|
-
}, 300);
|
|
169
|
-
|
|
170
|
-
export function bindAutoFit<T extends G2ViewTree = G2ViewTree>(
|
|
171
|
-
options: T,
|
|
172
|
-
context: G2Context = {},
|
|
173
|
-
) {
|
|
174
|
-
const { autoFit } = options;
|
|
175
|
-
if (autoFit) {
|
|
176
|
-
window.addEventListener('resize', onResize(options, context));
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
function unbindAutoFit<T extends G2ViewTree = G2ViewTree>(
|
|
181
|
-
options: T,
|
|
182
|
-
context: G2Context = {},
|
|
183
|
-
) {
|
|
184
|
-
const { autoFit } = options;
|
|
185
|
-
if (autoFit) {
|
|
186
|
-
window.removeEventListener('resize', onResize(options, context));
|
|
187
|
-
}
|
|
188
|
-
}
|
package/src/runtime/transform.ts
CHANGED
|
@@ -149,7 +149,7 @@ export function addGuideToScale(
|
|
|
149
149
|
mark: G2Mark,
|
|
150
150
|
context: TransformContext,
|
|
151
151
|
): [number[], G2Mark] {
|
|
152
|
-
const { axis = {}, legend = {} } = mark;
|
|
152
|
+
const { axis = {}, legend = {}, slider = {}, scrollbar = {} } = mark;
|
|
153
153
|
const normalize = (guide: boolean | Record<string, any>, channel: string) => {
|
|
154
154
|
if (typeof guide === 'boolean') return guide ? {} : null;
|
|
155
155
|
const eachGuide = guide[channel];
|
|
@@ -165,7 +165,11 @@ export function addGuideToScale(
|
|
|
165
165
|
...Object.fromEntries(
|
|
166
166
|
axisChannels.map((channel) => [
|
|
167
167
|
channel,
|
|
168
|
-
{
|
|
168
|
+
{
|
|
169
|
+
guide: normalize(axis, channel),
|
|
170
|
+
slider: normalize(slider, channel),
|
|
171
|
+
scrollbar: normalize(scrollbar, channel),
|
|
172
|
+
},
|
|
169
173
|
]),
|
|
170
174
|
),
|
|
171
175
|
color: { guide: normalize(legend, 'color') },
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
|
-
import { DisplayObject } from '@antv/g';
|
|
2
|
+
import { DisplayObject, TextStyleProps } from '@antv/g';
|
|
3
3
|
import { G2GuideComponentOptions, G2Mark, G2ViewTree } from './options';
|
|
4
4
|
import { LabelTransform, Scale } from './component';
|
|
5
5
|
import { MarkProps } from './mark';
|
|
@@ -8,11 +8,28 @@ import { G2Theme } from './theme';
|
|
|
8
8
|
export type { G2Theme };
|
|
9
9
|
|
|
10
10
|
export type G2Title = {
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Height of title, default is 36.
|
|
13
|
+
*/
|
|
14
|
+
size?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Text of title.
|
|
17
|
+
*/
|
|
18
|
+
title?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Text of subtitle.
|
|
21
|
+
*/
|
|
12
22
|
subtitle?: string | null;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Align method for title.
|
|
25
|
+
*/
|
|
26
|
+
align?: 'left' | 'center' | 'right';
|
|
27
|
+
/**
|
|
28
|
+
* The vertical spacing between title and subtitle, default is 2.
|
|
29
|
+
*/
|
|
30
|
+
spacing?: number;
|
|
31
|
+
} & WithPrefix<Omit<TextStyleProps, 'x' | 'y' | 'text'>, 'title'> & // G.Text style for title.
|
|
32
|
+
WithPrefix<Omit<TextStyleProps, 'x' | 'y' | 'text'>, 'subtitle'>; // G.Text style for subtitle.
|
|
16
33
|
|
|
17
34
|
export type G2ViewDescriptor = {
|
|
18
35
|
scale: Record<string, Scale>;
|
|
@@ -59,10 +76,9 @@ export type Primitive = number | string | boolean | Date;
|
|
|
59
76
|
|
|
60
77
|
export type TabularData = Record<string, Primitive>[];
|
|
61
78
|
|
|
62
|
-
export type WithPrefix<
|
|
63
|
-
string
|
|
64
|
-
|
|
65
|
-
: unknown;
|
|
79
|
+
export type WithPrefix<O extends Record<string, any>, P extends string> = {
|
|
80
|
+
[K in keyof O as `${P}${Capitalize<K & string>}`]?: O[K];
|
|
81
|
+
};
|
|
66
82
|
|
|
67
83
|
export type EncodeFunction = (
|
|
68
84
|
data: Record<string, MaybeArray<Primitive>>[],
|
|
@@ -116,8 +132,8 @@ export type GuideComponentPosition =
|
|
|
116
132
|
| 'left'
|
|
117
133
|
| 'bottom'
|
|
118
134
|
| 'right'
|
|
119
|
-
| 'centerHorizontal'
|
|
120
135
|
| 'centerVertical'
|
|
136
|
+
| 'centerHorizontal'
|
|
121
137
|
| 'center'
|
|
122
138
|
| 'arc'
|
|
123
139
|
| 'arcY'
|
|
@@ -102,6 +102,7 @@ export type G2Mark = {
|
|
|
102
102
|
axis?: boolean | Record<string, any>;
|
|
103
103
|
legend?: boolean | Record<string, any>;
|
|
104
104
|
slider?: Record<string, any>;
|
|
105
|
+
scrollbar?: Record<string, any>;
|
|
105
106
|
filter?: (i: number) => boolean;
|
|
106
107
|
children?: G2MarkChildrenCallback;
|
|
107
108
|
dataDomain?: number;
|
|
@@ -180,9 +181,5 @@ export type G2CompositionOptions = G2BaseComponentOptions<CompositionComponent>;
|
|
|
180
181
|
export type G2AdjustOptions = G2BaseComponentOptions<AdjustComponent>;
|
|
181
182
|
export type G2LabelTransformOptions =
|
|
182
183
|
G2BaseComponentOptions<LabelTransformComponent>;
|
|
183
|
-
export type G2TitleOptions = G2Title
|
|
184
|
-
position?: GuideComponentPosition;
|
|
185
|
-
size?: number;
|
|
186
|
-
zIndex?: number;
|
|
187
|
-
};
|
|
184
|
+
export type G2TitleOptions = G2Title;
|
|
188
185
|
export type G2DataOptions = G2BaseComponent<DataComponent>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextStyleProps, PathStyleProps } from '@antv/g';
|
|
2
|
-
import { WithPrefix } from './common';
|
|
2
|
+
import { G2Title, WithPrefix } from './common';
|
|
3
3
|
|
|
4
4
|
type TupleToUnion<T, U> = T extends [infer F, ...infer R]
|
|
5
5
|
? F extends string
|
|
@@ -81,10 +81,7 @@ type ComponentTheme = {
|
|
|
81
81
|
innerLabel?: LabelStyleProps;
|
|
82
82
|
slider?: any;
|
|
83
83
|
scrollbar?: any;
|
|
84
|
-
title?:
|
|
85
|
-
subtitle?: Omit<TextStyleProps, 'text'> & {
|
|
86
|
-
spacing?: number;
|
|
87
|
-
};
|
|
84
|
+
title?: Partial<G2Title>;
|
|
88
85
|
};
|
|
89
86
|
|
|
90
87
|
type AnimationTheme = {
|
package/src/shape/area/curve.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { area, areaRadial, CurveFactory } from 'd3-shape';
|
|
2
2
|
import { Path } from '@antv/g';
|
|
3
3
|
import { select } from '../../utils/selection';
|
|
4
|
-
import { isPolar } from '../../utils/coordinate';
|
|
4
|
+
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
5
5
|
import { Vector2, ShapeComponent as SC } from '../../runtime';
|
|
6
6
|
import { angleWithQuadrant, sub, dist } from '../../utils/vector';
|
|
7
7
|
import {
|
|
@@ -86,7 +86,7 @@ export const Curve: SC<CurveOptions> = (options) => {
|
|
|
86
86
|
} = options;
|
|
87
87
|
return (P, value, coordinate, theme) => {
|
|
88
88
|
const { mark, shape, defaultShape } = value;
|
|
89
|
-
const {
|
|
89
|
+
const { defaultColor, ...defaults } = getShapeTheme(
|
|
90
90
|
theme,
|
|
91
91
|
mark,
|
|
92
92
|
shape,
|
|
@@ -128,12 +128,19 @@ export const Curve: SC<CurveOptions> = (options) => {
|
|
|
128
128
|
const areaPath = (points) => {
|
|
129
129
|
const Y1 = points.slice(0, points.length / 2);
|
|
130
130
|
const Y0 = points.slice(points.length / 2);
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
return isTranspose(coordinate)
|
|
132
|
+
? area()
|
|
133
|
+
.y((_, idx) => Y1[idx][1])
|
|
134
|
+
.x1((_, idx) => Y1[idx][0])
|
|
135
|
+
.x0((_, idx) => Y0[idx][0])
|
|
136
|
+
.defined((_, idx) => [...Y1[idx], ...Y0[idx]].every(defined))
|
|
137
|
+
.curve(curve)(Y1)
|
|
138
|
+
: area()
|
|
139
|
+
.x((_, idx) => Y1[idx][0])
|
|
140
|
+
.y1((_, idx) => Y1[idx][1])
|
|
141
|
+
.y0((_, idx) => Y0[idx][1])
|
|
142
|
+
.defined((_, idx) => [...Y1[idx], ...Y0[idx]].every(defined))
|
|
143
|
+
.curve(curve)(Y1);
|
|
137
144
|
};
|
|
138
145
|
|
|
139
146
|
// Draw one area of connected defined points.
|
package/src/shape/box/box.ts
CHANGED
|
@@ -77,12 +77,12 @@ export const Box: SC<BoxOptions> = (options) => {
|
|
|
77
77
|
const { ...style } = options;
|
|
78
78
|
return (points, value, coordinate, theme) => {
|
|
79
79
|
const { mark, shape, defaultShape, color, transform } = value;
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
);
|
|
80
|
+
const {
|
|
81
|
+
defaultColor,
|
|
82
|
+
fill = defaultColor,
|
|
83
|
+
stroke = defaultColor,
|
|
84
|
+
...shapeTheme
|
|
85
|
+
} = getShapeTheme(theme, mark, shape, defaultShape);
|
|
86
86
|
|
|
87
87
|
const path = getPath(points, coordinate);
|
|
88
88
|
|
|
@@ -102,8 +102,7 @@ export const Connector: SC<ConnectorOptions> = (options) => {
|
|
|
102
102
|
return (points, value, coordinate, theme) => {
|
|
103
103
|
const { mark, shape, defaultShape } = value;
|
|
104
104
|
const {
|
|
105
|
-
|
|
106
|
-
stroke = fill,
|
|
105
|
+
defaultColor,
|
|
107
106
|
connectLength1 = length1,
|
|
108
107
|
...shapeTheme
|
|
109
108
|
} = getShapeTheme(theme, mark, shape, defaultShape);
|
|
@@ -114,7 +113,7 @@ export const Connector: SC<ConnectorOptions> = (options) => {
|
|
|
114
113
|
return select(new ConnectorPath())
|
|
115
114
|
.call(applyStyle, shapeTheme)
|
|
116
115
|
.style('points', P)
|
|
117
|
-
.style('stroke', color ||
|
|
116
|
+
.style('stroke', color || defaultColor)
|
|
118
117
|
.style('transform', transform)
|
|
119
118
|
.call(applyStyle, style)
|
|
120
119
|
.node();
|
package/src/shape/image/image.ts
CHANGED
|
@@ -9,13 +9,13 @@ export const Image: SC<ImageOptions> = (options) => {
|
|
|
9
9
|
const { ...style } = options;
|
|
10
10
|
return (points, value, coordinate, theme) => {
|
|
11
11
|
const { mark, shape, defaultShape } = value;
|
|
12
|
-
const {
|
|
12
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
13
13
|
theme,
|
|
14
14
|
mark,
|
|
15
15
|
shape,
|
|
16
16
|
defaultShape,
|
|
17
17
|
);
|
|
18
|
-
const { color =
|
|
18
|
+
const { color = defaultColor, src = '', size = 32, transform = '' } = value;
|
|
19
19
|
const { width = size, height = size } = style;
|
|
20
20
|
const [[x0, y0]] = points;
|
|
21
21
|
|
|
@@ -36,7 +36,8 @@ export const Color: SC<ColorOptions> = (options) => {
|
|
|
36
36
|
return (points, value, coordinate, theme) => {
|
|
37
37
|
const { mark, shape, defaultShape } = value;
|
|
38
38
|
const {
|
|
39
|
-
[colorAttribute]: defaultColor,
|
|
39
|
+
// [colorAttribute]: defaultColor,
|
|
40
|
+
defaultColor,
|
|
40
41
|
radius: defaultRadius = 0,
|
|
41
42
|
...defaults
|
|
42
43
|
} = getShapeTheme(theme, mark, shape, defaultShape);
|