@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
@@ -83,7 +83,7 @@ export class Slider extends Component<SliderStyleProps> {
83
83
  }
84
84
 
85
85
  private get availableSpace() {
86
- const { padding } = this.attributes;
86
+ const { x, y, padding } = this.attributes;
87
87
  const [top, right, bottom, left] = parseSeriesAttr(padding!);
88
88
  const { width, height } = this.shape;
89
89
  return {
@@ -96,6 +96,8 @@ export class Slider extends Component<SliderStyleProps> {
96
96
 
97
97
  constructor(options: SliderOptions) {
98
98
  super(options, {
99
+ x: 0,
100
+ y: 0,
99
101
  animate: { duration: 100, fill: 'both' },
100
102
  brushable: true,
101
103
  formatter: (val: any) => val.toString(),
@@ -167,18 +169,21 @@ export class Slider extends Component<SliderStyleProps> {
167
169
  }
168
170
 
169
171
  private renderTrack(container: Group) {
172
+ const { x, y } = this.attributes;
170
173
  const style = subStyleProps(this.attributes, 'track');
171
174
 
172
175
  this.trackShape = select(container)
173
176
  .maybeAppendByClassName(CLASS_NAMES.track, 'rect')
174
- .styles({ ...this.shape, ...style });
177
+ .styles({ x, y, ...this.shape, ...style });
175
178
  }
176
179
 
177
180
  private renderBrushArea(container: Group) {
178
- const { brushable } = this.attributes;
181
+ const { x, y, brushable } = this.attributes;
179
182
  this.brushArea = select(container)
180
183
  .maybeAppendByClassName(CLASS_NAMES.brushArea, 'rect')
181
184
  .styles({
185
+ x,
186
+ y,
182
187
  fill: 'transparent',
183
188
  cursor: brushable ? 'crosshair' : 'default',
184
189
  ...this.shape,
@@ -186,11 +191,11 @@ export class Slider extends Component<SliderStyleProps> {
186
191
  }
187
192
 
188
193
  private renderSparkline(container: Group) {
189
- const { orientation } = this.attributes;
194
+ const { x, y, orientation } = this.attributes;
190
195
  const sparklineGroup = select(container).maybeAppendByClassName(CLASS_NAMES.sparklineGroup, 'g');
191
196
 
192
197
  ifShow(orientation === 'horizontal', sparklineGroup, (group) => {
193
- const style = this.sparklineStyle!;
198
+ const style = { ...this.sparklineStyle!, x, y };
194
199
  group.maybeAppendByClassName(CLASS_NAMES.sparkline, () => new Sparkline({ style })).update(style);
195
200
  });
196
201
  }
@@ -232,7 +237,7 @@ export class Slider extends Component<SliderStyleProps> {
232
237
  }
233
238
 
234
239
  private renderSelection(container: Group) {
235
- const { type, selectionType } = this.attributes;
240
+ const { x, y, type, selectionType } = this.attributes;
236
241
  this.foregroundGroup = select(container).maybeAppendByClassName(CLASS_NAMES.foreground, 'g');
237
242
 
238
243
  // value 类型的 slider 不渲染选区
@@ -245,7 +250,10 @@ export class Slider extends Component<SliderStyleProps> {
245
250
  if (selectionType === 'invert') return 'crosshair';
246
251
  return 'default';
247
252
  })
248
- .styles(selectionStyle);
253
+ .styles({
254
+ ...selectionStyle,
255
+ transform: `translate(${x}, ${y})`,
256
+ });
249
257
  };
250
258
 
251
259
  const that = this;
@@ -381,8 +389,8 @@ export class Slider extends Component<SliderStyleProps> {
381
389
  private inferTextStyle(handleType: HandleType): Record<string, any> {
382
390
  const { orientation } = this.attributes;
383
391
  if (orientation === 'horizontal') return {};
384
- if (handleType === 'start') return { transform: 'rotate(90)', textAlign: 'start' };
385
- if (handleType === 'end') return { transform: 'rotate(90)', textAlign: 'end' };
392
+ if (handleType === 'start') return { transformOrigin: 'left center', transform: 'rotate(90)', textAlign: 'start' };
393
+ if (handleType === 'end') return { transformOrigin: 'right center', transform: 'rotate(90)', textAlign: 'end' };
386
394
  return {};
387
395
  }
388
396
 
@@ -470,8 +478,8 @@ export class Slider extends Component<SliderStyleProps> {
470
478
  }
471
479
 
472
480
  private getHandleStyle(handleType: HandleType): HandleStyleProps {
473
- const { showLabel, showLabelOnInteraction, orientation } = this.attributes;
474
- const handlePosition = this.calcHandlePosition(handleType);
481
+ const { x: ox, y: oy, showLabel, showLabelOnInteraction, orientation } = this.attributes;
482
+ const { x, y } = this.calcHandlePosition(handleType);
475
483
  const textStyle = this.calcHandleText(handleType);
476
484
 
477
485
  let internalShowLabel = showLabel;
@@ -483,7 +491,7 @@ export class Slider extends Component<SliderStyleProps> {
483
491
  return {
484
492
  ...superStyleProps(this.getHandleIconStyle(), 'icon'),
485
493
  ...superStyleProps({ ...this.getHandleLabelStyle(handleType), ...textStyle }, 'label'),
486
- ...handlePosition,
494
+ transform: `translate(${x + ox}, ${y + oy})`,
487
495
  orientation,
488
496
  showLabel: internalShowLabel,
489
497
  type: handleType,
@@ -21,6 +21,8 @@ export type SliderStyleProps = GroupStyleProps &
21
21
  PrefixObject<RectStyleProps, 'selection'> &
22
22
  HandleStyleProps &
23
23
  Partial<PrefixStyleProps<Omit<SparklineStyleProps, 'width' | 'height'>, 'sparkline'>> & {
24
+ x?: number;
25
+ y?: number;
24
26
  /** 动画配置 */
25
27
  animate?: GenericAnimation;
26
28
 
@@ -5,6 +5,8 @@ import { deepAssign, select } from '../../util';
5
5
  export type ColumnStyleProps = GroupStyleProps;
6
6
 
7
7
  export interface ColumnsStyleProps extends BaseStyleProps {
8
+ x?: number;
9
+ y?: number;
8
10
  columns: ColumnStyleProps[][];
9
11
  }
10
12
 
@@ -19,7 +21,8 @@ export class Columns extends DisplayObject<ColumnsStyleProps> {
19
21
  }
20
22
 
21
23
  public render(): void {
22
- const { columns } = this.attributes;
24
+ const { columns, x, y } = this.attributes;
25
+ this.columnsGroup.style.transform = `translate(${x}, ${y})`;
23
26
 
24
27
  select(this.columnsGroup)
25
28
  .selectAll('.column')
@@ -90,13 +90,13 @@ export class Sparkline extends Component<SparklineStyleProps> {
90
90
  lines: lines.map((line, idx) => {
91
91
  return {
92
92
  stroke: this.getColor(idx),
93
- path: smooth ? lineToCurvePath(line) : lineToLinePath(line),
93
+ d: smooth ? lineToCurvePath(line) : lineToLinePath(line),
94
94
  ...lineStyle,
95
95
  };
96
96
  }) as any,
97
97
  areas: areas.map((path, idx) => {
98
98
  return {
99
- path,
99
+ d: path,
100
100
  fill: this.getColor(idx),
101
101
  ...areaStyle,
102
102
  };
@@ -155,6 +155,8 @@ export class Sparkline extends Component<SparklineStyleProps> {
155
155
  constructor(options: SparklineOptions) {
156
156
  super(options, {
157
157
  type: 'line',
158
+ x: 0,
159
+ y: 0,
158
160
  width: 200,
159
161
  height: 20,
160
162
  isStack: false,
@@ -173,9 +175,13 @@ export class Sparkline extends Component<SparklineStyleProps> {
173
175
  public render(attributes: Required<SparklineStyleProps>, container: Group) {
174
176
  maybeAppend(container, '.container', 'rect').attr('className', 'container').node();
175
177
 
176
- const { type } = attributes;
178
+ const { type, x, y } = attributes;
177
179
  const className = `spark${type}`;
178
- const style: any = type === 'line' ? this.linesStyle : this.columnsStyle;
180
+ const style: any = {
181
+ x,
182
+ y,
183
+ ...(type === 'line' ? this.linesStyle : this.columnsStyle),
184
+ };
179
185
 
180
186
  select(container)
181
187
  .selectAll('.spark')
@@ -4,6 +4,8 @@ import { DisplayObject, Group } from '../../shapes';
4
4
  import { deepAssign, select } from '../../util';
5
5
 
6
6
  export interface LinesStyleProps extends BaseStyleProps {
7
+ x?: number;
8
+ y?: number;
7
9
  lines: PathStyleProps[];
8
10
  areas: PathStyleProps[];
9
11
  }
@@ -19,7 +21,8 @@ export class Lines extends DisplayObject<LinesStyleProps> {
19
21
  }
20
22
 
21
23
  public render(): void {
22
- const { lines, areas } = this.attributes;
24
+ const { lines, areas, x, y } = this.attributes;
25
+ this.style.transform = `translate(${x}, ${y})`;
23
26
  if (lines) this.renderLines(lines);
24
27
  if (areas) this.renderAreas(areas);
25
28
  }
@@ -31,6 +31,8 @@ type ColumnStyleProps = CallableObject<PrefixObject<RectStyleProps, 'column'>, C
31
31
  export type SparklineStyleProps = GroupStyleProps &
32
32
  LineStyleProps &
33
33
  ColumnStyleProps & {
34
+ x?: number;
35
+ y?: number;
34
36
  color?: string | string[] | ((idx: number) => string);
35
37
  data?: number[] | number[][];
36
38
  isStack?: boolean;
@@ -92,6 +92,7 @@ export class Switch extends Component<SwitchStyleProps> {
92
92
  });
93
93
 
94
94
  // 增加 整体宽度 需要对 tag 提前渲染获得 width 然后通过 width 计算 x 的位置
95
+ // @ts-ignore
95
96
  const { max, min } = tagShape?.getLocalBounds() || {};
96
97
  const width = max[0] - min[0] + sizeStyle.radius;
97
98
  const height = max[1] - min[1];
@@ -3,6 +3,8 @@ import type { ComponentOptions } from '../../core';
3
3
  import type { TagStyleProps } from '../tag';
4
4
 
5
5
  export type SwitchStyleProps = GroupStyleProps & {
6
+ x?: number;
7
+ y?: number;
6
8
  /**
7
9
  * @title 大小
8
10
  * @description switch 开关组件大小。默认为: default, 高度大小等于 22px,宽度默认等于高度的两倍,会随着内部的子元素大小自动调整。
@@ -23,6 +23,7 @@ function adjust(container: Group, paddingLeft: number, paddingTop: number, align
23
23
  }
24
24
 
25
25
  function getTextPosition(markerShape: Marker, spacing?: number) {
26
+ // @ts-ignore
26
27
  const bounds = markerShape.getLocalBounds();
27
28
 
28
29
  return {
@@ -60,15 +61,10 @@ export class Tag extends Component<TagStyleProps> {
60
61
  .style('zIndex', 0)
61
62
  .node();
62
63
  const markerStyle = marker || { symbol: 'triangle', size: 0 };
63
- // @ts-ignore
64
64
  const markerShape = maybeAppend(group, '.tag-marker', () => new Marker({ style: markerStyle }))
65
65
  .attr('className', 'tag-marker')
66
- .call((selection) => {
67
- (selection.node() as Marker).clear();
68
- })
69
66
  .update(markerStyle)
70
67
  .node() as Marker;
71
-
72
68
  const { x, y } = getTextPosition(markerShape, spacing);
73
69
 
74
70
  select(group)
@@ -6,6 +6,8 @@ import type { MarkerStyleProps } from '../marker';
6
6
  export type TagStyleProps = GroupStyleProps &
7
7
  PrefixStyleProps<Omit<TextStyleProps, 'x' | 'y' | 'text'>, 'label'> &
8
8
  PrefixStyleProps<Partial<RectStyleProps>, 'background'> & {
9
+ x?: number;
10
+ y?: number;
9
11
  text?: string;
10
12
  /** 水平对齐方式 */
11
13
  align?: 'start' | 'center' | 'end';
@@ -19,6 +19,8 @@ const componentsMap: Record<Functions | 'split', { new (...args: any): DisplayOb
19
19
  export class Controller extends Component<ControllerStyleProps> {
20
20
  static defaultOptions: ControllerOptions = {
21
21
  style: {
22
+ x: 0,
23
+ y: 0,
22
24
  width: 300,
23
25
  height: 40,
24
26
  padding: 0,
@@ -50,13 +52,13 @@ export class Controller extends Component<ControllerStyleProps> {
50
52
  }
51
53
 
52
54
  private renderBackground() {
53
- const { width, height } = this.style;
55
+ const { x, y, width, height } = this.style;
54
56
  const backgroundStyle = subStyleProps(this.attributes, 'background');
55
- this.background.attr({ width, height, ...backgroundStyle });
57
+ this.background.attr({ x, y, width, height, ...backgroundStyle });
56
58
  }
57
59
 
58
60
  private renderFunctions() {
59
- const { functions, iconSize, iconSpacing, width, height, align } = this.attributes;
61
+ const { functions, iconSize, iconSpacing, x, y, width, height, align } = this.attributes;
60
62
 
61
63
  const {
62
64
  padding: [, right, , left],
@@ -85,8 +87,8 @@ export class Controller extends Component<ControllerStyleProps> {
85
87
  components.forEach((name, index) => {
86
88
  const Ctor = componentsMap[name];
87
89
  const style: Record<string, any> = {
88
- x: index * (iconSize + iconSpacing) + xOffset,
89
- y: height / 2,
90
+ x: x + index * (iconSize + iconSpacing) + xOffset,
91
+ y: y + height / 2,
90
92
  size: iconSize,
91
93
  };
92
94
 
@@ -105,11 +107,9 @@ export class Controller extends Component<ControllerStyleProps> {
105
107
 
106
108
  if (Ctor === SpeedSelect) {
107
109
  // SpeedSelect 直接插入到 canvas
108
- const { x: baseX, y: baseY } = this.getBBox();
109
- const { x, y } = style;
110
110
  const canvas = this.ownerDocument?.defaultView;
111
111
  if (canvas) {
112
- this.speedSelect = new Ctor({ style: { ...style, zIndex: 100, x: baseX + x, y: baseY + y } }) as SpeedSelect;
112
+ this.speedSelect = new Ctor({ style: { ...style, zIndex: 100 } }) as SpeedSelect;
113
113
  (canvas as unknown as Canvas).appendChild(this.speedSelect);
114
114
  }
115
115
  } else {
@@ -40,6 +40,10 @@ type ChartModeHandleStyleProps = GroupStyleProps &
40
40
  PrefixObject<Omit<RectStyleProps, 'x' | 'y' | 'width' | 'height'>, 'background'> &
41
41
  PrefixObject<Omit<LineStyleProps, 'x1' | 'y1' | 'x2' | 'y2'>, 'icon'> &
42
42
  PrefixObject<Omit<LineStyleProps, 'x1' | 'y1' | 'x2' | 'y2'>, 'border'> & {
43
+ x?: number;
44
+ y?: number;
45
+ width?: number;
46
+ height?: number;
43
47
  /** 图标尺寸 */
44
48
  iconSize?: number;
45
49
  type: HandleType;
@@ -48,6 +52,8 @@ type ChartModeHandleOptions = ComponentOptions<ChartModeHandleStyleProps>;
48
52
  export class ChartModeHandle extends Component<ChartModeHandleStyleProps> {
49
53
  static defaultOptions: ChartModeHandleOptions = {
50
54
  style: {
55
+ x: 0,
56
+ y: 0,
51
57
  width: 10,
52
58
  height: 50,
53
59
  iconSize: 10,
@@ -62,41 +68,41 @@ export class ChartModeHandle extends Component<ChartModeHandleStyleProps> {
62
68
  };
63
69
 
64
70
  private renderBackground() {
65
- const { width, height } = this.attributes;
71
+ const { x, y, width, height } = this.attributes;
66
72
  const style = subStyleProps(this.attributes, 'background');
67
73
  select(this)
68
74
  .maybeAppend('background', 'rect')
69
75
  .attr('className', 'background')
70
- .styles({ x: -width / 2, y: -height / 2, width, height, ...style });
76
+ .styles({ x: x - width / 2, y: y - height / 2, width, height, ...style });
71
77
  }
72
78
 
73
79
  private renderIcon() {
74
- const { iconSize } = this.attributes;
80
+ const { x, y, iconSize } = this.attributes;
75
81
  const style = subStyleProps(this.attributes, 'icon');
76
82
  const diffX = 1;
77
83
  const diffY = iconSize / 2;
78
84
  select(this)
79
85
  .maybeAppend('icon-left-line', 'line')
80
86
  .attr('className', 'icon-left-line')
81
- .styles({ x1: -diffX, y1: -diffY, x2: -diffX, y2: diffY, ...style });
87
+ .styles({ x1: x - diffX, y1: y - diffY, x2: x - diffX, y2: y + diffY, ...style });
82
88
  select(this)
83
89
  .maybeAppend('icon-right-line', 'line')
84
90
  .attr('className', 'icon-right-line')
85
- .styles({ x1: diffX, y1: -diffY, x2: diffX, y2: diffY, ...style });
91
+ .styles({ x1: x + diffX, y1: y - diffY, x2: x + diffX, y2: y + diffY, ...style });
86
92
  }
87
93
 
88
94
  private renderBorder() {
89
- const { width, height, type } = this.attributes;
95
+ const { x: xx, y, width, height, type } = this.attributes;
90
96
  const style = subStyleProps(this.attributes, 'border');
91
97
  const x = type === 'start' ? +width / 2 : -width / 2;
92
98
  select(this)
93
99
  .maybeAppend('border', 'line')
94
100
  .attr('className', 'border')
95
101
  .styles({
96
- x1: x,
97
- y1: -height / 2,
98
- x2: x,
99
- y2: +height / 2,
102
+ x1: x + xx,
103
+ y1: y - height / 2,
104
+ x2: x + xx,
105
+ y2: y + height / 2,
100
106
  ...style,
101
107
  });
102
108
  }