@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.
Files changed (251) hide show
  1. package/dist/g2-lite.min.js +3 -3
  2. package/dist/g2.min.js +3 -3
  3. package/esm/api/chart.d.ts +2 -1
  4. package/esm/api/chart.js +2 -2
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/composition/base.d.ts +1 -1
  7. package/esm/api/composition/base.js +6 -17
  8. package/esm/api/composition/base.js.map +1 -1
  9. package/esm/api/composition/facetCircle.d.ts +2 -2
  10. package/esm/api/composition/facetCircle.js +2 -2
  11. package/esm/api/composition/facetCircle.js.map +1 -1
  12. package/esm/api/composition/facetRect.d.ts +2 -2
  13. package/esm/api/composition/facetRect.js +2 -2
  14. package/esm/api/composition/facetRect.js.map +1 -1
  15. package/esm/api/composition/geoPath.d.ts +2 -2
  16. package/esm/api/composition/geoPath.js +2 -2
  17. package/esm/api/composition/geoPath.js.map +1 -1
  18. package/esm/api/composition/geoView.d.ts +2 -2
  19. package/esm/api/composition/geoView.js +2 -2
  20. package/esm/api/composition/geoView.js.map +1 -1
  21. package/esm/api/composition/index.d.ts +2 -2
  22. package/esm/api/composition/index.js +2 -2
  23. package/esm/api/composition/index.js.map +1 -1
  24. package/esm/api/composition/repeatMatrix.d.ts +2 -2
  25. package/esm/api/composition/repeatMatrix.js +2 -2
  26. package/esm/api/composition/repeatMatrix.js.map +1 -1
  27. package/esm/api/composition/spaceFlex.d.ts +2 -2
  28. package/esm/api/composition/spaceFlex.js +2 -2
  29. package/esm/api/composition/spaceFlex.js.map +1 -1
  30. package/esm/api/composition/spaceLayer.d.ts +2 -2
  31. package/esm/api/composition/spaceLayer.js +2 -2
  32. package/esm/api/composition/spaceLayer.js.map +1 -1
  33. package/esm/api/composition/timingKeyframe.d.ts +2 -2
  34. package/esm/api/composition/timingKeyframe.js +2 -2
  35. package/esm/api/composition/timingKeyframe.js.map +1 -1
  36. package/esm/api/composition/view.d.ts +2 -2
  37. package/esm/api/composition/view.js +2 -2
  38. package/esm/api/composition/view.js.map +1 -1
  39. package/esm/api/index.d.ts +2 -0
  40. package/esm/api/index.js +2 -0
  41. package/esm/api/index.js.map +1 -1
  42. package/esm/api/mark/base.d.ts +1 -1
  43. package/esm/api/mark/base.js +7 -7
  44. package/esm/api/mark/base.js.map +1 -1
  45. package/esm/api/mark/index.d.ts +1 -0
  46. package/esm/api/mark/index.js +1 -0
  47. package/esm/api/mark/index.js.map +1 -1
  48. package/esm/api/mark/mark.d.ts +27 -27
  49. package/esm/api/mark/mark.js +28 -27
  50. package/esm/api/mark/mark.js.map +1 -1
  51. package/esm/api/mark/types.d.ts +1 -0
  52. package/esm/api/node.d.ts +1 -1
  53. package/esm/api/node.js +1 -1
  54. package/esm/api/node.js.map +1 -1
  55. package/esm/api/props.d.ts +1 -1
  56. package/esm/api/props.js +20 -0
  57. package/esm/api/props.js.map +1 -1
  58. package/esm/composition/timingKeyframe.js +13 -7
  59. package/esm/composition/timingKeyframe.js.map +1 -1
  60. package/esm/index.d.ts +1 -1
  61. package/esm/index.js +1 -1
  62. package/esm/index.js.map +1 -1
  63. package/esm/interaction/builtin/tooltip.d.ts +10 -2
  64. package/esm/interaction/index.d.ts +1 -0
  65. package/esm/interaction/index.js +1 -0
  66. package/esm/interaction/index.js.map +1 -1
  67. package/esm/interaction/native/event.d.ts +1 -0
  68. package/esm/interaction/native/event.js +42 -0
  69. package/esm/interaction/native/event.js.map +1 -0
  70. package/esm/interaction/native/tooltip.d.ts +2 -3
  71. package/esm/interaction/native/tooltip.js +68 -73
  72. package/esm/interaction/native/tooltip.js.map +1 -1
  73. package/esm/mark/utils.js +1 -5
  74. package/esm/mark/utils.js.map +1 -1
  75. package/esm/runtime/mark.js +5 -3
  76. package/esm/runtime/mark.js.map +1 -1
  77. package/esm/runtime/plot.js +33 -16
  78. package/esm/runtime/plot.js.map +1 -1
  79. package/esm/runtime/transform.d.ts +5 -0
  80. package/esm/runtime/transform.js +62 -4
  81. package/esm/runtime/transform.js.map +1 -1
  82. package/esm/runtime/types/common.d.ts +1 -0
  83. package/esm/runtime/types/component.d.ts +2 -1
  84. package/esm/runtime/types/options.d.ts +6 -1
  85. package/esm/spec/geometry.d.ts +33 -17
  86. package/esm/spec/interaction.d.ts +6 -1
  87. package/esm/stdlib/index.js +2 -2
  88. package/esm/stdlib/index.js.map +1 -1
  89. package/esm/transform/groupN.js +2 -2
  90. package/esm/transform/groupN.js.map +1 -1
  91. package/esm/transform/maybeTitle.js +13 -3
  92. package/esm/transform/maybeTitle.js.map +1 -1
  93. package/esm/transform/maybeTooltip.js +20 -20
  94. package/esm/transform/maybeTooltip.js.map +1 -1
  95. package/esm/transform/maybeZeroX.js +2 -2
  96. package/esm/transform/maybeZeroX.js.map +1 -1
  97. package/esm/transform/maybeZeroY.js +2 -2
  98. package/esm/transform/maybeZeroY.js.map +1 -1
  99. package/esm/transform/maybeZeroY1.js +2 -2
  100. package/esm/transform/maybeZeroY1.js.map +1 -1
  101. package/esm/transform/utils/helper.d.ts +12 -0
  102. package/esm/transform/utils/helper.js +8 -0
  103. package/esm/transform/utils/helper.js.map +1 -1
  104. package/esm/utils/helper.js +4 -1
  105. package/esm/utils/helper.js.map +1 -1
  106. package/lib/api/chart.d.ts +2 -1
  107. package/lib/api/chart.js +2 -2
  108. package/lib/api/chart.js.map +1 -1
  109. package/lib/api/composition/base.d.ts +1 -1
  110. package/lib/api/composition/base.js +8 -18
  111. package/lib/api/composition/base.js.map +1 -1
  112. package/lib/api/composition/facetCircle.d.ts +2 -2
  113. package/lib/api/composition/facetCircle.js +1 -1
  114. package/lib/api/composition/facetCircle.js.map +1 -1
  115. package/lib/api/composition/facetRect.d.ts +2 -2
  116. package/lib/api/composition/facetRect.js +1 -1
  117. package/lib/api/composition/facetRect.js.map +1 -1
  118. package/lib/api/composition/geoPath.d.ts +2 -2
  119. package/lib/api/composition/geoPath.js +1 -1
  120. package/lib/api/composition/geoPath.js.map +1 -1
  121. package/lib/api/composition/geoView.d.ts +2 -2
  122. package/lib/api/composition/geoView.js +1 -1
  123. package/lib/api/composition/geoView.js.map +1 -1
  124. package/lib/api/composition/index.d.ts +2 -2
  125. package/lib/api/composition/index.js +2 -2
  126. package/lib/api/composition/index.js.map +1 -1
  127. package/lib/api/composition/repeatMatrix.d.ts +2 -2
  128. package/lib/api/composition/repeatMatrix.js +1 -1
  129. package/lib/api/composition/repeatMatrix.js.map +1 -1
  130. package/lib/api/composition/spaceFlex.d.ts +2 -2
  131. package/lib/api/composition/spaceFlex.js +1 -1
  132. package/lib/api/composition/spaceFlex.js.map +1 -1
  133. package/lib/api/composition/spaceLayer.d.ts +2 -2
  134. package/lib/api/composition/spaceLayer.js +1 -1
  135. package/lib/api/composition/spaceLayer.js.map +1 -1
  136. package/lib/api/composition/timingKeyframe.d.ts +2 -2
  137. package/lib/api/composition/timingKeyframe.js +1 -1
  138. package/lib/api/composition/timingKeyframe.js.map +1 -1
  139. package/lib/api/composition/view.d.ts +2 -2
  140. package/lib/api/composition/view.js +1 -1
  141. package/lib/api/composition/view.js.map +1 -1
  142. package/lib/api/index.d.ts +2 -0
  143. package/lib/api/index.js +5 -1
  144. package/lib/api/index.js.map +1 -1
  145. package/lib/api/mark/base.d.ts +1 -1
  146. package/lib/api/mark/base.js +9 -9
  147. package/lib/api/mark/base.js.map +1 -1
  148. package/lib/api/mark/index.d.ts +1 -0
  149. package/lib/api/mark/index.js +3 -1
  150. package/lib/api/mark/index.js.map +1 -1
  151. package/lib/api/mark/mark.d.ts +27 -27
  152. package/lib/api/mark/mark.js +27 -26
  153. package/lib/api/mark/mark.js.map +1 -1
  154. package/lib/api/mark/types.d.ts +1 -0
  155. package/lib/api/node.d.ts +1 -1
  156. package/lib/api/node.js +1 -1
  157. package/lib/api/node.js.map +1 -1
  158. package/lib/api/props.d.ts +1 -1
  159. package/lib/api/props.js +20 -0
  160. package/lib/api/props.js.map +1 -1
  161. package/lib/composition/timingKeyframe.js +13 -7
  162. package/lib/composition/timingKeyframe.js.map +1 -1
  163. package/lib/index.d.ts +1 -1
  164. package/lib/index.js +3 -1
  165. package/lib/index.js.map +1 -1
  166. package/lib/interaction/builtin/tooltip.d.ts +10 -2
  167. package/lib/interaction/index.d.ts +1 -0
  168. package/lib/interaction/index.js +3 -1
  169. package/lib/interaction/index.js.map +1 -1
  170. package/lib/interaction/native/event.d.ts +1 -0
  171. package/lib/interaction/native/event.js +46 -0
  172. package/lib/interaction/native/event.js.map +1 -0
  173. package/lib/interaction/native/tooltip.d.ts +2 -3
  174. package/lib/interaction/native/tooltip.js +67 -72
  175. package/lib/interaction/native/tooltip.js.map +1 -1
  176. package/lib/mark/utils.js +1 -5
  177. package/lib/mark/utils.js.map +1 -1
  178. package/lib/runtime/mark.js +4 -2
  179. package/lib/runtime/mark.js.map +1 -1
  180. package/lib/runtime/plot.js +33 -16
  181. package/lib/runtime/plot.js.map +1 -1
  182. package/lib/runtime/transform.d.ts +5 -0
  183. package/lib/runtime/transform.js +64 -4
  184. package/lib/runtime/transform.js.map +1 -1
  185. package/lib/runtime/types/common.d.ts +1 -0
  186. package/lib/runtime/types/component.d.ts +2 -1
  187. package/lib/runtime/types/options.d.ts +6 -1
  188. package/lib/spec/geometry.d.ts +33 -17
  189. package/lib/spec/interaction.d.ts +6 -1
  190. package/lib/stdlib/index.js +1 -1
  191. package/lib/stdlib/index.js.map +1 -1
  192. package/lib/transform/groupN.js +1 -1
  193. package/lib/transform/groupN.js.map +1 -1
  194. package/lib/transform/maybeTitle.js +12 -2
  195. package/lib/transform/maybeTitle.js.map +1 -1
  196. package/lib/transform/maybeTooltip.js +20 -20
  197. package/lib/transform/maybeTooltip.js.map +1 -1
  198. package/lib/transform/maybeZeroX.js +1 -1
  199. package/lib/transform/maybeZeroX.js.map +1 -1
  200. package/lib/transform/maybeZeroY.js +1 -1
  201. package/lib/transform/maybeZeroY.js.map +1 -1
  202. package/lib/transform/maybeZeroY1.js +1 -1
  203. package/lib/transform/maybeZeroY1.js.map +1 -1
  204. package/lib/transform/utils/helper.d.ts +12 -0
  205. package/lib/transform/utils/helper.js +11 -1
  206. package/lib/transform/utils/helper.js.map +1 -1
  207. package/lib/utils/helper.js +4 -1
  208. package/lib/utils/helper.js.map +1 -1
  209. package/package.json +1 -1
  210. package/src/api/chart.ts +2 -2
  211. package/src/api/composition/base.ts +5 -7
  212. package/src/api/composition/facetCircle.ts +2 -2
  213. package/src/api/composition/facetRect.ts +2 -2
  214. package/src/api/composition/geoPath.ts +2 -2
  215. package/src/api/composition/geoView.ts +2 -2
  216. package/src/api/composition/index.ts +2 -2
  217. package/src/api/composition/repeatMatrix.ts +2 -2
  218. package/src/api/composition/spaceFlex.ts +2 -2
  219. package/src/api/composition/spaceLayer.ts +2 -2
  220. package/src/api/composition/timingKeyframe.ts +2 -2
  221. package/src/api/composition/view.ts +2 -2
  222. package/src/api/index.ts +2 -0
  223. package/src/api/mark/base.ts +7 -7
  224. package/src/api/mark/index.ts +2 -0
  225. package/src/api/mark/mark.ts +28 -27
  226. package/src/api/mark/types.ts +1 -0
  227. package/src/api/node.ts +1 -1
  228. package/src/api/props.ts +22 -1
  229. package/src/composition/timingKeyframe.ts +13 -7
  230. package/src/index.ts +1 -1
  231. package/src/interaction/index.ts +1 -0
  232. package/src/interaction/native/event.ts +44 -0
  233. package/src/interaction/native/tooltip.ts +66 -92
  234. package/src/mark/utils.ts +1 -5
  235. package/src/runtime/mark.ts +6 -2
  236. package/src/runtime/plot.ts +44 -18
  237. package/src/runtime/transform.ts +71 -4
  238. package/src/runtime/types/common.ts +1 -0
  239. package/src/runtime/types/component.ts +2 -0
  240. package/src/runtime/types/options.ts +6 -1
  241. package/src/spec/geometry.ts +38 -30
  242. package/src/spec/interaction.ts +5 -1
  243. package/src/stdlib/index.ts +2 -0
  244. package/src/transform/groupN.ts +2 -2
  245. package/src/transform/maybeTitle.ts +11 -3
  246. package/src/transform/maybeTooltip.ts +17 -21
  247. package/src/transform/maybeZeroX.ts +2 -2
  248. package/src/transform/maybeZeroY.ts +2 -2
  249. package/src/transform/maybeZeroY1.ts +2 -2
  250. package/src/transform/utils/helper.ts +10 -0
  251. package/src/utils/helper.ts +6 -1
@@ -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
- enterType?: AnimationTypes;
156
- enterDuration?: number;
157
- enterDelay?: number;
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);
@@ -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 = {
@@ -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,
@@ -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, column(RV, formatter?.(field) || field)];
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 { column, columnOf } from './utils/helper';
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 { title } = encode;
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, deepMix({}, mark, { encode: { title: column(T, ft) } })];
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
- const { tooltip } = encode;
17
- if (tooltip !== undefined) return [I, mark];
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
- let index = 0;
20
- const entries = channels.flatMap((channel) =>
21
- Object.entries(encode)
22
- .filter(([key]) => key.startsWith(channel))
23
- .flatMap(([key]) => {
24
- const [V, fv] = columnOf(encode, key);
25
- const E = [[key, column(V)]];
26
- // Only show channel with field.
27
- if (V && fv !== null) {
28
- const T = V.map((v) => ({ value: v, field: fv }));
29
- //@ts-ignore
30
- E.push([`tooltip${index === 0 ? '' : index}`, column(T, fv)]);
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, { encode: Object.fromEntries(entries) })];
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 { column, constant } from './utils/helper';
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: column(constant(I, 0)) },
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 { column, constant } from './utils/helper';
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: column(constant(I, 0)) },
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 { column, constant } from './utils/helper';
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: column(constant(I, 0)) },
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;
@@ -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 typeof d === 'object' && !(d instanceof Date) && d !== null;
115
+ return (
116
+ typeof d === 'object' &&
117
+ !(d instanceof Date) &&
118
+ d !== null &&
119
+ !Array.isArray(d)
120
+ );
116
121
  }