@antv/g2 5.1.9 → 5.1.11

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 (163) hide show
  1. package/dist/g2.lite.min.js +1 -1
  2. package/dist/g2.min.js +1 -1
  3. package/esm/animation/scaleInY.js +103 -33
  4. package/esm/animation/scaleInY.js.map +1 -1
  5. package/esm/component/slider.js +32 -2
  6. package/esm/component/slider.js.map +1 -1
  7. package/esm/composition/facetCircle.js +1 -1
  8. package/esm/index.d.ts +2 -0
  9. package/esm/interaction/chartIndex.d.ts +5 -0
  10. package/esm/interaction/chartIndex.js +4 -1
  11. package/esm/interaction/chartIndex.js.map +1 -1
  12. package/esm/interaction/elementHighlight.d.ts +5 -0
  13. package/esm/interaction/elementHighlight.js +3 -0
  14. package/esm/interaction/elementHighlight.js.map +1 -1
  15. package/esm/interaction/elementHighlightByColor.d.ts +5 -0
  16. package/esm/interaction/elementHighlightByColor.js +3 -0
  17. package/esm/interaction/elementHighlightByColor.js.map +1 -1
  18. package/esm/interaction/elementHighlightByX.d.ts +5 -0
  19. package/esm/interaction/elementHighlightByX.js +3 -0
  20. package/esm/interaction/elementHighlightByX.js.map +1 -1
  21. package/esm/interaction/elementSelect.d.ts +5 -0
  22. package/esm/interaction/elementSelect.js +3 -0
  23. package/esm/interaction/elementSelect.js.map +1 -1
  24. package/esm/interaction/elementSelectByColor.d.ts +5 -0
  25. package/esm/interaction/elementSelectByColor.js +3 -0
  26. package/esm/interaction/elementSelectByColor.js.map +1 -1
  27. package/esm/interaction/elementSelectByX.d.ts +5 -0
  28. package/esm/interaction/elementSelectByX.js +3 -0
  29. package/esm/interaction/elementSelectByX.js.map +1 -1
  30. package/esm/interaction/event.d.ts +5 -0
  31. package/esm/interaction/event.js +3 -0
  32. package/esm/interaction/event.js.map +1 -1
  33. package/esm/interaction/poptip.d.ts +5 -0
  34. package/esm/interaction/poptip.js +3 -0
  35. package/esm/interaction/poptip.js.map +1 -1
  36. package/esm/interaction/sliderFilter.js +2 -0
  37. package/esm/interaction/sliderFilter.js.map +1 -1
  38. package/esm/interaction/tooltip.d.ts +5 -0
  39. package/esm/interaction/tooltip.js +16 -9
  40. package/esm/interaction/tooltip.js.map +1 -1
  41. package/esm/lib/core.d.ts +1 -0
  42. package/esm/lib/core.js +2 -1
  43. package/esm/lib/core.js.map +1 -1
  44. package/esm/lib/std.d.ts +1 -0
  45. package/esm/mark/chord.js +2 -0
  46. package/esm/mark/chord.js.map +1 -1
  47. package/esm/runtime/library.js +7 -4
  48. package/esm/runtime/library.js.map +1 -1
  49. package/esm/runtime/plot.js +41 -19
  50. package/esm/runtime/plot.js.map +1 -1
  51. package/esm/runtime/render.js +5 -2
  52. package/esm/runtime/render.js.map +1 -1
  53. package/esm/runtime/types/common.d.ts +1 -1
  54. package/esm/shape/area/smooth.d.ts +1 -3
  55. package/esm/shape/area/smooth.js +9 -5
  56. package/esm/shape/area/smooth.js.map +1 -1
  57. package/esm/shape/line/smooth.d.ts +1 -3
  58. package/esm/shape/line/smooth.js +2 -2
  59. package/esm/shape/line/smooth.js.map +1 -1
  60. package/esm/spec/composition.d.ts +1 -1
  61. package/esm/spec/mark.d.ts +1 -1
  62. package/esm/spec/transform.d.ts +7 -2
  63. package/esm/transform/index.d.ts +2 -0
  64. package/esm/transform/index.js +1 -0
  65. package/esm/transform/index.js.map +1 -1
  66. package/esm/transform/jitterY.d.ts +8 -0
  67. package/esm/transform/jitterY.js +25 -0
  68. package/esm/transform/jitterY.js.map +1 -0
  69. package/lib/animation/scaleInY.js +102 -32
  70. package/lib/animation/scaleInY.js.map +1 -1
  71. package/lib/component/slider.js +32 -2
  72. package/lib/component/slider.js.map +1 -1
  73. package/lib/composition/facetCircle.js +1 -1
  74. package/lib/index.d.ts +2 -0
  75. package/lib/interaction/chartIndex.d.ts +5 -0
  76. package/lib/interaction/chartIndex.js +4 -1
  77. package/lib/interaction/chartIndex.js.map +1 -1
  78. package/lib/interaction/elementHighlight.d.ts +5 -0
  79. package/lib/interaction/elementHighlight.js +3 -0
  80. package/lib/interaction/elementHighlight.js.map +1 -1
  81. package/lib/interaction/elementHighlightByColor.d.ts +5 -0
  82. package/lib/interaction/elementHighlightByColor.js +3 -0
  83. package/lib/interaction/elementHighlightByColor.js.map +1 -1
  84. package/lib/interaction/elementHighlightByX.d.ts +5 -0
  85. package/lib/interaction/elementHighlightByX.js +3 -0
  86. package/lib/interaction/elementHighlightByX.js.map +1 -1
  87. package/lib/interaction/elementSelect.d.ts +5 -0
  88. package/lib/interaction/elementSelect.js +3 -0
  89. package/lib/interaction/elementSelect.js.map +1 -1
  90. package/lib/interaction/elementSelectByColor.d.ts +5 -0
  91. package/lib/interaction/elementSelectByColor.js +3 -0
  92. package/lib/interaction/elementSelectByColor.js.map +1 -1
  93. package/lib/interaction/elementSelectByX.d.ts +5 -0
  94. package/lib/interaction/elementSelectByX.js +3 -0
  95. package/lib/interaction/elementSelectByX.js.map +1 -1
  96. package/lib/interaction/event.d.ts +5 -0
  97. package/lib/interaction/event.js +3 -0
  98. package/lib/interaction/event.js.map +1 -1
  99. package/lib/interaction/poptip.d.ts +5 -0
  100. package/lib/interaction/poptip.js +3 -0
  101. package/lib/interaction/poptip.js.map +1 -1
  102. package/lib/interaction/sliderFilter.js +2 -0
  103. package/lib/interaction/sliderFilter.js.map +1 -1
  104. package/lib/interaction/tooltip.d.ts +5 -0
  105. package/lib/interaction/tooltip.js +16 -9
  106. package/lib/interaction/tooltip.js.map +1 -1
  107. package/lib/lib/core.d.ts +1 -0
  108. package/lib/lib/core.js +1 -0
  109. package/lib/lib/core.js.map +1 -1
  110. package/lib/lib/std.d.ts +1 -0
  111. package/lib/mark/chord.js +2 -0
  112. package/lib/mark/chord.js.map +1 -1
  113. package/lib/runtime/library.js +7 -4
  114. package/lib/runtime/library.js.map +1 -1
  115. package/lib/runtime/plot.js +41 -19
  116. package/lib/runtime/plot.js.map +1 -1
  117. package/lib/runtime/render.js +5 -2
  118. package/lib/runtime/render.js.map +1 -1
  119. package/lib/runtime/types/common.d.ts +1 -1
  120. package/lib/shape/area/smooth.d.ts +1 -3
  121. package/lib/shape/area/smooth.js +7 -3
  122. package/lib/shape/area/smooth.js.map +1 -1
  123. package/lib/shape/line/smooth.d.ts +1 -3
  124. package/lib/shape/line/smooth.js +2 -2
  125. package/lib/shape/line/smooth.js.map +1 -1
  126. package/lib/spec/composition.d.ts +1 -1
  127. package/lib/spec/mark.d.ts +1 -1
  128. package/lib/spec/transform.d.ts +7 -2
  129. package/lib/transform/index.d.ts +2 -0
  130. package/lib/transform/index.js +3 -1
  131. package/lib/transform/index.js.map +1 -1
  132. package/lib/transform/jitterY.d.ts +8 -0
  133. package/lib/transform/jitterY.js +29 -0
  134. package/lib/transform/jitterY.js.map +1 -0
  135. package/package.json +4 -2
  136. package/src/animation/scaleInY.ts +142 -43
  137. package/src/component/slider.ts +42 -2
  138. package/src/composition/facetCircle.ts +1 -1
  139. package/src/interaction/chartIndex.ts +5 -1
  140. package/src/interaction/elementHighlight.ts +4 -0
  141. package/src/interaction/elementHighlightByColor.ts +4 -0
  142. package/src/interaction/elementHighlightByX.ts +4 -0
  143. package/src/interaction/elementSelect.ts +4 -0
  144. package/src/interaction/elementSelectByColor.ts +4 -0
  145. package/src/interaction/elementSelectByX.ts +4 -0
  146. package/src/interaction/event.ts +4 -0
  147. package/src/interaction/poptip.ts +4 -0
  148. package/src/interaction/sliderFilter.ts +3 -0
  149. package/src/interaction/tooltip.ts +18 -12
  150. package/src/lib/core.ts +2 -0
  151. package/src/mark/chord.ts +2 -0
  152. package/src/runtime/library.ts +10 -3
  153. package/src/runtime/plot.ts +58 -21
  154. package/src/runtime/render.ts +3 -2
  155. package/src/runtime/types/common.ts +1 -1
  156. package/src/shape/area/smooth.ts +14 -8
  157. package/src/shape/line/smooth.ts +3 -5
  158. package/src/spec/composition.ts +1 -1
  159. package/src/spec/mark.ts +1 -1
  160. package/src/spec/transform.ts +8 -0
  161. package/src/transform/index.ts +2 -0
  162. package/src/transform/jitterY.ts +30 -0
  163. package/CHANGELOG.md +0 -471
@@ -1,18 +1,24 @@
1
- import { curveCatmullRomClosed, curveCatmullRom } from 'd3-shape';
2
- import { isPolar } from '../../utils/coordinate';
1
+ import {
2
+ curveCatmullRomClosed,
3
+ curveMonotoneX,
4
+ curveMonotoneY,
5
+ } from 'd3-shape';
6
+ import { isPolar, isTranspose } from '../../utils/coordinate';
3
7
  import { ShapeComponent as SC } from '../../runtime';
4
8
  import { Curve } from './curve';
5
9
 
6
- export type SmoothOptions = {
7
- alpha?: number;
8
- };
10
+ export type SmoothOptions = Record<string, any>;
9
11
 
10
12
  export const Smooth: SC<SmoothOptions> = (options, context) => {
11
- const { alpha = 0.5, ...rest } = options;
13
+ const { ...rest } = options;
12
14
  const { coordinate } = context;
13
15
  return (...params) => {
14
- const curve = isPolar(coordinate) ? curveCatmullRomClosed : curveCatmullRom;
15
- return Curve({ curve: curve.alpha(alpha), ...rest }, context)(...params);
16
+ const curve = isPolar(coordinate)
17
+ ? curveCatmullRomClosed
18
+ : isTranspose(coordinate)
19
+ ? curveMonotoneY
20
+ : curveMonotoneX;
21
+ return Curve({ curve, ...rest }, context)(...params);
16
22
  };
17
23
  };
18
24
 
@@ -7,12 +7,10 @@ import { isPolar, isTranspose } from '../../utils/coordinate';
7
7
  import { ShapeComponent as SC } from '../../runtime';
8
8
  import { Curve } from './curve';
9
9
 
10
- export type SmoothOptions = {
11
- alpha?: number;
12
- };
10
+ export type SmoothOptions = Record<string, any>;
13
11
 
14
12
  export const Smooth: SC<SmoothOptions> = (options, context) => {
15
- const { alpha = 0.5, ...rest } = options;
13
+ const { ...rest } = options;
16
14
  const { coordinate } = context;
17
15
  return (...params) => {
18
16
  const curve = isPolar(coordinate)
@@ -20,7 +18,7 @@ export const Smooth: SC<SmoothOptions> = (options, context) => {
20
18
  : isTranspose(coordinate)
21
19
  ? curveMonotoneY
22
20
  : curveMonotoneX;
23
- return Curve({ curve: curve, ...rest }, context)(...params);
21
+ return Curve({ curve, ...rest }, context)(...params);
24
22
  };
25
23
  };
26
24
 
@@ -65,7 +65,7 @@ export type ViewComposition = {
65
65
  insetBottom?: number;
66
66
  insetRight?: number;
67
67
  coordinate?: Coordinate;
68
- interaction?: Literal2Object<Interaction>;
68
+ interaction?: Literal2Object<Interaction> & Record<string, any>;
69
69
  transform?: Transform[];
70
70
  theme?: Theme;
71
71
  children?: (Mark | AxisComponent | LegendComponent)[];
package/src/spec/mark.ts CHANGED
@@ -188,7 +188,7 @@ export type BaseMark<T extends MarkTypes, C extends string = ChannelTypes> = {
188
188
  Partial<Record<PositionChannelTypes, Closeable<ScrollbarComponent>>>
189
189
  >;
190
190
  title?: string | TitleComponent;
191
- interaction?: Literal2Object<Interaction>;
191
+ interaction?: Literal2Object<Interaction> & Record<string, any>;
192
192
  theme?: Theme;
193
193
  };
194
194
 
@@ -8,6 +8,7 @@ export type Transform =
8
8
  | StackEnterTransform
9
9
  | JitterTransform
10
10
  | JitterXTransform
11
+ | JitterYTransform
11
12
  | SymmetryYTransform
12
13
  | DiffYTransform
13
14
  | SelectTransform
@@ -34,6 +35,7 @@ export type TransformTypes =
34
35
  | 'stackEnter'
35
36
  | 'jitter'
36
37
  | 'jitterX'
38
+ | 'jitterY'
37
39
  | 'symmetryY'
38
40
  | 'diffY'
39
41
  | 'select'
@@ -109,6 +111,12 @@ export type JitterXTransform = {
109
111
  random?: () => number;
110
112
  };
111
113
 
114
+ export type JitterYTransform = {
115
+ type?: 'jitterY';
116
+ padding?: number;
117
+ random?: () => number;
118
+ };
119
+
112
120
  export type StackEnterTransform = {
113
121
  type?: 'stackEnter';
114
122
  groupBy?: string[] | string;
@@ -23,6 +23,7 @@ export { StackEnter } from './stackEnter';
23
23
  export { NormalizeY } from './normalizeY';
24
24
  export { Jitter } from './jitter';
25
25
  export { JitterX } from './jitterX';
26
+ export { JitterY } from './jitterY';
26
27
  export { SymmetryY } from './symmetryY';
27
28
  export { DiffY } from './diffY';
28
29
  export { Select } from './select';
@@ -66,6 +67,7 @@ export type { StackEnterOptions } from './stackEnter';
66
67
  export type { NormalizeYOptions } from './normalizeY';
67
68
  export type { JitterOptions } from './jitter';
68
69
  export type { JitterXOptions } from './jitterX';
70
+ export type { JitterYOptions } from './jitterY';
69
71
  export type { SymmetryYOptions } from './symmetryY';
70
72
  export type { DiffYOptions } from './diffY';
71
73
  export type { SelectOptions } from './select';
@@ -0,0 +1,30 @@
1
+ import { deepMix } from '@antv/util';
2
+ import { TransformComponent as TC } from '../runtime';
3
+ import { JitterYTransform } from '../spec';
4
+ import { column, columnOf } from './utils/helper';
5
+ import { rangeOf, interpolate } from './jitter';
6
+
7
+ export type JitterYOptions = Omit<JitterYTransform, 'type'>;
8
+
9
+ /**
10
+ * The JitterY transform produce dy channels for marks (especially for point)
11
+ * with ordinal x and y dimension, say to make them jitter in their own space.
12
+ */
13
+ export const JitterY: TC<JitterYOptions> = (options = {}) => {
14
+ const { padding = 0, random = Math.random } = options;
15
+ return (I, mark) => {
16
+ const { encode, scale } = mark;
17
+ const { y: scaleY } = scale;
18
+ const [Y] = columnOf(encode, 'y');
19
+ const rangeY = rangeOf(Y, scaleY, padding);
20
+ const DY = I.map(() => interpolate(random(), ...rangeY));
21
+ return [
22
+ I,
23
+ deepMix({ scale: { y: { padding: 0.5 } } }, mark, {
24
+ encode: { dy: column(DY) },
25
+ }),
26
+ ];
27
+ };
28
+ };
29
+
30
+ JitterY.props = {};