@antv/g2 5.0.21 → 5.0.23
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 +308 -0
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/chart.d.ts +4 -1
- package/esm/api/chart.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 +1 -0
- 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/core.d.ts +1 -0
- package/esm/lib/core.js +4 -3
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/std.d.ts +1 -0
- package/esm/runtime/component.js +33 -30
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +78 -28
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +42 -42
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +0 -3
- 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/theme/classic.js +52 -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 +4 -1
- package/lib/api/chart.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 +1 -0
- 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/core.d.ts +1 -0
- package/lib/lib/core.js +1 -0
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/std.d.ts +1 -0
- package/lib/runtime/component.js +33 -30
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +76 -26
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +42 -42
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +0 -3
- 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/theme/classic.js +52 -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 -3
- package/src/api/chart.ts +3 -0
- package/src/api/index.ts +1 -1
- 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/core.ts +4 -3
- package/src/runtime/component.ts +57 -30
- package/src/runtime/layout.ts +90 -31
- package/src/runtime/plot.ts +62 -40
- package/src/runtime/render.ts +0 -5
- 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/utils.ts +2 -2
- package/src/theme/classic.ts +52 -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/component/axis.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
|
|
|
2
2
|
import type { DisplayObject } from '@antv/g';
|
|
3
3
|
import { Axis as AxisComponent } from '@antv/gui';
|
|
4
4
|
import { Linear as LinearScale } from '@antv/scale';
|
|
5
|
-
import { deepMix, omit } from '@antv/util';
|
|
5
|
+
import { deepMix, omit, upperFirst } from '@antv/util';
|
|
6
6
|
import { extent } from 'd3-array';
|
|
7
7
|
import { format } from 'd3-format';
|
|
8
8
|
import {
|
|
@@ -356,15 +356,15 @@ function inferAxisLinearOverrideStyle(
|
|
|
356
356
|
// axisY
|
|
357
357
|
if (orientation === 'vertical') {
|
|
358
358
|
return {
|
|
359
|
-
startPos: [x
|
|
360
|
-
endPos: [x
|
|
359
|
+
startPos: [x, y],
|
|
360
|
+
endPos: [x, y + height],
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
363
|
// axisX
|
|
364
364
|
else if (orientation === 'horizontal') {
|
|
365
365
|
return {
|
|
366
|
-
startPos: [x, y
|
|
367
|
-
endPos: [x + width, y
|
|
366
|
+
startPos: [x, y],
|
|
367
|
+
endPos: [x + width, y],
|
|
368
368
|
};
|
|
369
369
|
}
|
|
370
370
|
// axis with rotate
|
|
@@ -478,7 +478,7 @@ const ArcAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
478
478
|
// @fixme transform is not valid for arcAxis.
|
|
479
479
|
// @ts-ignore
|
|
480
480
|
style: omit(finalStyle, ['transform']),
|
|
481
|
-
});
|
|
481
|
+
}) as unknown as DisplayObject;
|
|
482
482
|
};
|
|
483
483
|
};
|
|
484
484
|
|
|
@@ -491,12 +491,12 @@ function inferThemeStyle(
|
|
|
491
491
|
orientation: GCO,
|
|
492
492
|
) {
|
|
493
493
|
const baseStyle = theme.axis;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
}
|
|
499
|
-
return Object.assign({}, baseStyle,
|
|
494
|
+
const positionStyle = ['top', 'right', 'bottom', 'left'].includes(position)
|
|
495
|
+
? theme[`axis${capitalizeFirst(position)}`]
|
|
496
|
+
: theme.axisLinear;
|
|
497
|
+
const channel = scale.getOptions().name;
|
|
498
|
+
const channelStyle = theme[`axis${upperFirst(channel)}`] || {};
|
|
499
|
+
return Object.assign({}, baseStyle, positionStyle, channelStyle);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
502
|
function inferDefaultStyle(
|
|
@@ -634,7 +634,7 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
634
634
|
return new AxisComponent({
|
|
635
635
|
className: 'axis',
|
|
636
636
|
style: adaptor(finalAxisStyle),
|
|
637
|
-
});
|
|
637
|
+
}) as unknown as DisplayObject;
|
|
638
638
|
};
|
|
639
639
|
};
|
|
640
640
|
|
|
@@ -678,6 +678,8 @@ LinearAxis.props = {
|
|
|
678
678
|
defaultPosition: 'center',
|
|
679
679
|
defaultSize: 45,
|
|
680
680
|
defaultOrder: 0,
|
|
681
|
+
defaultCrossPadding: [12, 12],
|
|
682
|
+
defaultPadding: [12, 12],
|
|
681
683
|
};
|
|
682
684
|
|
|
683
685
|
ArcAxis.props = {
|
|
@@ -685,4 +687,6 @@ ArcAxis.props = {
|
|
|
685
687
|
defaultOrientation: 'vertical',
|
|
686
688
|
defaultSize: 45,
|
|
687
689
|
defaultOrder: 0,
|
|
690
|
+
defaultCrossPadding: [12, 12],
|
|
691
|
+
defaultPadding: [12, 12],
|
|
688
692
|
};
|
|
@@ -2,12 +2,10 @@ import type { DisplayObject } from '@antv/g';
|
|
|
2
2
|
import { Category } from '@antv/gui';
|
|
3
3
|
import { last } from '@antv/util';
|
|
4
4
|
import { format } from 'd3-format';
|
|
5
|
-
import { Identity
|
|
5
|
+
import { Identity } from '@antv/scale';
|
|
6
6
|
import type {
|
|
7
7
|
FlexLayout,
|
|
8
|
-
G2Library,
|
|
9
8
|
G2MarkState,
|
|
10
|
-
G2Theme,
|
|
11
9
|
GuideComponentComponent as GCC,
|
|
12
10
|
GuideComponentOrientation as GCO,
|
|
13
11
|
GuideComponentPosition as GCP,
|
|
@@ -244,6 +242,6 @@ LegendCategory.props = {
|
|
|
244
242
|
defaultPosition: 'top',
|
|
245
243
|
defaultOrder: 1,
|
|
246
244
|
defaultSize: 40,
|
|
247
|
-
|
|
248
|
-
|
|
245
|
+
defaultCrossPadding: [12, 12],
|
|
246
|
+
defaultPadding: [12, 12],
|
|
249
247
|
};
|
|
@@ -65,10 +65,9 @@ function inferContinuousShape(
|
|
|
65
65
|
options: LegendContinuousOptions,
|
|
66
66
|
component: GCC,
|
|
67
67
|
): Shape {
|
|
68
|
-
const { size
|
|
68
|
+
const { size } = options;
|
|
69
69
|
const shape = inferComponentShape(value, options, component);
|
|
70
|
-
|
|
71
|
-
return updateShapeDimensions(shape, finalSize, shape.orientation);
|
|
70
|
+
return updateShapeDimensions(shape, size, shape.orientation);
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
function getFormatter(max: number) {
|
|
@@ -160,7 +159,7 @@ function getLinearConfig(
|
|
|
160
159
|
...shape,
|
|
161
160
|
domain: [domainMin, domainMax],
|
|
162
161
|
data: scale.getTicks().map((value) => ({ value })),
|
|
163
|
-
color: new Array(length).fill(0).map((d, i) => {
|
|
162
|
+
color: new Array(Math.floor(length)).fill(0).map((d, i) => {
|
|
164
163
|
const value = ((max - min) / (length - 1)) * i + min;
|
|
165
164
|
const color = scale.map(value);
|
|
166
165
|
const opacity = opacityScale ? opacityScale.map(value) : 1;
|
|
@@ -289,5 +288,5 @@ LegendContinuous.props = {
|
|
|
289
288
|
defaultLength: 200,
|
|
290
289
|
defaultLegendSize: 60,
|
|
291
290
|
defaultPadding: [20, 10], // [horizontal, vertical]
|
|
292
|
-
defaultCrossPadding: [
|
|
291
|
+
defaultCrossPadding: [12, 12], // [horizontal, vertical]
|
|
293
292
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Scrollbar as ScrollbarComponent } from '@antv/gui';
|
|
2
|
+
import { DisplayObject } from '@antv/g';
|
|
2
3
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
3
4
|
|
|
4
5
|
export type ScrollbarOptions = {
|
|
@@ -35,7 +36,7 @@ export const Scrollbar: GCC<ScrollbarOptions> = (options) => {
|
|
|
35
36
|
contentLength: actualSize,
|
|
36
37
|
viewportLength: mainSize,
|
|
37
38
|
}),
|
|
38
|
-
});
|
|
39
|
+
}) as unknown as DisplayObject;
|
|
39
40
|
};
|
|
40
41
|
};
|
|
41
42
|
|
|
@@ -43,4 +44,6 @@ Scrollbar.props = {
|
|
|
43
44
|
defaultPosition: 'bottom',
|
|
44
45
|
defaultSize: 24,
|
|
45
46
|
defaultOrder: 1,
|
|
47
|
+
defaultCrossPadding: [12, 12],
|
|
48
|
+
defaultPadding: [12, 12],
|
|
46
49
|
};
|
package/src/component/slider.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Slider as SliderComponent } from '@antv/gui';
|
|
2
2
|
import { format } from 'd3-format';
|
|
3
|
+
import { DisplayObject } from '@antv/g';
|
|
3
4
|
import { isTranspose } from '../utils/coordinate';
|
|
4
5
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
5
6
|
import { invert } from '../utils/scale';
|
|
@@ -62,7 +63,7 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
62
63
|
...style,
|
|
63
64
|
...rest,
|
|
64
65
|
}),
|
|
65
|
-
});
|
|
66
|
+
}) as unknown as DisplayObject;
|
|
66
67
|
};
|
|
67
68
|
};
|
|
68
69
|
|
|
@@ -70,4 +71,6 @@ Slider.props = {
|
|
|
70
71
|
defaultPosition: 'bottom',
|
|
71
72
|
defaultSize: 24,
|
|
72
73
|
defaultOrder: 1,
|
|
74
|
+
defaultCrossPadding: [12, 12],
|
|
75
|
+
defaultPadding: [12, 12],
|
|
73
76
|
};
|
package/src/component/title.ts
CHANGED
|
@@ -44,8 +44,6 @@ function inferStyleByAlign(
|
|
|
44
44
|
const Title = createComponent<TitleStyleProps>({
|
|
45
45
|
render(attributes, container) {
|
|
46
46
|
const {
|
|
47
|
-
x,
|
|
48
|
-
y,
|
|
49
47
|
width,
|
|
50
48
|
title,
|
|
51
49
|
subtitle,
|
|
@@ -60,7 +58,7 @@ const Title = createComponent<TitleStyleProps>({
|
|
|
60
58
|
const mainTitle = maybeAppend(container, '.title', 'text')
|
|
61
59
|
.attr('className', 'title')
|
|
62
60
|
.call(applyStyle, {
|
|
63
|
-
...inferStyleByAlign(0,
|
|
61
|
+
...inferStyleByAlign(0, 0, width, align),
|
|
64
62
|
fontSize: 14,
|
|
65
63
|
textBaseline: 'top',
|
|
66
64
|
text: title,
|
|
@@ -106,4 +104,6 @@ TitleComponent.props = {
|
|
|
106
104
|
defaultPosition: 'top',
|
|
107
105
|
defaultOrder: 2,
|
|
108
106
|
defaultSize: 36,
|
|
107
|
+
defaultCrossPadding: [20, 20],
|
|
108
|
+
defaultPadding: [12, 12],
|
|
109
109
|
};
|
package/src/component/utils.ts
CHANGED
|
@@ -124,15 +124,13 @@ export function inferComponentShape(
|
|
|
124
124
|
position = 'top',
|
|
125
125
|
size: userDefinedSize,
|
|
126
126
|
length: userDefinedLength,
|
|
127
|
-
crossPadding = 0,
|
|
128
127
|
} = options;
|
|
129
128
|
const isHorizontal = ['top', 'bottom', 'center'].includes(position);
|
|
130
129
|
const [bboxSize, bboxLength] = isHorizontal
|
|
131
130
|
? [bbox.height, bbox.width]
|
|
132
131
|
: [bbox.width, bbox.height];
|
|
133
132
|
const { defaultSize, defaultLength } = component.props;
|
|
134
|
-
const
|
|
135
|
-
const size = size0 - crossPadding * 2;
|
|
133
|
+
const size = userDefinedSize || defaultSize || bboxSize;
|
|
136
134
|
const length = userDefinedLength || defaultLength || bboxLength;
|
|
137
135
|
const orientation = isHorizontal ? 'horizontal' : 'vertical';
|
|
138
136
|
const [width, height] = isHorizontal ? [length, size] : [size, length];
|
|
@@ -184,7 +184,7 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
|
|
|
184
184
|
layout,
|
|
185
185
|
) => {
|
|
186
186
|
const { x: scaleX, y: scaleY } = scale;
|
|
187
|
-
const { paddingLeft, paddingTop } = layout;
|
|
187
|
+
const { paddingLeft, paddingTop, marginLeft, marginTop } = layout;
|
|
188
188
|
const { domain: domainX } = scaleX.getOptions();
|
|
189
189
|
const { domain: domainY } = scaleY.getOptions();
|
|
190
190
|
const index = indexOf(visualData);
|
|
@@ -252,8 +252,9 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
|
|
|
252
252
|
return {
|
|
253
253
|
key: `${key}-${i}`,
|
|
254
254
|
data: newData,
|
|
255
|
-
|
|
256
|
-
|
|
255
|
+
margin: 0,
|
|
256
|
+
x: left + paddingLeft + originX + marginLeft,
|
|
257
|
+
y: top + paddingTop + originY + marginTop,
|
|
257
258
|
parentKey: viewKey,
|
|
258
259
|
width,
|
|
259
260
|
height,
|
|
@@ -34,7 +34,7 @@ const setChildren = useOverrideAdaptor<G2ViewTree>((options) => {
|
|
|
34
34
|
} = options;
|
|
35
35
|
const createChildren = (visualData, scale, layout) => {
|
|
36
36
|
const { x: scaleX, y: scaleY } = scale;
|
|
37
|
-
const { paddingLeft, paddingTop } = layout;
|
|
37
|
+
const { paddingLeft, paddingTop, marginLeft, marginTop } = layout;
|
|
38
38
|
const { domain: domainX } = scaleX.getOptions();
|
|
39
39
|
const { domain: domainY } = scaleY.getOptions();
|
|
40
40
|
const index = indexOf(visualData);
|
|
@@ -84,10 +84,11 @@ const setChildren = useOverrideAdaptor<G2ViewTree>((options) => {
|
|
|
84
84
|
data,
|
|
85
85
|
parentKey: viewKey,
|
|
86
86
|
key: `${key}-${i}`,
|
|
87
|
-
x: left + paddingLeft + originX,
|
|
88
|
-
y: top + paddingTop + originY,
|
|
87
|
+
x: left + paddingLeft + originX + marginLeft,
|
|
88
|
+
y: top + paddingTop + originY + marginTop,
|
|
89
89
|
width,
|
|
90
90
|
height,
|
|
91
|
+
margin: 0,
|
|
91
92
|
paddingLeft: 0,
|
|
92
93
|
paddingRight: 0,
|
|
93
94
|
paddingTop: 0,
|
package/src/index.ts
CHANGED
|
@@ -15,7 +15,15 @@ export {
|
|
|
15
15
|
AREA_CLASS_NAME,
|
|
16
16
|
} from './runtime';
|
|
17
17
|
|
|
18
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
corelib,
|
|
20
|
+
stdlib,
|
|
21
|
+
litelib,
|
|
22
|
+
graphlib,
|
|
23
|
+
plotlib,
|
|
24
|
+
geolib,
|
|
25
|
+
threedlib,
|
|
26
|
+
} from './lib';
|
|
19
27
|
|
|
20
28
|
export * from './mark';
|
|
21
29
|
|
|
@@ -26,6 +34,7 @@ export {
|
|
|
26
34
|
register,
|
|
27
35
|
Runtime,
|
|
28
36
|
extend,
|
|
37
|
+
type ChartOptions,
|
|
29
38
|
} from './api';
|
|
30
39
|
|
|
31
40
|
export { ChartEvent } from './utils/event';
|
|
@@ -2,7 +2,7 @@ import { DisplayObject, Rect, Path } from '@antv/g';
|
|
|
2
2
|
import { subObject, omitPrefixObject } from '../utils/helper';
|
|
3
3
|
import { selectionOf, pixelsOf } from '../utils/scale';
|
|
4
4
|
import { createElement } from '../utils/createElement';
|
|
5
|
-
import { select, Selection } from '../utils/selection';
|
|
5
|
+
import { G2Element, select, Selection } from '../utils/selection';
|
|
6
6
|
import {
|
|
7
7
|
selectG2Elements,
|
|
8
8
|
selectPlotArea,
|
|
@@ -333,14 +333,17 @@ function hideRuleY(root) {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
// @todo Fill for composite g component.
|
|
337
|
+
function updateMarker(root, { data, style }) {
|
|
337
338
|
if (root.markers) root.markers.forEach((d) => d.remove());
|
|
338
339
|
const markers = data.map((d) => {
|
|
339
340
|
const [{ color, element }, point] = d;
|
|
340
341
|
const fill =
|
|
341
342
|
color || // encode value
|
|
342
343
|
element.style.fill ||
|
|
343
|
-
element.style.stroke
|
|
344
|
+
element.style.stroke ||
|
|
345
|
+
'#000';
|
|
346
|
+
|
|
344
347
|
const shape = new Circle({
|
|
345
348
|
style: {
|
|
346
349
|
cx: point[0],
|
|
@@ -609,7 +612,6 @@ export function seriesTooltip(
|
|
|
609
612
|
const markerStyles = subObject(style, 'marker');
|
|
610
613
|
updateMarker(root, {
|
|
611
614
|
data: filteredSeriesData,
|
|
612
|
-
items: tooltipData.items,
|
|
613
615
|
style: markerStyles,
|
|
614
616
|
});
|
|
615
617
|
}
|
package/src/lib/core.ts
CHANGED
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
Linear as ScaleLinear,
|
|
40
40
|
Ordinal as ScaleOrdinal,
|
|
41
41
|
Band as ScaleBand,
|
|
42
|
-
Identity as
|
|
42
|
+
Identity as ScaleIdentity,
|
|
43
43
|
Point as ScalePoint,
|
|
44
44
|
Time as ScaleTime,
|
|
45
45
|
Log as ScaleLog,
|
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
Sequential as ScaleSequential,
|
|
52
52
|
Constant as ScaleConstant,
|
|
53
53
|
} from '../scale';
|
|
54
|
-
import { Classic, ClassicDark, Academy } from '../theme';
|
|
54
|
+
import { Classic, ClassicDark, Academy, Light } from '../theme';
|
|
55
55
|
import {
|
|
56
56
|
AxisLinear,
|
|
57
57
|
AxisArc,
|
|
@@ -250,7 +250,7 @@ export function corelib() {
|
|
|
250
250
|
'scale.linear': ScaleLinear,
|
|
251
251
|
'scale.ordinal': ScaleOrdinal,
|
|
252
252
|
'scale.band': ScaleBand,
|
|
253
|
-
'scale.identity':
|
|
253
|
+
'scale.identity': ScaleIdentity,
|
|
254
254
|
'scale.point': ScalePoint,
|
|
255
255
|
'scale.time': ScaleTime,
|
|
256
256
|
'scale.log': ScaleLog,
|
|
@@ -264,6 +264,7 @@ export function corelib() {
|
|
|
264
264
|
'theme.classic': Classic,
|
|
265
265
|
'theme.classicDark': ClassicDark,
|
|
266
266
|
'theme.academy': Academy,
|
|
267
|
+
'theme.light': Light,
|
|
267
268
|
'component.axisX': AxisX,
|
|
268
269
|
'component.axisY': AxisY,
|
|
269
270
|
'component.axisRadar': AxisRadar,
|
package/src/runtime/component.ts
CHANGED
|
@@ -82,14 +82,20 @@ export function inferComponent(
|
|
|
82
82
|
// Title components.
|
|
83
83
|
if (title) {
|
|
84
84
|
const { props } = createGuideComponent('title');
|
|
85
|
-
const {
|
|
86
|
-
|
|
85
|
+
const {
|
|
86
|
+
defaultPosition,
|
|
87
|
+
defaultOrientation,
|
|
88
|
+
defaultOrder,
|
|
89
|
+
defaultSize,
|
|
90
|
+
defaultCrossPadding,
|
|
91
|
+
} = props;
|
|
87
92
|
const titleOptions = typeof title === 'string' ? { title } : title;
|
|
88
93
|
components.push({
|
|
89
94
|
type: 'title',
|
|
90
95
|
position: defaultPosition,
|
|
91
96
|
orientation: defaultOrientation,
|
|
92
97
|
order: defaultOrder,
|
|
98
|
+
crossPadding: defaultCrossPadding[0],
|
|
93
99
|
defaultSize,
|
|
94
100
|
...titleOptions,
|
|
95
101
|
});
|
|
@@ -224,7 +230,7 @@ export function groupComponents(
|
|
|
224
230
|
|
|
225
231
|
// Update attributes of group components,
|
|
226
232
|
// and maybe flatten group components without enough room.
|
|
227
|
-
return grouped.flatMap(([, components]
|
|
233
|
+
return grouped.flatMap(([, components]) => {
|
|
228
234
|
if (components.length === 1) return components[0];
|
|
229
235
|
|
|
230
236
|
// If crossSize defined, group components only when has
|
|
@@ -441,17 +447,10 @@ function inferAxisPositionAndOrientation(
|
|
|
441
447
|
return ['center', angle];
|
|
442
448
|
}
|
|
443
449
|
|
|
444
|
-
// There are multiple axes for parallel coordinate.
|
|
445
|
-
// Place the first one in the border area and put others in the center.
|
|
446
450
|
if (type === 'axisY' && isParallel(coordinates)) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
if (isTranspose(coordinates)) {
|
|
452
|
-
return index === 0 ? ['top', null] : ['center', 'horizontal'];
|
|
453
|
-
}
|
|
454
|
-
return index === 0 ? ordinalPosition : ['center', 'vertical'];
|
|
451
|
+
return isTranspose(coordinates)
|
|
452
|
+
? ['center', 'horizontal']
|
|
453
|
+
: ['center', 'vertical'];
|
|
455
454
|
}
|
|
456
455
|
|
|
457
456
|
// in non-cartesian coordinate systems, infer the arc axis angle
|
|
@@ -547,12 +546,18 @@ function inferScrollableComponents(
|
|
|
547
546
|
if (!options || !componentType) return;
|
|
548
547
|
|
|
549
548
|
const { props } = createGuideComponent(componentType);
|
|
550
|
-
const {
|
|
549
|
+
const {
|
|
550
|
+
defaultPosition,
|
|
551
|
+
defaultSize,
|
|
552
|
+
defaultOrder,
|
|
553
|
+
defaultCrossPadding: [crossPadding],
|
|
554
|
+
} = props;
|
|
551
555
|
return {
|
|
552
556
|
position: defaultPosition,
|
|
553
557
|
defaultSize,
|
|
554
558
|
order: defaultOrder,
|
|
555
559
|
type: componentType,
|
|
560
|
+
crossPadding,
|
|
556
561
|
...options,
|
|
557
562
|
scales: [scale],
|
|
558
563
|
};
|
|
@@ -591,6 +596,7 @@ export function computeComponentSize(
|
|
|
591
596
|
if (t === 'legendCategory') return computeCategoryLegendSize;
|
|
592
597
|
if (t.startsWith('slider')) return computeSliderSize;
|
|
593
598
|
if (t === 'title') return computeTitleSize;
|
|
599
|
+
if (t.startsWith('scrollbar')) return computeScrollbarSize;
|
|
594
600
|
return () => {};
|
|
595
601
|
};
|
|
596
602
|
return createCompute()(
|
|
@@ -632,6 +638,18 @@ function computeGroupSize(
|
|
|
632
638
|
children.forEach((d) => (d.size = maxSize));
|
|
633
639
|
}
|
|
634
640
|
|
|
641
|
+
function computeScrollbarSize(
|
|
642
|
+
component: G2GuideComponentOptions,
|
|
643
|
+
crossSize: number,
|
|
644
|
+
crossPadding: [number, number],
|
|
645
|
+
position: GCP,
|
|
646
|
+
theme: G2Theme,
|
|
647
|
+
library: G2Library,
|
|
648
|
+
) {
|
|
649
|
+
const { trackSize = 6 } = deepMix({}, theme.scrollbar, component);
|
|
650
|
+
component.size = trackSize;
|
|
651
|
+
}
|
|
652
|
+
|
|
635
653
|
function computeTitleSize(
|
|
636
654
|
component: G2GuideComponentOptions,
|
|
637
655
|
crossSize: number,
|
|
@@ -698,7 +716,7 @@ function computeAxisSize(
|
|
|
698
716
|
const scale = createScale(component, library);
|
|
699
717
|
const labelBBoxes = computeLabelsBBox(rest, scale);
|
|
700
718
|
const paddingTick = tickLength + labelSpacing;
|
|
701
|
-
if (labelBBoxes) {
|
|
719
|
+
if (labelBBoxes && labelBBoxes.length) {
|
|
702
720
|
const maxLabelWidth = max(labelBBoxes, (d) => d.width);
|
|
703
721
|
const maxLabelHeight = max(labelBBoxes, (d) => d.height);
|
|
704
722
|
if (isVertical) {
|
|
@@ -718,7 +736,7 @@ function computeAxisSize(
|
|
|
718
736
|
}
|
|
719
737
|
}
|
|
720
738
|
} else {
|
|
721
|
-
component.size =
|
|
739
|
+
component.size = tickLength;
|
|
722
740
|
}
|
|
723
741
|
|
|
724
742
|
// Compute title.
|
|
@@ -782,9 +800,6 @@ function computeContinuousLegendSize(
|
|
|
782
800
|
component.size += titleSpacing + titleBBox.height;
|
|
783
801
|
}
|
|
784
802
|
}
|
|
785
|
-
|
|
786
|
-
const { crossPadding: cp = 0 } = component;
|
|
787
|
-
component.size += cp * 2;
|
|
788
803
|
}
|
|
789
804
|
|
|
790
805
|
function computeCategoryLegendSize(
|
|
@@ -797,7 +812,14 @@ function computeCategoryLegendSize(
|
|
|
797
812
|
) {
|
|
798
813
|
const styleOf = () => {
|
|
799
814
|
const { legendCategory } = theme;
|
|
800
|
-
|
|
815
|
+
const { title } = component;
|
|
816
|
+
const [defaultTitle, specifiedTitle] = Array.isArray(title)
|
|
817
|
+
? [title, undefined]
|
|
818
|
+
: [undefined, title];
|
|
819
|
+
return deepMix({ title: defaultTitle }, legendCategory, {
|
|
820
|
+
...component,
|
|
821
|
+
title: specifiedTitle,
|
|
822
|
+
});
|
|
801
823
|
};
|
|
802
824
|
|
|
803
825
|
const {
|
|
@@ -806,16 +828,24 @@ function computeCategoryLegendSize(
|
|
|
806
828
|
titleSpacing,
|
|
807
829
|
rowPadding,
|
|
808
830
|
colPadding,
|
|
831
|
+
maxCols = Infinity,
|
|
832
|
+
maxRows = Infinity,
|
|
809
833
|
...rest
|
|
810
834
|
} = styleOf();
|
|
811
835
|
|
|
812
836
|
const { cols, length } = component;
|
|
813
837
|
|
|
814
|
-
const
|
|
838
|
+
const getRows = (rows) => Math.min(rows, maxRows);
|
|
839
|
+
const getCols = (cols) => Math.min(cols, maxCols);
|
|
815
840
|
|
|
816
841
|
// Vertical or horizontal.
|
|
817
842
|
const isVertical = position === 'left' || position === 'right';
|
|
818
843
|
|
|
844
|
+
const crossSize =
|
|
845
|
+
length === undefined
|
|
846
|
+
? crossSize0 + (isVertical ? 0 : crossPadding[0] + crossPadding[1])
|
|
847
|
+
: length;
|
|
848
|
+
|
|
819
849
|
// Compute title.
|
|
820
850
|
const titleBBox = computeTitleBBox(rest);
|
|
821
851
|
|
|
@@ -854,16 +884,16 @@ function computeCategoryLegendSize(
|
|
|
854
884
|
maxRows = rows;
|
|
855
885
|
maxPos = pos;
|
|
856
886
|
}
|
|
857
|
-
component.size = maxSize * cols;
|
|
887
|
+
component.size = maxSize * getCols(cols);
|
|
858
888
|
component.length = maxPos + titleHeight;
|
|
859
|
-
deepMix(component, { cols, gridRow: maxRows });
|
|
889
|
+
deepMix(component, { cols: getCols(cols), gridRow: maxRows });
|
|
860
890
|
};
|
|
861
891
|
|
|
862
892
|
// Horizontal grid layout.
|
|
863
893
|
const computeHorizontalGrid = () => {
|
|
864
894
|
const rows = Math.ceil(labelBBoxes.length / cols);
|
|
865
895
|
const maxWidth = max(labelBBoxes, (d) => widthOf(d.width)) * cols;
|
|
866
|
-
component.size = height * rows;
|
|
896
|
+
component.size = height * getRows(rows) - rowPadding;
|
|
867
897
|
component.length = Math.min(maxWidth, crossSize);
|
|
868
898
|
};
|
|
869
899
|
|
|
@@ -883,7 +913,7 @@ function computeCategoryLegendSize(
|
|
|
883
913
|
}
|
|
884
914
|
}
|
|
885
915
|
if (rows === 1) maxPos = pos;
|
|
886
|
-
component.size = height * rows;
|
|
916
|
+
component.size = height * getRows(rows) - rowPadding;
|
|
887
917
|
component.length = maxPos;
|
|
888
918
|
};
|
|
889
919
|
|
|
@@ -899,10 +929,6 @@ function computeCategoryLegendSize(
|
|
|
899
929
|
component.size += titleSpacing + titleBBox.height;
|
|
900
930
|
}
|
|
901
931
|
}
|
|
902
|
-
|
|
903
|
-
// Compute crossPadding.
|
|
904
|
-
const { crossPadding: cp = 0 } = component;
|
|
905
|
-
component.size += cp * 2;
|
|
906
932
|
}
|
|
907
933
|
|
|
908
934
|
export function createScale(
|
|
@@ -1071,7 +1097,8 @@ function computeLabelSize(
|
|
|
1071
1097
|
style: Record<string, any>,
|
|
1072
1098
|
): DOMRect {
|
|
1073
1099
|
const shape = normalizeLabel(d);
|
|
1074
|
-
|
|
1100
|
+
const { filter, ...rest } = style;
|
|
1101
|
+
shape.attr({ ...rest, visibility: 'none' });
|
|
1075
1102
|
const bbox = shape.getBBox();
|
|
1076
1103
|
return bbox;
|
|
1077
1104
|
}
|