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
@@ -12,12 +12,11 @@ import {getLineRegionSegments} from "../ChartInternal/shape/core/dataRegion";
12
12
  import {
13
13
  getRenderDataPoint,
14
14
  getRenderPoint,
15
- getShapePoint,
16
- getTreemapLabelText,
17
- getTreemapNodeRect
15
+ getRenderRect,
16
+ getShapePoint
18
17
  } from "../ChartInternal/shape/core/geometry";
19
18
  import {generateDrawAreaPath, generateDrawLinePath} from "../ChartInternal/shape/core/path";
20
- import {SUBCHART_BRUSH_HANDLE_PATH, TYPE} from "../config/const";
19
+ import {TYPE} from "../config/const";
21
20
  import {window} from "../module/browser";
22
21
  import {asHalfPixel, isFunction, isNumber, isObject, isString} from "../module/util";
23
22
  import CanvasEngine from "./CanvasEngine";
@@ -45,7 +44,6 @@ import {
45
44
  DENSE_SCATTER_POINT_CULL_THRESHOLD,
46
45
  getCanvasShapeIndices,
47
46
  getCanvasTargetVisibleRange,
48
- getFontSize,
49
47
  hasCanvasDrawableValue,
50
48
  isCanvasAreaType,
51
49
  isCanvasBarType,
@@ -55,7 +53,6 @@ import {
55
53
  isCanvasPointType,
56
54
  isCanvasScatterType,
57
55
  isCanvasTargetSupported,
58
- isCanvasTreemapType,
59
56
  isFiniteCanvasCoordinate,
60
57
  markCanvasPointOccupancy
61
58
  } from "./util";
@@ -70,7 +67,6 @@ const RENDERER_GROUPED_TYPE_FILTERS = [
70
67
  // fill() expensive, so canvas draws circles individually. SVG has no equivalent knob.
71
68
  const MAX_BATCHED_CIRCLE_POINTS = 1000;
72
69
  const canvasFocusLookupCache = new WeakMap<any[], Map<string, any>>();
73
- const subchartBrushHandlePathCache = new Map<string, Path2D>();
74
70
 
75
71
  type BarConnectLineType = "start-start" | "start-end" | "end-start" | "end-end";
76
72
  type CanvasBarConnectLineBox = {x: number, y: number, width: number, height: number};
@@ -153,7 +149,7 @@ function getPreservedAspectRatioRect(
153
149
  function getBackgroundImageOffset($$): {x: number, y: number} {
154
150
  const {state} = $$;
155
151
 
156
- return state.hasFunnel || state.hasTreemap ? {x: 0, y: 0} : {
152
+ return state.customType || state.hasTreemap ? {x: 0, y: 0} : {
157
153
  x: asHalfPixel(state.margin.left),
158
154
  y: asHalfPixel(state.margin.top)
159
155
  };
@@ -168,7 +164,7 @@ function getBackgroundImageOffset($$): {x: number, y: number} {
168
164
  * @param {boolean} isSub Whether to use subchart scales
169
165
  * @private
170
166
  */
171
- function drawCanvasLine($$, target, indices, painter: CanvasPainter, isSub = false): void {
167
+ export function drawCanvasLine($$, target, indices, painter: CanvasPainter, isSub = false): void {
172
168
  painter.strokePath(ctx => {
173
169
  generateDrawLinePath($$, indices, isSub, ctx)(target);
174
170
  }, {lineDash: []});
@@ -183,7 +179,7 @@ function drawCanvasLine($$, target, indices, painter: CanvasPainter, isSub = fal
183
179
  * @param {boolean} isSub Whether to use subchart scales
184
180
  * @private
185
181
  */
186
- function drawCanvasArea($$, target, indices, painter: CanvasPainter, isSub = false): void {
182
+ export function drawCanvasArea($$, target, indices, painter: CanvasPainter, isSub = false): void {
187
183
  painter.fillPath(ctx => {
188
184
  generateDrawAreaPath($$, indices, isSub, ctx)(target);
189
185
  });
@@ -246,34 +242,6 @@ function getFocusedCanvasDatum(focusData, d) {
246
242
  lookup.get(`${d.id}:*`) || null;
247
243
  }
248
244
 
249
- /**
250
- * Get cached Path2D for a subchart brush handle.
251
- * @param {string} axis Brush axis
252
- * @param {string} type Brush handle side
253
- * @returns {Path2D|null}
254
- * @private
255
- */
256
- function getSubchartBrushHandlePath(axis: "x" | "y", type: "start" | "end"): Path2D | null {
257
- const Path2DCtor = window.Path2D;
258
-
259
- if (!Path2DCtor) {
260
- return null;
261
- }
262
-
263
- const key = `${axis}:${type}`;
264
- const cached = subchartBrushHandlePathCache.get(key);
265
-
266
- if (cached) {
267
- return cached;
268
- }
269
-
270
- const path = new Path2DCtor(SUBCHART_BRUSH_HANDLE_PATH[axis][type]);
271
-
272
- subchartBrushHandlePathCache.set(key, path);
273
-
274
- return path;
275
- }
276
-
277
245
  /**
278
246
  * Resolve color.onover for a focused data row.
279
247
  * @param {object} $$ ChartInternal instance
@@ -331,7 +299,7 @@ function getCanvasTargetId(d): string | undefined {
331
299
  * @returns {boolean} Whether target is focused
332
300
  * @private
333
301
  */
334
- function isCanvasTargetFocused($$, d): boolean {
302
+ export function isCanvasTargetFocused($$, d): boolean {
335
303
  const id = getCanvasTargetId(d);
336
304
 
337
305
  return !!id && $$.state.focusedTargetIds?.has(id);
@@ -344,7 +312,7 @@ function isCanvasTargetFocused($$, d): boolean {
344
312
  * @returns {number} Target opacity
345
313
  * @private
346
314
  */
347
- function getCanvasTargetFocusOpacity($$, d): number {
315
+ export function getCanvasTargetFocusOpacity($$, d): number {
348
316
  const id = getCanvasTargetId(d);
349
317
 
350
318
  return id && $$.state.defocusedTargetIds?.has(id) ?
@@ -470,7 +438,7 @@ function getCanvasLinearGradientFill(
470
438
  * @returns {boolean} Whether the target is supported
471
439
  * @private
472
440
  */
473
- function isCanvasRenderableTarget($$, target): boolean {
441
+ export function isCanvasRenderableTarget($$, target): boolean {
474
442
  return isCanvasTargetSupported($$, target, RENDERER_GROUPED_TYPE_FILTERS);
475
443
  }
476
444
 
@@ -481,7 +449,7 @@ function isCanvasRenderableTarget($$, target): boolean {
481
449
  * @returns {number} Point opacity
482
450
  * @private
483
451
  */
484
- function getPointOpacity($$, target): number {
452
+ export function getPointOpacity($$, target): number {
485
453
  const opacity = $$.config.point_opacity;
486
454
 
487
455
  return Number.isFinite(opacity) ? opacity : (
@@ -497,7 +465,7 @@ function getPointOpacity($$, target): number {
497
465
  * @returns {number} Point radius
498
466
  * @private
499
467
  */
500
- function getTargetPointRadius($$, target, d): number {
468
+ export function getTargetPointRadius($$, target, d): number {
501
469
  const pointR = $$.config.point_r;
502
470
 
503
471
  return isCanvasBubbleType($$, target) || isFunction(pointR) ? ($$.pointR?.(d) ?? 2.5) : pointR;
@@ -620,7 +588,7 @@ function drawBarConnectLine(
620
588
  * @returns {string} Canvas point shape
621
589
  * @private
622
590
  */
623
- function getPointType($$, target): CanvasPointPattern {
591
+ export function getPointType($$, target): CanvasPointPattern {
624
592
  const {config} = $$;
625
593
 
626
594
  if (isCanvasBubbleType($$, target)) {
@@ -709,7 +677,7 @@ function getPointFillStyle(
709
677
  * @returns {string} Fill color
710
678
  * @private
711
679
  */
712
- function getCandlestickColor($$, d, value): string {
680
+ export function getCandlestickColor($$, d, value): string {
713
681
  const downColor = $$.config.candlestick_color_down;
714
682
  const color = value?._isUp ? $$.color(d) : (
715
683
  downColor && typeof downColor === "object" ? downColor[d.id] : downColor
@@ -817,7 +785,7 @@ function drawCanvasLineWithDataRegions($$, target, painter: CanvasPainter): void
817
785
  * @private
818
786
  */
819
787
  export default class CanvasRenderer {
820
- private painter: CanvasPainter;
788
+ painter: CanvasPainter;
821
789
  private labelImageCache = new Map<string, LabelImageCacheEntry>();
822
790
  private backgroundImageCache = new Map<string, LabelImageCacheEntry>();
823
791
  private backgroundClassStyleCache = new Map<string, CanvasBackgroundClassStyle>();
@@ -830,7 +798,7 @@ export default class CanvasRenderer {
830
798
  */
831
799
  constructor(
832
800
  private engine: CanvasEngine,
833
- private theme: CanvasTheme
801
+ public theme: CanvasTheme
834
802
  ) {
835
803
  this.painter = new CanvasPainter(engine.ctx);
836
804
  }
@@ -1043,7 +1011,7 @@ export default class CanvasRenderer {
1043
1011
  * @returns {object} Adjusted text position
1044
1012
  * @private
1045
1013
  */
1046
- private drawLabelImage($$, d, text: string, x: number, y: number): {x: number, y: number} {
1014
+ drawLabelImage($$, d, text: string, x: number, y: number): {x: number, y: number} {
1047
1015
  const option = getLabelImageOption($$, d);
1048
1016
 
1049
1017
  if (!option?.url) {
@@ -1079,7 +1047,7 @@ export default class CanvasRenderer {
1079
1047
  * @param {number} y Label y coordinate
1080
1048
  * @private
1081
1049
  */
1082
- private drawDataLabel($$, d, text: string, x: number, y: number): void {
1050
+ drawDataLabel($$, d, text: string, x: number, y: number): void {
1083
1051
  const {painter, theme: {style}} = this;
1084
1052
 
1085
1053
  ({x, y} = this.drawLabelImage($$, d, text, x, y));
@@ -1154,8 +1122,17 @@ export default class CanvasRenderer {
1154
1122
  * @private
1155
1123
  */
1156
1124
  draw($$, shape, focusData?): void {
1157
- if ($$.state.hasTreemap) {
1158
- this.drawTreemaps($$);
1125
+ // the type that is the whole chart is drawn by its module, alone
1126
+ const exclusive = $$.getCanvasTypeParts?.().find(part => part.exclusive);
1127
+
1128
+ if (exclusive) {
1129
+ exclusive.draw?.call($$, this, shape, focusData);
1130
+ return;
1131
+ }
1132
+
1133
+ if ($$.state.customType) {
1134
+ // registered by the module of the type: bundles without it do not carry its drawing
1135
+ $$.getCustomTypeParts()?.canvas?.draw?.call($$, this);
1159
1136
  return;
1160
1137
  }
1161
1138
 
@@ -1180,13 +1157,16 @@ export default class CanvasRenderer {
1180
1157
  }
1181
1158
 
1182
1159
  this.drawCandlesticks($$, shape, focusData);
1160
+
1161
+ // the types of their own modules drawn on the axes
1162
+ $$.getAxisTypeParts?.().forEach(part => part.canvas?.draw?.call($$, this, shape));
1183
1163
  drawLineLayers();
1184
1164
 
1185
1165
  if ($$.config.bar_front) {
1186
1166
  this.drawBars($$, shape, focusData);
1187
1167
  }
1188
1168
 
1189
- this.drawSelections($$, shape);
1169
+ $$.getCanvasFeature?.("selection")?.draw.call($$, this, shape);
1190
1170
  this.drawLabels($$, shape);
1191
1171
  };
1192
1172
 
@@ -1196,298 +1176,6 @@ export default class CanvasRenderer {
1196
1176
  drawContent);
1197
1177
  }
1198
1178
 
1199
- /**
1200
- * Draw the canvas subchart overview and brush selection.
1201
- * @param {object} $$ ChartInternal instance
1202
- * @param {object} _shape Cached main shape object
1203
- * @private
1204
- */
1205
- drawSubchart($$, _shape?): void {
1206
- const {config, state} = $$;
1207
-
1208
- // Keep accepting the main chart shape from existing internal calls.
1209
- void _shape;
1210
-
1211
- if (!config.subchart_show || !state.hasAxis || state.width2 <= 0 || state.height2 <= 0) {
1212
- return;
1213
- }
1214
-
1215
- const {ctx, painter, theme: {style}} = this;
1216
- const {margin2, width2, height2} = state;
1217
- const rect = {x: margin2.left, y: margin2.top, w: width2, h: height2};
1218
-
1219
- $$.withSubchartTypeContext(() => {
1220
- const targets = $$.filterTargetsToShow()
1221
- .filter(isCanvasRenderableTarget.bind(null, $$));
1222
- const shape = $$.getDrawShape();
1223
-
1224
- $$.updateSubchartYDomain?.(targets);
1225
-
1226
- painter.withState(() => {
1227
- painter.clipRect(rect, () => {
1228
- painter.withTranslation(rect.x, rect.y, () => {
1229
- const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
1230
- const areaIndices = getCanvasShapeIndices(
1231
- $$,
1232
- shape,
1233
- TYPE.AREA,
1234
- isCanvasAreaType.bind(null, $$)
1235
- );
1236
-
1237
- for (const target of areaTargets) {
1238
- if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
1239
- continue;
1240
- }
1241
-
1242
- ctx.globalAlpha = style.shape.areaOpacity *
1243
- getCanvasTargetFocusOpacity($$, target);
1244
- ctx.fillStyle = $$.color(target.id);
1245
- drawCanvasArea($$, target, areaIndices, painter, true);
1246
- }
1247
- ctx.globalAlpha = 1;
1248
-
1249
- const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
1250
- const barIndices = getCanvasShapeIndices(
1251
- $$,
1252
- shape,
1253
- TYPE.BAR,
1254
- isCanvasBarType.bind(null, $$)
1255
- );
1256
- const getBarPoints = $$.generateGetBarPoints?.(barIndices, true);
1257
-
1258
- if (getBarPoints) {
1259
- for (const target of barTargets) {
1260
- ctx.globalAlpha = style.shape.barOpacity *
1261
- getCanvasTargetFocusOpacity($$, target);
1262
- ctx.fillStyle = $$.color(target.id);
1263
- target.values.forEach((d, i) => {
1264
- if (!hasCanvasDrawableValue($$, d)) {
1265
- return;
1266
- }
1267
-
1268
- const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
1269
- const fill = $$.getSubchartCandlestickBarColor?.(d, true) ||
1270
- ctx.fillStyle;
1271
-
1272
- geometry && painter.fillRect(geometry.rect, {fill});
1273
- });
1274
- }
1275
- ctx.globalAlpha = 1;
1276
- }
1277
-
1278
- const candlestickTargets = targets.filter(
1279
- isCanvasCandlestickType.bind(null, $$)
1280
- );
1281
- const candlestickIndices = getCanvasShapeIndices(
1282
- $$,
1283
- shape,
1284
- TYPE.CANDLESTICK,
1285
- isCanvasCandlestickType.bind(null, $$)
1286
- );
1287
- const getCandlestickPoints = $$.generateGetCandlestickPoints?.(
1288
- candlestickIndices,
1289
- true
1290
- );
1291
-
1292
- if (getCandlestickPoints) {
1293
- ctx.lineWidth = style.shape.candlestickLineWidth;
1294
- for (const target of candlestickTargets) {
1295
- const targetOpacity = getCanvasTargetFocusOpacity($$, target);
1296
-
1297
- ctx.globalAlpha = targetOpacity;
1298
- target.values.forEach((d, i) => {
1299
- const value = $$.getCandlestickData?.(d);
1300
- const geometry = value && getCanvasCandlestickGeometry(
1301
- $$,
1302
- getCandlestickPoints,
1303
- d,
1304
- i
1305
- );
1306
-
1307
- if (!geometry) {
1308
- return;
1309
- }
1310
-
1311
- const color = getCandlestickColor($$, {id: target.id}, value);
1312
-
1313
- ctx.strokeStyle = color;
1314
- ctx.fillStyle = color;
1315
- painter.strokePath(() => {
1316
- painter.traceLine(
1317
- geometry.wickStart[0],
1318
- geometry.wickStart[1],
1319
- geometry.wickEnd[0],
1320
- geometry.wickEnd[1]
1321
- );
1322
- });
1323
- painter.fillRect(geometry.body, {fill: ctx.fillStyle});
1324
- });
1325
- }
1326
- }
1327
-
1328
- const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
1329
- const lineIndices = getCanvasShapeIndices(
1330
- $$,
1331
- shape,
1332
- TYPE.LINE,
1333
- isCanvasLineType.bind(null, $$)
1334
- );
1335
-
1336
- ctx.globalAlpha = 1;
1337
- for (const target of lineTargets) {
1338
- if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
1339
- continue;
1340
- }
1341
-
1342
- ctx.globalAlpha = getCanvasTargetFocusOpacity($$, target);
1343
- ctx.lineWidth = isCanvasTargetFocused($$, target) ?
1344
- style.shape.lineFocusedWidth :
1345
- style.shape.lineWidth;
1346
- ctx.strokeStyle = $$.color(target.id);
1347
- drawCanvasLine($$, target, lineIndices, painter, true);
1348
- }
1349
- ctx.globalAlpha = 1;
1350
-
1351
- if (config.point_show && !$$.isPointFocusOnly?.()) {
1352
- const cy = $$.updateCircleY?.(true);
1353
- const cx = $$.subxx?.bind($$);
1354
-
1355
- if (cx && cy) {
1356
- for (const target of targets) {
1357
- if (
1358
- !isCanvasScatterType($$, target) &&
1359
- !isCanvasBubbleType($$, target)
1360
- ) {
1361
- continue;
1362
- }
1363
-
1364
- const color = $$.color(target.id);
1365
- const pointFill = style.shape.pointFillColor || color;
1366
- const pointStroke = style.shape.pointStrokeColor || color;
1367
- const pointLineWidth = pointStroke ?
1368
- (style.shape.pointLineWidth ?? 1) :
1369
- 0;
1370
- const pointStyle = pointStroke && pointLineWidth > 0 ?
1371
- {
1372
- fill: pointFill,
1373
- stroke: pointStroke,
1374
- lineWidth: pointLineWidth
1375
- } :
1376
- {fill: pointFill};
1377
-
1378
- ctx.globalAlpha = getPointOpacity($$, target) *
1379
- getCanvasTargetFocusOpacity($$, target);
1380
- target.values.forEach((d, i) => {
1381
- if (!hasCanvasDrawableValue($$, d)) {
1382
- return;
1383
- }
1384
-
1385
- const x = config.axis_rotated ? cy(d, i) : cx(d);
1386
- const y = config.axis_rotated ? cx(d) : cy(d, i);
1387
- const r = Math.min(getTargetPointRadius($$, target, d), 3);
1388
-
1389
- if (isFiniteCanvasCoordinate(x, y)) {
1390
- drawPointPattern(painter, "circle", x, y, r,
1391
- pointStyle);
1392
- }
1393
- });
1394
- }
1395
- ctx.globalAlpha = 1;
1396
- }
1397
- }
1398
- });
1399
- });
1400
-
1401
- this.drawSubchartBrush($$);
1402
- });
1403
- });
1404
- }
1405
-
1406
- /**
1407
- * Draw current subchart brush selection.
1408
- * @param {object} $$ ChartInternal instance
1409
- * @private
1410
- */
1411
- drawSubchartBrush($$): void {
1412
- const {config, scale, state} = $$;
1413
- const domain = state.domain;
1414
-
1415
- if (
1416
- !config.subchart_show ||
1417
- config.subchart_brush_enabled === false ||
1418
- !domain?.length ||
1419
- !scale.subX
1420
- ) {
1421
- return;
1422
- }
1423
-
1424
- const {margin2, width2, height2} = state;
1425
- const p0 = scale.subX(domain[0]);
1426
- const p1 = scale.subX(domain[1]);
1427
- const axisLength = config.axis_rotated ? height2 : width2;
1428
- const extent = $$.axis?.getExtent?.();
1429
- const extentValues =
1430
- Array.isArray(extent) && extent.length >= 2 && extent.every(Number.isFinite) ?
1431
- extent.slice(0, 2) :
1432
- [0, axisLength];
1433
- const extentStart = Math.max(0, Math.min(axisLength, Math.min(...extentValues)));
1434
- const extentEnd = Math.max(0, Math.min(axisLength, Math.max(...extentValues)));
1435
- const start = Math.max(extentStart, Math.min(extentEnd, Math.min(p0, p1)));
1436
- const end = Math.max(extentStart, Math.min(extentEnd, Math.max(p0, p1)));
1437
- const size = end - start;
1438
-
1439
- if (size <= 0) {
1440
- return;
1441
- }
1442
-
1443
- const rect = config.axis_rotated ?
1444
- {x: margin2.left, y: margin2.top + start, w: width2, h: size} :
1445
- {x: margin2.left + start, y: margin2.top, w: size, h: height2};
1446
-
1447
- this.painter.fillRect(rect, {
1448
- fill: this.theme.style.subchartBrush.fill,
1449
- alpha: this.theme.style.subchartBrush.opacity
1450
- });
1451
-
1452
- if (config.subchart_showHandle) {
1453
- this.drawSubchartBrushHandle($$, start, "start");
1454
- this.drawSubchartBrushHandle($$, end, "end");
1455
- }
1456
- }
1457
-
1458
- /**
1459
- * Draw a visible subchart brush resize handle.
1460
- * @param {object} $$ ChartInternal instance
1461
- * @param {number} coord Brush handle coordinate
1462
- * @param {string} type Brush handle side
1463
- * @private
1464
- */
1465
- drawSubchartBrushHandle($$, coord: number, type: "start" | "end"): void {
1466
- const {config, state: {margin2, width2, height2}} = $$;
1467
- const {ctx, painter, theme: {style}} = this;
1468
- const isRotated = config.axis_rotated;
1469
- const fill = style.subchartBrush.handleFill;
1470
- const stroke = style.subchartBrush.handleStroke;
1471
- const x = isRotated ? margin2.left + (width2 / 2) : margin2.left + coord;
1472
- const y = isRotated ? margin2.top + coord : margin2.top + (height2 / 2);
1473
- const path = getSubchartBrushHandlePath(isRotated ? "y" : "x", type);
1474
-
1475
- if (!path) {
1476
- return;
1477
- }
1478
-
1479
- painter.withState(() => {
1480
- ctx.translate(x, y);
1481
- ctx.fillStyle = fill;
1482
- ctx.strokeStyle = stroke;
1483
- ctx.lineWidth = style.subchartBrush.handleLineWidth;
1484
- ctx.globalAlpha = style.subchartBrush.handleOpacity;
1485
- ctx.fill(path);
1486
- ctx.globalAlpha = 1;
1487
- ctx.stroke(path);
1488
- });
1489
- }
1490
-
1491
1179
  /**
1492
1180
  * Draw bar shapes on canvas.
1493
1181
  * @param {object} $$ ChartInternal instance
@@ -1687,13 +1375,39 @@ export default class CanvasRenderer {
1687
1375
  * @private
1688
1376
  */
1689
1377
  hasExpandedShapeFocus($$, selectedData): boolean {
1690
- return !!selectedData?.some(d =>
1691
- d &&
1692
- (
1693
- isCanvasBarType($$, d) ||
1694
- isCanvasCandlestickType($$, d)
1695
- )
1696
- );
1378
+ const isBar = isCanvasBarType.bind(null, $$);
1379
+ let getPoints;
1380
+
1381
+ return !!selectedData?.some(d => {
1382
+ if (!d) {
1383
+ return false;
1384
+ }
1385
+
1386
+ if (isCanvasCandlestickType($$, d)) {
1387
+ return true;
1388
+ }
1389
+
1390
+ if (!isBar(d)) {
1391
+ return false;
1392
+ }
1393
+
1394
+ // A bar thinner than a pixel shows no visible _expanded_ change, while redrawing
1395
+ // every bar on each focus move makes hovering a dense bar chart slow.
1396
+ getPoints = getPoints || $$.generateGetBarPoints(
1397
+ getCanvasShapeIndices($$, $$.state.canvasShape || {indices: {}}, TYPE.BAR, isBar),
1398
+ false
1399
+ );
1400
+
1401
+ const points = getPoints?.(d, d.index);
1402
+
1403
+ if (!points) {
1404
+ return true;
1405
+ }
1406
+
1407
+ const rect = getRenderRect($$, points, 0);
1408
+
1409
+ return ($$.config.axis_rotated ? rect.h : rect.w) >= 1;
1410
+ });
1697
1411
  }
1698
1412
 
1699
1413
  /**
@@ -1971,114 +1685,6 @@ export default class CanvasRenderer {
1971
1685
  });
1972
1686
  }
1973
1687
 
1974
- /**
1975
- * Draw selected canvas shapes.
1976
- * @param {object} $$ ChartInternal instance
1977
- * @param {object} shape Cached draw shape object
1978
- * @private
1979
- */
1980
- drawSelections($$, shape): void {
1981
- const selectedData = $$.getCanvasSelectedData?.();
1982
-
1983
- if (!$$.config.data_selection_enabled || !selectedData?.length || $$.state.hasTreemap) {
1984
- return;
1985
- }
1986
-
1987
- const {ctx, painter, theme: {style}} = this;
1988
- const {margin} = $$.state;
1989
- const isBar = isCanvasBarType.bind(null, $$);
1990
- const isCandlestick = isCanvasCandlestickType.bind(null, $$);
1991
- const barPoints = selectedData.some(isBar) ?
1992
- $$.generateGetBarPoints(
1993
- getCanvasShapeIndices($$, shape, TYPE.BAR, isBar),
1994
- false
1995
- ) :
1996
- null;
1997
- const candlestickPoints = selectedData.some(isCandlestick) ?
1998
- $$.generateGetCandlestickPoints?.(
1999
- getCanvasShapeIndices($$, shape, TYPE.CANDLESTICK, isCandlestick),
2000
- false
2001
- ) :
2002
- null;
2003
- const getRadius = barPoints ? getBarRadiusResolver($$) : null;
2004
- const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : new Set<string>();
2005
-
2006
- painter.withTranslation(margin.left, margin.top, () => {
2007
- selectedData.forEach(d => {
2008
- const color = $$.color(d.id);
2009
-
2010
- if (isBar(d) && barPoints) {
2011
- const geometry = getCanvasBarGeometry($$, barPoints, d, d.index);
2012
-
2013
- if (!geometry) {
2014
- return;
2015
- }
2016
-
2017
- const {points, rect} = geometry;
2018
- const corners = getRadius ?
2019
- getBarRadiusInfo($$, d, points, getRadius, stackingRadiusSet).corners :
2020
- 0;
2021
-
2022
- getRadius ?
2023
- painter.fillRoundRect(rect, corners, {fill: "#fff", alpha: 0.3}) :
2024
- painter.fillRect(rect, {fill: "#fff", alpha: 0.3});
2025
- getRadius ?
2026
- painter.strokeRoundRect(rect, corners, {stroke: color, lineWidth: 2}) :
2027
- painter.strokeRect(rect, {stroke: color, lineWidth: 2});
2028
- } else if (isCandlestick(d) && candlestickPoints) {
2029
- const value = $$.getCandlestickData?.(d);
2030
-
2031
- if (!value) {
2032
- return;
2033
- }
2034
-
2035
- const geometry = getCanvasCandlestickGeometry($$, candlestickPoints, d,
2036
- d.index);
2037
-
2038
- if (!geometry) {
2039
- return;
2040
- }
2041
-
2042
- const {body, wickStart, wickEnd} = geometry;
2043
-
2044
- painter.strokePath(() => {
2045
- painter.traceLine(wickStart[0], wickStart[1], wickEnd[0], wickEnd[1]);
2046
- }, {stroke: color, lineWidth: 3});
2047
- painter.fillRect(body, {fill: "#fff", alpha: 0.3});
2048
- painter.strokeRect(body, {stroke: color, lineWidth: 2});
2049
- } else if (isCanvasPointType($$, d)) {
2050
- const pointType = getPointType($$, {id: d.id});
2051
- const {x, y} = getRenderDataPoint($$, d);
2052
- const r = $$.pointR?.(d) ?? 2.5;
2053
- const selectR = $$.pointSelectR?.(d) ?? (r * 2);
2054
-
2055
- if (!isFiniteCanvasCoordinate(x, y)) {
2056
- return;
2057
- }
2058
-
2059
- drawPointPattern(painter, "circle", x, y, selectR, {
2060
- fill: style.selectedPoint.fill,
2061
- lineWidth: style.selectedPoint.lineWidth,
2062
- stroke: style.selectedPoint.stroke || color
2063
- });
2064
-
2065
- // with point.focus.only, the data point is rendered only while it's
2066
- // focused, so a selected-but-unfocused point shows just the selection
2067
- // ring (matching SVG). Skip drawing the data point itself here.
2068
- if (!$$.isPointFocusOnly?.()) {
2069
- drawPointPattern(painter, pointType, x, y, r, {
2070
- fill: style.shape.pointFillColor || color,
2071
- stroke: style.shape.pointStrokeColor || color,
2072
- lineWidth: style.shape.pointLineWidth ?? 1
2073
- });
2074
- }
2075
- }
2076
- });
2077
-
2078
- ctx.globalAlpha = 1;
2079
- });
2080
- }
2081
-
2082
1688
  /**
2083
1689
  * Draw data labels on canvas.
2084
1690
  * @param {object} $$ ChartInternal instance
@@ -2282,185 +1888,6 @@ export default class CanvasRenderer {
2282
1888
  });
2283
1889
  }
2284
1890
 
2285
- /**
2286
- * Draw data selection drag area.
2287
- * @param {object} $$ ChartInternal instance
2288
- * @param {object} rect Selection rectangle
2289
- * @private
2290
- */
2291
- drawSelectionDragArea($$, rect): void {
2292
- const {margin, width, height} = $$.state;
2293
- const plot = {
2294
- x: margin.left,
2295
- y: margin.top,
2296
- w: width,
2297
- h: height
2298
- };
2299
- const x = Math.max(plot.x, rect.x);
2300
- const y = Math.max(plot.y, rect.y);
2301
- const right = Math.min(plot.x + plot.w, rect.x + rect.w);
2302
- const bottom = Math.min(plot.y + plot.h, rect.y + rect.h);
2303
-
2304
- if (right <= x || bottom <= y) {
2305
- return;
2306
- }
2307
-
2308
- this.painter.fillRect({
2309
- x,
2310
- y,
2311
- w: right - x,
2312
- h: bottom - y
2313
- }, {
2314
- fill: this.theme.style.zoomBrush.fill,
2315
- alpha: this.theme.style.zoomBrush.opacity
2316
- });
2317
- }
2318
-
2319
- /**
2320
- * Draw treemap tiles and labels on canvas.
2321
- * @param {object} $$ ChartInternal instance
2322
- * @private
2323
- */
2324
- drawTreemaps($$): void {
2325
- const {ctx, painter, theme: {style}} = this;
2326
- const {config} = $$;
2327
- const root = $$.getTreemapRoot?.($$.data.targets);
2328
- const nodes = root?.children || [];
2329
-
2330
- painter.withState(() => {
2331
- ctx.lineWidth = style.treemap.lineWidth;
2332
- ctx.strokeStyle = style.treemap.stroke;
2333
-
2334
- for (const node of nodes) {
2335
- const {data} = node;
2336
-
2337
- if (!isCanvasTreemapType($$, data)) {
2338
- continue;
2339
- }
2340
-
2341
- const {x, y, w, h} = getTreemapNodeRect($$, node, root, true);
2342
-
2343
- if (
2344
- !isFiniteCanvasCoordinate(x, y) ||
2345
- !isFiniteCanvasCoordinate(x + w, y + h) ||
2346
- w <= 0 ||
2347
- h <= 0
2348
- ) {
2349
- continue;
2350
- }
2351
-
2352
- const rect = {x, y, w, h};
2353
-
2354
- ctx.fillStyle = $$.color(data.name);
2355
- painter.fillRect(rect);
2356
- painter.strokeRect(rect);
2357
-
2358
- if (
2359
- !config.treemap_label_show ||
2360
- (data.ratio || 0) < (config.treemap_label_threshold || 0)
2361
- ) {
2362
- continue;
2363
- }
2364
-
2365
- const label = getTreemapLabelText($$, data, w, h);
2366
-
2367
- if (!label) {
2368
- continue;
2369
- }
2370
-
2371
- const lines = label.split("\n");
2372
- const isCentered = !!config.data_labels.centered;
2373
-
2374
- ctx.font = style.label.font;
2375
- const lineHeight = getFontSize(ctx.font);
2376
- const metrics = ctx.measureText(lines[0] ?? "");
2377
- const fontBoundingHeight = (
2378
- (metrics.fontBoundingBoxAscent || 0) +
2379
- (metrics.fontBoundingBoxDescent || 0)
2380
- ) || (
2381
- (metrics.actualBoundingBoxAscent || 0) +
2382
- (metrics.actualBoundingBoxDescent || 0)
2383
- );
2384
- const textHeight = Math.max(lineHeight, fontBoundingHeight) +
2385
- ((lines.length - 1) * lineHeight);
2386
- const blockY = isCentered ? y + h / 2 : y + textHeight + 5;
2387
- let textX = isCentered ? x + w / 2 : x + 5;
2388
- let textY = blockY - (lines.length - 1) * lineHeight / (isCentered ? 2 : 1);
2389
-
2390
- ctx.textAlign = isCentered ? "center" : "left";
2391
- ctx.textBaseline = isCentered ? "middle" : "alphabetic";
2392
- ({x: textX, y: textY} = this.drawLabelImage($$, data, label, textX, textY));
2393
- ctx.fillStyle = getLabelColor($$, data, style.label.color);
2394
- drawLabelDecorations(
2395
- $$,
2396
- painter,
2397
- data,
2398
- label,
2399
- textX,
2400
- isCentered ? textY + ((lines.length - 1) * lineHeight / 2) : blockY
2401
- );
2402
-
2403
- lines.forEach((line, i) => {
2404
- painter.text(line, textX, textY + i * lineHeight, {
2405
- maxWidth: Math.max(0, w - 8)
2406
- });
2407
- });
2408
- }
2409
- });
2410
- }
2411
-
2412
- /**
2413
- * Draw synchronized focus grid on the canvas subchart.
2414
- * @param {object} $$ ChartInternal instance
2415
- * @param {Array} selectedData Focused data rows
2416
- * @private
2417
- */
2418
- drawSubchartFocus($$, selectedData): void {
2419
- const {config, scale, state} = $$;
2420
- const focus = selectedData?.find(d =>
2421
- d &&
2422
- hasCanvasDrawableValue($$, d)
2423
- );
2424
-
2425
- if (
2426
- !focus ||
2427
- !config.subchart_show ||
2428
- config.subchart_grid_focus_continuous ||
2429
- config.subchart_brush_enabled !== false ||
2430
- config.grid_focus_show === false ||
2431
- config.subchart_grid_focus === false ||
2432
- !config.tooltip_show ||
2433
- config.axis_tooltip ||
2434
- !scale.subX ||
2435
- state.width2 <= 0 ||
2436
- state.height2 <= 0
2437
- ) {
2438
- return;
2439
- }
2440
-
2441
- const {margin2, width2, height2} = state;
2442
- const pos = scale.subX(focus.x);
2443
-
2444
- if (!Number.isFinite(pos)) {
2445
- return;
2446
- }
2447
-
2448
- const {painter, theme: {style}} = this;
2449
- const lineWidth = style.axis.lineWidth;
2450
- const x = painter.crisp(margin2.left + pos, lineWidth);
2451
- const y = painter.crisp(margin2.top + pos, lineWidth);
2452
-
2453
- painter.strokePath(() => {
2454
- config.axis_rotated ?
2455
- painter.traceLine(margin2.left, y, margin2.left + width2, y) :
2456
- painter.traceLine(x, margin2.top, x, margin2.top + height2);
2457
- }, {
2458
- lineDash: style.focusGrid.dashArray,
2459
- lineWidth: style.focusGrid.lineWidth,
2460
- stroke: style.focusGrid.lineColor
2461
- });
2462
- }
2463
-
2464
1891
  /**
2465
1892
  * Draw focus grid and focused points on canvas.
2466
1893
  * @param {object} $$ ChartInternal instance
@@ -2468,7 +1895,8 @@ export default class CanvasRenderer {
2468
1895
  * @private
2469
1896
  */
2470
1897
  drawFocus($$, selectedData): void {
2471
- if (!selectedData?.length) {
1898
+ // a custom type has no axis, so there is no focus grid or point to draw
1899
+ if (!selectedData?.length || $$.state.customType) {
2472
1900
  return;
2473
1901
  }
2474
1902
 
@@ -2482,7 +1910,7 @@ export default class CanvasRenderer {
2482
1910
 
2483
1911
  $$.config.subchart_grid_focus !== false &&
2484
1912
  !isContinuousGridFocusEnabled($$) &&
2485
- this.drawSubchartFocus($$, selectedData);
1913
+ $$.getCanvasFeature?.("subchart")?.drawFocus.call($$, this, selectedData);
2486
1914
 
2487
1915
  painter.withTranslation(margin.left, margin.top, () => {
2488
1916
  if (