@antv/g2 5.0.13 → 5.0.15
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 +35 -0
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/animation/morphing.js +1 -2
- package/esm/animation/morphing.js.map +1 -1
- package/esm/api/utils.js +2 -2
- package/esm/api/utils.js.map +1 -1
- package/esm/component/slider.js +16 -4
- package/esm/component/slider.js.map +1 -1
- package/esm/composition/facetRect.js +1 -1
- package/esm/composition/facetRect.js.map +1 -1
- package/esm/interaction/brushFilter.js +3 -2
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/legendFilter.js +4 -1
- package/esm/interaction/legendFilter.js.map +1 -1
- package/esm/interaction/sliderFilter.js +28 -20
- package/esm/interaction/sliderFilter.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +2 -2
- package/esm/interaction/tooltip.js +48 -36
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/mark/line.js +1 -1
- package/esm/mark/line.js.map +1 -1
- package/esm/mark/utils.js +3 -3
- package/esm/mark/utils.js.map +1 -1
- package/esm/runtime/component.d.ts +1 -1
- package/esm/runtime/component.js +42 -24
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +39 -10
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +7 -2
- package/esm/runtime/plot.js.map +1 -1
- package/esm/shape/area/curve.js +1 -1
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/line/trail.js +4 -1
- package/esm/shape/line/trail.js.map +1 -1
- package/esm/spec/mark.d.ts +1 -0
- package/esm/theme/academy.js +2 -2
- package/esm/theme/academy.js.map +1 -1
- package/esm/theme/classic.js +2 -2
- package/esm/theme/classic.js.map +1 -1
- package/esm/theme/classicDark.js +2 -2
- package/esm/theme/classicDark.js.map +1 -1
- package/esm/transform/maybeGradient.js +3 -2
- package/esm/transform/maybeGradient.js.map +1 -1
- package/esm/utils/helper.d.ts +1 -0
- package/esm/utils/helper.js +15 -1
- package/esm/utils/helper.js.map +1 -1
- package/lib/animation/morphing.js +1 -2
- package/lib/animation/morphing.js.map +1 -1
- package/lib/api/utils.js +2 -2
- package/lib/api/utils.js.map +1 -1
- package/lib/component/slider.js +16 -4
- package/lib/component/slider.js.map +1 -1
- package/lib/composition/facetRect.js +1 -1
- package/lib/composition/facetRect.js.map +1 -1
- package/lib/interaction/brushFilter.js +3 -2
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/legendFilter.js +4 -1
- package/lib/interaction/legendFilter.js.map +1 -1
- package/lib/interaction/sliderFilter.js +28 -20
- package/lib/interaction/sliderFilter.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +2 -2
- package/lib/interaction/tooltip.js +48 -36
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/mark/line.js +1 -1
- package/lib/mark/line.js.map +1 -1
- package/lib/mark/utils.js +3 -3
- package/lib/mark/utils.js.map +1 -1
- package/lib/runtime/component.d.ts +1 -1
- package/lib/runtime/component.js +42 -24
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +38 -9
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +6 -1
- package/lib/runtime/plot.js.map +1 -1
- package/lib/shape/area/curve.js +1 -1
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/line/trail.js +4 -1
- package/lib/shape/line/trail.js.map +1 -1
- package/lib/spec/mark.d.ts +1 -0
- package/lib/theme/academy.js +2 -2
- package/lib/theme/academy.js.map +1 -1
- package/lib/theme/classic.js +2 -2
- package/lib/theme/classic.js.map +1 -1
- package/lib/theme/classicDark.js +2 -2
- package/lib/theme/classicDark.js.map +1 -1
- package/lib/transform/maybeGradient.js +3 -2
- package/lib/transform/maybeGradient.js.map +1 -1
- package/lib/utils/helper.d.ts +1 -0
- package/lib/utils/helper.js +16 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +1 -1
- package/src/animation/morphing.ts +1 -2
- package/src/api/utils.ts +2 -2
- package/src/component/slider.ts +22 -6
- package/src/composition/facetRect.ts +1 -1
- package/src/interaction/brushFilter.ts +3 -2
- package/src/interaction/legendFilter.ts +4 -1
- package/src/interaction/sliderFilter.ts +14 -6
- package/src/interaction/tooltip.ts +52 -34
- package/src/mark/line.ts +1 -1
- package/src/mark/utils.ts +3 -3
- package/src/runtime/component.ts +59 -31
- package/src/runtime/layout.ts +48 -22
- package/src/runtime/plot.ts +8 -2
- package/src/shape/area/curve.ts +1 -1
- package/src/shape/line/trail.ts +3 -1
- package/src/spec/mark.ts +1 -0
- package/src/theme/academy.ts +2 -2
- package/src/theme/classic.ts +2 -2
- package/src/theme/classicDark.ts +2 -2
- package/src/transform/maybeGradient.ts +4 -3
- package/src/utils/helper.ts +24 -1
package/src/mark/line.ts
CHANGED
|
@@ -95,8 +95,8 @@ Line.props = {
|
|
|
95
95
|
],
|
|
96
96
|
preInference: [
|
|
97
97
|
...basePreInference(),
|
|
98
|
-
{ type: 'maybeSeries' },
|
|
99
98
|
{ type: 'maybeGradient' },
|
|
99
|
+
{ type: 'maybeSeries' },
|
|
100
100
|
],
|
|
101
101
|
postInference: [...basePostInference(), ...tooltip1d(), ...tooltipXd()],
|
|
102
102
|
interaction: {
|
package/src/mark/utils.ts
CHANGED
|
@@ -102,12 +102,12 @@ export function p(d) {
|
|
|
102
102
|
|
|
103
103
|
export function visualMark(index: number[], scale, value, coordinate) {
|
|
104
104
|
const { x: X, y: Y } = value;
|
|
105
|
-
const {
|
|
105
|
+
const { innerWidth, innerHeight } = coordinate.getOptions();
|
|
106
106
|
const P: Vector2[][] = Array.from(index, (i) => {
|
|
107
107
|
const x0 = X[i];
|
|
108
108
|
const y0 = Y[i];
|
|
109
|
-
const x = typeof x0 === 'string' ? p(x0) *
|
|
110
|
-
const y = typeof y0 === 'string' ? p(y0) *
|
|
109
|
+
const x = typeof x0 === 'string' ? p(x0) * innerWidth : +x0;
|
|
110
|
+
const y = typeof y0 === 'string' ? p(y0) * innerHeight : +y0;
|
|
111
111
|
return [[x, y]];
|
|
112
112
|
});
|
|
113
113
|
return [index, P];
|
package/src/runtime/component.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { Coordinate } from '@antv/coord';
|
|
5
5
|
import { deepMix, isEqual } from '@antv/util';
|
|
6
|
-
import {
|
|
6
|
+
import { groups, max, sum } from 'd3-array';
|
|
7
7
|
import { format } from 'd3-format';
|
|
8
8
|
import { DisplayObject, Text } from '@antv/g';
|
|
9
9
|
import {
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
isTranspose,
|
|
29
29
|
} from './coordinate';
|
|
30
30
|
import { useLibrary } from './library';
|
|
31
|
-
import { isValidScale
|
|
31
|
+
import { isValidScale } from './scale';
|
|
32
32
|
import {
|
|
33
33
|
G2MarkState,
|
|
34
34
|
G2Theme,
|
|
@@ -90,7 +90,7 @@ export function inferComponent(
|
|
|
90
90
|
position: defaultPosition,
|
|
91
91
|
orientation: defaultOrientation,
|
|
92
92
|
order: defaultOrder,
|
|
93
|
-
|
|
93
|
+
defaultSize,
|
|
94
94
|
...titleOptions,
|
|
95
95
|
});
|
|
96
96
|
}
|
|
@@ -135,7 +135,7 @@ export function inferComponent(
|
|
|
135
135
|
const defaultCrossPadding = isVertical ? DCP[1] : DCP[0];
|
|
136
136
|
|
|
137
137
|
const {
|
|
138
|
-
size
|
|
138
|
+
size,
|
|
139
139
|
order = defaultOrder,
|
|
140
140
|
length = defaultLength,
|
|
141
141
|
padding = defaultPadding,
|
|
@@ -145,6 +145,7 @@ export function inferComponent(
|
|
|
145
145
|
components.push({
|
|
146
146
|
title: field,
|
|
147
147
|
...partialGuide,
|
|
148
|
+
defaultSize,
|
|
148
149
|
length,
|
|
149
150
|
position,
|
|
150
151
|
orientation,
|
|
@@ -523,7 +524,7 @@ function inferScrollableComponents(
|
|
|
523
524
|
const { defaultPosition, defaultSize, defaultOrder } = props;
|
|
524
525
|
return {
|
|
525
526
|
position: defaultPosition,
|
|
526
|
-
|
|
527
|
+
defaultSize,
|
|
527
528
|
order: defaultOrder,
|
|
528
529
|
type: componentType,
|
|
529
530
|
...options,
|
|
@@ -562,6 +563,7 @@ export function computeComponentSize(
|
|
|
562
563
|
if (t.startsWith('group')) return computeGroupSize;
|
|
563
564
|
if (t.startsWith('legendContinuous')) return computeContinuousLegendSize;
|
|
564
565
|
if (t === 'legendCategory') return computeCategoryLegendSize;
|
|
566
|
+
if (t.startsWith('slider')) return computeSliderSize;
|
|
565
567
|
return () => {};
|
|
566
568
|
};
|
|
567
569
|
return createCompute()(
|
|
@@ -603,6 +605,23 @@ function computeGroupSize(
|
|
|
603
605
|
children.forEach((d) => (d.size = maxSize));
|
|
604
606
|
}
|
|
605
607
|
|
|
608
|
+
function computeSliderSize(
|
|
609
|
+
component: G2GuideComponentOptions,
|
|
610
|
+
crossSize: number,
|
|
611
|
+
crossPadding: [number, number],
|
|
612
|
+
position: GCP,
|
|
613
|
+
theme: G2Theme,
|
|
614
|
+
library: G2Library,
|
|
615
|
+
) {
|
|
616
|
+
const styleOf = () => {
|
|
617
|
+
const { slider } = theme;
|
|
618
|
+
return deepMix({}, slider, component.style);
|
|
619
|
+
};
|
|
620
|
+
const { trackSize, handleIconSize } = styleOf();
|
|
621
|
+
const size = Math.max(trackSize, handleIconSize * 2.4);
|
|
622
|
+
component.size = size;
|
|
623
|
+
}
|
|
624
|
+
|
|
606
625
|
function computeAxisSize(
|
|
607
626
|
component: G2GuideComponentOptions,
|
|
608
627
|
crossSize: number,
|
|
@@ -624,25 +643,29 @@ function computeAxisSize(
|
|
|
624
643
|
|
|
625
644
|
// Compute Labels.
|
|
626
645
|
const scale = createScale(component, library);
|
|
627
|
-
const labelBBoxes = computeLabelsBBox(component, scale,
|
|
646
|
+
const labelBBoxes = computeLabelsBBox(component, scale, rest);
|
|
628
647
|
if (labelBBoxes) {
|
|
629
648
|
const maxLabelWidth = max(labelBBoxes, (d) => d.width);
|
|
649
|
+
const maxLabelHeight = max(labelBBoxes, (d) => d.height);
|
|
630
650
|
const paddingTick = tickLength + labelSpacing;
|
|
631
651
|
|
|
632
652
|
if (isVertical) {
|
|
633
653
|
component.size = maxLabelWidth + paddingTick;
|
|
634
654
|
} else {
|
|
635
|
-
|
|
655
|
+
const { tickFilter, style = {} } = component;
|
|
656
|
+
const { labelTransform } = style;
|
|
657
|
+
// If the labels can't be placed horizontally, and labelTransform is unset,
|
|
636
658
|
// rotate 90 deg to display them.
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
659
|
+
if (
|
|
660
|
+
overflowX(scale, labelBBoxes, crossSize, crossPadding, tickFilter) &&
|
|
661
|
+
!labelTransform
|
|
662
|
+
) {
|
|
640
663
|
component.style = {
|
|
641
|
-
...
|
|
664
|
+
...style,
|
|
642
665
|
labelTransform: 'rotate(90)',
|
|
643
666
|
};
|
|
667
|
+
component.size = maxLabelWidth + paddingTick;
|
|
644
668
|
} else {
|
|
645
|
-
const maxLabelHeight = max(labelBBoxes, (d) => d.height);
|
|
646
669
|
component.size = maxLabelHeight + paddingTick;
|
|
647
670
|
}
|
|
648
671
|
}
|
|
@@ -693,7 +716,7 @@ function computeContinuousLegendSize(
|
|
|
693
716
|
|
|
694
717
|
// Compute labels.
|
|
695
718
|
const scale = createScale(component, library);
|
|
696
|
-
const labelBBoxes = computeLabelsBBox(component, scale,
|
|
719
|
+
const labelBBoxes = computeLabelsBBox(component, scale, rest);
|
|
697
720
|
if (labelBBoxes) {
|
|
698
721
|
const key = isVertical ? 'width' : 'height';
|
|
699
722
|
const size = max(labelBBoxes, (d) => d[key]);
|
|
@@ -747,13 +770,7 @@ function computeCategoryLegendSize(
|
|
|
747
770
|
const titleBBox = computeTitleBBox(component, rest);
|
|
748
771
|
|
|
749
772
|
const scale = createScale(component, library);
|
|
750
|
-
const labelBBoxes = computeLabelsBBox(
|
|
751
|
-
component,
|
|
752
|
-
scale,
|
|
753
|
-
isVertical,
|
|
754
|
-
rest,
|
|
755
|
-
'itemLabel',
|
|
756
|
-
);
|
|
773
|
+
const labelBBoxes = computeLabelsBBox(component, scale, rest, 'itemLabel');
|
|
757
774
|
|
|
758
775
|
const height = Math.max(labelBBoxes[0].height, itemMarkerSize) + rowPadding;
|
|
759
776
|
const widthOf = (w, padding = 0) =>
|
|
@@ -859,7 +876,6 @@ export function createScale(
|
|
|
859
876
|
export function computeLabelsBBox(
|
|
860
877
|
component: G2GuideComponentOptions,
|
|
861
878
|
scale: Scale,
|
|
862
|
-
isVertical: boolean,
|
|
863
879
|
style: Record<string, any>,
|
|
864
880
|
key = 'label',
|
|
865
881
|
) {
|
|
@@ -868,22 +884,30 @@ export function computeLabelsBBox(
|
|
|
868
884
|
|
|
869
885
|
// Get labels to be rendered.
|
|
870
886
|
const labels = labelsOf(scale, labelFormatter, tickFilter);
|
|
871
|
-
const
|
|
872
|
-
const
|
|
873
|
-
|
|
874
|
-
Object.entries(
|
|
887
|
+
const labelStyle = subObject(style, key);
|
|
888
|
+
const labelStyles = labels.map((d, i) =>
|
|
889
|
+
Object.fromEntries(
|
|
890
|
+
Object.entries(labelStyle).map(([key, value]) => [
|
|
875
891
|
key,
|
|
876
892
|
typeof value === 'function' ? value(d, i) : value,
|
|
877
893
|
]),
|
|
878
|
-
)
|
|
879
|
-
|
|
880
|
-
|
|
894
|
+
),
|
|
895
|
+
);
|
|
896
|
+
const labelBBoxes = labels.map((d, i) => {
|
|
897
|
+
const normalizeStyle = labelStyles[i];
|
|
881
898
|
return computeLabelSize(d, normalizeStyle);
|
|
882
899
|
});
|
|
883
900
|
|
|
884
901
|
// Cache boxes to avoid computed twice.
|
|
885
|
-
|
|
886
|
-
|
|
902
|
+
// @todo GUI use untransformed bbox, so it can't cache if
|
|
903
|
+
// label.style has transform attributes.
|
|
904
|
+
const hasTransform = labelStyles.some((d) => d.transform);
|
|
905
|
+
if (!hasTransform) {
|
|
906
|
+
const I = labels.map((_, i) => i);
|
|
907
|
+
component.indexBBox = new Map(
|
|
908
|
+
I.map((i) => [i, [labels[i], labelBBoxes[i]]]),
|
|
909
|
+
);
|
|
910
|
+
}
|
|
887
911
|
|
|
888
912
|
return labelBBoxes;
|
|
889
913
|
}
|
|
@@ -897,8 +921,12 @@ export function computeTitleBBox(
|
|
|
897
921
|
const { title: styleTitle } = style;
|
|
898
922
|
if (isFalsy(title) || isFalsy(styleTitle) || title === undefined) return null;
|
|
899
923
|
const titleStyle = subObject(style, 'title');
|
|
924
|
+
const { direction, transform } = titleStyle;
|
|
900
925
|
const titleText = Array.isArray(title) ? title.join(',') : title;
|
|
901
|
-
const titleBBox = computeLabelSize(titleText,
|
|
926
|
+
const titleBBox = computeLabelSize(titleText, {
|
|
927
|
+
...titleStyle,
|
|
928
|
+
transform: transform || direction === 'vertical' ? 'rotate(-90)' : '',
|
|
929
|
+
});
|
|
902
930
|
return titleBBox;
|
|
903
931
|
}
|
|
904
932
|
|
package/src/runtime/layout.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
|
|
|
2
2
|
import { ascending, group, max, sum } from 'd3-array';
|
|
3
3
|
import { deepMix } from '@antv/util';
|
|
4
4
|
import { isParallel, isPolar, isRadar, radiusOf } from '../utils/coordinate';
|
|
5
|
-
import { capitalizeFirst } from '../utils/helper';
|
|
5
|
+
import { capitalizeFirst, defined } from '../utils/helper';
|
|
6
6
|
import { divide } from '../utils/array';
|
|
7
7
|
import { camelCase } from '../utils/string';
|
|
8
8
|
import {
|
|
@@ -199,12 +199,15 @@ function computeInset(
|
|
|
199
199
|
const maxLabelSpacing = max(styles, (d) => d.labelSpacing ?? 0);
|
|
200
200
|
|
|
201
201
|
// Compute labelBBoxes.
|
|
202
|
-
const labelBBoxes = axes
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
202
|
+
const labelBBoxes = axes
|
|
203
|
+
.flatMap((component, i) => {
|
|
204
|
+
const style = styles[i];
|
|
205
|
+
const scale = createScale(component, library);
|
|
206
|
+
const labels = computeLabelsBBox(component, scale, style);
|
|
207
|
+
return labels;
|
|
208
|
+
})
|
|
209
|
+
.filter(defined);
|
|
210
|
+
|
|
208
211
|
const size = max(labelBBoxes, (d) => d.height) + maxLabelSpacing;
|
|
209
212
|
|
|
210
213
|
// Compute titles.
|
|
@@ -254,32 +257,55 @@ function computePadding(
|
|
|
254
257
|
paddingTop,
|
|
255
258
|
paddingRight,
|
|
256
259
|
};
|
|
260
|
+
|
|
257
261
|
for (const position of positions) {
|
|
258
262
|
const key = `padding${capitalizeFirst(camelCase(position))}`;
|
|
263
|
+
const components = positionComponents.get(position) || [];
|
|
259
264
|
const value = layout[key];
|
|
260
|
-
|
|
261
|
-
if (
|
|
265
|
+
const defaultSizeOf = (d) => {
|
|
266
|
+
if (d.size === undefined) d.size = d.defaultSize;
|
|
267
|
+
};
|
|
268
|
+
const sizeOf = (d) => {
|
|
269
|
+
if (d.type === 'group') {
|
|
270
|
+
d.children.forEach(defaultSizeOf);
|
|
271
|
+
d.size = max(d.children, (d) => (d as any).size);
|
|
272
|
+
} else {
|
|
273
|
+
d.size = d.defaultSize;
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
const autoSizeOf = (d) => {
|
|
277
|
+
if (d.size) return;
|
|
278
|
+
if (value !== 'auto') sizeOf(d);
|
|
279
|
+
else {
|
|
280
|
+
// Compute component size dynamically.
|
|
281
|
+
computeComponentSize(
|
|
282
|
+
d,
|
|
283
|
+
crossSize,
|
|
284
|
+
crossPadding,
|
|
285
|
+
position,
|
|
286
|
+
theme,
|
|
287
|
+
library,
|
|
288
|
+
);
|
|
289
|
+
defaultSizeOf(d);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// Specified padding.
|
|
294
|
+
if (typeof value === 'number') {
|
|
295
|
+
components.forEach(defaultSizeOf);
|
|
296
|
+
} else {
|
|
297
|
+
// Compute padding dynamically.
|
|
298
|
+
if (components.length === 0) {
|
|
262
299
|
layout[key] = 30;
|
|
263
300
|
} else {
|
|
264
|
-
const components = positionComponents.get(position);
|
|
265
301
|
const grouped = groupComponents(components, crossSize);
|
|
266
|
-
|
|
267
|
-
grouped.forEach((component) =>
|
|
268
|
-
computeComponentSize(
|
|
269
|
-
component,
|
|
270
|
-
crossSize,
|
|
271
|
-
crossPadding,
|
|
272
|
-
position,
|
|
273
|
-
theme,
|
|
274
|
-
library,
|
|
275
|
-
),
|
|
276
|
-
);
|
|
277
|
-
}
|
|
302
|
+
grouped.forEach(autoSizeOf);
|
|
278
303
|
const totalSize = grouped.reduce((sum, { size }) => sum + size, 0);
|
|
279
304
|
layout[key] = totalSize;
|
|
280
305
|
}
|
|
281
306
|
}
|
|
282
307
|
}
|
|
308
|
+
|
|
283
309
|
return layout;
|
|
284
310
|
}
|
|
285
311
|
|
package/src/runtime/plot.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Vector2 } from '@antv/coord';
|
|
2
2
|
import { DisplayObject, IAnimation as GAnimation, Rect } from '@antv/g';
|
|
3
3
|
import { deepMix, upperFirst } from '@antv/util';
|
|
4
|
-
import { group } from 'd3-array';
|
|
4
|
+
import { group, groups } from 'd3-array';
|
|
5
5
|
import { format } from 'd3-format';
|
|
6
6
|
import { mapObject } from '../utils/array';
|
|
7
7
|
import { ChartEvent } from '../utils/event';
|
|
@@ -799,9 +799,15 @@ async function plotView(
|
|
|
799
799
|
|
|
800
800
|
// Render components.
|
|
801
801
|
// @todo renderComponent return ctor and options.
|
|
802
|
+
// Key for each type of component.
|
|
803
|
+
// Index them grouped by position.
|
|
804
|
+
for (const [, C] of groups(components, (d) => `${d.type}-${d.position}`)) {
|
|
805
|
+
C.forEach((d, i) => (d.index = i));
|
|
806
|
+
}
|
|
807
|
+
|
|
802
808
|
const componentsTransitions = selection
|
|
803
809
|
.selectAll(className(COMPONENT_CLASS_NAME))
|
|
804
|
-
.data(components, (d
|
|
810
|
+
.data(components, (d) => `${d.type}-${d.position}-${d.index}`)
|
|
805
811
|
.join(
|
|
806
812
|
(enter) =>
|
|
807
813
|
enter
|
package/src/shape/area/curve.ts
CHANGED
|
@@ -107,7 +107,7 @@ export const Curve: SC<CurveOptions> = (options, context) => {
|
|
|
107
107
|
|
|
108
108
|
const getPathNode = (path) => {
|
|
109
109
|
return select(document.createElement('path', {}))
|
|
110
|
-
.style('d', path)
|
|
110
|
+
.style('d', path || '')
|
|
111
111
|
.call(applyStyle, finalStyle)
|
|
112
112
|
.node();
|
|
113
113
|
};
|
package/src/shape/line/trail.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ShapeComponent as SC } from '../../runtime';
|
|
|
3
3
|
import { select } from '../../utils/selection';
|
|
4
4
|
import { applyStyle } from '../utils';
|
|
5
5
|
import { angle, sub, add, Vector2 } from '../../utils/vector';
|
|
6
|
+
import { defined } from '../../utils/helper';
|
|
6
7
|
import { Curve } from './curve';
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -44,6 +45,7 @@ function stroke(path, p0, p1, s0, s1) {
|
|
|
44
45
|
|
|
45
46
|
export type TrailOptions = Record<string, any>;
|
|
46
47
|
|
|
48
|
+
// @todo Support connect and connectStyle.
|
|
47
49
|
export const Trail: SC<TrailOptions> = (options, context) => {
|
|
48
50
|
const { document } = context;
|
|
49
51
|
return (P, value, defaults) => {
|
|
@@ -55,7 +57,7 @@ export const Trail: SC<TrailOptions> = (options, context) => {
|
|
|
55
57
|
const p1 = P[i + 1];
|
|
56
58
|
const s0 = seriesSize[i];
|
|
57
59
|
const s1 = seriesSize[i + 1];
|
|
58
|
-
stroke(path, p0, p1, s0, s1);
|
|
60
|
+
if ([...p0, ...p1].every(defined)) stroke(path, p0, p1, s0, s1);
|
|
59
61
|
}
|
|
60
62
|
return select(document.createElement('path', {}))
|
|
61
63
|
.call(applyStyle, rest)
|
package/src/spec/mark.ts
CHANGED
|
@@ -153,6 +153,7 @@ export type BaseMark<T extends MarkTypes, C extends string = ChannelTypes> = {
|
|
|
153
153
|
scale?: Partial<Record<C, Scale>>;
|
|
154
154
|
coordinate?: Coordinate;
|
|
155
155
|
style?: Record<string, any>;
|
|
156
|
+
viewStyle?: Record<string, any>;
|
|
156
157
|
state?: Partial<
|
|
157
158
|
Record<
|
|
158
159
|
'active' | 'selected' | 'inactive' | 'unselected',
|
package/src/theme/academy.ts
CHANGED
|
@@ -272,7 +272,7 @@ export const Academy: TC<AcademyOptions> = (options) => {
|
|
|
272
272
|
titlePosition: 'left',
|
|
273
273
|
titleSpacing: 4,
|
|
274
274
|
titleTextBaseline: 'middle',
|
|
275
|
-
|
|
275
|
+
titleDirection: 'vertical',
|
|
276
276
|
titleTransformOrigin: 'center',
|
|
277
277
|
},
|
|
278
278
|
axisRight: {
|
|
@@ -283,7 +283,7 @@ export const Academy: TC<AcademyOptions> = (options) => {
|
|
|
283
283
|
titlePosition: 'right',
|
|
284
284
|
titleSpacing: 0,
|
|
285
285
|
titleTextBaseline: 'top',
|
|
286
|
-
|
|
286
|
+
titleDirection: 'vertical',
|
|
287
287
|
titleTransformOrigin: 'center',
|
|
288
288
|
},
|
|
289
289
|
axisLinear: {
|
package/src/theme/classic.ts
CHANGED
|
@@ -274,7 +274,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
274
274
|
titlePosition: 'left',
|
|
275
275
|
titleSpacing: 10,
|
|
276
276
|
titleTextBaseline: 'middle',
|
|
277
|
-
|
|
277
|
+
titleDirection: 'vertical',
|
|
278
278
|
titleTransformOrigin: 'center',
|
|
279
279
|
},
|
|
280
280
|
axisRight: {
|
|
@@ -286,7 +286,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
286
286
|
titlePosition: 'right',
|
|
287
287
|
titleSpacing: 0,
|
|
288
288
|
titleTextBaseline: 'top',
|
|
289
|
-
|
|
289
|
+
titleDirection: 'vertical',
|
|
290
290
|
titleTransformOrigin: 'center',
|
|
291
291
|
},
|
|
292
292
|
axisLinear: {
|
package/src/theme/classicDark.ts
CHANGED
|
@@ -272,7 +272,7 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
|
|
|
272
272
|
titlePosition: 'left',
|
|
273
273
|
titleSpacing: 10,
|
|
274
274
|
titleTextBaseline: 'middle',
|
|
275
|
-
|
|
275
|
+
titleDirection: 'vertical',
|
|
276
276
|
titleTransformOrigin: 'center',
|
|
277
277
|
},
|
|
278
278
|
axisRight: {
|
|
@@ -283,7 +283,7 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
|
|
|
283
283
|
titlePosition: 'right',
|
|
284
284
|
titleSpacing: 0,
|
|
285
285
|
titleTextBaseline: 'top',
|
|
286
|
-
|
|
286
|
+
titleDirection: 'vertical',
|
|
287
287
|
titleTransformOrigin: 'center',
|
|
288
288
|
},
|
|
289
289
|
axisLinear: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { constant, visualColumn } from './utils/helper';
|
|
4
4
|
|
|
5
5
|
export type MaybeGradientOptions = Record<string, never>;
|
|
6
6
|
|
|
@@ -10,9 +10,10 @@ export type MaybeGradientOptions = Record<string, never>;
|
|
|
10
10
|
*/
|
|
11
11
|
export const MaybeGradient: TC<MaybeGradientOptions> = () => {
|
|
12
12
|
return (I, mark) => {
|
|
13
|
-
const { style = {} } = mark;
|
|
13
|
+
const { style = {}, encode } = mark;
|
|
14
|
+
const { series } = encode;
|
|
14
15
|
const { gradient } = style;
|
|
15
|
-
if (!gradient) return [I, mark];
|
|
16
|
+
if (!gradient || series) return [I, mark];
|
|
16
17
|
return [
|
|
17
18
|
I,
|
|
18
19
|
deepMix({}, mark, {
|
package/src/utils/helper.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import { lowerFirst, upperFirst } from '@antv/util';
|
|
2
|
+
import { lowerFirst, upperFirst, isPlainObject } from '@antv/util';
|
|
3
3
|
|
|
4
4
|
export function identity<T>(x: T): T {
|
|
5
5
|
return x;
|
|
@@ -146,3 +146,26 @@ export function isStrictObject(d: any): boolean {
|
|
|
146
146
|
export function isUnset(value) {
|
|
147
147
|
return value === null || value === false;
|
|
148
148
|
}
|
|
149
|
+
|
|
150
|
+
export function deepAssign(
|
|
151
|
+
dist: Record<string, unknown>,
|
|
152
|
+
src: Record<string, unknown>,
|
|
153
|
+
maxLevel = 5,
|
|
154
|
+
level = 0,
|
|
155
|
+
): Record<string, unknown> {
|
|
156
|
+
if (level >= maxLevel) return;
|
|
157
|
+
for (const key of Object.keys(src)) {
|
|
158
|
+
const value = src[key];
|
|
159
|
+
if (!isPlainObject(value) || !isPlainObject(dist[key])) {
|
|
160
|
+
dist[key] = value;
|
|
161
|
+
} else {
|
|
162
|
+
deepAssign(
|
|
163
|
+
dist[key] as Record<string, unknown>,
|
|
164
|
+
value as Record<string, unknown>,
|
|
165
|
+
maxLevel,
|
|
166
|
+
level + 1,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return dist;
|
|
171
|
+
}
|