@antv/g2 5.0.0-beta.8 → 5.0.0-beta.9

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/g2-lite.min.js +3 -3
  2. package/dist/g2.min.js +4 -4
  3. package/esm/animation/morphing.js +22 -2
  4. package/esm/animation/morphing.js.map +1 -1
  5. package/esm/api/chart.d.ts +3 -2
  6. package/esm/api/chart.js +6 -4
  7. package/esm/api/chart.js.map +1 -1
  8. package/esm/api/mark/base.d.ts +1 -1
  9. package/esm/api/mark/base.js +1 -1
  10. package/esm/api/mark/base.js.map +1 -1
  11. package/esm/component/axis.d.ts +5 -7
  12. package/esm/component/axis.js +126 -98
  13. package/esm/component/axis.js.map +1 -1
  14. package/esm/component/axisArc.d.ts +7 -0
  15. package/esm/component/axisArc.js +9 -0
  16. package/esm/component/axisArc.js.map +1 -0
  17. package/esm/component/axisRadar.d.ts +9 -0
  18. package/esm/component/axisRadar.js +46 -0
  19. package/esm/component/axisRadar.js.map +1 -0
  20. package/esm/component/axisX.d.ts +2 -1
  21. package/esm/component/axisX.js +5 -4
  22. package/esm/component/axisX.js.map +1 -1
  23. package/esm/component/axisY.d.ts +1 -1
  24. package/esm/component/axisY.js +4 -4
  25. package/esm/component/axisY.js.map +1 -1
  26. package/esm/component/index.d.ts +8 -0
  27. package/esm/component/index.js +5 -0
  28. package/esm/component/index.js.map +1 -1
  29. package/esm/component/legendCategory.d.ts +5 -3
  30. package/esm/component/legendCategory.js +80 -36
  31. package/esm/component/legendCategory.js.map +1 -1
  32. package/esm/component/legendContinuous.d.ts +3 -2
  33. package/esm/component/legendContinuous.js +66 -12
  34. package/esm/component/legendContinuous.js.map +1 -1
  35. package/esm/component/legendContinuousBlock.d.ts +4 -0
  36. package/esm/component/legendContinuousBlock.js +6 -0
  37. package/esm/component/legendContinuousBlock.js.map +1 -0
  38. package/esm/component/legendContinuousBlockSize.d.ts +4 -0
  39. package/esm/component/legendContinuousBlockSize.js +6 -0
  40. package/esm/component/legendContinuousBlockSize.js.map +1 -0
  41. package/esm/component/legendContinuousSize.d.ts +4 -0
  42. package/esm/component/legendContinuousSize.js +10 -0
  43. package/esm/component/legendContinuousSize.js.map +1 -0
  44. package/esm/component/scrollbar.js +1 -1
  45. package/esm/component/scrollbar.js.map +1 -1
  46. package/esm/component/slider.js +1 -1
  47. package/esm/component/slider.js.map +1 -1
  48. package/esm/component/title.js +1 -1
  49. package/esm/component/title.js.map +1 -1
  50. package/esm/component/utils.d.ts +12 -0
  51. package/esm/component/utils.js +35 -0
  52. package/esm/component/utils.js.map +1 -1
  53. package/esm/composition/facetCircle.js +1 -1
  54. package/esm/composition/facetCircle.js.map +1 -1
  55. package/esm/coordinate/index.d.ts +3 -3
  56. package/esm/coordinate/index.js +3 -3
  57. package/esm/coordinate/index.js.map +1 -1
  58. package/esm/coordinate/polar.d.ts +6 -0
  59. package/esm/coordinate/polar.js +18 -6
  60. package/esm/coordinate/polar.js.map +1 -1
  61. package/esm/coordinate/radial.d.ts +6 -0
  62. package/esm/coordinate/radial.js +17 -5
  63. package/esm/coordinate/radial.js.map +1 -1
  64. package/esm/coordinate/theta.d.ts +7 -0
  65. package/esm/coordinate/theta.js +16 -4
  66. package/esm/coordinate/theta.js.map +1 -1
  67. package/esm/interaction/index.d.ts +1 -0
  68. package/esm/interaction/index.js +1 -0
  69. package/esm/interaction/index.js.map +1 -1
  70. package/esm/interaction/native/brushAxisHighlight.js +6 -1
  71. package/esm/interaction/native/brushAxisHighlight.js.map +1 -1
  72. package/esm/interaction/native/brushFilter.js +1 -1
  73. package/esm/interaction/native/brushFilter.js.map +1 -1
  74. package/esm/interaction/native/legendFilter.d.ts +2 -0
  75. package/esm/interaction/native/legendFilter.js +19 -3
  76. package/esm/interaction/native/legendFilter.js.map +1 -1
  77. package/esm/interaction/native/legendHighlight.js +2 -3
  78. package/esm/interaction/native/legendHighlight.js.map +1 -1
  79. package/esm/interaction/native/poptip.d.ts +5 -0
  80. package/esm/interaction/native/poptip.js +91 -0
  81. package/esm/interaction/native/poptip.js.map +1 -0
  82. package/esm/mark/pack.js +0 -1
  83. package/esm/mark/pack.js.map +1 -1
  84. package/esm/mark/treemap.js +0 -1
  85. package/esm/mark/treemap.js.map +1 -1
  86. package/esm/runtime/component.d.ts +3 -0
  87. package/esm/runtime/component.js +246 -103
  88. package/esm/runtime/component.js.map +1 -1
  89. package/esm/runtime/coordinate.d.ts +11 -0
  90. package/esm/runtime/coordinate.js +23 -16
  91. package/esm/runtime/coordinate.js.map +1 -1
  92. package/esm/runtime/layout.d.ts +1 -1
  93. package/esm/runtime/layout.js +145 -76
  94. package/esm/runtime/layout.js.map +1 -1
  95. package/esm/runtime/plot.js +1 -0
  96. package/esm/runtime/plot.js.map +1 -1
  97. package/esm/runtime/scale.d.ts +2 -1
  98. package/esm/runtime/scale.js +35 -0
  99. package/esm/runtime/scale.js.map +1 -1
  100. package/esm/runtime/transform.js +1 -1
  101. package/esm/runtime/transform.js.map +1 -1
  102. package/esm/runtime/types/common.d.ts +11 -2
  103. package/esm/runtime/types/component.d.ts +9 -7
  104. package/esm/runtime/types/options.d.ts +5 -5
  105. package/esm/runtime/types/scale.d.ts +18 -0
  106. package/esm/runtime/types/scale.js +19 -0
  107. package/esm/runtime/types/scale.js.map +1 -0
  108. package/esm/runtime/types/theme.d.ts +2 -1
  109. package/esm/shape/connector/connector.js +1 -1
  110. package/esm/shape/utils.js.map +1 -1
  111. package/esm/spec/geometry.d.ts +1 -1
  112. package/esm/spec/interaction.d.ts +11 -6
  113. package/esm/stdlib/index.js +3 -3
  114. package/esm/stdlib/index.js.map +1 -1
  115. package/esm/theme/academy.js +10 -4
  116. package/esm/theme/academy.js.map +1 -1
  117. package/esm/theme/dark.js +10 -4
  118. package/esm/theme/dark.js.map +1 -1
  119. package/esm/theme/light.js +12 -4
  120. package/esm/theme/light.js.map +1 -1
  121. package/esm/utils/angle.d.ts +2 -0
  122. package/esm/utils/angle.js +7 -0
  123. package/esm/utils/angle.js.map +1 -0
  124. package/esm/utils/array.d.ts +8 -0
  125. package/esm/utils/array.js +35 -0
  126. package/esm/utils/array.js.map +1 -1
  127. package/esm/utils/coordinate.d.ts +4 -0
  128. package/esm/utils/coordinate.js +19 -0
  129. package/esm/utils/coordinate.js.map +1 -1
  130. package/lib/animation/morphing.js +22 -2
  131. package/lib/animation/morphing.js.map +1 -1
  132. package/lib/api/chart.d.ts +3 -2
  133. package/lib/api/chart.js +6 -4
  134. package/lib/api/chart.js.map +1 -1
  135. package/lib/api/mark/base.d.ts +1 -1
  136. package/lib/api/mark/base.js +1 -1
  137. package/lib/api/mark/base.js.map +1 -1
  138. package/lib/component/axis.d.ts +5 -7
  139. package/lib/component/axis.js +127 -100
  140. package/lib/component/axis.js.map +1 -1
  141. package/lib/component/axisArc.d.ts +7 -0
  142. package/lib/component/axisArc.js +13 -0
  143. package/lib/component/axisArc.js.map +1 -0
  144. package/lib/component/axisRadar.d.ts +9 -0
  145. package/lib/component/axisRadar.js +50 -0
  146. package/lib/component/axisRadar.js.map +1 -0
  147. package/lib/component/axisX.d.ts +2 -1
  148. package/lib/component/axisX.js +6 -4
  149. package/lib/component/axisX.js.map +1 -1
  150. package/lib/component/axisY.d.ts +1 -1
  151. package/lib/component/axisY.js +3 -3
  152. package/lib/component/axisY.js.map +1 -1
  153. package/lib/component/index.d.ts +8 -0
  154. package/lib/component/index.js +12 -1
  155. package/lib/component/index.js.map +1 -1
  156. package/lib/component/legendCategory.d.ts +5 -3
  157. package/lib/component/legendCategory.js +79 -35
  158. package/lib/component/legendCategory.js.map +1 -1
  159. package/lib/component/legendContinuous.d.ts +3 -2
  160. package/lib/component/legendContinuous.js +65 -11
  161. package/lib/component/legendContinuous.js.map +1 -1
  162. package/lib/component/legendContinuousBlock.d.ts +4 -0
  163. package/lib/component/legendContinuousBlock.js +10 -0
  164. package/lib/component/legendContinuousBlock.js.map +1 -0
  165. package/lib/component/legendContinuousBlockSize.d.ts +4 -0
  166. package/lib/component/legendContinuousBlockSize.js +10 -0
  167. package/lib/component/legendContinuousBlockSize.js.map +1 -0
  168. package/lib/component/legendContinuousSize.d.ts +4 -0
  169. package/lib/component/legendContinuousSize.js +14 -0
  170. package/lib/component/legendContinuousSize.js.map +1 -0
  171. package/lib/component/scrollbar.js +1 -1
  172. package/lib/component/scrollbar.js.map +1 -1
  173. package/lib/component/slider.js +1 -1
  174. package/lib/component/slider.js.map +1 -1
  175. package/lib/component/title.js +1 -1
  176. package/lib/component/title.js.map +1 -1
  177. package/lib/component/utils.d.ts +12 -0
  178. package/lib/component/utils.js +39 -1
  179. package/lib/component/utils.js.map +1 -1
  180. package/lib/composition/facetCircle.js +1 -1
  181. package/lib/composition/facetCircle.js.map +1 -1
  182. package/lib/coordinate/index.d.ts +3 -3
  183. package/lib/coordinate/index.js +4 -1
  184. package/lib/coordinate/index.js.map +1 -1
  185. package/lib/coordinate/polar.d.ts +6 -0
  186. package/lib/coordinate/polar.js +20 -7
  187. package/lib/coordinate/polar.js.map +1 -1
  188. package/lib/coordinate/radial.d.ts +6 -0
  189. package/lib/coordinate/radial.js +19 -6
  190. package/lib/coordinate/radial.js.map +1 -1
  191. package/lib/coordinate/theta.d.ts +7 -0
  192. package/lib/coordinate/theta.js +18 -5
  193. package/lib/coordinate/theta.js.map +1 -1
  194. package/lib/interaction/index.d.ts +1 -0
  195. package/lib/interaction/index.js +3 -1
  196. package/lib/interaction/index.js.map +1 -1
  197. package/lib/interaction/native/brushAxisHighlight.js +6 -1
  198. package/lib/interaction/native/brushAxisHighlight.js.map +1 -1
  199. package/lib/interaction/native/brushFilter.js +1 -1
  200. package/lib/interaction/native/brushFilter.js.map +1 -1
  201. package/lib/interaction/native/legendFilter.d.ts +2 -0
  202. package/lib/interaction/native/legendFilter.js +22 -4
  203. package/lib/interaction/native/legendFilter.js.map +1 -1
  204. package/lib/interaction/native/legendHighlight.js +1 -2
  205. package/lib/interaction/native/legendHighlight.js.map +1 -1
  206. package/lib/interaction/native/poptip.d.ts +5 -0
  207. package/lib/interaction/native/poptip.js +95 -0
  208. package/lib/interaction/native/poptip.js.map +1 -0
  209. package/lib/mark/pack.js +0 -1
  210. package/lib/mark/pack.js.map +1 -1
  211. package/lib/mark/treemap.js +0 -1
  212. package/lib/mark/treemap.js.map +1 -1
  213. package/lib/runtime/component.d.ts +3 -0
  214. package/lib/runtime/component.js +250 -107
  215. package/lib/runtime/component.js.map +1 -1
  216. package/lib/runtime/coordinate.d.ts +11 -0
  217. package/lib/runtime/coordinate.js +26 -17
  218. package/lib/runtime/coordinate.js.map +1 -1
  219. package/lib/runtime/layout.d.ts +1 -1
  220. package/lib/runtime/layout.js +146 -77
  221. package/lib/runtime/layout.js.map +1 -1
  222. package/lib/runtime/plot.js +1 -0
  223. package/lib/runtime/plot.js.map +1 -1
  224. package/lib/runtime/scale.d.ts +2 -1
  225. package/lib/runtime/scale.js +37 -1
  226. package/lib/runtime/scale.js.map +1 -1
  227. package/lib/runtime/transform.js +1 -1
  228. package/lib/runtime/transform.js.map +1 -1
  229. package/lib/runtime/types/common.d.ts +11 -2
  230. package/lib/runtime/types/component.d.ts +9 -7
  231. package/lib/runtime/types/options.d.ts +5 -5
  232. package/lib/runtime/types/scale.d.ts +18 -0
  233. package/lib/runtime/types/scale.js +22 -0
  234. package/lib/runtime/types/scale.js.map +1 -0
  235. package/lib/runtime/types/theme.d.ts +2 -1
  236. package/lib/shape/connector/connector.js +1 -1
  237. package/lib/shape/utils.js.map +1 -1
  238. package/lib/spec/geometry.d.ts +1 -1
  239. package/lib/spec/interaction.d.ts +11 -6
  240. package/lib/stdlib/index.js +1 -1
  241. package/lib/stdlib/index.js.map +1 -1
  242. package/lib/theme/academy.js +10 -4
  243. package/lib/theme/academy.js.map +1 -1
  244. package/lib/theme/dark.js +10 -4
  245. package/lib/theme/dark.js.map +1 -1
  246. package/lib/theme/light.js +12 -4
  247. package/lib/theme/light.js.map +1 -1
  248. package/lib/utils/angle.d.ts +2 -0
  249. package/lib/utils/angle.js +12 -0
  250. package/lib/utils/angle.js.map +1 -0
  251. package/lib/utils/array.d.ts +8 -0
  252. package/lib/utils/array.js +38 -1
  253. package/lib/utils/array.js.map +1 -1
  254. package/lib/utils/coordinate.d.ts +4 -0
  255. package/lib/utils/coordinate.js +24 -1
  256. package/lib/utils/coordinate.js.map +1 -1
  257. package/package.json +5 -6
  258. package/src/animation/morphing.ts +23 -2
  259. package/src/api/chart.ts +8 -6
  260. package/src/api/mark/base.ts +1 -1
  261. package/src/component/axis.ts +199 -125
  262. package/src/component/axisArc.ts +16 -0
  263. package/src/component/axisRadar.ts +73 -0
  264. package/src/component/axisX.ts +7 -4
  265. package/src/component/axisY.ts +4 -4
  266. package/src/component/index.ts +8 -0
  267. package/src/component/legendCategory.ts +156 -35
  268. package/src/component/legendContinuous.ts +121 -30
  269. package/src/component/legendContinuousBlock.ts +17 -0
  270. package/src/component/legendContinuousBlockSize.ts +22 -0
  271. package/src/component/legendContinuousSize.ts +27 -0
  272. package/src/component/scrollbar.ts +1 -1
  273. package/src/component/slider.ts +1 -1
  274. package/src/component/title.ts +1 -1
  275. package/src/component/utils.ts +46 -0
  276. package/src/composition/facetCircle.ts +1 -1
  277. package/src/coordinate/index.ts +3 -3
  278. package/src/coordinate/polar.ts +19 -11
  279. package/src/coordinate/radial.ts +19 -10
  280. package/src/coordinate/theta.ts +18 -9
  281. package/src/interaction/index.ts +1 -0
  282. package/src/interaction/native/brushAxisHighlight.ts +9 -1
  283. package/src/interaction/native/brushFilter.ts +1 -1
  284. package/src/interaction/native/legendFilter.ts +21 -3
  285. package/src/interaction/native/legendHighlight.ts +2 -3
  286. package/src/interaction/native/poptip.ts +87 -0
  287. package/src/mark/pack.ts +0 -1
  288. package/src/mark/treemap.ts +0 -1
  289. package/src/runtime/component.ts +335 -124
  290. package/src/runtime/coordinate.ts +29 -16
  291. package/src/runtime/layout.ts +206 -97
  292. package/src/runtime/plot.ts +1 -0
  293. package/src/runtime/scale.ts +41 -0
  294. package/src/runtime/transform.ts +3 -0
  295. package/src/runtime/types/common.ts +23 -10
  296. package/src/runtime/types/component.ts +19 -10
  297. package/src/runtime/types/options.ts +15 -15
  298. package/src/runtime/types/scale.ts +20 -0
  299. package/src/runtime/types/theme.ts +2 -1
  300. package/src/shape/connector/connector.ts +1 -1
  301. package/src/shape/utils.ts +2 -0
  302. package/src/spec/geometry.ts +3 -1
  303. package/src/spec/interaction.ts +16 -8
  304. package/src/stdlib/index.ts +14 -0
  305. package/src/theme/academy.ts +10 -4
  306. package/src/theme/dark.ts +10 -4
  307. package/src/theme/light.ts +12 -4
  308. package/src/utils/angle.ts +7 -0
  309. package/src/utils/array.ts +39 -0
  310. package/src/utils/coordinate.ts +29 -0
  311. package/src/.DS_Store +0 -0
  312. package/src/data/.DS_Store +0 -0
  313. package/src/shape/.DS_Store +0 -0
@@ -5,17 +5,26 @@ import { Transpose } from './transpose';
5
5
 
6
6
  export type ThetaOptions = ThetaCoordinate;
7
7
 
8
+ export const getThetaOptions = (options: ThetaOptions = {}) => {
9
+ const defaultOptions = {
10
+ startAngle: -Math.PI / 2,
11
+ endAngle: (Math.PI * 3) / 2,
12
+ innerRadius: 0,
13
+ outerRadius: 1,
14
+ };
15
+ return { ...defaultOptions, ...options };
16
+ };
17
+
8
18
  /**
9
19
  * Theta = Transpose + Polar.
10
20
  */
11
- export const Theta: CC<ThetaOptions> = ({
12
- startAngle = -Math.PI / 2,
13
- endAngle = (Math.PI * 3) / 2,
14
- innerRadius = 0,
15
- outerRadius = 1,
16
- }) => [
17
- ...Transpose(),
18
- ...Polar({ startAngle, endAngle, innerRadius, outerRadius }),
19
- ];
21
+ export const Theta: CC<ThetaOptions> = (options) => {
22
+ const { startAngle, endAngle, innerRadius, outerRadius } =
23
+ getThetaOptions(options);
24
+ return [
25
+ ...Transpose(),
26
+ ...Polar({ startAngle, endAngle, innerRadius, outerRadius }),
27
+ ];
28
+ };
20
29
 
21
30
  Theta.props = {};
@@ -19,6 +19,7 @@ export { BrushFilter } from './native/brushFilter';
19
19
  export { BrushXFilter } from './native/brushXFilter';
20
20
  export { BrushYFilter } from './native/brushYFilter';
21
21
  export { SliderFilter } from './native/sliderFilter';
22
+ export { Poptip } from './native/poptip';
22
23
 
23
24
  export { LEGEND_ITEMS_CLASS_NAME } from './native/legendFilter';
24
25
 
@@ -185,7 +185,15 @@ export function BrushAxisHighlight(options) {
185
185
  offsetY: y0,
186
186
  offsetX: x0,
187
187
  points: (element) => element.__data__.points,
188
- horizontal: (axis) => axis.attributes.horizontal,
188
+ horizontal: (axis) => {
189
+ const {
190
+ startPos: [sx, sy],
191
+ endPos: [ex, ey],
192
+ } = axis.attributes;
193
+ // attention, non-horizontal does not mean vertical
194
+ // it may has a specific degree angle
195
+ return sx !== ex && sy === ey;
196
+ },
189
197
  datum: createDatumof(view),
190
198
  unhighlightedOpacity: 0.5,
191
199
  ...options,
@@ -60,7 +60,7 @@ export function brushFilter(
60
60
 
61
61
  return () => {
62
62
  brush.destroy();
63
- root.removeEventListener('dblclick', click);
63
+ root.removeEventListener('click', click);
64
64
  };
65
65
  }
66
66
 
@@ -27,11 +27,28 @@ export function legendsOf(root) {
27
27
  return root.getElementsByClassName(CATEGORY_LEGEND_CLASS_NAME);
28
28
  }
29
29
 
30
+ export function dataOf(root) {
31
+ // legend -> layout -> container
32
+ let parent = root.parentNode;
33
+ while (parent && !parent.__data__) {
34
+ parent = parent.parentNode;
35
+ }
36
+ return parent.__data__;
37
+ }
38
+
39
+ export function attributesOf(root) {
40
+ let child = root;
41
+ while (child && !child.attr('class').startsWith('legend')) {
42
+ child = child.children[0];
43
+ }
44
+ return child.attributes;
45
+ }
46
+
30
47
  function builtInAccessors(selectedLegend) {
31
48
  // Get the value and scale type from legend.
32
- const { data } = selectedLegend.attributes;
33
- const { __data__ } = selectedLegend.parentNode;
34
- const { name: channel } = __data__.scale;
49
+ const { data } = attributesOf(selectedLegend);
50
+ // In theory, scales' channels are the same
51
+ const { name: channel } = dataOf(selectedLegend).scales[0];
35
52
  return [
36
53
  channel,
37
54
  {
@@ -70,6 +87,7 @@ function legendFilter(
70
87
  ? {
71
88
  labelUnselectedFill: '#aaa',
72
89
  markerUnselectedFill: '#aaa',
90
+ markerUnselectedStroke: '#aaa',
73
91
  }
74
92
  : options;
75
93
  const markerStyle = subObject(style, 'marker');
@@ -1,7 +1,7 @@
1
1
  import { group } from 'd3-array';
2
2
  import { subObject } from '../../utils/helper';
3
3
  import { selectG2Elements, useState } from './utils';
4
- import { markerOf, labelOf, itemsOf, legendsOf } from './legendFilter';
4
+ import { markerOf, labelOf, itemsOf, legendsOf, dataOf } from './legendFilter';
5
5
 
6
6
  export function LegendHighlight({ channel, ...rest }) {
7
7
  return (context) => {
@@ -9,8 +9,7 @@ export function LegendHighlight({ channel, ...rest }) {
9
9
  const legends = legendsOf(container);
10
10
  const elements = selectG2Elements(container);
11
11
  const channelOf = (legend) => {
12
- const { __data__ } = legend.parentNode;
13
- return __data__.scale.name;
12
+ return dataOf(legend).scales[0].name;
14
13
  };
15
14
  const scaleOf = (channel) => {
16
15
  const {
@@ -0,0 +1,87 @@
1
+ import { DisplayObject, HTML } from '@antv/g';
2
+ import { kebabCase } from '../../utils/string';
3
+ import { subObject } from '../../utils/helper';
4
+
5
+ function dom(tag, children, style) {
6
+ return `<${tag} style="${Object.entries(style)
7
+ .map(([key, value]) => `${kebabCase(key)}:${value}`)
8
+ .join(';')}">${children}</${tag}>`;
9
+ }
10
+
11
+ const defaultTipStyle = {
12
+ backgroundColor: 'rgba(0,0,0,0.75)',
13
+ color: '#fff',
14
+ width: 'max-content',
15
+ padding: '1px 4px',
16
+ fontSize: '12px',
17
+ borderRadius: '2.5px',
18
+ boxShadow:
19
+ '0 3px 6px -4px rgba(0,0,0,0.12), 0 6px 16px 0 rgba(0,0,0,0.08), 0 9px 28px 8px rgba(0,0,0,0.05)',
20
+ };
21
+
22
+ function isTipText(element) {
23
+ if (element.nodeName !== 'text') return false;
24
+ if (element.isOverflowing()) return true;
25
+ return false;
26
+ }
27
+
28
+ export function Poptip({ offsetX = 8, offsetY = 8, ...style }) {
29
+ return (context) => {
30
+ const { container } = context;
31
+ const [x0, y0] = container.getBounds().min;
32
+ const tipStyle = subObject(style, 'tip');
33
+ const tips = new Set();
34
+
35
+ const pointerover = (e) => {
36
+ const { target } = e;
37
+ if (!isTipText(target)) {
38
+ e.stopPropagation();
39
+ return;
40
+ }
41
+ const { offsetX: mouseX, offsetY: mouseY } = e;
42
+ const x = mouseX + offsetX - x0;
43
+ const y = mouseY + offsetY - y0;
44
+ if (target.tip) {
45
+ target.tip.style.x = x;
46
+ target.tip.style.y = y;
47
+ return;
48
+ }
49
+ const { text } = target.style;
50
+ const tipELement = new HTML({
51
+ className: 'poptip',
52
+ style: {
53
+ innerHTML: dom('div', text, {
54
+ ...defaultTipStyle,
55
+ ...tipStyle,
56
+ }),
57
+ x,
58
+ y,
59
+ },
60
+ });
61
+ container.appendChild(tipELement);
62
+ target.tip = tipELement;
63
+ tips.add(tipELement);
64
+ };
65
+
66
+ const pointerout = (e) => {
67
+ const { target } = e;
68
+ if (!isTipText(target)) {
69
+ e.stopPropagation();
70
+ return;
71
+ }
72
+ if (!target.tip) return;
73
+ target.tip.remove();
74
+ target.tip = null;
75
+ tips.delete(target.tip);
76
+ };
77
+
78
+ container.addEventListener('pointerover', pointerover);
79
+ container.addEventListener('pointerout', pointerout);
80
+
81
+ return () => {
82
+ container.removeEventListener('pointerover', pointerover);
83
+ container.removeEventListener('pointerout', pointerout);
84
+ tips.forEach((tip) => (tip as DisplayObject).remove());
85
+ };
86
+ };
87
+ }
package/src/mark/pack.ts CHANGED
@@ -74,7 +74,6 @@ export const Pack: CC<PackOptions> = (markOptions) => {
74
74
  wordWrap: true,
75
75
  maxLines: 1,
76
76
  wordWrapWidth: (d) => d.r * 2,
77
- lineHeight: (d) => d.r * 2,
78
77
  };
79
78
  const transformedData = dataTransform(
80
79
  data,
@@ -158,7 +158,6 @@ export const Treemap: CC<TreemapOptions> = (options) => {
158
158
  wordWrap: true,
159
159
  maxLines: 1,
160
160
  wordWrapWidth: (d) => d.x1 - d.x0,
161
- lineHeight: (d) => d.y1 - d.y0,
162
161
  };
163
162
  const transformedData = dataTransform(
164
163
  data,