@antv/g2 5.0.16 → 5.0.18
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.js +5 -1
- package/esm/api/chart.js.map +1 -1
- package/esm/api/mark/types.d.ts +2 -2
- package/esm/component/legendCategory.js +23 -21
- package/esm/component/legendCategory.js.map +1 -1
- package/esm/component/legendContinuous.js +7 -6
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/component/title.js +2 -4
- package/esm/component/title.js.map +1 -1
- package/esm/interaction/legendFilter.d.ts +2 -0
- package/esm/interaction/legendFilter.js +66 -37
- package/esm/interaction/legendFilter.js.map +1 -1
- package/esm/mark/lineX.js +5 -3
- package/esm/mark/lineX.js.map +1 -1
- package/esm/mark/lineY.js +5 -3
- package/esm/mark/lineY.js.map +1 -1
- package/esm/mark/point.js +1 -1
- package/esm/mark/point.js.map +1 -1
- package/esm/runtime/component.d.ts +3 -2
- package/esm/runtime/component.js +62 -22
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +3 -3
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/mark.js +3 -2
- package/esm/runtime/mark.js.map +1 -1
- package/esm/runtime/plot.js +8 -8
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/scale.d.ts +3 -3
- package/esm/runtime/scale.js +21 -13
- package/esm/runtime/scale.js.map +1 -1
- package/esm/runtime/types/common.d.ts +12 -14
- package/esm/runtime/types/theme.d.ts +10 -13
- package/esm/shape/label/label.d.ts +7 -1
- package/esm/shape/label/label.js +11 -2
- package/esm/shape/label/label.js.map +1 -1
- package/esm/shape/label/position/default.js +7 -2
- package/esm/shape/label/position/default.js.map +1 -1
- package/esm/shape/text/advance.js +29 -13
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/spec/component.d.ts +11 -12
- package/esm/spec/composition.d.ts +1 -1
- package/esm/spec/index.d.ts +2 -1
- package/esm/spec/index.js.map +1 -1
- package/esm/spec/interaction.d.ts +1 -2
- package/esm/spec/mark.d.ts +1 -1
- package/esm/theme/academy.js +17 -32
- package/esm/theme/academy.js.map +1 -1
- package/esm/theme/classic.js +18 -33
- package/esm/theme/classic.js.map +1 -1
- package/esm/theme/classicDark.js +17 -32
- package/esm/theme/classicDark.js.map +1 -1
- package/esm/transform/filter.js +19 -6
- package/esm/transform/filter.js.map +1 -1
- package/esm/utils/selection.d.ts +1 -1
- package/esm/utils/selection.js +3 -1
- package/esm/utils/selection.js.map +1 -1
- package/lib/api/chart.js +5 -1
- package/lib/api/chart.js.map +1 -1
- package/lib/api/mark/types.d.ts +2 -2
- package/lib/component/legendCategory.js +23 -21
- package/lib/component/legendCategory.js.map +1 -1
- package/lib/component/legendContinuous.js +6 -5
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/component/title.js +2 -4
- package/lib/component/title.js.map +1 -1
- package/lib/interaction/legendFilter.d.ts +2 -0
- package/lib/interaction/legendFilter.js +67 -37
- package/lib/interaction/legendFilter.js.map +1 -1
- package/lib/mark/lineX.js +4 -2
- package/lib/mark/lineX.js.map +1 -1
- package/lib/mark/lineY.js +4 -2
- package/lib/mark/lineY.js.map +1 -1
- package/lib/mark/point.js +1 -1
- package/lib/mark/point.js.map +1 -1
- package/lib/runtime/component.d.ts +3 -2
- package/lib/runtime/component.js +64 -23
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +3 -3
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/mark.js +3 -2
- package/lib/runtime/mark.js.map +1 -1
- package/lib/runtime/plot.js +7 -7
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/scale.d.ts +3 -3
- package/lib/runtime/scale.js +21 -13
- package/lib/runtime/scale.js.map +1 -1
- package/lib/runtime/types/common.d.ts +12 -14
- package/lib/runtime/types/theme.d.ts +10 -13
- package/lib/shape/label/label.d.ts +7 -1
- package/lib/shape/label/label.js +11 -2
- package/lib/shape/label/label.js.map +1 -1
- package/lib/shape/label/position/default.js +7 -2
- package/lib/shape/label/position/default.js.map +1 -1
- package/lib/shape/text/advance.js +29 -13
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/spec/component.d.ts +11 -12
- package/lib/spec/composition.d.ts +1 -1
- package/lib/spec/index.d.ts +2 -1
- package/lib/spec/index.js.map +1 -1
- package/lib/spec/interaction.d.ts +1 -2
- package/lib/spec/mark.d.ts +1 -1
- package/lib/theme/academy.js +17 -32
- package/lib/theme/academy.js.map +1 -1
- package/lib/theme/classic.js +18 -33
- package/lib/theme/classic.js.map +1 -1
- package/lib/theme/classicDark.js +17 -32
- package/lib/theme/classicDark.js.map +1 -1
- package/lib/transform/filter.js +19 -6
- package/lib/transform/filter.js.map +1 -1
- package/lib/utils/selection.d.ts +1 -1
- package/lib/utils/selection.js +3 -1
- package/lib/utils/selection.js.map +1 -1
- package/package.json +9 -6
- package/src/api/chart.ts +10 -1
- package/src/api/mark/types.ts +5 -2
- package/src/component/legendCategory.ts +26 -32
- package/src/component/legendContinuous.ts +10 -6
- package/src/component/title.ts +11 -15
- package/src/interaction/legendFilter.ts +96 -49
- package/src/mark/lineX.ts +11 -5
- package/src/mark/lineY.ts +11 -5
- package/src/mark/point.ts +1 -1
- package/src/runtime/component.ts +76 -29
- package/src/runtime/layout.ts +3 -3
- package/src/runtime/mark.ts +10 -1
- package/src/runtime/plot.ts +17 -10
- package/src/runtime/scale.ts +30 -15
- package/src/runtime/types/common.ts +16 -18
- package/src/runtime/types/theme.ts +14 -17
- package/src/shape/label/label.ts +21 -2
- package/src/shape/label/position/default.ts +8 -2
- package/src/shape/text/advance.ts +46 -16
- package/src/spec/component.ts +11 -12
- package/src/spec/composition.ts +1 -1
- package/src/spec/index.ts +2 -1
- package/src/spec/interaction.ts +1 -2
- package/src/spec/mark.ts +1 -1
- package/src/theme/academy.ts +18 -32
- package/src/theme/classic.ts +19 -33
- package/src/theme/classicDark.ts +18 -32
- package/src/transform/filter.ts +16 -5
- package/src/utils/selection.ts +6 -1
- package/CHANGELOG.md +0 -236
|
@@ -34,6 +34,8 @@ type TextShapeStyleProps = Omit<TextStyleProps, 'text'> &
|
|
|
34
34
|
BackgroundStyleProps &
|
|
35
35
|
MarkerStyleProps<'startMarker'> &
|
|
36
36
|
MarkerStyleProps<'endMarker'> & {
|
|
37
|
+
id: string;
|
|
38
|
+
className?: string;
|
|
37
39
|
x0?: number; // x0 represents the x position of relative point, default is equal to x
|
|
38
40
|
y0?: number;
|
|
39
41
|
coordCenter?: Vector2; // center of coordinate
|
|
@@ -44,6 +46,8 @@ type TextShapeStyleProps = Omit<TextStyleProps, 'text'> &
|
|
|
44
46
|
labelTransform?: string;
|
|
45
47
|
labelTransformOrigin?: string;
|
|
46
48
|
rotate?: number;
|
|
49
|
+
innerHTML?: string | HTMLElement;
|
|
50
|
+
text?: string;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
53
|
function getConnectorPoint(shape: GText | Rect) {
|
|
@@ -126,8 +130,10 @@ function inferConnectorPath(
|
|
|
126
130
|
|
|
127
131
|
export const Advance = createElement((g) => {
|
|
128
132
|
const {
|
|
133
|
+
id,
|
|
134
|
+
className,
|
|
129
135
|
// Do not pass className
|
|
130
|
-
class:
|
|
136
|
+
class: _c,
|
|
131
137
|
transform,
|
|
132
138
|
rotate,
|
|
133
139
|
labelTransform,
|
|
@@ -136,15 +142,22 @@ export const Advance = createElement((g) => {
|
|
|
136
142
|
y,
|
|
137
143
|
x0 = x,
|
|
138
144
|
y0 = y,
|
|
145
|
+
text,
|
|
139
146
|
background,
|
|
140
147
|
connector,
|
|
141
148
|
startMarker,
|
|
142
149
|
endMarker,
|
|
143
150
|
coordCenter,
|
|
151
|
+
innerHTML,
|
|
144
152
|
...rest
|
|
145
153
|
} = g.attributes as TextShapeStyleProps;
|
|
146
|
-
|
|
147
|
-
|
|
154
|
+
|
|
155
|
+
// Position is invalid, do not render the UI,
|
|
156
|
+
// or clear previous elements.
|
|
157
|
+
if ([x, y, x0, y0].some((v) => !isNumber(v))) {
|
|
158
|
+
g.children.forEach((d) => d.remove());
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
148
161
|
|
|
149
162
|
const { padding, ...backgroundStyle } = subObject(rest, 'background');
|
|
150
163
|
const { points = [], ...connectorStyle } = subObject(rest, 'connector');
|
|
@@ -152,26 +165,43 @@ export const Advance = createElement((g) => {
|
|
|
152
165
|
[+x0, +y0],
|
|
153
166
|
[+x, +y],
|
|
154
167
|
];
|
|
155
|
-
const shape1 = select(g)
|
|
156
|
-
.maybeAppend('text', 'text')
|
|
157
|
-
.style('zIndex', 0)
|
|
158
|
-
.call(applyStyle, {
|
|
159
|
-
textBaseline: 'middle',
|
|
160
|
-
transform: labelTransform,
|
|
161
|
-
transformOrigin: labelTransformOrigin,
|
|
162
|
-
...rest,
|
|
163
|
-
})
|
|
164
|
-
.node();
|
|
165
168
|
|
|
166
|
-
|
|
169
|
+
let textShape;
|
|
170
|
+
// Use html to customize advance text.
|
|
171
|
+
if (innerHTML) {
|
|
172
|
+
textShape = select(g)
|
|
173
|
+
.maybeAppend(id, 'html', className)
|
|
174
|
+
.style('zIndex', 0)
|
|
175
|
+
.style('innerHTML', innerHTML)
|
|
176
|
+
.call(applyStyle, {
|
|
177
|
+
transform: labelTransform,
|
|
178
|
+
transformOrigin: labelTransformOrigin,
|
|
179
|
+
...rest,
|
|
180
|
+
})
|
|
181
|
+
.node();
|
|
182
|
+
} else {
|
|
183
|
+
textShape = select(g)
|
|
184
|
+
.maybeAppend('text', 'text')
|
|
185
|
+
.style('zIndex', 0)
|
|
186
|
+
.style('text', text)
|
|
187
|
+
.call(applyStyle, {
|
|
188
|
+
textBaseline: 'middle',
|
|
189
|
+
transform: labelTransform,
|
|
190
|
+
transformOrigin: labelTransformOrigin,
|
|
191
|
+
...rest,
|
|
192
|
+
})
|
|
193
|
+
.node();
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const rect = select(g)
|
|
167
197
|
.maybeAppend('background', 'rect')
|
|
168
198
|
.style('zIndex', -1)
|
|
169
|
-
.call(applyStyle, inferBackgroundBounds(
|
|
199
|
+
.call(applyStyle, inferBackgroundBounds(textShape, padding))
|
|
170
200
|
.call(applyStyle, background ? backgroundStyle : {})
|
|
171
201
|
.node();
|
|
172
202
|
|
|
173
203
|
const connectorPath = inferConnectorPath(
|
|
174
|
-
|
|
204
|
+
rect,
|
|
175
205
|
endPoints,
|
|
176
206
|
points,
|
|
177
207
|
coordCenter,
|
package/src/spec/component.ts
CHANGED
|
@@ -23,21 +23,17 @@ export type TitleComponent = {
|
|
|
23
23
|
*/
|
|
24
24
|
subtitle?: string | null;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Align method for title.
|
|
27
27
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* The vertical spacing between title and subtitle, default is 2.
|
|
35
|
-
*/
|
|
36
|
-
spacing?: number;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
28
|
+
align?: 'left' | 'center' | 'right';
|
|
29
|
+
/**
|
|
30
|
+
* The vertical spacing between title and subtitle, default is 2.
|
|
31
|
+
*/
|
|
32
|
+
spacing?: number;
|
|
33
|
+
} & UsePrefix<'title' | 'subtitle', Record<string, any>>;
|
|
39
34
|
|
|
40
35
|
export type AxisComponent = {
|
|
36
|
+
type?: 'axisX' | 'axisY';
|
|
41
37
|
tickCount?: number;
|
|
42
38
|
labelFormatter?: any;
|
|
43
39
|
tickFilter?: any;
|
|
@@ -48,10 +44,12 @@ export type AxisComponent = {
|
|
|
48
44
|
Record<string, any>
|
|
49
45
|
>
|
|
50
46
|
>;
|
|
47
|
+
scale?: Record<string, any>; //@todo
|
|
51
48
|
[key: string]: any; // @todo
|
|
52
49
|
};
|
|
53
50
|
|
|
54
51
|
export type LegendComponent = {
|
|
52
|
+
type?: 'legends';
|
|
55
53
|
tickCount?: number;
|
|
56
54
|
labelFormatter?: any;
|
|
57
55
|
tickFilter?: any;
|
|
@@ -63,6 +61,7 @@ export type LegendComponent = {
|
|
|
63
61
|
Record<string, any>
|
|
64
62
|
>
|
|
65
63
|
>;
|
|
64
|
+
scale?: Record<string, any>; //@todo
|
|
66
65
|
[key: string]: any; // @todo
|
|
67
66
|
};
|
|
68
67
|
|
package/src/spec/composition.ts
CHANGED
|
@@ -66,7 +66,7 @@ export type ViewComposition = {
|
|
|
66
66
|
interaction?: Literal2Object<Interaction>;
|
|
67
67
|
transform?: Transform[];
|
|
68
68
|
theme?: Theme;
|
|
69
|
-
children?: Mark[];
|
|
69
|
+
children?: (Mark | AxisComponent | LegendComponent)[];
|
|
70
70
|
scale?: Record<string, Scale>;
|
|
71
71
|
frame?: boolean;
|
|
72
72
|
labelTransform?: LabelTransform[];
|
package/src/spec/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { AxisComponent, LegendComponent } from './component';
|
|
1
2
|
import { Composition } from './composition';
|
|
2
3
|
import { Mark } from './mark';
|
|
3
4
|
|
|
4
|
-
export type G2Spec = (Mark | Composition) & {
|
|
5
|
+
export type G2Spec = (Mark | Composition | AxisComponent | LegendComponent) & {
|
|
5
6
|
width?: number;
|
|
6
7
|
height?: number;
|
|
7
8
|
};
|
package/src/spec/interaction.ts
CHANGED
|
@@ -184,8 +184,7 @@ export type TooltipInteraction = {
|
|
|
184
184
|
event, // @todo
|
|
185
185
|
options: { title: 'string'; items: TooltipItemValue[] },
|
|
186
186
|
) => HTMLElement | string;
|
|
187
|
-
|
|
188
|
-
};
|
|
187
|
+
} & Record<`crosshairs${any}`, any>;
|
|
189
188
|
|
|
190
189
|
export type FisheyeInteraction = {
|
|
191
190
|
type?: 'fisheye';
|
package/src/spec/mark.ts
CHANGED
|
@@ -280,7 +280,7 @@ export type SankeyMark = BaseMark<
|
|
|
280
280
|
linkLabels: Record<string, any>[];
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
-
export type PathMark = BaseMark<'path', ChannelTypes>;
|
|
283
|
+
export type PathMark = BaseMark<'path', ChannelTypes | 'd'>;
|
|
284
284
|
|
|
285
285
|
export type TreemapMark = BaseMark<'treemap', 'value' | ChannelTypes> & {
|
|
286
286
|
layout?: Record<string, any>;
|
package/src/theme/academy.ts
CHANGED
|
@@ -10,14 +10,14 @@ const COLORS = {
|
|
|
10
10
|
|
|
11
11
|
const BACKGROUND_COLOR = 'transparent';
|
|
12
12
|
|
|
13
|
+
const DEFAULT_COLOR = '#4e79a7';
|
|
14
|
+
|
|
13
15
|
export const Academy: TC<AcademyOptions> = (options) => {
|
|
14
|
-
const DEFAULT_COLOR = '#4e79a7';
|
|
15
16
|
const defaultOptions: Theme = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
elementActiveStroke: COLORS.BLACK,
|
|
17
|
+
color: DEFAULT_COLOR,
|
|
18
|
+
size: 1,
|
|
19
|
+
category10: 'tableau10',
|
|
20
|
+
category20: 'tableau10',
|
|
21
21
|
enter: {
|
|
22
22
|
duration: 300,
|
|
23
23
|
fill: 'both',
|
|
@@ -33,12 +33,12 @@ export const Academy: TC<AcademyOptions> = (options) => {
|
|
|
33
33
|
fill: 'both',
|
|
34
34
|
delay: 0,
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
view: {
|
|
37
|
+
viewFill: BACKGROUND_COLOR,
|
|
38
|
+
plotFill: 'transparent',
|
|
39
|
+
mainFill: 'transparent',
|
|
40
|
+
contentFill: 'transparent',
|
|
41
|
+
},
|
|
42
42
|
line: {
|
|
43
43
|
line: {
|
|
44
44
|
fill: '',
|
|
@@ -198,26 +198,6 @@ export const Academy: TC<AcademyOptions> = (options) => {
|
|
|
198
198
|
endMarkerFillOpacity: 0.95,
|
|
199
199
|
},
|
|
200
200
|
},
|
|
201
|
-
interaction: {
|
|
202
|
-
active: {
|
|
203
|
-
line: {
|
|
204
|
-
line: { lineWidth: 3 },
|
|
205
|
-
},
|
|
206
|
-
interval: {
|
|
207
|
-
rect: { stroke: COLORS.BLACK },
|
|
208
|
-
},
|
|
209
|
-
area: {
|
|
210
|
-
area: { fillOpacity: 0.5 },
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
inactive: {
|
|
214
|
-
area: {
|
|
215
|
-
area: { fillOpacity: 0.3 },
|
|
216
|
-
},
|
|
217
|
-
},
|
|
218
|
-
selected: {},
|
|
219
|
-
disabled: {},
|
|
220
|
-
},
|
|
221
201
|
axis: {
|
|
222
202
|
arrow: false,
|
|
223
203
|
gridLineDash: [0, 0],
|
|
@@ -390,6 +370,12 @@ export const Academy: TC<AcademyOptions> = (options) => {
|
|
|
390
370
|
stroke: undefined,
|
|
391
371
|
offset: 0,
|
|
392
372
|
},
|
|
373
|
+
htmlLabel: {
|
|
374
|
+
fontSize: 12,
|
|
375
|
+
opacity: 0.65,
|
|
376
|
+
color: COLORS.BLACK,
|
|
377
|
+
fontWeight: 'normal',
|
|
378
|
+
},
|
|
393
379
|
slider: {
|
|
394
380
|
trackSize: 16,
|
|
395
381
|
trackFill: COLORS.STROKE,
|
package/src/theme/classic.ts
CHANGED
|
@@ -10,17 +10,17 @@ const COLORS = {
|
|
|
10
10
|
|
|
11
11
|
const BACKGROUND_COLOR = 'transparent';
|
|
12
12
|
|
|
13
|
+
const DEFAULT_COLOR = '#5B8FF9';
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Default theme.
|
|
15
17
|
*/
|
|
16
18
|
export const Classic: TC<ClassicOptions> = (options) => {
|
|
17
|
-
const DEFAULT_COLOR = '#5B8FF9';
|
|
18
19
|
const defaultOptions: Theme = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
elementActiveStroke: COLORS.BLACK,
|
|
20
|
+
color: DEFAULT_COLOR,
|
|
21
|
+
size: 1,
|
|
22
|
+
category10: 'category10',
|
|
23
|
+
category20: 'category20',
|
|
24
24
|
enter: {
|
|
25
25
|
duration: 300,
|
|
26
26
|
fill: 'both',
|
|
@@ -36,12 +36,12 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
36
36
|
fill: 'both',
|
|
37
37
|
delay: 0,
|
|
38
38
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
view: {
|
|
40
|
+
viewFill: BACKGROUND_COLOR,
|
|
41
|
+
plotFill: 'transparent',
|
|
42
|
+
mainFill: 'transparent',
|
|
43
|
+
contentFill: 'transparent',
|
|
44
|
+
},
|
|
45
45
|
line: {
|
|
46
46
|
line: {
|
|
47
47
|
fill: '',
|
|
@@ -132,7 +132,6 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
132
132
|
},
|
|
133
133
|
text: {
|
|
134
134
|
text: {
|
|
135
|
-
// fill: COLORS.BLACK,fillOpacity: 0.65,
|
|
136
135
|
fill: '#1D2129',
|
|
137
136
|
fontSize: 12,
|
|
138
137
|
strokeWidth: 0,
|
|
@@ -199,26 +198,6 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
199
198
|
endMarkerFillOpacity: 0.95,
|
|
200
199
|
},
|
|
201
200
|
},
|
|
202
|
-
interaction: {
|
|
203
|
-
active: {
|
|
204
|
-
line: {
|
|
205
|
-
line: { lineWidth: 3 },
|
|
206
|
-
},
|
|
207
|
-
interval: {
|
|
208
|
-
rect: { stroke: COLORS.BLACK },
|
|
209
|
-
},
|
|
210
|
-
area: {
|
|
211
|
-
area: { fillOpacity: 0.5 },
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
inactive: {
|
|
215
|
-
area: {
|
|
216
|
-
area: { fillOpacity: 0.3 },
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
selected: {},
|
|
220
|
-
disabled: {},
|
|
221
|
-
},
|
|
222
201
|
axis: {
|
|
223
202
|
arrow: false,
|
|
224
203
|
gridLineDash: [0, 0],
|
|
@@ -398,6 +377,12 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
398
377
|
stroke: undefined,
|
|
399
378
|
offset: 0,
|
|
400
379
|
},
|
|
380
|
+
htmlLabel: {
|
|
381
|
+
fontSize: 12,
|
|
382
|
+
opacity: 0.65,
|
|
383
|
+
color: COLORS.BLACK,
|
|
384
|
+
fontWeight: 'normal',
|
|
385
|
+
},
|
|
401
386
|
slider: {
|
|
402
387
|
trackSize: 16,
|
|
403
388
|
trackFill: COLORS.STROKE,
|
|
@@ -429,6 +414,7 @@ export const Classic: TC<ClassicOptions> = (options) => {
|
|
|
429
414
|
thumbHighlightedFillOpacity: 0.2,
|
|
430
415
|
},
|
|
431
416
|
title: {
|
|
417
|
+
spacing: 8,
|
|
432
418
|
titleFill: COLORS.BLACK,
|
|
433
419
|
titleFillOpacity: 0.85,
|
|
434
420
|
titleFontSize: 14,
|
package/src/theme/classicDark.ts
CHANGED
|
@@ -10,17 +10,17 @@ const COLORS = {
|
|
|
10
10
|
|
|
11
11
|
const BACKGROUND_COLOR = '#141414';
|
|
12
12
|
|
|
13
|
+
const DEFAULT_COLOR = '#5B8FF9';
|
|
14
|
+
|
|
13
15
|
/**
|
|
14
16
|
* Dark theme.
|
|
15
17
|
*/
|
|
16
18
|
export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
|
|
17
|
-
const DEFAULT_COLOR = '#5B8FF9';
|
|
18
19
|
const defaultOptions: Theme = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
elementActiveStroke: COLORS.BLACK,
|
|
20
|
+
color: DEFAULT_COLOR,
|
|
21
|
+
category10: 'category10',
|
|
22
|
+
category20: 'category20',
|
|
23
|
+
size: 1,
|
|
24
24
|
enter: {
|
|
25
25
|
duration: 300,
|
|
26
26
|
fill: 'both',
|
|
@@ -36,12 +36,12 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
|
|
|
36
36
|
fill: 'both',
|
|
37
37
|
delay: 0,
|
|
38
38
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
view: {
|
|
40
|
+
viewFill: BACKGROUND_COLOR,
|
|
41
|
+
plotFill: 'transparent',
|
|
42
|
+
mainFill: 'transparent',
|
|
43
|
+
contentFill: 'transparent',
|
|
44
|
+
},
|
|
45
45
|
line: {
|
|
46
46
|
line: {
|
|
47
47
|
fill: '',
|
|
@@ -199,26 +199,6 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
|
|
|
199
199
|
endMarkerFillOpacity: 0.95,
|
|
200
200
|
},
|
|
201
201
|
},
|
|
202
|
-
interaction: {
|
|
203
|
-
active: {
|
|
204
|
-
line: {
|
|
205
|
-
line: { lineWidth: 3 },
|
|
206
|
-
},
|
|
207
|
-
interval: {
|
|
208
|
-
rect: { stroke: COLORS.BLACK },
|
|
209
|
-
},
|
|
210
|
-
area: {
|
|
211
|
-
area: { fillOpacity: 0.5 },
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
inactive: {
|
|
215
|
-
area: {
|
|
216
|
-
area: { fillOpacity: 0.3 },
|
|
217
|
-
},
|
|
218
|
-
},
|
|
219
|
-
selected: {},
|
|
220
|
-
disabled: {},
|
|
221
|
-
},
|
|
222
202
|
axis: {
|
|
223
203
|
arrow: false,
|
|
224
204
|
gridLineDash: [0, 0],
|
|
@@ -396,6 +376,12 @@ export const ClassicDark: TC<ClassicDarkOptions> = (options) => {
|
|
|
396
376
|
stroke: undefined,
|
|
397
377
|
offset: 0,
|
|
398
378
|
},
|
|
379
|
+
htmlLabel: {
|
|
380
|
+
fontSize: 12,
|
|
381
|
+
opacity: 0.65,
|
|
382
|
+
color: COLORS.BLACK,
|
|
383
|
+
fontWeight: 'normal',
|
|
384
|
+
},
|
|
399
385
|
slider: {
|
|
400
386
|
trackSize: 16,
|
|
401
387
|
trackFill: COLORS.STROKE,
|
package/src/transform/filter.ts
CHANGED
|
@@ -6,6 +6,11 @@ import { columnOf } from './utils/helper';
|
|
|
6
6
|
|
|
7
7
|
export type FilterOptions = Omit<FilterTransform, 'type'>;
|
|
8
8
|
|
|
9
|
+
function normalizeValue(value) {
|
|
10
|
+
if (typeof value === 'object') return [value.value, value.ordinal];
|
|
11
|
+
else return [value, true];
|
|
12
|
+
}
|
|
13
|
+
|
|
9
14
|
/**
|
|
10
15
|
* The Filter transform filter channels.
|
|
11
16
|
*/
|
|
@@ -13,15 +18,21 @@ export const Filter: TC<FilterOptions> = (options = {}) => {
|
|
|
13
18
|
return (I, mark) => {
|
|
14
19
|
const { encode, data } = mark;
|
|
15
20
|
const filters = Object.entries(options)
|
|
16
|
-
.map(([key,
|
|
21
|
+
.map(([key, v]) => {
|
|
17
22
|
const [V] = columnOf(encode, key);
|
|
18
23
|
// Skip empty channel.
|
|
19
24
|
if (!V) return null;
|
|
25
|
+
const [value, ordinal = true] = normalizeValue(v);
|
|
20
26
|
if (typeof value === 'function') return (i) => value(V[i]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
if (ordinal) {
|
|
28
|
+
const expectedValues = Array.isArray(value) ? value : [value];
|
|
29
|
+
// Skip empty expected values.
|
|
30
|
+
if (expectedValues.length === 0) return null;
|
|
31
|
+
return (i) => expectedValues.includes(V[i]);
|
|
32
|
+
} else {
|
|
33
|
+
const [start, end] = value;
|
|
34
|
+
return (i) => V[i] >= start && V[i] <= end;
|
|
35
|
+
}
|
|
25
36
|
})
|
|
26
37
|
.filter(defined);
|
|
27
38
|
|
package/src/utils/selection.ts
CHANGED
|
@@ -166,7 +166,11 @@ export class Selection<T = any> {
|
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
maybeAppend(
|
|
169
|
+
maybeAppend(
|
|
170
|
+
id: string,
|
|
171
|
+
node: string | (() => G2Element),
|
|
172
|
+
className?: string,
|
|
173
|
+
) {
|
|
170
174
|
const element = this._elements[0];
|
|
171
175
|
const child = element.getElementById(id) as G2Element;
|
|
172
176
|
if (child) {
|
|
@@ -175,6 +179,7 @@ export class Selection<T = any> {
|
|
|
175
179
|
const newChild =
|
|
176
180
|
typeof node === 'string' ? this.createElement(node) : node();
|
|
177
181
|
newChild.id = id;
|
|
182
|
+
if (className) newChild.className = className;
|
|
178
183
|
element.appendChild(newChild);
|
|
179
184
|
return new Selection([newChild], null, this._parent, this._document);
|
|
180
185
|
}
|