@antv/component 1.0.1-beta.1 → 1.0.1-beta.2

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 (247) 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 +14 -10
  6. package/esm/animation/utils.js.map +1 -1
  7. package/esm/ui/axis/constant.js +1 -0
  8. package/esm/ui/axis/constant.js.map +1 -1
  9. package/esm/ui/axis/guides/labels.js +9 -11
  10. package/esm/ui/axis/guides/labels.js.map +1 -1
  11. package/esm/ui/axis/guides/ticks.js +1 -1
  12. package/esm/ui/axis/guides/ticks.js.map +1 -1
  13. package/esm/ui/axis/guides/title.js +9 -6
  14. package/esm/ui/axis/guides/title.js.map +1 -1
  15. package/esm/ui/axis/overlap/autoEllipsis.js +2 -1
  16. package/esm/ui/axis/overlap/autoEllipsis.js.map +1 -1
  17. package/esm/ui/axis/overlap/autoHide.js +2 -1
  18. package/esm/ui/axis/overlap/autoHide.js.map +1 -1
  19. package/esm/ui/axis/utils/bounds.d.ts +1 -3
  20. package/esm/ui/axis/utils/bounds.js +7 -4
  21. package/esm/ui/axis/utils/bounds.js.map +1 -1
  22. package/esm/ui/breadcrumb/index.js +2 -2
  23. package/esm/ui/breadcrumb/index.js.map +1 -1
  24. package/esm/ui/button/index.js +6 -8
  25. package/esm/ui/button/index.js.map +1 -1
  26. package/esm/ui/button/types.d.ts +0 -2
  27. package/esm/ui/checkbox/constant.d.ts +2 -2
  28. package/esm/ui/checkbox/index.js +1 -1
  29. package/esm/ui/checkbox/index.js.map +1 -1
  30. package/esm/ui/indicator/indicator.js +1 -2
  31. package/esm/ui/indicator/indicator.js.map +1 -1
  32. package/esm/ui/indicator/types.d.ts +0 -2
  33. package/esm/ui/layout/layout.js +1 -3
  34. package/esm/ui/layout/layout.js.map +1 -1
  35. package/esm/ui/layout/types.d.ts +0 -2
  36. package/esm/ui/legend/category/item.d.ts +0 -2
  37. package/esm/ui/legend/category/item.js +4 -10
  38. package/esm/ui/legend/category/item.js.map +1 -1
  39. package/esm/ui/legend/category/items.d.ts +0 -2
  40. package/esm/ui/legend/category/items.js.map +1 -1
  41. package/esm/ui/legend/category.js +2 -4
  42. package/esm/ui/legend/category.js.map +1 -1
  43. package/esm/ui/legend/continuous.d.ts +1 -0
  44. package/esm/ui/legend/continuous.js +17 -5
  45. package/esm/ui/legend/continuous.js.map +1 -1
  46. package/esm/ui/marker/index.js +4 -4
  47. package/esm/ui/marker/index.js.map +1 -1
  48. package/esm/ui/marker/types.d.ts +0 -2
  49. package/esm/ui/navigator/index.js +0 -5
  50. package/esm/ui/navigator/index.js.map +1 -1
  51. package/esm/ui/navigator/types.d.ts +0 -2
  52. package/esm/ui/scrollbar/index.js +2 -4
  53. package/esm/ui/scrollbar/index.js.map +1 -1
  54. package/esm/ui/scrollbar/types.d.ts +0 -2
  55. package/esm/ui/select/option.js +1 -1
  56. package/esm/ui/select/option.js.map +1 -1
  57. package/esm/ui/select/select.js +9 -11
  58. package/esm/ui/select/select.js.map +1 -1
  59. package/esm/ui/select/types.d.ts +0 -4
  60. package/esm/ui/slider/constant.d.ts +0 -2
  61. package/esm/ui/slider/constant.js +0 -2
  62. package/esm/ui/slider/constant.js.map +1 -1
  63. package/esm/ui/slider/handle.d.ts +0 -4
  64. package/esm/ui/slider/handle.js +17 -14
  65. package/esm/ui/slider/handle.js.map +1 -1
  66. package/esm/ui/slider/index.js +16 -17
  67. package/esm/ui/slider/index.js.map +1 -1
  68. package/esm/ui/slider/types.d.ts +0 -2
  69. package/esm/ui/sparkline/columns.d.ts +0 -2
  70. package/esm/ui/sparkline/columns.js +1 -2
  71. package/esm/ui/sparkline/columns.js.map +1 -1
  72. package/esm/ui/sparkline/index.js +2 -4
  73. package/esm/ui/sparkline/index.js.map +1 -1
  74. package/esm/ui/sparkline/lines.d.ts +0 -2
  75. package/esm/ui/sparkline/lines.js +1 -2
  76. package/esm/ui/sparkline/lines.js.map +1 -1
  77. package/esm/ui/sparkline/types.d.ts +0 -2
  78. package/esm/ui/switch/index.js +0 -1
  79. package/esm/ui/switch/index.js.map +1 -1
  80. package/esm/ui/switch/types.d.ts +0 -2
  81. package/esm/ui/tag/index.js +0 -1
  82. package/esm/ui/tag/index.js.map +1 -1
  83. package/esm/ui/tag/types.d.ts +0 -2
  84. package/esm/ui/timebar/controller.js +8 -8
  85. package/esm/ui/timebar/controller.js.map +1 -1
  86. package/esm/ui/timebar/handle.d.ts +0 -4
  87. package/esm/ui/timebar/handle.js +7 -9
  88. package/esm/ui/timebar/handle.js.map +1 -1
  89. package/esm/ui/timebar/icons.js +90 -103
  90. package/esm/ui/timebar/icons.js.map +1 -1
  91. package/esm/ui/timebar/timebar.js +6 -14
  92. package/esm/ui/timebar/timebar.js.map +1 -1
  93. package/esm/ui/timebar/types.d.ts +0 -4
  94. package/esm/ui/tooltip/types.d.ts +0 -2
  95. package/esm/util/keyframe-interpolate.d.ts +1 -1
  96. package/esm/util/primitive.js +3 -0
  97. package/esm/util/primitive.js.map +1 -1
  98. package/esm/util/scale-to-pixel.js +2 -3
  99. package/esm/util/scale-to-pixel.js.map +1 -1
  100. package/lib/animation/fadeIn.d.ts +1 -1
  101. package/lib/animation/fadeOut.d.ts +1 -1
  102. package/lib/animation/utils.d.ts +3 -3
  103. package/lib/animation/utils.js +14 -10
  104. package/lib/animation/utils.js.map +1 -1
  105. package/lib/ui/axis/constant.js +1 -0
  106. package/lib/ui/axis/constant.js.map +1 -1
  107. package/lib/ui/axis/guides/labels.js +9 -11
  108. package/lib/ui/axis/guides/labels.js.map +1 -1
  109. package/lib/ui/axis/guides/ticks.js +1 -1
  110. package/lib/ui/axis/guides/ticks.js.map +1 -1
  111. package/lib/ui/axis/guides/title.js +8 -5
  112. package/lib/ui/axis/guides/title.js.map +1 -1
  113. package/lib/ui/axis/overlap/autoEllipsis.js +2 -1
  114. package/lib/ui/axis/overlap/autoEllipsis.js.map +1 -1
  115. package/lib/ui/axis/overlap/autoHide.js +2 -1
  116. package/lib/ui/axis/overlap/autoHide.js.map +1 -1
  117. package/lib/ui/axis/utils/bounds.d.ts +1 -3
  118. package/lib/ui/axis/utils/bounds.js +9 -5
  119. package/lib/ui/axis/utils/bounds.js.map +1 -1
  120. package/lib/ui/breadcrumb/index.js +2 -2
  121. package/lib/ui/breadcrumb/index.js.map +1 -1
  122. package/lib/ui/button/index.js +6 -8
  123. package/lib/ui/button/index.js.map +1 -1
  124. package/lib/ui/button/types.d.ts +0 -2
  125. package/lib/ui/checkbox/constant.d.ts +2 -2
  126. package/lib/ui/checkbox/index.js +1 -1
  127. package/lib/ui/checkbox/index.js.map +1 -1
  128. package/lib/ui/indicator/indicator.js +1 -2
  129. package/lib/ui/indicator/indicator.js.map +1 -1
  130. package/lib/ui/indicator/types.d.ts +0 -2
  131. package/lib/ui/layout/layout.js +1 -3
  132. package/lib/ui/layout/layout.js.map +1 -1
  133. package/lib/ui/layout/types.d.ts +0 -2
  134. package/lib/ui/legend/category/item.d.ts +0 -2
  135. package/lib/ui/legend/category/item.js +4 -10
  136. package/lib/ui/legend/category/item.js.map +1 -1
  137. package/lib/ui/legend/category/items.d.ts +0 -2
  138. package/lib/ui/legend/category/items.js.map +1 -1
  139. package/lib/ui/legend/category.js +2 -4
  140. package/lib/ui/legend/category.js.map +1 -1
  141. package/lib/ui/legend/continuous.d.ts +1 -0
  142. package/lib/ui/legend/continuous.js +17 -5
  143. package/lib/ui/legend/continuous.js.map +1 -1
  144. package/lib/ui/marker/index.js +4 -4
  145. package/lib/ui/marker/index.js.map +1 -1
  146. package/lib/ui/marker/types.d.ts +0 -2
  147. package/lib/ui/navigator/index.js +0 -5
  148. package/lib/ui/navigator/index.js.map +1 -1
  149. package/lib/ui/navigator/types.d.ts +0 -2
  150. package/lib/ui/scrollbar/index.js +2 -4
  151. package/lib/ui/scrollbar/index.js.map +1 -1
  152. package/lib/ui/scrollbar/types.d.ts +0 -2
  153. package/lib/ui/select/option.js +1 -1
  154. package/lib/ui/select/option.js.map +1 -1
  155. package/lib/ui/select/select.js +9 -11
  156. package/lib/ui/select/select.js.map +1 -1
  157. package/lib/ui/select/types.d.ts +0 -4
  158. package/lib/ui/slider/constant.d.ts +0 -2
  159. package/lib/ui/slider/constant.js +0 -2
  160. package/lib/ui/slider/constant.js.map +1 -1
  161. package/lib/ui/slider/handle.d.ts +0 -4
  162. package/lib/ui/slider/handle.js +17 -14
  163. package/lib/ui/slider/handle.js.map +1 -1
  164. package/lib/ui/slider/index.js +16 -17
  165. package/lib/ui/slider/index.js.map +1 -1
  166. package/lib/ui/slider/types.d.ts +0 -2
  167. package/lib/ui/sparkline/columns.d.ts +0 -2
  168. package/lib/ui/sparkline/columns.js +1 -2
  169. package/lib/ui/sparkline/columns.js.map +1 -1
  170. package/lib/ui/sparkline/index.js +2 -4
  171. package/lib/ui/sparkline/index.js.map +1 -1
  172. package/lib/ui/sparkline/lines.d.ts +0 -2
  173. package/lib/ui/sparkline/lines.js +1 -2
  174. package/lib/ui/sparkline/lines.js.map +1 -1
  175. package/lib/ui/sparkline/types.d.ts +0 -2
  176. package/lib/ui/switch/index.js +0 -1
  177. package/lib/ui/switch/index.js.map +1 -1
  178. package/lib/ui/switch/types.d.ts +0 -2
  179. package/lib/ui/tag/index.js +0 -1
  180. package/lib/ui/tag/index.js.map +1 -1
  181. package/lib/ui/tag/types.d.ts +0 -2
  182. package/lib/ui/timebar/controller.js +8 -8
  183. package/lib/ui/timebar/controller.js.map +1 -1
  184. package/lib/ui/timebar/handle.d.ts +0 -4
  185. package/lib/ui/timebar/handle.js +7 -9
  186. package/lib/ui/timebar/handle.js.map +1 -1
  187. package/lib/ui/timebar/icons.js +90 -103
  188. package/lib/ui/timebar/icons.js.map +1 -1
  189. package/lib/ui/timebar/timebar.js +6 -14
  190. package/lib/ui/timebar/timebar.js.map +1 -1
  191. package/lib/ui/timebar/types.d.ts +0 -4
  192. package/lib/ui/tooltip/types.d.ts +0 -2
  193. package/lib/util/keyframe-interpolate.d.ts +1 -1
  194. package/lib/util/primitive.js +3 -0
  195. package/lib/util/primitive.js.map +1 -1
  196. package/lib/util/scale-to-pixel.js +2 -3
  197. package/lib/util/scale-to-pixel.js.map +1 -1
  198. package/package.json +6 -6
  199. package/src/animation/utils.ts +15 -16
  200. package/src/ui/axis/constant.ts +1 -0
  201. package/src/ui/axis/guides/labels.ts +10 -18
  202. package/src/ui/axis/guides/ticks.ts +1 -1
  203. package/src/ui/axis/guides/title.ts +9 -9
  204. package/src/ui/axis/overlap/autoEllipsis.ts +2 -1
  205. package/src/ui/axis/overlap/autoHide.ts +2 -1
  206. package/src/ui/axis/utils/bounds.ts +7 -4
  207. package/src/ui/breadcrumb/index.ts +3 -2
  208. package/src/ui/button/index.ts +6 -10
  209. package/src/ui/button/types.ts +0 -2
  210. package/src/ui/checkbox/index.ts +2 -0
  211. package/src/ui/indicator/indicator.ts +1 -2
  212. package/src/ui/indicator/types.ts +0 -2
  213. package/src/ui/layout/layout.ts +1 -4
  214. package/src/ui/layout/types.ts +0 -2
  215. package/src/ui/legend/category/item.ts +4 -14
  216. package/src/ui/legend/category/items.ts +0 -2
  217. package/src/ui/legend/category.ts +2 -4
  218. package/src/ui/legend/continuous.ts +20 -5
  219. package/src/ui/marker/index.ts +4 -5
  220. package/src/ui/marker/types.ts +0 -2
  221. package/src/ui/navigator/index.ts +0 -7
  222. package/src/ui/navigator/types.ts +0 -2
  223. package/src/ui/scrollbar/index.ts +1 -5
  224. package/src/ui/scrollbar/types.ts +0 -2
  225. package/src/ui/select/option.ts +1 -1
  226. package/src/ui/select/select.ts +9 -11
  227. package/src/ui/select/types.ts +0 -4
  228. package/src/ui/slider/constant.ts +0 -2
  229. package/src/ui/slider/handle.ts +14 -26
  230. package/src/ui/slider/index.ts +12 -20
  231. package/src/ui/slider/types.ts +0 -2
  232. package/src/ui/sparkline/columns.ts +1 -4
  233. package/src/ui/sparkline/index.ts +2 -8
  234. package/src/ui/sparkline/lines.ts +1 -4
  235. package/src/ui/sparkline/types.ts +0 -2
  236. package/src/ui/switch/index.ts +0 -1
  237. package/src/ui/switch/types.ts +0 -2
  238. package/src/ui/tag/index.ts +0 -1
  239. package/src/ui/tag/types.ts +0 -2
  240. package/src/ui/timebar/controller.ts +8 -8
  241. package/src/ui/timebar/handle.ts +10 -16
  242. package/src/ui/timebar/icons.ts +86 -93
  243. package/src/ui/timebar/timebar.ts +9 -13
  244. package/src/ui/timebar/types.ts +0 -4
  245. package/src/ui/tooltip/types.ts +0 -2
  246. package/src/util/primitive.ts +3 -0
  247. package/src/util/scale-to-pixel.ts +1 -3
@@ -41,8 +41,6 @@ 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,
46
44
  animate: {
47
45
  easing: 'linear',
48
46
  duration: 200,
@@ -307,8 +305,6 @@ export class Navigator extends Component<NavigatorStyleProps> {
307
305
 
308
306
  this.updatePageInfo();
309
307
 
310
- // group.node().style.transform = `translate(${pageWidth + spacing}, ${pageHeight / 2})`;
311
-
312
308
  // put it on the right side of the container
313
309
  group.node().setLocalPosition(pageWidth + spacing, pageHeight / 2);
314
310
  if (whetherToAddEventListener) {
@@ -322,9 +318,6 @@ export class Navigator extends Component<NavigatorStyleProps> {
322
318
  }
323
319
 
324
320
  render(attributes: NavigatorStyleProps, container: Group) {
325
- const { x = 0, y = 0 } = attributes;
326
- this.attr('transform', `translate(${x}, ${y})`);
327
-
328
321
  /**
329
322
  * container
330
323
  * |- contentGroup (with clip path)
@@ -6,8 +6,6 @@ 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;
11
9
  animate?: GenericAnimation;
12
10
  /** padding between buttons and page number */
13
11
  controllerPadding?: number;
@@ -23,8 +23,6 @@ export class Scrollbar extends Component<ScrollbarStyleProps> {
23
23
 
24
24
  constructor(options: ScrollbarOptions) {
25
25
  super(options, {
26
- x: 0,
27
- y: 0,
28
26
  isRound: true,
29
27
  orientation: 'vertical',
30
28
  padding: [2, 2, 2, 2],
@@ -92,13 +90,11 @@ export class Scrollbar extends Component<ScrollbarStyleProps> {
92
90
  }
93
91
 
94
92
  private renderSlider(container: Group) {
95
- const { x, y, orientation, trackSize, padding, slidable } = this.attributes;
93
+ const { orientation, trackSize, padding, slidable } = this.attributes;
96
94
  const trackStyle = subStyleProps<RectStyleProps>(this.attributes, 'track');
97
95
  const selectionStyle = subStyleProps<RectStyleProps>(this.attributes, 'thumb');
98
96
 
99
97
  const style: SliderStyleProps = {
100
- x,
101
- y,
102
98
  brushable: false,
103
99
  orientation,
104
100
  padding,
@@ -8,8 +8,6 @@ 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;
13
11
  /** 滑条朝向 */
14
12
  orientation?: Required<SliderStyleProps>['orientation'];
15
13
 
@@ -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({ transform: `translate(${left}, ${(backgroundHeight - labelHeight) / 2})` });
55
+ this.label.attr({ x: left, y: (backgroundHeight - labelHeight) / 2 });
56
56
  }
57
57
 
58
58
  constructor(options: OptionOptions) {
@@ -9,8 +9,6 @@ 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,
14
12
  width: 140,
15
13
  height: 32,
16
14
  options: [],
@@ -76,10 +74,10 @@ export class Select extends Component<SelectStyleProps> {
76
74
  );
77
75
 
78
76
  private renderSelect() {
79
- const { x, y, width, height, bordered, showDropdownIcon } = this.style;
77
+ const { width, height, bordered, showDropdownIcon } = this.style;
80
78
  const selectStyle = subStyleProps(this.attributes, 'select');
81
79
  const placeholderStyle = subStyleProps(this.attributes, 'placeholder');
82
- this.select.attr({ x, y, width, height, ...selectStyle, fill: '#fff', strokeWidth: bordered ? 1 : 0 });
80
+ this.select.attr({ width, height, ...selectStyle, fill: '#fff', strokeWidth: bordered ? 1 : 0 });
83
81
  const padding = this.dropdownPadding;
84
82
  // dropdown icon
85
83
  const iconSize = 10;
@@ -87,7 +85,7 @@ export class Select extends Component<SelectStyleProps> {
87
85
  select(this.select)
88
86
  .maybeAppend('.dropdown-icon', 'path')
89
87
  .style('d', 'M-5,-3.5 L0,3.5 L5,-3.5')
90
- .style('transform', `translate(${x + width - iconSize - padding[1] - padding[3]}, ${y + height / 2})`)
88
+ .style('transform', `translate(${width - iconSize - padding[1] - padding[3]}, ${height / 2})`)
91
89
  .style('lineWidth', 1)
92
90
  .style('stroke', this.select.style.stroke);
93
91
  }
@@ -95,7 +93,7 @@ export class Select extends Component<SelectStyleProps> {
95
93
  const currentOption = this.style.options?.find((option) => option.value === this.currentValue);
96
94
  // placeholder
97
95
  const finalPlaceholderStyle = {
98
- x: x + padding[3],
96
+ x: padding[3],
99
97
  ...placeholderStyle,
100
98
  };
101
99
  select(this.select)
@@ -109,7 +107,7 @@ export class Select extends Component<SelectStyleProps> {
109
107
  .styles(finalPlaceholderStyle)
110
108
  .style('y', function () {
111
109
  const bbox = this.getBBox();
112
- return y + (height - bbox.height) / 2;
110
+ return (height - bbox.height) / 2;
113
111
  }),
114
112
  (update) => update.styles(finalPlaceholderStyle),
115
113
  (exit) => exit.remove()
@@ -118,7 +116,7 @@ export class Select extends Component<SelectStyleProps> {
118
116
  // value
119
117
  const labelStyle = subStyleProps(this.attributes, 'optionLabel');
120
118
  const finalValueStyle = {
121
- x: x + padding[3],
119
+ x: padding[3],
122
120
  ...labelStyle,
123
121
  };
124
122
 
@@ -133,7 +131,7 @@ export class Select extends Component<SelectStyleProps> {
133
131
  .styles(finalValueStyle)
134
132
  .style('y', function () {
135
133
  const bbox = this.getBBox();
136
- return y + (height - bbox.height) / 2;
134
+ return (height - bbox.height) / 2;
137
135
  }),
138
136
  (update) => update.styles(finalValueStyle),
139
137
  (exit) => exit.remove()
@@ -141,7 +139,7 @@ export class Select extends Component<SelectStyleProps> {
141
139
  }
142
140
 
143
141
  private renderDropdown() {
144
- const { x, y, width, height, options, onSelect, open } = this.style;
142
+ const { width, height, options, onSelect, open } = this.style;
145
143
  const dropdownStyle = subStyleProps(this.attributes, 'dropdown');
146
144
  const optionStyle = subStyleProps(this.attributes, 'option');
147
145
  const padding = this.dropdownPadding;
@@ -195,7 +193,7 @@ export class Select extends Component<SelectStyleProps> {
195
193
  const { spacing } = dropdownStyle;
196
194
 
197
195
  this.dropdown.attr({
198
- transform: `translate(${x}, ${y + height + spacing})`,
196
+ y: height + spacing,
199
197
  width: bbox.width + padding[1] + padding[3],
200
198
  height: bbox.height + padding[0] + padding[2],
201
199
  ...dropdownStyle,
@@ -28,10 +28,6 @@ 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;
35
31
  /** 宽度 */
36
32
  width?: number;
37
33
  /** 高度 */
@@ -20,8 +20,6 @@ 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,
25
23
  orientation: 'horizontal',
26
24
  showLabel: true,
27
25
  type: 'start',
@@ -8,8 +8,6 @@ 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;
13
11
  size?: number;
14
12
  radius?: number;
15
13
  shape?: string | ((type: HandleType) => DisplayObject);
@@ -21,8 +19,6 @@ export type LabelStyleProps = Partial<TextStyleProps>;
21
19
  export type HandleStyleProps = GroupStyleProps &
22
20
  PrefixStyleProps<LabelStyleProps, 'label'> &
23
21
  PrefixStyleProps<IconStyleProps, 'icon'> & {
24
- x?: number;
25
- y?: number;
26
22
  orientation?: IconStyleProps['orientation'];
27
23
  showLabel?: boolean;
28
24
  spacing?: number;
@@ -45,7 +41,7 @@ const CLASS_NAMES = classNames(
45
41
 
46
42
  class HandleIcon extends Component<IconStyleProps> {
47
43
  render(attributes: Required<IconStyleProps>, container: DisplayObject) {
48
- const { x, y, size = 10, radius = size / 4, orientation, ...iconStyle } = attributes;
44
+ const { size = 10, radius = size / 4, orientation, ...iconStyle } = attributes;
49
45
  // 默认手柄
50
46
  const width = size!;
51
47
  const height = width * 2.4;
@@ -57,20 +53,21 @@ class HandleIcon extends Component<IconStyleProps> {
57
53
  width,
58
54
  height,
59
55
  radius,
60
- x: x - width / 2,
61
- y: y - height / 2,
62
- transformOrigin: 'center',
56
+ x: -width / 2,
57
+ y: -height / 2,
63
58
  });
64
59
 
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;
60
+ const x1 = (1 / 3) * width;
61
+ const x2 = (2 / 3) * width;
62
+ const y1 = (1 / 4) * height;
63
+ const y2 = (3 / 4) * height;
69
64
 
70
65
  rect.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-1`, 'line').styles({ x1, x2: x1, y1, y2, ...iconStyle });
71
66
  rect.maybeAppendByClassName(`${CLASS_NAMES.iconLine}-2`, 'line').styles({ x1: x2, x2, y1, y2, ...iconStyle });
72
67
 
73
- if (orientation === 'vertical') rect.node().style.transform = 'rotate(90)';
68
+ rect.node().setOrigin(width / 2, height / 2);
69
+ if (orientation === 'vertical') container.setLocalEulerAngles(90);
70
+ else container.setLocalEulerAngles(0);
74
71
  }
75
72
  }
76
73
 
@@ -84,14 +81,8 @@ export class Handle extends Component<HandleStyleProps> {
84
81
  }
85
82
 
86
83
  private renderLabel(container: Group) {
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');
84
+ const { showLabel } = this.attributes;
85
+ const { transform, ...style } = subStyleProps(this.attributes, 'label');
95
86
  const [labelStyle, groupStyle] = splitStyle(style, []);
96
87
 
97
88
  const labelGroup = select(container).maybeAppendByClassName(CLASS_NAMES.labelGroup, 'g').styles(groupStyle);
@@ -101,10 +92,7 @@ export class Handle extends Component<HandleStyleProps> {
101
92
  ifShow(!!showLabel, labelGroup, (group) => {
102
93
  this.label = group.maybeAppendByClassName(CLASS_NAMES.label, 'text').styles({
103
94
  ...rest,
104
- x: x + labelX,
105
- y: y + labelY,
106
95
  transform,
107
- transformOrigin,
108
96
  text: `${text}`,
109
97
  });
110
98
 
@@ -119,8 +107,8 @@ export class Handle extends Component<HandleStyleProps> {
119
107
  }
120
108
 
121
109
  private renderIcon(container: Group) {
122
- const { x, y, orientation, type } = this.attributes;
123
- const iconStyle = { x, y, orientation, ...HANDLE_ICON_DEFAULT_CFG, ...subStyleProps(this.attributes, 'icon') };
110
+ const { orientation, type } = this.attributes;
111
+ const iconStyle = { orientation, ...HANDLE_ICON_DEFAULT_CFG, ...subStyleProps(this.attributes, 'icon') };
124
112
  const { iconShape = () => new HandleIcon({ style: iconStyle }) } = this.attributes;
125
113
  const iconGroup = select(container).maybeAppendByClassName(CLASS_NAMES.iconGroup, 'g');
126
114
  iconGroup
@@ -83,7 +83,7 @@ export class Slider extends Component<SliderStyleProps> {
83
83
  }
84
84
 
85
85
  private get availableSpace() {
86
- const { x, y, padding } = this.attributes;
86
+ const { padding } = this.attributes;
87
87
  const [top, right, bottom, left] = parseSeriesAttr(padding!);
88
88
  const { width, height } = this.shape;
89
89
  return {
@@ -96,8 +96,6 @@ export class Slider extends Component<SliderStyleProps> {
96
96
 
97
97
  constructor(options: SliderOptions) {
98
98
  super(options, {
99
- x: 0,
100
- y: 0,
101
99
  animate: { duration: 100, fill: 'both' },
102
100
  brushable: true,
103
101
  formatter: (val: any) => val.toString(),
@@ -169,21 +167,18 @@ export class Slider extends Component<SliderStyleProps> {
169
167
  }
170
168
 
171
169
  private renderTrack(container: Group) {
172
- const { x, y } = this.attributes;
173
170
  const style = subStyleProps(this.attributes, 'track');
174
171
 
175
172
  this.trackShape = select(container)
176
173
  .maybeAppendByClassName(CLASS_NAMES.track, 'rect')
177
- .styles({ x, y, ...this.shape, ...style });
174
+ .styles({ ...this.shape, ...style });
178
175
  }
179
176
 
180
177
  private renderBrushArea(container: Group) {
181
- const { x, y, brushable } = this.attributes;
178
+ const { brushable } = this.attributes;
182
179
  this.brushArea = select(container)
183
180
  .maybeAppendByClassName(CLASS_NAMES.brushArea, 'rect')
184
181
  .styles({
185
- x,
186
- y,
187
182
  fill: 'transparent',
188
183
  cursor: brushable ? 'crosshair' : 'default',
189
184
  ...this.shape,
@@ -191,11 +186,11 @@ export class Slider extends Component<SliderStyleProps> {
191
186
  }
192
187
 
193
188
  private renderSparkline(container: Group) {
194
- const { x, y, orientation } = this.attributes;
189
+ const { orientation } = this.attributes;
195
190
  const sparklineGroup = select(container).maybeAppendByClassName(CLASS_NAMES.sparklineGroup, 'g');
196
191
 
197
192
  ifShow(orientation === 'horizontal', sparklineGroup, (group) => {
198
- const style = { ...this.sparklineStyle!, x, y };
193
+ const style = this.sparklineStyle!;
199
194
  group.maybeAppendByClassName(CLASS_NAMES.sparkline, () => new Sparkline({ style })).update(style);
200
195
  });
201
196
  }
@@ -237,7 +232,7 @@ export class Slider extends Component<SliderStyleProps> {
237
232
  }
238
233
 
239
234
  private renderSelection(container: Group) {
240
- const { x, y, type, selectionType } = this.attributes;
235
+ const { type, selectionType } = this.attributes;
241
236
  this.foregroundGroup = select(container).maybeAppendByClassName(CLASS_NAMES.foreground, 'g');
242
237
 
243
238
  // value 类型的 slider 不渲染选区
@@ -250,10 +245,7 @@ export class Slider extends Component<SliderStyleProps> {
250
245
  if (selectionType === 'invert') return 'crosshair';
251
246
  return 'default';
252
247
  })
253
- .styles({
254
- ...selectionStyle,
255
- transform: `translate(${x}, ${y})`,
256
- });
248
+ .styles(selectionStyle);
257
249
  };
258
250
 
259
251
  const that = this;
@@ -389,8 +381,8 @@ export class Slider extends Component<SliderStyleProps> {
389
381
  private inferTextStyle(handleType: HandleType): Record<string, any> {
390
382
  const { orientation } = this.attributes;
391
383
  if (orientation === 'horizontal') return {};
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' };
384
+ if (handleType === 'start') return { transform: 'rotate(90)', textAlign: 'start' };
385
+ if (handleType === 'end') return { transform: 'rotate(90)', textAlign: 'end' };
394
386
  return {};
395
387
  }
396
388
 
@@ -478,8 +470,8 @@ export class Slider extends Component<SliderStyleProps> {
478
470
  }
479
471
 
480
472
  private getHandleStyle(handleType: HandleType): HandleStyleProps {
481
- const { x: ox, y: oy, showLabel, showLabelOnInteraction, orientation } = this.attributes;
482
- const { x, y } = this.calcHandlePosition(handleType);
473
+ const { showLabel, showLabelOnInteraction, orientation } = this.attributes;
474
+ const handlePosition = this.calcHandlePosition(handleType);
483
475
  const textStyle = this.calcHandleText(handleType);
484
476
 
485
477
  let internalShowLabel = showLabel;
@@ -491,7 +483,7 @@ export class Slider extends Component<SliderStyleProps> {
491
483
  return {
492
484
  ...superStyleProps(this.getHandleIconStyle(), 'icon'),
493
485
  ...superStyleProps({ ...this.getHandleLabelStyle(handleType), ...textStyle }, 'label'),
494
- transform: `translate(${x + ox}, ${y + oy})`,
486
+ ...handlePosition,
495
487
  orientation,
496
488
  showLabel: internalShowLabel,
497
489
  type: handleType,
@@ -21,8 +21,6 @@ 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;
26
24
  /** 动画配置 */
27
25
  animate?: GenericAnimation;
28
26
 
@@ -5,8 +5,6 @@ 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;
10
8
  columns: ColumnStyleProps[][];
11
9
  }
12
10
 
@@ -21,8 +19,7 @@ export class Columns extends DisplayObject<ColumnsStyleProps> {
21
19
  }
22
20
 
23
21
  public render(): void {
24
- const { columns, x, y } = this.attributes;
25
- this.columnsGroup.style.transform = `translate(${x}, ${y})`;
22
+ const { columns } = this.attributes;
26
23
 
27
24
  select(this.columnsGroup)
28
25
  .selectAll('.column')
@@ -155,8 +155,6 @@ 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,
160
158
  width: 200,
161
159
  height: 20,
162
160
  isStack: false,
@@ -175,13 +173,9 @@ export class Sparkline extends Component<SparklineStyleProps> {
175
173
  public render(attributes: Required<SparklineStyleProps>, container: Group) {
176
174
  maybeAppend(container, '.container', 'rect').attr('className', 'container').node();
177
175
 
178
- const { type, x, y } = attributes;
176
+ const { type } = attributes;
179
177
  const className = `spark${type}`;
180
- const style: any = {
181
- x,
182
- y,
183
- ...(type === 'line' ? this.linesStyle : this.columnsStyle),
184
- };
178
+ const style: any = type === 'line' ? this.linesStyle : this.columnsStyle;
185
179
 
186
180
  select(container)
187
181
  .selectAll('.spark')
@@ -4,8 +4,6 @@ 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;
9
7
  lines: PathStyleProps[];
10
8
  areas: PathStyleProps[];
11
9
  }
@@ -21,8 +19,7 @@ export class Lines extends DisplayObject<LinesStyleProps> {
21
19
  }
22
20
 
23
21
  public render(): void {
24
- const { lines, areas, x, y } = this.attributes;
25
- this.style.transform = `translate(${x}, ${y})`;
22
+ const { lines, areas } = this.attributes;
26
23
  if (lines) this.renderLines(lines);
27
24
  if (areas) this.renderAreas(areas);
28
25
  }
@@ -31,8 +31,6 @@ 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;
36
34
  color?: string | string[] | ((idx: number) => string);
37
35
  data?: number[] | number[][];
38
36
  isStack?: boolean;
@@ -92,7 +92,6 @@ export class Switch extends Component<SwitchStyleProps> {
92
92
  });
93
93
 
94
94
  // 增加 整体宽度 需要对 tag 提前渲染获得 width 然后通过 width 计算 x 的位置
95
- // @ts-ignore
96
95
  const { max, min } = tagShape?.getLocalBounds() || {};
97
96
  const width = max[0] - min[0] + sizeStyle.radius;
98
97
  const height = max[1] - min[1];
@@ -3,8 +3,6 @@ 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;
8
6
  /**
9
7
  * @title 大小
10
8
  * @description switch 开关组件大小。默认为: default, 高度大小等于 22px,宽度默认等于高度的两倍,会随着内部的子元素大小自动调整。
@@ -23,7 +23,6 @@ function adjust(container: Group, paddingLeft: number, paddingTop: number, align
23
23
  }
24
24
 
25
25
  function getTextPosition(markerShape: Marker, spacing?: number) {
26
- // @ts-ignore
27
26
  const bounds = markerShape.getLocalBounds();
28
27
 
29
28
  return {
@@ -6,8 +6,6 @@ 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;
11
9
  text?: string;
12
10
  /** 水平对齐方式 */
13
11
  align?: 'start' | 'center' | 'end';
@@ -19,8 +19,6 @@ 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,
24
22
  width: 300,
25
23
  height: 40,
26
24
  padding: 0,
@@ -52,13 +50,13 @@ export class Controller extends Component<ControllerStyleProps> {
52
50
  }
53
51
 
54
52
  private renderBackground() {
55
- const { x, y, width, height } = this.style;
53
+ const { width, height } = this.style;
56
54
  const backgroundStyle = subStyleProps(this.attributes, 'background');
57
- this.background.attr({ x, y, width, height, ...backgroundStyle });
55
+ this.background.attr({ width, height, ...backgroundStyle });
58
56
  }
59
57
 
60
58
  private renderFunctions() {
61
- const { functions, iconSize, iconSpacing, x, y, width, height, align } = this.attributes;
59
+ const { functions, iconSize, iconSpacing, width, height, align } = this.attributes;
62
60
 
63
61
  const {
64
62
  padding: [, right, , left],
@@ -87,8 +85,8 @@ export class Controller extends Component<ControllerStyleProps> {
87
85
  components.forEach((name, index) => {
88
86
  const Ctor = componentsMap[name];
89
87
  const style: Record<string, any> = {
90
- x: x + index * (iconSize + iconSpacing) + xOffset,
91
- y: y + height / 2,
88
+ x: index * (iconSize + iconSpacing) + xOffset,
89
+ y: height / 2,
92
90
  size: iconSize,
93
91
  };
94
92
 
@@ -107,9 +105,11 @@ export class Controller extends Component<ControllerStyleProps> {
107
105
 
108
106
  if (Ctor === SpeedSelect) {
109
107
  // 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 } }) as SpeedSelect;
112
+ this.speedSelect = new Ctor({ style: { ...style, zIndex: 100, x: baseX + x, y: baseY + y } }) as SpeedSelect;
113
113
  (canvas as unknown as Canvas).appendChild(this.speedSelect);
114
114
  }
115
115
  } else {
@@ -40,10 +40,6 @@ 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;
47
43
  /** 图标尺寸 */
48
44
  iconSize?: number;
49
45
  type: HandleType;
@@ -52,8 +48,6 @@ type ChartModeHandleOptions = ComponentOptions<ChartModeHandleStyleProps>;
52
48
  export class ChartModeHandle extends Component<ChartModeHandleStyleProps> {
53
49
  static defaultOptions: ChartModeHandleOptions = {
54
50
  style: {
55
- x: 0,
56
- y: 0,
57
51
  width: 10,
58
52
  height: 50,
59
53
  iconSize: 10,
@@ -68,41 +62,41 @@ export class ChartModeHandle extends Component<ChartModeHandleStyleProps> {
68
62
  };
69
63
 
70
64
  private renderBackground() {
71
- const { x, y, width, height } = this.attributes;
65
+ const { width, height } = this.attributes;
72
66
  const style = subStyleProps(this.attributes, 'background');
73
67
  select(this)
74
68
  .maybeAppend('background', 'rect')
75
69
  .attr('className', 'background')
76
- .styles({ x: x - width / 2, y: y - height / 2, width, height, ...style });
70
+ .styles({ x: -width / 2, y: -height / 2, width, height, ...style });
77
71
  }
78
72
 
79
73
  private renderIcon() {
80
- const { x, y, iconSize } = this.attributes;
74
+ const { iconSize } = this.attributes;
81
75
  const style = subStyleProps(this.attributes, 'icon');
82
76
  const diffX = 1;
83
77
  const diffY = iconSize / 2;
84
78
  select(this)
85
79
  .maybeAppend('icon-left-line', 'line')
86
80
  .attr('className', 'icon-left-line')
87
- .styles({ x1: x - diffX, y1: y - diffY, x2: x - diffX, y2: y + diffY, ...style });
81
+ .styles({ x1: -diffX, y1: -diffY, x2: -diffX, y2: diffY, ...style });
88
82
  select(this)
89
83
  .maybeAppend('icon-right-line', 'line')
90
84
  .attr('className', 'icon-right-line')
91
- .styles({ x1: x + diffX, y1: y - diffY, x2: x + diffX, y2: y + diffY, ...style });
85
+ .styles({ x1: diffX, y1: -diffY, x2: diffX, y2: diffY, ...style });
92
86
  }
93
87
 
94
88
  private renderBorder() {
95
- const { x: xx, y, width, height, type } = this.attributes;
89
+ const { width, height, type } = this.attributes;
96
90
  const style = subStyleProps(this.attributes, 'border');
97
91
  const x = type === 'start' ? +width / 2 : -width / 2;
98
92
  select(this)
99
93
  .maybeAppend('border', 'line')
100
94
  .attr('className', 'border')
101
95
  .styles({
102
- x1: x + xx,
103
- y1: y - height / 2,
104
- x2: x + xx,
105
- y2: y + height / 2,
96
+ x1: x,
97
+ y1: -height / 2,
98
+ x2: x,
99
+ y2: +height / 2,
106
100
  ...style,
107
101
  });
108
102
  }