@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
package/src/spec/geometry.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MarkComponent } from '../runtime';
|
|
1
|
+
import { MarkComponent, Primitive } from '../runtime';
|
|
2
2
|
import { Encode } from './encode';
|
|
3
3
|
import { Transform } from './transform';
|
|
4
4
|
import { Scale } from './scale';
|
|
@@ -93,8 +93,7 @@ export type ChannelTypes =
|
|
|
93
93
|
| 'groupKey'
|
|
94
94
|
| 'label'
|
|
95
95
|
| 'position'
|
|
96
|
-
| 'series'
|
|
97
|
-
| `tooltip${number}`;
|
|
96
|
+
| 'series';
|
|
98
97
|
|
|
99
98
|
export type BaseGeometry<
|
|
100
99
|
T extends GeometryTypes,
|
|
@@ -149,36 +148,13 @@ export type BaseGeometry<
|
|
|
149
148
|
frame?: boolean;
|
|
150
149
|
labels?: Record<string, any>[];
|
|
151
150
|
stack?: boolean;
|
|
151
|
+
tooltip?: Tooltip;
|
|
152
152
|
animate?:
|
|
153
153
|
| boolean
|
|
154
154
|
| {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
enterEasing?: string;
|
|
159
|
-
enterFill?: 'forwards' | 'none' | 'backwards' | 'both' | 'auto';
|
|
160
|
-
updateType?: AnimationTypes;
|
|
161
|
-
updateDuration?: number;
|
|
162
|
-
updateDelay?: number;
|
|
163
|
-
updateEasing?: string;
|
|
164
|
-
updateFill?:
|
|
165
|
-
| 'forwards'
|
|
166
|
-
| 'none'
|
|
167
|
-
| 'backwards'
|
|
168
|
-
| 'forwards'
|
|
169
|
-
| 'both'
|
|
170
|
-
| 'auto';
|
|
171
|
-
exitType?: AnimationTypes;
|
|
172
|
-
exitDuration?: number;
|
|
173
|
-
exitDelay?: number;
|
|
174
|
-
exitEasing?: string;
|
|
175
|
-
exitFill?:
|
|
176
|
-
| 'forwards'
|
|
177
|
-
| 'none'
|
|
178
|
-
| 'backwards'
|
|
179
|
-
| 'forwards'
|
|
180
|
-
| 'both'
|
|
181
|
-
| 'auto';
|
|
155
|
+
enter?: Animation | null | boolean;
|
|
156
|
+
update?: Animation | null | boolean;
|
|
157
|
+
exit?: Animation | null | boolean;
|
|
182
158
|
};
|
|
183
159
|
cartesian?: boolean;
|
|
184
160
|
layout?: Record<string, any>;
|
|
@@ -192,6 +168,14 @@ type StateOptions = {
|
|
|
192
168
|
unselected?: Record<string, any>; // @todo
|
|
193
169
|
};
|
|
194
170
|
|
|
171
|
+
export type Animation = {
|
|
172
|
+
type?: AnimationTypes;
|
|
173
|
+
duration?: number;
|
|
174
|
+
delay?: number;
|
|
175
|
+
easing?: string;
|
|
176
|
+
fill?: 'forwards' | 'none' | 'backwards' | 'both' | 'auto';
|
|
177
|
+
};
|
|
178
|
+
|
|
195
179
|
export type Axis = {
|
|
196
180
|
tickCount?: number;
|
|
197
181
|
labelFormatter?: any;
|
|
@@ -325,3 +309,27 @@ export type WordCloudMark = BaseGeometry<
|
|
|
325
309
|
};
|
|
326
310
|
|
|
327
311
|
export type CustomComponent = BaseGeometry<MarkComponent>;
|
|
312
|
+
|
|
313
|
+
export type Tooltip =
|
|
314
|
+
| TooltipItem
|
|
315
|
+
| TooltipItem[]
|
|
316
|
+
| { title?: Encodeable<TooltipTitle>; items?: TooltipItem[] }
|
|
317
|
+
| null;
|
|
318
|
+
|
|
319
|
+
export type TooltipTitle = string | { field?: string; channel?: string };
|
|
320
|
+
|
|
321
|
+
export type TooltipItem =
|
|
322
|
+
| string
|
|
323
|
+
| { name?: string; color?: string; channel?: string; field?: string }
|
|
324
|
+
| Encodeable<Primitive>
|
|
325
|
+
| Encodeable<TooltipItemValue>;
|
|
326
|
+
|
|
327
|
+
export type TooltipItemValue = {
|
|
328
|
+
name?: string;
|
|
329
|
+
color?: string;
|
|
330
|
+
value?: Primitive;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
export type Encodeable<T> =
|
|
334
|
+
| T
|
|
335
|
+
| ((d: any, index: number, data: any[], column: any) => T);
|
package/src/spec/interaction.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InteractionComponent } from '../runtime';
|
|
2
|
-
import { ChannelTypes } from './geometry';
|
|
2
|
+
import { ChannelTypes, TooltipItemValue } from './geometry';
|
|
3
3
|
import { FisheyeCoordinate } from './coordinate';
|
|
4
4
|
|
|
5
5
|
export type Interaction =
|
|
@@ -197,6 +197,10 @@ export type TooltipInteraction = {
|
|
|
197
197
|
crosshairs?: boolean;
|
|
198
198
|
// @todo
|
|
199
199
|
item?: any;
|
|
200
|
+
render?: (
|
|
201
|
+
event, // @todo
|
|
202
|
+
options: { title: 'string'; items: TooltipItemValue[] },
|
|
203
|
+
) => HTMLElement | string;
|
|
200
204
|
};
|
|
201
205
|
|
|
202
206
|
export type FisheyeInteraction = {
|
package/src/stdlib/index.ts
CHANGED
|
@@ -184,6 +184,7 @@ import {
|
|
|
184
184
|
BrushYFilter,
|
|
185
185
|
SliderFilter,
|
|
186
186
|
Poptip,
|
|
187
|
+
Event,
|
|
187
188
|
// ElementHighlightByX,
|
|
188
189
|
// ElementHighlightByColor,
|
|
189
190
|
// ElementListHighlight,
|
|
@@ -521,6 +522,7 @@ export function createLibrary(): G2Library {
|
|
|
521
522
|
'interaction.brushYFilter': BrushYFilter,
|
|
522
523
|
'interaction.sliderFilter': SliderFilter,
|
|
523
524
|
'interaction.poptip': Poptip,
|
|
525
|
+
'interaction.event': Event,
|
|
524
526
|
// 'interaction.elementSelected': ElementSelected,
|
|
525
527
|
// 'interaction.elementHighlight': ElementHighlight,
|
|
526
528
|
// 'interaction.elementHighlightByX': ElementHighlightByX,
|
package/src/transform/groupN.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { TransformComponent as TC, Primitive, G2Mark } from '../runtime';
|
|
10
10
|
import { GroupTransform, Reducer } from '../spec';
|
|
11
11
|
import { indexOf } from '../utils/array';
|
|
12
|
-
import { columnOf, column } from './utils/helper';
|
|
12
|
+
import { columnOf, column, nonConstantColumn } from './utils/helper';
|
|
13
13
|
|
|
14
14
|
export type GroupNOptions = Omit<
|
|
15
15
|
GroupTransform & {
|
|
@@ -100,7 +100,7 @@ export const GroupN: TC<GroupNOptions> = (options = {}) => {
|
|
|
100
100
|
const [reducerFunction, formatter] = normalizeReducer(reducer);
|
|
101
101
|
const [V, field] = columnOf(encode, channel);
|
|
102
102
|
const RV = groups.map((I) => reducerFunction(I, V ?? data));
|
|
103
|
-
return [channel,
|
|
103
|
+
return [channel, nonConstantColumn(RV, formatter?.(field) || field)];
|
|
104
104
|
});
|
|
105
105
|
const reducedColumns = Object.keys(encode).map((key) => {
|
|
106
106
|
const [V, fv] = columnOf(encode, key);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { columnOf } from './utils/helper';
|
|
4
4
|
|
|
5
5
|
export type MaybeTitleOptions = {
|
|
6
6
|
channel?: string;
|
|
@@ -13,10 +13,18 @@ export const MaybeTitle: TC<MaybeTitleOptions> = (options = {}) => {
|
|
|
13
13
|
const { channel = 'x' } = options;
|
|
14
14
|
return (I, mark) => {
|
|
15
15
|
const { encode } = mark;
|
|
16
|
-
const {
|
|
16
|
+
const { tooltip } = mark;
|
|
17
|
+
if (tooltip === null) return [I, mark];
|
|
18
|
+
const { title } = tooltip;
|
|
17
19
|
if (title !== undefined) return [I, mark];
|
|
18
20
|
const [T, ft] = columnOf(encode, channel);
|
|
19
|
-
return [I,
|
|
21
|
+
if (!T) return [I, mark];
|
|
22
|
+
return [
|
|
23
|
+
I,
|
|
24
|
+
deepMix({}, mark, {
|
|
25
|
+
tooltip: { title: T.map((d) => ({ value: d, name: ft })) },
|
|
26
|
+
}),
|
|
27
|
+
];
|
|
20
28
|
};
|
|
21
29
|
};
|
|
22
30
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import { column, columnOf } from './utils/helper';
|
|
4
3
|
|
|
5
4
|
export type MaybeTooltipOptions = {
|
|
6
5
|
channel: string | string[];
|
|
@@ -12,28 +11,25 @@ export type MaybeTooltipOptions = {
|
|
|
12
11
|
export const MaybeTooltip: TC<MaybeTooltipOptions> = (options) => {
|
|
13
12
|
const { channel } = options;
|
|
14
13
|
return (I, mark) => {
|
|
15
|
-
const { encode } = mark;
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
const { encode, tooltip } = mark;
|
|
15
|
+
if (tooltip === null) return [I, mark];
|
|
16
|
+
const { items = [] } = tooltip;
|
|
17
|
+
if (items.length > 0) return [I, mark];
|
|
18
18
|
const channels = Array.isArray(channel) ? channel : [channel];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
index++;
|
|
32
|
-
}
|
|
33
|
-
return E;
|
|
34
|
-
}),
|
|
19
|
+
const newItems = channels.flatMap((channel) =>
|
|
20
|
+
Object.keys(encode)
|
|
21
|
+
.filter((key) => key.startsWith(channel))
|
|
22
|
+
.map((key) => {
|
|
23
|
+
const { field, value, inferred = false } = encode[key];
|
|
24
|
+
// Do not show inferred column.
|
|
25
|
+
if (inferred) return null;
|
|
26
|
+
if (field) return { field };
|
|
27
|
+
if (value) return { channel: key };
|
|
28
|
+
return null;
|
|
29
|
+
})
|
|
30
|
+
.filter((d) => d !== null),
|
|
35
31
|
);
|
|
36
|
-
return [I, deepMix({}, mark, {
|
|
32
|
+
return [I, deepMix({}, mark, { tooltip: { items: newItems } })];
|
|
37
33
|
};
|
|
38
34
|
};
|
|
39
35
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { inferredColumn, constant } from './utils/helper';
|
|
4
4
|
|
|
5
5
|
export type MaybeZeroXOptions = Record<string, never>;
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ export const MaybeZeroX: TC<MaybeZeroXOptions> = () => {
|
|
|
16
16
|
return [
|
|
17
17
|
I,
|
|
18
18
|
deepMix({}, mark, {
|
|
19
|
-
encode: { x:
|
|
19
|
+
encode: { x: inferredColumn(constant(I, 0)) },
|
|
20
20
|
scale: { x: { guide: null } },
|
|
21
21
|
}),
|
|
22
22
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { inferredColumn, constant } from './utils/helper';
|
|
4
4
|
|
|
5
5
|
export type MaybeZeroYOptions = Record<string, never>;
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ export const MaybeZeroY: TC<MaybeZeroYOptions> = () => {
|
|
|
15
15
|
return [
|
|
16
16
|
I,
|
|
17
17
|
deepMix({}, mark, {
|
|
18
|
-
encode: { y:
|
|
18
|
+
encode: { y: inferredColumn(constant(I, 0)) },
|
|
19
19
|
scale: { y: { guide: null } },
|
|
20
20
|
}),
|
|
21
21
|
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { deepMix } from '@antv/util';
|
|
2
2
|
import { TransformComponent as TC } from '../runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { inferredColumn, constant } from './utils/helper';
|
|
4
4
|
|
|
5
5
|
export type MaybeZeroY1Options = Record<string, never>;
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ export const MaybeZeroY1: TC<MaybeZeroY1Options> = () => {
|
|
|
15
15
|
return [
|
|
16
16
|
I,
|
|
17
17
|
deepMix({}, mark, {
|
|
18
|
-
encode: { y1:
|
|
18
|
+
encode: { y1: inferredColumn(constant(I, 0)) },
|
|
19
19
|
}),
|
|
20
20
|
];
|
|
21
21
|
};
|
|
@@ -5,11 +5,21 @@ export function column(value: Primitive[], field?: string) {
|
|
|
5
5
|
return { type: 'column', value, field };
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export function inferredColumn(value: Primitive[], field?: string) {
|
|
9
|
+
const c = column(value, field);
|
|
10
|
+
return { ...c, inferred: true };
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
export function visualColumn(value: Primitive[], field?: string) {
|
|
9
14
|
if (value === null) return undefined;
|
|
10
15
|
return { type: 'column', value, field, visual: true };
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
export function nonConstantColumn(value: Primitive[], field?: string) {
|
|
19
|
+
const c = column(value, field);
|
|
20
|
+
return { ...c, constant: false };
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
export function constant(I: number[], value: any) {
|
|
14
24
|
const array = [];
|
|
15
25
|
for (const i of I) array[i] = value;
|
package/src/utils/helper.ts
CHANGED
|
@@ -112,5 +112,10 @@ export function maybePercentage(x: number | string, size: number) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
export function isStrictObject(d: any): boolean {
|
|
115
|
-
return
|
|
115
|
+
return (
|
|
116
|
+
typeof d === 'object' &&
|
|
117
|
+
!(d instanceof Date) &&
|
|
118
|
+
d !== null &&
|
|
119
|
+
!Array.isArray(d)
|
|
120
|
+
);
|
|
116
121
|
}
|