@antv/component 1.0.3 → 2.0.1

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 (313) hide show
  1. package/dist/component.min.js +1 -1
  2. package/esm/animation/fadeIn.d.ts +1 -1
  3. package/esm/animation/fadeOut.d.ts +1 -1
  4. package/esm/animation/utils.d.ts +3 -3
  5. package/esm/animation/utils.js +10 -14
  6. package/esm/animation/utils.js.map +1 -1
  7. package/esm/index.js +0 -2
  8. package/esm/index.js.map +1 -1
  9. package/esm/ui/axis/axis.d.ts +1 -1
  10. package/esm/ui/axis/constant.js +1 -2
  11. package/esm/ui/axis/constant.js.map +1 -1
  12. package/esm/ui/axis/guides/grid.d.ts +1 -1
  13. package/esm/ui/axis/guides/labels.d.ts +1 -1
  14. package/esm/ui/axis/guides/labels.js +17 -11
  15. package/esm/ui/axis/guides/labels.js.map +1 -1
  16. package/esm/ui/axis/guides/line.js +3 -3
  17. package/esm/ui/axis/guides/line.js.map +1 -1
  18. package/esm/ui/axis/guides/ticks.d.ts +1 -1
  19. package/esm/ui/axis/guides/ticks.js +1 -1
  20. package/esm/ui/axis/guides/ticks.js.map +1 -1
  21. package/esm/ui/axis/guides/title.d.ts +1 -1
  22. package/esm/ui/axis/guides/title.js +8 -11
  23. package/esm/ui/axis/guides/title.js.map +1 -1
  24. package/esm/ui/axis/overlap/autoEllipsis.js +1 -2
  25. package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
  26. package/esm/ui/axis/overlap/autoHide.js +1 -2
  27. package/esm/ui/axis/overlap/autoHide.js.map +1 -1
  28. package/esm/ui/axis/utils/bounds.d.ts +3 -1
  29. package/esm/ui/axis/utils/bounds.js +5 -8
  30. package/esm/ui/axis/utils/bounds.js.map +1 -1
  31. package/esm/ui/axis/utils/test.js +4 -2
  32. package/esm/ui/axis/utils/test.js.map +1 -1
  33. package/esm/ui/breadcrumb/index.js +2 -2
  34. package/esm/ui/breadcrumb/index.js.map +1 -1
  35. package/esm/ui/button/index.js +8 -6
  36. package/esm/ui/button/index.js.map +1 -1
  37. package/esm/ui/button/types.d.ts +2 -0
  38. package/esm/ui/checkbox/constant.d.ts +4 -4
  39. package/esm/ui/checkbox/constant.js +1 -1
  40. package/esm/ui/checkbox/constant.js.map +1 -1
  41. package/esm/ui/checkbox/index.js +1 -1
  42. package/esm/ui/checkbox/index.js.map +1 -1
  43. package/esm/ui/crosshair/base.js +1 -1
  44. package/esm/ui/crosshair/base.js.map +1 -1
  45. package/esm/ui/crosshair/circle.js +1 -1
  46. package/esm/ui/crosshair/circle.js.map +1 -1
  47. package/esm/ui/crosshair/polygon.js +1 -1
  48. package/esm/ui/crosshair/polygon.js.map +1 -1
  49. package/esm/ui/grid/index.d.ts +1 -1
  50. package/esm/ui/grid/index.js +4 -4
  51. package/esm/ui/grid/index.js.map +1 -1
  52. package/esm/ui/indicator/indicator.js +3 -2
  53. package/esm/ui/indicator/indicator.js.map +1 -1
  54. package/esm/ui/indicator/types.d.ts +2 -0
  55. package/esm/ui/layout/layout.js +3 -1
  56. package/esm/ui/layout/layout.js.map +1 -1
  57. package/esm/ui/layout/types.d.ts +2 -0
  58. package/esm/ui/legend/base.d.ts +1 -1
  59. package/esm/ui/legend/category/item.d.ts +2 -0
  60. package/esm/ui/legend/category/item.js +10 -4
  61. package/esm/ui/legend/category/item.js.map +1 -1
  62. package/esm/ui/legend/category/items.d.ts +2 -0
  63. package/esm/ui/legend/category/items.js.map +1 -1
  64. package/esm/ui/legend/category.js +4 -3
  65. package/esm/ui/legend/category.js.map +1 -1
  66. package/esm/ui/legend/continuous/ribbon.js +4 -4
  67. package/esm/ui/legend/continuous/ribbon.js.map +1 -1
  68. package/esm/ui/legend/continuous.d.ts +2 -2
  69. package/esm/ui/legend/continuous.js +35 -25
  70. package/esm/ui/legend/continuous.js.map +1 -1
  71. package/esm/ui/marker/index.js +5 -4
  72. package/esm/ui/marker/index.js.map +1 -1
  73. package/esm/ui/marker/types.d.ts +2 -0
  74. package/esm/ui/navigator/index.js +6 -1
  75. package/esm/ui/navigator/index.js.map +1 -1
  76. package/esm/ui/navigator/types.d.ts +2 -0
  77. package/esm/ui/scrollbar/index.js +4 -2
  78. package/esm/ui/scrollbar/index.js.map +1 -1
  79. package/esm/ui/scrollbar/types.d.ts +2 -0
  80. package/esm/ui/select/option.js +1 -1
  81. package/esm/ui/select/option.js.map +1 -1
  82. package/esm/ui/select/select.js +11 -9
  83. package/esm/ui/select/select.js.map +1 -1
  84. package/esm/ui/select/types.d.ts +4 -0
  85. package/esm/ui/slider/constant.d.ts +2 -0
  86. package/esm/ui/slider/constant.js +2 -0
  87. package/esm/ui/slider/constant.js.map +1 -1
  88. package/esm/ui/slider/handle.d.ts +4 -0
  89. package/esm/ui/slider/handle.js +14 -17
  90. package/esm/ui/slider/handle.js.map +1 -1
  91. package/esm/ui/slider/index.js +17 -16
  92. package/esm/ui/slider/index.js.map +1 -1
  93. package/esm/ui/slider/types.d.ts +2 -0
  94. package/esm/ui/sparkline/columns.d.ts +2 -0
  95. package/esm/ui/sparkline/columns.js +2 -1
  96. package/esm/ui/sparkline/columns.js.map +1 -1
  97. package/esm/ui/sparkline/index.js +6 -4
  98. package/esm/ui/sparkline/index.js.map +1 -1
  99. package/esm/ui/sparkline/lines.d.ts +2 -0
  100. package/esm/ui/sparkline/lines.js +2 -1
  101. package/esm/ui/sparkline/lines.js.map +1 -1
  102. package/esm/ui/sparkline/types.d.ts +2 -0
  103. package/esm/ui/switch/index.js +1 -0
  104. package/esm/ui/switch/index.js.map +1 -1
  105. package/esm/ui/switch/types.d.ts +2 -0
  106. package/esm/ui/tag/index.js +1 -4
  107. package/esm/ui/tag/index.js.map +1 -1
  108. package/esm/ui/tag/types.d.ts +2 -0
  109. package/esm/ui/timebar/controller.js +8 -8
  110. package/esm/ui/timebar/controller.js.map +1 -1
  111. package/esm/ui/timebar/handle.d.ts +4 -0
  112. package/esm/ui/timebar/handle.js +9 -7
  113. package/esm/ui/timebar/handle.js.map +1 -1
  114. package/esm/ui/timebar/icons.d.ts +2 -2
  115. package/esm/ui/timebar/icons.js +104 -91
  116. package/esm/ui/timebar/icons.js.map +1 -1
  117. package/esm/ui/timebar/timebar.js +14 -6
  118. package/esm/ui/timebar/timebar.js.map +1 -1
  119. package/esm/ui/timebar/types.d.ts +4 -0
  120. package/esm/ui/tooltip/types.d.ts +2 -0
  121. package/esm/util/keyframe-interpolate.d.ts +1 -1
  122. package/esm/util/offscreen.js +1 -0
  123. package/esm/util/offscreen.js.map +1 -1
  124. package/esm/util/primitive.js +0 -3
  125. package/esm/util/primitive.js.map +1 -1
  126. package/esm/util/scale-to-pixel.js +3 -2
  127. package/esm/util/scale-to-pixel.js.map +1 -1
  128. package/lib/animation/fadeIn.d.ts +1 -1
  129. package/lib/animation/fadeOut.d.ts +1 -1
  130. package/lib/animation/utils.d.ts +3 -3
  131. package/lib/animation/utils.js +10 -14
  132. package/lib/animation/utils.js.map +1 -1
  133. package/lib/index.js +0 -2
  134. package/lib/index.js.map +1 -1
  135. package/lib/ui/axis/axis.d.ts +1 -1
  136. package/lib/ui/axis/constant.js +1 -2
  137. package/lib/ui/axis/constant.js.map +1 -1
  138. package/lib/ui/axis/guides/grid.d.ts +1 -1
  139. package/lib/ui/axis/guides/labels.d.ts +1 -1
  140. package/lib/ui/axis/guides/labels.js +17 -11
  141. package/lib/ui/axis/guides/labels.js.map +1 -1
  142. package/lib/ui/axis/guides/line.js +3 -3
  143. package/lib/ui/axis/guides/line.js.map +1 -1
  144. package/lib/ui/axis/guides/ticks.d.ts +1 -1
  145. package/lib/ui/axis/guides/ticks.js +1 -1
  146. package/lib/ui/axis/guides/ticks.js.map +1 -1
  147. package/lib/ui/axis/guides/title.d.ts +1 -1
  148. package/lib/ui/axis/guides/title.js +7 -10
  149. package/lib/ui/axis/guides/title.js.map +1 -1
  150. package/lib/ui/axis/overlap/autoEllipsis.js +1 -2
  151. package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
  152. package/lib/ui/axis/overlap/autoHide.js +1 -2
  153. package/lib/ui/axis/overlap/autoHide.js.map +1 -1
  154. package/lib/ui/axis/utils/bounds.d.ts +3 -1
  155. package/lib/ui/axis/utils/bounds.js +6 -10
  156. package/lib/ui/axis/utils/bounds.js.map +1 -1
  157. package/lib/ui/axis/utils/test.js +4 -2
  158. package/lib/ui/axis/utils/test.js.map +1 -1
  159. package/lib/ui/breadcrumb/index.js +2 -2
  160. package/lib/ui/breadcrumb/index.js.map +1 -1
  161. package/lib/ui/button/index.js +8 -6
  162. package/lib/ui/button/index.js.map +1 -1
  163. package/lib/ui/button/types.d.ts +2 -0
  164. package/lib/ui/checkbox/constant.d.ts +4 -4
  165. package/lib/ui/checkbox/constant.js +1 -1
  166. package/lib/ui/checkbox/constant.js.map +1 -1
  167. package/lib/ui/checkbox/index.js +1 -1
  168. package/lib/ui/checkbox/index.js.map +1 -1
  169. package/lib/ui/crosshair/base.js +1 -1
  170. package/lib/ui/crosshair/base.js.map +1 -1
  171. package/lib/ui/crosshair/circle.js +1 -1
  172. package/lib/ui/crosshair/circle.js.map +1 -1
  173. package/lib/ui/crosshair/polygon.js +1 -1
  174. package/lib/ui/crosshair/polygon.js.map +1 -1
  175. package/lib/ui/grid/index.d.ts +1 -1
  176. package/lib/ui/grid/index.js +4 -4
  177. package/lib/ui/grid/index.js.map +1 -1
  178. package/lib/ui/indicator/indicator.js +3 -2
  179. package/lib/ui/indicator/indicator.js.map +1 -1
  180. package/lib/ui/indicator/types.d.ts +2 -0
  181. package/lib/ui/layout/layout.js +3 -1
  182. package/lib/ui/layout/layout.js.map +1 -1
  183. package/lib/ui/layout/types.d.ts +2 -0
  184. package/lib/ui/legend/base.d.ts +1 -1
  185. package/lib/ui/legend/category/item.d.ts +2 -0
  186. package/lib/ui/legend/category/item.js +10 -4
  187. package/lib/ui/legend/category/item.js.map +1 -1
  188. package/lib/ui/legend/category/items.d.ts +2 -0
  189. package/lib/ui/legend/category/items.js.map +1 -1
  190. package/lib/ui/legend/category.js +4 -3
  191. package/lib/ui/legend/category.js.map +1 -1
  192. package/lib/ui/legend/continuous/ribbon.js +4 -4
  193. package/lib/ui/legend/continuous/ribbon.js.map +1 -1
  194. package/lib/ui/legend/continuous.d.ts +2 -2
  195. package/lib/ui/legend/continuous.js +35 -25
  196. package/lib/ui/legend/continuous.js.map +1 -1
  197. package/lib/ui/marker/index.js +5 -4
  198. package/lib/ui/marker/index.js.map +1 -1
  199. package/lib/ui/marker/types.d.ts +2 -0
  200. package/lib/ui/navigator/index.js +6 -1
  201. package/lib/ui/navigator/index.js.map +1 -1
  202. package/lib/ui/navigator/types.d.ts +2 -0
  203. package/lib/ui/scrollbar/index.js +4 -2
  204. package/lib/ui/scrollbar/index.js.map +1 -1
  205. package/lib/ui/scrollbar/types.d.ts +2 -0
  206. package/lib/ui/select/option.js +1 -1
  207. package/lib/ui/select/option.js.map +1 -1
  208. package/lib/ui/select/select.js +11 -9
  209. package/lib/ui/select/select.js.map +1 -1
  210. package/lib/ui/select/types.d.ts +4 -0
  211. package/lib/ui/slider/constant.d.ts +2 -0
  212. package/lib/ui/slider/constant.js +2 -0
  213. package/lib/ui/slider/constant.js.map +1 -1
  214. package/lib/ui/slider/handle.d.ts +4 -0
  215. package/lib/ui/slider/handle.js +14 -17
  216. package/lib/ui/slider/handle.js.map +1 -1
  217. package/lib/ui/slider/index.js +17 -16
  218. package/lib/ui/slider/index.js.map +1 -1
  219. package/lib/ui/slider/types.d.ts +2 -0
  220. package/lib/ui/sparkline/columns.d.ts +2 -0
  221. package/lib/ui/sparkline/columns.js +2 -1
  222. package/lib/ui/sparkline/columns.js.map +1 -1
  223. package/lib/ui/sparkline/index.js +6 -4
  224. package/lib/ui/sparkline/index.js.map +1 -1
  225. package/lib/ui/sparkline/lines.d.ts +2 -0
  226. package/lib/ui/sparkline/lines.js +2 -1
  227. package/lib/ui/sparkline/lines.js.map +1 -1
  228. package/lib/ui/sparkline/types.d.ts +2 -0
  229. package/lib/ui/switch/index.js +1 -0
  230. package/lib/ui/switch/index.js.map +1 -1
  231. package/lib/ui/switch/types.d.ts +2 -0
  232. package/lib/ui/tag/index.js +1 -4
  233. package/lib/ui/tag/index.js.map +1 -1
  234. package/lib/ui/tag/types.d.ts +2 -0
  235. package/lib/ui/timebar/controller.js +8 -8
  236. package/lib/ui/timebar/controller.js.map +1 -1
  237. package/lib/ui/timebar/handle.d.ts +4 -0
  238. package/lib/ui/timebar/handle.js +9 -7
  239. package/lib/ui/timebar/handle.js.map +1 -1
  240. package/lib/ui/timebar/icons.d.ts +2 -2
  241. package/lib/ui/timebar/icons.js +104 -91
  242. package/lib/ui/timebar/icons.js.map +1 -1
  243. package/lib/ui/timebar/timebar.js +14 -6
  244. package/lib/ui/timebar/timebar.js.map +1 -1
  245. package/lib/ui/timebar/types.d.ts +4 -0
  246. package/lib/ui/tooltip/types.d.ts +2 -0
  247. package/lib/util/keyframe-interpolate.d.ts +1 -1
  248. package/lib/util/offscreen.js +1 -0
  249. package/lib/util/offscreen.js.map +1 -1
  250. package/lib/util/primitive.js +0 -3
  251. package/lib/util/primitive.js.map +1 -1
  252. package/lib/util/scale-to-pixel.js +3 -2
  253. package/lib/util/scale-to-pixel.js.map +1 -1
  254. package/package.json +6 -6
  255. package/src/animation/utils.ts +16 -15
  256. package/src/index.ts +0 -4
  257. package/src/ui/axis/constant.ts +1 -2
  258. package/src/ui/axis/guides/labels.ts +24 -12
  259. package/src/ui/axis/guides/line.ts +3 -3
  260. package/src/ui/axis/guides/ticks.ts +1 -1
  261. package/src/ui/axis/guides/title.ts +11 -11
  262. package/src/ui/axis/overlap/autoEllipsis.ts +1 -2
  263. package/src/ui/axis/overlap/autoHide.ts +1 -2
  264. package/src/ui/axis/utils/bounds.ts +6 -8
  265. package/src/ui/axis/utils/test.ts +4 -2
  266. package/src/ui/breadcrumb/index.ts +2 -3
  267. package/src/ui/button/index.ts +10 -6
  268. package/src/ui/button/types.ts +2 -0
  269. package/src/ui/checkbox/constant.ts +1 -1
  270. package/src/ui/checkbox/index.ts +0 -2
  271. package/src/ui/crosshair/base.ts +1 -1
  272. package/src/ui/crosshair/circle.ts +1 -1
  273. package/src/ui/crosshair/polygon.ts +1 -1
  274. package/src/ui/grid/index.ts +4 -4
  275. package/src/ui/indicator/indicator.ts +3 -2
  276. package/src/ui/indicator/types.ts +2 -0
  277. package/src/ui/layout/layout.ts +4 -1
  278. package/src/ui/layout/types.ts +2 -0
  279. package/src/ui/legend/category/item.ts +14 -4
  280. package/src/ui/legend/category/items.ts +2 -0
  281. package/src/ui/legend/category.ts +4 -3
  282. package/src/ui/legend/continuous/ribbon.ts +4 -4
  283. package/src/ui/legend/continuous.ts +48 -29
  284. package/src/ui/marker/index.ts +5 -3
  285. package/src/ui/marker/types.ts +2 -0
  286. package/src/ui/navigator/index.ts +8 -1
  287. package/src/ui/navigator/types.ts +2 -0
  288. package/src/ui/scrollbar/index.ts +5 -1
  289. package/src/ui/scrollbar/types.ts +2 -0
  290. package/src/ui/select/option.ts +1 -1
  291. package/src/ui/select/select.ts +11 -9
  292. package/src/ui/select/types.ts +4 -0
  293. package/src/ui/slider/constant.ts +2 -0
  294. package/src/ui/slider/handle.ts +26 -14
  295. package/src/ui/slider/index.ts +20 -12
  296. package/src/ui/slider/types.ts +2 -0
  297. package/src/ui/sparkline/columns.ts +4 -1
  298. package/src/ui/sparkline/index.ts +10 -4
  299. package/src/ui/sparkline/lines.ts +4 -1
  300. package/src/ui/sparkline/types.ts +2 -0
  301. package/src/ui/switch/index.ts +1 -0
  302. package/src/ui/switch/types.ts +2 -0
  303. package/src/ui/tag/index.ts +1 -5
  304. package/src/ui/tag/types.ts +2 -0
  305. package/src/ui/timebar/controller.ts +8 -8
  306. package/src/ui/timebar/handle.ts +16 -10
  307. package/src/ui/timebar/icons.ts +94 -87
  308. package/src/ui/timebar/timebar.ts +13 -9
  309. package/src/ui/timebar/types.ts +4 -0
  310. package/src/ui/tooltip/types.ts +2 -0
  311. package/src/util/offscreen.ts +1 -0
  312. package/src/util/primitive.ts +0 -3
  313. package/src/util/scale-to-pixel.ts +3 -1
@@ -4,6 +4,8 @@ import type { SeriesAttr } from '../../util/series';
4
4
 
5
5
  export type LayoutStyleProps = GroupStyleProps &
6
6
  LayoutElementConfig & {
7
+ x?: number;
8
+ y?: number;
7
9
  width: number;
8
10
  height: number;
9
11
  margin?: SeriesAttr;
@@ -43,6 +43,8 @@ export type CategoryItemStyleProps = GroupStyleProps &
43
43
  valueText?: ExtendDisplayObject;
44
44
  // if width and height not specific, set it to actual space occurred
45
45
  width?: number;
46
+ x?: number;
47
+ y?: number;
46
48
  };
47
49
 
48
50
  export type CategoryItemOptions = ComponentOptions<CategoryItemStyleProps>;
@@ -203,7 +205,8 @@ export class CategoryItem extends Component<CategoryItemStyleProps> {
203
205
 
204
206
  // record the scale of marker
205
207
  this.markerGroup.node().scale(1 / this.markerGroup.node().getScale()[0]);
206
- scaleToPixel(this.markerGroup.node(), this.scaleSize, true);
208
+ const scale = scaleToPixel(this.markerGroup.node(), this.scaleSize, true);
209
+ this.markerGroup.node().style._transform = `scale(${scale})`;
207
210
  });
208
211
  }
209
212
 
@@ -238,18 +241,25 @@ export class CategoryItem extends Component<CategoryItemStyleProps> {
238
241
  },
239
242
  } = this;
240
243
  const halfHeight = height / 2;
241
- this.markerGroup.styles({ x: markerX, y: halfHeight });
242
- this.labelGroup.styles({ x: labelX, y: halfHeight });
244
+
245
+ // console.log(this.markerGroup.node().style._transform);
246
+
247
+ this.markerGroup.styles({
248
+ transform: `translate(${markerX}, ${halfHeight})${this.markerGroup.node().style._transform}`,
249
+ });
250
+ this.labelGroup.styles({ transform: `translate(${labelX}, ${halfHeight})` });
243
251
 
244
252
  ellipsisIt(this.labelGroup.select(CLASS_NAMES.label.class).node(), Math.ceil(labelWidth));
245
253
  if (this.showValue) {
246
- this.valueGroup.styles({ x: valueX, y: halfHeight });
254
+ this.valueGroup.styles({ transform: `translate(${valueX}, ${halfHeight})` });
247
255
  ellipsisIt(this.valueGroup.select(CLASS_NAMES.value.class).node(), Math.ceil(valueWidth));
248
256
  }
249
257
  }
250
258
 
251
259
  public render(attributes: CategoryItemStyleProps, container: Group) {
252
260
  const ctn = select(container);
261
+ const { x = 0, y = 0 } = attributes;
262
+ ctn.styles({ transform: `translate(${x}, ${y})` });
253
263
  this.renderMarker(ctn);
254
264
  this.renderLabel(ctn);
255
265
  this.renderValue(ctn);
@@ -36,6 +36,8 @@ export type CategoryItemsStyleProps = GroupStyleProps &
36
36
  data: CategoryItemsDatum[];
37
37
  orientation?: 'horizontal' | 'vertical';
38
38
  layout?: 'flex' | 'grid';
39
+ x?: number;
40
+ y?: number;
39
41
  width?: number;
40
42
  height?: number;
41
43
  gridRow?: number;
@@ -44,7 +44,7 @@ export class Category extends Component<CategoryStyleProps> {
44
44
  const itemStyle = { ...partialItemStyle, width, height, x: 0, y: 0 } as CategoryStyleProps;
45
45
  this.itemsGroup = container
46
46
  .maybeAppendByClassName<Group>(CLASS_NAMES.itemsGroup, 'g')
47
- .styles({ x, y, ...groupStyle });
47
+ .styles({ ...groupStyle, transform: `translate(${x}, ${y})` });
48
48
  const that = this;
49
49
  this.itemsGroup
50
50
  .selectAll(CLASS_NAMES.items.class)
@@ -66,7 +66,7 @@ export class Category extends Component<CategoryStyleProps> {
66
66
  const { showTitle } = this.attributes;
67
67
  if (showTitle) {
68
68
  const { x, y } = this.title.node<Title>().getAvailableSpace();
69
- this.itemsGroup.node().setLocalPosition(x, y);
69
+ this.itemsGroup.node().style.transform = `translate(${x}, ${y})`;
70
70
  }
71
71
  }
72
72
 
@@ -84,8 +84,9 @@ export class Category extends Component<CategoryStyleProps> {
84
84
  }
85
85
 
86
86
  render(attributes: Required<CategoryStyleProps>, container: Group) {
87
- const { width, height } = attributes;
87
+ const { width, height, x = 0, y = 0 } = this.attributes;
88
88
  const ctn = select(container);
89
+ container.style.transform = `translate(${x}, ${y})`;
89
90
 
90
91
  this.renderTitle(ctn, width!, height!);
91
92
 
@@ -93,7 +93,7 @@ function getClipPath(attr: RequiredRibbonStyleProps): any[] {
93
93
 
94
94
  function renderTrack(container: Selection, attr: RequiredRibbonStyleProps) {
95
95
  const style = subStyleProps(attr, 'track');
96
- container.maybeAppendByClassName(CLASS_NAMES.track, 'path').styles({ path: getTrackPath(attr), ...style });
96
+ container.maybeAppendByClassName(CLASS_NAMES.track, 'path').styles({ d: getTrackPath(attr), ...style });
97
97
  }
98
98
 
99
99
  function renderSelection(container: Selection, attr: RequiredRibbonStyleProps) {
@@ -102,12 +102,12 @@ function renderSelection(container: Selection, attr: RequiredRibbonStyleProps) {
102
102
 
103
103
  const ribbon = container
104
104
  .maybeAppendByClassName(CLASS_NAMES.selection, 'path')
105
- .styles({ path: getSelectionPath(attr), fill, ...style });
105
+ .styles({ d: getSelectionPath(attr), fill, ...style });
106
106
  const clipPath = ribbon
107
107
  .maybeAppendByClassName(CLASS_NAMES.clipPath, 'path')
108
- .styles({ path: getClipPath(attr) })
108
+ .styles({ d: getClipPath(attr) })
109
109
  .node();
110
- ribbon.style('clip-path', clipPath);
110
+ ribbon.style('clipPath', clipPath);
111
111
  }
112
112
 
113
113
  export class Ribbon extends Component<RibbonStyleProps> {
@@ -2,7 +2,7 @@ import { CustomEvent } from '@antv/g';
2
2
  import { Linear } from '@antv/scale';
3
3
  import { clamp, isUndefined } from '@antv/util';
4
4
  import { Component } from '../../core';
5
- import type { BaseStyleProps, DisplayObject, TextStyleProps } from '../../shapes';
5
+ import type { DisplayObject, TextStyleProps } from '../../shapes';
6
6
  import { Group } from '../../shapes';
7
7
  import { Point } from '../../types';
8
8
  import {
@@ -92,7 +92,9 @@ export class Continuous extends Component<ContinuousStyleProps> {
92
92
  /** label */
93
93
 
94
94
  /** content */
95
- const contentGroup = select(container).maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g').styles({ x, y });
95
+ const contentGroup = select(container)
96
+ .maybeAppendByClassName(CLASS_NAMES.contentGroup, 'g')
97
+ .styles({ transform: `translate(${x}, ${y})` });
96
98
 
97
99
  const labelGroup = contentGroup.maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles({ zIndex: 1 });
98
100
  ifShow(!!showLabel, labelGroup, (group) => {
@@ -268,8 +270,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
268
270
  const { length, size } = this.ribbonShape;
269
271
  const style: Required<RibbonStyleProps> = deepAssign(
270
272
  {
271
- x,
272
- y,
273
+ transform: `translate(${x}, ${y})`,
273
274
  length,
274
275
  size,
275
276
  type,
@@ -344,22 +345,6 @@ export class Continuous extends Component<ContinuousStyleProps> {
344
345
  this.setHandlePosition('end', max);
345
346
  }
346
347
 
347
- private adjustTitle() {
348
- const { titlePosition, orientation } = this.attributes;
349
- const [title] = this.getElementsByClassName(CLASS_NAMES.title.name);
350
- const handle: Handle = this.handlesGroup.select(`.${this.getHandleClassName('start')}`).node();
351
- if (!title || !handle) return;
352
- if (titlePosition !== 'top-left' || orientation !== 'horizontal') return;
353
- const {
354
- min: [handleX],
355
- } = handle.getLocalBounds();
356
- const {
357
- min: [titleX],
358
- } = title.getLocalBounds();
359
- const diffX = handleX - titleX;
360
- title.style.x = +(this.style.x || 0) + diffX;
361
- }
362
-
363
348
  private cacheHandleBBox: DOMRect | null = null;
364
349
 
365
350
  private get handleBBox() {
@@ -391,7 +376,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
391
376
  [ribbonX + ribbonSize * this.handleOffsetRatio, ribbonY + offset]
392
377
  );
393
378
  const handle: Handle = this.handlesGroup.select(`.${this.getHandleClassName(type)}`).node();
394
- handle?.update({ x, y, formatter: handleFormatter });
379
+ handle?.update({ transform: `translate(${x}, ${y})`, formatter: handleFormatter });
395
380
  }
396
381
 
397
382
  private renderIndicator(container: Selection) {
@@ -532,7 +517,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
532
517
  else if (labelPosition === 'top') spacing = labelSpacing;
533
518
  }
534
519
 
535
- return { offset, spacing: labelSpacing, tickLength };
520
+ return { offset, spacing, tickLength };
536
521
  }
537
522
 
538
523
  private adjustLabel() {
@@ -585,11 +570,13 @@ export class Continuous extends Component<ContinuousStyleProps> {
585
570
  data.map(({ value }) => value),
586
571
  value
587
572
  );
588
- this.showIndicator((range[0] + range[1]) / 2, `${range[0]}-${range[1]}`);
573
+
574
+ const selection = this.getRealSelection(range);
575
+ this.showIndicator((range[0] + range[1]) / 2, `${selection[0]}-${selection[1]}`);
589
576
  this.dispatchIndicated(value, range);
590
577
  } else {
591
578
  const safetyValue = this.getTickValue(value);
592
- this.showIndicator(safetyValue);
579
+ this.showIndicator(safetyValue, `${this.getRealValue(safetyValue)}`);
593
580
  this.dispatchIndicated(safetyValue);
594
581
  }
595
582
  };
@@ -605,6 +592,7 @@ export class Continuous extends Component<ContinuousStyleProps> {
605
592
  const safeValue = clamp(value, min, max);
606
593
  const offset = this.getOffset(safeValue);
607
594
  const pos: Point = this.ifHorizontal([offset + x, y], [x, offset + y]);
595
+
608
596
  this.indicator.update({
609
597
  x: pos[0],
610
598
  y: pos[1],
@@ -701,9 +689,8 @@ export class Continuous extends Component<ContinuousStyleProps> {
701
689
 
702
690
  /**
703
691
  * 事件触发的位置对应的value值
704
- * @param limit {boolean} 我也忘了要干啥了
705
692
  */
706
- private getValueByCanvasPoint(e: any, limit: boolean = false) {
693
+ private getValueByCanvasPoint(e: any) {
707
694
  const { min, max } = this.range;
708
695
  const [x, y] = this.ribbon.node().getPosition();
709
696
  const startPos = this.ifHorizontal(x, y);
@@ -723,18 +710,50 @@ export class Continuous extends Component<ContinuousStyleProps> {
723
710
  return scale.map(value);
724
711
  }
725
712
 
713
+ private getRealSelection(range: number[]) {
714
+ const { max } = this.range;
715
+ const [start, end] = range;
716
+
717
+ return this.ifHorizontal([start, end], [max - end, max - start]);
718
+ }
719
+
720
+ private getRealValue(value: number) {
721
+ const { max } = this.range;
722
+
723
+ return this.ifHorizontal(value, max - value);
724
+ }
725
+
726
726
  private dispatchSelection() {
727
+ const selection = this.getRealSelection(this.selection);
728
+
727
729
  const evt = new CustomEvent('valuechange', {
728
730
  detail: {
729
- value: this.selection,
731
+ value: selection,
730
732
  },
731
733
  });
732
734
  this.dispatchEvent(evt as any);
733
735
  }
734
736
 
735
- private dispatchIndicated(value: number, range?: unknown) {
737
+ private dispatchIndicated(value: number, range?: number[]) {
738
+ const { max } = this.range;
739
+
740
+ const detail = this.ifHorizontal(
741
+ () => {
742
+ return {
743
+ value,
744
+ range,
745
+ };
746
+ },
747
+ () => {
748
+ return {
749
+ value: max - value,
750
+ range: range ? this.getRealSelection(range) : undefined,
751
+ };
752
+ }
753
+ );
754
+
736
755
  const evt = new CustomEvent('indicate', {
737
- detail: { value, range },
756
+ detail,
738
757
  });
739
758
  this.dispatchEvent(evt as any);
740
759
  }
@@ -44,7 +44,9 @@ function getType(symbol: MarkerStyleProps['symbol']): string | null {
44
44
 
45
45
  export class Marker extends Component<MarkerStyleProps> {
46
46
  public render(attributes: Required<MarkerStyleProps>, container: Group) {
47
+ const { x = 0, y = 0 } = attributes;
47
48
  const { symbol, size = 16, ...style } = this.getSubShapeStyle(attributes);
49
+
48
50
  const type = getType(symbol);
49
51
  ifShow(!!type, select(container), (group) => {
50
52
  group
@@ -58,13 +60,13 @@ export class Marker extends Component<MarkerStyleProps> {
58
60
  img: symbol,
59
61
  width: r,
60
62
  height: r,
61
- x: -size,
62
- y: -size,
63
+ x: x - size,
64
+ y: y - size,
63
65
  });
64
66
  } else {
65
67
  const r = (size as number) / 2;
66
68
  const symbolFn = isFunction(symbol) ? symbol : Marker.getSymbol(symbol);
67
- selection.styles({ path: symbolFn?.(0, 0, r), ...style });
69
+ selection.styles({ d: symbolFn?.(x, y, r), ...style });
68
70
  }
69
71
  });
70
72
  });
@@ -4,6 +4,8 @@ import type { BaseCustomElementStyleProps } from '../../shapes';
4
4
  export type FunctionalSymbol = (x: number, y: number, r: number) => any;
5
5
 
6
6
  export type MarkerStyleProps = BaseCustomElementStyleProps & {
7
+ x?: number;
8
+ y?: number;
7
9
  size?: number;
8
10
  symbol: string | FunctionalSymbol;
9
11
  };
@@ -41,6 +41,8 @@ const CLASS_NAMES = classNames(
41
41
  export class Navigator extends Component<NavigatorStyleProps> {
42
42
  constructor(options: NavigatorOptions) {
43
43
  super(options, {
44
+ x: 0,
45
+ y: 0,
44
46
  animate: {
45
47
  easing: 'linear',
46
48
  duration: 200,
@@ -48,7 +50,7 @@ export class Navigator extends Component<NavigatorStyleProps> {
48
50
  },
49
51
  buttonCursor: 'pointer',
50
52
  buttonFill: 'black',
51
- buttonPath: button(0, 0, 6),
53
+ buttonD: button(0, 0, 6),
52
54
  buttonSize: 12,
53
55
  controllerPadding: 5,
54
56
  controllerSpacing: 5,
@@ -305,6 +307,8 @@ export class Navigator extends Component<NavigatorStyleProps> {
305
307
 
306
308
  this.updatePageInfo();
307
309
 
310
+ // group.node().style.transform = `translate(${pageWidth + spacing}, ${pageHeight / 2})`;
311
+
308
312
  // put it on the right side of the container
309
313
  group.node().setLocalPosition(pageWidth + spacing, pageHeight / 2);
310
314
  if (whetherToAddEventListener) {
@@ -318,6 +322,9 @@ export class Navigator extends Component<NavigatorStyleProps> {
318
322
  }
319
323
 
320
324
  render(attributes: NavigatorStyleProps, container: Group) {
325
+ const { x = 0, y = 0 } = attributes;
326
+ this.attr('transform', `translate(${x}, ${y})`);
327
+
321
328
  /**
322
329
  * container
323
330
  * |- contentGroup (with clip path)
@@ -6,6 +6,8 @@ import type { PrefixObject } from '../../types';
6
6
  export type NavigatorStyleProps = Omit<RectStyleProps, 'width' | 'height'> &
7
7
  PrefixObject<PathStyleProps & { size?: number }, 'button'> &
8
8
  PrefixObject<TextStyleProps, 'pageNum'> & {
9
+ x?: number;
10
+ y?: number;
9
11
  animate?: GenericAnimation;
10
12
  /** padding between buttons and page number */
11
13
  controllerPadding?: number;
@@ -23,6 +23,8 @@ export class Scrollbar extends Component<ScrollbarStyleProps> {
23
23
 
24
24
  constructor(options: ScrollbarOptions) {
25
25
  super(options, {
26
+ x: 0,
27
+ y: 0,
26
28
  isRound: true,
27
29
  orientation: 'vertical',
28
30
  padding: [2, 2, 2, 2],
@@ -90,11 +92,13 @@ export class Scrollbar extends Component<ScrollbarStyleProps> {
90
92
  }
91
93
 
92
94
  private renderSlider(container: Group) {
93
- const { orientation, trackSize, padding, slidable } = this.attributes;
95
+ const { x, y, orientation, trackSize, padding, slidable } = this.attributes;
94
96
  const trackStyle = subStyleProps<RectStyleProps>(this.attributes, 'track');
95
97
  const selectionStyle = subStyleProps<RectStyleProps>(this.attributes, 'thumb');
96
98
 
97
99
  const style: SliderStyleProps = {
100
+ x,
101
+ y,
98
102
  brushable: false,
99
103
  orientation,
100
104
  padding,
@@ -8,6 +8,8 @@ import type { SliderStyleProps } from '../slider';
8
8
  export type ScrollbarStyleProps = GroupStyleProps &
9
9
  PrefixObject<RectStyleProps, 'track'> &
10
10
  PrefixObject<RectStyleProps, 'thumb'> & {
11
+ x?: number;
12
+ y?: number;
11
13
  /** 滑条朝向 */
12
14
  orientation?: Required<SliderStyleProps>['orientation'];
13
15
 
@@ -52,7 +52,7 @@ export class Option extends Component<OptionStyleProps> {
52
52
  fill: selected ? this.selectedColor : '#fff',
53
53
  });
54
54
  // place label
55
- this.label.attr({ x: left, y: (backgroundHeight - labelHeight) / 2 });
55
+ this.label.attr({ transform: `translate(${left}, ${(backgroundHeight - labelHeight) / 2})` });
56
56
  }
57
57
 
58
58
  constructor(options: OptionOptions) {
@@ -9,6 +9,8 @@ import type { SelectOptions, SelectStyleProps } from './types';
9
9
  export class Select extends Component<SelectStyleProps> {
10
10
  static defaultOptions: SelectOptions = {
11
11
  style: {
12
+ x: 0,
13
+ y: 0,
12
14
  width: 140,
13
15
  height: 32,
14
16
  options: [],
@@ -74,10 +76,10 @@ export class Select extends Component<SelectStyleProps> {
74
76
  );
75
77
 
76
78
  private renderSelect() {
77
- const { width, height, bordered, showDropdownIcon } = this.style;
79
+ const { x, y, width, height, bordered, showDropdownIcon } = this.style;
78
80
  const selectStyle = subStyleProps(this.attributes, 'select');
79
81
  const placeholderStyle = subStyleProps(this.attributes, 'placeholder');
80
- this.select.attr({ width, height, ...selectStyle, fill: '#fff', strokeWidth: bordered ? 1 : 0 });
82
+ this.select.attr({ x, y, width, height, ...selectStyle, fill: '#fff', strokeWidth: bordered ? 1 : 0 });
81
83
  const padding = this.dropdownPadding;
82
84
  // dropdown icon
83
85
  const iconSize = 10;
@@ -85,7 +87,7 @@ export class Select extends Component<SelectStyleProps> {
85
87
  select(this.select)
86
88
  .maybeAppend('.dropdown-icon', 'path')
87
89
  .style('d', 'M-5,-3.5 L0,3.5 L5,-3.5')
88
- .style('transform', `translate(${width - iconSize - padding[1] - padding[3]}, ${height / 2})`)
90
+ .style('transform', `translate(${x + width - iconSize - padding[1] - padding[3]}, ${y + height / 2})`)
89
91
  .style('lineWidth', 1)
90
92
  .style('stroke', this.select.style.stroke);
91
93
  }
@@ -93,7 +95,7 @@ export class Select extends Component<SelectStyleProps> {
93
95
  const currentOption = this.style.options?.find((option) => option.value === this.currentValue);
94
96
  // placeholder
95
97
  const finalPlaceholderStyle = {
96
- x: padding[3],
98
+ x: x + padding[3],
97
99
  ...placeholderStyle,
98
100
  };
99
101
  select(this.select)
@@ -107,7 +109,7 @@ export class Select extends Component<SelectStyleProps> {
107
109
  .styles(finalPlaceholderStyle)
108
110
  .style('y', function () {
109
111
  const bbox = this.getBBox();
110
- return (height - bbox.height) / 2;
112
+ return y + (height - bbox.height) / 2;
111
113
  }),
112
114
  (update) => update.styles(finalPlaceholderStyle),
113
115
  (exit) => exit.remove()
@@ -116,7 +118,7 @@ export class Select extends Component<SelectStyleProps> {
116
118
  // value
117
119
  const labelStyle = subStyleProps(this.attributes, 'optionLabel');
118
120
  const finalValueStyle = {
119
- x: padding[3],
121
+ x: x + padding[3],
120
122
  ...labelStyle,
121
123
  };
122
124
 
@@ -131,7 +133,7 @@ export class Select extends Component<SelectStyleProps> {
131
133
  .styles(finalValueStyle)
132
134
  .style('y', function () {
133
135
  const bbox = this.getBBox();
134
- return (height - bbox.height) / 2;
136
+ return y + (height - bbox.height) / 2;
135
137
  }),
136
138
  (update) => update.styles(finalValueStyle),
137
139
  (exit) => exit.remove()
@@ -139,7 +141,7 @@ export class Select extends Component<SelectStyleProps> {
139
141
  }
140
142
 
141
143
  private renderDropdown() {
142
- const { width, height, options, onSelect, open } = this.style;
144
+ const { x, y, width, height, options, onSelect, open } = this.style;
143
145
  const dropdownStyle = subStyleProps(this.attributes, 'dropdown');
144
146
  const optionStyle = subStyleProps(this.attributes, 'option');
145
147
  const padding = this.dropdownPadding;
@@ -193,7 +195,7 @@ export class Select extends Component<SelectStyleProps> {
193
195
  const { spacing } = dropdownStyle;
194
196
 
195
197
  this.dropdown.attr({
196
- y: height + spacing,
198
+ transform: `translate(${x}, ${y + height + spacing})`,
197
199
  width: bbox.width + padding[1] + padding[3],
198
200
  height: bbox.height + padding[0] + padding[2],
199
201
  ...dropdownStyle,
@@ -28,6 +28,10 @@ export type SelectStyleProps = GroupStyleProps &
28
28
  PrefixObject<Omit<RectStyleProps, 'width' | 'height'>, 'dropdown'> &
29
29
  PrefixObject<TextStyleProps, 'option'> &
30
30
  PrefixObject<Omit<OptionStyleProps, 'value' | 'label' | 'selected' | 'onClick'>, 'option'> & {
31
+ /** 左上角 X 坐标 */
32
+ x?: number;
33
+ /** 左上角 Y 坐标 */
34
+ y?: number;
31
35
  /** 宽度 */
32
36
  width?: number;
33
37
  /** 高度 */
@@ -20,6 +20,8 @@ export const HANDLE_LABEL_DEFAULT_CFG = {
20
20
  } as const;
21
21
 
22
22
  export const HANDLE_DEFAULT_CFG = {
23
+ x: 0,
24
+ y: 0,
23
25
  orientation: 'horizontal',
24
26
  showLabel: true,
25
27
  type: 'start',
@@ -8,6 +8,8 @@ import { HANDLE_DEFAULT_CFG, HANDLE_ICON_DEFAULT_CFG, HANDLE_LABEL_DEFAULT_CFG }
8
8
  export type HandleType = 'start' | 'end';
9
9
 
10
10
  export type IconStyleProps = PathStyleProps & {
11
+ x?: number;
12
+ y?: number;
11
13
  size?: number;
12
14
  radius?: number;
13
15
  shape?: string | ((type: HandleType) => DisplayObject);
@@ -19,6 +21,8 @@ export type LabelStyleProps = Partial<TextStyleProps>;
19
21
  export type HandleStyleProps = GroupStyleProps &
20
22
  PrefixStyleProps<LabelStyleProps, 'label'> &
21
23
  PrefixStyleProps<IconStyleProps, 'icon'> & {
24
+ x?: number;
25
+ y?: number;
22
26
  orientation?: IconStyleProps['orientation'];
23
27
  showLabel?: boolean;
24
28
  spacing?: number;
@@ -41,7 +45,7 @@ const CLASS_NAMES = classNames(
41
45
 
42
46
  class HandleIcon extends Component<IconStyleProps> {
43
47
  render(attributes: Required<IconStyleProps>, container: DisplayObject) {
44
- const { size = 10, radius = size / 4, orientation, ...iconStyle } = attributes;
48
+ const { x, y, size = 10, radius = size / 4, orientation, ...iconStyle } = attributes;
45
49
  // 默认手柄
46
50
  const width = size!;
47
51
  const height = width * 2.4;
@@ -53,21 +57,20 @@ class HandleIcon extends Component<IconStyleProps> {
53
57
  width,
54
58
  height,
55
59
  radius,
56
- x: -width / 2,
57
- y: -height / 2,
60
+ x: x - width / 2,
61
+ y: y - height / 2,
62
+ transformOrigin: 'center',
58
63
  });
59
64
 
60
- const x1 = (1 / 3) * width;
61
- const x2 = (2 / 3) * width;
62
- const y1 = (1 / 4) * height;
63
- const y2 = (3 / 4) * height;
65
+ const x1 = x + (1 / 3) * width - width / 2;
66
+ const x2 = x + (2 / 3) * width - width / 2;
67
+ const y1 = y + (1 / 4) * height - height / 2;
68
+ const y2 = y + (3 / 4) * height - height / 2;
64
69
 
65
70
  rect.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-1`, 'line').styles({ x1, x2: x1, y1, y2, ...iconStyle });
66
71
  rect.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-2`, 'line').styles({ x1: x2, x2, y1, y2, ...iconStyle });
67
72
 
68
- rect.node().setOrigin(width / 2, height / 2);
69
- if (orientation === 'vertical') container.setLocalEulerAngles(90);
70
- else container.setLocalEulerAngles(0);
73
+ if (orientation === 'vertical') rect.node().style.transform = 'rotate(90)';
71
74
  }
72
75
  }
73
76
 
@@ -81,8 +84,14 @@ export class Handle extends Component<HandleStyleProps> {
81
84
  }
82
85
 
83
86
  private renderLabel(container: Group) {
84
- const { showLabel } = this.attributes;
85
- const { transform, ...style } = subStyleProps(this.attributes, 'label');
87
+ const { x, y, showLabel } = this.attributes;
88
+ const {
89
+ x: labelX = 0,
90
+ y: labelY = 0,
91
+ transform,
92
+ transformOrigin,
93
+ ...style
94
+ } = subStyleProps(this.attributes, 'label');
86
95
  const [labelStyle, groupStyle] = splitStyle(style, []);
87
96
 
88
97
  const labelGroup = select(container).maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles(groupStyle);
@@ -92,7 +101,10 @@ export class Handle extends Component<HandleStyleProps> {
92
101
  ifShow(!!showLabel, labelGroup, (group) => {
93
102
  this.label = group.maybeAppendByClassName(CLASS_NAMES.label, 'text').styles({
94
103
  ...rest,
104
+ x: x + labelX,
105
+ y: y + labelY,
95
106
  transform,
107
+ transformOrigin,
96
108
  text: `${text}`,
97
109
  });
98
110
 
@@ -107,8 +119,8 @@ export class Handle extends Component<HandleStyleProps> {
107
119
  }
108
120
 
109
121
  private renderIcon(container: Group) {
110
- const { orientation, type } = this.attributes;
111
- const iconStyle = { orientation, ...HANDLE_ICON_DEFAULT_CFG, ...subStyleProps(this.attributes, 'icon') };
122
+ const { x, y, orientation, type } = this.attributes;
123
+ const iconStyle = { x, y, orientation, ...HANDLE_ICON_DEFAULT_CFG, ...subStyleProps(this.attributes, 'icon') };
112
124
  const { iconShape = () => new HandleIcon({ style: iconStyle }) } = this.attributes;
113
125
  const iconGroup = select(container).maybeAppendByClassName(CLASS_NAMES.iconGroup, 'g');
114
126
  iconGroup