@antv/g2 5.0.23 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +3 -3
- package/esm/api/chart.d.ts +5 -16
- package/esm/api/extend.d.ts +5 -1
- package/esm/api/extend.js.map +1 -1
- package/esm/api/library.d.ts +5 -16
- package/esm/api/runtime.js +4 -1
- package/esm/api/runtime.js.map +1 -1
- package/esm/lib/builtinlib.d.ts +13 -0
- package/esm/lib/builtinlib.js +21 -0
- package/esm/lib/builtinlib.js.map +1 -0
- package/esm/lib/core.d.ts +1 -12
- package/esm/lib/core.js +4 -16
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/graph.d.ts +5 -0
- package/esm/lib/graph.js +7 -1
- package/esm/lib/graph.js.map +1 -1
- package/esm/lib/plot.d.ts +0 -5
- package/esm/lib/plot.js +2 -7
- package/esm/lib/plot.js.map +1 -1
- package/esm/lib/std.d.ts +5 -16
- package/esm/lib/threed.d.ts +1 -0
- package/esm/lib/threed.js +2 -1
- package/esm/lib/threed.js.map +1 -1
- package/esm/mark/index.d.ts +1 -0
- package/esm/mark/index.js +1 -0
- package/esm/mark/index.js.map +1 -1
- package/esm/mark/line3D.d.ts +7 -0
- package/esm/mark/line3D.js +65 -0
- package/esm/mark/line3D.js.map +1 -0
- package/esm/runtime/layout.js +1 -0
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/library.d.ts +1 -1
- package/esm/runtime/library.js +3 -1
- package/esm/runtime/library.js.map +1 -1
- package/esm/runtime/plot.js +5 -1
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +1 -1
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/transform.js +9 -1
- package/esm/runtime/transform.js.map +1 -1
- package/esm/shape/index.d.ts +1 -0
- package/esm/shape/index.js +1 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/line3D/line.d.ts +3 -0
- package/esm/shape/line3D/line.js +30 -0
- package/esm/shape/line3D/line.js.map +1 -0
- package/esm/shape/point3D/cube.js +2 -2
- package/esm/shape/point3D/cube.js.map +1 -1
- package/esm/shape/point3D/sphere.js +2 -2
- package/esm/shape/point3D/sphere.js.map +1 -1
- package/esm/theme/classic.js +2 -0
- package/esm/theme/classic.js.map +1 -1
- package/esm/theme/light.js +11 -11
- package/lib/api/chart.d.ts +5 -16
- package/lib/api/extend.d.ts +5 -1
- package/lib/api/extend.js.map +1 -1
- package/lib/api/library.d.ts +5 -16
- package/lib/api/runtime.js +4 -1
- package/lib/api/runtime.js.map +1 -1
- package/lib/lib/builtinlib.d.ts +13 -0
- package/lib/lib/builtinlib.js +25 -0
- package/lib/lib/builtinlib.js.map +1 -0
- package/lib/lib/core.d.ts +1 -12
- package/lib/lib/core.js +0 -12
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/graph.d.ts +5 -0
- package/lib/lib/graph.js +6 -0
- package/lib/lib/graph.js.map +1 -1
- package/lib/lib/plot.d.ts +0 -5
- package/lib/lib/plot.js +0 -5
- package/lib/lib/plot.js.map +1 -1
- package/lib/lib/std.d.ts +5 -16
- package/lib/lib/threed.d.ts +1 -0
- package/lib/lib/threed.js +1 -0
- package/lib/lib/threed.js.map +1 -1
- package/lib/mark/index.d.ts +1 -0
- package/lib/mark/index.js +3 -1
- package/lib/mark/index.js.map +1 -1
- package/lib/mark/line3D.d.ts +7 -0
- package/lib/mark/line3D.js +69 -0
- package/lib/mark/line3D.js.map +1 -0
- package/lib/runtime/layout.js +1 -0
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/library.d.ts +1 -1
- package/lib/runtime/library.js +3 -1
- package/lib/runtime/library.js.map +1 -1
- package/lib/runtime/plot.js +5 -1
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +1 -1
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/transform.js +9 -1
- package/lib/runtime/transform.js.map +1 -1
- package/lib/shape/index.d.ts +1 -0
- package/lib/shape/index.js +8 -6
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/line3D/line.d.ts +3 -0
- package/lib/shape/line3D/line.js +34 -0
- package/lib/shape/line3D/line.js.map +1 -0
- package/lib/shape/point3D/cube.js +1 -1
- package/lib/shape/point3D/cube.js.map +1 -1
- package/lib/shape/point3D/sphere.js +1 -1
- package/lib/shape/point3D/sphere.js.map +1 -1
- package/lib/theme/classic.js +2 -0
- package/lib/theme/classic.js.map +1 -1
- package/lib/theme/light.js +11 -11
- package/package.json +2 -2
- package/src/api/extend.ts +6 -1
- package/src/api/runtime.ts +6 -3
- package/src/lib/builtinlib.ts +28 -0
- package/src/lib/core.ts +0 -22
- package/src/lib/graph.ts +7 -1
- package/src/lib/plot.ts +2 -7
- package/src/lib/threed.ts +2 -1
- package/src/mark/index.ts +1 -0
- package/src/mark/line3D.ts +81 -0
- package/src/runtime/layout.ts +1 -0
- package/src/runtime/library.ts +4 -1
- package/src/runtime/plot.ts +9 -1
- package/src/runtime/render.ts +1 -1
- package/src/runtime/transform.ts +12 -1
- package/src/shape/index.ts +1 -0
- package/src/shape/line3D/line.ts +29 -0
- package/src/shape/point3D/cube.ts +2 -2
- package/src/shape/point3D/sphere.ts +2 -2
- package/src/theme/classic.ts +2 -0
- package/src/theme/light.ts +11 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g2",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "the Grammar of Graphics in Javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
|
|
43
43
|
},
|
|
44
44
|
"sideEffects": [
|
|
45
|
-
"./
|
|
45
|
+
"./esm/index.js"
|
|
46
46
|
],
|
|
47
47
|
"keywords": [
|
|
48
48
|
"antv",
|
package/src/api/extend.ts
CHANGED
|
@@ -16,9 +16,14 @@ type CompositionOf<Library> = Of<
|
|
|
16
16
|
CompositionOf<Library>
|
|
17
17
|
>;
|
|
18
18
|
|
|
19
|
+
type BuiltinComposition = {
|
|
20
|
+
'composition.mark': any;
|
|
21
|
+
'composition.view': any;
|
|
22
|
+
};
|
|
23
|
+
|
|
19
24
|
export type API<Spec, Library> = Runtime<Spec> &
|
|
20
25
|
MarkOf<Library, (composite?) => MarkNode> &
|
|
21
|
-
CompositionOf<Library>;
|
|
26
|
+
CompositionOf<Library & BuiltinComposition>;
|
|
22
27
|
|
|
23
28
|
export function extend<
|
|
24
29
|
Spec extends G2Spec = G2Spec,
|
package/src/api/runtime.ts
CHANGED
|
@@ -222,9 +222,12 @@ export class Runtime<Spec extends G2Spec = G2Spec> extends CompositionNode {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// Create composition generators.
|
|
225
|
-
const compositions =
|
|
226
|
-
|
|
227
|
-
|
|
225
|
+
const compositions = [
|
|
226
|
+
'composition.view', // chat.view()
|
|
227
|
+
...Object.keys(library).filter(
|
|
228
|
+
(key) => key.startsWith('composition.') && key !== 'composition.mark',
|
|
229
|
+
),
|
|
230
|
+
];
|
|
228
231
|
this._compositions = Object.fromEntries(
|
|
229
232
|
compositions.map((key) => {
|
|
230
233
|
const name = key.split('.').pop();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AxisLinear,
|
|
3
|
+
AxisArc,
|
|
4
|
+
AxisRadar,
|
|
5
|
+
LegendContinuousBlock,
|
|
6
|
+
LegendContinuousBlockSize,
|
|
7
|
+
LegendContinuousSize,
|
|
8
|
+
} from '../component';
|
|
9
|
+
import { Mark, View } from '../composition';
|
|
10
|
+
import { LabelShape } from '../shape';
|
|
11
|
+
import { Event } from '../interaction/event';
|
|
12
|
+
|
|
13
|
+
// Some private visual components, they are not public to
|
|
14
|
+
// users, only for runtime.
|
|
15
|
+
export function builtinlib() {
|
|
16
|
+
return {
|
|
17
|
+
'component.axisRadar': AxisRadar,
|
|
18
|
+
'component.axisLinear': AxisLinear,
|
|
19
|
+
'component.axisArc': AxisArc,
|
|
20
|
+
'component.legendContinuousBlock': LegendContinuousBlock,
|
|
21
|
+
'component.legendContinuousBlockSize': LegendContinuousBlockSize,
|
|
22
|
+
'component.legendContinuousSize': LegendContinuousSize,
|
|
23
|
+
'interaction.event': Event,
|
|
24
|
+
'composition.mark': Mark,
|
|
25
|
+
'composition.view': View,
|
|
26
|
+
'shape.label.label': LabelShape,
|
|
27
|
+
} as const;
|
|
28
|
+
}
|
package/src/lib/core.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Cartesian,
|
|
3
3
|
Polar,
|
|
4
|
-
Helix,
|
|
5
4
|
Transpose,
|
|
6
5
|
Theta,
|
|
7
6
|
Parallel,
|
|
@@ -53,16 +52,10 @@ import {
|
|
|
53
52
|
} from '../scale';
|
|
54
53
|
import { Classic, ClassicDark, Academy, Light } from '../theme';
|
|
55
54
|
import {
|
|
56
|
-
AxisLinear,
|
|
57
|
-
AxisArc,
|
|
58
55
|
AxisX,
|
|
59
56
|
AxisY,
|
|
60
|
-
AxisRadar,
|
|
61
57
|
LegendCategory,
|
|
62
58
|
LegendContinuous,
|
|
63
|
-
LegendContinuousBlock,
|
|
64
|
-
LegendContinuousBlockSize,
|
|
65
|
-
LegendContinuousSize,
|
|
66
59
|
TitleComponent,
|
|
67
60
|
SliderX,
|
|
68
61
|
SliderY,
|
|
@@ -106,14 +99,11 @@ import {
|
|
|
106
99
|
BrushYFilter,
|
|
107
100
|
SliderFilter,
|
|
108
101
|
Poptip,
|
|
109
|
-
Event,
|
|
110
102
|
ScrollbarFilter,
|
|
111
103
|
} from '../interaction';
|
|
112
104
|
import {
|
|
113
105
|
SpaceLayer,
|
|
114
106
|
SpaceFlex,
|
|
115
|
-
Mark,
|
|
116
|
-
View,
|
|
117
107
|
FacetRect,
|
|
118
108
|
FacetCircle,
|
|
119
109
|
RepeatMatrix,
|
|
@@ -167,7 +157,6 @@ import {
|
|
|
167
157
|
ContrastReverse,
|
|
168
158
|
OverlapHide,
|
|
169
159
|
} from '../label-transform';
|
|
170
|
-
import { LabelShape } from '../shape';
|
|
171
160
|
|
|
172
161
|
export function corelib() {
|
|
173
162
|
return {
|
|
@@ -211,7 +200,6 @@ export function corelib() {
|
|
|
211
200
|
'transform.filter': Filter,
|
|
212
201
|
'coordinate.cartesian': Cartesian,
|
|
213
202
|
'coordinate.polar': Polar,
|
|
214
|
-
'coordinate.helix': Helix,
|
|
215
203
|
'coordinate.transpose': Transpose,
|
|
216
204
|
'coordinate.theta': Theta,
|
|
217
205
|
'coordinate.parallel': Parallel,
|
|
@@ -244,7 +232,6 @@ export function corelib() {
|
|
|
244
232
|
'mark.shape': Shape,
|
|
245
233
|
'mark.density': Density,
|
|
246
234
|
'mark.heatmap': Heatmap,
|
|
247
|
-
'shape.label.label': LabelShape,
|
|
248
235
|
'palette.category10': Category10,
|
|
249
236
|
'palette.category20': Category20,
|
|
250
237
|
'scale.linear': ScaleLinear,
|
|
@@ -267,14 +254,8 @@ export function corelib() {
|
|
|
267
254
|
'theme.light': Light,
|
|
268
255
|
'component.axisX': AxisX,
|
|
269
256
|
'component.axisY': AxisY,
|
|
270
|
-
'component.axisRadar': AxisRadar,
|
|
271
|
-
'component.axisLinear': AxisLinear,
|
|
272
|
-
'component.axisArc': AxisArc,
|
|
273
257
|
'component.legendCategory': LegendCategory,
|
|
274
258
|
'component.legendContinuous': LegendContinuous,
|
|
275
|
-
'component.legendContinuousBlock': LegendContinuousBlock,
|
|
276
|
-
'component.legendContinuousBlockSize': LegendContinuousBlockSize,
|
|
277
|
-
'component.legendContinuousSize': LegendContinuousSize,
|
|
278
259
|
'component.legends': Legends,
|
|
279
260
|
'component.title': TitleComponent,
|
|
280
261
|
'component.sliderX': SliderX,
|
|
@@ -315,11 +296,8 @@ export function corelib() {
|
|
|
315
296
|
'interaction.sliderFilter': SliderFilter,
|
|
316
297
|
'interaction.scrollbarFilter': ScrollbarFilter,
|
|
317
298
|
'interaction.poptip': Poptip,
|
|
318
|
-
'interaction.event': Event,
|
|
319
299
|
'composition.spaceLayer': SpaceLayer,
|
|
320
300
|
'composition.spaceFlex': SpaceFlex,
|
|
321
|
-
'composition.mark': Mark,
|
|
322
|
-
'composition.view': View,
|
|
323
301
|
'composition.facetRect': FacetRect,
|
|
324
302
|
'composition.repeatMatrix': RepeatMatrix,
|
|
325
303
|
'composition.facetCircle': FacetCircle,
|
package/src/lib/graph.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { ForceGraph, Tree } from '../mark';
|
|
1
|
+
import { Sankey, Treemap, Pack, ForceGraph, Tree } from '../mark';
|
|
2
|
+
import { Arc, Cluster } from '../data';
|
|
2
3
|
|
|
3
4
|
export function graphlib() {
|
|
4
5
|
return {
|
|
6
|
+
'data.arc': Arc,
|
|
7
|
+
'data.cluster': Cluster,
|
|
5
8
|
'mark.forceGraph': ForceGraph,
|
|
6
9
|
'mark.tree': Tree,
|
|
10
|
+
'mark.pack': Pack,
|
|
11
|
+
'mark.sankey': Sankey,
|
|
12
|
+
'mark.treemap': Treemap,
|
|
7
13
|
} as const;
|
|
8
14
|
}
|
package/src/lib/plot.ts
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Boxplot, WordCloud, Gauge } from '../mark';
|
|
2
|
+
import { Venn } from '../data';
|
|
3
3
|
|
|
4
4
|
export function plotlib() {
|
|
5
5
|
return {
|
|
6
6
|
'data.venn': Venn,
|
|
7
|
-
'data.arc': Arc,
|
|
8
|
-
'data.cluster': Cluster,
|
|
9
|
-
'mark.sankey': Sankey,
|
|
10
|
-
'mark.treemap': Treemap,
|
|
11
7
|
'mark.boxplot': Boxplot,
|
|
12
|
-
'mark.pack': Pack,
|
|
13
8
|
'mark.gauge': Gauge,
|
|
14
9
|
'mark.wordCloud': WordCloud,
|
|
15
10
|
} as const;
|
package/src/lib/threed.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Cartesian3D } from '../coordinate';
|
|
2
2
|
import { AxisZ } from '../component';
|
|
3
|
-
import { Point3D } from '../mark';
|
|
3
|
+
import { Point3D, Line3D } from '../mark';
|
|
4
4
|
|
|
5
5
|
export function threedlib() {
|
|
6
6
|
return {
|
|
7
7
|
'coordinate.cartesian3D': Cartesian3D,
|
|
8
8
|
'component.axisZ': AxisZ,
|
|
9
9
|
'mark.point3D': Point3D,
|
|
10
|
+
'mark.line3D': Line3D,
|
|
10
11
|
} as const;
|
|
11
12
|
}
|
package/src/mark/index.ts
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { group } from 'd3-array';
|
|
2
|
+
import { Mark, MarkComponent as MC, SingleMark, Vector3 } from '../runtime';
|
|
3
|
+
import { LineMark } from '../spec';
|
|
4
|
+
import { Line3DShape } from '../shape';
|
|
5
|
+
import { MaybeSeries } from '../transform';
|
|
6
|
+
import {
|
|
7
|
+
baseGeometryChannels,
|
|
8
|
+
basePostInference,
|
|
9
|
+
basePreInference,
|
|
10
|
+
tooltip3d,
|
|
11
|
+
} from './utils';
|
|
12
|
+
|
|
13
|
+
const shape = {
|
|
14
|
+
line: Line3DShape,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type LineOptions = Omit<LineMark, 'type'>;
|
|
18
|
+
|
|
19
|
+
const line: Mark = (index, scale, value, coordinate) => {
|
|
20
|
+
const { series: S, x: X, y: Y, z: Z } = value;
|
|
21
|
+
const { x, y, z } = scale;
|
|
22
|
+
|
|
23
|
+
// Because x and y channel is not strictly required in Line.props,
|
|
24
|
+
// it should throw error with empty x, y or z channels.
|
|
25
|
+
if (X === undefined || Y === undefined || Z === undefined) {
|
|
26
|
+
throw new Error('Missing encode for x, y or z channel.');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Group data into series.
|
|
30
|
+
// There is only one series without specified series encode.
|
|
31
|
+
const series = S ? Array.from(group(index, (i) => S[i]).values()) : [index];
|
|
32
|
+
const I = series.map((group) => group[0]).filter((i) => i !== undefined);
|
|
33
|
+
|
|
34
|
+
// A group of data corresponds to one line.
|
|
35
|
+
const xoffset = (x?.getBandWidth?.() || 0) / 2;
|
|
36
|
+
const yoffset = (y?.getBandWidth?.() || 0) / 2;
|
|
37
|
+
const zoffset = (z?.getBandWidth?.() || 0) / 2;
|
|
38
|
+
const P = Array.from(series, (I) => {
|
|
39
|
+
return I.map((i) =>
|
|
40
|
+
coordinate.map([
|
|
41
|
+
(+X[i] || 0) + xoffset,
|
|
42
|
+
(+Y[i] || 0) + yoffset,
|
|
43
|
+
(+Z[i] || 0) + zoffset,
|
|
44
|
+
]),
|
|
45
|
+
) as Vector3[];
|
|
46
|
+
});
|
|
47
|
+
return [I, P, series];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Convert value for each channel to line shapes.
|
|
52
|
+
*/
|
|
53
|
+
export const Line3D: MC<LineOptions> = () => {
|
|
54
|
+
return (index, scale, value, coordinate) => {
|
|
55
|
+
const mark = line;
|
|
56
|
+
return (mark as SingleMark)(index, scale, value, coordinate);
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
Line3D.props = {
|
|
61
|
+
defaultShape: 'line',
|
|
62
|
+
defaultLabelShape: 'label',
|
|
63
|
+
composite: false,
|
|
64
|
+
shape,
|
|
65
|
+
channels: [
|
|
66
|
+
...baseGeometryChannels({ shapes: Object.keys(shape) }),
|
|
67
|
+
{ name: 'x' },
|
|
68
|
+
{ name: 'y' },
|
|
69
|
+
{ name: 'z' },
|
|
70
|
+
{ name: 'position', independent: true },
|
|
71
|
+
{ name: 'size' },
|
|
72
|
+
{ name: 'series', scale: 'identity' },
|
|
73
|
+
],
|
|
74
|
+
preInference: [...basePreInference(), { type: MaybeSeries }],
|
|
75
|
+
postInference: [...basePostInference(), ...tooltip3d()],
|
|
76
|
+
interaction: {
|
|
77
|
+
shareTooltip: false,
|
|
78
|
+
seriesTooltip: false,
|
|
79
|
+
crosshairs: false,
|
|
80
|
+
},
|
|
81
|
+
};
|
package/src/runtime/layout.ts
CHANGED
|
@@ -311,6 +311,7 @@ function computePadding(
|
|
|
311
311
|
|
|
312
312
|
for (const position of positions) {
|
|
313
313
|
const key = `padding${capitalizeFirst(camelCase(position))}`;
|
|
314
|
+
const insetKey = `inset${capitalizeFirst(camelCase(position))}`;
|
|
314
315
|
const components = positionComponents.get(position) || [];
|
|
315
316
|
const value = layout[key];
|
|
316
317
|
const defaultSizeOf = (d) => {
|
package/src/runtime/library.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IDocument } from '@antv/g';
|
|
2
2
|
import { error } from '../utils/helper';
|
|
3
|
+
import { builtinlib } from '../lib/builtinlib';
|
|
3
4
|
import { G2ComponentOptions, G2Context, G2Library } from './types/options';
|
|
4
5
|
import {
|
|
5
6
|
G2Component,
|
|
@@ -13,8 +14,10 @@ export function useLibrary<
|
|
|
13
14
|
V extends G2ComponentValue,
|
|
14
15
|
>(
|
|
15
16
|
namespace: G2ComponentNamespaces,
|
|
16
|
-
|
|
17
|
+
publicLibrary: G2Library,
|
|
17
18
|
): [(options: O, context?) => V, (type: O['type']) => C] {
|
|
19
|
+
const library = { ...builtinlib(), ...publicLibrary };
|
|
20
|
+
|
|
18
21
|
const create = (type: O['type']) => {
|
|
19
22
|
if (typeof type !== 'string') return type;
|
|
20
23
|
const key = `${namespace}.${type}`;
|
package/src/runtime/plot.ts
CHANGED
|
@@ -500,8 +500,16 @@ async function transformMarks(
|
|
|
500
500
|
const { composite = true } = props;
|
|
501
501
|
if (!composite) flattenMarks.push(mark);
|
|
502
502
|
else {
|
|
503
|
+
// Unwrap data from { value: data } to data,
|
|
504
|
+
// then the composite mark can process the normalized data.
|
|
505
|
+
const { data } = mark;
|
|
506
|
+
const newMark = {
|
|
507
|
+
...mark,
|
|
508
|
+
data: data ? (Array.isArray(data) ? data : data.value) : data,
|
|
509
|
+
};
|
|
510
|
+
|
|
503
511
|
// Convert composite mark to marks.
|
|
504
|
-
const marks = await useMark(
|
|
512
|
+
const marks = await useMark(newMark, context);
|
|
505
513
|
const M = Array.isArray(marks) ? marks : [marks];
|
|
506
514
|
discovered.unshift(...M.map((d, i) => ({ ...d, key: `${key}-${i}` })));
|
|
507
515
|
}
|
package/src/runtime/render.ts
CHANGED
|
@@ -70,7 +70,7 @@ export function render<T extends G2ViewTree = G2ViewTree>(
|
|
|
70
70
|
},
|
|
71
71
|
): HTMLElement {
|
|
72
72
|
// Initialize the context if it is not provided.
|
|
73
|
-
const { width = 640, height = 480, depth = 0
|
|
73
|
+
const { width = 640, height = 480, depth = 0 } = options;
|
|
74
74
|
const keyed = inferKeys(options);
|
|
75
75
|
const {
|
|
76
76
|
canvas = Canvas(width, height),
|
package/src/runtime/transform.ts
CHANGED
|
@@ -42,9 +42,20 @@ export async function applyDataTransform(
|
|
|
42
42
|
const transform = [connector, ...T];
|
|
43
43
|
const transformFunctions = transform.map(useData);
|
|
44
44
|
const transformedData = await composeAsync(transformFunctions)(data);
|
|
45
|
+
|
|
46
|
+
// Maintain the consistency of shape between input and output data.
|
|
47
|
+
// If the shape of raw data is like { value: any }
|
|
48
|
+
// and the returned transformedData is Object,
|
|
49
|
+
// returns the wrapped data: { value: transformedData },
|
|
50
|
+
// otherwise returns the processed tabular data.
|
|
51
|
+
const newData =
|
|
52
|
+
data && !Array.isArray(data) && !Array.isArray(transformedData)
|
|
53
|
+
? { value: transformedData }
|
|
54
|
+
: transformedData;
|
|
55
|
+
|
|
45
56
|
return [
|
|
46
57
|
Array.isArray(transformedData) ? indexOf(transformedData) : [],
|
|
47
|
-
{ ...mark, data:
|
|
58
|
+
{ ...mark, data: newData },
|
|
48
59
|
];
|
|
49
60
|
}
|
|
50
61
|
|
package/src/shape/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { HV as LineHV } from './line/hv';
|
|
|
10
10
|
export { VH as LineVH } from './line/vh';
|
|
11
11
|
export { HVH as LineHVH } from './line/hvh';
|
|
12
12
|
export { Trail as LineTrail } from './line/trail';
|
|
13
|
+
export { Line as Line3DShape } from './line3D/line';
|
|
13
14
|
export { HollowBowtie as PointHollowBowtie } from './point/hollowBowtie';
|
|
14
15
|
export { HollowDiamond as PointHollowDiamond } from './point/hollowDiamond';
|
|
15
16
|
export { HollowHexagon as PointHollowHexagon } from './point/hollowHexagon';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Polyline } from '@antv/g';
|
|
2
|
+
import { applyStyle } from '../utils';
|
|
3
|
+
import { ShapeComponent as SC } from '../../runtime';
|
|
4
|
+
import { select } from '../../utils/selection';
|
|
5
|
+
|
|
6
|
+
export type LineOptions = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
export const Line: SC<LineOptions> = (options, context) => {
|
|
9
|
+
return (P, value, defaults) => {
|
|
10
|
+
const { color: defaultColor, lineWidth: defaultSize, ...rest } = defaults;
|
|
11
|
+
const { color = defaultColor, size = defaultSize } = value;
|
|
12
|
+
const stroke = color;
|
|
13
|
+
const finalStyle = {
|
|
14
|
+
isBillboard: true,
|
|
15
|
+
...rest,
|
|
16
|
+
...(stroke && { stroke }),
|
|
17
|
+
...(size && { lineWidth: size }),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return select(new Polyline())
|
|
21
|
+
.style('points', P)
|
|
22
|
+
.call(applyStyle, finalStyle)
|
|
23
|
+
.node();
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Line.props = {
|
|
28
|
+
defaultMarker: 'line',
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MeshLambertMaterial, CubeGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
2
|
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
3
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
4
|
import { select } from '../../utils/selection';
|
|
@@ -28,7 +28,7 @@ export const Cube: SC<CubeOptions> = (options, context) => {
|
|
|
28
28
|
});
|
|
29
29
|
// create a material with Phong lighting model
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
context.cubeMaterial = new
|
|
31
|
+
context.cubeMaterial = new MeshLambertMaterial(device);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return (points, value, defaults) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MeshLambertMaterial, SphereGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
2
|
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
3
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
4
|
import { select } from '../../utils/selection';
|
|
@@ -28,7 +28,7 @@ export const Sphere: SC<SphereOptions> = (options, context) => {
|
|
|
28
28
|
});
|
|
29
29
|
// create a material with Phong lighting model
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
context.sphereMaterial = new
|
|
31
|
+
context.sphereMaterial = new MeshLambertMaterial(device);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return (points, value, defaults) => {
|
package/src/theme/classic.ts
CHANGED
package/src/theme/light.ts
CHANGED
|
@@ -6,7 +6,7 @@ const COLORS = {
|
|
|
6
6
|
BLACK: '#1D2129',
|
|
7
7
|
WHITE: '#fff',
|
|
8
8
|
STROKE: '#416180',
|
|
9
|
-
DEFAULT: '#
|
|
9
|
+
DEFAULT: '#1783FF',
|
|
10
10
|
BACKGROUND: 'transparent',
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -56,16 +56,16 @@ export const Light: TC<LightOptions> = (options) => {
|
|
|
56
56
|
'#FF80CA',
|
|
57
57
|
'#2491B3',
|
|
58
58
|
'#17C76F',
|
|
59
|
-
'#
|
|
60
|
-
'#
|
|
61
|
-
'#
|
|
62
|
-
'#
|
|
63
|
-
'#
|
|
64
|
-
'#
|
|
65
|
-
'#
|
|
66
|
-
'#
|
|
67
|
-
'#
|
|
68
|
-
'#
|
|
59
|
+
'#AABA01',
|
|
60
|
+
'#BC7CFC',
|
|
61
|
+
'#237CBC',
|
|
62
|
+
'#2DE379',
|
|
63
|
+
'#CE8032',
|
|
64
|
+
'#FF7AF4',
|
|
65
|
+
'#545FD3',
|
|
66
|
+
'#AFE410',
|
|
67
|
+
'#D8C608',
|
|
68
|
+
'#FFA1E0',
|
|
69
69
|
],
|
|
70
70
|
enter: {
|
|
71
71
|
duration: 300,
|