@antv/g2 5.0.0-beta.3 → 5.0.0-beta.4

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 (196) hide show
  1. package/dist/g2-lite.min.js +2 -2
  2. package/dist/g2.min.js +2 -2
  3. package/esm/api/mark/mark.js +1 -0
  4. package/esm/api/mark/mark.js.map +1 -1
  5. package/esm/api/mark/types.d.ts +1 -0
  6. package/esm/component/axis.js +45 -24
  7. package/esm/component/axis.js.map +1 -1
  8. package/esm/component/index.d.ts +4 -0
  9. package/esm/component/index.js +2 -0
  10. package/esm/component/index.js.map +1 -1
  11. package/esm/component/legendCategory.js +1 -0
  12. package/esm/component/legendCategory.js.map +1 -1
  13. package/esm/component/slider.d.ts +9 -0
  14. package/esm/component/slider.js +59 -0
  15. package/esm/component/slider.js.map +1 -0
  16. package/esm/component/sliderX.d.ts +7 -0
  17. package/esm/component/sliderX.js +9 -0
  18. package/esm/component/sliderX.js.map +1 -0
  19. package/esm/component/sliderY.d.ts +7 -0
  20. package/esm/component/sliderY.js +9 -0
  21. package/esm/component/sliderY.js.map +1 -0
  22. package/esm/composition/facetRect.js +4 -4
  23. package/esm/composition/facetRect.js.map +1 -1
  24. package/esm/composition/mark.js +2 -1
  25. package/esm/composition/mark.js.map +1 -1
  26. package/esm/composition/repeatMatrix.js +2 -2
  27. package/esm/composition/repeatMatrix.js.map +1 -1
  28. package/esm/data/filter.d.ts +3 -3
  29. package/esm/data/filter.js.map +1 -1
  30. package/esm/data/index.d.ts +3 -1
  31. package/esm/data/index.js +1 -0
  32. package/esm/data/index.js.map +1 -1
  33. package/esm/data/sort.d.ts +8 -0
  34. package/esm/data/sort.js +12 -0
  35. package/esm/data/sort.js.map +1 -0
  36. package/esm/interaction/builtin/tooltip.d.ts +6 -4
  37. package/esm/interaction/index.d.ts +2 -0
  38. package/esm/interaction/index.js +2 -0
  39. package/esm/interaction/index.js.map +1 -1
  40. package/esm/interaction/native/legendFilter.d.ts +8 -0
  41. package/esm/interaction/native/legendFilter.js +189 -0
  42. package/esm/interaction/native/legendFilter.js.map +1 -0
  43. package/esm/interaction/native/tooltip.d.ts +2 -2
  44. package/esm/interaction/native/tooltip.js +39 -17
  45. package/esm/interaction/native/tooltip.js.map +1 -1
  46. package/esm/interaction/native/utils.d.ts +1 -1
  47. package/esm/interaction/native/utils.js +2 -2
  48. package/esm/interaction/native/utils.js.map +1 -1
  49. package/esm/mark/area.js +1 -1
  50. package/esm/mark/area.js.map +1 -1
  51. package/esm/mark/line.js +1 -1
  52. package/esm/mark/line.js.map +1 -1
  53. package/esm/runtime/component.js +29 -1
  54. package/esm/runtime/component.js.map +1 -1
  55. package/esm/runtime/plot.js +14 -7
  56. package/esm/runtime/plot.js.map +1 -1
  57. package/esm/runtime/types/mark.d.ts +1 -1
  58. package/esm/runtime/types/options.d.ts +1 -0
  59. package/esm/runtime/types/theme.d.ts +5 -0
  60. package/esm/spec/data.d.ts +10 -3
  61. package/esm/spec/geometry.d.ts +1 -0
  62. package/esm/spec/interaction.d.ts +9 -2
  63. package/esm/spec/transform.d.ts +7 -2
  64. package/esm/stdlib/index.js +6 -6
  65. package/esm/stdlib/index.js.map +1 -1
  66. package/esm/theme/dark.js +78 -28
  67. package/esm/theme/dark.js.map +1 -1
  68. package/esm/theme/light.js +68 -17
  69. package/esm/theme/light.js.map +1 -1
  70. package/esm/transform/filter.d.ts +7 -0
  71. package/esm/transform/filter.js +42 -0
  72. package/esm/transform/filter.js.map +1 -0
  73. package/esm/transform/index.d.ts +2 -0
  74. package/esm/transform/index.js +1 -0
  75. package/esm/transform/index.js.map +1 -1
  76. package/esm/utils/selection.d.ts +1 -0
  77. package/esm/utils/selection.js.map +1 -1
  78. package/esm/utils/size.js +1 -1
  79. package/esm/utils/size.js.map +1 -1
  80. package/lib/api/mark/mark.js +1 -0
  81. package/lib/api/mark/mark.js.map +1 -1
  82. package/lib/api/mark/types.d.ts +1 -0
  83. package/lib/component/axis.js +45 -24
  84. package/lib/component/axis.js.map +1 -1
  85. package/lib/component/index.d.ts +4 -0
  86. package/lib/component/index.js +5 -1
  87. package/lib/component/index.js.map +1 -1
  88. package/lib/component/legendCategory.js +1 -0
  89. package/lib/component/legendCategory.js.map +1 -1
  90. package/lib/component/slider.d.ts +9 -0
  91. package/lib/component/slider.js +63 -0
  92. package/lib/component/slider.js.map +1 -0
  93. package/lib/component/sliderX.d.ts +7 -0
  94. package/lib/component/sliderX.js +13 -0
  95. package/lib/component/sliderX.js.map +1 -0
  96. package/lib/component/sliderY.d.ts +7 -0
  97. package/lib/component/sliderY.js +13 -0
  98. package/lib/component/sliderY.js.map +1 -0
  99. package/lib/composition/facetRect.js +4 -4
  100. package/lib/composition/facetRect.js.map +1 -1
  101. package/lib/composition/mark.js +2 -1
  102. package/lib/composition/mark.js.map +1 -1
  103. package/lib/composition/repeatMatrix.js +2 -2
  104. package/lib/composition/repeatMatrix.js.map +1 -1
  105. package/lib/data/filter.d.ts +3 -3
  106. package/lib/data/filter.js.map +1 -1
  107. package/lib/data/index.d.ts +3 -1
  108. package/lib/data/index.js +3 -1
  109. package/lib/data/index.js.map +1 -1
  110. package/lib/data/sort.d.ts +8 -0
  111. package/lib/data/sort.js +17 -0
  112. package/lib/data/sort.js.map +1 -0
  113. package/lib/interaction/builtin/tooltip.d.ts +6 -4
  114. package/lib/interaction/index.d.ts +2 -0
  115. package/lib/interaction/index.js +5 -1
  116. package/lib/interaction/index.js.map +1 -1
  117. package/lib/interaction/native/legendFilter.d.ts +8 -0
  118. package/lib/interaction/native/legendFilter.js +193 -0
  119. package/lib/interaction/native/legendFilter.js.map +1 -0
  120. package/lib/interaction/native/tooltip.d.ts +2 -2
  121. package/lib/interaction/native/tooltip.js +39 -17
  122. package/lib/interaction/native/tooltip.js.map +1 -1
  123. package/lib/interaction/native/utils.d.ts +1 -1
  124. package/lib/interaction/native/utils.js +2 -2
  125. package/lib/interaction/native/utils.js.map +1 -1
  126. package/lib/mark/area.js +1 -1
  127. package/lib/mark/area.js.map +1 -1
  128. package/lib/mark/line.js +1 -1
  129. package/lib/mark/line.js.map +1 -1
  130. package/lib/runtime/component.js +29 -1
  131. package/lib/runtime/component.js.map +1 -1
  132. package/lib/runtime/plot.js +14 -7
  133. package/lib/runtime/plot.js.map +1 -1
  134. package/lib/runtime/types/mark.d.ts +1 -1
  135. package/lib/runtime/types/options.d.ts +1 -0
  136. package/lib/runtime/types/theme.d.ts +5 -0
  137. package/lib/spec/data.d.ts +10 -3
  138. package/lib/spec/geometry.d.ts +1 -0
  139. package/lib/spec/interaction.d.ts +9 -2
  140. package/lib/spec/transform.d.ts +7 -2
  141. package/lib/stdlib/index.js +2 -2
  142. package/lib/stdlib/index.js.map +1 -1
  143. package/lib/theme/dark.js +78 -28
  144. package/lib/theme/dark.js.map +1 -1
  145. package/lib/theme/light.js +68 -17
  146. package/lib/theme/light.js.map +1 -1
  147. package/lib/transform/filter.d.ts +7 -0
  148. package/lib/transform/filter.js +46 -0
  149. package/lib/transform/filter.js.map +1 -0
  150. package/lib/transform/index.d.ts +2 -0
  151. package/lib/transform/index.js +3 -1
  152. package/lib/transform/index.js.map +1 -1
  153. package/lib/utils/selection.d.ts +1 -0
  154. package/lib/utils/selection.js.map +1 -1
  155. package/lib/utils/size.js +1 -1
  156. package/lib/utils/size.js.map +1 -1
  157. package/package.json +5 -4
  158. package/src/api/mark/mark.ts +1 -0
  159. package/src/api/mark/types.ts +1 -0
  160. package/src/component/axis.ts +46 -91
  161. package/src/component/index.ts +4 -0
  162. package/src/component/legendCategory.ts +1 -0
  163. package/src/component/slider.ts +63 -0
  164. package/src/component/sliderX.ts +16 -0
  165. package/src/component/sliderY.ts +16 -0
  166. package/src/composition/facetRect.ts +4 -2
  167. package/src/composition/mark.ts +2 -0
  168. package/src/composition/repeatMatrix.ts +8 -1
  169. package/src/data/filter.ts +3 -3
  170. package/src/data/index.ts +3 -1
  171. package/src/data/sort.ts +18 -0
  172. package/src/interaction/index.ts +3 -0
  173. package/src/interaction/native/legendFilter.ts +206 -0
  174. package/src/interaction/native/tooltip.ts +57 -16
  175. package/src/interaction/native/utils.ts +2 -1
  176. package/src/mark/area.ts +1 -1
  177. package/src/mark/line.ts +1 -1
  178. package/src/runtime/component.ts +49 -2
  179. package/src/runtime/plot.ts +11 -5
  180. package/src/runtime/types/mark.ts +1 -1
  181. package/src/runtime/types/options.ts +1 -0
  182. package/src/runtime/types/theme.ts +5 -0
  183. package/src/spec/data.ts +12 -2
  184. package/src/spec/geometry.ts +1 -0
  185. package/src/spec/interaction.ts +11 -1
  186. package/src/spec/transform.ts +9 -1
  187. package/src/stdlib/index.ts +12 -2
  188. package/src/theme/dark.ts +79 -28
  189. package/src/theme/light.ts +68 -17
  190. package/src/transform/filter.ts +48 -0
  191. package/src/transform/index.ts +2 -0
  192. package/src/utils/selection.ts +2 -0
  193. package/src/utils/size.ts +1 -1
  194. package/src/.DS_Store +0 -0
  195. package/src/data/.DS_Store +0 -0
  196. package/src/shape/.DS_Store +0 -0
@@ -1,5 +1,5 @@
1
- import { Coordinate, Vector2 } from '@antv/coord';
2
- import { Axis as AxisComponent, AxisStyleProps } from '@antv/gui';
1
+ import { Coordinate } from '@antv/coord';
2
+ import { Axis as AxisComponent } from '@antv/gui';
3
3
  import { Linear as LinearScale } from '@antv/scale';
4
4
  import { deepMix } from '@antv/util';
5
5
  import { format } from 'd3-format';
@@ -12,6 +12,7 @@ import {
12
12
  isRadial,
13
13
  isFisheye,
14
14
  } from '../utils/coordinate';
15
+ import { capitalizeFirst } from '../utils/helper';
15
16
  import {
16
17
  BBox,
17
18
  GuideComponentComponent as GCC,
@@ -242,124 +243,46 @@ function inferGrid(value: boolean, coordinate: Coordinate, scale: Scale) {
242
243
  return value === undefined ? !!scale.getTicks : value;
243
244
  }
244
245
 
245
- function inferStyle(
246
+ function inferOverrideStyle(
246
247
  position: GuideComponentPosition,
247
- direction: string,
248
248
  bbox: BBox,
249
249
  coordinate: Coordinate,
250
- scale: Scale,
251
250
  ): {
252
- type: 'linear';
253
251
  startPos: [number, number];
254
252
  endPos: [number, number];
255
- labelSpacing: number;
256
- titlePosition: AxisStyleProps['titlePosition'];
257
- titleTextBaseline: 'top' | 'bottom' | 'middle';
258
- titleSpacing?: number;
259
- titleTransform: string;
260
- titleTransformOrigin: string;
261
- labelDirection: 'negative' | 'positive';
262
- labelTransform?: string;
263
- tickDirection: 'negative' | 'positive';
264
- showLabel?: boolean;
265
- showTick?: boolean;
266
253
  showLine?: boolean;
267
- gridLength: number;
268
- gridDirection: 'negative' | 'positive';
269
- gridConnect?: string;
270
- gridType?: string;
271
- gridCenter?: Vector2;
272
- gridControlAngles?: number[];
273
- girdClosed?: true;
254
+ [k: string]: any;
274
255
  } {
275
- const gridLength = getGridLength(position, coordinate);
276
256
  const [, cy] = coordinate.getCenter();
277
257
  const { x, y, width, height } = bbox;
278
258
 
279
- const common = {
280
- type: 'linear' as const,
281
- lineArrow: null,
282
- titleTransform: undefined,
283
- titleTransformOrigin: 'center',
284
- labelAlign: 'horizontal',
285
- gridLength,
286
- };
287
-
288
259
  if (position === 'bottom') {
289
260
  return {
290
- ...common,
291
261
  startPos: [x, y],
292
262
  endPos: [x + width, y],
293
- titlePosition: scale.getTicks ? 'right-bottom' : 'bottom',
294
- titleTransform: scale.getTicks ? 'translate(-100%, 0)' : undefined,
295
- titleSpacing: 10,
296
- titleTextBaseline: 'bottom',
297
- labelSpacing: 12,
298
- labelDirection: 'positive',
299
- tickDirection: 'positive',
300
- gridDirection: 'negative',
301
263
  };
302
264
  } else if (position === 'left' || position === 'centerHorizontal') {
303
265
  return {
304
- ...common,
305
266
  startPos: [x + width, y],
306
267
  endPos: [x + width, y + height],
307
- titleSpacing: 10,
308
- titleTextBaseline: 'middle',
309
- titlePosition: 'left',
310
- titleTransform: `translate(50%, 0) rotate(-90)`,
311
- labelSpacing: 4,
312
- labelDirection: 'positive',
313
- tickDirection: 'positive',
314
- gridDirection: 'negative',
315
268
  showLine: position === 'centerHorizontal' ? true : undefined,
316
269
  };
317
270
  } else if (position === 'right') {
318
271
  return {
319
- ...common,
320
272
  endPos: [x, y + height],
321
273
  startPos: [x, y],
322
- titlePosition: 'right',
323
- titleSpacing: 0,
324
- titleTextBaseline: 'top',
325
- titleTransform: `translate(-50%, 0) rotate(-90)`,
326
- labelSpacing: 4,
327
- labelDirection: 'negative',
328
- tickDirection: 'negative',
329
- gridDirection: 'positive',
330
274
  };
331
275
  } else if (position === 'arcY') {
332
276
  return {
333
- ...common,
334
277
  startPos: [x, y],
335
278
  endPos: [x + width, y + height],
336
- titlePosition: 'top',
337
- titleSpacing: 0,
338
- titleTextBaseline: 'bottom',
339
- labelDirection: direction === 'right' ? 'negative' : 'positive',
340
- labelTransform: direction === 'center' ? 'translate(50%, 0)' : '',
341
- tickDirection: direction === 'right' ? 'negative' : 'positive',
342
- labelSpacing: direction === 'center' ? 0 : 4,
343
- gridDirection: 'negative',
344
- gridConnect: 'arc',
345
- gridType: 'surround',
346
279
  gridCenter: [bbox.x, cy + bbox.y],
347
- gridControlAngles: [90, 180, 360],
348
- girdClosed: true,
349
280
  };
350
281
  }
351
282
 
352
283
  return {
353
- ...common,
354
284
  startPos: [x, y + height],
355
285
  endPos: [x + width, y + height],
356
- titlePosition: 'top',
357
- titleSpacing: 0,
358
- titleTextBaseline: 'middle',
359
- labelSpacing: 8,
360
- labelDirection: 'negative',
361
- tickDirection: 'negative',
362
- gridDirection: 'positive',
363
286
  showLine: position === 'centerVertical' ? true : undefined,
364
287
  };
365
288
  }
@@ -418,6 +341,35 @@ const ArcAxis = (options) => {
418
341
  };
419
342
  };
420
343
 
344
+ function inferDefaultStyle(scale, theme, position, direction) {
345
+ const p = position === 'centerHorizontal' ? 'left' : position;
346
+
347
+ const themeStyle = Object.assign(
348
+ {},
349
+ theme.axis,
350
+ theme[`axis${capitalizeFirst(p)}`] || theme.axisTop,
351
+ );
352
+
353
+ if (position === 'bottom') {
354
+ return {
355
+ ...themeStyle,
356
+ titlePosition: scale.getTicks ? 'right-bottom' : 'bottom',
357
+ titleTransformOrigin: 'center',
358
+ titleTransform: scale.getTicks ? 'translate(-100%, 0)' : undefined,
359
+ };
360
+ } else if (position === 'arcY') {
361
+ return {
362
+ ...themeStyle,
363
+ labelDirection: direction === 'right' ? 'negative' : 'positive',
364
+ labelTransform: direction === 'center' ? 'translate(50%, 0)' : '',
365
+ tickDirection: direction === 'right' ? 'negative' : 'positive',
366
+ labelSpacing: direction === 'center' ? 0 : 4,
367
+ };
368
+ }
369
+
370
+ return themeStyle;
371
+ }
372
+
421
373
  const LinearAxis: GCC<AxisOptions> = (options) => {
422
374
  const {
423
375
  order,
@@ -433,13 +385,14 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
433
385
  labelAutoHide = false,
434
386
  labelAutoRotate = true,
435
387
  grid,
388
+ label: showLabel = true,
389
+ tick: showTick = true,
436
390
  ...userDefinitions
437
391
  } = options;
438
392
 
439
393
  return (scale, value, coordinate, theme) => {
440
394
  const { domain, bbox } = value;
441
395
 
442
- const { axis: axisTheme } = theme;
443
396
  const ticks = getTicks(
444
397
  scale,
445
398
  domain,
@@ -452,31 +405,33 @@ const LinearAxis: GCC<AxisOptions> = (options) => {
452
405
  );
453
406
 
454
407
  const showGrid = inferGrid(grid, coordinate, scale);
408
+ const gridLength = getGridLength(position, coordinate);
455
409
 
456
410
  const {
457
- showLabel = options.label === undefined ? true : options.label,
458
- showTick = options.tick === undefined ? true : options.tick,
459
411
  showLine = options.line === undefined ? false : options.line,
460
- ...defaultStyle
461
- } = inferStyle(position, direction, bbox, coordinate, scale);
412
+ ...overrideStyle
413
+ } = inferOverrideStyle(position, bbox, coordinate);
414
+
415
+ const defaultStyle = inferDefaultStyle(scale, theme, position, direction);
462
416
 
463
417
  const axisStyle = {
464
418
  ...defaultStyle,
419
+ type: 'linear' as const,
465
420
  data: ticks,
466
421
  title: titleContent(title),
467
422
  showLabel,
468
423
  labelTransforms: labelTransforms(labelAutoHide, labelAutoRotate),
469
424
  showGrid,
470
425
  showTick,
426
+ gridLength,
471
427
  ...userDefinitions,
472
428
  // Always showLine, make title could align the end of axis.
473
429
  showLine: true,
474
430
  ...(!showLine ? { lineOpacity: 0 } : null),
475
- } as AxisStyleProps;
431
+ ...overrideStyle,
432
+ };
476
433
 
477
- return new AxisComponent({
478
- style: Object.assign({}, axisTheme, axisStyle),
479
- });
434
+ return new AxisComponent({ style: axisStyle });
480
435
  };
481
436
  };
482
437
 
@@ -3,9 +3,13 @@ export { AxisY } from './axisY';
3
3
  export { LegendCategory } from './legendCategory';
4
4
  export { LegendContinuous } from './legendContinuous';
5
5
  export { TitleComponent } from './title';
6
+ export { SliderX } from './sliderX';
7
+ export { SliderY } from './sliderY';
6
8
 
7
9
  export type { AxisXOptions } from './axisX';
8
10
  export type { AxisYOptions } from './axisY';
9
11
  export type { LegendCategoryOptions } from './legendCategory';
10
12
  export type { LegendContinuousOptions } from './legendContinuous';
11
13
  export type { TitleComponentOptions } from './title';
14
+ export type { SliderXOptions } from './sliderX';
15
+ export type { SliderYOptions } from './sliderY';
@@ -83,6 +83,7 @@ export const LegendCategory: GCC<LegendCategoryOptions> = (options) => {
83
83
 
84
84
  const { legend: legendTheme = {} } = theme;
85
85
  return new Category({
86
+ className: 'legend-category',
86
87
  style: Object.assign({}, legendTheme, legendStyle, rest),
87
88
  });
88
89
  };
@@ -0,0 +1,63 @@
1
+ import { Slider as SliderComponent } from '@antv/gui';
2
+ import { format } from 'd3-format';
3
+ import { least } from 'd3-array';
4
+ import { GuideComponentComponent as GCC, Scale } from '../runtime';
5
+
6
+ export type SliderOptions = {
7
+ orient: 'horizontal' | 'vertical';
8
+ [key: string]: any;
9
+ };
10
+
11
+ /**
12
+ * Slider component.
13
+ */
14
+ export const Slider: GCC<SliderOptions> = (options) => {
15
+ // do not pass size.
16
+ const { orient, labelFormatter, size, ...rest } = options;
17
+
18
+ return (scale, value, coordinate, theme) => {
19
+ const { bbox } = value;
20
+ const { x, y, width, height } = bbox;
21
+ const { slider: sliderTheme = {} } = theme;
22
+ const defaultFormatter = scale.getFormatter?.() || ((v) => v);
23
+ const formatter =
24
+ typeof labelFormatter === 'string'
25
+ ? format(labelFormatter)
26
+ : labelFormatter;
27
+
28
+ return new SliderComponent({
29
+ className: 'slider',
30
+ style: Object.assign({}, sliderTheme, {
31
+ x,
32
+ y,
33
+ length: orient === 'horizontal' ? width : height,
34
+ orient,
35
+ formatter: (v) => {
36
+ const f = formatter || defaultFormatter;
37
+ const tick = invertTick(scale, v);
38
+ return f(tick);
39
+ },
40
+ // @todo GUI should rename size to railSize
41
+ size: sliderTheme.railSize,
42
+ ...rest,
43
+ }),
44
+ });
45
+ };
46
+ };
47
+
48
+ /**
49
+ * Translate [0,1] value to origin value.
50
+ */
51
+ function invertTick(scale: Scale, v: number) {
52
+ if (!scale.getBandWidth) return scale.invert(v);
53
+ // @ts-ignore @todo should support in scale
54
+ const range = scale.adjustedRange as number[];
55
+ const abs = (v) => Math.abs(v);
56
+ return scale.invert(least(range, (a, b) => abs(a - v) - abs(b - v)));
57
+ }
58
+
59
+ Slider.props = {
60
+ defaultPosition: 'bottom',
61
+ defaultSize: 24,
62
+ defaultOrder: 1,
63
+ };
@@ -0,0 +1,16 @@
1
+ import { GuideComponentComponent as GCC } from '../runtime';
2
+ import { Slider, SliderOptions } from './slider';
3
+
4
+ export type SliderXOptions = SliderOptions;
5
+
6
+ /**
7
+ * SliderX component.
8
+ */
9
+ export const SliderX: GCC<SliderXOptions> = (options) => {
10
+ return Slider({ ...options, orient: 'horizontal' });
11
+ };
12
+
13
+ SliderX.props = {
14
+ ...Slider.props,
15
+ defaultPosition: 'bottom',
16
+ };
@@ -0,0 +1,16 @@
1
+ import { GuideComponentComponent as GCC } from '../runtime';
2
+ import { Slider, SliderOptions } from './slider';
3
+
4
+ export type SliderYOptions = SliderOptions;
5
+
6
+ /**
7
+ * SliderY component.
8
+ */
9
+ export const SliderY: GCC<SliderYOptions> = (options) => {
10
+ return Slider({ ...options, orient: 'vertical' });
11
+ };
12
+
13
+ SliderY.props = {
14
+ ...Slider.props,
15
+ defaultPosition: 'left',
16
+ };
@@ -174,6 +174,7 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
174
174
  x: originX = 0,
175
175
  y: originY = 0,
176
176
  shareData = false,
177
+ key: viewKey,
177
178
  } = options;
178
179
  const { value: data } = dataValue;
179
180
  // Only support field encode now.
@@ -233,8 +234,8 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
233
234
  legend = {},
234
235
  ...rest
235
236
  }) => {
236
- const guideY = scale?.y?.guide;
237
- const guideX = scale?.x?.guide;
237
+ const guideY = scale?.y?.guide || axis.y;
238
+ const guideX = scale?.x?.guide || axis.x;
238
239
  const defaultScale = {
239
240
  x: { tickCount: encodeX ? 5 : undefined },
240
241
  y: { tickCount: encodeY ? 5 : undefined },
@@ -256,6 +257,7 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
256
257
  data: newData,
257
258
  x: left + paddingLeft + originX,
258
259
  y: top + paddingTop + originY,
260
+ parentKey: viewKey,
259
261
  width,
260
262
  height,
261
263
  paddingLeft: 0,
@@ -35,6 +35,7 @@ export const Mark: CC<MarkOptions> = () => {
35
35
  frame,
36
36
  title,
37
37
  labelTransform,
38
+ parentKey,
38
39
  ...mark
39
40
  } = options;
40
41
 
@@ -68,6 +69,7 @@ export const Mark: CC<MarkOptions> = () => {
68
69
  marginBottom,
69
70
  marginTop,
70
71
  marginRight,
72
+ parentKey,
71
73
  marks: [{ ...mark, key: `${key}-0`, data }],
72
74
  },
73
75
  ];
@@ -25,7 +25,13 @@ const setScale = useDefaultAdaptor<G2ViewTree>((options) => {
25
25
  });
26
26
 
27
27
  const setChildren = useOverrideAdaptor<G2ViewTree>((options) => {
28
- const { data, children, x: originX = 0, y: originY = 0 } = options;
28
+ const {
29
+ data,
30
+ children,
31
+ x: originX = 0,
32
+ y: originY = 0,
33
+ key: viewKey,
34
+ } = options;
29
35
  const createChildren = (visualData, scale, layout) => {
30
36
  const { x: scaleX, y: scaleY } = scale;
31
37
  const { paddingLeft, paddingTop } = layout;
@@ -76,6 +82,7 @@ const setChildren = useOverrideAdaptor<G2ViewTree>((options) => {
76
82
  };
77
83
  return {
78
84
  data,
85
+ parentKey: viewKey,
79
86
  key: `${key}-${i}`,
80
87
  x: left + paddingLeft + originX,
81
88
  y: top + paddingTop + originY,
@@ -1,7 +1,7 @@
1
1
  import { DataComponent as DC } from '../runtime';
2
- import { FilterTransform } from '../spec';
2
+ import { FilterDataTransform } from '../spec';
3
3
 
4
- export type FilterOptions = Omit<FilterTransform, 'type'>;
4
+ export type FilterDataOptions = Omit<FilterDataTransform, 'type'>;
5
5
 
6
6
  export function defined(d: any): boolean {
7
7
  return d !== undefined && d !== null && !Number.isNaN(d);
@@ -11,7 +11,7 @@ export function defined(d: any): boolean {
11
11
  * Filter data by specified fields and filter callback for each fields.
12
12
  * It saves datum with every fields defined by default.
13
13
  */
14
- export const Filter: DC<FilterOptions> = (options) => {
14
+ export const Filter: DC<FilterDataOptions> = (options) => {
15
15
  const { callback = defined } = options;
16
16
  return (data) => data.filter(callback);
17
17
  };
package/src/data/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { Fetch } from './fetch';
2
2
  export { Fold } from './fold';
3
3
  export { Filter } from './filter';
4
+ export { Sort } from './sort';
4
5
  export { Pick } from './pick';
5
6
  export { Rename } from './rename';
6
7
  export { Subset } from './subset';
@@ -17,7 +18,8 @@ export { Join } from './join';
17
18
 
18
19
  export type { FetchOptions } from './fetch';
19
20
  export type { FoldOptions } from './fold';
20
- export type { FilterOptions } from './filter';
21
+ export type { FilterDataOptions } from './filter';
22
+ export type { SortOptions } from './sort';
21
23
  export type { PickOptions } from './pick';
22
24
  export type { RenameOptions } from './rename';
23
25
  export type { SubsetOptions } from './subset';
@@ -0,0 +1,18 @@
1
+ import { DataComponent as DC } from '../runtime';
2
+ import { SortTransform } from '../spec';
3
+
4
+ export type SortOptions = Omit<SortTransform, 'type'>;
5
+
6
+ export function defined(d: any): boolean {
7
+ return d !== undefined && d !== null && !Number.isNaN(d);
8
+ }
9
+
10
+ /**
11
+ * Sort data similar with Array.prototypo.sort.
12
+ */
13
+ export const Sort: DC<SortOptions> = (options) => {
14
+ const { callback } = options;
15
+ return (data) => (Array.isArray(data) ? [...data].sort(callback) : data);
16
+ };
17
+
18
+ Sort.props = {};
@@ -9,6 +9,9 @@ export { ElementSelectByColor } from './native/elementSelectByColor';
9
9
  export { ChartIndex } from './native/chartIndex';
10
10
  export { Fisheye } from './native/fisheye';
11
11
  export { Tooltip } from './native/tooltip';
12
+ export { LegendFilter } from './native/legendFilter';
13
+
14
+ export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
12
15
 
13
16
  // export { ElementSelected } from './builtin/elementSelected';
14
17
  // export { Tooltip } from './builtin/tooltip';