@antv/g2 5.0.22 → 5.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +325 -0
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/chart.d.ts +9 -17
- package/esm/api/chart.js.map +1 -1
- package/esm/api/extend.d.ts +5 -1
- package/esm/api/extend.js.map +1 -1
- package/esm/api/index.d.ts +1 -1
- package/esm/api/index.js.map +1 -1
- package/esm/api/library.d.ts +6 -16
- package/esm/api/runtime.js +4 -1
- package/esm/api/runtime.js.map +1 -1
- package/esm/component/axis.js +15 -10
- package/esm/component/axis.js.map +1 -1
- package/esm/component/legendCategory.js +2 -2
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.js +4 -5
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/scrollbar.js +2 -0
- package/esm/component/scrollbar.js.map +1 -1
- package/esm/component/slider.js +2 -0
- package/esm/component/slider.js.map +1 -1
- package/esm/component/title.js +4 -2
- package/esm/component/title.js.map +1 -1
- package/esm/component/utils.d.ts +1 -1
- package/esm/component/utils.js +2 -3
- package/esm/component/utils.js.map +1 -1
- package/esm/composition/facetRect.js +2 -2
- package/esm/composition/facetRect.js.map +1 -1
- package/esm/composition/repeatMatrix.js +3 -3
- package/esm/composition/repeatMatrix.js.map +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/tooltip.js +4 -3
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/lib/builtinlib.d.ts +13 -0
- package/esm/lib/builtinlib.js +21 -0
- package/esm/lib/builtinlib.js.map +1 -0
- package/esm/lib/core.d.ts +2 -12
- package/esm/lib/core.js +8 -19
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/graph.d.ts +5 -0
- package/esm/lib/graph.js +7 -1
- package/esm/lib/graph.js.map +1 -1
- package/esm/lib/plot.d.ts +0 -5
- package/esm/lib/plot.js +2 -7
- package/esm/lib/plot.js.map +1 -1
- package/esm/lib/std.d.ts +6 -16
- package/esm/lib/threed.d.ts +1 -0
- package/esm/lib/threed.js +2 -1
- package/esm/lib/threed.js.map +1 -1
- package/esm/mark/index.d.ts +1 -0
- package/esm/mark/index.js +1 -0
- package/esm/mark/index.js.map +1 -1
- package/esm/mark/line3D.d.ts +7 -0
- package/esm/mark/line3D.js +65 -0
- package/esm/mark/line3D.js.map +1 -0
- package/esm/runtime/component.js +33 -30
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +79 -28
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/library.d.ts +1 -1
- package/esm/runtime/library.js +3 -1
- package/esm/runtime/library.js.map +1 -1
- package/esm/runtime/plot.js +42 -42
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +1 -4
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/scale.js +2 -0
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/types/common.d.ts +3 -1
- package/esm/runtime/types/theme.d.ts +8 -2
- package/esm/shape/connector/connector.js +19 -30
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/index.d.ts +1 -0
- package/esm/shape/index.js +1 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/line3D/line.d.ts +3 -0
- package/esm/shape/line3D/line.js +30 -0
- package/esm/shape/line3D/line.js.map +1 -0
- package/esm/shape/point3D/cube.js +2 -2
- package/esm/shape/point3D/cube.js.map +1 -1
- package/esm/shape/point3D/sphere.js +2 -2
- package/esm/shape/point3D/sphere.js.map +1 -1
- package/esm/theme/classic.js +54 -37
- package/esm/theme/classic.js.map +1 -1
- package/esm/theme/index.d.ts +1 -0
- package/esm/theme/index.js +1 -0
- package/esm/theme/index.js.map +1 -1
- package/esm/theme/light.d.ts +6 -0
- package/esm/theme/light.js +476 -0
- package/esm/theme/light.js.map +1 -0
- package/esm/utils/selection.d.ts +1 -1
- package/esm/utils/selection.js +10 -10
- package/esm/utils/selection.js.map +1 -1
- package/esm/utils/size.js +1 -1
- package/lib/api/chart.d.ts +9 -17
- package/lib/api/chart.js.map +1 -1
- package/lib/api/extend.d.ts +5 -1
- package/lib/api/extend.js.map +1 -1
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/library.d.ts +6 -16
- package/lib/api/runtime.js +4 -1
- package/lib/api/runtime.js.map +1 -1
- package/lib/component/axis.js +14 -9
- package/lib/component/axis.js.map +1 -1
- package/lib/component/legendCategory.js +2 -2
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.js +4 -5
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/scrollbar.js +2 -0
- package/lib/component/scrollbar.js.map +1 -1
- package/lib/component/slider.js +2 -0
- package/lib/component/slider.js.map +1 -1
- package/lib/component/title.js +4 -2
- package/lib/component/title.js.map +1 -1
- package/lib/component/utils.d.ts +1 -1
- package/lib/component/utils.js +2 -3
- package/lib/component/utils.js.map +1 -1
- package/lib/composition/facetRect.js +2 -2
- package/lib/composition/facetRect.js.map +1 -1
- package/lib/composition/repeatMatrix.js +3 -3
- package/lib/composition/repeatMatrix.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +4 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/tooltip.js +4 -3
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/lib/builtinlib.d.ts +13 -0
- package/lib/lib/builtinlib.js +25 -0
- package/lib/lib/builtinlib.js.map +1 -0
- package/lib/lib/core.d.ts +2 -12
- package/lib/lib/core.js +1 -12
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/graph.d.ts +5 -0
- package/lib/lib/graph.js +6 -0
- package/lib/lib/graph.js.map +1 -1
- package/lib/lib/plot.d.ts +0 -5
- package/lib/lib/plot.js +0 -5
- package/lib/lib/plot.js.map +1 -1
- package/lib/lib/std.d.ts +6 -16
- package/lib/lib/threed.d.ts +1 -0
- package/lib/lib/threed.js +1 -0
- package/lib/lib/threed.js.map +1 -1
- package/lib/mark/index.d.ts +1 -0
- package/lib/mark/index.js +3 -1
- package/lib/mark/index.js.map +1 -1
- package/lib/mark/line3D.d.ts +7 -0
- package/lib/mark/line3D.js +69 -0
- package/lib/mark/line3D.js.map +1 -0
- package/lib/runtime/component.js +33 -30
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +77 -26
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/library.d.ts +1 -1
- package/lib/runtime/library.js +3 -1
- package/lib/runtime/library.js.map +1 -1
- package/lib/runtime/plot.js +42 -42
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +1 -4
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/scale.js +2 -0
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/types/common.d.ts +3 -1
- package/lib/runtime/types/theme.d.ts +8 -2
- package/lib/shape/connector/connector.js +19 -30
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/index.d.ts +1 -0
- package/lib/shape/index.js +8 -6
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/line3D/line.d.ts +3 -0
- package/lib/shape/line3D/line.js +34 -0
- package/lib/shape/line3D/line.js.map +1 -0
- package/lib/shape/point3D/cube.js +1 -1
- package/lib/shape/point3D/cube.js.map +1 -1
- package/lib/shape/point3D/sphere.js +1 -1
- package/lib/shape/point3D/sphere.js.map +1 -1
- package/lib/theme/classic.js +54 -37
- package/lib/theme/classic.js.map +1 -1
- package/lib/theme/index.d.ts +1 -0
- package/lib/theme/index.js +3 -1
- package/lib/theme/index.js.map +1 -1
- package/lib/theme/light.d.ts +6 -0
- package/lib/theme/light.js +480 -0
- package/lib/theme/light.js.map +1 -0
- package/lib/utils/selection.d.ts +1 -1
- package/lib/utils/selection.js +10 -10
- package/lib/utils/selection.js.map +1 -1
- package/lib/utils/size.js +1 -1
- package/package.json +4 -4
- package/src/api/chart.ts +3 -0
- package/src/api/extend.ts +6 -1
- package/src/api/index.ts +1 -1
- package/src/api/runtime.ts +6 -3
- package/src/component/axis.ts +17 -13
- package/src/component/legendCategory.ts +3 -5
- package/src/component/legendContinuous.ts +4 -5
- package/src/component/scrollbar.ts +4 -1
- package/src/component/slider.ts +4 -1
- package/src/component/title.ts +3 -3
- package/src/component/utils.ts +1 -3
- package/src/composition/facetRect.ts +4 -3
- package/src/composition/repeatMatrix.ts +4 -3
- package/src/index.ts +10 -1
- package/src/interaction/brushHighlight.ts +1 -1
- package/src/interaction/tooltip.ts +5 -3
- package/src/lib/builtinlib.ts +28 -0
- package/src/lib/core.ts +4 -25
- package/src/lib/graph.ts +7 -1
- package/src/lib/plot.ts +2 -7
- package/src/lib/threed.ts +2 -1
- package/src/mark/index.ts +1 -0
- package/src/mark/line3D.ts +81 -0
- package/src/runtime/component.ts +57 -30
- package/src/runtime/layout.ts +91 -31
- package/src/runtime/library.ts +4 -1
- package/src/runtime/plot.ts +62 -40
- package/src/runtime/render.ts +1 -6
- package/src/runtime/scale.ts +1 -0
- package/src/runtime/types/common.ts +2 -0
- package/src/runtime/types/theme.ts +8 -2
- package/src/shape/connector/connector.ts +41 -47
- package/src/shape/index.ts +1 -0
- package/src/shape/line3D/line.ts +29 -0
- package/src/shape/point3D/cube.ts +2 -2
- package/src/shape/point3D/sphere.ts +2 -2
- package/src/shape/utils.ts +2 -2
- package/src/theme/classic.ts +54 -37
- package/src/theme/index.ts +1 -0
- package/src/theme/light.ts +483 -0
- package/src/utils/selection.ts +11 -11
- package/src/utils/size.ts +1 -1
package/src/runtime/plot.ts
CHANGED
|
@@ -217,20 +217,20 @@ export async function plot<T extends G2ViewTree>(
|
|
|
217
217
|
.attr('className', VIEW_CLASS_NAME)
|
|
218
218
|
.attr('id', (view) => view.key)
|
|
219
219
|
.call(applyTranslate)
|
|
220
|
-
.each(function (view) {
|
|
221
|
-
plotView(view, select(
|
|
222
|
-
enterContainer.set(view,
|
|
220
|
+
.each(function (view, i, element) {
|
|
221
|
+
plotView(view, select(element), transitions, library, context);
|
|
222
|
+
enterContainer.set(view, element);
|
|
223
223
|
}),
|
|
224
224
|
(update) =>
|
|
225
|
-
update.call(applyTranslate).each(function (view) {
|
|
226
|
-
plotView(view, select(
|
|
227
|
-
updateContainer.set(view,
|
|
225
|
+
update.call(applyTranslate).each(function (view, i, element) {
|
|
226
|
+
plotView(view, select(element), transitions, library, context);
|
|
227
|
+
updateContainer.set(view, element);
|
|
228
228
|
}),
|
|
229
229
|
(exit) =>
|
|
230
230
|
exit
|
|
231
|
-
.each(function () {
|
|
231
|
+
.each(function (d, i, element) {
|
|
232
232
|
// Remove existed interactions.
|
|
233
|
-
const interactions =
|
|
233
|
+
const interactions = element['nameInteraction'].values();
|
|
234
234
|
for (const interaction of interactions) {
|
|
235
235
|
interaction.destroy();
|
|
236
236
|
}
|
|
@@ -775,8 +775,8 @@ async function plotView(
|
|
|
775
775
|
.style('y', (i) => areaLayouts[i].y)
|
|
776
776
|
.style('width', (i) => areaLayouts[i].width)
|
|
777
777
|
.style('height', (i) => areaLayouts[i].height)
|
|
778
|
-
.each(function (i) {
|
|
779
|
-
applyStyle(select(
|
|
778
|
+
.each(function (i, d, element) {
|
|
779
|
+
applyStyle(select(element), areaStyles[i]);
|
|
780
780
|
});
|
|
781
781
|
let px = 0;
|
|
782
782
|
let py = 0;
|
|
@@ -847,7 +847,11 @@ async function plotView(
|
|
|
847
847
|
),
|
|
848
848
|
),
|
|
849
849
|
(update) =>
|
|
850
|
-
update.transition(function (
|
|
850
|
+
update.transition(function (
|
|
851
|
+
options: G2GuideComponentOptions,
|
|
852
|
+
i,
|
|
853
|
+
element,
|
|
854
|
+
) {
|
|
851
855
|
const { preserve = false } = options;
|
|
852
856
|
if (preserve) return;
|
|
853
857
|
const newComponent = renderComponent(
|
|
@@ -858,7 +862,7 @@ async function plotView(
|
|
|
858
862
|
markState,
|
|
859
863
|
);
|
|
860
864
|
const { attributes } = newComponent;
|
|
861
|
-
const [node] =
|
|
865
|
+
const [node] = element.childNodes;
|
|
862
866
|
return node.update(attributes);
|
|
863
867
|
}),
|
|
864
868
|
)
|
|
@@ -933,8 +937,8 @@ async function plotView(
|
|
|
933
937
|
// Using attribute as alternative for other classNames.
|
|
934
938
|
.attr('className', ELEMENT_CLASS_NAME)
|
|
935
939
|
.attr('markType', type)
|
|
936
|
-
.transition(function (data) {
|
|
937
|
-
return enterFunction(data, [
|
|
940
|
+
.transition(function (data, i, element) {
|
|
941
|
+
return enterFunction(data, [element]);
|
|
938
942
|
}),
|
|
939
943
|
(update) =>
|
|
940
944
|
update.call((selection) => {
|
|
@@ -944,14 +948,15 @@ async function plotView(
|
|
|
944
948
|
return [x, y];
|
|
945
949
|
});
|
|
946
950
|
selection
|
|
947
|
-
.transition(function (data, index) {
|
|
948
|
-
maybeFacetElement(
|
|
951
|
+
.transition(function (data, index, element) {
|
|
952
|
+
maybeFacetElement(element, parent, origin);
|
|
949
953
|
const node = shapeFunction(data, index);
|
|
950
|
-
const animation = updateFunction(data, [
|
|
954
|
+
const animation = updateFunction(data, [element], [node]);
|
|
951
955
|
if (animation !== null) return animation;
|
|
952
|
-
if (
|
|
956
|
+
if (element.nodeName === node.nodeName)
|
|
957
|
+
copyAttributes(element, node);
|
|
953
958
|
else {
|
|
954
|
-
|
|
959
|
+
element.parentNode.replaceChild(node, element);
|
|
955
960
|
node.className = ELEMENT_CLASS_NAME;
|
|
956
961
|
// @ts-ignore
|
|
957
962
|
node.markType = type;
|
|
@@ -963,11 +968,11 @@ async function plotView(
|
|
|
963
968
|
}),
|
|
964
969
|
(exit) => {
|
|
965
970
|
return exit
|
|
966
|
-
.each(function () {
|
|
967
|
-
|
|
971
|
+
.each(function (d, i, element) {
|
|
972
|
+
element.__removed__ = true;
|
|
968
973
|
})
|
|
969
|
-
.transition(function (data) {
|
|
970
|
-
return exitFunction(data, [
|
|
974
|
+
.transition(function (data, i, element) {
|
|
975
|
+
return exitFunction(data, [element]);
|
|
971
976
|
})
|
|
972
977
|
.remove();
|
|
973
978
|
},
|
|
@@ -977,25 +982,33 @@ async function plotView(
|
|
|
977
982
|
.append(shapeFunction)
|
|
978
983
|
.attr('className', ELEMENT_CLASS_NAME)
|
|
979
984
|
.attr('markType', type)
|
|
980
|
-
.transition(function (data) {
|
|
985
|
+
.transition(function (data, i, element) {
|
|
981
986
|
// Remove merged elements after animation finishing.
|
|
982
|
-
const { __fromElements__: fromElements } =
|
|
983
|
-
const transition = updateFunction(data, fromElements, [
|
|
984
|
-
const exit = new Selection(
|
|
987
|
+
const { __fromElements__: fromElements } = element;
|
|
988
|
+
const transition = updateFunction(data, fromElements, [element]);
|
|
989
|
+
const exit = new Selection(
|
|
990
|
+
fromElements,
|
|
991
|
+
null,
|
|
992
|
+
element.parentNode,
|
|
993
|
+
);
|
|
985
994
|
exit.transition(transition).remove();
|
|
986
995
|
return transition;
|
|
987
996
|
}),
|
|
988
997
|
(split) =>
|
|
989
998
|
split
|
|
990
|
-
.transition(function (data) {
|
|
999
|
+
.transition(function (data, i, element) {
|
|
991
1000
|
// Append splitted shapes.
|
|
992
|
-
const enter = new Selection(
|
|
1001
|
+
const enter = new Selection(
|
|
1002
|
+
[],
|
|
1003
|
+
element.__toData__,
|
|
1004
|
+
element.parentNode,
|
|
1005
|
+
);
|
|
993
1006
|
const toElements = enter
|
|
994
1007
|
.append(shapeFunction)
|
|
995
1008
|
.attr('className', ELEMENT_CLASS_NAME)
|
|
996
1009
|
.attr('markType', type)
|
|
997
1010
|
.nodes();
|
|
998
|
-
return updateFunction(data, [
|
|
1011
|
+
return updateFunction(data, [element], toElements);
|
|
999
1012
|
})
|
|
1000
1013
|
// Remove elements to be splitted after animation finishing.
|
|
1001
1014
|
.remove(),
|
|
@@ -1071,11 +1084,11 @@ function plotLabel(
|
|
|
1071
1084
|
.append((d) => labelShapeFunction.get(d)(d))
|
|
1072
1085
|
.attr('className', LABEL_CLASS_NAME),
|
|
1073
1086
|
(update) =>
|
|
1074
|
-
update.each(function (d) {
|
|
1087
|
+
update.each(function (d, i, element) {
|
|
1075
1088
|
// @todo Handle Label with different type.
|
|
1076
1089
|
const shapeFunction = labelShapeFunction.get(d);
|
|
1077
1090
|
const node = shapeFunction(d);
|
|
1078
|
-
copyAttributes(
|
|
1091
|
+
copyAttributes(element, node);
|
|
1079
1092
|
}),
|
|
1080
1093
|
(exit) => exit.remove(),
|
|
1081
1094
|
)
|
|
@@ -1525,7 +1538,7 @@ function createExitFunction(
|
|
|
1525
1538
|
|
|
1526
1539
|
function inferTheme(theme: G2ThemeOptions = {}): G2ThemeOptions {
|
|
1527
1540
|
if (typeof theme === 'string') return { type: theme };
|
|
1528
|
-
const { type = '
|
|
1541
|
+
const { type = 'light', ...rest } = theme;
|
|
1529
1542
|
return { ...rest, type };
|
|
1530
1543
|
}
|
|
1531
1544
|
|
|
@@ -1568,9 +1581,16 @@ function updateBBox(selection: Selection) {
|
|
|
1568
1581
|
|
|
1569
1582
|
function animateBBox(selection: Selection, extent: [number, number]) {
|
|
1570
1583
|
const [delay, duration] = extent;
|
|
1571
|
-
selection.transition(function (data) {
|
|
1572
|
-
const { x, y, width, height } =
|
|
1573
|
-
const {
|
|
1584
|
+
selection.transition(function (data, i, element) {
|
|
1585
|
+
const { x, y, width, height } = element.style;
|
|
1586
|
+
const {
|
|
1587
|
+
paddingLeft,
|
|
1588
|
+
paddingTop,
|
|
1589
|
+
innerWidth,
|
|
1590
|
+
innerHeight,
|
|
1591
|
+
marginLeft,
|
|
1592
|
+
marginTop,
|
|
1593
|
+
} = data;
|
|
1574
1594
|
const keyframes = [
|
|
1575
1595
|
{
|
|
1576
1596
|
x,
|
|
@@ -1579,13 +1599,13 @@ function animateBBox(selection: Selection, extent: [number, number]) {
|
|
|
1579
1599
|
height,
|
|
1580
1600
|
},
|
|
1581
1601
|
{
|
|
1582
|
-
x: paddingLeft,
|
|
1583
|
-
y: paddingTop,
|
|
1602
|
+
x: paddingLeft + marginLeft,
|
|
1603
|
+
y: paddingTop + marginTop,
|
|
1584
1604
|
width: innerWidth,
|
|
1585
1605
|
height: innerHeight,
|
|
1586
1606
|
},
|
|
1587
1607
|
];
|
|
1588
|
-
return
|
|
1608
|
+
return element.animate(keyframes, { delay, duration, fill: 'both' });
|
|
1589
1609
|
});
|
|
1590
1610
|
}
|
|
1591
1611
|
|
|
@@ -1645,10 +1665,12 @@ function applyClip(selection, clip?: boolean) {
|
|
|
1645
1665
|
const {
|
|
1646
1666
|
paddingTop: y,
|
|
1647
1667
|
paddingLeft: x,
|
|
1668
|
+
marginLeft: x1,
|
|
1669
|
+
marginTop: y1,
|
|
1648
1670
|
innerWidth: width,
|
|
1649
1671
|
innerHeight: height,
|
|
1650
1672
|
} = data;
|
|
1651
|
-
return new Rect({ style: { x, y, width, height } });
|
|
1673
|
+
return new Rect({ style: { x: x + x1, y: y + y1, width, height } });
|
|
1652
1674
|
});
|
|
1653
1675
|
}
|
|
1654
1676
|
|
package/src/runtime/render.ts
CHANGED
|
@@ -70,12 +70,7 @@ export function render<T extends G2ViewTree = G2ViewTree>(
|
|
|
70
70
|
},
|
|
71
71
|
): HTMLElement {
|
|
72
72
|
// Initialize the context if it is not provided.
|
|
73
|
-
const { width = 640, height = 480, depth = 0
|
|
74
|
-
if (!theme) {
|
|
75
|
-
error(
|
|
76
|
-
'ChartOptions.theme is required, such as `const chart = new Chart({ theme: "classic"})`.',
|
|
77
|
-
);
|
|
78
|
-
}
|
|
73
|
+
const { width = 640, height = 480, depth = 0 } = options;
|
|
79
74
|
const keyed = inferKeys(options);
|
|
80
75
|
const {
|
|
81
76
|
canvas = Canvas(width, height),
|
package/src/runtime/scale.ts
CHANGED
|
@@ -423,6 +423,7 @@ function categoricalColors(
|
|
|
423
423
|
const { category10: c10, category20: c20 } = theme;
|
|
424
424
|
const defaultPalette = unique(values.flat()).length <= c10.length ? c10 : c20;
|
|
425
425
|
const { palette = defaultPalette, offset } = options;
|
|
426
|
+
if (Array.isArray(palette)) return palette;
|
|
426
427
|
// Built-in palettes have higher priority.
|
|
427
428
|
try {
|
|
428
429
|
return usePalette({ type: palette });
|
|
@@ -195,6 +195,8 @@ export type SectionArea = [
|
|
|
195
195
|
direction: Direction,
|
|
196
196
|
reverse: boolean,
|
|
197
197
|
comparator: (a: Primitive, b: Primitive) => number,
|
|
198
|
+
minX?: number,
|
|
199
|
+
totalWidth?: number,
|
|
198
200
|
];
|
|
199
201
|
|
|
200
202
|
export type Section = Record<GuideComponentPosition, SectionArea>;
|
|
@@ -68,6 +68,8 @@ type InteractionTheme = {
|
|
|
68
68
|
|
|
69
69
|
type ComponentTheme = {
|
|
70
70
|
axis?: any;
|
|
71
|
+
axisX?: any;
|
|
72
|
+
axisY?: any;
|
|
71
73
|
axisLinear?: any;
|
|
72
74
|
axisTop?: any;
|
|
73
75
|
axisBottom?: any;
|
|
@@ -75,6 +77,7 @@ type ComponentTheme = {
|
|
|
75
77
|
axisRight?: any;
|
|
76
78
|
axisRadar?: any;
|
|
77
79
|
axisArc?: any;
|
|
80
|
+
legend?: any;
|
|
78
81
|
legendCategory?: any;
|
|
79
82
|
legendContinuous?: any;
|
|
80
83
|
label?: LabelStyleProps;
|
|
@@ -112,9 +115,12 @@ type AreaTheme = {
|
|
|
112
115
|
};
|
|
113
116
|
|
|
114
117
|
export type G2Theme = {
|
|
118
|
+
padding?: 'auto' | number;
|
|
119
|
+
inset?: 'auto' | number;
|
|
120
|
+
margin?: number;
|
|
115
121
|
color?: string;
|
|
116
|
-
category10?: string;
|
|
117
|
-
category20?: string;
|
|
122
|
+
category10?: string | string[];
|
|
123
|
+
category20?: string | string[];
|
|
118
124
|
size?: number;
|
|
119
125
|
view?: WithPrefix<AreaTheme, 'view'> &
|
|
120
126
|
WithPrefix<AreaTheme, 'plot'> &
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
2
|
import type { PathArray } from '@antv/util';
|
|
3
|
-
import { PathStyleProps } from '@antv/g';
|
|
3
|
+
import { PathStyleProps, Path } from '@antv/g';
|
|
4
4
|
import { Marker } from '@antv/gui';
|
|
5
5
|
import { line as d3line } from 'd3-shape';
|
|
6
6
|
import { ShapeComponent as SC, Vector2, WithPrefix } from '../../runtime';
|
|
7
|
-
import { createElement } from '../../utils/createElement';
|
|
8
7
|
import { isTranspose } from '../../utils/coordinate';
|
|
9
8
|
import { subObject } from '../../utils/helper';
|
|
10
9
|
import { select } from '../../utils/selection';
|
|
@@ -33,51 +32,19 @@ function inferConnectorPath(points: Vector2[]) {
|
|
|
33
32
|
.y((d) => d[1])(points);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
const ConnectorPath = createElement((g) => {
|
|
37
|
-
// Do not copy className to path.
|
|
38
|
-
const {
|
|
39
|
-
points,
|
|
40
|
-
class: className,
|
|
41
|
-
endMarker = true,
|
|
42
|
-
direction,
|
|
43
|
-
...rest
|
|
44
|
-
} = g.attributes;
|
|
45
|
-
|
|
46
|
-
const markerStyle = subObject(rest, 'endMarker');
|
|
47
|
-
const path = inferConnectorPath(points);
|
|
48
|
-
|
|
49
|
-
select(g)
|
|
50
|
-
.maybeAppend('connector', 'path')
|
|
51
|
-
.style('path', path)
|
|
52
|
-
.style(
|
|
53
|
-
'markerEnd',
|
|
54
|
-
endMarker
|
|
55
|
-
? new Marker({
|
|
56
|
-
className: 'marker',
|
|
57
|
-
style: {
|
|
58
|
-
...markerStyle,
|
|
59
|
-
symbol: inferSymbol,
|
|
60
|
-
},
|
|
61
|
-
})
|
|
62
|
-
: null,
|
|
63
|
-
)
|
|
64
|
-
.call(applyStyle, rest);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
35
|
function getPoints(
|
|
68
36
|
coordinate: Coordinate,
|
|
69
37
|
points: Vector2[],
|
|
70
|
-
|
|
38
|
+
offset1: number,
|
|
39
|
+
offset2: number,
|
|
71
40
|
length1 = 0,
|
|
72
41
|
): Vector2[] {
|
|
73
42
|
const [[x0, y0], [x1, y1]] = points;
|
|
74
43
|
|
|
75
44
|
if (isTranspose(coordinate)) {
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
const X1 = x1 + OFFSET;
|
|
45
|
+
const X0 = x0 + offset1;
|
|
46
|
+
const X1 = x1 + offset2;
|
|
79
47
|
const X = X0 + length1;
|
|
80
|
-
|
|
81
48
|
return [
|
|
82
49
|
[X0, y0],
|
|
83
50
|
[X, y0],
|
|
@@ -86,10 +53,9 @@ function getPoints(
|
|
|
86
53
|
];
|
|
87
54
|
}
|
|
88
55
|
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const Y = Y0 + -length1;
|
|
56
|
+
const Y0 = y0 - offset1;
|
|
57
|
+
const Y1 = y1 - offset2;
|
|
58
|
+
const Y = Y0 - length1;
|
|
93
59
|
return [
|
|
94
60
|
[x0, Y0],
|
|
95
61
|
[x0, Y],
|
|
@@ -99,17 +65,45 @@ function getPoints(
|
|
|
99
65
|
}
|
|
100
66
|
|
|
101
67
|
export const Connector: SC<ConnectorOptions> = (options, context) => {
|
|
102
|
-
const {
|
|
68
|
+
const {
|
|
69
|
+
offset = 0,
|
|
70
|
+
offset1 = offset,
|
|
71
|
+
offset2 = offset,
|
|
72
|
+
connectLength1: length1,
|
|
73
|
+
endMarker = true,
|
|
74
|
+
...style
|
|
75
|
+
} = options;
|
|
103
76
|
const { coordinate } = context;
|
|
77
|
+
|
|
104
78
|
return (points, value, defaults) => {
|
|
105
|
-
const { color: defaultColor, connectLength1
|
|
79
|
+
const { color: defaultColor, connectLength1, ...rest } = defaults;
|
|
106
80
|
const { color, transform } = value;
|
|
107
|
-
const P = getPoints(
|
|
108
|
-
|
|
81
|
+
const P = getPoints(
|
|
82
|
+
coordinate,
|
|
83
|
+
points,
|
|
84
|
+
offset1,
|
|
85
|
+
offset2,
|
|
86
|
+
length1 || connectLength1,
|
|
87
|
+
);
|
|
88
|
+
const makerStyle = subObject({ ...style, ...defaults }, 'endMarker');
|
|
89
|
+
|
|
90
|
+
return select(new Path())
|
|
109
91
|
.call(applyStyle, rest)
|
|
110
|
-
.style('
|
|
92
|
+
.style('path', inferConnectorPath(P))
|
|
111
93
|
.style('stroke', color || defaultColor)
|
|
112
94
|
.style('transform', transform)
|
|
95
|
+
.style(
|
|
96
|
+
'markerEnd',
|
|
97
|
+
endMarker
|
|
98
|
+
? new Marker({
|
|
99
|
+
className: 'marker',
|
|
100
|
+
style: {
|
|
101
|
+
...makerStyle,
|
|
102
|
+
symbol: inferSymbol,
|
|
103
|
+
},
|
|
104
|
+
})
|
|
105
|
+
: null,
|
|
106
|
+
)
|
|
113
107
|
.call(applyStyle, style)
|
|
114
108
|
.node();
|
|
115
109
|
};
|
package/src/shape/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { HV as LineHV } from './line/hv';
|
|
|
10
10
|
export { VH as LineVH } from './line/vh';
|
|
11
11
|
export { HVH as LineHVH } from './line/hvh';
|
|
12
12
|
export { Trail as LineTrail } from './line/trail';
|
|
13
|
+
export { Line as Line3DShape } from './line3D/line';
|
|
13
14
|
export { HollowBowtie as PointHollowBowtie } from './point/hollowBowtie';
|
|
14
15
|
export { HollowDiamond as PointHollowDiamond } from './point/hollowDiamond';
|
|
15
16
|
export { HollowHexagon as PointHollowHexagon } from './point/hollowHexagon';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Polyline } from '@antv/g';
|
|
2
|
+
import { applyStyle } from '../utils';
|
|
3
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
4
|
+
import { select } from '../../utils/selection';
|
|
5
|
+
|
|
6
|
+
export type LineOptions = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
export const Line: SC<LineOptions> = (options, context) => {
|
|
9
|
+
return (P, value, defaults) => {
|
|
10
|
+
const { color: defaultColor, lineWidth: defaultSize, ...rest } = defaults;
|
|
11
|
+
const { color = defaultColor, size = defaultSize } = value;
|
|
12
|
+
const stroke = color;
|
|
13
|
+
const finalStyle = {
|
|
14
|
+
isBillboard: true,
|
|
15
|
+
...rest,
|
|
16
|
+
...(stroke && { stroke }),
|
|
17
|
+
...(size && { lineWidth: size }),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return select(new Polyline())
|
|
21
|
+
.style('points', P)
|
|
22
|
+
.call(applyStyle, finalStyle)
|
|
23
|
+
.node();
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Line.props = {
|
|
28
|
+
defaultMarker: 'line',
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MeshLambertMaterial, CubeGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
2
|
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
3
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
4
|
import { select } from '../../utils/selection';
|
|
@@ -28,7 +28,7 @@ export const Cube: SC<CubeOptions> = (options, context) => {
|
|
|
28
28
|
});
|
|
29
29
|
// create a material with Phong lighting model
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
context.cubeMaterial = new
|
|
31
|
+
context.cubeMaterial = new MeshLambertMaterial(device);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return (points, value, defaults) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MeshLambertMaterial, SphereGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
2
|
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
3
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
4
|
import { select } from '../../utils/selection';
|
|
@@ -28,7 +28,7 @@ export const Sphere: SC<SphereOptions> = (options, context) => {
|
|
|
28
28
|
});
|
|
29
29
|
// create a material with Phong lighting model
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
context.sphereMaterial = new
|
|
31
|
+
context.sphereMaterial = new MeshLambertMaterial(device);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return (points, value, defaults) => {
|
package/src/shape/utils.ts
CHANGED
|
@@ -3,10 +3,10 @@ import { Linear } from '@antv/scale';
|
|
|
3
3
|
import { lowerFirst } from '@antv/util';
|
|
4
4
|
import { extent } from 'd3-array';
|
|
5
5
|
import { Path as D3Path } from 'd3-path';
|
|
6
|
-
import {
|
|
6
|
+
import { Primitive, Vector2, Vector3 } from '../runtime';
|
|
7
7
|
import { indexOf } from '../utils/array';
|
|
8
8
|
import { isPolar, isTranspose } from '../utils/coordinate';
|
|
9
|
-
import { Selection } from '../utils/selection';
|
|
9
|
+
import { G2Element, Selection } from '../utils/selection';
|
|
10
10
|
import { angle, angleWithQuadrant, dist, sub } from '../utils/vector';
|
|
11
11
|
|
|
12
12
|
export function applyStyle(
|