@antv/g2 5.0.0-beta.4 → 5.0.0-beta.5

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 (348) hide show
  1. package/dist/g2-lite.min.js +5 -2
  2. package/dist/g2.min.js +5 -2
  3. package/esm/api/mark/mark.js +0 -2
  4. package/esm/api/mark/mark.js.map +1 -1
  5. package/esm/api/mark/types.d.ts +0 -2
  6. package/esm/component/axis.js +5 -4
  7. package/esm/component/axis.js.map +1 -1
  8. package/esm/component/slider.js +2 -4
  9. package/esm/component/slider.js.map +1 -1
  10. package/esm/composition/mark.js +2 -1
  11. package/esm/composition/mark.js.map +1 -1
  12. package/esm/interaction/builtin/brushHighlight.d.ts +1 -1
  13. package/esm/interaction/index.d.ts +3 -0
  14. package/esm/interaction/index.js +3 -0
  15. package/esm/interaction/index.js.map +1 -1
  16. package/esm/interaction/native/brushHighlight.d.ts +15 -0
  17. package/esm/interaction/native/brushHighlight.js +283 -0
  18. package/esm/interaction/native/brushHighlight.js.map +1 -0
  19. package/esm/interaction/native/brushXHighlight.d.ts +1 -0
  20. package/esm/interaction/native/brushXHighlight.js +8 -0
  21. package/esm/interaction/native/brushXHighlight.js.map +1 -0
  22. package/esm/interaction/native/brushYHighlight.d.ts +1 -0
  23. package/esm/interaction/native/brushYHighlight.js +8 -0
  24. package/esm/interaction/native/brushYHighlight.js.map +1 -0
  25. package/esm/interaction/native/legendFilter.js +3 -12
  26. package/esm/interaction/native/legendFilter.js.map +1 -1
  27. package/esm/interaction/native/tooltip.js +96 -28
  28. package/esm/interaction/native/tooltip.js.map +1 -1
  29. package/esm/interaction/native/utils.d.ts +4 -0
  30. package/esm/interaction/native/utils.js +23 -0
  31. package/esm/interaction/native/utils.js.map +1 -1
  32. package/esm/label-transform/contrastReverse.d.ts +9 -0
  33. package/esm/label-transform/contrastReverse.js +48 -0
  34. package/esm/label-transform/contrastReverse.js.map +1 -0
  35. package/esm/label-transform/index.d.ts +8 -8
  36. package/esm/label-transform/index.js +4 -4
  37. package/esm/label-transform/index.js.map +1 -1
  38. package/esm/label-transform/overflowHide.d.ts +7 -0
  39. package/esm/label-transform/overflowHide.js +18 -0
  40. package/esm/label-transform/overflowHide.js.map +1 -0
  41. package/esm/label-transform/overlapDodgeY.d.ts +7 -0
  42. package/esm/label-transform/{dodgeY.js → overlapDodgeY.js} +4 -4
  43. package/esm/label-transform/overlapDodgeY.js.map +1 -0
  44. package/esm/label-transform/overlapHide.d.ts +7 -0
  45. package/esm/label-transform/overlapHide.js +24 -0
  46. package/esm/label-transform/overlapHide.js.map +1 -0
  47. package/esm/runtime/plot.js +24 -6
  48. package/esm/runtime/plot.js.map +1 -1
  49. package/esm/runtime/scale.js +17 -5
  50. package/esm/runtime/scale.js.map +1 -1
  51. package/esm/runtime/transform.js +10 -4
  52. package/esm/runtime/transform.js.map +1 -1
  53. package/esm/runtime/types/common.d.ts +1 -0
  54. package/esm/runtime/types/options.d.ts +1 -0
  55. package/esm/shape/label/label.js +3 -3
  56. package/esm/shape/label/label.js.map +1 -1
  57. package/esm/shape/label/position/area.d.ts +13 -0
  58. package/esm/shape/label/position/area.js +28 -0
  59. package/esm/shape/label/position/area.js.map +1 -0
  60. package/esm/shape/label/position/bottom.d.ts +1 -0
  61. package/esm/shape/label/position/bottom.js +2 -0
  62. package/esm/shape/label/position/bottom.js.map +1 -0
  63. package/esm/shape/label/position/bottomLeft.d.ts +1 -0
  64. package/esm/shape/label/position/bottomLeft.js +2 -0
  65. package/esm/shape/label/position/bottomLeft.js.map +1 -0
  66. package/esm/shape/label/position/bottomRight.d.ts +1 -0
  67. package/esm/shape/label/position/bottomRight.js +2 -0
  68. package/esm/shape/label/position/bottomRight.js.map +1 -0
  69. package/esm/shape/label/position/default.d.ts +20 -0
  70. package/esm/shape/label/{position.js → position/default.js} +9 -45
  71. package/esm/shape/label/position/default.js.map +1 -0
  72. package/esm/shape/label/position/index.d.ts +13 -0
  73. package/esm/shape/label/position/index.js +14 -0
  74. package/esm/shape/label/position/index.js.map +1 -0
  75. package/esm/shape/label/position/inside.d.ts +1 -0
  76. package/esm/shape/label/position/inside.js +2 -0
  77. package/esm/shape/label/position/inside.js.map +1 -0
  78. package/esm/shape/label/position/left.d.ts +1 -0
  79. package/esm/shape/label/position/left.js +2 -0
  80. package/esm/shape/label/position/left.js.map +1 -0
  81. package/esm/shape/label/position/outside.d.ts +1 -0
  82. package/esm/shape/label/position/outside.js +2 -0
  83. package/esm/shape/label/position/outside.js.map +1 -0
  84. package/esm/shape/label/position/right.d.ts +1 -0
  85. package/esm/shape/label/position/right.js +2 -0
  86. package/esm/shape/label/position/right.js.map +1 -0
  87. package/esm/shape/label/position/spider.d.ts +7 -0
  88. package/esm/shape/label/position/spider.js +40 -0
  89. package/esm/shape/label/position/spider.js.map +1 -0
  90. package/esm/shape/label/position/surround.d.ts +7 -0
  91. package/esm/shape/label/position/surround.js +37 -0
  92. package/esm/shape/label/position/surround.js.map +1 -0
  93. package/esm/shape/label/position/top.d.ts +1 -0
  94. package/esm/shape/label/position/top.js +2 -0
  95. package/esm/shape/label/position/top.js.map +1 -0
  96. package/esm/shape/label/position/topLeft.d.ts +1 -0
  97. package/esm/shape/label/position/topLeft.js +2 -0
  98. package/esm/shape/label/position/topLeft.js.map +1 -0
  99. package/esm/shape/label/position/topRight.d.ts +1 -0
  100. package/esm/shape/label/position/topRight.js +2 -0
  101. package/esm/shape/label/position/topRight.js.map +1 -0
  102. package/esm/spec/composition.d.ts +2 -0
  103. package/esm/spec/geometry.d.ts +1 -1
  104. package/esm/spec/interaction.d.ts +21 -5
  105. package/esm/spec/labelTransform.d.ts +24 -11
  106. package/esm/spec/theme.d.ts +5 -2
  107. package/esm/stdlib/index.js +5 -6
  108. package/esm/stdlib/index.js.map +1 -1
  109. package/esm/theme/academy.d.ts +3 -0
  110. package/esm/theme/academy.js +402 -0
  111. package/esm/theme/academy.js.map +1 -0
  112. package/esm/theme/dark.js +3 -2
  113. package/esm/theme/dark.js.map +1 -1
  114. package/esm/theme/index.d.ts +1 -0
  115. package/esm/theme/index.js +1 -0
  116. package/esm/theme/index.js.map +1 -1
  117. package/esm/theme/light.js +4 -3
  118. package/esm/theme/light.js.map +1 -1
  119. package/esm/transform/maybeTooltip.js +3 -1
  120. package/esm/transform/maybeTooltip.js.map +1 -1
  121. package/esm/utils/bounds.d.ts +26 -0
  122. package/esm/utils/bounds.js +41 -0
  123. package/esm/utils/bounds.js.map +1 -0
  124. package/esm/utils/color.d.ts +6 -0
  125. package/esm/utils/color.js +7 -0
  126. package/esm/utils/color.js.map +1 -0
  127. package/esm/utils/coordinate.d.ts +1 -0
  128. package/esm/utils/coordinate.js +12 -0
  129. package/esm/utils/coordinate.js.map +1 -1
  130. package/esm/utils/helper.d.ts +1 -0
  131. package/esm/utils/helper.js +3 -0
  132. package/esm/utils/helper.js.map +1 -1
  133. package/lib/api/mark/mark.js +0 -2
  134. package/lib/api/mark/mark.js.map +1 -1
  135. package/lib/api/mark/types.d.ts +0 -2
  136. package/lib/component/axis.js +5 -4
  137. package/lib/component/axis.js.map +1 -1
  138. package/lib/component/slider.js +2 -4
  139. package/lib/component/slider.js.map +1 -1
  140. package/lib/composition/mark.js +2 -1
  141. package/lib/composition/mark.js.map +1 -1
  142. package/lib/interaction/builtin/brushHighlight.d.ts +1 -1
  143. package/lib/interaction/index.d.ts +3 -0
  144. package/lib/interaction/index.js +7 -1
  145. package/lib/interaction/index.js.map +1 -1
  146. package/lib/interaction/native/brushHighlight.d.ts +15 -0
  147. package/lib/interaction/native/brushHighlight.js +289 -0
  148. package/lib/interaction/native/brushHighlight.js.map +1 -0
  149. package/lib/interaction/native/brushXHighlight.d.ts +1 -0
  150. package/lib/interaction/native/brushXHighlight.js +12 -0
  151. package/lib/interaction/native/brushXHighlight.js.map +1 -0
  152. package/lib/interaction/native/brushYHighlight.d.ts +1 -0
  153. package/lib/interaction/native/brushYHighlight.js +12 -0
  154. package/lib/interaction/native/brushYHighlight.js.map +1 -0
  155. package/lib/interaction/native/legendFilter.js +4 -13
  156. package/lib/interaction/native/legendFilter.js.map +1 -1
  157. package/lib/interaction/native/tooltip.js +93 -25
  158. package/lib/interaction/native/tooltip.js.map +1 -1
  159. package/lib/interaction/native/utils.d.ts +4 -0
  160. package/lib/interaction/native/utils.js +28 -1
  161. package/lib/interaction/native/utils.js.map +1 -1
  162. package/lib/label-transform/contrastReverse.d.ts +9 -0
  163. package/lib/label-transform/contrastReverse.js +52 -0
  164. package/lib/label-transform/contrastReverse.js.map +1 -0
  165. package/lib/label-transform/index.d.ts +8 -8
  166. package/lib/label-transform/index.js +9 -9
  167. package/lib/label-transform/index.js.map +1 -1
  168. package/lib/label-transform/overflowHide.d.ts +7 -0
  169. package/lib/label-transform/overflowHide.js +22 -0
  170. package/lib/label-transform/overflowHide.js.map +1 -0
  171. package/lib/label-transform/overlapDodgeY.d.ts +7 -0
  172. package/lib/label-transform/{dodgeY.js → overlapDodgeY.js} +6 -6
  173. package/lib/label-transform/overlapDodgeY.js.map +1 -0
  174. package/lib/label-transform/overlapHide.d.ts +7 -0
  175. package/lib/label-transform/overlapHide.js +28 -0
  176. package/lib/label-transform/overlapHide.js.map +1 -0
  177. package/lib/runtime/plot.js +24 -6
  178. package/lib/runtime/plot.js.map +1 -1
  179. package/lib/runtime/scale.js +16 -4
  180. package/lib/runtime/scale.js.map +1 -1
  181. package/lib/runtime/transform.js +10 -4
  182. package/lib/runtime/transform.js.map +1 -1
  183. package/lib/runtime/types/common.d.ts +1 -0
  184. package/lib/runtime/types/options.d.ts +1 -0
  185. package/lib/shape/label/label.js +3 -3
  186. package/lib/shape/label/label.js.map +1 -1
  187. package/lib/shape/label/position/area.d.ts +13 -0
  188. package/lib/shape/label/position/area.js +32 -0
  189. package/lib/shape/label/position/area.js.map +1 -0
  190. package/lib/shape/label/position/bottom.d.ts +1 -0
  191. package/lib/shape/label/position/bottom.js +6 -0
  192. package/lib/shape/label/position/bottom.js.map +1 -0
  193. package/lib/shape/label/position/bottomLeft.d.ts +1 -0
  194. package/lib/shape/label/position/bottomLeft.js +6 -0
  195. package/lib/shape/label/position/bottomLeft.js.map +1 -0
  196. package/lib/shape/label/position/bottomRight.d.ts +1 -0
  197. package/lib/shape/label/position/bottomRight.js +6 -0
  198. package/lib/shape/label/position/bottomRight.js.map +1 -0
  199. package/lib/shape/label/position/default.d.ts +20 -0
  200. package/lib/shape/label/{position.js → position/default.js} +10 -43
  201. package/lib/shape/label/position/default.js.map +1 -0
  202. package/lib/shape/label/position/index.d.ts +13 -0
  203. package/lib/shape/label/position/index.js +30 -0
  204. package/lib/shape/label/position/index.js.map +1 -0
  205. package/lib/shape/label/position/inside.d.ts +1 -0
  206. package/lib/shape/label/position/inside.js +6 -0
  207. package/lib/shape/label/position/inside.js.map +1 -0
  208. package/lib/shape/label/position/left.d.ts +1 -0
  209. package/lib/shape/label/position/left.js +6 -0
  210. package/lib/shape/label/position/left.js.map +1 -0
  211. package/lib/shape/label/position/outside.d.ts +1 -0
  212. package/lib/shape/label/position/outside.js +6 -0
  213. package/lib/shape/label/position/outside.js.map +1 -0
  214. package/lib/shape/label/position/right.d.ts +1 -0
  215. package/lib/shape/label/position/right.js +6 -0
  216. package/lib/shape/label/position/right.js.map +1 -0
  217. package/lib/shape/label/position/spider.d.ts +7 -0
  218. package/lib/shape/label/position/spider.js +44 -0
  219. package/lib/shape/label/position/spider.js.map +1 -0
  220. package/lib/shape/label/position/surround.d.ts +7 -0
  221. package/lib/shape/label/position/surround.js +41 -0
  222. package/lib/shape/label/position/surround.js.map +1 -0
  223. package/lib/shape/label/position/top.d.ts +1 -0
  224. package/lib/shape/label/position/top.js +6 -0
  225. package/lib/shape/label/position/top.js.map +1 -0
  226. package/lib/shape/label/position/topLeft.d.ts +1 -0
  227. package/lib/shape/label/position/topLeft.js +6 -0
  228. package/lib/shape/label/position/topLeft.js.map +1 -0
  229. package/lib/shape/label/position/topRight.d.ts +1 -0
  230. package/lib/shape/label/position/topRight.js +6 -0
  231. package/lib/shape/label/position/topRight.js.map +1 -0
  232. package/lib/spec/composition.d.ts +2 -0
  233. package/lib/spec/geometry.d.ts +1 -1
  234. package/lib/spec/interaction.d.ts +21 -5
  235. package/lib/spec/labelTransform.d.ts +24 -11
  236. package/lib/spec/theme.d.ts +5 -2
  237. package/lib/stdlib/index.js +2 -3
  238. package/lib/stdlib/index.js.map +1 -1
  239. package/lib/theme/academy.d.ts +3 -0
  240. package/lib/theme/academy.js +406 -0
  241. package/lib/theme/academy.js.map +1 -0
  242. package/lib/theme/dark.js +3 -2
  243. package/lib/theme/dark.js.map +1 -1
  244. package/lib/theme/index.d.ts +1 -0
  245. package/lib/theme/index.js +3 -1
  246. package/lib/theme/index.js.map +1 -1
  247. package/lib/theme/light.js +4 -3
  248. package/lib/theme/light.js.map +1 -1
  249. package/lib/transform/maybeTooltip.js +3 -1
  250. package/lib/transform/maybeTooltip.js.map +1 -1
  251. package/lib/utils/bounds.d.ts +26 -0
  252. package/lib/utils/bounds.js +48 -0
  253. package/lib/utils/bounds.js.map +1 -0
  254. package/lib/utils/color.d.ts +6 -0
  255. package/lib/utils/color.js +11 -0
  256. package/lib/utils/color.js.map +1 -0
  257. package/lib/utils/coordinate.d.ts +1 -0
  258. package/lib/utils/coordinate.js +14 -1
  259. package/lib/utils/coordinate.js.map +1 -1
  260. package/lib/utils/helper.d.ts +1 -0
  261. package/lib/utils/helper.js +5 -1
  262. package/lib/utils/helper.js.map +1 -1
  263. package/package.json +2 -2
  264. package/src/.DS_Store +0 -0
  265. package/src/api/mark/mark.ts +0 -2
  266. package/src/api/mark/types.ts +0 -2
  267. package/src/component/axis.ts +16 -11
  268. package/src/component/slider.ts +1 -3
  269. package/src/composition/mark.ts +2 -0
  270. package/src/data/.DS_Store +0 -0
  271. package/src/interaction/index.ts +3 -0
  272. package/src/interaction/native/brushHighlight.ts +346 -0
  273. package/src/interaction/native/brushXHighlight.ts +11 -0
  274. package/src/interaction/native/brushYHighlight.ts +11 -0
  275. package/src/interaction/native/legendFilter.ts +3 -14
  276. package/src/interaction/native/tooltip.ts +119 -32
  277. package/src/interaction/native/utils.ts +31 -0
  278. package/src/label-transform/contrastReverse.ts +56 -0
  279. package/src/label-transform/index.ts +8 -8
  280. package/src/label-transform/overflowHide.ts +23 -0
  281. package/src/label-transform/{dodgeY.ts → overlapDodgeY.ts} +6 -6
  282. package/src/label-transform/overlapHide.ts +32 -0
  283. package/src/runtime/plot.ts +35 -6
  284. package/src/runtime/scale.ts +15 -7
  285. package/src/runtime/transform.ts +13 -4
  286. package/src/runtime/types/common.ts +1 -0
  287. package/src/runtime/types/options.ts +1 -0
  288. package/src/shape/.DS_Store +0 -0
  289. package/src/shape/label/label.ts +4 -3
  290. package/src/shape/label/position/area.ts +39 -0
  291. package/src/shape/label/position/bottom.ts +1 -0
  292. package/src/shape/label/position/bottomLeft.ts +1 -0
  293. package/src/shape/label/position/bottomRight.ts +1 -0
  294. package/src/shape/label/{position.ts → position/default.ts} +12 -56
  295. package/src/shape/label/position/index.ts +13 -0
  296. package/src/shape/label/position/inside.ts +1 -0
  297. package/src/shape/label/position/left.ts +1 -0
  298. package/src/shape/label/position/outside.ts +1 -0
  299. package/src/shape/label/position/right.ts +1 -0
  300. package/src/shape/label/position/spider.ts +46 -0
  301. package/src/shape/label/position/surround.ts +42 -0
  302. package/src/shape/label/position/top.ts +1 -0
  303. package/src/shape/label/position/topLeft.ts +1 -0
  304. package/src/shape/label/position/topRight.ts +1 -0
  305. package/src/spec/composition.ts +2 -0
  306. package/src/spec/geometry.ts +2 -1
  307. package/src/spec/interaction.ts +28 -4
  308. package/src/spec/labelTransform.ts +29 -11
  309. package/src/spec/theme.ts +6 -2
  310. package/src/stdlib/index.ts +19 -7
  311. package/src/theme/academy.ts +408 -0
  312. package/src/theme/dark.ts +3 -2
  313. package/src/theme/index.ts +1 -0
  314. package/src/theme/light.ts +4 -3
  315. package/src/transform/maybeTooltip.ts +3 -1
  316. package/src/utils/bounds.ts +52 -0
  317. package/src/utils/color.ts +12 -0
  318. package/src/utils/coordinate.ts +12 -0
  319. package/src/utils/helper.ts +4 -0
  320. package/esm/label-transform/dodgeY.d.ts +0 -7
  321. package/esm/label-transform/dodgeY.js.map +0 -1
  322. package/esm/label-transform/hideOverlap.d.ts +0 -4
  323. package/esm/label-transform/hideOverlap.js +0 -48
  324. package/esm/label-transform/hideOverlap.js.map +0 -1
  325. package/esm/label-transform/spider.d.ts +0 -7
  326. package/esm/label-transform/spider.js +0 -30
  327. package/esm/label-transform/spider.js.map +0 -1
  328. package/esm/label-transform/surround.d.ts +0 -7
  329. package/esm/label-transform/surround.js +0 -30
  330. package/esm/label-transform/surround.js.map +0 -1
  331. package/esm/shape/label/position.d.ts +0 -25
  332. package/esm/shape/label/position.js.map +0 -1
  333. package/lib/label-transform/dodgeY.d.ts +0 -7
  334. package/lib/label-transform/dodgeY.js.map +0 -1
  335. package/lib/label-transform/hideOverlap.d.ts +0 -4
  336. package/lib/label-transform/hideOverlap.js +0 -52
  337. package/lib/label-transform/hideOverlap.js.map +0 -1
  338. package/lib/label-transform/spider.d.ts +0 -7
  339. package/lib/label-transform/spider.js +0 -34
  340. package/lib/label-transform/spider.js.map +0 -1
  341. package/lib/label-transform/surround.d.ts +0 -7
  342. package/lib/label-transform/surround.js +0 -34
  343. package/lib/label-transform/surround.js.map +0 -1
  344. package/lib/shape/label/position.d.ts +0 -25
  345. package/lib/shape/label/position.js.map +0 -1
  346. package/src/label-transform/hideOverlap.ts +0 -62
  347. package/src/label-transform/spider.ts +0 -37
  348. package/src/label-transform/surround.ts +0 -37
@@ -0,0 +1,408 @@
1
+ import { ThemeComponent as TC, Theme } from '../runtime';
2
+
3
+ export type AcademyOptions = Theme;
4
+
5
+ const COLORS = {
6
+ BLACK: '#000',
7
+ WHITE: '#fff',
8
+ STROKE: '#888',
9
+ };
10
+
11
+ const BACKGROUND_COLOR = 'transparent';
12
+
13
+ export const Academy: TC<AcademyOptions> = (options) => {
14
+ const DEFAULT_COLOR = '#4e79a7';
15
+ const defaultOptions: Theme = {
16
+ defaultColor: DEFAULT_COLOR,
17
+ defaultCategory10: 'tableau10',
18
+ defaultCategory20: 'tableau10',
19
+ defaultSize: 1,
20
+ elementActiveStroke: COLORS.BLACK,
21
+ enter: {
22
+ duration: 300,
23
+ fill: 'both',
24
+ delay: 0,
25
+ },
26
+ update: {
27
+ duration: 300,
28
+ fill: 'both',
29
+ delay: 0,
30
+ },
31
+ exit: {
32
+ duration: 300,
33
+ fill: 'both',
34
+ delay: 0,
35
+ },
36
+ // --- Theme of area style
37
+ viewFill: BACKGROUND_COLOR,
38
+ plotFill: 'transparent',
39
+ mainFill: 'transparent',
40
+ contentFill: 'transparent',
41
+ // --- Theme of mark shape
42
+ line: {
43
+ line: {
44
+ fill: '',
45
+ strokeOpacity: 1,
46
+ lineWidth: 1,
47
+ connectStroke: '#aaa',
48
+ },
49
+ },
50
+ point: {
51
+ point: {
52
+ r: 3,
53
+ fillOpacity: 0.95,
54
+ lineWidth: 0,
55
+ },
56
+ hollow: {
57
+ r: 3,
58
+ fill: '',
59
+ strokeOpacity: 0.95,
60
+ lineWidth: 1,
61
+ },
62
+ plus: {
63
+ r: 3,
64
+ fill: '',
65
+ strokeOpacity: 0.95,
66
+ lineWidth: 3,
67
+ },
68
+ diamond: {
69
+ r: 3,
70
+ fill: '',
71
+ strokeOpacity: 0.95,
72
+ lineWidth: 1,
73
+ },
74
+ },
75
+ interval: {
76
+ rect: {
77
+ fillOpacity: 0.95,
78
+ },
79
+ hollow: {
80
+ fill: '',
81
+ strokeOpacity: 1,
82
+ lineWidth: 2,
83
+ },
84
+ },
85
+ area: {
86
+ area: {
87
+ fillOpacity: 0.85,
88
+ lineWidth: 0,
89
+ connectFill: COLORS.BLACK,
90
+ connectFillOpacity: 0.1,
91
+ },
92
+ },
93
+ polygon: {
94
+ polygon: {
95
+ fillOpacity: 0.95,
96
+ },
97
+ },
98
+ cell: {
99
+ cell: {
100
+ fillOpacity: 0.95,
101
+ },
102
+ hollow: {
103
+ fill: '',
104
+ strokeOpacity: 1,
105
+ lineWidth: 2,
106
+ },
107
+ },
108
+ rect: {
109
+ rect: {
110
+ fillOpacity: 0.95,
111
+ },
112
+ hollow: {
113
+ fill: '',
114
+ strokeOpacity: 1,
115
+ lineWidth: 2,
116
+ },
117
+ },
118
+ link: {
119
+ link: {
120
+ fill: '',
121
+ strokeOpacity: 1,
122
+ },
123
+ },
124
+ vector: {
125
+ vector: {
126
+ fillOpacity: 1,
127
+ },
128
+ },
129
+ box: {
130
+ box: {
131
+ fillOpacity: 0.95,
132
+ stroke: '#1D2129',
133
+ lineWidth: 1,
134
+ },
135
+ },
136
+ text: {
137
+ text: {
138
+ fill: '#1D2129',
139
+ fontSize: 10,
140
+ strokeWidth: 0,
141
+ connectorStroke: COLORS.STROKE,
142
+ connectorStrokeOpacity: 0.45,
143
+ connectorLineWidth: 1,
144
+ backgroundFill: COLORS.STROKE,
145
+ backgroundFillOpacity: 0.15,
146
+ backgroundPadding: [2, 4],
147
+ startMarkerSymbol: 'circle',
148
+ startMarkerSize: 4,
149
+ endMarkerSymbol: 'circle',
150
+ endMarkerSize: 4,
151
+ },
152
+ badge: {
153
+ fill: '#1D2129',
154
+ fillOpacity: 0.65,
155
+ strokeWidth: 0,
156
+ fontSize: 10,
157
+ textAlign: 'center',
158
+ textBaseline: 'middle',
159
+ markerFill: COLORS.STROKE,
160
+ markerFillOpacity: 0.25,
161
+ markerStrokeOpacity: 0,
162
+ },
163
+ },
164
+ lineX: {
165
+ line: {
166
+ stroke: COLORS.STROKE,
167
+ strokeOpacity: 0.45,
168
+ lineWidth: 1,
169
+ },
170
+ },
171
+ lineY: {
172
+ line: {
173
+ stroke: COLORS.STROKE,
174
+ strokeOpacity: 0.45,
175
+ lineWidth: 1,
176
+ },
177
+ },
178
+ rangeX: {
179
+ range: {
180
+ fill: COLORS.STROKE,
181
+ fillOpacity: 0.15,
182
+ lineWidth: 0,
183
+ },
184
+ },
185
+ rangeY: {
186
+ range: {
187
+ fill: COLORS.STROKE,
188
+ fillOpacity: 0.15,
189
+ lineWidth: 0,
190
+ },
191
+ },
192
+ connector: {
193
+ connector: {
194
+ stroke: COLORS.STROKE,
195
+ strokeOpacity: 0.45,
196
+ lineWidth: 1,
197
+ connectLength1: 12,
198
+ endMarker: true,
199
+ endMarkerSize: 6,
200
+ endMarkerFill: COLORS.STROKE,
201
+ endMarkerFillOpacity: 0.95,
202
+ },
203
+ },
204
+ interaction: {
205
+ active: {
206
+ line: {
207
+ line: { lineWidth: 3 },
208
+ },
209
+ interval: {
210
+ rect: { stroke: COLORS.BLACK },
211
+ },
212
+ area: {
213
+ area: { fillOpacity: 0.5 },
214
+ },
215
+ },
216
+ inactive: {
217
+ area: {
218
+ area: { fillOpacity: 0.3 },
219
+ },
220
+ },
221
+ selected: {},
222
+ disabled: {},
223
+ },
224
+ axis: {
225
+ titleFill: COLORS.BLACK,
226
+ titleFillOpacity: 1,
227
+ titleFontSize: 11,
228
+ titleFontWeight: 'bold',
229
+ titleSpacing: 12,
230
+ line: true,
231
+ lineStroke: '#888',
232
+ lineStrokeOpacity: 1,
233
+ lineLineWidth: 1,
234
+ lineArrow: null,
235
+ tickStroke: COLORS.STROKE,
236
+ tickStrokeOpacity: 1,
237
+ tickLineWidth: 1,
238
+ tickLength: 5,
239
+ labelFill: COLORS.BLACK,
240
+ labelFillOpacity: 1,
241
+ labelFontSize: 10,
242
+ labelAutoRotate: false,
243
+ labelFontWeight: 'normal',
244
+ labelSpacing: 4,
245
+ labelAlign: 'horizontal',
246
+ gridStroke: '#ddd',
247
+ gridStrokeOpacity: 1,
248
+ gridLineWidth: 1,
249
+ gridLineDash: [0, 0],
250
+ titleTransformOrigin: 'center',
251
+ },
252
+ axisTop: {
253
+ titlePosition: 'top',
254
+ titleSpacing: 0,
255
+ titleTextBaseline: 'middle',
256
+ labelDirection: 'negative',
257
+ tickDirection: 'negative',
258
+ gridDirection: 'positive',
259
+ },
260
+ axisBottom: {
261
+ titleSpacing: 4,
262
+ titleTextBaseline: 'bottom',
263
+ labelSpacing: 8,
264
+ labelDirection: 'positive',
265
+ tickDirection: 'positive',
266
+ gridDirection: 'negative',
267
+ },
268
+ axisLeft: {
269
+ titleTextBaseline: 'middle',
270
+ titleSpacing: 4,
271
+ titlePosition: 'left',
272
+ titleTransformOrigin: 'center',
273
+ titleTransform: `translate(50%, 0) rotate(-90) translate(0, -50%)`,
274
+ labelSpacing: 4,
275
+ labelDirection: 'positive',
276
+ tickDirection: 'positive',
277
+ gridDirection: 'negative',
278
+ },
279
+ axisRight: {
280
+ titleTextBaseline: 'top',
281
+ titleSpacing: 0,
282
+ titlePosition: 'right',
283
+ titleTransformOrigin: 'center',
284
+ titleTransform: `translate(-50%, 0) rotate(-90)`,
285
+ labelSpacing: 4,
286
+ labelDirection: 'negative',
287
+ tickDirection: 'negative',
288
+ gridDirection: 'positive',
289
+ },
290
+ axisArcY: {
291
+ titlePosition: 'top',
292
+ titleSpacing: 0,
293
+ titleTextBaseline: 'bottom',
294
+ gridDirection: 'negative',
295
+ gridConnect: 'arc',
296
+ gridControlAngles: [90, 180, 360],
297
+ gridType: 'surround',
298
+ girdClosed: true,
299
+ },
300
+ legend: {
301
+ padding: 8,
302
+ showTitle: false,
303
+ titleFill: COLORS.BLACK,
304
+ titleFillOpacity: 1,
305
+ titleFontSize: 11,
306
+ titleFontWeight: 'bold',
307
+ titleSpacing: 4,
308
+ // legend marker
309
+ itemMarkerFill: DEFAULT_COLOR,
310
+ itemMarkerFillOpacity: 1,
311
+ itemMarkerSize: 8,
312
+ itemSpacing: [5, 4],
313
+ itemLabelFill: COLORS.BLACK,
314
+ itemLabelFillOpacity: 1,
315
+ itemLabelFontSize: 10,
316
+ itemLabelFontWeight: 'normal',
317
+ itemValueFill: COLORS.BLACK,
318
+ itemValueFillOpacity: 1,
319
+ itemValueFontSize: 10,
320
+ itemValueFontWeight: 'normal',
321
+ itemBackgroundFill: 'transparent',
322
+ // [todo] rename legend navigator
323
+ navButtonFill: COLORS.BLACK,
324
+ navButtonFillOpacity: 0.45,
325
+ navButtonSize: 6,
326
+ navPageNumFill: COLORS.BLACK,
327
+ navPageNumFillOpacity: 0.45,
328
+ navPageNumFontSize: 10,
329
+ // others
330
+ backgroundFill: 'transparent',
331
+ },
332
+ continuousLegend: {
333
+ showTitle: false,
334
+ labelFill: COLORS.BLACK,
335
+ labelFillOpacity: 0.45,
336
+ labelFontSize: 10,
337
+ labelFontWeight: 'normal',
338
+ handleWidth: 10,
339
+ handleHeight: 12,
340
+ handleMarkerFill: COLORS.BLACK,
341
+ handleMarkerFillOpacity: 0.6,
342
+ handleMarkerStroke: COLORS.BLACK,
343
+ handleMarkerStrokeOpacity: 0.25,
344
+ handleMarkerLineWidth: 1,
345
+ handleLabelFill: COLORS.BLACK,
346
+ handleLabelFillOpacity: 0.45,
347
+ handleLabelFontSize: 10,
348
+ handleLabelFontWeight: 'normal',
349
+ },
350
+ label: {
351
+ fill: COLORS.BLACK,
352
+ fillOpacity: 0.65,
353
+ fontSize: 10,
354
+ fontWeight: 'normal',
355
+ stroke: null,
356
+ offset: 12,
357
+ connectorStroke: COLORS.BLACK,
358
+ connectorStrokeOpacity: 0.45,
359
+ connectorLineWidth: 1,
360
+ connectorLength2: 8,
361
+ connectorDistance: 4,
362
+ },
363
+ innerLabel: {
364
+ fill: COLORS.WHITE,
365
+ fontSize: 10,
366
+ fillOpacity: 0.85,
367
+ fontWeight: 'normal',
368
+ stroke: null,
369
+ offset: 0,
370
+ },
371
+ slider: {
372
+ trackSize: 16,
373
+ backgroundFill: COLORS.STROKE,
374
+ backgroundFillOpacity: 0.05,
375
+ selectionFill: DEFAULT_COLOR,
376
+ selectionFillOpacity: 0.15,
377
+ handleIconSize: 10,
378
+ handleIconFill: '#f7f7f7',
379
+ handleIconFillOpacity: 1,
380
+ handleIconStroke: COLORS.BLACK,
381
+ handleIconStrokeOpacity: 0.25,
382
+ handleIconLineWidth: 1,
383
+ handleIconRadius: 2,
384
+ handleLabelFill: COLORS.BLACK,
385
+ handleLabelFillOpacity: 0.45,
386
+ handleLabelFontSize: 10,
387
+ handleLabelFontWeight: 'normal',
388
+ },
389
+ scrollbar: {},
390
+ title: {
391
+ fill: COLORS.BLACK,
392
+ fillOpacity: 0.85,
393
+ fontSize: 24,
394
+ fontWeight: 'bold',
395
+ textBaseline: 'top',
396
+ },
397
+ subtitle: {
398
+ fill: COLORS.BLACK,
399
+ fillOpacity: 0.65,
400
+ fontSize: 10,
401
+ fontWeight: 'normal',
402
+ textBaseline: 'top',
403
+ },
404
+ };
405
+ return Object.assign({}, defaultOptions, options);
406
+ };
407
+
408
+ Academy.props = {};
package/src/theme/dark.ts CHANGED
@@ -132,7 +132,7 @@ export const Dark: TC<DarkOptions> = (options) => {
132
132
  box: {
133
133
  box: {
134
134
  fillOpacity: 0.95,
135
- stroke: '#1D2129',
135
+ stroke: COLORS.BLACK,
136
136
  lineWidth: 1,
137
137
  },
138
138
  },
@@ -281,6 +281,7 @@ export const Dark: TC<DarkOptions> = (options) => {
281
281
  titleTransform: `translate(50%, 0) rotate(-90)`,
282
282
  labelSpacing: 4,
283
283
  labelDirection: 'positive',
284
+ labelAutoRotate: false,
284
285
  tickDirection: 'positive',
285
286
  gridDirection: 'negative',
286
287
  },
@@ -375,7 +376,7 @@ export const Dark: TC<DarkOptions> = (options) => {
375
376
  offset: 0,
376
377
  },
377
378
  slider: {
378
- railSize: 16,
379
+ trackSize: 16,
379
380
  backgroundFill: COLORS.STROKE,
380
381
  backgroundFillOpacity: 1,
381
382
  selectionFill: DEFAULT_COLOR,
@@ -1,2 +1,3 @@
1
1
  export { Light } from './light';
2
2
  export { Dark } from './dark';
3
+ export { Academy } from './academy';
@@ -132,7 +132,7 @@ export const Light: TC<LightOptions> = (options) => {
132
132
  box: {
133
133
  box: {
134
134
  fillOpacity: 0.95,
135
- stroke: '#1D2129',
135
+ stroke: COLORS.BLACK,
136
136
  lineWidth: 1,
137
137
  },
138
138
  },
@@ -281,6 +281,7 @@ export const Light: TC<LightOptions> = (options) => {
281
281
  titleTransform: `translate(50%, 0) rotate(-90)`,
282
282
  labelSpacing: 4,
283
283
  labelDirection: 'positive',
284
+ labelAutoRotate: false,
284
285
  tickDirection: 'positive',
285
286
  gridDirection: 'negative',
286
287
  },
@@ -329,7 +330,7 @@ export const Light: TC<LightOptions> = (options) => {
329
330
  itemBackgroundFill: 'transparent',
330
331
  // [todo] rename legend navigator
331
332
  navButtonFill: COLORS.BLACK,
332
- navButtonFillOpacity: 0.45,
333
+ navButtonFillOpacity: 0.65,
333
334
  navPageNumFill: COLORS.BLACK,
334
335
  navPageNumFillOpacity: 0.45,
335
336
  navPageNumFontSize: 12,
@@ -376,7 +377,7 @@ export const Light: TC<LightOptions> = (options) => {
376
377
  offset: 0,
377
378
  },
378
379
  slider: {
379
- railSize: 16,
380
+ trackSize: 16,
380
381
  backgroundFill: COLORS.STROKE,
381
382
  backgroundFillOpacity: 1,
382
383
  selectionFill: DEFAULT_COLOR,
@@ -25,7 +25,9 @@ export const MaybeTooltip: TC<MaybeTooltipOptions> = (options) => {
25
25
  const E = [[key, column(V)]];
26
26
  // Only show channel with field.
27
27
  if (V && fv !== null) {
28
- E.push([`tooltip${index === 0 ? '' : index}`, column(V, fv)]);
28
+ const T = V.map((v) => ({ value: v, field: fv }));
29
+ //@ts-ignore
30
+ E.push([`tooltip${index === 0 ? '' : index}`, column(T, fv)]);
29
31
  index++;
30
32
  }
31
33
  return E;
@@ -0,0 +1,52 @@
1
+ import { AABB } from '@antv/g';
2
+ import { Vector2 } from './vector';
3
+
4
+ type Min = Vector2;
5
+ type Max = Vector2;
6
+ export type Bounds = [Min, Max];
7
+
8
+ export function parseAABB(min2: AABB): Bounds {
9
+ const { min, max } = min2;
10
+ return [
11
+ [min[0], min[1]],
12
+ [max[0], max[1]],
13
+ ];
14
+ }
15
+
16
+ /**
17
+ * Whether the `point` in `bounds`.
18
+ * @param point
19
+ * @param bounds
20
+ */
21
+ export function isInBounds(point: Vector2, bounds: Bounds): boolean {
22
+ const [x, y] = point;
23
+ const [min, max] = bounds;
24
+ return x >= min[0] && x <= max[0] && y >= min[1] && y <= max[1];
25
+ }
26
+
27
+ /**
28
+ * Whether `b1` is overflow from `b2`.
29
+ * @param b1
30
+ * @param b2
31
+ */
32
+ export function isOverflow(b1: Bounds, b2: Bounds): boolean {
33
+ const [min, max] = b1;
34
+ return !(isInBounds(min, b2) && isInBounds(max, b2));
35
+ }
36
+
37
+ /**
38
+ * Whether `b1` is overlap with `b2`.
39
+ * @param b1
40
+ * @param b2
41
+ * @returns
42
+ */
43
+ export function isOverlap(b1: Bounds, b2: Bounds): boolean {
44
+ const [min1, max1] = b1;
45
+ const [min2, max2] = b2;
46
+ return (
47
+ min1[0] < max2[0] &&
48
+ max1[0] > min2[0] &&
49
+ min1[1] < max2[1] &&
50
+ max1[1] > min2[1]
51
+ );
52
+ }
@@ -0,0 +1,12 @@
1
+ import { parseColor } from '@antv/g';
2
+
3
+ export type Color = {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ };
8
+
9
+ export function parseToRGB(c: string | Color): Color {
10
+ if (typeof c === 'object') return c;
11
+ return parseColor(c);
12
+ }
@@ -44,3 +44,15 @@ export function isCircular(coordinate: Coordinate): boolean {
44
44
  export function isTheta(coordinate: Coordinate): boolean {
45
45
  return isPolar(coordinate) && isTranspose(coordinate);
46
46
  }
47
+
48
+ export function getRadius(coordinate: Coordinate): number {
49
+ if (isCircular(coordinate)) {
50
+ const [width, height] = coordinate.getSize();
51
+ const polar = coordinate
52
+ .getOptions()
53
+ .transformations.find((t) => t[0] === 'polar');
54
+ // coordinate.size * outerRadius.
55
+ if (polar) return (Math.max(width, height) / 2) * polar[4];
56
+ }
57
+ return 0;
58
+ }
@@ -99,3 +99,7 @@ export function maybePercentage(x: number | string, size: number) {
99
99
  const px = +x.replace('%', '');
100
100
  return Number.isNaN(px) ? null : (px / 100) * size;
101
101
  }
102
+
103
+ export function isStrictObject(d: any): boolean {
104
+ return typeof d === 'object' && !(d instanceof Date) && d !== null;
105
+ }
@@ -1,7 +0,0 @@
1
- import { DodgeYLabelTransform } from 'spec';
2
- import { LabelTransformComponent as LLC } from '../runtime';
3
- export type DodgeYOptions = Omit<DodgeYLabelTransform, 'type'>;
4
- /**
5
- * An iterative dodge method avoids label overlap. (n * log(n))
6
- */
7
- export declare const DodgeY: LLC<DodgeYOptions>;
@@ -1 +0,0 @@
1
- {"version":3,"file":"dodgeY.js","sourceRoot":"src/","sources":["label-transform/dodgeY.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAIrC,SAAS,kBAAkB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED,SAAS,MAAM;IACb,MAAM,GAAG,GAAG,IAAI,GAAG,EAAQ,CAAC;IAC5B,MAAM,GAAG,GAAG,CAAC,GAAM,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,CAAC,GAAM,EAAE,KAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACtD,OAAO,CAAC,GAAG,EAAE,GAAG,CAAU,CAAC;AAC7B,CAAC;AAID,SAAS,yBAAyB,CAAC,KAAoB;IACrD,MAAM,IAAI,GAAG,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;IACxD,cAAc,IAAI,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IACnD,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,CAAC;IAEf,OAAO,E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AQ;gBAAE,MAAM;SAC7B;QAED,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YAC1B,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;SACvC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,4 +0,0 @@
1
- import { LabelTransformComponent as LLC } from '../runtime';
2
- import { HideOverlapLabelTransform } from '../spec';
3
- export type HideOverlapOptions = Omit<HideOverlapLabelTransform, 'type'>;
4
- export declare const HideOverlap: LLC<HideOverlapOptions>;
@@ -1,48 +0,0 @@
1
- import { isPolygonsIntersect } from '@antv/path-util';
2
- import { ascending } from 'd3-array';
3
- function getPoints(element) {
4
- const { min, max } = element.getRenderBounds();
5
- const [x0, y0] = min;
6
- const [x1, y1] = max;
7
- return [
8
- [x0, y0],
9
- [x0, y1],
10
- [x1, y1],
11
- [x1, y0],
12
- ];
13
- }
14
- function priority(shape) {
15
- return shape.style.priority || 0;
16
- }
17
- function show(shape) {
18
- shape.style.visibility = 'visible';
19
- }
20
- function hide(shape) {
21
- shape.style.visibility = 'hidden';
22
- }
23
- // @todo Support label shape with priority attribute.
24
- export const HideOverlap = () => {
25
- return (labels, coordinate) => {
26
- const displayLabels = [];
27
- // Label with lower priority will be hidden when overlapped.
28
- labels.sort((a, b) => ascending(priority(a), priority(b)));
29
- for (let i = 0; i < labels.length; i++) {
30
- const label = labels[i];
31
- show(label);
32
- let overlapping = false;
33
- for (let j = 0; j < displayLabels.length; j++) {
34
- const existedLabel = displayLabels[j];
35
- if (isPolygonsIntersect(getPoints(label), getPoints(existedLabel))) {
36
- hide(label);
37
- overlapping = true;
38
- break;
39
- }
40
- }
41
- if (!overlapping) {
42
- displayLabels.push(label);
43
- }
44
- }
45
- return labels;
46
- };
47
- };
48
- //# sourceMappingURL=hideOverlap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hideO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AAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;YACxB,IAAI,CAAC,KAAK,CAAC,CAAC;YAEZ,IAAI,WAAW,GAAG,KAAK,CAAC;YACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAC7C,MAAM,YAAY,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;gBACtC,IAAI,mBAAmB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE;oBAClE,IAAI,CAAC,KAAK,CAAC,CAAC;oBACZ,WAAW,GAAG,IAAI,CAAC;oBACnB,MAAM;iBACP;aACF;YAED,IAAI,CAAC,WAAW,EAAE;gBAChB,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC3B;SACF;QAED,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { SpiderLabelTransform } from '../spec';
2
- import { LabelTransformComponent as LLC } from '../runtime';
3
- export type SpiderOptions = Omit<SpiderLabelTransform, 'type'>;
4
- /**
5
- * Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
6
- */
7
- export declare const Spider: LLC<SpiderOptions>;
@@ -1,30 +0,0 @@
1
- import { isCircular } from '../utils/coordinate';
2
- import { maybePercentage } from '../utils/helper';
3
- import { sub } from '../utils/vector';
4
- /**
5
- * Spider label transform only suitable for the labels in polar coordinate, labels should distinguish coordinate type.
6
- */
7
- export const Spider = (options) => {
8
- const { edgeDistance = 0 } = options;
9
- return (labels, coordinate) => {
10
- if (!isCircular(coordinate))
11
- return labels;
12
- const { x: coordX, width } = coordinate.getOptions();
13
- const center = coordinate.getCenter();
14
- const margin = maybePercentage(edgeDistance, width);
15
- const edgeX = coordX + margin;
16
- const edgeX1 = coordX + width - margin;
17
- labels.forEach((label) => {
18
- const { x: originX, x0, y0 } = label.style;
19
- const dx = originX <= center[0] ? edgeX - originX : edgeX1 - originX;
20
- label.style.x += dx;
21
- const { x, y } = label.style;
22
- const p0 = sub([x0, y0], center);
23
- const p1 = sub([0, y], center);
24
- const p1x = p0[1] ? (p0[0] * p1[1]) / p0[1] + center[0] : x;
25
- label.style.connectorPoints = [[p1x - x, 0]];
26
- });
27
- return labels;
28
- };
29
- };
30
- //# sourceMappingURL=spider.js.map