@antv/g2 5.0.0-beta.6 → 5.0.0-beta.7

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 (228) 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 -2
  4. package/esm/api/chart.js +2 -3
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/composition/base.d.ts +4 -0
  7. package/esm/api/composition/base.js +16 -0
  8. package/esm/api/composition/base.js.map +1 -0
  9. package/esm/api/composition/facetCircle.d.ts +2 -3
  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 -3
  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 -3
  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 -3
  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 -1
  22. package/esm/api/composition/index.js +2 -1
  23. package/esm/api/composition/index.js.map +1 -1
  24. package/esm/api/composition/repeatMatrix.d.ts +2 -3
  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 -3
  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 -3
  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 -3
  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 +3 -3
  37. package/esm/api/composition/view.js +4 -4
  38. package/esm/api/composition/view.js.map +1 -1
  39. package/esm/api/mark/mark.d.ts +34 -28
  40. package/esm/api/mark/mark.js +38 -26
  41. package/esm/api/mark/mark.js.map +1 -1
  42. package/esm/api/node.d.ts +2 -1
  43. package/esm/api/node.js +8 -9
  44. package/esm/api/node.js.map +1 -1
  45. package/esm/component/slider.js +3 -13
  46. package/esm/component/slider.js.map +1 -1
  47. package/esm/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
  48. package/esm/geo/{d3-projection.js → d3Projection.js} +1 -1
  49. package/esm/geo/d3Projection.js.map +1 -0
  50. package/esm/geo/geoView.js +1 -1
  51. package/esm/geo/geoView.js.map +1 -1
  52. package/esm/interaction/index.d.ts +1 -0
  53. package/esm/interaction/index.js +1 -0
  54. package/esm/interaction/index.js.map +1 -1
  55. package/esm/interaction/native/brushFilter.d.ts +3 -1
  56. package/esm/interaction/native/brushFilter.js +7 -32
  57. package/esm/interaction/native/brushFilter.js.map +1 -1
  58. package/esm/interaction/native/brushXFilter.js +1 -1
  59. package/esm/interaction/native/brushXFilter.js.map +1 -1
  60. package/esm/interaction/native/brushYFilter.js +1 -1
  61. package/esm/interaction/native/brushYFilter.js.map +1 -1
  62. package/esm/interaction/native/elementHighlight.js +1 -0
  63. package/esm/interaction/native/elementHighlight.js.map +1 -1
  64. package/esm/interaction/native/elementSelect.js +1 -0
  65. package/esm/interaction/native/elementSelect.js.map +1 -1
  66. package/esm/interaction/native/sliderFilter.d.ts +5 -0
  67. package/esm/interaction/native/sliderFilter.js +87 -0
  68. package/esm/interaction/native/sliderFilter.js.map +1 -0
  69. package/esm/interaction/native/tooltip.js +11 -0
  70. package/esm/interaction/native/tooltip.js.map +1 -1
  71. package/esm/label-transform/overlapDodgeY.js +8 -0
  72. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  73. package/esm/runtime/component.d.ts +1 -1
  74. package/esm/runtime/component.js +5 -3
  75. package/esm/runtime/component.js.map +1 -1
  76. package/esm/runtime/plot.d.ts +1 -1
  77. package/esm/runtime/plot.js +65 -26
  78. package/esm/runtime/plot.js.map +1 -1
  79. package/esm/runtime/scale.d.ts +2 -1
  80. package/esm/runtime/scale.js +7 -0
  81. package/esm/runtime/scale.js.map +1 -1
  82. package/esm/spec/geometry.d.ts +1 -0
  83. package/esm/spec/interaction.d.ts +8 -2
  84. package/esm/spec/transform.d.ts +2 -2
  85. package/esm/stdlib/index.js +2 -2
  86. package/esm/stdlib/index.js.map +1 -1
  87. package/esm/transform/select.js +1 -13
  88. package/esm/transform/select.js.map +1 -1
  89. package/esm/transform/selectX.js +1 -1
  90. package/esm/transform/selectX.js.map +1 -1
  91. package/esm/transform/selectY.js +1 -1
  92. package/esm/transform/selectY.js.map +1 -1
  93. package/esm/utils/scale.d.ts +2 -0
  94. package/esm/utils/scale.js +30 -0
  95. package/esm/utils/scale.js.map +1 -0
  96. package/lib/api/chart.d.ts +2 -2
  97. package/lib/api/chart.js +1 -2
  98. package/lib/api/chart.js.map +1 -1
  99. package/lib/api/composition/base.d.ts +4 -0
  100. package/lib/api/composition/base.js +19 -0
  101. package/lib/api/composition/base.js.map +1 -0
  102. package/lib/api/composition/facetCircle.d.ts +2 -3
  103. package/lib/api/composition/facetCircle.js +2 -2
  104. package/lib/api/composition/facetCircle.js.map +1 -1
  105. package/lib/api/composition/facetRect.d.ts +2 -3
  106. package/lib/api/composition/facetRect.js +2 -2
  107. package/lib/api/composition/facetRect.js.map +1 -1
  108. package/lib/api/composition/geoPath.d.ts +2 -3
  109. package/lib/api/composition/geoPath.js +2 -2
  110. package/lib/api/composition/geoPath.js.map +1 -1
  111. package/lib/api/composition/geoView.d.ts +2 -3
  112. package/lib/api/composition/geoView.js +2 -2
  113. package/lib/api/composition/geoView.js.map +1 -1
  114. package/lib/api/composition/index.d.ts +2 -1
  115. package/lib/api/composition/index.js +3 -1
  116. package/lib/api/composition/index.js.map +1 -1
  117. package/lib/api/composition/repeatMatrix.d.ts +2 -3
  118. package/lib/api/composition/repeatMatrix.js +2 -2
  119. package/lib/api/composition/repeatMatrix.js.map +1 -1
  120. package/lib/api/composition/spaceFlex.d.ts +2 -3
  121. package/lib/api/composition/spaceFlex.js +2 -2
  122. package/lib/api/composition/spaceFlex.js.map +1 -1
  123. package/lib/api/composition/spaceLayer.d.ts +2 -3
  124. package/lib/api/composition/spaceLayer.js +2 -2
  125. package/lib/api/composition/spaceLayer.js.map +1 -1
  126. package/lib/api/composition/timingKeyframe.d.ts +2 -3
  127. package/lib/api/composition/timingKeyframe.js +2 -2
  128. package/lib/api/composition/timingKeyframe.js.map +1 -1
  129. package/lib/api/composition/view.d.ts +3 -3
  130. package/lib/api/composition/view.js +4 -4
  131. package/lib/api/composition/view.js.map +1 -1
  132. package/lib/api/mark/mark.d.ts +34 -28
  133. package/lib/api/mark/mark.js +40 -27
  134. package/lib/api/mark/mark.js.map +1 -1
  135. package/lib/api/node.d.ts +2 -1
  136. package/lib/api/node.js +8 -9
  137. package/lib/api/node.js.map +1 -1
  138. package/lib/component/slider.js +3 -13
  139. package/lib/component/slider.js.map +1 -1
  140. package/lib/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
  141. package/lib/geo/{d3-projection.js → d3Projection.js} +1 -1
  142. package/lib/geo/d3Projection.js.map +1 -0
  143. package/lib/geo/geoView.js +1 -1
  144. package/lib/geo/geoView.js.map +1 -1
  145. package/lib/interaction/index.d.ts +1 -0
  146. package/lib/interaction/index.js +3 -1
  147. package/lib/interaction/index.js.map +1 -1
  148. package/lib/interaction/native/brushFilter.d.ts +3 -1
  149. package/lib/interaction/native/brushFilter.js +10 -35
  150. package/lib/interaction/native/brushFilter.js.map +1 -1
  151. package/lib/interaction/native/brushXFilter.js +1 -1
  152. package/lib/interaction/native/brushXFilter.js.map +1 -1
  153. package/lib/interaction/native/brushYFilter.js +1 -1
  154. package/lib/interaction/native/brushYFilter.js.map +1 -1
  155. package/lib/interaction/native/elementHighlight.js +1 -0
  156. package/lib/interaction/native/elementHighlight.js.map +1 -1
  157. package/lib/interaction/native/elementSelect.js +1 -0
  158. package/lib/interaction/native/elementSelect.js.map +1 -1
  159. package/lib/interaction/native/sliderFilter.d.ts +5 -0
  160. package/lib/interaction/native/sliderFilter.js +91 -0
  161. package/lib/interaction/native/sliderFilter.js.map +1 -0
  162. package/lib/interaction/native/tooltip.js +11 -0
  163. package/lib/interaction/native/tooltip.js.map +1 -1
  164. package/lib/label-transform/overlapDodgeY.js +8 -0
  165. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  166. package/lib/runtime/component.d.ts +1 -1
  167. package/lib/runtime/component.js +4 -2
  168. package/lib/runtime/component.js.map +1 -1
  169. package/lib/runtime/plot.d.ts +1 -1
  170. package/lib/runtime/plot.js +62 -23
  171. package/lib/runtime/plot.js.map +1 -1
  172. package/lib/runtime/scale.d.ts +2 -1
  173. package/lib/runtime/scale.js +9 -1
  174. package/lib/runtime/scale.js.map +1 -1
  175. package/lib/spec/geometry.d.ts +1 -0
  176. package/lib/spec/interaction.d.ts +8 -2
  177. package/lib/spec/transform.d.ts +2 -2
  178. package/lib/stdlib/index.js +1 -1
  179. package/lib/stdlib/index.js.map +1 -1
  180. package/lib/transform/select.js +1 -13
  181. package/lib/transform/select.js.map +1 -1
  182. package/lib/transform/selectX.js +1 -1
  183. package/lib/transform/selectX.js.map +1 -1
  184. package/lib/transform/selectY.js +1 -1
  185. package/lib/transform/selectY.js.map +1 -1
  186. package/lib/utils/scale.d.ts +2 -0
  187. package/lib/utils/scale.js +35 -0
  188. package/lib/utils/scale.js.map +1 -0
  189. package/package.json +1 -1
  190. package/src/api/chart.ts +2 -2
  191. package/src/api/composition/base.ts +11 -0
  192. package/src/api/composition/facetCircle.ts +2 -3
  193. package/src/api/composition/facetRect.ts +2 -3
  194. package/src/api/composition/geoPath.ts +2 -3
  195. package/src/api/composition/geoView.ts +2 -3
  196. package/src/api/composition/index.ts +2 -0
  197. package/src/api/composition/repeatMatrix.ts +2 -3
  198. package/src/api/composition/spaceFlex.ts +2 -3
  199. package/src/api/composition/spaceLayer.ts +2 -3
  200. package/src/api/composition/timingKeyframe.ts +2 -3
  201. package/src/api/composition/view.ts +6 -4
  202. package/src/api/mark/mark.ts +47 -27
  203. package/src/api/node.ts +9 -11
  204. package/src/component/slider.ts +3 -12
  205. package/src/geo/{d3-projection.ts → d3Projection.ts} +0 -0
  206. package/src/geo/geoView.ts +1 -1
  207. package/src/interaction/index.ts +1 -0
  208. package/src/interaction/native/brushFilter.ts +18 -38
  209. package/src/interaction/native/brushXFilter.ts +1 -0
  210. package/src/interaction/native/brushYFilter.ts +1 -0
  211. package/src/interaction/native/elementHighlight.ts +1 -0
  212. package/src/interaction/native/elementSelect.ts +1 -0
  213. package/src/interaction/native/sliderFilter.ts +112 -0
  214. package/src/interaction/native/tooltip.ts +11 -0
  215. package/src/label-transform/overlapDodgeY.ts +8 -1
  216. package/src/runtime/component.ts +18 -25
  217. package/src/runtime/plot.ts +120 -72
  218. package/src/runtime/scale.ts +14 -0
  219. package/src/spec/geometry.ts +1 -0
  220. package/src/spec/interaction.ts +10 -1
  221. package/src/spec/transform.ts +3 -1
  222. package/src/stdlib/index.ts +2 -0
  223. package/src/transform/select.ts +1 -2
  224. package/src/transform/selectX.ts +1 -1
  225. package/src/transform/selectY.ts +1 -1
  226. package/src/utils/scale.ts +31 -0
  227. package/esm/geo/d3-projection.js.map +0 -1
  228. package/lib/geo/d3-projection.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"selectX.js","sourceRoot":"src/","sources":["transform/selectX.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,qCAAkC;AAIlC;;GAEG;AACI,MAAM,OAAO,GAAuB,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE;IAC1D,MAAM,EAAE,QAAQ,KAAc,OAAO,EAAhB,IAAI,UAAK,OAAO,EAA/B,YAAqB,CAAU,CAAC;IACtC,OAAO,IAAA,eAAM,kBAAG,CAAC,EAAE,QAAQ,IAAK,IAAI,EAAG,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB;AAEF,eAAO,CAAC,KAAK,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"selectX.js","sourceRoot":"src/","sources":["transform/selectX.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,qCAAkC;AAIlC;;GAEG;AACI,MAAM,OAAO,GAAuB,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE;IAC1D,MAAM,EAAE,QAAQ,KAAc,OAAO,EAAhB,IAAI,UAAK,OAAO,EAA/B,YAAqB,CAAU,CAAC;IACtC,OAAO,IAAA,eAAM,kBAAG,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAK,IAAI,EAAG,CAAC;AACrD,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB;AAEF,eAAO,CAAC,KAAK,GAAG,EAAE,CAAC"}
@@ -18,7 +18,7 @@ const select_1 = require("./select");
18
18
  */
19
19
  const SelectY = (options = {}) => {
20
20
  const { selector } = options, rest = __rest(options, ["selector"]);
21
- return (0, select_1.Select)(Object.assign({ y: selector }, rest));
21
+ return (0, select_1.Select)(Object.assign({ channel: 'y', selector }, rest));
22
22
  };
23
23
  exports.SelectY = SelectY;
24
24
  exports.SelectY.props = {};
@@ -1 +1 @@
1
- {"version":3,"file":"selectY.js","sourceRoot":"src/","sources":["transform/selectY.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,qCAAkC;AAIlC;;GAEG;AACI,MAAM,OAAO,GAAuB,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE;IAC1D,MAAM,EAAE,QAAQ,KAAc,OAAO,EAAhB,IAAI,UAAK,OAAO,EAA/B,YAAqB,CAAU,CAAC;IACtC,OAAO,IAAA,eAAM,kBAAG,CAAC,EAAE,QAAQ,IAAK,IAAI,EAAG,CAAC;AAC1C,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB;AAEF,eAAO,CAAC,KAAK,GAAG,EAAE,CAAC"}
1
+ {"version":3,"file":"selectY.js","sourceRoot":"src/","sources":["transform/selectY.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,qCAAkC;AAIlC;;GAEG;AACI,MAAM,OAAO,GAAuB,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE;IAC1D,MAAM,EAAE,QAAQ,KAAc,OAAO,EAAhB,IAAI,UAAK,OAAO,EAA/B,YAAqB,CAAU,CAAC;IACtC,OAAO,IAAA,eAAM,kBAAG,OAAO,EAAE,GAAG,EAAE,QAAQ,IAAK,IAAI,EAAG,CAAC;AACrD,CAAC,CAAC;AAHW,QAAA,OAAO,WAGlB;AAEF,eAAO,CAAC,KAAK,GAAG,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function invert(scale: any, x: any, start: any): any;
2
+ export declare function domainOf(scale: any, values: any): any;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.domainOf = exports.invert = void 0;
4
+ const d3_array_1 = require("d3-array");
5
+ function isOrdinalScale(scale) {
6
+ return scale.getBandWidth;
7
+ }
8
+ function constrain(x, lo, hi) {
9
+ return Math.min(hi, Math.max(lo, x));
10
+ }
11
+ function invert(scale, x, start) {
12
+ if (!isOrdinalScale(scale))
13
+ return scale.invert(x);
14
+ const { adjustedRange } = scale;
15
+ const { domain } = scale.getOptions();
16
+ const offset = start ? -1 : 0;
17
+ const step = scale.getStep();
18
+ const range = start ? adjustedRange : adjustedRange.map((d) => d + step);
19
+ // R[i0 - 1] < x <= R[i0]
20
+ const i0 = (0, d3_array_1.bisectLeft)(range, x);
21
+ const i1 = constrain(i0 + offset, 0, domain.length - 1);
22
+ return domain[i1];
23
+ }
24
+ exports.invert = invert;
25
+ function domainOf(scale, values) {
26
+ if (!isOrdinalScale(scale))
27
+ return (0, d3_array_1.sort)(values);
28
+ const { domain } = scale.getOptions();
29
+ const [v1, v2] = values;
30
+ const start = domain.indexOf(v1);
31
+ const end = domain.indexOf(v2);
32
+ return domain.slice(start, end + 1);
33
+ }
34
+ exports.domainOf = domainOf;
35
+ //# sourceMappingURL=scale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scale.js","sourceRoot":"src/","sources":["utils/scale.ts"],"names":[],"mappings":";;;AAAA,uCAA4C;AAE5C,SAAS,cAAc,CAAC,KAAK;IAC3B,OAAO,KAAK,CAAC,YAAY,CAAC;AAC5B,CAAC;AAED,SAAS,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE;IAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,SAAgB,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK;IACpC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACnD,MAAM,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IACzE,yBAAyB;IACzB,MAAM,EAAE,GAAG,IAAA,qBAAU,EAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAChC,MAAM,EAAE,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC,EAAE,CAAC,CAAC;AACpB,CAAC;AAXD,wBAWC;AAED,SAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACpC,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC;QAAE,OAAO,IAAA,eAAI,EAAC,MAAM,CAAC,CAAC;IAChD,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,CAAC;IACtC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC;IACxB,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC;AACtC,CAAC;AAPD,4BAOC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2",
3
- "version": "5.0.0-beta.6",
3
+ "version": "5.0.0-beta.7",
4
4
  "description": "the Grammar of Graphics in Javascript",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
package/src/api/chart.ts CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  ObjectAttribute,
21
21
  } from './types';
22
22
  import { mark, Mark } from './mark';
23
- import { composition, Composition } from './composition';
23
+ import { composition, Composition, View } from './composition';
24
24
  import { library } from './library';
25
25
 
26
26
  function normalizeContainer(container: string | HTMLElement): HTMLElement {
@@ -161,7 +161,7 @@ export const props: NodePropertyDescriptor[] = [
161
161
  ];
162
162
 
163
163
  @defineProps(props)
164
- export class Chart extends Node<ChartOptions> {
164
+ export class Chart extends View<ChartOptions> {
165
165
  private _container: HTMLElement;
166
166
  private _context: G2Context;
167
167
 
@@ -0,0 +1,11 @@
1
+ import { defineProps } from '../props';
2
+ import { Node } from '../node';
3
+
4
+ @defineProps([{ name: 'on', type: 'event' }])
5
+ export class Base<
6
+ Value extends Record<string, any> = Record<string, any>,
7
+ ParentValue extends Record<string, any> = Record<string, any>,
8
+ ChildValue extends Record<string, any> = Record<string, any>,
9
+ > extends Node<Value, ParentValue, ChildValue> {
10
+ getView() {}
11
+ }
@@ -6,9 +6,8 @@ import {
6
6
  ArrayAttribute,
7
7
  ObjectAttribute,
8
8
  } from '../types';
9
- import { Node } from '../node';
10
9
  import { mark, Mark } from '../mark';
11
- import { Composition } from './index';
10
+ import { Composition, Base } from './index';
12
11
 
13
12
  type FacetCircleSpec = Concrete<FacetCircleComposition>;
14
13
 
@@ -30,7 +29,7 @@ export interface FacetCircle extends Composition, Mark {
30
29
  { type: 'object', name: 'axis' },
31
30
  ...nodeProps(mark),
32
31
  ])
33
- export class FacetCircle extends Node<FacetCircleComposition> {
32
+ export class FacetCircle extends Base<FacetCircleComposition> {
34
33
  constructor() {
35
34
  super({}, 'facetCircle');
36
35
  }
@@ -6,9 +6,8 @@ import {
6
6
  ArrayAttribute,
7
7
  ObjectAttribute,
8
8
  } from '../types';
9
- import { Node } from '../node';
10
9
  import { mark, Mark } from '../mark';
11
- import { Composition } from './index';
10
+ import { Composition, Base } from './index';
12
11
 
13
12
  type FacetRectSpec = Concrete<FacetRectComposition>;
14
13
 
@@ -30,7 +29,7 @@ export interface FacetRect extends Composition, Mark {
30
29
  { type: 'object', name: 'axis' },
31
30
  ...nodeProps(mark),
32
31
  ])
33
- export class FacetRect extends Node<FacetRectComposition> {
32
+ export class FacetRect extends Base<FacetRectComposition> {
34
33
  constructor() {
35
34
  super({}, 'facetRect');
36
35
  }
@@ -6,9 +6,8 @@ import {
6
6
  ArrayAttribute,
7
7
  Concrete,
8
8
  } from '../types';
9
- import { Node } from '../node';
10
9
  import { mark, Mark } from '../mark';
11
- import { Composition } from './index';
10
+ import { Composition, Base } from './index';
12
11
 
13
12
  type GeoPathSpec = Concrete<GeoPathComposition>;
14
13
 
@@ -36,7 +35,7 @@ export interface GeoPath extends Mark, Composition {
36
35
  { type: 'object', name: 'legend' },
37
36
  ...nodeProps(mark),
38
37
  ])
39
- export class GeoPath extends Node<GeoPathComposition> {
38
+ export class GeoPath extends Base<GeoPathComposition> {
40
39
  constructor() {
41
40
  super({}, 'geoPath');
42
41
  }
@@ -6,9 +6,8 @@ import {
6
6
  ArrayAttribute,
7
7
  Concrete,
8
8
  } from '../types';
9
- import { Node } from '../node';
10
9
  import { mark, Mark } from '../mark';
11
- import { Composition } from './index';
10
+ import { Composition, Base } from './index';
12
11
 
13
12
  type GeoViewSpec = Concrete<GeoViewComposition>;
14
13
 
@@ -35,7 +34,7 @@ export interface GeoView extends Mark, Composition {
35
34
  { type: 'object', name: 'legend' },
36
35
  ...nodeProps(mark),
37
36
  ])
38
- export class GeoView extends Node<GeoViewComposition> {
37
+ export class GeoView extends Base<GeoViewComposition> {
39
38
  constructor() {
40
39
  super({}, 'geoView');
41
40
  }
@@ -1,4 +1,5 @@
1
1
  import { defineProps, nodeProps } from '../props';
2
+ import { Base } from './base';
2
3
  import { View } from './view';
3
4
  import { SpaceLayer } from './spaceLayer';
4
5
  import { SpaceFlex } from './spaceFlex';
@@ -34,6 +35,7 @@ export interface Composition {
34
35
  }
35
36
 
36
37
  export {
38
+ Base,
37
39
  View,
38
40
  SpaceLayer,
39
41
  SpaceFlex,
@@ -6,9 +6,8 @@ import {
6
6
  ArrayAttribute,
7
7
  ObjectAttribute,
8
8
  } from '../types';
9
- import { Node } from '../node';
10
9
  import { mark, Mark } from '../mark';
11
- import { Composition } from './index';
10
+ import { Composition, Base } from './index';
12
11
 
13
12
  type RepeatMatrixSpec = Concrete<RepeatMatrixComposition>;
14
13
 
@@ -30,7 +29,7 @@ export interface RepeatMatrix extends Composition, Mark {
30
29
  { type: 'object', name: 'legend' },
31
30
  ...nodeProps(mark),
32
31
  ])
33
- export class RepeatMatrix extends Node<RepeatMatrixComposition> {
32
+ export class RepeatMatrix extends Base<RepeatMatrixComposition> {
34
33
  constructor() {
35
34
  super({}, 'repeatMatrix');
36
35
  }
@@ -1,9 +1,8 @@
1
1
  import { SpaceFlexComposition } from '../../spec';
2
2
  import { defineProps, nodeProps } from '../props';
3
3
  import { ValueAttribute, Concrete } from '../types';
4
- import { Node } from '../node';
5
4
  import { mark, Mark } from '../mark';
6
- import { Composition } from './index';
5
+ import { Composition, Base } from './index';
7
6
 
8
7
  type SpaceFlexSpec = Concrete<SpaceFlexComposition>;
9
8
 
@@ -12,7 +11,7 @@ export interface SpaceFlex extends Composition, Mark {
12
11
  }
13
12
 
14
13
  @defineProps([{ type: 'value', name: 'data' }, ...nodeProps(mark)])
15
- export class SpaceFlex extends Node<SpaceFlexSpec> {
14
+ export class SpaceFlex extends Base<SpaceFlexSpec> {
16
15
  constructor() {
17
16
  super({}, 'spaceFlex');
18
17
  }
@@ -1,9 +1,8 @@
1
1
  import { SpaceLayerComposition } from '../../spec';
2
2
  import { defineProps, nodeProps } from '../props';
3
3
  import { ValueAttribute, Concrete } from '../types';
4
- import { Node } from '../node';
5
4
  import { mark, Mark } from '../mark';
6
- import { Composition } from './index';
5
+ import { Composition, Base } from './index';
7
6
 
8
7
  type SpaceLayerSpec = Concrete<SpaceLayerComposition>;
9
8
 
@@ -12,7 +11,7 @@ export interface SpaceLayer extends Composition, Mark {
12
11
  }
13
12
 
14
13
  @defineProps([{ type: 'value', name: 'data' }, ...nodeProps(mark)])
15
- export class SpaceLayer extends Node<SpaceLayerComposition> {
14
+ export class SpaceLayer extends Base<SpaceLayerComposition> {
16
15
  constructor() {
17
16
  super({}, 'spaceLayer');
18
17
  }
@@ -1,16 +1,15 @@
1
1
  import { TimingKeyframeComposition } from '../../spec';
2
2
  import { defineProps, nodeProps } from '../props';
3
3
  import { Concrete } from '../types';
4
- import { Node } from '../node';
5
4
  import { mark, Mark } from '../mark';
6
- import { Composition } from './index';
5
+ import { Composition, Base } from './index';
7
6
 
8
7
  type TimingKeyframeSpec = Concrete<TimingKeyframeComposition>;
9
8
 
10
9
  export interface TimingKeyframe extends Composition, Mark {}
11
10
 
12
11
  @defineProps([...nodeProps(mark)])
13
- export class TimingKeyframe extends Node<TimingKeyframeSpec> {
12
+ export class TimingKeyframe extends Base<TimingKeyframeSpec> {
14
13
  constructor() {
15
14
  super({}, 'timingKeyframe');
16
15
  }
@@ -6,8 +6,8 @@ import {
6
6
  ArrayAttribute,
7
7
  Concrete,
8
8
  } from '../types';
9
- import { Node } from '../node';
10
9
  import { mark, Mark } from '../mark';
10
+ import { Base } from './base';
11
11
 
12
12
  type ViewSpec = Concrete<ViewComposition>;
13
13
 
@@ -33,8 +33,10 @@ export interface View extends Mark {
33
33
  { type: 'object', name: 'legend' },
34
34
  ...nodeProps(mark),
35
35
  ])
36
- export class View extends Node<ViewComposition> {
37
- constructor() {
38
- super({}, 'view');
36
+ export class View<
37
+ ViewProps extends ViewComposition = ViewComposition,
38
+ > extends Base<ViewProps> {
39
+ constructor(options = {}, type = 'view') {
40
+ super(options, type);
39
41
  }
40
42
  }
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  IntervalGeometry,
3
+ RectGeometry,
3
4
  AreaGeometry,
4
5
  PointGeometry,
5
6
  CellGeometry,
@@ -34,7 +35,7 @@ export interface Interval extends API<Concrete<IntervalGeometry>, Interval> {
34
35
  type: 'interval';
35
36
  }
36
37
 
37
- export interface Rect extends API<Concrete<IntervalGeometry>, Rect> {
38
+ export interface Rect extends API<Concrete<RectGeometry>, Rect> {
38
39
  type: 'rect';
39
40
  }
40
41
 
@@ -147,183 +148,202 @@ export const props: NodePropertyDescriptor[] = [
147
148
  { name: 'scrollbar', type: 'object' },
148
149
  ];
149
150
 
151
+ export class MarkBase<
152
+ Value extends Record<string, any> = Record<string, any>,
153
+ ParentValue extends Record<string, any> = Record<string, any>,
154
+ ChildValue extends Record<string, any> = Record<string, any>,
155
+ > extends Node<Value, ParentValue, ChildValue> {
156
+ changeData(data) {
157
+ const chart = this.root();
158
+ if (!chart) return;
159
+ this.attr('data', data);
160
+ chart?.render();
161
+ }
162
+
163
+ getMark() {}
164
+
165
+ getScale() {}
166
+
167
+ getGroup() {}
168
+ }
169
+
150
170
  @defineProps(props)
151
- export class Interval extends Node<IntervalGeometry> {
171
+ export class Interval extends MarkBase<IntervalGeometry> {
152
172
  constructor() {
153
173
  super({}, 'interval');
154
174
  }
155
175
  }
156
176
 
157
177
  @defineProps(props)
158
- export class Rect extends Node<IntervalGeometry> {
178
+ export class Rect extends MarkBase<RectGeometry> {
159
179
  constructor() {
160
180
  super({}, 'rect');
161
181
  }
162
182
  }
163
183
 
164
184
  @defineProps(props)
165
- export class Point extends Node<PointGeometry> {
185
+ export class Point extends MarkBase<PointGeometry> {
166
186
  constructor() {
167
187
  super({}, 'point');
168
188
  }
169
189
  }
170
190
 
171
191
  @defineProps(props)
172
- export class Area extends Node<AreaGeometry> {
192
+ export class Area extends MarkBase<AreaGeometry> {
173
193
  constructor() {
174
194
  super({}, 'area');
175
195
  }
176
196
  }
177
197
 
178
198
  @defineProps(props)
179
- export class Line extends Node<LineGeometry> {
199
+ export class Line extends MarkBase<LineGeometry> {
180
200
  constructor() {
181
201
  super({}, 'line');
182
202
  }
183
203
  }
184
204
 
185
205
  @defineProps(props)
186
- export class Cell extends Node<CellGeometry> {
206
+ export class Cell extends MarkBase<CellGeometry> {
187
207
  constructor() {
188
208
  super({}, 'cell');
189
209
  }
190
210
  }
191
211
 
192
212
  @defineProps(props)
193
- export class Vector extends Node<VectorGeometry> {
213
+ export class Vector extends MarkBase<VectorGeometry> {
194
214
  constructor() {
195
215
  super({}, 'vector');
196
216
  }
197
217
  }
198
218
 
199
219
  @defineProps(props)
200
- export class Link extends Node<LinkGeometry> {
220
+ export class Link extends MarkBase<LinkGeometry> {
201
221
  constructor() {
202
222
  super({}, 'link');
203
223
  }
204
224
  }
205
225
 
206
226
  @defineProps(props)
207
- export class Polygon extends Node<PolygonGeometry> {
227
+ export class Polygon extends MarkBase<PolygonGeometry> {
208
228
  constructor() {
209
229
  super({}, 'polygon');
210
230
  }
211
231
  }
212
232
 
213
233
  @defineProps(props)
214
- export class Image extends Node<ImageGeometry> {
234
+ export class Image extends MarkBase<ImageGeometry> {
215
235
  constructor() {
216
236
  super({}, 'image');
217
237
  }
218
238
  }
219
239
 
220
240
  @defineProps(props)
221
- export class Text extends Node<TextGeometry> {
241
+ export class Text extends MarkBase<TextGeometry> {
222
242
  constructor() {
223
243
  super({}, 'text');
224
244
  }
225
245
  }
226
246
 
227
247
  @defineProps(props)
228
- export class Box extends Node<BoxGeometry> {
248
+ export class Box extends MarkBase<BoxGeometry> {
229
249
  constructor() {
230
250
  super({}, 'box');
231
251
  }
232
252
  }
233
253
 
234
254
  @defineProps(props)
235
- export class LineX extends Node<LineXMark> {
255
+ export class LineX extends MarkBase<LineXMark> {
236
256
  constructor() {
237
257
  super({}, 'lineX');
238
258
  }
239
259
  }
240
260
 
241
261
  @defineProps(props)
242
- export class LineY extends Node<LineYMark> {
262
+ export class LineY extends MarkBase<LineYMark> {
243
263
  constructor() {
244
264
  super({}, 'lineY');
245
265
  }
246
266
  }
247
267
 
248
268
  @defineProps(props)
249
- export class Range extends Node<RangeMark> {
269
+ export class Range extends MarkBase<RangeMark> {
250
270
  constructor() {
251
271
  super({}, 'range');
252
272
  }
253
273
  }
254
274
 
255
275
  @defineProps(props)
256
- export class RangeX extends Node<RangeXMark> {
276
+ export class RangeX extends MarkBase<RangeXMark> {
257
277
  constructor() {
258
278
  super({}, 'rangeX');
259
279
  }
260
280
  }
261
281
 
262
282
  @defineProps(props)
263
- export class RangeY extends Node<RangeYMark> {
283
+ export class RangeY extends MarkBase<RangeYMark> {
264
284
  constructor() {
265
285
  super({}, 'rangeY');
266
286
  }
267
287
  }
268
288
 
269
289
  @defineProps(props)
270
- export class Connector extends Node<ConnectorMark> {
290
+ export class Connector extends MarkBase<ConnectorMark> {
271
291
  constructor() {
272
292
  super({}, 'connector');
273
293
  }
274
294
  }
275
295
 
276
296
  @defineProps(props)
277
- export class Shape extends Node<ShapeMark> {
297
+ export class Shape extends MarkBase<ShapeMark> {
278
298
  constructor() {
279
299
  super({}, 'shape');
280
300
  }
281
301
  }
282
302
 
283
303
  @defineProps([...props, { name: 'layout', type: 'value' }])
284
- export class Sankey extends Node<SankeyMark> {
304
+ export class Sankey extends MarkBase<SankeyMark> {
285
305
  constructor() {
286
306
  super({}, 'sankey');
287
307
  }
288
308
  }
289
309
 
290
310
  @defineProps([...props, { name: 'layout', type: 'value' }])
291
- export class Treemap extends Node<ConnectorMark> {
311
+ export class Treemap extends MarkBase<ConnectorMark> {
292
312
  constructor() {
293
313
  super({}, 'treemap');
294
314
  }
295
315
  }
296
316
 
297
317
  @defineProps(props)
298
- export class Boxplot extends Node<Boxplot> {
318
+ export class Boxplot extends MarkBase<Boxplot> {
299
319
  constructor() {
300
320
  super({}, 'boxplot');
301
321
  }
302
322
  }
303
323
 
304
324
  @defineProps([...props, { name: 'layout', type: 'value' }])
305
- export class Pack extends Node<Pack> {
325
+ export class Pack extends MarkBase<Pack> {
306
326
  constructor() {
307
327
  super({}, 'pack');
308
328
  }
309
329
  }
310
330
 
311
331
  @defineProps([...props, { name: 'layout', type: 'value' }])
312
- export class ForceGraph extends Node<ForceGraph> {
332
+ export class ForceGraph extends MarkBase<ForceGraph> {
313
333
  constructor() {
314
334
  super({}, 'forceGraph');
315
335
  }
316
336
  }
317
337
 
318
338
  @defineProps([...props, { name: 'layout', type: 'value' }])
319
- export class Tree extends Node<Tree> {
339
+ export class Tree extends MarkBase<Tree> {
320
340
  constructor() {
321
341
  super({}, 'tree');
322
342
  }
323
343
  }
324
344
 
325
345
  @defineProps([...props, { name: 'layout', type: 'object' }])
326
- export class WordCloud extends Node<WordCloud> {
346
+ export class WordCloud extends MarkBase<WordCloud> {
327
347
  constructor() {
328
348
  super({}, 'wordCloud');
329
349
  }
package/src/api/node.ts CHANGED
@@ -1,4 +1,3 @@
1
- import { emitEvent, CHART_LIFE_CIRCLE } from '../utils/event';
2
1
  import { Chart } from './chart';
3
2
 
4
3
  /**
@@ -116,16 +115,6 @@ export class Node<
116
115
  return nodes;
117
116
  }
118
117
 
119
- changeData(data: any) {
120
- // Find the root chart and render.
121
- let root: Node = this;
122
- while (root && root.parentNode) {
123
- root = root.parentNode;
124
- }
125
- this.attr('data', data);
126
- (root as Chart).render();
127
- }
128
-
129
118
  /**
130
119
  * Apply specified callback to the node value.
131
120
  */
@@ -136,4 +125,13 @@ export class Node<
136
125
  callback(this.map(), ...params);
137
126
  return this;
138
127
  }
128
+
129
+ root(): Chart {
130
+ // Find the root chart and render.
131
+ let root: Node = this;
132
+ while (root && root.parentNode) {
133
+ root = root.parentNode;
134
+ }
135
+ return root as Chart;
136
+ }
139
137
  }
@@ -2,6 +2,7 @@ import { Slider as SliderComponent } from '@antv/gui';
2
2
  import { format } from 'd3-format';
3
3
  import { least } from 'd3-array';
4
4
  import { GuideComponentComponent as GCC, Scale } from '../runtime';
5
+ import { invert } from '../utils/scale';
5
6
 
6
7
  export type SliderOptions = {
7
8
  orient: 'horizontal' | 'vertical';
@@ -34,7 +35,8 @@ export const Slider: GCC<SliderOptions> = (options) => {
34
35
  orient,
35
36
  formatter: (v) => {
36
37
  const f = formatter || defaultFormatter;
37
- const tick = invertTick(scale, v);
38
+ // @todo Pass index to distinguish the left and the right value.
39
+ const tick = invert(scale, v, true);
38
40
  return f(tick);
39
41
  },
40
42
  ...rest,
@@ -43,17 +45,6 @@ export const Slider: GCC<SliderOptions> = (options) => {
43
45
  };
44
46
  };
45
47
 
46
- /**
47
- * Translate [0,1] value to origin value.
48
- */
49
- function invertTick(scale: Scale, v: number) {
50
- if (!scale.getBandWidth) return scale.invert(v);
51
- // @ts-ignore @todo should support in scale
52
- const range = scale.adjustedRange as number[];
53
- const abs = (v) => Math.abs(v);
54
- return scale.invert(least(range, (a, b) => abs(a - v) - abs(b - v)));
55
- }
56
-
57
48
  Slider.props = {
58
49
  defaultPosition: 'bottom',
59
50
  defaultSize: 24,
File without changes
@@ -4,7 +4,7 @@ import { geoPath, geoGraticule10 } from 'd3-geo';
4
4
  import { CompositionComponent as CC } from '../runtime';
5
5
  import { GeoViewComposition } from '../spec';
6
6
 
7
- import * as d3Projection from './d3-projection';
7
+ import * as d3Projection from './d3Projection';
8
8
 
9
9
  /**
10
10
  * Get projection factory from d3-projection.
@@ -17,6 +17,7 @@ export { BrushAxisHighlight } from './native/brushAxisHighlight';
17
17
  export { BrushFilter } from './native/brushFilter';
18
18
  export { BrushXFilter } from './native/brushXFilter';
19
19
  export { BrushYFilter } from './native/brushYFilter';
20
+ export { SliderFilter } from './native/sliderFilter';
20
21
 
21
22
  export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
22
23