@antv/g2 5.0.6 → 5.0.8
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 +4 -4
- package/dist/g2.min.js +4 -4
- package/esm/animation/morphing.js +4 -0
- package/esm/animation/morphing.js.map +1 -1
- package/esm/api/chart.d.ts +4 -7
- package/esm/api/chart.js +22 -90
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/index.d.ts +3 -1
- package/esm/api/mark/index.js +2 -1
- package/esm/api/mark/index.js.map +1 -1
- package/esm/api/mark/mark.d.ts +7 -1
- package/esm/api/mark/mark.js +9 -0
- package/esm/api/mark/mark.js.map +1 -1
- package/esm/api/utils.d.ts +10 -0
- package/esm/api/utils.js +71 -0
- package/esm/api/utils.js.map +1 -0
- package/esm/component/axis.js +17 -19
- package/esm/component/axis.js.map +1 -1
- package/esm/component/axisX.js +3 -1
- package/esm/component/axisX.js.map +1 -1
- package/esm/component/axisY.js +1 -1
- package/esm/component/axisY.js.map +1 -1
- package/esm/component/constant.js +6 -0
- package/esm/component/constant.js.map +1 -1
- package/esm/component/legendCategory.js +8 -5
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.js +91 -33
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/utils.d.ts +9 -5
- package/esm/component/utils.js +14 -14
- package/esm/component/utils.js.map +1 -1
- package/esm/composition/mark.js +2 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/data/index.d.ts +2 -0
- package/esm/data/index.js +1 -0
- package/esm/data/index.js.map +1 -1
- package/esm/data/kde.d.ts +10 -0
- package/esm/data/kde.js +30 -0
- package/esm/data/kde.js.map +1 -0
- package/esm/interaction/brushFilter.js +2 -6
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/brushHighlight.d.ts +3 -2
- package/esm/interaction/brushHighlight.js +202 -28
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/brushXHighlight.js +1 -1
- package/esm/interaction/brushXHighlight.js.map +1 -1
- package/esm/interaction/brushYHighlight.js +1 -1
- package/esm/interaction/brushYHighlight.js.map +1 -1
- package/esm/interaction/event.d.ts +1 -0
- package/esm/interaction/event.js +14 -12
- package/esm/interaction/event.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +4 -4
- package/esm/interaction/tooltip.js +103 -31
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/mark/density.d.ts +4 -0
- package/esm/mark/density.js +61 -0
- package/esm/mark/density.js.map +1 -0
- package/esm/mark/gauge.d.ts +7 -0
- package/esm/mark/gauge.js +4 -6
- package/esm/mark/gauge.js.map +1 -1
- package/esm/mark/index.d.ts +2 -0
- package/esm/mark/index.js +1 -0
- package/esm/mark/index.js.map +1 -1
- package/esm/runtime/component.d.ts +4 -2
- package/esm/runtime/component.js +164 -12
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.d.ts +3 -3
- package/esm/runtime/layout.js +40 -21
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +10 -7
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/scale.js +2 -2
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/transform.js +4 -1
- package/esm/runtime/transform.js.map +1 -1
- package/esm/runtime/types/component.d.ts +1 -0
- package/esm/shape/area/area.js +1 -1
- package/esm/shape/area/area.js.map +1 -1
- package/esm/shape/area/curve.js +1 -1
- package/esm/shape/area/curve.js.map +1 -1
- package/esm/shape/box/violin.d.ts +3 -0
- package/esm/shape/box/violin.js +85 -0
- package/esm/shape/box/violin.js.map +1 -0
- package/esm/shape/connector/connector.js +1 -1
- package/esm/shape/density/density.d.ts +8 -0
- package/esm/shape/density/density.js +50 -0
- package/esm/shape/density/density.js.map +1 -0
- package/esm/shape/index.d.ts +4 -0
- package/esm/shape/index.js +2 -0
- package/esm/shape/index.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.d.ts +1 -1
- package/esm/shape/text/advance.js +1 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +1 -1
- package/esm/shape/utils.js +1 -1
- package/esm/shape/utils.js.map +1 -1
- package/esm/spec/composition.d.ts +22 -19
- package/esm/spec/dataTransform.d.ts +34 -2
- package/esm/spec/interaction.d.ts +3 -1
- package/esm/spec/mark.d.ts +9 -8
- package/esm/spec/transform.d.ts +1 -1
- package/esm/spec/utils.d.ts +1 -0
- package/esm/stdlib/index.js +5 -5
- package/esm/stdlib/index.js.map +1 -1
- package/esm/theme/classic.js +3 -0
- package/esm/theme/classic.js.map +1 -1
- package/esm/theme/classicDark.js +1 -0
- package/esm/theme/classicDark.js.map +1 -1
- package/esm/transform/filter.js +6 -2
- package/esm/transform/filter.js.map +1 -1
- package/esm/{shape → utils}/createElement.d.ts +1 -1
- package/esm/{shape → utils}/createElement.js.map +1 -1
- package/esm/utils/helper.d.ts +3 -0
- package/esm/utils/helper.js +3 -0
- package/esm/utils/helper.js.map +1 -1
- package/esm/utils/scale.js +5 -1
- package/esm/utils/scale.js.map +1 -1
- package/esm/utils/size.js +7 -4
- package/esm/utils/size.js.map +1 -1
- package/lib/animation/morphing.js +4 -0
- package/lib/animation/morphing.js.map +1 -1
- package/lib/api/chart.d.ts +4 -7
- package/lib/api/chart.js +27 -97
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/index.d.ts +3 -1
- package/lib/api/mark/index.js +1 -0
- package/lib/api/mark/index.js.map +1 -1
- package/lib/api/mark/mark.d.ts +7 -1
- package/lib/api/mark/mark.js +10 -1
- package/lib/api/mark/mark.js.map +1 -1
- package/lib/api/utils.d.ts +10 -0
- package/lib/api/utils.js +80 -0
- package/lib/api/utils.js.map +1 -0
- package/lib/component/axis.js +17 -19
- package/lib/component/axis.js.map +1 -1
- package/lib/component/axisX.js +3 -1
- package/lib/component/axisX.js.map +1 -1
- package/lib/component/axisY.js +1 -1
- package/lib/component/axisY.js.map +1 -1
- package/lib/component/constant.js +6 -0
- package/lib/component/constant.js.map +1 -1
- package/lib/component/legendCategory.js +7 -4
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.js +90 -32
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/utils.d.ts +9 -5
- package/lib/component/utils.js +16 -15
- package/lib/component/utils.js.map +1 -1
- package/lib/composition/mark.js +2 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/data/index.d.ts +2 -0
- package/lib/data/index.js +3 -1
- package/lib/data/index.js.map +1 -1
- package/lib/data/kde.d.ts +10 -0
- package/lib/data/kde.js +38 -0
- package/lib/data/kde.js.map +1 -0
- package/lib/interaction/brushFilter.js +2 -6
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/brushHighlight.d.ts +3 -2
- package/lib/interaction/brushHighlight.js +201 -27
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/brushXHighlight.js +1 -1
- package/lib/interaction/brushXHighlight.js.map +1 -1
- package/lib/interaction/brushYHighlight.js +1 -1
- package/lib/interaction/brushYHighlight.js.map +1 -1
- package/lib/interaction/event.d.ts +1 -0
- package/lib/interaction/event.js +15 -12
- package/lib/interaction/event.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +4 -4
- package/lib/interaction/tooltip.js +102 -30
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/mark/density.d.ts +4 -0
- package/lib/mark/density.js +65 -0
- package/lib/mark/density.js.map +1 -0
- package/lib/mark/gauge.d.ts +7 -0
- package/lib/mark/gauge.js +4 -6
- package/lib/mark/gauge.js.map +1 -1
- package/lib/mark/index.d.ts +2 -0
- package/lib/mark/index.js +3 -1
- package/lib/mark/index.js.map +1 -1
- package/lib/runtime/component.d.ts +4 -2
- package/lib/runtime/component.js +163 -10
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.d.ts +3 -3
- package/lib/runtime/layout.js +40 -21
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +10 -7
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/scale.js +2 -2
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/transform.js +4 -1
- package/lib/runtime/transform.js.map +1 -1
- package/lib/runtime/types/component.d.ts +1 -0
- package/lib/shape/area/area.js +1 -1
- package/lib/shape/area/area.js.map +1 -1
- package/lib/shape/area/curve.js +1 -1
- package/lib/shape/area/curve.js.map +1 -1
- package/lib/shape/box/violin.d.ts +3 -0
- package/lib/shape/box/violin.js +89 -0
- package/lib/shape/box/violin.js.map +1 -0
- package/lib/shape/connector/connector.js +1 -1
- package/lib/shape/density/density.d.ts +8 -0
- package/lib/shape/density/density.js +54 -0
- package/lib/shape/density/density.js.map +1 -0
- package/lib/shape/index.d.ts +4 -0
- package/lib/shape/index.js +6 -1
- package/lib/shape/index.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.d.ts +1 -1
- package/lib/shape/text/advance.js +1 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +1 -1
- package/lib/shape/utils.js +1 -1
- package/lib/shape/utils.js.map +1 -1
- package/lib/spec/composition.d.ts +22 -19
- package/lib/spec/dataTransform.d.ts +34 -2
- package/lib/spec/interaction.d.ts +3 -1
- package/lib/spec/mark.d.ts +9 -8
- package/lib/spec/transform.d.ts +1 -1
- package/lib/spec/utils.d.ts +1 -0
- package/lib/stdlib/index.js +2 -2
- package/lib/stdlib/index.js.map +1 -1
- package/lib/theme/classic.js +3 -0
- package/lib/theme/classic.js.map +1 -1
- package/lib/theme/classicDark.js +1 -0
- package/lib/theme/classicDark.js.map +1 -1
- package/lib/transform/filter.js +6 -2
- package/lib/transform/filter.js.map +1 -1
- package/lib/{shape → utils}/createElement.d.ts +1 -1
- package/lib/{shape → utils}/createElement.js.map +1 -1
- package/lib/utils/helper.d.ts +3 -0
- package/lib/utils/helper.js +5 -1
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/scale.js +5 -1
- package/lib/utils/scale.js.map +1 -1
- package/lib/utils/size.js +7 -4
- package/lib/utils/size.js.map +1 -1
- package/package.json +5 -3
- package/src/animation/morphing.ts +5 -0
- package/src/api/chart.ts +30 -113
- package/src/api/mark/index.ts +3 -0
- package/src/api/mark/mark.ts +12 -0
- package/src/api/utils.ts +79 -0
- package/src/component/axis.ts +22 -18
- package/src/component/axisX.ts +3 -1
- package/src/component/axisY.ts +2 -1
- package/src/component/constant.ts +6 -0
- package/src/component/legendCategory.ts +19 -6
- package/src/component/legendContinuous.ts +185 -74
- package/src/component/utils.ts +14 -3
- package/src/composition/mark.ts +2 -0
- package/src/data/index.ts +2 -0
- package/src/data/kde.ts +53 -0
- package/src/interaction/brushFilter.ts +8 -6
- package/src/interaction/brushHighlight.ts +258 -20
- package/src/interaction/brushXHighlight.ts +1 -0
- package/src/interaction/brushYHighlight.ts +1 -0
- package/src/interaction/event.ts +19 -13
- package/src/interaction/tooltip.ts +154 -25
- package/src/mark/density.ts +81 -0
- package/src/mark/gauge.ts +13 -7
- package/src/mark/index.ts +2 -0
- package/src/runtime/component.ts +210 -12
- package/src/runtime/layout.ts +74 -19
- package/src/runtime/plot.ts +8 -6
- package/src/runtime/scale.ts +2 -2
- package/src/runtime/transform.ts +2 -1
- package/src/runtime/types/component.ts +1 -0
- package/src/shape/area/area.ts +1 -1
- package/src/shape/area/curve.ts +1 -1
- package/src/shape/box/violin.ts +119 -0
- package/src/shape/connector/connector.ts +1 -1
- package/src/shape/density/density.ts +52 -0
- package/src/shape/index.ts +4 -0
- package/src/shape/line/curve.ts +1 -1
- package/src/shape/text/advance.ts +1 -1
- package/src/shape/text/badge.ts +1 -1
- package/src/shape/utils.ts +1 -1
- package/src/spec/composition.ts +22 -19
- package/src/spec/dataTransform.ts +35 -0
- package/src/spec/interaction.ts +3 -2
- package/src/spec/mark.ts +10 -6
- package/src/spec/transform.ts +1 -0
- package/src/spec/utils.ts +2 -0
- package/src/stdlib/index.ts +8 -0
- package/src/theme/classic.ts +3 -0
- package/src/theme/classicDark.ts +1 -0
- package/src/transform/filter.ts +6 -2
- package/src/{shape → utils}/createElement.ts +1 -1
- package/src/utils/helper.ts +12 -1
- package/src/utils/scale.ts +5 -1
- package/src/utils/size.ts +10 -4
- /package/esm/{shape → utils}/createElement.js +0 -0
- /package/lib/{shape → utils}/createElement.js +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { path as d3path } from 'd3-path';
|
|
2
|
+
import { Path } from '@antv/g';
|
|
3
|
+
import { applyStyle, getShapeTheme } from '../utils';
|
|
4
|
+
import { select } from '../../utils/selection';
|
|
5
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
6
|
+
|
|
7
|
+
export type DensityOptions = {
|
|
8
|
+
colorAttribute: 'fill' | 'stroke';
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Draw density shape.
|
|
13
|
+
*/
|
|
14
|
+
export const Density: SC<DensityOptions> = (options) => {
|
|
15
|
+
const { ...style } = options;
|
|
16
|
+
return (points, value, coordinate, theme) => {
|
|
17
|
+
const { mark, shape, defaultShape, transform } = value;
|
|
18
|
+
const { defaultColor, ...shapeTheme } = getShapeTheme(
|
|
19
|
+
theme,
|
|
20
|
+
mark,
|
|
21
|
+
shape,
|
|
22
|
+
defaultShape,
|
|
23
|
+
);
|
|
24
|
+
const { color = defaultColor } = value;
|
|
25
|
+
const [first, ...p] = points;
|
|
26
|
+
|
|
27
|
+
// todo smooth, hollow
|
|
28
|
+
const path = d3path();
|
|
29
|
+
path.moveTo(...first);
|
|
30
|
+
p.forEach(([x, y]) => {
|
|
31
|
+
path.lineTo(x, y);
|
|
32
|
+
});
|
|
33
|
+
path.closePath();
|
|
34
|
+
|
|
35
|
+
return select(new Path())
|
|
36
|
+
.call(applyStyle, shapeTheme)
|
|
37
|
+
.style('d', path.toString())
|
|
38
|
+
.style('stroke', color || defaultColor) // Always has stroke color.
|
|
39
|
+
.style('fill', color || defaultColor)
|
|
40
|
+
.style('fillOpacity', 0.4)
|
|
41
|
+
.style('transform', transform)
|
|
42
|
+
.call(applyStyle, style)
|
|
43
|
+
.node();
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
Density.props = {
|
|
48
|
+
defaultMarker: 'square',
|
|
49
|
+
defaultEnterAnimation: 'fadeIn',
|
|
50
|
+
defaultUpdateAnimation: 'morphing',
|
|
51
|
+
defaultExitAnimation: 'fadeOut',
|
|
52
|
+
};
|
package/src/shape/index.ts
CHANGED
|
@@ -42,11 +42,13 @@ export { Image } from './image/image';
|
|
|
42
42
|
export { Polygon } from './polygon/polygon';
|
|
43
43
|
export { Ribbon } from './polygon/ribbon';
|
|
44
44
|
export { Box } from './box/box';
|
|
45
|
+
export { Violin } from './box/violin';
|
|
45
46
|
export { Line as LineXY } from './lineXY/line';
|
|
46
47
|
export { Connector } from './connector/connector';
|
|
47
48
|
export { Label } from './label/label';
|
|
48
49
|
export { Path } from './path/path';
|
|
49
50
|
export { Hollow as HollowPath } from './path/hollow';
|
|
51
|
+
export { Density } from './density/density';
|
|
50
52
|
export { Shape } from './shape/shape';
|
|
51
53
|
|
|
52
54
|
export type { RectOptions } from './interval/rect';
|
|
@@ -93,10 +95,12 @@ export type { LinkOptions } from './link/link';
|
|
|
93
95
|
export type { ImageOptions } from './image/image';
|
|
94
96
|
export type { PolygonOptions } from './polygon/polygon';
|
|
95
97
|
export type { BoxOptions } from './box/box';
|
|
98
|
+
export type { ViolinOptions } from './box/violin';
|
|
96
99
|
|
|
97
100
|
export type { LineOptions as LineXYOptions } from './lineXY/line';
|
|
98
101
|
export type { ConnectorOptions } from './connector/connector';
|
|
99
102
|
|
|
100
103
|
export type { LabelOptions } from './label/label';
|
|
104
|
+
export type { DensityOptions } from './density/density';
|
|
101
105
|
|
|
102
106
|
export type { ShapeOptions } from './shape/shape';
|
package/src/shape/line/curve.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
getShapeTheme,
|
|
11
11
|
getTransform,
|
|
12
12
|
} from '../utils';
|
|
13
|
-
import { createElement } from '
|
|
13
|
+
import { createElement } from '../../utils/createElement';
|
|
14
14
|
import { subObject } from '../../utils/helper';
|
|
15
15
|
import { angleWithQuadrant, dist, sub } from '../../utils/vector';
|
|
16
16
|
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { Marker } from '@antv/gui';
|
|
11
11
|
import { line } from 'd3-shape';
|
|
12
12
|
import { WithPrefix } from '../../runtime';
|
|
13
|
-
import { createElement } from '
|
|
13
|
+
import { createElement } from '../../utils/createElement';
|
|
14
14
|
import { applyStyle } from '../utils';
|
|
15
15
|
import { subObject } from '../../utils/helper';
|
|
16
16
|
import { select } from '../../utils/selection';
|
package/src/shape/text/badge.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TextStyleProps, DisplayObject } from '@antv/g';
|
|
2
2
|
import { Marker } from '@antv/gui';
|
|
3
3
|
import { ShapeComponent as SC, WithPrefix } from '../../runtime';
|
|
4
|
-
import { createElement } from '../../
|
|
4
|
+
import { createElement } from '../../utils/createElement';
|
|
5
5
|
import { subObject } from '../../utils/helper';
|
|
6
6
|
import { select } from '../../utils/selection';
|
|
7
7
|
import { applyStyle, getShapeTheme } from '../../shape/utils';
|
package/src/shape/utils.ts
CHANGED
|
@@ -218,7 +218,7 @@ export function getConnectStyle(
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
export function toOpacityKey(options) {
|
|
221
|
-
const { opacityAttribute =
|
|
221
|
+
const { colorAttribute, opacityAttribute = colorAttribute } = options;
|
|
222
222
|
return `${opacityAttribute}Opacity`;
|
|
223
223
|
}
|
|
224
224
|
|
package/src/spec/composition.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Transform } from './transform';
|
|
|
5
5
|
import { Scale } from './scale';
|
|
6
6
|
import { Data } from './data';
|
|
7
7
|
import { LabelTransform } from './labelTransform';
|
|
8
|
-
import { Literal2Object } from './utils';
|
|
8
|
+
import { Literal2Object, Padding } from './utils';
|
|
9
9
|
import { TitleComponent } from './component';
|
|
10
10
|
import { Mark } from './mark';
|
|
11
11
|
|
|
@@ -40,11 +40,11 @@ export type ViewComposition = {
|
|
|
40
40
|
data?: Data;
|
|
41
41
|
key?: string;
|
|
42
42
|
class?: string;
|
|
43
|
-
padding?:
|
|
44
|
-
paddingLeft?:
|
|
45
|
-
paddingRight?:
|
|
46
|
-
paddingTop?:
|
|
47
|
-
paddingBottom?:
|
|
43
|
+
padding?: Padding;
|
|
44
|
+
paddingLeft?: Padding;
|
|
45
|
+
paddingRight?: Padding;
|
|
46
|
+
paddingTop?: Padding;
|
|
47
|
+
paddingBottom?: Padding;
|
|
48
48
|
margin?: number;
|
|
49
49
|
marginLeft?: number;
|
|
50
50
|
marginBottom?: number;
|
|
@@ -99,7 +99,7 @@ export type SpaceFlexComposition = {
|
|
|
99
99
|
data?: Data;
|
|
100
100
|
direction?: 'col' | 'row';
|
|
101
101
|
ratio?: number[];
|
|
102
|
-
padding?:
|
|
102
|
+
padding?: Padding;
|
|
103
103
|
children?: Node[];
|
|
104
104
|
};
|
|
105
105
|
|
|
@@ -118,10 +118,11 @@ export type FacetRectComposition = {
|
|
|
118
118
|
type?: 'facetRect';
|
|
119
119
|
transform?: Transform;
|
|
120
120
|
data?: Data;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
padding?: Padding;
|
|
122
|
+
paddingLeft?: Padding;
|
|
123
|
+
paddingRight?: Padding;
|
|
124
|
+
paddingTop?: Padding;
|
|
125
|
+
paddingBottom?: Padding;
|
|
125
126
|
margin?: number;
|
|
126
127
|
marginLeft?: number;
|
|
127
128
|
marginBottom?: number;
|
|
@@ -149,10 +150,11 @@ export type FacetRectComposition = {
|
|
|
149
150
|
|
|
150
151
|
export type RepeatMatrixComposition = {
|
|
151
152
|
type?: 'repeatMatrix';
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
padding?: Padding;
|
|
154
|
+
paddingLeft?: Padding;
|
|
155
|
+
paddingRight?: Padding;
|
|
156
|
+
paddingTop?: Padding;
|
|
157
|
+
paddingBottom?: Padding;
|
|
156
158
|
margin?: number;
|
|
157
159
|
marginLeft?: number;
|
|
158
160
|
marginBottom?: number;
|
|
@@ -181,10 +183,11 @@ export type RepeatMatrixComposition = {
|
|
|
181
183
|
|
|
182
184
|
export type FacetCircleComposition = {
|
|
183
185
|
type?: 'facetCircle';
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
padding?: Padding;
|
|
187
|
+
paddingLeft?: Padding;
|
|
188
|
+
paddingRight?: Padding;
|
|
189
|
+
paddingTop?: Padding;
|
|
190
|
+
paddingBottom?: Padding;
|
|
188
191
|
margin?: number;
|
|
189
192
|
marginLeft?: number;
|
|
190
193
|
marginBottom?: number;
|
|
@@ -10,6 +10,7 @@ export type DataTransform =
|
|
|
10
10
|
| FilterDataTransform
|
|
11
11
|
| MapTransform
|
|
12
12
|
| SliceTransform
|
|
13
|
+
| KDEDataTransform
|
|
13
14
|
| CustomTransform;
|
|
14
15
|
|
|
15
16
|
export type DataTransformTypes =
|
|
@@ -22,6 +23,7 @@ export type DataTransformTypes =
|
|
|
22
23
|
| 'filter'
|
|
23
24
|
| 'map'
|
|
24
25
|
| 'slice'
|
|
26
|
+
| 'kde'
|
|
25
27
|
| 'custom'
|
|
26
28
|
| DataComponent;
|
|
27
29
|
|
|
@@ -119,6 +121,39 @@ export type CustomDataTransform = {
|
|
|
119
121
|
callback?: (d: any) => any;
|
|
120
122
|
};
|
|
121
123
|
|
|
124
|
+
export type KDEDataTransform = {
|
|
125
|
+
type?: 'kde';
|
|
126
|
+
/**
|
|
127
|
+
* Kernel Density Estimation field.
|
|
128
|
+
*/
|
|
129
|
+
field: string;
|
|
130
|
+
/**
|
|
131
|
+
* Group data by fields.
|
|
132
|
+
*/
|
|
133
|
+
groupBy: string[];
|
|
134
|
+
/**
|
|
135
|
+
* Generate new fieds, default: ['y', 'size']
|
|
136
|
+
*/
|
|
137
|
+
as?: ['y', 'size'];
|
|
138
|
+
/**
|
|
139
|
+
* Defaults to smallest value in the array minus some threshold.
|
|
140
|
+
*/
|
|
141
|
+
min?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Defaults to largest value in the array plus some threshold.
|
|
144
|
+
*/
|
|
145
|
+
max?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Number of points to represent the pdf. Defaults to 10.
|
|
148
|
+
*/
|
|
149
|
+
size?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Determine how many points to the left and right does an element affect,
|
|
152
|
+
* similar to bandwidth in kernel density estimation. Defaults to 2.
|
|
153
|
+
*/
|
|
154
|
+
width?: number;
|
|
155
|
+
};
|
|
156
|
+
|
|
122
157
|
export type CustomTransform = {
|
|
123
158
|
type?: DataComponent;
|
|
124
159
|
[key: string]: any;
|
package/src/spec/interaction.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { TooltipStyleProps } from '@antv/gui';
|
|
2
|
-
import { InteractionComponent } from '../runtime';
|
|
2
|
+
import { BBox, InteractionComponent } from '../runtime';
|
|
3
3
|
import { FisheyeCoordinate } from './coordinateTransform';
|
|
4
4
|
import { TooltipItemValue } from './component';
|
|
5
|
-
import { AtheisticChanelTypes } from './mark';
|
|
6
5
|
|
|
7
6
|
export type Interaction =
|
|
8
7
|
| ElementHighlightInteraction
|
|
@@ -176,6 +175,8 @@ export type TooltipInteraction = {
|
|
|
176
175
|
crosshairs?: boolean;
|
|
177
176
|
groupName?: boolean;
|
|
178
177
|
position?: TooltipStyleProps['position'];
|
|
178
|
+
bounding?: BBox;
|
|
179
|
+
mount?: string | HTMLElement;
|
|
179
180
|
// enterable?: boolean;
|
|
180
181
|
sort?: (d: TooltipItemValue) => any;
|
|
181
182
|
filter?: (d: TooltipItemValue) => any;
|
package/src/spec/mark.ts
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
TitleComponent,
|
|
16
16
|
TooltipComponent,
|
|
17
17
|
} from './component';
|
|
18
|
-
import { Closeable, Literal2Object } from './utils';
|
|
18
|
+
import { Closeable, Literal2Object, Padding } from './utils';
|
|
19
19
|
|
|
20
20
|
export type Mark =
|
|
21
21
|
| IntervalMark
|
|
@@ -46,6 +46,7 @@ export type Mark =
|
|
|
46
46
|
| ForceGraphMark
|
|
47
47
|
| TreeMark
|
|
48
48
|
| WordCloudMark
|
|
49
|
+
| DensityMark
|
|
49
50
|
| CustomMark;
|
|
50
51
|
|
|
51
52
|
export type MarkTypes =
|
|
@@ -79,6 +80,7 @@ export type MarkTypes =
|
|
|
79
80
|
| 'tree'
|
|
80
81
|
| 'wordCloud'
|
|
81
82
|
| 'gauge'
|
|
83
|
+
| 'density'
|
|
82
84
|
| MarkComponent;
|
|
83
85
|
|
|
84
86
|
export type ChannelTypes =
|
|
@@ -121,11 +123,11 @@ export type BaseMark<T extends MarkTypes, C extends string = ChannelTypes> = {
|
|
|
121
123
|
y?: number;
|
|
122
124
|
width?: number;
|
|
123
125
|
height?: number;
|
|
124
|
-
paddingLeft?:
|
|
125
|
-
paddingRight?:
|
|
126
|
-
paddingBottom?:
|
|
127
|
-
paddingTop?:
|
|
128
|
-
padding?:
|
|
126
|
+
paddingLeft?: Padding;
|
|
127
|
+
paddingRight?: Padding;
|
|
128
|
+
paddingBottom?: Padding;
|
|
129
|
+
paddingTop?: Padding;
|
|
130
|
+
padding?: Padding;
|
|
129
131
|
inset?: number;
|
|
130
132
|
insetLeft?: number;
|
|
131
133
|
insetBottom?: number;
|
|
@@ -370,4 +372,6 @@ export type GaugeMark = BaseMark<
|
|
|
370
372
|
| ChannelTypes
|
|
371
373
|
>;
|
|
372
374
|
|
|
375
|
+
export type DensityMark = BaseMark<'density', ChannelTypes | 'series'>;
|
|
376
|
+
|
|
373
377
|
export type CustomMark = BaseMark<MarkComponent, ChannelTypes>;
|
package/src/spec/transform.ts
CHANGED
package/src/spec/utils.ts
CHANGED
package/src/stdlib/index.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
ForceGraph,
|
|
40
40
|
Tree as TreeGeometry,
|
|
41
41
|
WordCloud as WordCloudGeometry,
|
|
42
|
+
Density as DensityGeometry,
|
|
42
43
|
Gauge,
|
|
43
44
|
} from '../mark';
|
|
44
45
|
import { Category10, Category20 } from '../palette';
|
|
@@ -101,6 +102,7 @@ import {
|
|
|
101
102
|
Polygon,
|
|
102
103
|
Ribbon,
|
|
103
104
|
Box,
|
|
105
|
+
Violin,
|
|
104
106
|
Funnel,
|
|
105
107
|
Pyramid,
|
|
106
108
|
Vector,
|
|
@@ -108,6 +110,7 @@ import {
|
|
|
108
110
|
Label,
|
|
109
111
|
Path as PathShape,
|
|
110
112
|
HollowPath,
|
|
113
|
+
Density as DensityShape,
|
|
111
114
|
Shape as CustomShape,
|
|
112
115
|
} from '../shape';
|
|
113
116
|
import { Classic, ClassicDark, Academy } from '../theme';
|
|
@@ -238,6 +241,7 @@ import {
|
|
|
238
241
|
WordCloud,
|
|
239
242
|
Join,
|
|
240
243
|
Sort,
|
|
244
|
+
KDE,
|
|
241
245
|
} from '../data';
|
|
242
246
|
import {
|
|
243
247
|
OverlapDodgeY,
|
|
@@ -266,6 +270,7 @@ export function createLibrary(): G2Library {
|
|
|
266
270
|
'data.arc': ArcTransform,
|
|
267
271
|
'data.wordCloud': WordCloud,
|
|
268
272
|
'data.join': Join,
|
|
273
|
+
'data.kde': KDE,
|
|
269
274
|
// 'transform.voronoi': Voronoi,
|
|
270
275
|
'transform.maybeZeroY1': MaybeZeroY1,
|
|
271
276
|
'transform.maybeZeroX': MaybeZeroX,
|
|
@@ -350,6 +355,7 @@ export function createLibrary(): G2Library {
|
|
|
350
355
|
'mark.gauge': Gauge,
|
|
351
356
|
'mark.tree': TreeGeometry,
|
|
352
357
|
'mark.wordCloud': WordCloudGeometry,
|
|
358
|
+
'mark.density': DensityGeometry,
|
|
353
359
|
'palette.category10': Category10,
|
|
354
360
|
'palette.category20': Category20,
|
|
355
361
|
'scale.linear': Linear,
|
|
@@ -412,6 +418,7 @@ export function createLibrary(): G2Library {
|
|
|
412
418
|
'shape.polygon.polygon': Polygon,
|
|
413
419
|
'shape.polygon.ribbon': Ribbon,
|
|
414
420
|
'shape.box.box': Box,
|
|
421
|
+
'shape.box.violin': Violin,
|
|
415
422
|
'shape.vector.vector': Vector,
|
|
416
423
|
'shape.label.label': Label,
|
|
417
424
|
'shape.text.badge': Badge,
|
|
@@ -424,6 +431,7 @@ export function createLibrary(): G2Library {
|
|
|
424
431
|
'shape.rangeY.range': RectShape,
|
|
425
432
|
'shape.path.path': PathShape,
|
|
426
433
|
'shape.path.hollow': HollowPath,
|
|
434
|
+
'shape.density.density': DensityShape,
|
|
427
435
|
'theme.classic': Classic,
|
|
428
436
|
'theme.classicDark': ClassicDark,
|
|
429
437
|
'theme.academy': Academy,
|
package/src/theme/classic.ts
CHANGED
|
@@ -259,6 +259,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
259
259
|
gridDirection: 'negative',
|
|
260
260
|
labelDirection: 'positive',
|
|
261
261
|
labelSpacing: 12,
|
|
262
|
+
labelAutoRotate: true,
|
|
262
263
|
tickDirection: 'positive',
|
|
263
264
|
titlePosition: 'bottom',
|
|
264
265
|
titleSpacing: 10,
|
|
@@ -280,6 +281,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
280
281
|
gridDirection: 'positive',
|
|
281
282
|
labelDirection: 'negative',
|
|
282
283
|
labelSpacing: 4,
|
|
284
|
+
labelAutoRotate: false,
|
|
283
285
|
tickDirection: 'negative',
|
|
284
286
|
titlePosition: 'right',
|
|
285
287
|
titleSpacing: 0,
|
|
@@ -348,6 +350,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
348
350
|
labelFontWeight: 'normal',
|
|
349
351
|
labelSpacing: 8,
|
|
350
352
|
tick: true,
|
|
353
|
+
// title: false,
|
|
351
354
|
// [todo] legend rail
|
|
352
355
|
},
|
|
353
356
|
label: {
|
package/src/theme/classicDark.ts
CHANGED
package/src/transform/filter.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type FilterOptions = Omit<FilterTransform, 'type'>;
|
|
|
11
11
|
*/
|
|
12
12
|
export const Filter: TC<FilterOptions> = (options = {}) => {
|
|
13
13
|
return (I, mark) => {
|
|
14
|
-
const { encode } = mark;
|
|
14
|
+
const { encode, data } = mark;
|
|
15
15
|
const filters = Object.entries(options)
|
|
16
16
|
.map(([key, value]) => {
|
|
17
17
|
const [V] = columnOf(encode, key);
|
|
@@ -43,7 +43,11 @@ export const Filter: TC<FilterOptions> = (options = {}) => {
|
|
|
43
43
|
});
|
|
44
44
|
return [
|
|
45
45
|
newIndex,
|
|
46
|
-
deepMix({}, mark, {
|
|
46
|
+
deepMix({}, mark, {
|
|
47
|
+
encode: Object.fromEntries(newEncodes),
|
|
48
|
+
// Filter data for tooltip item.
|
|
49
|
+
data: FI.map((i) => data[i]),
|
|
50
|
+
}),
|
|
47
51
|
];
|
|
48
52
|
};
|
|
49
53
|
};
|
|
@@ -6,7 +6,7 @@ export type ElementDescriptor = {
|
|
|
6
6
|
|
|
7
7
|
export function createElement<T = Record<string, any>>(
|
|
8
8
|
descriptor: ElementDescriptor | ElementDescriptor['render'],
|
|
9
|
-
): new () => DisplayObject {
|
|
9
|
+
): new (T?) => DisplayObject {
|
|
10
10
|
const render =
|
|
11
11
|
typeof descriptor === 'function' ? descriptor : descriptor.render;
|
|
12
12
|
return class extends CustomElement<T> {
|
package/src/utils/helper.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DisplayObject } from '@antv/g';
|
|
2
|
-
import { lowerFirst,
|
|
2
|
+
import { lowerFirst, upperFirst } from '@antv/util';
|
|
3
3
|
|
|
4
4
|
export function identity<T>(x: T): T {
|
|
5
5
|
return x;
|
|
@@ -116,6 +116,17 @@ export function filterPrefixObject(
|
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
export function omitPrefixObject(
|
|
120
|
+
obj: Record<string, any>,
|
|
121
|
+
...prefixes: string[]
|
|
122
|
+
) {
|
|
123
|
+
return Object.fromEntries(
|
|
124
|
+
Object.entries(obj).filter(([key]) =>
|
|
125
|
+
prefixes.every((prefix) => !key.startsWith(prefix)),
|
|
126
|
+
),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
119
130
|
export function maybePercentage(x: number | string, size: number) {
|
|
120
131
|
if (x === undefined) return null;
|
|
121
132
|
if (typeof x === 'number') return x;
|
package/src/utils/scale.ts
CHANGED
|
@@ -47,7 +47,11 @@ export function pixelsOf(selection, scale, coordinate) {
|
|
|
47
47
|
const [[minX, maxX], [minY, maxY]] = selection;
|
|
48
48
|
const { x: scaleX, y: scaleY } = scale;
|
|
49
49
|
const p0 = [scaleX.map(minX), scaleY.map(minY)];
|
|
50
|
-
const
|
|
50
|
+
const maybeStep = (scale) => (scale.getStep ? scale.getStep() : 0);
|
|
51
|
+
const p1 = [
|
|
52
|
+
scaleX.map(maxX) + maybeStep(scaleX),
|
|
53
|
+
scaleY.map(maxY) + maybeStep(scaleY),
|
|
54
|
+
];
|
|
51
55
|
const [x, y] = coordinate.map(p0);
|
|
52
56
|
const [x1, y1] = coordinate.map(p1);
|
|
53
57
|
return [x, y, x1, y1];
|
package/src/utils/size.ts
CHANGED
|
@@ -54,21 +54,27 @@ export function getBBoxSize(options: G2View): Size {
|
|
|
54
54
|
insetTop = inset,
|
|
55
55
|
insetBottom = inset,
|
|
56
56
|
} = options;
|
|
57
|
+
|
|
58
|
+
// @todo Add this padding to theme.
|
|
59
|
+
// 30 is default size for padding, which defined in runtime.
|
|
60
|
+
const maybeAuto = (padding) => (padding === 'auto' ? 30 : padding);
|
|
61
|
+
|
|
57
62
|
const finalWidth =
|
|
58
63
|
width -
|
|
59
|
-
paddingLeft -
|
|
60
|
-
paddingRight -
|
|
64
|
+
maybeAuto(paddingLeft) -
|
|
65
|
+
maybeAuto(paddingRight) -
|
|
61
66
|
marginLeft -
|
|
62
67
|
marginRight -
|
|
63
68
|
insetLeft -
|
|
64
69
|
insetRight;
|
|
65
70
|
const finalHeight =
|
|
66
71
|
height -
|
|
67
|
-
paddingTop -
|
|
68
|
-
paddingBottom -
|
|
72
|
+
maybeAuto(paddingTop) -
|
|
73
|
+
maybeAuto(paddingBottom) -
|
|
69
74
|
marginTop -
|
|
70
75
|
marginBottom -
|
|
71
76
|
insetTop -
|
|
72
77
|
insetBottom;
|
|
78
|
+
|
|
73
79
|
return { width: finalWidth, height: finalHeight };
|
|
74
80
|
}
|
|
File without changes
|
|
File without changes
|