@antv/g2 5.0.0-beta.11 → 5.0.0-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/chart.d.ts +2 -1
- package/esm/api/chart.js +2 -2
- package/esm/api/chart.js.map +1 -1
- package/esm/api/composition/base.d.ts +1 -1
- package/esm/api/composition/base.js +6 -17
- package/esm/api/composition/base.js.map +1 -1
- package/esm/api/composition/facetCircle.d.ts +2 -2
- package/esm/api/composition/facetCircle.js +2 -2
- package/esm/api/composition/facetCircle.js.map +1 -1
- package/esm/api/composition/facetRect.d.ts +2 -2
- package/esm/api/composition/facetRect.js +2 -2
- package/esm/api/composition/facetRect.js.map +1 -1
- package/esm/api/composition/geoPath.d.ts +2 -2
- package/esm/api/composition/geoPath.js +2 -2
- package/esm/api/composition/geoPath.js.map +1 -1
- package/esm/api/composition/geoView.d.ts +2 -2
- package/esm/api/composition/geoView.js +2 -2
- package/esm/api/composition/geoView.js.map +1 -1
- package/esm/api/composition/index.d.ts +2 -2
- package/esm/api/composition/index.js +2 -2
- package/esm/api/composition/index.js.map +1 -1
- package/esm/api/composition/repeatMatrix.d.ts +2 -2
- package/esm/api/composition/repeatMatrix.js +2 -2
- package/esm/api/composition/repeatMatrix.js.map +1 -1
- package/esm/api/composition/spaceFlex.d.ts +2 -2
- package/esm/api/composition/spaceFlex.js +2 -2
- package/esm/api/composition/spaceFlex.js.map +1 -1
- package/esm/api/composition/spaceLayer.d.ts +2 -2
- package/esm/api/composition/spaceLayer.js +2 -2
- package/esm/api/composition/spaceLayer.js.map +1 -1
- package/esm/api/composition/timingKeyframe.d.ts +2 -2
- package/esm/api/composition/timingKeyframe.js +2 -2
- package/esm/api/composition/timingKeyframe.js.map +1 -1
- package/esm/api/composition/view.d.ts +2 -2
- package/esm/api/composition/view.js +2 -2
- package/esm/api/composition/view.js.map +1 -1
- package/esm/api/index.d.ts +2 -0
- package/esm/api/index.js +2 -0
- package/esm/api/index.js.map +1 -1
- package/esm/api/mark/base.d.ts +1 -1
- package/esm/api/mark/base.js +7 -7
- package/esm/api/mark/base.js.map +1 -1
- package/esm/api/mark/index.d.ts +1 -0
- package/esm/api/mark/index.js +1 -0
- package/esm/api/mark/index.js.map +1 -1
- package/esm/api/mark/mark.d.ts +27 -27
- package/esm/api/mark/mark.js +28 -27
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/mark/types.d.ts +1 -0
- package/esm/api/node.d.ts +1 -1
- package/esm/api/node.js +1 -1
- package/esm/api/node.js.map +1 -1
- package/esm/api/props.d.ts +1 -1
- package/esm/api/props.js +20 -0
- package/esm/api/props.js.map +1 -1
- package/esm/composition/timingKeyframe.js +13 -7
- package/esm/composition/timingKeyframe.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interaction/builtin/tooltip.d.ts +10 -2
- package/esm/interaction/index.d.ts +1 -0
- package/esm/interaction/index.js +1 -0
- package/esm/interaction/index.js.map +1 -1
- package/esm/interaction/native/event.d.ts +1 -0
- package/esm/interaction/native/event.js +42 -0
- package/esm/interaction/native/event.js.map +1 -0
- package/esm/interaction/native/tooltip.d.ts +2 -3
- package/esm/interaction/native/tooltip.js +68 -73
- package/esm/interaction/native/tooltip.js.map +1 -1
- package/esm/mark/utils.js +1 -5
- package/esm/mark/utils.js.map +1 -1
- package/esm/runtime/mark.js +5 -3
- package/esm/runtime/mark.js.map +1 -1
- package/esm/runtime/plot.js +33 -16
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/transform.d.ts +5 -0
- package/esm/runtime/transform.js +62 -4
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/common.d.ts +1 -0
- package/esm/runtime/types/component.d.ts +2 -1
- package/esm/runtime/types/options.d.ts +6 -1
- package/esm/spec/geometry.d.ts +33 -17
- package/esm/spec/interaction.d.ts +6 -1
- package/esm/stdlib/index.js +2 -2
- package/esm/stdlib/index.js.map +1 -1
- package/esm/transform/groupN.js +2 -2
- package/esm/transform/groupN.js.map +1 -1
- package/esm/transform/maybeTitle.js +13 -3
- package/esm/transform/maybeTitle.js.map +1 -1
- package/esm/transform/maybeTooltip.js +20 -20
- package/esm/transform/maybeTooltip.js.map +1 -1
- package/esm/transform/maybeZeroX.js +2 -2
- package/esm/transform/maybeZeroX.js.map +1 -1
- package/esm/transform/maybeZeroY.js +2 -2
- package/esm/transform/maybeZeroY.js.map +1 -1
- package/esm/transform/maybeZeroY1.js +2 -2
- package/esm/transform/maybeZeroY1.js.map +1 -1
- package/esm/transform/utils/helper.d.ts +12 -0
- package/esm/transform/utils/helper.js +8 -0
- package/esm/transform/utils/helper.js.map +1 -1
- package/esm/utils/helper.js +4 -1
- package/esm/utils/helper.js.map +1 -1
- package/lib/api/chart.d.ts +2 -1
- package/lib/api/chart.js +2 -2
- package/lib/api/chart.js.map +1 -1
- package/lib/api/composition/base.d.ts +1 -1
- package/lib/api/composition/base.js +8 -18
- package/lib/api/composition/base.js.map +1 -1
- package/lib/api/composition/facetCircle.d.ts +2 -2
- package/lib/api/composition/facetCircle.js +1 -1
- package/lib/api/composition/facetCircle.js.map +1 -1
- package/lib/api/composition/facetRect.d.ts +2 -2
- package/lib/api/composition/facetRect.js +1 -1
- package/lib/api/composition/facetRect.js.map +1 -1
- package/lib/api/composition/geoPath.d.ts +2 -2
- package/lib/api/composition/geoPath.js +1 -1
- package/lib/api/composition/geoPath.js.map +1 -1
- package/lib/api/composition/geoView.d.ts +2 -2
- package/lib/api/composition/geoView.js +1 -1
- package/lib/api/composition/geoView.js.map +1 -1
- package/lib/api/composition/index.d.ts +2 -2
- package/lib/api/composition/index.js +2 -2
- package/lib/api/composition/index.js.map +1 -1
- package/lib/api/composition/repeatMatrix.d.ts +2 -2
- package/lib/api/composition/repeatMatrix.js +1 -1
- package/lib/api/composition/repeatMatrix.js.map +1 -1
- package/lib/api/composition/spaceFlex.d.ts +2 -2
- package/lib/api/composition/spaceFlex.js +1 -1
- package/lib/api/composition/spaceFlex.js.map +1 -1
- package/lib/api/composition/spaceLayer.d.ts +2 -2
- package/lib/api/composition/spaceLayer.js +1 -1
- package/lib/api/composition/spaceLayer.js.map +1 -1
- package/lib/api/composition/timingKeyframe.d.ts +2 -2
- package/lib/api/composition/timingKeyframe.js +1 -1
- package/lib/api/composition/timingKeyframe.js.map +1 -1
- package/lib/api/composition/view.d.ts +2 -2
- package/lib/api/composition/view.js +1 -1
- package/lib/api/composition/view.js.map +1 -1
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.js +5 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/mark/base.d.ts +1 -1
- package/lib/api/mark/base.js +9 -9
- package/lib/api/mark/base.js.map +1 -1
- package/lib/api/mark/index.d.ts +1 -0
- package/lib/api/mark/index.js +3 -1
- package/lib/api/mark/index.js.map +1 -1
- package/lib/api/mark/mark.d.ts +27 -27
- package/lib/api/mark/mark.js +27 -26
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/mark/types.d.ts +1 -0
- package/lib/api/node.d.ts +1 -1
- package/lib/api/node.js +1 -1
- package/lib/api/node.js.map +1 -1
- package/lib/api/props.d.ts +1 -1
- package/lib/api/props.js +20 -0
- package/lib/api/props.js.map +1 -1
- package/lib/composition/timingKeyframe.js +13 -7
- package/lib/composition/timingKeyframe.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/builtin/tooltip.d.ts +10 -2
- package/lib/interaction/index.d.ts +1 -0
- package/lib/interaction/index.js +3 -1
- package/lib/interaction/index.js.map +1 -1
- package/lib/interaction/native/event.d.ts +1 -0
- package/lib/interaction/native/event.js +46 -0
- package/lib/interaction/native/event.js.map +1 -0
- package/lib/interaction/native/tooltip.d.ts +2 -3
- package/lib/interaction/native/tooltip.js +67 -72
- package/lib/interaction/native/tooltip.js.map +1 -1
- package/lib/mark/utils.js +1 -5
- package/lib/mark/utils.js.map +1 -1
- package/lib/runtime/mark.js +4 -2
- package/lib/runtime/mark.js.map +1 -1
- package/lib/runtime/plot.js +33 -16
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/transform.d.ts +5 -0
- package/lib/runtime/transform.js +64 -4
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/common.d.ts +1 -0
- package/lib/runtime/types/component.d.ts +2 -1
- package/lib/runtime/types/options.d.ts +6 -1
- package/lib/spec/geometry.d.ts +33 -17
- package/lib/spec/interaction.d.ts +6 -1
- package/lib/stdlib/index.js +1 -1
- package/lib/stdlib/index.js.map +1 -1
- package/lib/transform/groupN.js +1 -1
- package/lib/transform/groupN.js.map +1 -1
- package/lib/transform/maybeTitle.js +12 -2
- package/lib/transform/maybeTitle.js.map +1 -1
- package/lib/transform/maybeTooltip.js +20 -20
- package/lib/transform/maybeTooltip.js.map +1 -1
- package/lib/transform/maybeZeroX.js +1 -1
- package/lib/transform/maybeZeroX.js.map +1 -1
- package/lib/transform/maybeZeroY.js +1 -1
- package/lib/transform/maybeZeroY.js.map +1 -1
- package/lib/transform/maybeZeroY1.js +1 -1
- package/lib/transform/maybeZeroY1.js.map +1 -1
- package/lib/transform/utils/helper.d.ts +12 -0
- package/lib/transform/utils/helper.js +11 -1
- package/lib/transform/utils/helper.js.map +1 -1
- package/lib/utils/helper.js +4 -1
- package/lib/utils/helper.js.map +1 -1
- package/package.json +1 -1
- package/src/api/chart.ts +2 -2
- package/src/api/composition/base.ts +5 -7
- package/src/api/composition/facetCircle.ts +2 -2
- package/src/api/composition/facetRect.ts +2 -2
- package/src/api/composition/geoPath.ts +2 -2
- package/src/api/composition/geoView.ts +2 -2
- package/src/api/composition/index.ts +2 -2
- package/src/api/composition/repeatMatrix.ts +2 -2
- package/src/api/composition/spaceFlex.ts +2 -2
- package/src/api/composition/spaceLayer.ts +2 -2
- package/src/api/composition/timingKeyframe.ts +2 -2
- package/src/api/composition/view.ts +2 -2
- package/src/api/index.ts +2 -0
- package/src/api/mark/base.ts +7 -7
- package/src/api/mark/index.ts +2 -0
- package/src/api/mark/mark.ts +28 -27
- package/src/api/mark/types.ts +1 -0
- package/src/api/node.ts +1 -1
- package/src/api/props.ts +22 -1
- package/src/composition/timingKeyframe.ts +13 -7
- package/src/index.ts +1 -1
- package/src/interaction/index.ts +1 -0
- package/src/interaction/native/event.ts +44 -0
- package/src/interaction/native/tooltip.ts +66 -92
- package/src/mark/utils.ts +1 -5
- package/src/runtime/mark.ts +6 -2
- package/src/runtime/plot.ts +44 -18
- package/src/runtime/transform.ts +71 -4
- package/src/runtime/types/common.ts +1 -0
- package/src/runtime/types/component.ts +2 -0
- package/src/runtime/types/options.ts +6 -1
- package/src/spec/geometry.ts +38 -30
- package/src/spec/interaction.ts +5 -1
- package/src/stdlib/index.ts +2 -0
- package/src/transform/groupN.ts +2 -2
- package/src/transform/maybeTitle.ts +11 -3
- package/src/transform/maybeTooltip.ts +17 -21
- package/src/transform/maybeZeroX.ts +2 -2
- package/src/transform/maybeZeroY.ts +2 -2
- package/src/transform/maybeZeroY1.ts +2 -2
- package/src/transform/utils/helper.ts +10 -0
- package/src/utils/helper.ts +6 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
2
|
import { Coordinate } from '@antv/coord';
|
|
3
|
-
import { defineProps } from '../props';
|
|
4
3
|
import { Node } from '../node';
|
|
5
4
|
import { G2Theme, G2ViewDescriptor } from '../../runtime';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
export class Base<
|
|
6
|
+
export class CompositionNode<
|
|
9
7
|
Value extends Record<string, any> = Record<string, any>,
|
|
10
8
|
ParentValue extends Record<string, any> = Record<string, any>,
|
|
11
9
|
ChildValue extends Record<string, any> = Record<string, any>,
|
|
@@ -14,8 +12,8 @@ export class Base<
|
|
|
14
12
|
* Get view instance by key.
|
|
15
13
|
*/
|
|
16
14
|
getView(): G2ViewDescriptor {
|
|
17
|
-
const chart = this.
|
|
18
|
-
const { views } = chart.
|
|
15
|
+
const chart = this.getRoot();
|
|
16
|
+
const { views } = chart.getContext();
|
|
19
17
|
if (!views?.length) return undefined;
|
|
20
18
|
return views.find((view) => view.key === this.attr('key'));
|
|
21
19
|
}
|
|
@@ -31,8 +29,8 @@ export class Base<
|
|
|
31
29
|
getGroup(): DisplayObject {
|
|
32
30
|
const key = this.attr('key');
|
|
33
31
|
if (!key) return undefined;
|
|
34
|
-
const chart = this.
|
|
35
|
-
const chartGroup = chart.
|
|
32
|
+
const chart = this.getRoot();
|
|
33
|
+
const chartGroup = chart.getContext().canvas.getRoot();
|
|
36
34
|
return chartGroup.getElementById(key);
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ObjectAttribute,
|
|
8
8
|
} from '../types';
|
|
9
9
|
import { mark, Mark } from '../mark';
|
|
10
|
-
import { Composition,
|
|
10
|
+
import { Composition, CompositionNode } from './index';
|
|
11
11
|
|
|
12
12
|
type FacetCircleSpec = Concrete<FacetCircleComposition>;
|
|
13
13
|
|
|
@@ -29,7 +29,7 @@ export interface FacetCircle extends Composition, Mark {
|
|
|
29
29
|
{ type: 'object', name: 'axis' },
|
|
30
30
|
...nodeProps(mark),
|
|
31
31
|
])
|
|
32
|
-
export class FacetCircle extends
|
|
32
|
+
export class FacetCircle extends CompositionNode<FacetCircleComposition> {
|
|
33
33
|
constructor() {
|
|
34
34
|
super({}, 'facetCircle');
|
|
35
35
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ObjectAttribute,
|
|
8
8
|
} from '../types';
|
|
9
9
|
import { mark, Mark } from '../mark';
|
|
10
|
-
import { Composition,
|
|
10
|
+
import { Composition, CompositionNode } from './index';
|
|
11
11
|
|
|
12
12
|
type FacetRectSpec = Concrete<FacetRectComposition>;
|
|
13
13
|
|
|
@@ -29,7 +29,7 @@ export interface FacetRect extends Composition, Mark {
|
|
|
29
29
|
{ type: 'object', name: 'axis' },
|
|
30
30
|
...nodeProps(mark),
|
|
31
31
|
])
|
|
32
|
-
export class FacetRect extends
|
|
32
|
+
export class FacetRect extends CompositionNode<FacetRectComposition> {
|
|
33
33
|
constructor() {
|
|
34
34
|
super({}, 'facetRect');
|
|
35
35
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Concrete,
|
|
8
8
|
} from '../types';
|
|
9
9
|
import { mark, Mark } from '../mark';
|
|
10
|
-
import { Composition,
|
|
10
|
+
import { Composition, CompositionNode } from './index';
|
|
11
11
|
|
|
12
12
|
type GeoPathSpec = Concrete<GeoPathComposition>;
|
|
13
13
|
|
|
@@ -33,7 +33,7 @@ export interface GeoPath extends Mark, Composition {
|
|
|
33
33
|
{ type: 'object', name: 'legend' },
|
|
34
34
|
...nodeProps(mark),
|
|
35
35
|
])
|
|
36
|
-
export class GeoPath extends
|
|
36
|
+
export class GeoPath extends CompositionNode<GeoPathComposition> {
|
|
37
37
|
constructor() {
|
|
38
38
|
super({}, 'geoPath');
|
|
39
39
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Concrete,
|
|
8
8
|
} from '../types';
|
|
9
9
|
import { mark, Mark } from '../mark';
|
|
10
|
-
import { Composition,
|
|
10
|
+
import { Composition, CompositionNode } from './index';
|
|
11
11
|
|
|
12
12
|
type GeoViewSpec = Concrete<GeoViewComposition>;
|
|
13
13
|
|
|
@@ -32,7 +32,7 @@ export interface GeoView extends Mark, Composition {
|
|
|
32
32
|
{ type: 'object', name: 'legend' },
|
|
33
33
|
...nodeProps(mark),
|
|
34
34
|
])
|
|
35
|
-
export class GeoView extends
|
|
35
|
+
export class GeoView extends CompositionNode<GeoViewComposition> {
|
|
36
36
|
constructor() {
|
|
37
37
|
super({}, 'geoView');
|
|
38
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineProps, nodeProps } from '../props';
|
|
2
|
-
import {
|
|
2
|
+
import { CompositionNode } from './base';
|
|
3
3
|
import { View } from './view';
|
|
4
4
|
import { SpaceLayer } from './spaceLayer';
|
|
5
5
|
import { SpaceFlex } from './spaceFlex';
|
|
@@ -35,7 +35,7 @@ export interface Composition {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export {
|
|
38
|
-
|
|
38
|
+
CompositionNode,
|
|
39
39
|
View,
|
|
40
40
|
SpaceLayer,
|
|
41
41
|
SpaceFlex,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
ObjectAttribute,
|
|
8
8
|
} from '../types';
|
|
9
9
|
import { mark, Mark } from '../mark';
|
|
10
|
-
import { Composition,
|
|
10
|
+
import { Composition, CompositionNode } from './index';
|
|
11
11
|
|
|
12
12
|
type RepeatMatrixSpec = Concrete<RepeatMatrixComposition>;
|
|
13
13
|
|
|
@@ -29,7 +29,7 @@ export interface RepeatMatrix extends Composition, Mark {
|
|
|
29
29
|
{ type: 'object', name: 'legend' },
|
|
30
30
|
...nodeProps(mark),
|
|
31
31
|
])
|
|
32
|
-
export class RepeatMatrix extends
|
|
32
|
+
export class RepeatMatrix extends CompositionNode<RepeatMatrixComposition> {
|
|
33
33
|
constructor() {
|
|
34
34
|
super({}, 'repeatMatrix');
|
|
35
35
|
}
|
|
@@ -2,7 +2,7 @@ import { SpaceFlexComposition } from '../../spec';
|
|
|
2
2
|
import { defineProps, nodeProps } from '../props';
|
|
3
3
|
import { ValueAttribute, Concrete } from '../types';
|
|
4
4
|
import { mark, Mark } from '../mark';
|
|
5
|
-
import { Composition,
|
|
5
|
+
import { Composition, CompositionNode } from './index';
|
|
6
6
|
|
|
7
7
|
type SpaceFlexSpec = Concrete<SpaceFlexComposition>;
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export interface SpaceFlex extends Composition, Mark {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
@defineProps([{ type: 'value', name: 'data' }, ...nodeProps(mark)])
|
|
14
|
-
export class SpaceFlex extends
|
|
14
|
+
export class SpaceFlex extends CompositionNode<SpaceFlexSpec> {
|
|
15
15
|
constructor() {
|
|
16
16
|
super({}, 'spaceFlex');
|
|
17
17
|
}
|
|
@@ -2,7 +2,7 @@ import { SpaceLayerComposition } from '../../spec';
|
|
|
2
2
|
import { defineProps, nodeProps } from '../props';
|
|
3
3
|
import { ValueAttribute, Concrete } from '../types';
|
|
4
4
|
import { mark, Mark } from '../mark';
|
|
5
|
-
import { Composition,
|
|
5
|
+
import { Composition, CompositionNode } from './index';
|
|
6
6
|
|
|
7
7
|
type SpaceLayerSpec = Concrete<SpaceLayerComposition>;
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ export interface SpaceLayer extends Composition, Mark {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
@defineProps([{ type: 'value', name: 'data' }, ...nodeProps(mark)])
|
|
14
|
-
export class SpaceLayer extends
|
|
14
|
+
export class SpaceLayer extends CompositionNode<SpaceLayerComposition> {
|
|
15
15
|
constructor() {
|
|
16
16
|
super({}, 'spaceLayer');
|
|
17
17
|
}
|
|
@@ -2,14 +2,14 @@ import { TimingKeyframeComposition } from '../../spec';
|
|
|
2
2
|
import { defineProps, nodeProps } from '../props';
|
|
3
3
|
import { Concrete } from '../types';
|
|
4
4
|
import { mark, Mark } from '../mark';
|
|
5
|
-
import { Composition,
|
|
5
|
+
import { Composition, CompositionNode } from './index';
|
|
6
6
|
|
|
7
7
|
type TimingKeyframeSpec = Concrete<TimingKeyframeComposition>;
|
|
8
8
|
|
|
9
9
|
export interface TimingKeyframe extends Composition, Mark {}
|
|
10
10
|
|
|
11
11
|
@defineProps([...nodeProps(mark)])
|
|
12
|
-
export class TimingKeyframe extends
|
|
12
|
+
export class TimingKeyframe extends CompositionNode<TimingKeyframeSpec> {
|
|
13
13
|
constructor() {
|
|
14
14
|
super({}, 'timingKeyframe');
|
|
15
15
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
Concrete,
|
|
8
8
|
} from '../types';
|
|
9
9
|
import { mark, Mark } from '../mark';
|
|
10
|
-
import {
|
|
10
|
+
import { CompositionNode } from './base';
|
|
11
11
|
|
|
12
12
|
type ViewSpec = Concrete<ViewComposition>;
|
|
13
13
|
|
|
@@ -35,7 +35,7 @@ export interface View extends Mark {
|
|
|
35
35
|
])
|
|
36
36
|
export class View<
|
|
37
37
|
ViewProps extends ViewComposition = ViewComposition,
|
|
38
|
-
> extends
|
|
38
|
+
> extends CompositionNode<ViewProps> {
|
|
39
39
|
constructor(options = {}, type = 'view') {
|
|
40
40
|
super(options, type);
|
|
41
41
|
}
|
package/src/api/index.ts
CHANGED
package/src/api/mark/base.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { DisplayObject } from '@antv/g';
|
|
|
2
2
|
import { Node } from '../node';
|
|
3
3
|
import { G2MarkState, Scale } from '../../runtime';
|
|
4
4
|
|
|
5
|
-
export class
|
|
5
|
+
export class MarkNode<
|
|
6
6
|
Value extends Record<string, any> = Record<string, any>,
|
|
7
7
|
ParentValue extends Record<string, any> = Record<string, any>,
|
|
8
8
|
ChildValue extends Record<string, any> = Record<string, any>,
|
|
9
9
|
> extends Node<Value, ParentValue, ChildValue> {
|
|
10
10
|
changeData(data: any) {
|
|
11
|
-
const chart = this.
|
|
11
|
+
const chart = this.getRoot();
|
|
12
12
|
if (!chart) return;
|
|
13
13
|
this.attr('data', data);
|
|
14
14
|
return chart?.render();
|
|
@@ -18,7 +18,7 @@ export class MarkBase<
|
|
|
18
18
|
* Get mark from chart views.
|
|
19
19
|
*/
|
|
20
20
|
getMark(): G2MarkState {
|
|
21
|
-
const chartView = this.
|
|
21
|
+
const chartView = this.getRoot()?.getView();
|
|
22
22
|
if (!chartView) return undefined;
|
|
23
23
|
const { markState } = chartView;
|
|
24
24
|
const markKey = Array.from(markState.keys()).find(
|
|
@@ -31,7 +31,7 @@ export class MarkBase<
|
|
|
31
31
|
* Get all scales instance.
|
|
32
32
|
*/
|
|
33
33
|
getScale(): Record<string, Scale> {
|
|
34
|
-
const chartView = this.
|
|
34
|
+
const chartView = this.getRoot()?.getView();
|
|
35
35
|
if (!chartView) return undefined;
|
|
36
36
|
return chartView?.scale;
|
|
37
37
|
}
|
|
@@ -40,7 +40,7 @@ export class MarkBase<
|
|
|
40
40
|
* Get the scale instance by channel.
|
|
41
41
|
*/
|
|
42
42
|
getScaleByChannel(channel: string): Scale {
|
|
43
|
-
const chartView = this.
|
|
43
|
+
const chartView = this.getRoot()?.getView();
|
|
44
44
|
if (!chartView) return undefined;
|
|
45
45
|
return chartView?.scale?.[channel];
|
|
46
46
|
}
|
|
@@ -51,8 +51,8 @@ export class MarkBase<
|
|
|
51
51
|
getGroup(): DisplayObject {
|
|
52
52
|
const key = this.attr('key');
|
|
53
53
|
if (!key) return undefined;
|
|
54
|
-
const chart = this.
|
|
55
|
-
const chartGroup = chart.
|
|
54
|
+
const chart = this.getRoot();
|
|
55
|
+
const chartGroup = chart.getContext().canvas.getRoot();
|
|
56
56
|
return chartGroup.getElementById(key);
|
|
57
57
|
}
|
|
58
58
|
}
|
package/src/api/mark/index.ts
CHANGED
package/src/api/mark/mark.ts
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from '../../spec';
|
|
29
29
|
import { NodePropertyDescriptor, defineProps } from '../props';
|
|
30
30
|
import { Concrete } from '../types';
|
|
31
|
-
import {
|
|
31
|
+
import { MarkNode } from './base';
|
|
32
32
|
import { API } from './types';
|
|
33
33
|
|
|
34
34
|
export interface Interval extends API<Concrete<IntervalGeometry>, Interval> {
|
|
@@ -149,185 +149,186 @@ export const props: NodePropertyDescriptor[] = [
|
|
|
149
149
|
{ name: 'slider', type: 'object' },
|
|
150
150
|
{ name: 'scrollbar', type: 'object' },
|
|
151
151
|
{ name: 'state', type: 'object' },
|
|
152
|
+
{ name: 'tooltip', type: 'mix' },
|
|
152
153
|
];
|
|
153
154
|
|
|
154
155
|
@defineProps(props)
|
|
155
|
-
export class Interval extends
|
|
156
|
+
export class Interval extends MarkNode<IntervalGeometry> {
|
|
156
157
|
constructor() {
|
|
157
158
|
super({}, 'interval');
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
@defineProps(props)
|
|
162
|
-
export class Rect extends
|
|
163
|
+
export class Rect extends MarkNode<RectGeometry> {
|
|
163
164
|
constructor() {
|
|
164
165
|
super({}, 'rect');
|
|
165
166
|
}
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
@defineProps(props)
|
|
169
|
-
export class Point extends
|
|
170
|
+
export class Point extends MarkNode<PointGeometry> {
|
|
170
171
|
constructor() {
|
|
171
172
|
super({}, 'point');
|
|
172
173
|
}
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
@defineProps(props)
|
|
176
|
-
export class Area extends
|
|
177
|
+
export class Area extends MarkNode<AreaGeometry> {
|
|
177
178
|
constructor() {
|
|
178
179
|
super({}, 'area');
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
|
|
182
183
|
@defineProps(props)
|
|
183
|
-
export class Line extends
|
|
184
|
+
export class Line extends MarkNode<LineGeometry> {
|
|
184
185
|
constructor() {
|
|
185
186
|
super({}, 'line');
|
|
186
187
|
}
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
@defineProps(props)
|
|
190
|
-
export class Cell extends
|
|
191
|
+
export class Cell extends MarkNode<CellGeometry> {
|
|
191
192
|
constructor() {
|
|
192
193
|
super({}, 'cell');
|
|
193
194
|
}
|
|
194
195
|
}
|
|
195
196
|
|
|
196
197
|
@defineProps(props)
|
|
197
|
-
export class Vector extends
|
|
198
|
+
export class Vector extends MarkNode<VectorGeometry> {
|
|
198
199
|
constructor() {
|
|
199
200
|
super({}, 'vector');
|
|
200
201
|
}
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
@defineProps(props)
|
|
204
|
-
export class Link extends
|
|
205
|
+
export class Link extends MarkNode<LinkGeometry> {
|
|
205
206
|
constructor() {
|
|
206
207
|
super({}, 'link');
|
|
207
208
|
}
|
|
208
209
|
}
|
|
209
210
|
|
|
210
211
|
@defineProps(props)
|
|
211
|
-
export class Polygon extends
|
|
212
|
+
export class Polygon extends MarkNode<PolygonGeometry> {
|
|
212
213
|
constructor() {
|
|
213
214
|
super({}, 'polygon');
|
|
214
215
|
}
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
@defineProps(props)
|
|
218
|
-
export class Image extends
|
|
219
|
+
export class Image extends MarkNode<ImageGeometry> {
|
|
219
220
|
constructor() {
|
|
220
221
|
super({}, 'image');
|
|
221
222
|
}
|
|
222
223
|
}
|
|
223
224
|
|
|
224
225
|
@defineProps(props)
|
|
225
|
-
export class Text extends
|
|
226
|
+
export class Text extends MarkNode<TextGeometry> {
|
|
226
227
|
constructor() {
|
|
227
228
|
super({}, 'text');
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
|
|
231
232
|
@defineProps(props)
|
|
232
|
-
export class Box extends
|
|
233
|
+
export class Box extends MarkNode<BoxGeometry> {
|
|
233
234
|
constructor() {
|
|
234
235
|
super({}, 'box');
|
|
235
236
|
}
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
@defineProps(props)
|
|
239
|
-
export class LineX extends
|
|
240
|
+
export class LineX extends MarkNode<LineXMark> {
|
|
240
241
|
constructor() {
|
|
241
242
|
super({}, 'lineX');
|
|
242
243
|
}
|
|
243
244
|
}
|
|
244
245
|
|
|
245
246
|
@defineProps(props)
|
|
246
|
-
export class LineY extends
|
|
247
|
+
export class LineY extends MarkNode<LineYMark> {
|
|
247
248
|
constructor() {
|
|
248
249
|
super({}, 'lineY');
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
@defineProps(props)
|
|
253
|
-
export class Range extends
|
|
254
|
+
export class Range extends MarkNode<RangeMark> {
|
|
254
255
|
constructor() {
|
|
255
256
|
super({}, 'range');
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
259
|
|
|
259
260
|
@defineProps(props)
|
|
260
|
-
export class RangeX extends
|
|
261
|
+
export class RangeX extends MarkNode<RangeXMark> {
|
|
261
262
|
constructor() {
|
|
262
263
|
super({}, 'rangeX');
|
|
263
264
|
}
|
|
264
265
|
}
|
|
265
266
|
|
|
266
267
|
@defineProps(props)
|
|
267
|
-
export class RangeY extends
|
|
268
|
+
export class RangeY extends MarkNode<RangeYMark> {
|
|
268
269
|
constructor() {
|
|
269
270
|
super({}, 'rangeY');
|
|
270
271
|
}
|
|
271
272
|
}
|
|
272
273
|
|
|
273
274
|
@defineProps(props)
|
|
274
|
-
export class Connector extends
|
|
275
|
+
export class Connector extends MarkNode<ConnectorMark> {
|
|
275
276
|
constructor() {
|
|
276
277
|
super({}, 'connector');
|
|
277
278
|
}
|
|
278
279
|
}
|
|
279
280
|
|
|
280
281
|
@defineProps(props)
|
|
281
|
-
export class Shape extends
|
|
282
|
+
export class Shape extends MarkNode<ShapeMark> {
|
|
282
283
|
constructor() {
|
|
283
284
|
super({}, 'shape');
|
|
284
285
|
}
|
|
285
286
|
}
|
|
286
287
|
|
|
287
288
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
288
|
-
export class Sankey extends
|
|
289
|
+
export class Sankey extends MarkNode<SankeyMark> {
|
|
289
290
|
constructor() {
|
|
290
291
|
super({}, 'sankey');
|
|
291
292
|
}
|
|
292
293
|
}
|
|
293
294
|
|
|
294
295
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
295
|
-
export class Treemap extends
|
|
296
|
+
export class Treemap extends MarkNode<ConnectorMark> {
|
|
296
297
|
constructor() {
|
|
297
298
|
super({}, 'treemap');
|
|
298
299
|
}
|
|
299
300
|
}
|
|
300
301
|
|
|
301
302
|
@defineProps(props)
|
|
302
|
-
export class Boxplot extends
|
|
303
|
+
export class Boxplot extends MarkNode<Boxplot> {
|
|
303
304
|
constructor() {
|
|
304
305
|
super({}, 'boxplot');
|
|
305
306
|
}
|
|
306
307
|
}
|
|
307
308
|
|
|
308
309
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
309
|
-
export class Pack extends
|
|
310
|
+
export class Pack extends MarkNode<Pack> {
|
|
310
311
|
constructor() {
|
|
311
312
|
super({}, 'pack');
|
|
312
313
|
}
|
|
313
314
|
}
|
|
314
315
|
|
|
315
316
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
316
|
-
export class ForceGraph extends
|
|
317
|
+
export class ForceGraph extends MarkNode<ForceGraph> {
|
|
317
318
|
constructor() {
|
|
318
319
|
super({}, 'forceGraph');
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
@defineProps([...props, { name: 'layout', type: 'value' }])
|
|
323
|
-
export class Tree extends
|
|
324
|
+
export class Tree extends MarkNode<Tree> {
|
|
324
325
|
constructor() {
|
|
325
326
|
super({}, 'tree');
|
|
326
327
|
}
|
|
327
328
|
}
|
|
328
329
|
|
|
329
330
|
@defineProps([...props, { name: 'layout', type: 'object' }])
|
|
330
|
-
export class WordCloud extends
|
|
331
|
+
export class WordCloud extends MarkNode<WordCloud> {
|
|
331
332
|
constructor() {
|
|
332
333
|
super({}, 'wordCloud');
|
|
333
334
|
}
|
package/src/api/mark/types.ts
CHANGED
package/src/api/node.ts
CHANGED
package/src/api/props.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { isStrictObject } from '../utils/helper';
|
|
2
|
+
|
|
1
3
|
export type NodePropertyDescriptor = {
|
|
2
|
-
type: 'object' | 'value' | 'array' | 'node' | 'container' | '
|
|
4
|
+
type: 'object' | 'value' | 'array' | 'node' | 'container' | 'mix';
|
|
3
5
|
name: string;
|
|
4
6
|
key?: string;
|
|
5
7
|
ctor?: new (...args: any[]) => any;
|
|
@@ -36,6 +38,24 @@ function defineObjectProp(
|
|
|
36
38
|
};
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
function defineMixProp(Node, { name }: NodePropertyDescriptor) {
|
|
42
|
+
Node.prototype[name] = function (key) {
|
|
43
|
+
if (arguments.length === 0) return this.attr(name);
|
|
44
|
+
if (Array.isArray(key)) return this.attr(name, { items: key });
|
|
45
|
+
if (
|
|
46
|
+
isStrictObject(key) &&
|
|
47
|
+
(key.title !== undefined || key.items !== undefined)
|
|
48
|
+
) {
|
|
49
|
+
return this.attr(name, key);
|
|
50
|
+
}
|
|
51
|
+
const obj = this.attr(name) || {};
|
|
52
|
+
const { items = [] } = obj;
|
|
53
|
+
items.push(key);
|
|
54
|
+
obj.items = items;
|
|
55
|
+
return this.attr(name, obj);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
39
59
|
function defineNodeProp(Node, { name, ctor }: NodePropertyDescriptor) {
|
|
40
60
|
Node.prototype[name] = function () {
|
|
41
61
|
return this.append(ctor);
|
|
@@ -62,6 +82,7 @@ export function defineProps(descriptors: NodePropertyDescriptor[]) {
|
|
|
62
82
|
else if (type === 'object') defineObjectProp(Node, descriptor);
|
|
63
83
|
else if (type === 'node') defineNodeProp(Node, descriptor);
|
|
64
84
|
else if (type === 'container') defineContainerProp(Node, descriptor);
|
|
85
|
+
else if (type === 'mix') defineMixProp(Node, descriptor);
|
|
65
86
|
}
|
|
66
87
|
return Node;
|
|
67
88
|
};
|
|
@@ -32,13 +32,19 @@ function setAnimation(node: G2ViewTree, duration: number, easing: string) {
|
|
|
32
32
|
const n = discovered.pop();
|
|
33
33
|
n.animate = deepMix(
|
|
34
34
|
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
enter: {
|
|
36
|
+
duration,
|
|
37
|
+
},
|
|
38
|
+
update: {
|
|
39
|
+
duration,
|
|
40
|
+
easing,
|
|
41
|
+
type: 'morphing',
|
|
42
|
+
fill: 'both',
|
|
43
|
+
},
|
|
44
|
+
exit: {
|
|
45
|
+
type: 'fadeOut',
|
|
46
|
+
duration,
|
|
47
|
+
},
|
|
42
48
|
},
|
|
43
49
|
n.animate || {},
|
|
44
50
|
);
|
package/src/index.ts
CHANGED
package/src/interaction/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ export { BrushXFilter } from './native/brushXFilter';
|
|
|
20
20
|
export { BrushYFilter } from './native/brushYFilter';
|
|
21
21
|
export { SliderFilter } from './native/sliderFilter';
|
|
22
22
|
export { Poptip } from './native/poptip';
|
|
23
|
+
export { Event } from './native/event';
|
|
23
24
|
|
|
24
25
|
export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
|
|
25
26
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
function dataOf(element, view) {
|
|
2
|
+
const { __data__: datum } = element;
|
|
3
|
+
const { markKey, index, seriesIndex } = datum;
|
|
4
|
+
const { markState } = view;
|
|
5
|
+
const selectedMark: any = Array.from(markState.keys()).find(
|
|
6
|
+
(mark) => (mark as any).key === markKey,
|
|
7
|
+
);
|
|
8
|
+
if (!selectedMark) return;
|
|
9
|
+
if (seriesIndex) {
|
|
10
|
+
return seriesIndex.map((i) => selectedMark.data[i]);
|
|
11
|
+
}
|
|
12
|
+
return selectedMark.data[index];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function clickEvent(view, emitter) {
|
|
16
|
+
return (e) => {
|
|
17
|
+
const { target } = e;
|
|
18
|
+
const { classList } = target;
|
|
19
|
+
const [elementType, markType] = classList;
|
|
20
|
+
if (elementType === 'element') {
|
|
21
|
+
const { data = {} } = e;
|
|
22
|
+
data.data = dataOf(target, view);
|
|
23
|
+
e.data = data;
|
|
24
|
+
emitter.emit('element:click', e);
|
|
25
|
+
emitter.emit(`${markType}:click`, e);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
// @todo Handle click axis and legend.
|
|
29
|
+
emitter.emit(`${elementType}:click`);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// @todo More events such as mouseenter, mouseleave.
|
|
34
|
+
// @todo Provide more info for event.dataset.
|
|
35
|
+
export function Event() {
|
|
36
|
+
return (context, _, emitter) => {
|
|
37
|
+
const { container, view } = context;
|
|
38
|
+
const click = clickEvent(view, emitter);
|
|
39
|
+
container.addEventListener('click', click);
|
|
40
|
+
return () => {
|
|
41
|
+
container.removeEventListener('click', click);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}
|