@antv/g2 5.0.0-rc.1 → 5.0.0-rc.2
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/README.en-US.md +4 -1
- package/README.md +3 -2
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/animation/fadeIn.js +1 -1
- package/esm/animation/fadeIn.js.map +1 -1
- package/esm/animation/fadeOut.js +1 -1
- package/esm/animation/fadeOut.js.map +1 -1
- package/esm/animation/morphing.js +1 -1
- package/esm/animation/morphing.js.map +1 -1
- package/esm/animation/scaleInX.js +1 -1
- package/esm/animation/scaleInX.js.map +1 -1
- package/esm/animation/scaleInY.js +1 -1
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/scaleOutX.js +1 -1
- package/esm/animation/scaleOutX.js.map +1 -1
- package/esm/animation/scaleOutY.js +1 -1
- package/esm/animation/scaleOutY.js.map +1 -1
- package/esm/animation/waveIn.js +2 -2
- package/esm/animation/waveIn.js.map +1 -1
- package/esm/animation/zoomIn.js +1 -1
- package/esm/animation/zoomIn.js.map +1 -1
- package/esm/animation/zoomOut.js +1 -1
- package/esm/animation/zoomOut.js.map +1 -1
- package/esm/api/chart.d.ts +1 -0
- package/esm/api/chart.js +16 -11
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +2 -2
- package/esm/api/composition/base.js +3 -2
- package/esm/api/composition/base.js.map +1 -1
- package/esm/component/axis.js +7 -5
- package/esm/component/axis.js.map +1 -1
- package/esm/component/legendCategory.js +20 -5
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.js +2 -2
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/legendContinuousBlockSize.js +1 -1
- package/esm/component/legendContinuousBlockSize.js.map +1 -1
- package/esm/component/legendContinuousSize.js +1 -1
- package/esm/component/legendContinuousSize.js.map +1 -1
- package/esm/component/scrollbar.d.ts +1 -1
- package/esm/component/scrollbar.js +3 -3
- package/esm/component/scrollbar.js.map +1 -1
- package/esm/component/scrollbarX.js +1 -1
- package/esm/component/scrollbarX.js.map +1 -1
- package/esm/component/scrollbarY.js +1 -1
- package/esm/component/scrollbarY.js.map +1 -1
- package/esm/component/slider.d.ts +1 -1
- package/esm/component/slider.js +3 -3
- package/esm/component/slider.js.map +1 -1
- package/esm/component/sliderX.js +1 -1
- package/esm/component/sliderX.js.map +1 -1
- package/esm/component/sliderY.js +1 -1
- package/esm/component/sliderY.js.map +1 -1
- package/esm/component/utils.d.ts +1 -1
- package/esm/component/utils.js +2 -2
- package/esm/component/utils.js.map +1 -1
- package/esm/geo/geoView.js +1 -1
- package/esm/geo/geoView.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/interaction/brushFilter.js +1 -1
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/brushHighlight.js +6 -3
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/elementHighlight.js +1 -1
- package/esm/interaction/elementHighlight.js.map +1 -1
- package/esm/interaction/event.js +20 -20
- package/esm/interaction/event.js.map +1 -1
- package/esm/interaction/legendFilter.d.ts +1 -4
- package/esm/interaction/legendFilter.js +45 -73
- package/esm/interaction/legendFilter.js.map +1 -1
- package/esm/interaction/sliderFilter.js +6 -6
- package/esm/interaction/sliderFilter.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +2 -2
- package/esm/interaction/tooltip.js +40 -18
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/interaction/utils.js +7 -5
- package/esm/interaction/utils.js.map +1 -1
- package/esm/label-transform/overflowHide.js +3 -2
- package/esm/label-transform/overflowHide.js.map +1 -1
- package/esm/label-transform/overlapHide.js +3 -2
- package/esm/label-transform/overlapHide.js.map +1 -1
- package/esm/mark/gauge.js +2 -2
- package/esm/mark/gauge.js.map +1 -1
- package/esm/mark/sankey.js +2 -2
- package/esm/mark/sankey.js.map +1 -1
- package/esm/mark/utils.d.ts +2 -2
- package/esm/mark/utils.js +2 -2
- package/esm/mark/utils.js.map +1 -1
- package/esm/runtime/component.js +18 -3
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/plot.js +56 -22
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.d.ts +1 -1
- package/esm/runtime/render.js +15 -8
- package/esm/runtime/render.js.map +1 -1
- package/esm/shape/interval/color.js +18 -9
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/label/label.js +1 -1
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/area.js +1 -1
- package/esm/shape/label/position/area.js.map +1 -1
- package/esm/shape/line/curve.js +1 -1
- package/esm/shape/line/curve.js.map +1 -1
- package/esm/shape/text/advance.js +3 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/text.js +1 -1
- package/esm/shape/text/text.js.map +1 -1
- package/esm/spec/interaction.d.ts +2 -0
- package/esm/spec/scale.d.ts +3 -2
- package/esm/stdlib/index.js +1 -1
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/academy.js +5 -5
- package/esm/theme/academy.js.map +1 -1
- package/esm/theme/dark.js +5 -5
- package/esm/theme/dark.js.map +1 -1
- package/esm/theme/light.js +6 -8
- package/esm/theme/light.js.map +1 -1
- package/esm/transform/filter.js +4 -1
- package/esm/transform/filter.js.map +1 -1
- package/esm/utils/event.d.ts +33 -14
- package/esm/utils/event.js +43 -16
- package/esm/utils/event.js.map +1 -1
- package/esm/utils/helper.js +2 -1
- package/esm/utils/helper.js.map +1 -1
- package/esm/utils/style.d.ts +5 -0
- package/esm/utils/style.js +23 -0
- package/esm/utils/style.js.map +1 -0
- package/lib/animation/fadeIn.js +1 -1
- package/lib/animation/fadeIn.js.map +1 -1
- package/lib/animation/fadeOut.js +1 -1
- package/lib/animation/fadeOut.js.map +1 -1
- package/lib/animation/morphing.js +1 -1
- package/lib/animation/morphing.js.map +1 -1
- package/lib/animation/scaleInX.js +1 -1
- package/lib/animation/scaleInX.js.map +1 -1
- package/lib/animation/scaleInY.js +1 -1
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/scaleOutX.js +1 -1
- package/lib/animation/scaleOutX.js.map +1 -1
- package/lib/animation/scaleOutY.js +1 -1
- package/lib/animation/scaleOutY.js.map +1 -1
- package/lib/animation/waveIn.js +2 -2
- package/lib/animation/waveIn.js.map +1 -1
- package/lib/animation/zoomIn.js +1 -1
- package/lib/animation/zoomIn.js.map +1 -1
- package/lib/animation/zoomOut.js +1 -1
- package/lib/animation/zoomOut.js.map +1 -1
- package/lib/api/chart.d.ts +1 -0
- package/lib/api/chart.js +15 -10
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +2 -2
- package/lib/api/composition/base.js +3 -2
- package/lib/api/composition/base.js.map +1 -1
- package/lib/component/axis.js +7 -5
- package/lib/component/axis.js.map +1 -1
- package/lib/component/legendCategory.js +20 -5
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.js +2 -2
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/legendContinuousBlockSize.js +1 -1
- package/lib/component/legendContinuousBlockSize.js.map +1 -1
- package/lib/component/legendContinuousSize.js +1 -1
- package/lib/component/legendContinuousSize.js.map +1 -1
- package/lib/component/scrollbar.d.ts +1 -1
- package/lib/component/scrollbar.js +3 -3
- package/lib/component/scrollbar.js.map +1 -1
- package/lib/component/scrollbarX.js +1 -1
- package/lib/component/scrollbarX.js.map +1 -1
- package/lib/component/scrollbarY.js +1 -1
- package/lib/component/scrollbarY.js.map +1 -1
- package/lib/component/slider.d.ts +1 -1
- package/lib/component/slider.js +3 -3
- package/lib/component/slider.js.map +1 -1
- package/lib/component/sliderX.js +1 -1
- package/lib/component/sliderX.js.map +1 -1
- package/lib/component/sliderY.js +1 -1
- package/lib/component/sliderY.js.map +1 -1
- package/lib/component/utils.d.ts +1 -1
- package/lib/component/utils.js +2 -2
- package/lib/component/utils.js.map +1 -1
- package/lib/geo/geoView.js +1 -1
- package/lib/geo/geoView.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/brushFilter.js +1 -1
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/brushHighlight.js +6 -3
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/event.js +20 -20
- package/lib/interaction/event.js.map +1 -1
- package/lib/interaction/legendFilter.d.ts +1 -4
- package/lib/interaction/legendFilter.js +45 -73
- package/lib/interaction/legendFilter.js.map +1 -1
- package/lib/interaction/sliderFilter.js +6 -6
- package/lib/interaction/sliderFilter.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +2 -2
- package/lib/interaction/tooltip.js +40 -18
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/interaction/utils.js +7 -5
- package/lib/interaction/utils.js.map +1 -1
- package/lib/label-transform/overflowHide.js +3 -2
- package/lib/label-transform/overflowHide.js.map +1 -1
- package/lib/label-transform/overlapHide.js +3 -2
- package/lib/label-transform/overlapHide.js.map +1 -1
- package/lib/mark/gauge.js +2 -2
- package/lib/mark/gauge.js.map +1 -1
- package/lib/mark/sankey.js +2 -2
- package/lib/mark/sankey.js.map +1 -1
- package/lib/mark/utils.d.ts +2 -2
- package/lib/mark/utils.js +2 -2
- package/lib/mark/utils.js.map +1 -1
- package/lib/runtime/component.js +18 -3
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/plot.js +55 -21
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.d.ts +1 -1
- package/lib/runtime/render.js +14 -7
- package/lib/runtime/render.js.map +1 -1
- package/lib/shape/interval/color.js +18 -9
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/label/label.js +1 -1
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/area.js +1 -1
- package/lib/shape/label/position/area.js.map +1 -1
- package/lib/shape/line/curve.js +1 -1
- package/lib/shape/line/curve.js.map +1 -1
- package/lib/shape/text/advance.js +3 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/text.js +1 -1
- package/lib/shape/text/text.js.map +1 -1
- package/lib/spec/interaction.d.ts +2 -0
- package/lib/spec/scale.d.ts +3 -2
- package/lib/stdlib/index.js +1 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/academy.js +5 -5
- package/lib/theme/academy.js.map +1 -1
- package/lib/theme/dark.js +5 -5
- package/lib/theme/dark.js.map +1 -1
- package/lib/theme/light.js +6 -8
- package/lib/theme/light.js.map +1 -1
- package/lib/transform/filter.js +4 -1
- package/lib/transform/filter.js.map +1 -1
- package/lib/utils/event.d.ts +33 -14
- package/lib/utils/event.js +44 -17
- package/lib/utils/event.js.map +1 -1
- package/lib/utils/helper.js +2 -1
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/style.d.ts +5 -0
- package/lib/utils/style.js +30 -0
- package/lib/utils/style.js.map +1 -0
- package/package.json +2 -2
- package/src/animation/fadeIn.ts +1 -1
- package/src/animation/fadeOut.ts +1 -1
- package/src/animation/morphing.ts +1 -1
- package/src/animation/scaleInX.ts +4 -4
- package/src/animation/scaleInY.ts +4 -4
- package/src/animation/scaleOutX.ts +4 -4
- package/src/animation/scaleOutY.ts +4 -4
- package/src/animation/waveIn.ts +4 -4
- package/src/animation/zoomIn.ts +4 -4
- package/src/animation/zoomOut.ts +4 -4
- package/src/api/chart.ts +16 -12
- package/src/api/composition/base.ts +5 -4
- package/src/component/axis.ts +8 -6
- package/src/component/legendCategory.ts +19 -11
- package/src/component/legendContinuous.ts +2 -2
- package/src/component/legendContinuousBlockSize.ts +1 -5
- package/src/component/legendContinuousSize.ts +1 -1
- package/src/component/scrollbar.ts +5 -5
- package/src/component/scrollbarX.ts +1 -1
- package/src/component/scrollbarY.ts +1 -1
- package/src/component/slider.ts +6 -7
- package/src/component/sliderX.ts +1 -1
- package/src/component/sliderY.ts +1 -1
- package/src/component/utils.ts +2 -2
- package/src/geo/geoView.ts +1 -1
- package/src/index.ts +1 -0
- package/src/interaction/brushFilter.ts +2 -2
- package/src/interaction/brushHighlight.ts +8 -3
- package/src/interaction/elementHighlight.ts +6 -6
- package/src/interaction/event.ts +30 -20
- package/src/interaction/legendFilter.ts +45 -70
- package/src/interaction/sliderFilter.ts +6 -6
- package/src/interaction/tooltip.ts +51 -21
- package/src/interaction/utils.ts +6 -3
- package/src/label-transform/overflowHide.ts +3 -3
- package/src/label-transform/overlapHide.ts +3 -2
- package/src/mark/gauge.ts +2 -1
- package/src/mark/sankey.ts +2 -1
- package/src/mark/utils.ts +2 -4
- package/src/runtime/component.ts +27 -10
- package/src/runtime/plot.ts +70 -20
- package/src/runtime/render.ts +16 -8
- package/src/shape/interval/color.ts +19 -4
- package/src/shape/label/label.ts +1 -1
- package/src/shape/label/position/area.ts +1 -1
- package/src/shape/line/curve.ts +1 -1
- package/src/shape/text/advance.ts +3 -2
- package/src/shape/text/text.ts +1 -1
- package/src/spec/interaction.ts +3 -0
- package/src/spec/scale.ts +3 -2
- package/src/stdlib/index.ts +2 -2
- package/src/theme/academy.ts +5 -5
- package/src/theme/dark.ts +5 -5
- package/src/theme/light.ts +6 -8
- package/src/transform/filter.ts +4 -1
- package/src/utils/event.ts +47 -15
- package/src/utils/helper.ts +2 -1
- package/src/utils/style.ts +34 -0
package/src/animation/waveIn.ts
CHANGED
|
@@ -37,9 +37,9 @@ export const WaveIn: AC<WaveInOptions> = (options) => {
|
|
|
37
37
|
const {
|
|
38
38
|
radius = 0,
|
|
39
39
|
inset = 0,
|
|
40
|
-
fillOpacity,
|
|
41
|
-
strokeOpacity,
|
|
42
|
-
opacity,
|
|
40
|
+
fillOpacity = 1,
|
|
41
|
+
strokeOpacity = 1,
|
|
42
|
+
opacity = 1,
|
|
43
43
|
} = style;
|
|
44
44
|
|
|
45
45
|
const { points, y, y1 } = __data__;
|
|
@@ -62,7 +62,7 @@ export const WaveIn: AC<WaveInOptions> = (options) => {
|
|
|
62
62
|
transform: `translate(${center[0]}, ${center[1]})`,
|
|
63
63
|
});
|
|
64
64
|
const convertedPathDefinition = convertToPath(pathForConversion);
|
|
65
|
-
pathForConversion.style.transform = '
|
|
65
|
+
pathForConversion.style.transform = '';
|
|
66
66
|
return convertedPathDefinition;
|
|
67
67
|
};
|
|
68
68
|
|
package/src/animation/zoomIn.ts
CHANGED
|
@@ -12,10 +12,10 @@ export const ZoomIn: AC<ZoomInOptions> = (options) => {
|
|
|
12
12
|
return (from, to, value, coordinate, defaults) => {
|
|
13
13
|
const [shape] = from;
|
|
14
14
|
const {
|
|
15
|
-
transform: prefix,
|
|
16
|
-
fillOpacity,
|
|
17
|
-
strokeOpacity,
|
|
18
|
-
opacity,
|
|
15
|
+
transform: prefix = '',
|
|
16
|
+
fillOpacity = 1,
|
|
17
|
+
strokeOpacity = 1,
|
|
18
|
+
opacity = 1,
|
|
19
19
|
} = shape.style;
|
|
20
20
|
const keyframes = [
|
|
21
21
|
{
|
package/src/animation/zoomOut.ts
CHANGED
|
@@ -12,10 +12,10 @@ export const ZoomOut: AC<ZoomOutOptions> = (options) => {
|
|
|
12
12
|
return (from, to, value, coordinate, defaults) => {
|
|
13
13
|
const [shape] = from;
|
|
14
14
|
const {
|
|
15
|
-
transform: prefix,
|
|
16
|
-
fillOpacity,
|
|
17
|
-
strokeOpacity,
|
|
18
|
-
opacity,
|
|
15
|
+
transform: prefix = '',
|
|
16
|
+
fillOpacity = 1,
|
|
17
|
+
strokeOpacity = 1,
|
|
18
|
+
opacity = 1,
|
|
19
19
|
} = shape.style;
|
|
20
20
|
const keyframes = [
|
|
21
21
|
{ transform: `${prefix} scale(1)`.trimStart() },
|
package/src/api/chart.ts
CHANGED
|
@@ -6,7 +6,7 @@ import EventEmitter from '@antv/event-emitter';
|
|
|
6
6
|
import { G2Context, render, destroy } from '../runtime';
|
|
7
7
|
import { ViewComposition } from '../spec';
|
|
8
8
|
import { getChartSize } from '../utils/size';
|
|
9
|
-
import {
|
|
9
|
+
import { ChartEvent } from '../utils/event';
|
|
10
10
|
import { G2ViewTree } from '../runtime/types/options';
|
|
11
11
|
import { Node } from './node';
|
|
12
12
|
import {
|
|
@@ -65,6 +65,7 @@ function normalizeRoot(node: Node) {
|
|
|
65
65
|
root.attr('padding', node.attr('padding'));
|
|
66
66
|
root.attr('margin', node.attr('margin'));
|
|
67
67
|
root.attr('inset', node.attr('inset'));
|
|
68
|
+
root.attr('theme', node.attr('theme'));
|
|
68
69
|
return root;
|
|
69
70
|
}
|
|
70
71
|
|
|
@@ -122,6 +123,7 @@ export type ChartOptions = ViewComposition & {
|
|
|
122
123
|
autoFit?: boolean;
|
|
123
124
|
renderer?: CanvasRenderer;
|
|
124
125
|
plugins?: RendererPlugin[];
|
|
126
|
+
theme?: string;
|
|
125
127
|
};
|
|
126
128
|
|
|
127
129
|
type ChartProps = Concrete<ViewComposition>;
|
|
@@ -154,7 +156,6 @@ export const props: NodePropertyDescriptor[] = [
|
|
|
154
156
|
{ name: 'title', type: 'value' },
|
|
155
157
|
{ name: 'key', type: 'value' },
|
|
156
158
|
{ name: 'transform', type: 'array' },
|
|
157
|
-
{ name: 'theme', type: 'object' },
|
|
158
159
|
{ name: 'scale', type: 'object' },
|
|
159
160
|
{ name: 'axis', type: 'object' },
|
|
160
161
|
{ name: 'legend', type: 'object' },
|
|
@@ -208,8 +209,12 @@ export class Chart extends View<ChartOptions> {
|
|
|
208
209
|
);
|
|
209
210
|
}
|
|
210
211
|
|
|
211
|
-
return new Promise((resolve) => {
|
|
212
|
-
|
|
212
|
+
return new Promise((resolve, reject) => {
|
|
213
|
+
try {
|
|
214
|
+
render(this.options(), this._context, () => resolve(this), reject);
|
|
215
|
+
} catch (e) {
|
|
216
|
+
reject(e);
|
|
217
|
+
}
|
|
213
218
|
});
|
|
214
219
|
}
|
|
215
220
|
/**
|
|
@@ -233,10 +238,9 @@ export class Chart extends View<ChartOptions> {
|
|
|
233
238
|
return this._options || optionsOf(this);
|
|
234
239
|
}
|
|
235
240
|
this._options = deepMix(
|
|
236
|
-
this._options ||
|
|
241
|
+
this._options || optionsOf(this),
|
|
237
242
|
omit(options, SPEC_EXTERNAL_KEYS),
|
|
238
243
|
);
|
|
239
|
-
|
|
240
244
|
return this;
|
|
241
245
|
}
|
|
242
246
|
|
|
@@ -270,19 +274,19 @@ export class Chart extends View<ChartOptions> {
|
|
|
270
274
|
|
|
271
275
|
destroy() {
|
|
272
276
|
const options = this.options();
|
|
273
|
-
this.emit(
|
|
277
|
+
this.emit(ChartEvent.BEFORE_DESTROY);
|
|
274
278
|
this.unbindAutoFit();
|
|
275
279
|
destroy(options, this._context);
|
|
276
280
|
// Remove the container.
|
|
277
281
|
removeContainer(this._container);
|
|
278
|
-
this.emit(
|
|
282
|
+
this.emit(ChartEvent.AFTER_DESTROY);
|
|
279
283
|
}
|
|
280
284
|
|
|
281
285
|
clear() {
|
|
282
286
|
const options = this.options();
|
|
283
|
-
this.emit(
|
|
287
|
+
this.emit(ChartEvent.BEFORE_CLEAR);
|
|
284
288
|
destroy(options, this._context);
|
|
285
|
-
this.emit(
|
|
289
|
+
this.emit(ChartEvent.AFTER_CLEAR);
|
|
286
290
|
}
|
|
287
291
|
|
|
288
292
|
forceFit() {
|
|
@@ -303,12 +307,12 @@ export class Chart extends View<ChartOptions> {
|
|
|
303
307
|
if (width === adjustedWidth && height === adjustedHeight) {
|
|
304
308
|
return Promise.resolve(this);
|
|
305
309
|
}
|
|
306
|
-
this.emit(
|
|
310
|
+
this.emit(ChartEvent.BEFORE_CHANGE_SIZE);
|
|
307
311
|
this.width(adjustedWidth);
|
|
308
312
|
this.height(adjustedHeight);
|
|
309
313
|
const finished = this.render();
|
|
310
314
|
finished.then(() => {
|
|
311
|
-
this.emit(
|
|
315
|
+
this.emit(ChartEvent.AFTER_CHANGE_SIZE);
|
|
312
316
|
});
|
|
313
317
|
return finished;
|
|
314
318
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { DisplayObject } from '@antv/g';
|
|
2
1
|
import { Coordinate } from '@antv/coord';
|
|
3
|
-
import {
|
|
2
|
+
import { DisplayObject } from '@antv/g';
|
|
4
3
|
import { G2Theme, G2ViewDescriptor } from '../../runtime';
|
|
4
|
+
import { hide, show } from '../../utils/style';
|
|
5
|
+
import { Node } from '../node';
|
|
5
6
|
|
|
6
7
|
export class CompositionNode<
|
|
7
8
|
Value extends Record<string, any> = Record<string, any>,
|
|
@@ -40,7 +41,7 @@ export class CompositionNode<
|
|
|
40
41
|
show() {
|
|
41
42
|
const group = this.getGroup();
|
|
42
43
|
if (!group) return;
|
|
43
|
-
!group.isVisible() && group
|
|
44
|
+
!group.isVisible() && show(group);
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
/**
|
|
@@ -49,6 +50,6 @@ export class CompositionNode<
|
|
|
49
50
|
hide() {
|
|
50
51
|
const group = this.getGroup();
|
|
51
52
|
if (!group) return;
|
|
52
|
-
group.isVisible() && group
|
|
53
|
+
group.isVisible() && hide(group);
|
|
53
54
|
}
|
|
54
55
|
}
|
package/src/component/axis.ts
CHANGED
|
@@ -141,6 +141,7 @@ function getTicks(
|
|
|
141
141
|
const ticks = ticksOf(scale, domain, tickMethod);
|
|
142
142
|
const filteredTicks = tickFilter ? ticks.filter(tickFilter) : ticks;
|
|
143
143
|
const labelFormatter = scale.getFormatter?.() || defaultTickFormatter;
|
|
144
|
+
const toString = (d) => (typeof d === 'object' ? d : String(d));
|
|
144
145
|
const applyInset = createInset(position, coordinate);
|
|
145
146
|
const applyFisheye = createFisheye(position, coordinate);
|
|
146
147
|
|
|
@@ -150,7 +151,7 @@ function getTicks(
|
|
|
150
151
|
const tick = applyInset(scale.map(d) + offset);
|
|
151
152
|
return {
|
|
152
153
|
value: isTranspose(coordinate) && scale.getTicks?.() ? 1 - tick : tick,
|
|
153
|
-
label: labelFormatter(d, i, array),
|
|
154
|
+
label: toString(labelFormatter(prettyNumber(d), i, array)),
|
|
154
155
|
id: String(i),
|
|
155
156
|
};
|
|
156
157
|
});
|
|
@@ -166,7 +167,7 @@ function getTicks(
|
|
|
166
167
|
const tick = applyFisheye(applyInset(scale.map(d) + offset));
|
|
167
168
|
return {
|
|
168
169
|
value: tick,
|
|
169
|
-
label:
|
|
170
|
+
label: toString(labelFormatter(prettyNumber(d), i, array)),
|
|
170
171
|
id: String(i),
|
|
171
172
|
};
|
|
172
173
|
});
|
|
@@ -204,7 +205,8 @@ function inferArcStyle(
|
|
|
204
205
|
const common = {
|
|
205
206
|
center,
|
|
206
207
|
radius,
|
|
207
|
-
|
|
208
|
+
startAngle,
|
|
209
|
+
endAngle,
|
|
208
210
|
titleFillOpacity: 0,
|
|
209
211
|
titlePosition: 'inner',
|
|
210
212
|
showLine: false,
|
|
@@ -369,7 +371,7 @@ const ArcAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
369
371
|
style: deepMix({}, axisTheme, defaultStyle, {
|
|
370
372
|
type: 'arc',
|
|
371
373
|
data: ticks,
|
|
372
|
-
|
|
374
|
+
titleText: titleContent(title),
|
|
373
375
|
showGrid,
|
|
374
376
|
...rest,
|
|
375
377
|
...important,
|
|
@@ -490,9 +492,9 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
490
492
|
...style,
|
|
491
493
|
type: 'linear' as const,
|
|
492
494
|
data: ticks,
|
|
493
|
-
|
|
495
|
+
titleText: titleContent(title),
|
|
494
496
|
showLabel,
|
|
495
|
-
|
|
497
|
+
labelOverlap: labelTransforms(labelAutoHide, labelAutoRotate),
|
|
496
498
|
showGrid,
|
|
497
499
|
showTick,
|
|
498
500
|
gridLength,
|
|
@@ -68,16 +68,24 @@ function createShape(
|
|
|
68
68
|
'shape',
|
|
69
69
|
library,
|
|
70
70
|
);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
[
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
const shapeOptions = [
|
|
72
|
+
[
|
|
73
|
+
[0, 0],
|
|
74
|
+
[0, 0],
|
|
75
|
+
],
|
|
76
|
+
{ size: 6, ...style },
|
|
77
|
+
coordinate,
|
|
78
|
+
theme,
|
|
79
|
+
];
|
|
80
|
+
return () => {
|
|
81
|
+
try {
|
|
82
|
+
// @ts-ignore
|
|
83
|
+
return useShape({ type: `point.${shape}` })(...shapeOptions);
|
|
84
|
+
} catch (e) {
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
return useShape({ type: 'point.point' })(...shapeOptions);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
81
89
|
}
|
|
82
90
|
|
|
83
91
|
function inferItemMarker(
|
|
@@ -211,7 +219,7 @@ export const LegendCategory: GCC<LegendCategoryOptions> = (options) => {
|
|
|
211
219
|
);
|
|
212
220
|
|
|
213
221
|
const legendStyle = {
|
|
214
|
-
|
|
222
|
+
orientation: ['right', 'left', 'center'].includes(position)
|
|
215
223
|
? 'vertical'
|
|
216
224
|
: 'horizontal',
|
|
217
225
|
width,
|
|
@@ -31,13 +31,13 @@ function inferContinuousConfig(
|
|
|
31
31
|
const colorScale = scaleOf(scales, 'color');
|
|
32
32
|
const { domain, range } = colorScale.getOptions();
|
|
33
33
|
const [min, max] = [domain[0], domain.slice(-1)[0]];
|
|
34
|
-
const {
|
|
34
|
+
const { orientation, width, height, length } = inferComponentShape(
|
|
35
35
|
value,
|
|
36
36
|
options,
|
|
37
37
|
component,
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
const shape = {
|
|
40
|
+
const shape = { orientation, width, height };
|
|
41
41
|
|
|
42
42
|
if (colorScale instanceof Threshold) {
|
|
43
43
|
const thresholds = (colorScale as any).thresholds as number[];
|
|
@@ -7,11 +7,7 @@ export const LegendContinuousBlockSize: GCC<
|
|
|
7
7
|
LegendContinuousBlockSizeOptions
|
|
8
8
|
> = (options) => {
|
|
9
9
|
return LegendContinuous(
|
|
10
|
-
Object.assign(
|
|
11
|
-
{},
|
|
12
|
-
{ type: 'size', block: true, labelShowTick: false },
|
|
13
|
-
options,
|
|
14
|
-
),
|
|
10
|
+
Object.assign({}, { type: 'size', block: true, showTick: false }, options),
|
|
15
11
|
);
|
|
16
12
|
};
|
|
17
13
|
|
|
@@ -2,7 +2,7 @@ import { Scrollbar as ScrollbarComponent } from '@antv/gui';
|
|
|
2
2
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
3
3
|
|
|
4
4
|
export type ScrollbarOptions = {
|
|
5
|
-
|
|
5
|
+
orientation: 'horizontal' | 'vertical';
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -10,7 +10,7 @@ export type ScrollbarOptions = {
|
|
|
10
10
|
* Scrollbar component.
|
|
11
11
|
*/
|
|
12
12
|
export const Scrollbar: GCC<ScrollbarOptions> = (options) => {
|
|
13
|
-
const {
|
|
13
|
+
const { orientation, labelFormatter, style, ...rest } = options;
|
|
14
14
|
|
|
15
15
|
return (scales, value, coordinate, theme) => {
|
|
16
16
|
const { bbox } = value;
|
|
@@ -23,13 +23,13 @@ export const Scrollbar: GCC<ScrollbarOptions> = (options) => {
|
|
|
23
23
|
...style,
|
|
24
24
|
x,
|
|
25
25
|
y,
|
|
26
|
-
trackLength:
|
|
26
|
+
trackLength: orientation === 'horizontal' ? width : height,
|
|
27
27
|
...rest,
|
|
28
|
-
|
|
28
|
+
orientation,
|
|
29
29
|
value: 0,
|
|
30
30
|
// @todo Get actual length of content.
|
|
31
31
|
contentLength: 1500,
|
|
32
|
-
viewportLength:
|
|
32
|
+
viewportLength: orientation === 'horizontal' ? width : height,
|
|
33
33
|
}),
|
|
34
34
|
});
|
|
35
35
|
};
|
|
@@ -7,7 +7,7 @@ export type ScrollbarXOptions = ScrollbarOptions;
|
|
|
7
7
|
* ScrollbarX component.
|
|
8
8
|
*/
|
|
9
9
|
export const ScrollbarX: GCC<ScrollbarXOptions> = (options) => {
|
|
10
|
-
return Scrollbar({ ...options,
|
|
10
|
+
return Scrollbar({ ...options, orientation: 'horizontal' });
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
ScrollbarX.props = {
|
|
@@ -7,7 +7,7 @@ export type ScrollbarYOptions = ScrollbarOptions;
|
|
|
7
7
|
* ScrollbarY component.
|
|
8
8
|
*/
|
|
9
9
|
export const ScrollbarY: GCC<ScrollbarYOptions> = (options) => {
|
|
10
|
-
return Scrollbar({ ...options,
|
|
10
|
+
return Scrollbar({ ...options, orientation: 'vertical' });
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
ScrollbarY.props = {
|
package/src/component/slider.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Slider as SliderComponent } from '@antv/gui';
|
|
2
2
|
import { format } from 'd3-format';
|
|
3
|
-
import {
|
|
4
|
-
import { GuideComponentComponent as GCC, Scale } from '../runtime';
|
|
3
|
+
import { GuideComponentComponent as GCC } from '../runtime';
|
|
5
4
|
import { invert } from '../utils/scale';
|
|
6
5
|
|
|
7
6
|
export type SliderOptions = {
|
|
8
|
-
|
|
7
|
+
orientation: 'horizontal' | 'vertical';
|
|
9
8
|
[key: string]: any;
|
|
10
9
|
};
|
|
11
10
|
|
|
@@ -14,13 +13,13 @@ export type SliderOptions = {
|
|
|
14
13
|
*/
|
|
15
14
|
export const Slider: GCC<SliderOptions> = (options) => {
|
|
16
15
|
// do not pass size.
|
|
17
|
-
const {
|
|
16
|
+
const { orientation, labelFormatter, size, style, ...rest } = options;
|
|
18
17
|
|
|
19
18
|
return ([scale], value, coordinate, theme) => {
|
|
20
19
|
const { bbox } = value;
|
|
21
20
|
const { x, y, width, height } = bbox;
|
|
22
21
|
const { slider: sliderTheme = {} } = theme;
|
|
23
|
-
const defaultFormatter = scale.getFormatter?.() || ((v) => v);
|
|
22
|
+
const defaultFormatter = scale.getFormatter?.() || ((v) => v.toString());
|
|
24
23
|
const formatter =
|
|
25
24
|
typeof labelFormatter === 'string'
|
|
26
25
|
? format(labelFormatter)
|
|
@@ -31,8 +30,8 @@ export const Slider: GCC<SliderOptions> = (options) => {
|
|
|
31
30
|
style: Object.assign({}, sliderTheme, {
|
|
32
31
|
x,
|
|
33
32
|
y,
|
|
34
|
-
trackLength:
|
|
35
|
-
|
|
33
|
+
trackLength: orientation === 'horizontal' ? width : height,
|
|
34
|
+
orientation,
|
|
36
35
|
formatter: (v) => {
|
|
37
36
|
const f = formatter || defaultFormatter;
|
|
38
37
|
// @todo Pass index to distinguish the left and the right value.
|
package/src/component/sliderX.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type SliderXOptions = SliderOptions;
|
|
|
7
7
|
* SliderX component.
|
|
8
8
|
*/
|
|
9
9
|
export const SliderX: GCC<SliderXOptions> = (options) => {
|
|
10
|
-
return Slider({ ...options,
|
|
10
|
+
return Slider({ ...options, orientation: 'horizontal' });
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
SliderX.props = {
|
package/src/component/sliderY.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type SliderYOptions = SliderOptions;
|
|
|
7
7
|
* SliderY component.
|
|
8
8
|
*/
|
|
9
9
|
export const SliderY: GCC<SliderYOptions> = (options) => {
|
|
10
|
-
return Slider({ ...options,
|
|
10
|
+
return Slider({ ...options, orientation: 'vertical' });
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
SliderY.props = {
|
package/src/component/utils.ts
CHANGED
|
@@ -120,9 +120,9 @@ export function inferComponentShape(
|
|
|
120
120
|
const { defaultSize, defaultLength } = component.props;
|
|
121
121
|
const size = userDefinedSize || defaultSize || bboxSize;
|
|
122
122
|
const length = userDefinedLength || defaultLength || bboxLength;
|
|
123
|
-
const
|
|
123
|
+
const orientation = isHorizontal ? 'horizontal' : 'vertical';
|
|
124
124
|
const [width, height] = isHorizontal ? [length, size] : [size, length];
|
|
125
|
-
return {
|
|
125
|
+
return { orientation, width, height, size, length };
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
export function domainOf(scales: Scale[]): any[] {
|
package/src/geo/geoView.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -104,8 +104,8 @@ export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
|
|
|
104
104
|
{
|
|
105
105
|
// Hide label to keep smooth transition.
|
|
106
106
|
axis: {
|
|
107
|
-
...(hideX && { x: {
|
|
108
|
-
...(hideY && { y: {
|
|
107
|
+
...(hideX && { x: { labelOverlap: [{ type: 'hide' }] } }),
|
|
108
|
+
...(hideY && { y: { labelOverlap: [{ type: 'hide' }] } }),
|
|
109
109
|
},
|
|
110
110
|
},
|
|
111
111
|
mark,
|
|
@@ -83,8 +83,11 @@ export function brush(
|
|
|
83
83
|
mask = new Rect({
|
|
84
84
|
// @ts-ignore
|
|
85
85
|
style: {
|
|
86
|
+
x: 0,
|
|
87
|
+
y: 0,
|
|
88
|
+
width: 0,
|
|
89
|
+
height: 0,
|
|
86
90
|
draggable: true,
|
|
87
|
-
fill: 'transparent',
|
|
88
91
|
},
|
|
89
92
|
className: 'mask',
|
|
90
93
|
});
|
|
@@ -96,6 +99,8 @@ export function brush(
|
|
|
96
99
|
mask = new Rect({
|
|
97
100
|
// @ts-ignore
|
|
98
101
|
style: {
|
|
102
|
+
x: 0,
|
|
103
|
+
y: 0,
|
|
99
104
|
...style,
|
|
100
105
|
fill,
|
|
101
106
|
fillOpacity,
|
|
@@ -305,8 +310,8 @@ export function brushHighlight(
|
|
|
305
310
|
const {
|
|
306
311
|
width: rootWidth,
|
|
307
312
|
height: rootHeight,
|
|
308
|
-
x: ordinalX,
|
|
309
|
-
y: ordinalY,
|
|
313
|
+
x: ordinalX = 0,
|
|
314
|
+
y: ordinalY = 0,
|
|
310
315
|
} = bboxOf(root);
|
|
311
316
|
const extent = optionalExtent
|
|
312
317
|
? optionalExtent
|
|
@@ -3,15 +3,15 @@ import { deepMix } from '@antv/util';
|
|
|
3
3
|
import { group } from 'd3-array';
|
|
4
4
|
import { subObject } from '../utils/helper';
|
|
5
5
|
import {
|
|
6
|
-
createValueof,
|
|
7
6
|
createDatumof,
|
|
8
|
-
|
|
9
|
-
useState,
|
|
10
|
-
renderLink,
|
|
11
|
-
renderBackground,
|
|
12
|
-
selectPlotArea,
|
|
7
|
+
createValueof,
|
|
13
8
|
mergeState,
|
|
14
9
|
offsetTransform,
|
|
10
|
+
renderBackground,
|
|
11
|
+
renderLink,
|
|
12
|
+
selectG2Elements,
|
|
13
|
+
selectPlotArea,
|
|
14
|
+
useState,
|
|
15
15
|
} from './utils';
|
|
16
16
|
|
|
17
17
|
/**
|
package/src/interaction/event.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ChartEvent } from '../utils/event';
|
|
2
|
+
|
|
1
3
|
function dataOf(element, view) {
|
|
2
4
|
const { __data__: datum } = element;
|
|
3
5
|
const { markKey, index, seriesIndex } = datum;
|
|
@@ -22,8 +24,7 @@ function bubblesEvent(eventType, view, emitter, predicate = (event) => true) {
|
|
|
22
24
|
return (e) => {
|
|
23
25
|
if (!predicate(e)) return;
|
|
24
26
|
const { target } = e;
|
|
25
|
-
const {
|
|
26
|
-
const [elementType, markType] = classList;
|
|
27
|
+
const { className: elementType, markType } = target;
|
|
27
28
|
if (elementType === 'element') {
|
|
28
29
|
updateData(e, target, view);
|
|
29
30
|
emitter.emit(`element:${eventType}`, e);
|
|
@@ -41,33 +42,42 @@ export function Event() {
|
|
|
41
42
|
const { container, view } = context;
|
|
42
43
|
|
|
43
44
|
// Click events.
|
|
44
|
-
const click = bubblesEvent(
|
|
45
|
+
const click = bubblesEvent(
|
|
46
|
+
ChartEvent.CLICK,
|
|
47
|
+
view,
|
|
48
|
+
emitter,
|
|
49
|
+
(e) => e.detail === 1,
|
|
50
|
+
);
|
|
45
51
|
const dblclick = bubblesEvent(
|
|
46
|
-
|
|
52
|
+
ChartEvent.DBLCLICK,
|
|
47
53
|
view,
|
|
48
54
|
emitter,
|
|
49
55
|
(e) => e.detail === 2,
|
|
50
56
|
);
|
|
51
57
|
|
|
52
58
|
// Pointer events.
|
|
53
|
-
const pointertap = bubblesEvent(
|
|
54
|
-
const pointerdown = bubblesEvent(
|
|
55
|
-
const pointerup = bubblesEvent(
|
|
56
|
-
const pointerover = bubblesEvent(
|
|
57
|
-
const pointerout = bubblesEvent(
|
|
58
|
-
const pointermove = bubblesEvent(
|
|
59
|
-
const pointerenter = bubblesEvent(
|
|
60
|
-
const pointerleave = bubblesEvent(
|
|
61
|
-
const pointerupoutside = bubblesEvent(
|
|
59
|
+
const pointertap = bubblesEvent(ChartEvent.POINTER_TAP, view, emitter);
|
|
60
|
+
const pointerdown = bubblesEvent(ChartEvent.POINTER_DOWN, view, emitter);
|
|
61
|
+
const pointerup = bubblesEvent(ChartEvent.POINTER_UP, view, emitter);
|
|
62
|
+
const pointerover = bubblesEvent(ChartEvent.POINTER_OVER, view, emitter);
|
|
63
|
+
const pointerout = bubblesEvent(ChartEvent.POINTER_OUT, view, emitter);
|
|
64
|
+
const pointermove = bubblesEvent(ChartEvent.POINTER_MOVE, view, emitter);
|
|
65
|
+
const pointerenter = bubblesEvent(ChartEvent.POINTER_ENTER, view, emitter);
|
|
66
|
+
const pointerleave = bubblesEvent(ChartEvent.POINTER_LEAVE, view, emitter);
|
|
67
|
+
const pointerupoutside = bubblesEvent(
|
|
68
|
+
ChartEvent.POINTER_UPOUTSIDE,
|
|
69
|
+
view,
|
|
70
|
+
emitter,
|
|
71
|
+
);
|
|
62
72
|
|
|
63
73
|
// Drag and drop events.
|
|
64
|
-
const dragstart = bubblesEvent(
|
|
65
|
-
const drag = bubblesEvent(
|
|
66
|
-
const dragend = bubblesEvent(
|
|
67
|
-
const dragenter = bubblesEvent(
|
|
68
|
-
const dragleave = bubblesEvent(
|
|
69
|
-
const dragover = bubblesEvent(
|
|
70
|
-
const drop = bubblesEvent(
|
|
74
|
+
const dragstart = bubblesEvent(ChartEvent.DRAG_START, view, emitter);
|
|
75
|
+
const drag = bubblesEvent(ChartEvent.DRAG, view, emitter);
|
|
76
|
+
const dragend = bubblesEvent(ChartEvent.DRAG_END, view, emitter);
|
|
77
|
+
const dragenter = bubblesEvent(ChartEvent.DRAG_ENTER, view, emitter);
|
|
78
|
+
const dragleave = bubblesEvent(ChartEvent.DRAG_LEAVE, view, emitter);
|
|
79
|
+
const dragover = bubblesEvent(ChartEvent.DRAG_OVER, view, emitter);
|
|
80
|
+
const drop = bubblesEvent(ChartEvent.DROP, view, emitter);
|
|
71
81
|
|
|
72
82
|
// For legacy usage.
|
|
73
83
|
container.addEventListener('click', click);
|