billboard.js 4.1.4 → 4.2.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/dist/billboard.css +87 -1
  2. package/dist/billboard.js +11129 -7032
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +20 -20
  5. package/dist/billboard.pkgd.js +22703 -14154
  6. package/dist/billboard.pkgd.min.js +37 -37
  7. package/dist/billboard.react.js +5 -5
  8. package/dist/billboard.react.min.js +2 -2
  9. package/dist/billboard.worker.js +1 -1
  10. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-sparkline.js +21 -4
  13. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  14. package/dist/plugin/billboardjs-plugin-stanford.js +22 -13
  15. package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
  16. package/dist/plugin/billboardjs-plugin-tableview.js +20 -3
  17. package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
  18. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  19. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1689 -1252
  21. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
  22. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2288 -1012
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6350 -2390
  25. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -18
  26. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1310 -1006
  27. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -10
  28. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1293 -1006
  29. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
  30. package/dist/theme/dark.css +90 -1
  31. package/dist/theme/dark.min.css +2 -2
  32. package/dist/theme/datalab.css +87 -1
  33. package/dist/theme/datalab.min.css +2 -2
  34. package/dist/theme/graph.css +87 -1
  35. package/dist/theme/graph.min.css +2 -2
  36. package/dist/theme/insight.css +87 -1
  37. package/dist/theme/insight.min.css +2 -2
  38. package/dist/theme/modern.css +87 -1
  39. package/dist/theme/modern.min.css +2 -2
  40. package/dist-esm/Chart/Chart.js +5 -5
  41. package/dist-esm/Chart/api/axis.js +2 -3
  42. package/dist-esm/Chart/api/category.js +2 -3
  43. package/dist-esm/Chart/api/chart.js +3 -4
  44. package/dist-esm/Chart/api/color.js +2 -3
  45. package/dist-esm/Chart/api/data.js +3 -4
  46. package/dist-esm/Chart/api/export.js +3 -4
  47. package/dist-esm/Chart/api/flow.js +15 -9
  48. package/dist-esm/Chart/api/focus.js +5 -3
  49. package/dist-esm/Chart/api/grid.js +2 -3
  50. package/dist-esm/Chart/api/group.js +2 -3
  51. package/dist-esm/Chart/api/legend.js +1 -2
  52. package/dist-esm/Chart/api/load.js +3 -4
  53. package/dist-esm/Chart/api/regions.js +3 -4
  54. package/dist-esm/Chart/api/selection.js +3 -4
  55. package/dist-esm/Chart/api/show.js +2 -3
  56. package/dist-esm/Chart/api/stubs.js +3 -4
  57. package/dist-esm/Chart/api/subchart.js +4 -5
  58. package/dist-esm/Chart/api/tooltip.js +28 -9
  59. package/dist-esm/Chart/api/x.js +2 -3
  60. package/dist-esm/Chart/api/zoom.js +6 -7
  61. package/dist-esm/ChartInternal/Axis/Axis.js +5 -6
  62. package/dist-esm/ChartInternal/Axis/AxisRenderer.js +26 -17
  63. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +40 -12
  64. package/dist-esm/ChartInternal/ChartInternal.js +39 -24
  65. package/dist-esm/ChartInternal/data/convert.helper.js +2 -3
  66. package/dist-esm/ChartInternal/data/convert.js +3 -4
  67. package/dist-esm/ChartInternal/data/data.js +18 -11
  68. package/dist-esm/ChartInternal/data/load.js +4 -5
  69. package/dist-esm/ChartInternal/interactions/drag.js +3 -4
  70. package/dist-esm/ChartInternal/interactions/eventrect.js +4 -5
  71. package/dist-esm/ChartInternal/interactions/flow.js +25 -19
  72. package/dist-esm/ChartInternal/interactions/interaction.js +14 -13
  73. package/dist-esm/ChartInternal/interactions/subchart.js +5 -6
  74. package/dist-esm/ChartInternal/interactions/zoom.js +4 -5
  75. package/dist-esm/ChartInternal/internals/category.js +2 -3
  76. package/dist-esm/ChartInternal/internals/class.js +5 -5
  77. package/dist-esm/ChartInternal/internals/clip.js +2 -3
  78. package/dist-esm/ChartInternal/internals/color.js +4 -5
  79. package/dist-esm/ChartInternal/internals/domain.js +7 -7
  80. package/dist-esm/ChartInternal/internals/format.js +3 -4
  81. package/dist-esm/ChartInternal/internals/grid.js +4 -5
  82. package/dist-esm/ChartInternal/internals/legend.js +7 -7
  83. package/dist-esm/ChartInternal/internals/redraw.js +13 -13
  84. package/dist-esm/ChartInternal/internals/region.js +4 -5
  85. package/dist-esm/ChartInternal/internals/scale.js +2 -3
  86. package/dist-esm/ChartInternal/internals/selection.js +3 -4
  87. package/dist-esm/ChartInternal/internals/size.axis.js +2 -3
  88. package/dist-esm/ChartInternal/internals/size.js +8 -9
  89. package/dist-esm/ChartInternal/internals/style.js +4 -5
  90. package/dist-esm/ChartInternal/internals/subchart.util.js +2 -3
  91. package/dist-esm/ChartInternal/internals/text.arc.js +3 -4
  92. package/dist-esm/ChartInternal/internals/text.js +22 -23
  93. package/dist-esm/ChartInternal/internals/text.util.js +4 -5
  94. package/dist-esm/ChartInternal/internals/title.js +4 -5
  95. package/dist-esm/ChartInternal/internals/tooltip.js +42 -23
  96. package/dist-esm/ChartInternal/internals/transform.js +5 -6
  97. package/dist-esm/ChartInternal/internals/type.js +78 -11
  98. package/dist-esm/ChartInternal/shape/arc.js +5 -6
  99. package/dist-esm/ChartInternal/shape/area.js +4 -5
  100. package/dist-esm/ChartInternal/shape/bar.js +5 -6
  101. package/dist-esm/ChartInternal/shape/boxplot.js +111 -0
  102. package/dist-esm/ChartInternal/shape/bubble.js +2 -3
  103. package/dist-esm/ChartInternal/shape/bullet.js +213 -0
  104. package/dist-esm/ChartInternal/shape/candlestick.js +5 -6
  105. package/dist-esm/ChartInternal/shape/core/barRadius.js +2 -3
  106. package/dist-esm/ChartInternal/shape/core/boxplot.js +192 -0
  107. package/dist-esm/ChartInternal/shape/core/bubble.js +4 -5
  108. package/dist-esm/ChartInternal/shape/core/bullet.js +528 -0
  109. package/dist-esm/ChartInternal/shape/core/candlestick.js +2 -3
  110. package/dist-esm/ChartInternal/shape/core/dataRegion.js +2 -3
  111. package/dist-esm/ChartInternal/shape/core/geometry.js +2 -3
  112. package/dist-esm/ChartInternal/shape/core/heatmap.js +453 -0
  113. package/dist-esm/ChartInternal/shape/core/path.js +2 -3
  114. package/dist-esm/ChartInternal/shape/core/point.js +2 -3
  115. package/dist-esm/ChartInternal/shape/core/sankey.js +576 -0
  116. package/dist-esm/ChartInternal/shape/core/treemap.js +2 -3
  117. package/dist-esm/ChartInternal/shape/funnel.js +45 -6
  118. package/dist-esm/ChartInternal/shape/gauge.js +3 -4
  119. package/dist-esm/ChartInternal/shape/heatmap.js +144 -0
  120. package/dist-esm/ChartInternal/shape/line.js +7 -8
  121. package/dist-esm/ChartInternal/shape/point.js +9 -9
  122. package/dist-esm/ChartInternal/shape/polar.js +3 -4
  123. package/dist-esm/ChartInternal/shape/radar.js +19 -7
  124. package/dist-esm/ChartInternal/shape/sankey.js +154 -0
  125. package/dist-esm/ChartInternal/shape/shape.js +15 -11
  126. package/dist-esm/ChartInternal/shape/treemap.js +8 -5
  127. package/dist-esm/canvas/CanvasAxisRenderer.js +28 -328
  128. package/dist-esm/canvas/CanvasEngine.js +2 -3
  129. package/dist-esm/canvas/CanvasPainter.js +2 -3
  130. package/dist-esm/canvas/CanvasRenderer.js +38 -408
  131. package/dist-esm/canvas/CanvasTheme.js +28 -8
  132. package/dist-esm/canvas/HitDetector.js +20 -24
  133. package/dist-esm/canvas/axisTicks.js +5 -6
  134. package/dist-esm/canvas/boxplot.js +201 -0
  135. package/dist-esm/canvas/bullet.js +212 -0
  136. package/dist-esm/canvas/classes.js +2 -3
  137. package/dist-esm/canvas/color.js +2 -3
  138. package/dist-esm/canvas/flow.js +190 -0
  139. package/dist-esm/canvas/geometry.js +2 -3
  140. package/dist-esm/canvas/grid.js +206 -0
  141. package/dist-esm/canvas/heatmap.js +141 -0
  142. package/dist-esm/canvas/labels.js +3 -4
  143. package/dist-esm/canvas/pointPattern.js +2 -3
  144. package/dist-esm/canvas/sankey.js +137 -0
  145. package/dist-esm/canvas/selection.js +473 -0
  146. package/dist-esm/canvas/subchart.js +814 -0
  147. package/dist-esm/canvas/treemap.js +100 -0
  148. package/dist-esm/canvas/util.js +2 -3
  149. package/dist-esm/config/Options/Options.js +3 -4
  150. package/dist-esm/config/Options/axis/axis.js +2 -3
  151. package/dist-esm/config/Options/axis/x.js +2 -3
  152. package/dist-esm/config/Options/axis/y.js +2 -3
  153. package/dist-esm/config/Options/axis/y2.js +14 -3
  154. package/dist-esm/config/Options/common/boost.js +2 -3
  155. package/dist-esm/config/Options/common/color.js +2 -3
  156. package/dist-esm/config/Options/common/grid.js +2 -3
  157. package/dist-esm/config/Options/common/legend.js +2 -3
  158. package/dist-esm/config/Options/common/main.js +2 -3
  159. package/dist-esm/config/Options/common/point.js +2 -3
  160. package/dist-esm/config/Options/common/title.js +2 -3
  161. package/dist-esm/config/Options/common/tooltip.js +2 -3
  162. package/dist-esm/config/Options/data/axis.js +2 -3
  163. package/dist-esm/config/Options/data/data.js +49 -4
  164. package/dist-esm/config/Options/data/selection.js +2 -3
  165. package/dist-esm/config/Options/interaction/interaction.js +2 -3
  166. package/dist-esm/config/Options/interaction/subchart.js +6 -3
  167. package/dist-esm/config/Options/interaction/zoom.js +2 -3
  168. package/dist-esm/config/Options/shape/arc.js +2 -3
  169. package/dist-esm/config/Options/shape/area.js +2 -3
  170. package/dist-esm/config/Options/shape/bar.js +2 -3
  171. package/dist-esm/config/Options/shape/boxplot.js +106 -0
  172. package/dist-esm/config/Options/shape/bubble.js +2 -3
  173. package/dist-esm/config/Options/shape/bullet.js +177 -0
  174. package/dist-esm/config/Options/shape/candlestick.js +2 -3
  175. package/dist-esm/config/Options/shape/donut.js +2 -3
  176. package/dist-esm/config/Options/shape/funnel.js +2 -3
  177. package/dist-esm/config/Options/shape/gauge.js +2 -3
  178. package/dist-esm/config/Options/shape/heatmap.js +137 -0
  179. package/dist-esm/config/Options/shape/line.js +2 -3
  180. package/dist-esm/config/Options/shape/pie.js +2 -3
  181. package/dist-esm/config/Options/shape/polar.js +2 -3
  182. package/dist-esm/config/Options/shape/radar.js +2 -3
  183. package/dist-esm/config/Options/shape/sankey.js +116 -0
  184. package/dist-esm/config/Options/shape/scatter.js +2 -3
  185. package/dist-esm/config/Options/shape/spline.js +2 -3
  186. package/dist-esm/config/Options/shape/treemap.js +2 -3
  187. package/dist-esm/config/Store/Element.js +2 -3
  188. package/dist-esm/config/Store/State.js +4 -4
  189. package/dist-esm/config/Store/Store.js +2 -3
  190. package/dist-esm/config/classes.js +2 -4
  191. package/dist-esm/config/config.js +2 -3
  192. package/dist-esm/config/const.js +31 -23
  193. package/dist-esm/config/resolver/axis.core.js +4 -5
  194. package/dist-esm/config/resolver/axis.js +2 -3
  195. package/dist-esm/config/resolver/canvas.js +113 -900
  196. package/dist-esm/config/resolver/canvasBoxplot.js +49 -0
  197. package/dist-esm/config/resolver/canvasBullet.js +29 -0
  198. package/dist-esm/config/resolver/canvasFlow.js +28 -0
  199. package/dist-esm/config/resolver/canvasGrid.js +27 -0
  200. package/dist-esm/config/resolver/canvasHeatmap.js +31 -0
  201. package/dist-esm/config/resolver/canvasSankey.js +31 -0
  202. package/dist-esm/config/resolver/canvasSelection.js +30 -0
  203. package/dist-esm/config/resolver/canvasShape.js +13 -12
  204. package/dist-esm/config/resolver/canvasSubchart.js +30 -0
  205. package/dist-esm/config/resolver/canvasType.js +48 -0
  206. package/dist-esm/config/resolver/category.js +3 -4
  207. package/dist-esm/config/resolver/customType.js +58 -0
  208. package/dist-esm/config/resolver/export.js +3 -4
  209. package/dist-esm/config/resolver/flow.js +5 -6
  210. package/dist-esm/config/resolver/grid.js +6 -7
  211. package/dist-esm/config/resolver/interaction/selection.js +6 -7
  212. package/dist-esm/config/resolver/interaction/subchart.js +6 -7
  213. package/dist-esm/config/resolver/interaction/zoom.js +6 -7
  214. package/dist-esm/config/resolver/regions.js +5 -6
  215. package/dist-esm/config/resolver/shape/arc.helpers.js +5 -6
  216. package/dist-esm/config/resolver/shape/area.js +3 -4
  217. package/dist-esm/config/resolver/shape/axis.helpers.js +2 -3
  218. package/dist-esm/config/resolver/shape/bar.js +5 -6
  219. package/dist-esm/config/resolver/shape/boxplot.js +30 -0
  220. package/dist-esm/config/resolver/shape/bubble.js +5 -6
  221. package/dist-esm/config/resolver/shape/bullet.js +23 -0
  222. package/dist-esm/config/resolver/shape/candlestick.js +5 -6
  223. package/dist-esm/config/resolver/shape/donut.js +2 -3
  224. package/dist-esm/config/resolver/shape/funnel.js +7 -6
  225. package/dist-esm/config/resolver/shape/gauge.js +4 -5
  226. package/dist-esm/config/resolver/shape/heatmap.js +23 -0
  227. package/dist-esm/config/resolver/shape/line.js +2 -3
  228. package/dist-esm/config/resolver/shape/pie.js +3 -4
  229. package/dist-esm/config/resolver/shape/polar.js +4 -5
  230. package/dist-esm/config/resolver/shape/radar.js +5 -6
  231. package/dist-esm/config/resolver/shape/sankey.js +23 -0
  232. package/dist-esm/config/resolver/shape/scatter.js +4 -5
  233. package/dist-esm/config/resolver/shape/treemap.js +4 -5
  234. package/dist-esm/core.js +5 -6
  235. package/dist-esm/index.canvas.js +13 -9
  236. package/dist-esm/index.esm.js +6 -2
  237. package/dist-esm/module/Cache.js +2 -3
  238. package/dist-esm/module/browser.js +2 -3
  239. package/dist-esm/module/dsv.js +2 -3
  240. package/dist-esm/module/error.js +23 -16
  241. package/dist-esm/module/generator.js +3 -4
  242. package/dist-esm/module/sanitize.js +2 -3
  243. package/dist-esm/module/util/brush.js +2 -3
  244. package/dist-esm/module/util/dom.js +3 -4
  245. package/dist-esm/module/util/object.js +13 -6
  246. package/dist-esm/module/util/type-checks.js +2 -3
  247. package/dist-esm/module/worker.js +2 -3
  248. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +6 -10
  249. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -18
  250. package/dist-esm/plugin/billboardjs-plugin-stanford.js +17 -45
  251. package/dist-esm/plugin/billboardjs-plugin-tableview.js +10 -18
  252. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +9 -16
  253. package/dist-esm/react/index.js +2 -3
  254. package/package.json +44 -44
  255. package/src/Chart/Chart.ts +1 -0
  256. package/src/Chart/api/chart.ts +2 -1
  257. package/src/Chart/api/flow.ts +20 -7
  258. package/src/Chart/api/focus.ts +3 -0
  259. package/src/Chart/api/subchart.ts +1 -1
  260. package/src/Chart/api/tooltip.ts +54 -15
  261. package/src/ChartInternal/Axis/AxisRenderer.ts +29 -20
  262. package/src/ChartInternal/Axis/AxisRendererHelper.ts +45 -9
  263. package/src/ChartInternal/ChartInternal.ts +46 -19
  264. package/src/ChartInternal/data/IData.ts +13 -0
  265. package/src/ChartInternal/data/data.ts +26 -5
  266. package/src/ChartInternal/data/load.ts +2 -2
  267. package/src/ChartInternal/interactions/flow.ts +50 -19
  268. package/src/ChartInternal/interactions/interaction.ts +15 -11
  269. package/src/ChartInternal/internals/class.ts +3 -2
  270. package/src/ChartInternal/internals/domain.ts +4 -2
  271. package/src/ChartInternal/internals/format.ts +3 -1
  272. package/src/ChartInternal/internals/legend.ts +2 -1
  273. package/src/ChartInternal/internals/redraw.ts +18 -12
  274. package/src/ChartInternal/internals/size.ts +5 -3
  275. package/src/ChartInternal/internals/text.ts +24 -28
  276. package/src/ChartInternal/internals/tooltip.ts +59 -20
  277. package/src/ChartInternal/internals/transform.ts +2 -2
  278. package/src/ChartInternal/internals/type.ts +101 -9
  279. package/src/ChartInternal/shape/boxplot.ts +172 -0
  280. package/src/ChartInternal/shape/bullet.ts +323 -0
  281. package/src/ChartInternal/shape/core/boxplot.ts +241 -0
  282. package/src/ChartInternal/shape/core/bullet.ts +734 -0
  283. package/src/ChartInternal/shape/core/heatmap.ts +665 -0
  284. package/src/ChartInternal/shape/core/sankey.ts +782 -0
  285. package/src/ChartInternal/shape/funnel.ts +73 -2
  286. package/src/ChartInternal/shape/heatmap.ts +236 -0
  287. package/src/ChartInternal/shape/point.ts +6 -3
  288. package/src/ChartInternal/shape/radar.ts +30 -1
  289. package/src/ChartInternal/shape/sankey.ts +242 -0
  290. package/src/ChartInternal/shape/shape.ts +16 -4
  291. package/src/ChartInternal/shape/treemap.ts +10 -0
  292. package/src/Plugin/stanford/index.ts +1 -28
  293. package/src/canvas/CanvasAxisRenderer.ts +54 -596
  294. package/src/canvas/CanvasRenderer.ts +68 -640
  295. package/src/canvas/CanvasTheme.ts +92 -6
  296. package/src/canvas/HitDetector.ts +30 -28
  297. package/src/canvas/boxplot.ts +230 -0
  298. package/src/canvas/bullet.ts +269 -0
  299. package/src/canvas/flow.ts +237 -0
  300. package/src/canvas/grid.ts +359 -0
  301. package/src/canvas/heatmap.ts +147 -0
  302. package/src/canvas/labels.ts +3 -1
  303. package/src/canvas/sankey.ts +151 -0
  304. package/src/canvas/selection.ts +626 -0
  305. package/src/canvas/subchart.ts +1292 -0
  306. package/src/canvas/treemap.ts +142 -0
  307. package/src/config/Options/axis/y2.ts +13 -0
  308. package/src/config/Options/data/data.ts +47 -1
  309. package/src/config/Options/interaction/subchart.ts +4 -0
  310. package/src/config/Options/shape/boxplot.ts +95 -0
  311. package/src/config/Options/shape/bullet.ts +170 -0
  312. package/src/config/Options/shape/heatmap.ts +125 -0
  313. package/src/config/Options/shape/sankey.ts +108 -0
  314. package/src/config/Store/State.ts +2 -1
  315. package/src/config/classes.ts +0 -1
  316. package/src/config/const.ts +30 -21
  317. package/src/config/resolver/canvas.ts +147 -1293
  318. package/src/config/resolver/canvasBoxplot.ts +42 -0
  319. package/src/config/resolver/canvasBullet.ts +20 -0
  320. package/src/config/resolver/canvasFlow.ts +18 -0
  321. package/src/config/resolver/canvasGrid.ts +17 -0
  322. package/src/config/resolver/canvasHeatmap.ts +23 -0
  323. package/src/config/resolver/canvasSankey.ts +23 -0
  324. package/src/config/resolver/canvasSelection.ts +20 -0
  325. package/src/config/resolver/canvasShape.ts +6 -1
  326. package/src/config/resolver/canvasSubchart.ts +20 -0
  327. package/src/config/resolver/canvasType.ts +51 -0
  328. package/src/config/resolver/customType.ts +69 -0
  329. package/src/config/resolver/shape/boxplot.ts +31 -0
  330. package/src/config/resolver/shape/bullet.ts +18 -0
  331. package/src/config/resolver/shape/funnel.ts +8 -2
  332. package/src/config/resolver/shape/heatmap.ts +18 -0
  333. package/src/config/resolver/shape/index.ts +4 -0
  334. package/src/config/resolver/shape/sankey.ts +18 -0
  335. package/src/index.canvas.ts +9 -3
  336. package/src/index.esm.ts +4 -0
  337. package/src/index.ts +34 -0
  338. package/src/module/error.ts +32 -18
  339. package/src/module/util/object.ts +26 -1
  340. package/src/scss/billboard.scss +106 -0
  341. package/src/scss/theme/dark.scss +110 -0
  342. package/src/scss/theme/datalab.scss +106 -0
  343. package/src/scss/theme/graph.scss +106 -0
  344. package/src/scss/theme/insight.scss +106 -0
  345. package/src/scss/theme/modern.scss +106 -0
  346. package/types/bb.d.ts +4 -0
  347. package/types/canvas.d.ts +3 -0
  348. package/types/chart.d.ts +5 -0
  349. package/types/index.d.ts +4 -0
  350. package/types/options.d.ts +13 -1
  351. package/types/options.shape.d.ts +431 -0
  352. package/types/types.d.ts +4 -0
@@ -5,11 +5,11 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.1.4
8
+ * @version 4.2.0-next.1
9
9
  * @requires billboard.js
10
10
  * @summary billboard.js plugin
11
11
  */
12
- //#region src/module/polygon.ts
12
+ // src/module/polygon.ts
13
13
  /**
14
14
  * Compute the signed area of a polygon using the Shoelace formula.
15
15
  * @param {Array} polygon Array of [x, y] coordinates
@@ -49,8 +49,7 @@ function polygonCentroid(polygon) {
49
49
  k *= 3;
50
50
  return [x / k, y / k];
51
51
  }
52
- //#endregion
53
- //#region src/module/voronoi.ts
52
+ // src/module/voronoi.ts
54
53
  const EPSILON = 1e-9;
55
54
  /**
56
55
  * Clip a convex polygon by the half-plane of points at least as close to `a` as
@@ -121,12 +120,10 @@ function voronoiCells(points, bounds) {
121
120
  return cell.length > 2 ? [...cell, cell[0]] : null;
122
121
  });
123
122
  }
124
- //#endregion
125
- //#region src/module/util/type-checks.ts
123
+ // src/module/util/type-checks.ts
126
124
  const isDefined = (v) => typeof v !== "undefined";
127
125
  const isObjectType = (v) => typeof v === "object";
128
- //#endregion
129
- //#region src/config/config.ts
126
+ // src/config/config.ts
130
127
  /**
131
128
  * Load configuration option
132
129
  * @param {object} config User's generation config value
@@ -152,8 +149,7 @@ function loadConfig(config) {
152
149
  });
153
150
  if (this.api) this.state.orgConfig = config;
154
151
  }
155
- //#endregion
156
- //#region src/Plugin/Plugin.ts
152
+ // src/Plugin/Plugin.ts
157
153
  /**
158
154
  * Copyright (c) 2017 ~ present NAVER Corp.
159
155
  * billboard.js project is licensed under the MIT license
@@ -175,7 +171,7 @@ var Plugin = class {
175
171
  $$;
176
172
  options;
177
173
  config;
178
- static version = "4.1.4";
174
+ static version = "4.2.0-next.1";
179
175
  /**
180
176
  * Constructor
181
177
  * @param {Any} options config option object
@@ -222,8 +218,7 @@ var Plugin = class {
222
218
  });
223
219
  }
224
220
  };
225
- //#endregion
226
- //#region src/Plugin/textoverlap/Options.ts
221
+ // src/Plugin/textoverlap/Options.ts
227
222
  /**
228
223
  * Copyright (c) 2017 ~ present NAVER Corp.
229
224
  * billboard.js project is licensed under the MIT license
@@ -274,8 +269,7 @@ var Options = class {
274
269
  };
275
270
  }
276
271
  };
277
- //#endregion
278
- //#region src/Plugin/textoverlap/index.ts
272
+ // src/Plugin/textoverlap/index.ts
279
273
  /**
280
274
  * TextOverlap plugin<br>
281
275
  * Prevents label overlap using [Voronoi layout](https://en.wikipedia.org/wiki/Voronoi_diagram).
@@ -369,5 +363,4 @@ var TextOverlap = class extends Plugin {
369
363
  });
370
364
  }
371
365
  };
372
- //#endregion
373
366
  export { TextOverlap as default };
@@ -5,10 +5,10 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.1.4
8
+ * @version 4.2.0-next.1
9
9
  */
10
10
  import { createElement, forwardRef, useEffect, useImperativeHandle, useRef } from "react";
11
- //#region src/react/index.ts
11
+ // src/react/index.ts
12
12
  /**
13
13
  * Resolve chart type from a direct string or resolver function.
14
14
  * @param {string|function} [type] Chart type value or resolver
@@ -153,5 +153,4 @@ const Chart = forwardRef((props, ref) => {
153
153
  ref: container
154
154
  });
155
155
  });
156
- //#endregion
157
156
  export { Chart, Chart as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "billboard.js",
3
- "version": "4.1.4",
3
+ "version": "4.2.0-next.1",
4
4
  "description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
5
5
  "homepage": "https://naver.github.io/billboard.js/",
6
6
  "main": "dist/billboard.js",
@@ -110,17 +110,17 @@
110
110
  "dependencies": {
111
111
  "@types/d3-selection": "^3.0.12",
112
112
  "@types/d3-transition": "^3.0.9",
113
- "d3-axis": "^3.0.0",
114
- "d3-brush": "^3.0.0",
115
- "d3-drag": "^3.0.0",
116
- "d3-hierarchy": "^3.1.2",
117
- "d3-interpolate": "^3.0.1",
118
- "d3-scale": "^4.0.2",
119
- "d3-selection": "^3.0.0",
120
- "d3-shape": "^3.2.0",
121
- "d3-time-format": "^4.1.0",
122
- "d3-transition": "^3.0.1",
123
- "d3-zoom": "^3.0.0"
113
+ "d3-axis": "^3.0.1",
114
+ "d3-brush": "^3.0.1",
115
+ "d3-drag": "^3.0.1",
116
+ "d3-hierarchy": "^3.1.3",
117
+ "d3-interpolate": "^3.0.2",
118
+ "d3-scale": "^4.0.3",
119
+ "d3-selection": "^3.0.1",
120
+ "d3-shape": "^3.2.1",
121
+ "d3-time-format": "^4.1.1",
122
+ "d3-transition": "^3.0.2",
123
+ "d3-zoom": "^3.0.1"
124
124
  },
125
125
  "peerDependencies": {
126
126
  "react": ">=16.8.0"
@@ -131,71 +131,71 @@
131
131
  }
132
132
  },
133
133
  "devDependencies": {
134
- "@commitlint/cli": "^21.2.3",
135
- "@commitlint/config-conventional": "^21.2.3",
134
+ "@commitlint/cli": "^21.2.4",
135
+ "@commitlint/config-conventional": "^21.2.4",
136
136
  "@eslint/js": "^10.0.1",
137
- "@playwright/test": "^1.63.0",
137
+ "@playwright/test": "^1.65.1",
138
138
  "@semantic-release/changelog": "^7.0.0",
139
139
  "@semantic-release/commit-analyzer": "^13.0.1",
140
140
  "@semantic-release/exec": "^7.1.0",
141
141
  "@semantic-release/git": "^11.0.1",
142
142
  "@semantic-release/npm": "^13.2.0",
143
143
  "@semantic-release/release-notes-generator": "^14.1.1",
144
- "@storybook/react-vite": "^10.6.0",
144
+ "@storybook/react-vite": "^10.6.7",
145
145
  "@testing-library/dom": "^10.4.2",
146
146
  "@testing-library/react": "^16.3.3",
147
147
  "@types/d3": "^7.4.3",
148
148
  "@types/react": "^19.3.0",
149
149
  "@types/react-dom": "^19.3.0",
150
- "@types/sinon": "^22.0.0",
151
- "@vitest/browser": "^5.0.2",
152
- "@vitest/browser-playwright": "^5.0.2",
153
- "@vitest/coverage-istanbul": "^5.0.2",
154
- "@vitest/ui": "^5.0.2",
150
+ "@types/sinon": "^22.0.2",
151
+ "@vitest/browser": "^5.1.0",
152
+ "@vitest/browser-playwright": "^5.1.0",
153
+ "@vitest/coverage-istanbul": "^5.1.0",
154
+ "@vitest/ui": "^5.1.0",
155
155
  "better-docs": "^2.7.3",
156
156
  "clean-webpack-plugin": "^4.0.0",
157
- "cloc": "2.6.0-cloc",
158
- "core-js": "^3.50.0",
157
+ "cloc": "2.12.0-cloc",
158
+ "core-js": "^3.51.0",
159
159
  "cross-env": "^10.1.0",
160
160
  "css-loader": "^7.1.5",
161
- "d3-delaunay": "^6.0.4",
162
- "d3-format": "^3.1.2",
163
- "d3-time": "^3.1.0",
161
+ "d3-delaunay": "^6.0.6",
162
+ "d3-format": "^3.1.3",
163
+ "d3-time": "^3.1.1",
164
164
  "docdash": "^2.0.2",
165
- "dprint": "^0.57.4",
165
+ "dprint": "^0.64.3",
166
166
  "esbuild-loader": "^4.5.0",
167
- "eslint": "^10.11.0",
167
+ "eslint": "^10.15.0",
168
168
  "eslint-plugin-import": "^2.32.0",
169
- "eslint-plugin-jsdoc": "^64.5.4",
169
+ "eslint-plugin-jsdoc": "^65.4.7",
170
170
  "husky": "^9.1.7",
171
171
  "jsdoc": "^4.0.5",
172
172
  "lint-staged": "^17.6.0",
173
173
  "mini-css-extract-plugin": "^2.10.2",
174
- "playwright": "^1.63.0",
175
- "react": "^19.3.0",
176
- "react-dom": "^19.3.0",
174
+ "playwright": "^1.65.1",
175
+ "react": "^19.3.1",
176
+ "react-dom": "^19.3.1",
177
177
  "regenerator-runtime": "^0.14.1",
178
- "rolldown": "^1.2.11",
179
- "sass": "^1.105.0",
180
- "sass-loader": "^17.0.1",
178
+ "rolldown": "^1.3.2",
179
+ "sass": "^1.108.2",
180
+ "sass-loader": "^17.1.0",
181
181
  "semantic-release": "^25.0.9",
182
182
  "simulant": "^0.2.2",
183
183
  "sinon": "^22.1.0",
184
- "storybook": "^10.6.0",
184
+ "storybook": "^10.6.7",
185
185
  "string-replace-loader": "^3.3.0",
186
186
  "style-loader": "^4.0.0",
187
- "tslib": "^2.8.1",
187
+ "tslib": "^2.9.1",
188
188
  "typescript": "^6.0.3",
189
- "typescript-eslint": "^8.70.1",
190
- "vitest": "^5.0.2",
191
- "webpack": "^5.111.1",
192
- "webpack-bundle-analyzer": "^5.4.0",
189
+ "typescript-eslint": "^8.72.2",
190
+ "vitest": "^5.1.0",
191
+ "webpack": "^5.112.2",
192
+ "webpack-bundle-analyzer": "^5.4.2",
193
193
  "webpack-clean": "^1.2.5",
194
- "webpack-cli": "^7.2.3",
195
- "webpack-dev-server": "^6.0.0",
194
+ "webpack-cli": "^7.3.1",
195
+ "webpack-dev-server": "^6.1.0",
196
196
  "webpack-merge": "^6.0.1",
197
197
  "webpackbar": "^7.0.0",
198
198
  "write-file-webpack-plugin": "^4.5.1"
199
199
  },
200
- "packageManager": "pnpm@10.16.0"
200
+ "packageManager": "pnpm@10.34.9"
201
201
  }
@@ -51,6 +51,7 @@ import apiTooltip from "./api/tooltip";
51
51
  * @property {object} $.bar Bar element object
52
52
  * @property {d3.selection} $.bar.bars Bar elements
53
53
  * @property {d3.selection} $.candlestick Candlestick elements
54
+ * @property {d3.selection} $.boxplot Boxplot elements
54
55
  * @property {object} $.line Line element object
55
56
  * @property {d3.selection} $.line.lines Line elements
56
57
  * @property {d3.selection} $.line.areas Areas elements
@@ -70,7 +70,8 @@ export default {
70
70
 
71
71
  // keep current zoom domain
72
72
  if ($$.scale.zoom) {
73
- state.current.zoomDomain = $$.scale.zoom.domain();
73
+ // in the range of .zoom(): a category scale reads its end one category further
74
+ state.current.zoomDomain = $$.zoom?.getDomain() ?? $$.scale.zoom.domain();
74
75
  }
75
76
 
76
77
  $$.scale.zoom = null;
@@ -86,6 +86,18 @@ export default {
86
86
  const orgDataCount = $$.getMaxDataCount();
87
87
  const targets = $$.convertDataToTargets(data, true);
88
88
  const isTimeSeries = $$.axis.isTimeSeries();
89
+ // timeseries and custom x take x from the data; otherwise x follows the index
90
+ const isCustomX = !isTimeSeries && $$.axis.isCustomX() && !$$.axis.isCategorized();
91
+ const hasDataX = isTimeSeries || isCustomX;
92
+ const firstValue = $$.data.targets.find(t => t.values.length)?.values[0];
93
+ // updateDataIndexByX() renumbers the index from 0 after each flow while x keeps
94
+ // moving on, so the gap between them carries x forward
95
+ const xOffset = firstValue ? firstValue.x - firstValue.index : 0;
96
+ const getX = (
97
+ index: number
98
+ ) => (isTimeSeries ? $$.getOtherTargetX(index) : index + xOffset);
99
+ // x of the values added by this flow, for series missing from the flow data
100
+ const flowedXs: number[] = [];
89
101
 
90
102
  // Update/Add data
91
103
  $$.data.targets.forEach(t => {
@@ -106,10 +118,11 @@ export default {
106
118
  for (let j = 0; j < length; j++) {
107
119
  values[j].index = tail + j;
108
120
 
109
- if (!isTimeSeries) {
110
- values[j].x = tail + j;
121
+ if (!hasDataX) {
122
+ values[j].x = getX(tail + j);
111
123
  }
112
124
 
125
+ flowedXs[j] = values[j].x;
113
126
  t.values.push(values[j]);
114
127
  }
115
128
 
@@ -136,7 +149,7 @@ export default {
136
149
  t.values.push({
137
150
  id: t.id,
138
151
  index: tail + j,
139
- x: isTimeSeries ? $$.getOtherTargetX(tail + j) : tail + j,
152
+ x: isCustomX ? flowedXs[j] : getX(tail + j),
140
153
  value: null
141
154
  });
142
155
  }
@@ -165,7 +178,7 @@ export default {
165
178
  values[i] = {
166
179
  id: t.id,
167
180
  index,
168
- x: isTimeSeries ? $$.getOtherTargetX(index) : index,
181
+ x: isCustomX ? $$.data.targets[0].values[i]?.x : getX(index),
169
182
  value: null
170
183
  };
171
184
  }
@@ -176,8 +189,8 @@ export default {
176
189
 
177
190
  v.index += tail;
178
191
 
179
- if (!isTimeSeries) {
180
- v.x += tail;
192
+ if (!hasDataX) {
193
+ v.x = getX(v.index);
181
194
  }
182
195
  }
183
196
  });
@@ -257,6 +270,7 @@ export default {
257
270
  withUpdateXDomain: true
258
271
  });
259
272
  $$.updateTypesElements();
273
+ $$.updateCanvasFlowFocus?.();
260
274
  args.done?.call($$.api);
261
275
  return;
262
276
  }
@@ -269,7 +283,6 @@ export default {
269
283
  // Redraw with new targets
270
284
  $$.redraw({
271
285
  flow: {
272
- index: baseValue.index,
273
286
  length: length,
274
287
  duration: isValue(args.duration) ?
275
288
  args.duration :
@@ -66,6 +66,7 @@ export default {
66
66
 
67
67
  state.focusedTargetIds = new Set(targetIds);
68
68
  targetIds.forEach(id => state.defocusedTargetIds.delete(id));
69
+ $$.customTypeHooks?.afterFocus?.($$);
69
70
  },
70
71
 
71
72
  /**
@@ -118,6 +119,7 @@ export default {
118
119
 
119
120
  targetIds.forEach(id => state.focusedTargetIds.delete(id));
120
121
  state.defocusedTargetIds = new Set(targetIds);
122
+ $$.customTypeHooks?.afterFocus?.($$);
121
123
  },
122
124
 
123
125
  /**
@@ -173,5 +175,6 @@ export default {
173
175
 
174
176
  state.focusedTargetIds = new Set();
175
177
  state.defocusedTargetIds = new Set();
178
+ $$.customTypeHooks?.afterFocus?.($$);
176
179
  }
177
180
  };
@@ -35,7 +35,7 @@ const subchart = function<T = TDomain[]>(domainValue?: T): T | undefined {
35
35
 
36
36
  if (Array.isArray(domain)) {
37
37
  domain = axis.isTimeSeries() ? domain.map(x => parseDate.bind($$)(x)) : domain;
38
- domain = $$.setCanvasSubchartDomain(domain) || state.domain;
38
+ domain = $$.setCanvasSubchartDomain?.(domain) || state.domain;
39
39
  } else {
40
40
  domain = state.domain ?? x.orgDomain();
41
41
  }
@@ -73,10 +73,22 @@ const tooltip = {
73
73
  */
74
74
  show: function(args): void {
75
75
  const $$ = this.internal;
76
- const {$el, config, state: {eventReceiver, hasFunnel, hasTreemap, inputType}} = $$;
76
+ const {
77
+ $el,
78
+ config,
79
+ state: {customType, eventReceiver, hasTreemap, inputType, isCanvasMode}
80
+ } = $$;
77
81
  let index;
78
82
  let mouse;
79
83
 
84
+ // a custom type addresses its data by id: resolve the given index to it.
85
+ // canvas resolves it by itself below
86
+ if (customType && !isCanvasMode && !args.data) {
87
+ const found = $$.customTypeHooks?.tooltipTarget?.($$, args).data[0];
88
+
89
+ found && (args = {...args, data: {id: found.id}, index: args.index ?? found.index});
90
+ }
91
+
80
92
  // determine mouse position on the chart
81
93
  if (args.mouse) {
82
94
  mouse = args.mouse;
@@ -87,10 +99,26 @@ const tooltip = {
87
99
  const {data} = args;
88
100
  const y = $$.getYScaleById(data.id)?.(data.value);
89
101
 
90
- if ((hasFunnel || hasTreemap) && data.id) {
91
- const selector = $$.selectorTarget(data.id, undefined, `.${$SHAPE.shape}`);
92
-
93
- eventReceiver.rect = $el.main.select(selector);
102
+ if ((customType || hasTreemap) && data.id) {
103
+ // canvas has no shape elements: the tooltip is resolved from the data below
104
+ if (!isCanvasMode) {
105
+ const shape = `.${$SHAPE.shape}`;
106
+ // a shape of the type can be of the given index too: `bb-shape-{index}`
107
+ // the index of the data, or of the given x for a type that names its columns
108
+ const at = args.index ?? data.index ??
109
+ (isDefined(args.x) ?
110
+ $$.customTypeHooks?.tooltipTarget?.($$, args).data[0]?.index :
111
+ undefined);
112
+ const byIndex = isDefined(at) ?
113
+ $el.main.select(
114
+ $$.selectorTarget(data.id, undefined, `${shape}${shape}-${at}`)
115
+ ) :
116
+ null;
117
+
118
+ eventReceiver.rect = byIndex?.node() ?
119
+ byIndex :
120
+ $el.main.select($$.selectorTarget(data.id, undefined, shape));
121
+ }
94
122
  } else if ($$.isMultipleX()) {
95
123
  // if multiple xs, target point will be determined by mouse
96
124
  mouse = [$$.xx(data), y];
@@ -113,30 +141,41 @@ const tooltip = {
113
141
 
114
142
  if ($$.state.isCanvasMode) {
115
143
  const targets = $$.filterTargetsToShow?.() || $$.data.targets;
116
- const selectedData = args.data?.id && !config.tooltip_grouped ?
117
- targets
118
- .filter(target => target.id === args.data.id)
119
- .map(target => target.values[index ?? args.data.index])
120
- .filter(Boolean) :
121
- targets
122
- .map(target => target.values[index])
123
- .filter(Boolean);
144
+ // a custom type can address its data other than by index
145
+ const custom = customType ? $$.customTypeHooks?.tooltipTarget?.($$, args) : null;
146
+ const selectedData = custom ?
147
+ custom.data :
148
+ (args.data?.id && !config.tooltip_grouped ?
149
+ targets
150
+ .filter(target => target.id === args.data.id)
151
+ .map(target => target.values[index ?? args.data.index])
152
+ .filter(Boolean) :
153
+ targets
154
+ .map(target => target.values[index])
155
+ .filter(Boolean));
124
156
  const canvas = $el.canvas?.node?.();
125
157
  const shape = $$.state.canvasShape || $$.getDrawShape?.();
126
158
  const first = selectedData[0];
127
159
  const point = mouse || (
128
- first && shape?.pos?.cx && shape?.pos?.cy ?
160
+ custom ? custom.point : (first && shape?.pos?.cx && shape?.pos?.cy ?
129
161
  [
130
162
  $$.state.margin.left + shape.pos.cx(first),
131
163
  $$.state.margin.top + shape.pos.cy(first)
132
164
  ] :
133
- undefined
165
+ undefined)
134
166
  );
135
167
 
136
168
  if (!selectedData.length || !canvas) {
137
169
  return;
138
170
  }
139
171
 
172
+ // a programmatic show has no pointer: place the tooltip at the point of the custom type
173
+ if (custom && point) {
174
+ const rect = canvas.getBoundingClientRect();
175
+
176
+ $$.state.event = {clientX: rect.left + point[0], clientY: rect.top + point[1]};
177
+ }
178
+
140
179
  $$.state.canvasFocusKey = selectedData
141
180
  .map(v => `${v.id}:${v.index}`)
142
181
  .join("|");
@@ -197,6 +197,10 @@ export default class AxisRenderer {
197
197
  });
198
198
 
199
199
  if (tickShow.tick || tickShow.text) {
200
+ // resolve the .domain node once: a selector string handed to insert() runs
201
+ // querySelector for every entering tick, which is O(ticks^2) on dense axes
202
+ const domainNode = g.select(".domain").node();
203
+
200
204
  // count of tick data in array
201
205
  const ticks = config.tickValues ||
202
206
  helper.generateTicks(scale1, isLeftRight || params.config.axis_rotated);
@@ -221,7 +225,7 @@ export default class AxisRenderer {
221
225
  // enter selection
222
226
  const tickEnter = tick
223
227
  .enter()
224
- .insert("g", ".domain")
228
+ .insert("g", () => domainNode)
225
229
  .attr("class", "tick");
226
230
 
227
231
  // MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks.
@@ -285,7 +289,10 @@ export default class AxisRenderer {
285
289
  .enter()
286
290
  .append("tspan")
287
291
  .merge(tspan)
288
- .text(d => d.splitted);
292
+ .each(function(d) {
293
+ // assigning textContent replaces the text node even for the same string
294
+ this.textContent !== d.splitted && (this.textContent = d.splitted);
295
+ });
289
296
 
290
297
  // set <tspan>'s position
291
298
  tspan
@@ -545,34 +552,36 @@ export default class AxisRenderer {
545
552
  );
546
553
  }
547
554
 
548
- // split given text by tick width size
549
- // eslint-disable-next-line
550
- function split(splitted, text) {
551
- let subtext;
555
+ // split given text by tick width size.
556
+ // iterate rather than recurse per line, so a very long label cannot overflow the stack
557
+ const text = String(tickText);
558
+ const result: string[] = [];
559
+ let start = 0;
560
+
561
+ while (true) {
552
562
  let spaceIndex;
553
- let textWidth;
563
+ let splitAt = -1;
554
564
 
555
- for (let i = 1; i < text.length; i++) {
556
- if (text.charAt(i) === " ") {
565
+ for (let i = 1; start + i < text.length; i++) {
566
+ if (text.charAt(start + i) === " ") {
557
567
  spaceIndex = i;
558
568
  }
559
569
 
560
- subtext = text.substr(0, i + 1);
561
- textWidth = charWidth * subtext.length;
562
-
563
570
  // if text width gets over tick width, split by space index or current index
564
- if (tickWidth < textWidth) {
565
- return split(
566
- splitted.concat(text.substr(0, spaceIndex || i)),
567
- text.slice(spaceIndex ? spaceIndex + 1 : i)
568
- );
571
+ if (tickWidth < charWidth * (i + 1)) {
572
+ splitAt = i;
573
+ break;
569
574
  }
570
575
  }
571
576
 
572
- return splitted.concat(text);
573
- }
577
+ if (splitAt === -1) {
578
+ result.push(text.slice(start));
579
+ return result;
580
+ }
574
581
 
575
- return split(splitted, String(tickText));
582
+ result.push(text.substr(start, spaceIndex || splitAt));
583
+ start += spaceIndex ? spaceIndex + 1 : splitAt;
584
+ }
576
585
  }
577
586
 
578
587
  scale(x?): AxisRenderer {
@@ -7,6 +7,12 @@ import type {d3Selection} from "../../../types/types";
7
7
  import {getBBox, isDefined, isValue} from "../../module/util";
8
8
  import {getScale} from "../internals/scale";
9
9
 
10
+ /**
11
+ * Size of one character per chart and font
12
+ * @private
13
+ */
14
+ const charSizeCache = new WeakMap<object, Record<string, {w: number, h: number}>>();
15
+
10
16
  export default class AxisRendererHelper {
11
17
  private owner;
12
18
  private config;
@@ -49,20 +55,48 @@ export default class AxisRendererHelper {
49
55
  return this.charSize[orient];
50
56
  }
51
57
 
52
- !text.empty() && text
53
- .text("0")
54
- .call((el: d3Selection) => {
55
- try {
56
- const {width, height} = getBBox(el.node(), true);
58
+ const node = text.node();
59
+
60
+ if (node) {
61
+ // A new renderer is made per redraw, so the size is kept per chart. It depends on
62
+ // the font only, which the key tells apart when the style changes.
63
+ const chart = this.owner.params.owner;
64
+ const style = window.getComputedStyle(node);
65
+ const key = [
66
+ orient,
67
+ style.fontStyle,
68
+ style.fontWeight,
69
+ style.fontSize,
70
+ style.fontFamily,
71
+ style.letterSpacing
72
+ ].join(" ");
73
+ const cache = charSizeCache.get(chart) ?? {};
74
+ const cached = cache[key];
75
+
76
+ charSizeCache.set(chart, cache);
77
+
78
+ try {
79
+ if (cached) {
80
+ size.w = cached.w;
81
+ size.h = cached.h;
82
+ } else {
83
+ // only the first node is measured, so write "0" to it alone
84
+ node.textContent = "0";
85
+
86
+ const {width, height} = getBBox(node, true);
57
87
 
58
88
  if (width && height) {
59
89
  size.w = width;
60
90
  size.h = height;
91
+ cache[key] = {w: width, h: height};
61
92
  }
62
- } finally {
63
- el.text("");
64
93
  }
65
- });
94
+ } finally {
95
+ // every node is emptied, as the callers rebuild their content
96
+ // (and a leftover <title> would stay)
97
+ text.text("");
98
+ }
99
+ }
66
100
 
67
101
  this.charSize[orient] = size;
68
102
 
@@ -166,7 +200,9 @@ export default class AxisRendererHelper {
166
200
  const {config} = this;
167
201
  let transitionSelection = selection;
168
202
 
169
- if (config.withoutTransition) {
203
+ // a flow passes its own transition (setTransition), which applies even when the
204
+ // chart transition is off, so the ticks slide with the shapes
205
+ if (config.withoutTransition && !config.transition) {
170
206
  transitionSelection = selection.interrupt();
171
207
  } else if (config.transition || !this.owner.params.noTransition) {
172
208
  // prevent for 'transition not found' case