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
@@ -0,0 +1,1292 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import type {AxisTickFormat} from "../../types/axis";
6
+ import {getMainCoordFromSubchartCoord} from "../ChartInternal/internals/subchart.util";
7
+ import {AXIS_TICK_PADDING, AXIS_TICK_SIZE, SUBCHART_BRUSH_HANDLE_PATH, TYPE} from "../config/const";
8
+ import {getCanvasEventPoint} from "../config/resolver/canvas";
9
+ import {window} from "../module/browser";
10
+ import {parseDate} from "../module/util";
11
+ import {
12
+ getSubXTickLineValues,
13
+ getSubXTickValues,
14
+ getYTickValues,
15
+ normalizeXValue,
16
+ type YAxisId
17
+ } from "./axisTicks";
18
+ import {
19
+ getAxisTickFont,
20
+ getHorizontalXAxisClipRect,
21
+ getRotatedXAxisClipRect,
22
+ getXOuterTickDirection,
23
+ getXTickTextDirection,
24
+ getXTickTextLineHeight,
25
+ getXTickTextLines,
26
+ getXTickTextWidth,
27
+ isInAxisRange
28
+ } from "./CanvasAxisRenderer";
29
+ import {
30
+ drawCanvasArea,
31
+ drawCanvasLine,
32
+ getCandlestickColor,
33
+ getCanvasTargetFocusOpacity,
34
+ getPointOpacity,
35
+ getTargetPointRadius,
36
+ isCanvasRenderableTarget,
37
+ isCanvasTargetFocused
38
+ } from "./CanvasRenderer";
39
+ import {getCanvasBarGeometry, getCanvasCandlestickGeometry} from "./geometry";
40
+ import {drawPointPattern} from "./pointPattern";
41
+ import {
42
+ getCanvasShapeIndices,
43
+ getFontSize,
44
+ hasCanvasDrawableValue,
45
+ isCanvasAreaType,
46
+ isCanvasBarType,
47
+ isCanvasBubbleType,
48
+ isCanvasCandlestickType,
49
+ isCanvasLineType,
50
+ isCanvasScatterType,
51
+ isFiniteCanvasCoordinate
52
+ } from "./util";
53
+
54
+ const CANVAS_SUBCHART_HANDLE_SIZE = 6;
55
+ const CANVAS_SUBCHART_CLICK_TOLERANCE = 2;
56
+ const subchartBrushHandlePathCache = new Map<string, Path2D>();
57
+
58
+ /**
59
+ * Normalize a subchart domain range for the current x axis type.
60
+ * @param {object} $$ ChartInternal instance
61
+ * @param {Array} domain Domain range
62
+ * @returns {Array} Normalized domain range
63
+ * @private
64
+ */
65
+ function normalizeCanvasSubchartDomain($$, domain): any[] | null {
66
+ if (!Array.isArray(domain) || domain.length < 2) {
67
+ return null;
68
+ }
69
+
70
+ const values = domain.slice(0, 2);
71
+
72
+ return $$.axis?.isTimeSeries?.() ? values.map(value => parseDate.call($$, value)) : values;
73
+ }
74
+
75
+ /**
76
+ * Get the canvas-space rectangle occupied by the subchart plot.
77
+ * @param {object} $$ ChartInternal instance
78
+ * @returns {object|null} Subchart rectangle
79
+ * @private
80
+ */
81
+ function getCanvasSubchartRect($$): {x: number, y: number, w: number, h: number} | null {
82
+ const {config, state} = $$;
83
+
84
+ if (!config.subchart_show || !state.hasAxis || state.width2 <= 0 || state.height2 <= 0) {
85
+ return null;
86
+ }
87
+
88
+ return {
89
+ x: state.margin2.left,
90
+ y: state.margin2.top,
91
+ w: state.width2,
92
+ h: state.height2
93
+ };
94
+ }
95
+
96
+ /**
97
+ * Check whether a canvas point is inside the subchart plot area.
98
+ * @param {object} $$ ChartInternal instance
99
+ * @param {Array} point Canvas-local point
100
+ * @returns {boolean} Whether point is in the subchart
101
+ * @private
102
+ */
103
+ function isCanvasSubchartPoint($$, point: number[]): boolean {
104
+ const rect = getCanvasSubchartRect($$);
105
+
106
+ return !!rect &&
107
+ point[0] >= rect.x &&
108
+ point[0] <= rect.x + rect.w &&
109
+ point[1] >= rect.y &&
110
+ point[1] <= rect.y + rect.h;
111
+ }
112
+
113
+ /**
114
+ * Convert a canvas subchart point to the equivalent main plot point.
115
+ * @param {object} $$ ChartInternal instance
116
+ * @param {Array} point Canvas-local point
117
+ * @returns {Array|null} Main plot point or null when not applicable
118
+ * @private
119
+ */
120
+ function getCanvasMainPointFromSubchart($$, point: number[]): number[] | null {
121
+ const {config, state} = $$;
122
+ const rect = getCanvasSubchartRect($$);
123
+
124
+ if (config.subchart_brush_enabled !== false || !rect || !isCanvasSubchartPoint($$, point)) {
125
+ return null;
126
+ }
127
+
128
+ const mainCoord = getMainCoordFromSubchartCoord(
129
+ $$,
130
+ config.axis_rotated ? point[1] - rect.y : point[0] - rect.x
131
+ );
132
+
133
+ if (mainCoord === null) {
134
+ return null;
135
+ }
136
+
137
+ return config.axis_rotated ?
138
+ [state.margin.left + (state.width / 2), state.margin.top + mainCoord] :
139
+ [state.margin.left + mainCoord, state.margin.top + (state.height / 2)];
140
+ }
141
+
142
+ /**
143
+ * Get the allowed local brush coordinate extent for canvas subchart interactions.
144
+ * @param {object} $$ ChartInternal instance
145
+ * @returns {Array} Brush extent in subchart-local pixels
146
+ * @private
147
+ */
148
+ function getCanvasSubchartBrushExtent($$): [number, number] {
149
+ const rect = getCanvasSubchartRect($$);
150
+ const axisLength = rect ? ($$.config.axis_rotated ? rect.h : rect.w) : 0;
151
+ const extent = $$.axis?.getExtent?.();
152
+ const values = Array.isArray(extent) ? extent.slice(0, 2) : [];
153
+
154
+ if (values.length === 2 && values.every(Number.isFinite)) {
155
+ const start = Math.max(0, Math.min(axisLength, values[0]));
156
+ const end = Math.max(0, Math.min(axisLength, values[1]));
157
+
158
+ return [Math.min(start, end), Math.max(start, end)];
159
+ }
160
+
161
+ return [0, axisLength];
162
+ }
163
+
164
+ /**
165
+ * Get the local brush coordinate from a canvas subchart pointer event.
166
+ * @param {object} $$ ChartInternal instance
167
+ * @param {Event} event Input event
168
+ * @param {boolean} clampToExtent Whether to clamp pointer outside brush extent
169
+ * @returns {number|null} Brush coordinate
170
+ * @private
171
+ */
172
+ function getCanvasSubchartBrushCoord(
173
+ $$,
174
+ event: MouseEvent | PointerEvent | TouchEvent,
175
+ clampToExtent = false
176
+ ):
177
+ | number
178
+ | null {
179
+ const point = getCanvasEventPoint($$, event);
180
+ const rect = point && getCanvasSubchartRect($$);
181
+
182
+ if (!point || !rect || !isCanvasSubchartPoint($$, point)) {
183
+ return null;
184
+ }
185
+
186
+ const raw = $$.config.axis_rotated ? point[1] - rect.y : point[0] - rect.x;
187
+ const [min, max] = getCanvasSubchartBrushExtent($$);
188
+
189
+ if (!clampToExtent && (raw < min || raw > max)) {
190
+ return null;
191
+ }
192
+
193
+ return Math.max(min, Math.min(max, raw));
194
+ }
195
+
196
+ /**
197
+ * Build a scale domain from two subchart brush coordinates.
198
+ * @param {object} $$ ChartInternal instance
199
+ * @param {number} start Brush start coordinate
200
+ * @param {number} end Brush end coordinate
201
+ * @returns {Array} Domain range
202
+ * @private
203
+ */
204
+ function getCanvasSubchartDomainFromCoords($$, start: number, end: number): any[] {
205
+ const coordStart = Math.min(start, end);
206
+ const coordEnd = Math.max(start, end);
207
+
208
+ return [
209
+ $$.scale.subX.invert(coordStart),
210
+ $$.scale.subX.invert(coordEnd)
211
+ ];
212
+ }
213
+
214
+ /**
215
+ * Get current canvas subchart brush selection in local subchart pixels.
216
+ * @param {object} $$ ChartInternal instance
217
+ * @returns {Array|null} Brush selection pixels
218
+ * @private
219
+ */
220
+ function getCanvasSubchartBrushSelection($$): [number, number] | null {
221
+ const {scale, state} = $$;
222
+ const domain = state.domain;
223
+
224
+ if (!domain?.length || !scale.subX) {
225
+ return null;
226
+ }
227
+
228
+ const rect = getCanvasSubchartRect($$);
229
+ const p0 = scale.subX(domain[0]);
230
+ const p1 = scale.subX(domain[1]);
231
+
232
+ if (!rect || !Number.isFinite(p0) || !Number.isFinite(p1)) {
233
+ return null;
234
+ }
235
+
236
+ const [min, max] = getCanvasSubchartBrushExtent($$);
237
+
238
+ return [
239
+ Math.max(min, Math.min(max, Math.min(p0, p1))),
240
+ Math.max(min, Math.min(max, Math.max(p0, p1)))
241
+ ];
242
+ }
243
+
244
+ /**
245
+ * Get the subchart brush mode at a local brush coordinate.
246
+ * @param {object} $$ ChartInternal instance
247
+ * @param {number} coord Brush coordinate
248
+ * @returns {string} Brush mode
249
+ * @private
250
+ */
251
+ function getCanvasSubchartBrushMode($$, coord: number):
252
+ | "select"
253
+ | "move"
254
+ | "resize-start"
255
+ | "resize-end" {
256
+ const selection = getCanvasSubchartBrushSelection($$);
257
+
258
+ if (!selection) {
259
+ return "select";
260
+ }
261
+
262
+ const [start, end] = selection;
263
+
264
+ if (Math.abs(coord - start) <= CANVAS_SUBCHART_HANDLE_SIZE) {
265
+ return "resize-start";
266
+ }
267
+
268
+ if (Math.abs(coord - end) <= CANVAS_SUBCHART_HANDLE_SIZE) {
269
+ return "resize-end";
270
+ }
271
+
272
+ return coord > start && coord < end ? "move" : "select";
273
+ }
274
+
275
+ /**
276
+ * Clamp a subchart brush selection to the subchart extent.
277
+ * @param {object} $$ ChartInternal instance
278
+ * @param {number} start Selection start pixel
279
+ * @param {number} end Selection end pixel
280
+ * @returns {Array} Clamped selection pixels
281
+ * @private
282
+ */
283
+ function clampCanvasSubchartSelection($$, start: number, end: number): [number, number] {
284
+ const [min, max] = getCanvasSubchartBrushExtent($$);
285
+
286
+ return [
287
+ Math.max(min, Math.min(max, start)),
288
+ Math.max(min, Math.min(max, end))
289
+ ];
290
+ }
291
+
292
+ /**
293
+ * Get cursor for a canvas subchart brush mode.
294
+ * @param {object} $$ ChartInternal instance
295
+ * @param {string} mode Brush mode
296
+ * @returns {string} CSS cursor
297
+ * @private
298
+ */
299
+ function getCanvasSubchartCursor($$, mode: string): string {
300
+ if (/^resize/.test(mode)) {
301
+ return $$.config.axis_rotated ? "ns-resize" : "ew-resize";
302
+ }
303
+
304
+ return mode === "move" ? "move" : "crosshair";
305
+ }
306
+
307
+ /**
308
+ * Get cached Path2D for a subchart brush handle.
309
+ * @param {string} axis Brush axis
310
+ * @param {string} type Brush handle side
311
+ * @returns {Path2D|null}
312
+ * @private
313
+ */
314
+ function getSubchartBrushHandlePath(axis: "x" | "y", type: "start" | "end"): Path2D | null {
315
+ const Path2DCtor = window.Path2D;
316
+
317
+ if (!Path2DCtor) {
318
+ return null;
319
+ }
320
+
321
+ const key = `${axis}:${type}`;
322
+ const cached = subchartBrushHandlePathCache.get(key);
323
+
324
+ if (cached) {
325
+ return cached;
326
+ }
327
+
328
+ const path = new Path2DCtor(SUBCHART_BRUSH_HANDLE_PATH[axis][type]);
329
+
330
+ subchartBrushHandlePathCache.set(key, path);
331
+
332
+ return path;
333
+ }
334
+
335
+ /**
336
+ * Get tick formatter for the canvas subchart y/y2 axis.
337
+ * @param {object} $$ ChartInternal context
338
+ * @param {string} id Axis id
339
+ * @returns {function} Tick formatter
340
+ * @private
341
+ */
342
+ function getSubYTickFormat($$, id: YAxisId): AxisTickFormat {
343
+ const subAxisId = id === "y2" ? "subY2" : "subY";
344
+ const axisFormat = $$.axis?.[subAxisId]?.tickFormat?.();
345
+ const configFormat = $$.config[`subchart_axis_${id}_tick_format`] ||
346
+ $$.config[`axis_${id}_tick_format`];
347
+
348
+ if (axisFormat) {
349
+ return axisFormat;
350
+ }
351
+
352
+ return typeof configFormat === "function" ? configFormat.bind($$.api) : (v => v);
353
+ }
354
+
355
+ /**
356
+ * Draw the canvas subchart overview and brush selection.
357
+ * @param {object} renderer Canvas renderer
358
+ * @param {object} $$ ChartInternal instance
359
+ * @param {object} _shape Cached main shape object
360
+ * @private
361
+ */
362
+ function drawSubchart(renderer, $$, _shape?): void {
363
+ const {config, state} = $$;
364
+
365
+ // Keep accepting the main chart shape from existing internal calls.
366
+ void _shape;
367
+
368
+ if (!config.subchart_show || !state.hasAxis || state.width2 <= 0 || state.height2 <= 0) {
369
+ return;
370
+ }
371
+
372
+ const {ctx, painter, theme: {style}} = renderer;
373
+ const {margin2, width2, height2} = state;
374
+ const rect = {x: margin2.left, y: margin2.top, w: width2, h: height2};
375
+
376
+ $$.withSubchartTypeContext(() => {
377
+ const targets = $$.filterTargetsToShow()
378
+ .filter(isCanvasRenderableTarget.bind(null, $$));
379
+ const shape = $$.getDrawShape();
380
+
381
+ $$.updateSubchartYDomain?.(targets);
382
+
383
+ painter.withState(() => {
384
+ painter.clipRect(rect, () => {
385
+ painter.withTranslation(rect.x, rect.y, () => {
386
+ const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
387
+ const areaIndices = getCanvasShapeIndices(
388
+ $$,
389
+ shape,
390
+ TYPE.AREA,
391
+ isCanvasAreaType.bind(null, $$)
392
+ );
393
+
394
+ for (const target of areaTargets) {
395
+ if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
396
+ continue;
397
+ }
398
+
399
+ ctx.globalAlpha = style.shape.areaOpacity *
400
+ getCanvasTargetFocusOpacity($$, target);
401
+ ctx.fillStyle = $$.color(target.id);
402
+ drawCanvasArea($$, target, areaIndices, painter, true);
403
+ }
404
+ ctx.globalAlpha = 1;
405
+
406
+ const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
407
+ const barIndices = getCanvasShapeIndices(
408
+ $$,
409
+ shape,
410
+ TYPE.BAR,
411
+ isCanvasBarType.bind(null, $$)
412
+ );
413
+ const getBarPoints = $$.generateGetBarPoints?.(barIndices, true);
414
+
415
+ if (getBarPoints) {
416
+ for (const target of barTargets) {
417
+ ctx.globalAlpha = style.shape.barOpacity *
418
+ getCanvasTargetFocusOpacity($$, target);
419
+ ctx.fillStyle = $$.color(target.id);
420
+ target.values.forEach((d, i) => {
421
+ if (!hasCanvasDrawableValue($$, d)) {
422
+ return;
423
+ }
424
+
425
+ const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
426
+ const fill = $$.getSubchartCandlestickBarColor?.(d, true) ||
427
+ ctx.fillStyle;
428
+
429
+ geometry && painter.fillRect(geometry.rect, {fill});
430
+ });
431
+ }
432
+ ctx.globalAlpha = 1;
433
+ }
434
+
435
+ const candlestickTargets = targets.filter(
436
+ isCanvasCandlestickType.bind(null, $$)
437
+ );
438
+ const candlestickIndices = getCanvasShapeIndices(
439
+ $$,
440
+ shape,
441
+ TYPE.CANDLESTICK,
442
+ isCanvasCandlestickType.bind(null, $$)
443
+ );
444
+ const getCandlestickPoints = $$.generateGetCandlestickPoints?.(
445
+ candlestickIndices,
446
+ true
447
+ );
448
+
449
+ if (getCandlestickPoints) {
450
+ ctx.lineWidth = style.shape.candlestickLineWidth;
451
+ for (const target of candlestickTargets) {
452
+ const targetOpacity = getCanvasTargetFocusOpacity($$, target);
453
+
454
+ ctx.globalAlpha = targetOpacity;
455
+ target.values.forEach((d, i) => {
456
+ const value = $$.getCandlestickData?.(d);
457
+ const geometry = value && getCanvasCandlestickGeometry(
458
+ $$,
459
+ getCandlestickPoints,
460
+ d,
461
+ i
462
+ );
463
+
464
+ if (!geometry) {
465
+ return;
466
+ }
467
+
468
+ const color = getCandlestickColor($$, {id: target.id}, value);
469
+
470
+ ctx.strokeStyle = color;
471
+ ctx.fillStyle = color;
472
+ painter.strokePath(() => {
473
+ painter.traceLine(
474
+ geometry.wickStart[0],
475
+ geometry.wickStart[1],
476
+ geometry.wickEnd[0],
477
+ geometry.wickEnd[1]
478
+ );
479
+ });
480
+ painter.fillRect(geometry.body, {fill: ctx.fillStyle});
481
+ });
482
+ }
483
+ }
484
+
485
+ const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
486
+ const lineIndices = getCanvasShapeIndices(
487
+ $$,
488
+ shape,
489
+ TYPE.LINE,
490
+ isCanvasLineType.bind(null, $$)
491
+ );
492
+
493
+ ctx.globalAlpha = 1;
494
+ for (const target of lineTargets) {
495
+ if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
496
+ continue;
497
+ }
498
+
499
+ ctx.globalAlpha = getCanvasTargetFocusOpacity($$, target);
500
+ ctx.lineWidth = isCanvasTargetFocused($$, target) ?
501
+ style.shape.lineFocusedWidth :
502
+ style.shape.lineWidth;
503
+ ctx.strokeStyle = $$.color(target.id);
504
+ drawCanvasLine($$, target, lineIndices, painter, true);
505
+ }
506
+ ctx.globalAlpha = 1;
507
+
508
+ if (config.point_show && !$$.isPointFocusOnly?.()) {
509
+ const cy = $$.updateCircleY?.(true);
510
+ const cx = $$.subxx?.bind($$);
511
+
512
+ if (cx && cy) {
513
+ for (const target of targets) {
514
+ if (
515
+ !isCanvasScatterType($$, target) &&
516
+ !isCanvasBubbleType($$, target)
517
+ ) {
518
+ continue;
519
+ }
520
+
521
+ const color = $$.color(target.id);
522
+ const pointFill = style.shape.pointFillColor || color;
523
+ const pointStroke = style.shape.pointStrokeColor || color;
524
+ const pointLineWidth = pointStroke ?
525
+ (style.shape.pointLineWidth ?? 1) :
526
+ 0;
527
+ const pointStyle = pointStroke && pointLineWidth > 0 ?
528
+ {
529
+ fill: pointFill,
530
+ stroke: pointStroke,
531
+ lineWidth: pointLineWidth
532
+ } :
533
+ {fill: pointFill};
534
+
535
+ ctx.globalAlpha = getPointOpacity($$, target) *
536
+ getCanvasTargetFocusOpacity($$, target);
537
+ target.values.forEach((d, i) => {
538
+ if (!hasCanvasDrawableValue($$, d)) {
539
+ return;
540
+ }
541
+
542
+ const x = config.axis_rotated ? cy(d, i) : cx(d);
543
+ const y = config.axis_rotated ? cx(d) : cy(d, i);
544
+ const r = Math.min(getTargetPointRadius($$, target, d), 3);
545
+
546
+ if (isFiniteCanvasCoordinate(x, y)) {
547
+ drawPointPattern(painter, "circle", x, y, r, pointStyle);
548
+ }
549
+ });
550
+ }
551
+ ctx.globalAlpha = 1;
552
+ }
553
+ }
554
+ });
555
+ });
556
+
557
+ drawSubchartBrush(renderer, $$);
558
+ });
559
+ });
560
+ }
561
+
562
+ /**
563
+ * Draw current subchart brush selection.
564
+ * @param {object} renderer Canvas renderer
565
+ * @param {object} $$ ChartInternal instance
566
+ * @private
567
+ */
568
+ function drawSubchartBrush(renderer, $$): void {
569
+ const {config, scale, state} = $$;
570
+ const domain = state.domain;
571
+
572
+ if (
573
+ !config.subchart_show ||
574
+ config.subchart_brush_enabled === false ||
575
+ !domain?.length ||
576
+ !scale.subX
577
+ ) {
578
+ return;
579
+ }
580
+
581
+ const {margin2, width2, height2} = state;
582
+ const p0 = scale.subX(domain[0]);
583
+ const p1 = scale.subX(domain[1]);
584
+ const axisLength = config.axis_rotated ? height2 : width2;
585
+ const extent = $$.axis?.getExtent?.();
586
+ const extentValues =
587
+ Array.isArray(extent) && extent.length >= 2 && extent.every(Number.isFinite) ?
588
+ extent.slice(0, 2) :
589
+ [0, axisLength];
590
+ const extentStart = Math.max(0, Math.min(axisLength, Math.min(...extentValues)));
591
+ const extentEnd = Math.max(0, Math.min(axisLength, Math.max(...extentValues)));
592
+ const start = Math.max(extentStart, Math.min(extentEnd, Math.min(p0, p1)));
593
+ const end = Math.max(extentStart, Math.min(extentEnd, Math.max(p0, p1)));
594
+ const size = end - start;
595
+
596
+ if (size <= 0) {
597
+ return;
598
+ }
599
+
600
+ const rect = config.axis_rotated ?
601
+ {x: margin2.left, y: margin2.top + start, w: width2, h: size} :
602
+ {x: margin2.left + start, y: margin2.top, w: size, h: height2};
603
+
604
+ renderer.painter.fillRect(rect, {
605
+ fill: renderer.theme.style.subchartBrush.fill,
606
+ alpha: renderer.theme.style.subchartBrush.opacity
607
+ });
608
+
609
+ if (config.subchart_showHandle) {
610
+ drawSubchartBrushHandle(renderer, $$, start, "start");
611
+ drawSubchartBrushHandle(renderer, $$, end, "end");
612
+ }
613
+ }
614
+
615
+ /**
616
+ * Draw a visible subchart brush resize handle.
617
+ * @param {object} renderer Canvas renderer
618
+ * @param {object} $$ ChartInternal instance
619
+ * @param {number} coord Brush handle coordinate
620
+ * @param {string} type Brush handle side
621
+ * @private
622
+ */
623
+ function drawSubchartBrushHandle(renderer, $$, coord: number, type: "start" | "end"): void {
624
+ const {config, state: {margin2, width2, height2}} = $$;
625
+ const {ctx, painter, theme: {style}} = renderer;
626
+ const isRotated = config.axis_rotated;
627
+ const fill = style.subchartBrush.handleFill;
628
+ const stroke = style.subchartBrush.handleStroke;
629
+ const x = isRotated ? margin2.left + (width2 / 2) : margin2.left + coord;
630
+ const y = isRotated ? margin2.top + coord : margin2.top + (height2 / 2);
631
+ const path = getSubchartBrushHandlePath(isRotated ? "y" : "x", type);
632
+
633
+ if (!path) {
634
+ return;
635
+ }
636
+
637
+ painter.withState(() => {
638
+ ctx.translate(x, y);
639
+ ctx.fillStyle = fill;
640
+ ctx.strokeStyle = stroke;
641
+ ctx.lineWidth = style.subchartBrush.handleLineWidth;
642
+ ctx.globalAlpha = style.subchartBrush.handleOpacity;
643
+ ctx.fill(path);
644
+ ctx.globalAlpha = 1;
645
+ ctx.stroke(path);
646
+ });
647
+ }
648
+
649
+ /**
650
+ * Draw synchronized focus grid on the canvas subchart.
651
+ * @param {object} renderer Canvas renderer
652
+ * @param {object} $$ ChartInternal instance
653
+ * @param {Array} selectedData Focused data rows
654
+ * @private
655
+ */
656
+ function drawSubchartFocus(renderer, $$, selectedData): void {
657
+ const {config, scale, state} = $$;
658
+ const focus = selectedData?.find(d =>
659
+ d &&
660
+ hasCanvasDrawableValue($$, d)
661
+ );
662
+
663
+ if (
664
+ !focus ||
665
+ !config.subchart_show ||
666
+ config.subchart_grid_focus_continuous ||
667
+ config.subchart_brush_enabled !== false ||
668
+ config.grid_focus_show === false ||
669
+ config.subchart_grid_focus === false ||
670
+ !config.tooltip_show ||
671
+ config.axis_tooltip ||
672
+ !scale.subX ||
673
+ state.width2 <= 0 ||
674
+ state.height2 <= 0
675
+ ) {
676
+ return;
677
+ }
678
+
679
+ const {margin2, width2, height2} = state;
680
+ const pos = scale.subX(focus.x);
681
+
682
+ if (!Number.isFinite(pos)) {
683
+ return;
684
+ }
685
+
686
+ const {painter, theme: {style}} = renderer;
687
+ const lineWidth = style.axis.lineWidth;
688
+ const x = painter.crisp(margin2.left + pos, lineWidth);
689
+ const y = painter.crisp(margin2.top + pos, lineWidth);
690
+
691
+ painter.strokePath(() => {
692
+ config.axis_rotated ?
693
+ painter.traceLine(margin2.left, y, margin2.left + width2, y) :
694
+ painter.traceLine(x, margin2.top, x, margin2.top + height2);
695
+ }, {
696
+ lineDash: style.focusGrid.dashArray,
697
+ lineWidth: style.focusGrid.lineWidth,
698
+ stroke: style.focusGrid.lineColor
699
+ });
700
+ }
701
+
702
+ /**
703
+ * Draw the canvas subchart x axis.
704
+ * @param {object} renderer Canvas renderer
705
+ * @param {object} $$ ChartInternal instance
706
+ * @private
707
+ */
708
+ function drawSubXAxis(renderer, $$): void {
709
+ const {ctx, painter, theme: {style: {axis}}} = renderer;
710
+ const {
711
+ config,
712
+ format,
713
+ scale,
714
+ state: {current, margin2, width2, height2}
715
+ } = $$;
716
+
717
+ if (
718
+ !config.subchart_show ||
719
+ !config.subchart_axis_x_show ||
720
+ !scale.subX ||
721
+ width2 <= 0 ||
722
+ height2 <= 0
723
+ ) {
724
+ return;
725
+ }
726
+
727
+ const isRotated = config.axis_rotated;
728
+ const x = painter.crisp(margin2.left, axis.lineWidth);
729
+ const y = painter.crisp(margin2.top + height2, axis.lineWidth);
730
+ const x1 = margin2.left;
731
+ const x2 = margin2.left + width2;
732
+ const y1 = margin2.top;
733
+ const y2 = margin2.top + height2;
734
+ const rangeStart = isRotated ? y1 : x1;
735
+ const rangeEnd = isRotated ? y2 : x2;
736
+ const ticks = getSubXTickValues($$);
737
+ const lineTicks = getSubXTickLineValues($$, ticks, axis.tickWidth);
738
+ const outerTick = config.subchart_axis_x_tick_outer ?? config.axis_x_tick_outer;
739
+ const tickDirection = isRotated ?
740
+ (config.axis_x_tick_inner ? 1 : -1) :
741
+ (config.axis_x_tick_inner ? -1 : 1);
742
+ const outerTickDirection = getXOuterTickDirection(isRotated);
743
+ const tickTextDirection = getXTickTextDirection(isRotated);
744
+ const tickTextPosition = config.axis_x_tick_text_position;
745
+ const tickRotate = !isRotated ? ($$.getAxisTickRotate?.("x") || 0) : 0;
746
+ const tickFormat = format.subXAxisTick || $$.axis?.getXAxisTickFormat?.(true);
747
+
748
+ painter.clipRect(
749
+ isRotated ? getRotatedXAxisClipRect(margin2, current.width, height2) : {
750
+ ...getHorizontalXAxisClipRect(
751
+ margin2,
752
+ width2,
753
+ current.height - margin2.top
754
+ ),
755
+ y: margin2.top
756
+ },
757
+ () => {
758
+ ctx.globalAlpha = 1;
759
+ ctx.strokeStyle = axis.lineColor;
760
+ ctx.lineWidth = axis.lineWidth;
761
+ ctx.setLineDash([]);
762
+
763
+ painter.strokePath(() => {
764
+ if (isRotated) {
765
+ painter.traceLine(x, y1, x, y2);
766
+ } else {
767
+ painter.traceLine(x1, y, x2, y);
768
+ }
769
+
770
+ if (outerTick) {
771
+ if (isRotated) {
772
+ painter.traceLine(x, y1, x + (AXIS_TICK_SIZE * outerTickDirection), y1);
773
+ painter.traceLine(x, y2, x + (AXIS_TICK_SIZE * outerTickDirection), y2);
774
+ } else {
775
+ painter.traceLine(x1, y, x1, y + (AXIS_TICK_SIZE * outerTickDirection));
776
+ painter.traceLine(x2, y, x2, y + (AXIS_TICK_SIZE * outerTickDirection));
777
+ }
778
+ }
779
+ });
780
+
781
+ const tickFont = getAxisTickFont(axis, "x");
782
+
783
+ ctx.font = tickFont;
784
+ ctx.fillStyle = axis.labelColor;
785
+ ctx.textAlign = isRotated ? (tickTextDirection > 0 ? "left" : "right") : "center";
786
+ ctx.textBaseline = isRotated ? "middle" : (tickTextDirection > 0 ? "top" : "bottom");
787
+ ctx.strokeStyle = axis.tickColor;
788
+ ctx.lineWidth = axis.tickWidth;
789
+
790
+ // invariant across ticks: measure/resolve once per draw pass
791
+ const lineHeight = getXTickTextLineHeight(painter, getFontSize(tickFont));
792
+ const tickTextWidth = getXTickTextWidth($$, ticks, isRotated, scale.subX);
793
+
794
+ if (config.subchart_axis_x_tick_show) {
795
+ for (const tick of lineTicks) {
796
+ const tickPos = scale.subX(normalizeXValue($$, tick));
797
+ const tx = margin2.left + tickPos;
798
+ const ty = margin2.top + tickPos;
799
+ const pos = isRotated ? ty : tx;
800
+
801
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
802
+ continue;
803
+ }
804
+
805
+ painter.strokePath(() => {
806
+ if (isRotated) {
807
+ painter.traceLine(x, ty, x + (AXIS_TICK_SIZE * tickDirection), ty);
808
+ } else {
809
+ painter.traceLine(tx, y, tx, y + (AXIS_TICK_SIZE * tickDirection));
810
+ }
811
+ });
812
+ }
813
+ }
814
+
815
+ for (const tick of ticks) {
816
+ const tickPos = scale.subX(normalizeXValue($$, tick));
817
+ const tx = margin2.left + tickPos;
818
+ const ty = margin2.top + tickPos;
819
+ const pos = isRotated ? ty : tx;
820
+
821
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
822
+ continue;
823
+ }
824
+
825
+ if (!config.subchart_axis_x_tick_text_show) {
826
+ continue;
827
+ }
828
+
829
+ const lines = getXTickTextLines(
830
+ $$,
831
+ painter,
832
+ tickFormat,
833
+ tick,
834
+ ticks,
835
+ isRotated,
836
+ scale.subX,
837
+ tickTextWidth
838
+ );
839
+ let textX;
840
+ let textY;
841
+
842
+ if (isRotated) {
843
+ textX = x + ((AXIS_TICK_SIZE + AXIS_TICK_PADDING) * tickTextDirection) +
844
+ (tickTextPosition.x || 0);
845
+ textY = ty + (tickTextPosition.y || 0);
846
+ ctx.textAlign = tickTextDirection > 0 ? "left" : "right";
847
+ ctx.textBaseline = "middle";
848
+ } else {
849
+ textX = tx + (tickTextPosition.x || 0);
850
+ textY = y + ((AXIS_TICK_SIZE + AXIS_TICK_PADDING) * tickTextDirection) +
851
+ (tickTextPosition.y || 0);
852
+ ctx.textAlign = tickRotate ? (tickRotate > 0 ? "left" : "right") : "center";
853
+ ctx.textBaseline = tickTextDirection > 0 ? "top" : "bottom";
854
+ }
855
+
856
+ painter.withState(textCtx => {
857
+ textCtx.translate(textX, textY);
858
+ tickRotate && textCtx.rotate(tickRotate * Math.PI / 180);
859
+
860
+ lines.forEach((line, i) => {
861
+ textCtx.fillText(line, 0, i * lineHeight);
862
+ });
863
+ });
864
+ }
865
+ }
866
+ );
867
+ }
868
+
869
+ /**
870
+ * Draw the canvas subchart y/y2 axes.
871
+ * @param {object} renderer Canvas renderer
872
+ * @param {object} $$ ChartInternal instance
873
+ * @private
874
+ */
875
+ function drawSubYAxes(renderer, $$): void {
876
+ const {
877
+ config,
878
+ scale,
879
+ state: {margin2, width2, height2}
880
+ } = $$;
881
+
882
+ if (!config.subchart_show || width2 <= 0 || height2 <= 0) {
883
+ return;
884
+ }
885
+
886
+ (["y", "y2"] as YAxisId[]).forEach(id => {
887
+ const subScale = id === "y2" ? scale.subY2 : scale.subY;
888
+
889
+ if (!config[`subchart_axis_${id}_show`] || !subScale) {
890
+ return;
891
+ }
892
+
893
+ renderer.drawYAxis($$, id, {
894
+ scale: subScale,
895
+ ticks: getYTickValues($$, id, undefined, true, subScale, `subchart_axis_${id}`),
896
+ format: getSubYTickFormat($$, id),
897
+ index: 0,
898
+ outerTick: config[`subchart_axis_${id}_tick_outer`] ??
899
+ config[`axis_${id}_tick_outer`],
900
+ margin: margin2,
901
+ width: width2,
902
+ height: height2,
903
+ prefix: `subchart_axis_${id}`,
904
+ tickShow: config[`subchart_axis_${id}_tick_show`],
905
+ tickTextShow: config[`subchart_axis_${id}_tick_text_show`],
906
+ tickTextPosition: config[`axis_${id}_tick_text_position`]
907
+ });
908
+ });
909
+ }
910
+
911
+ /**
912
+ * Canvas subchart interaction: the brush, its cursor and the selected domain.
913
+ * Added to the chart by subchart(): bundles without the module do not carry it.
914
+ * @private
915
+ */
916
+ export default {
917
+ /**
918
+ * Convert a canvas subchart point to the equivalent main plot point.
919
+ * @param {Array} point Canvas-local point
920
+ * @returns {Array|null} Main plot point or null when not applicable
921
+ * @private
922
+ */
923
+ getCanvasMainPointFromSubchart(point: number[]): number[] | null {
924
+ return getCanvasMainPointFromSubchart(this, point);
925
+ },
926
+
927
+ /**
928
+ * Apply the current canvas subchart selection to the main x domain.
929
+ * @private
930
+ */
931
+ applyCanvasSubchartDomain(): void {
932
+ const $$ = this;
933
+ const {axis, config, scale, state} = $$;
934
+
935
+ if (!config.subchart_show || !state.hasAxis || !scale.subX) {
936
+ return;
937
+ }
938
+
939
+ if (!state.rendered && !state.domain && config.subchart_init_range) {
940
+ state.domain = normalizeCanvasSubchartDomain($$, config.subchart_init_range);
941
+ }
942
+
943
+ const domain = normalizeCanvasSubchartDomain($$, state.domain);
944
+
945
+ if (
946
+ !domain ||
947
+ !$$.withinRange(domain, $$.getZoomDomain("subX", true), $$.getZoomDomain("subX"))
948
+ ) {
949
+ return;
950
+ }
951
+
952
+ state.domain = domain;
953
+ scale.x.domain(domain);
954
+ axis.x.scale(scale.x);
955
+ },
956
+
957
+ /**
958
+ * Set the canvas subchart selection domain and redraw the main chart.
959
+ * @param {Array} domain Domain range
960
+ * @param {boolean} redraw Whether to redraw immediately
961
+ * @param {boolean} callCallback Whether to call subchart.onbrush
962
+ * @returns {Array|undefined} Applied domain range
963
+ * @private
964
+ */
965
+ setCanvasSubchartDomain(domain, redraw = true, callCallback = false): any[] | undefined {
966
+ const $$ = this;
967
+ const {config, scale, state} = $$;
968
+ const nextDomain = normalizeCanvasSubchartDomain($$, domain);
969
+
970
+ if (
971
+ !config.subchart_show ||
972
+ !nextDomain ||
973
+ !$$.withinRange(nextDomain, $$.getZoomDomain("subX", true), $$.getZoomDomain("subX"))
974
+ ) {
975
+ return undefined;
976
+ }
977
+
978
+ state.domain = nextDomain;
979
+ scale.zoom = null;
980
+
981
+ if (redraw) {
982
+ $$.redraw({
983
+ withTransition: false,
984
+ withY: config.zoom_rescale,
985
+ withSubchart: false,
986
+ withEventRect: false,
987
+ withDimension: false
988
+ });
989
+ }
990
+
991
+ callCallback && config.subchart_onbrush.bind($$.api)(state.domain);
992
+
993
+ return state.domain;
994
+ },
995
+
996
+ /**
997
+ * Clear the canvas subchart brush selection and restore the full x domain.
998
+ * @param {boolean} redraw Whether to redraw immediately
999
+ * @param {boolean} callCallback Whether to call subchart.onbrush
1000
+ * @private
1001
+ */
1002
+ clearCanvasSubchartDomain(redraw = true, callCallback = false): void {
1003
+ const $$ = this;
1004
+ const {axis, config, org, scale, state} = $$;
1005
+
1006
+ if (!config.subchart_show) {
1007
+ return;
1008
+ }
1009
+
1010
+ state.domain = undefined;
1011
+ scale.zoom = null;
1012
+
1013
+ if (org.xDomain?.length) {
1014
+ scale.x.domain(org.xDomain);
1015
+ axis.x.scale(scale.x);
1016
+ }
1017
+
1018
+ if (redraw) {
1019
+ $$.redraw({
1020
+ withTransition: false,
1021
+ withUpdateXDomain: true,
1022
+ withUpdateOrgXDomain: false,
1023
+ withY: config.zoom_rescale,
1024
+ withSubchart: false,
1025
+ withEventRect: false,
1026
+ withDimension: false
1027
+ });
1028
+ }
1029
+
1030
+ callCallback && config.subchart_onbrush.bind($$.api)(scale.x.orgDomain());
1031
+ },
1032
+
1033
+ /**
1034
+ * Update canvas subchart brush domain from an input event.
1035
+ * @param {Event} event Input event
1036
+ * @returns {boolean} Whether the brush was updated
1037
+ * @private
1038
+ */
1039
+ updateCanvasSubchartBrush(event: MouseEvent | PointerEvent | TouchEvent): boolean {
1040
+ const $$ = this;
1041
+ const {config, state} = $$;
1042
+ const start = state.canvasSubchartBrushStart;
1043
+ const origin = state.canvasSubchartBrushOrigin;
1044
+ const mode = state.canvasSubchartBrushMode;
1045
+ const coord = getCanvasSubchartBrushCoord($$, event, true);
1046
+
1047
+ if (
1048
+ config.subchart_brush_enabled === false ||
1049
+ !state.canvasSubchartBrushDragging ||
1050
+ start === null ||
1051
+ coord === null ||
1052
+ !mode
1053
+ ) {
1054
+ return false;
1055
+ }
1056
+
1057
+ const delta = coord - start;
1058
+
1059
+ if (Math.abs(delta) > CANVAS_SUBCHART_CLICK_TOLERANCE) {
1060
+ state.canvasSubchartBrushMoved = true;
1061
+ }
1062
+
1063
+ if (!state.canvasSubchartBrushMoved) {
1064
+ event.preventDefault?.();
1065
+ return true;
1066
+ }
1067
+
1068
+ let selection: [number, number];
1069
+
1070
+ if (mode === "move" && origin) {
1071
+ const [extentStart, extentEnd] = getCanvasSubchartBrushExtent($$);
1072
+ const size = origin[1] - origin[0];
1073
+ let nextStart = origin[0] + delta;
1074
+ let nextEnd = origin[1] + delta;
1075
+
1076
+ if (nextStart < extentStart) {
1077
+ nextEnd += extentStart - nextStart;
1078
+ nextStart = extentStart;
1079
+ }
1080
+
1081
+ if (nextEnd > extentEnd) {
1082
+ nextStart -= nextEnd - extentEnd;
1083
+ nextEnd = extentEnd;
1084
+ }
1085
+
1086
+ selection = [
1087
+ Math.max(extentStart, Math.min(extentEnd - size, nextStart)),
1088
+ Math.min(extentEnd, Math.max(extentStart + size, nextEnd))
1089
+ ];
1090
+ } else if (mode === "resize-start" && origin) {
1091
+ selection = clampCanvasSubchartSelection($$, coord, origin[1]);
1092
+ } else if (mode === "resize-end" && origin) {
1093
+ selection = clampCanvasSubchartSelection($$, origin[0], coord);
1094
+ } else {
1095
+ selection = clampCanvasSubchartSelection($$, start, coord);
1096
+ }
1097
+
1098
+ const domain = getCanvasSubchartDomainFromCoords($$, selection[0], selection[1]);
1099
+
1100
+ $$.setCanvasSubchartDomain(domain, true);
1101
+ state.cancelClick = true;
1102
+ event.preventDefault?.();
1103
+
1104
+ return true;
1105
+ },
1106
+
1107
+ /**
1108
+ * Update cursor while hovering over the canvas subchart brush area.
1109
+ * @param {Event} event Input event
1110
+ * @returns {boolean} Whether the pointer is over the subchart
1111
+ * @private
1112
+ */
1113
+ updateCanvasSubchartCursor(event: MouseEvent | PointerEvent | TouchEvent): boolean {
1114
+ const $$ = this;
1115
+ const canvas = $$.$el.canvas.node();
1116
+
1117
+ if ($$.config.subchart_brush_enabled === false) {
1118
+ canvas.style.cursor = "";
1119
+ return false;
1120
+ }
1121
+
1122
+ const coord = getCanvasSubchartBrushCoord($$, event);
1123
+
1124
+ if (coord === null) {
1125
+ canvas.style.cursor = "";
1126
+ return false;
1127
+ }
1128
+
1129
+ const mode = getCanvasSubchartBrushMode($$, coord);
1130
+
1131
+ canvas.style.cursor = getCanvasSubchartCursor($$, mode);
1132
+
1133
+ return true;
1134
+ },
1135
+
1136
+ /**
1137
+ * Start a canvas subchart brush gesture.
1138
+ * @param {Event} event Mouse, pointer or touch event
1139
+ * @returns {boolean} Whether brushing started
1140
+ * @private
1141
+ */
1142
+ startCanvasSubchartBrush(event: MouseEvent | PointerEvent | TouchEvent): boolean {
1143
+ const $$ = this;
1144
+ const {state} = $$;
1145
+
1146
+ if ($$.config.subchart_brush_enabled === false) {
1147
+ return false;
1148
+ }
1149
+
1150
+ const coord = getCanvasSubchartBrushCoord($$, event);
1151
+
1152
+ if (coord === null) {
1153
+ return false;
1154
+ }
1155
+
1156
+ const mode = getCanvasSubchartBrushMode($$, coord);
1157
+
1158
+ state.event = event;
1159
+ state.canvasSubchartBrushDragging = true;
1160
+ state.canvasSubchartBrushMode = mode;
1161
+ state.canvasSubchartBrushStart = coord;
1162
+ state.canvasSubchartBrushOrigin = getCanvasSubchartBrushSelection($$);
1163
+ state.canvasSubchartBrushMoved = false;
1164
+ state.cancelClick = true;
1165
+ $$.setDragStatus(true);
1166
+ event.preventDefault?.();
1167
+
1168
+ return true;
1169
+ },
1170
+
1171
+ /**
1172
+ * End a canvas subchart brush gesture.
1173
+ * @param {Event} event Mouse, pointer or touch event
1174
+ * @returns {boolean} Whether brushing ended
1175
+ * @private
1176
+ */
1177
+ endCanvasSubchartBrush(event: MouseEvent | PointerEvent | TouchEvent): boolean {
1178
+ const $$ = this;
1179
+ const {state} = $$;
1180
+
1181
+ if (!state.canvasSubchartBrushDragging) {
1182
+ return false;
1183
+ }
1184
+
1185
+ $$.updateCanvasSubchartBrush(event);
1186
+
1187
+ const shouldClear = state.canvasSubchartBrushMode === "select" &&
1188
+ !state.canvasSubchartBrushMoved;
1189
+ const shouldCallback = state.canvasSubchartBrushMoved || shouldClear;
1190
+
1191
+ if (shouldClear) {
1192
+ $$.clearCanvasSubchartDomain?.(true, true);
1193
+ } else if (shouldCallback) {
1194
+ $$.config.subchart_onbrush.bind($$.api)(state.domain ?? $$.scale.x.orgDomain());
1195
+ }
1196
+
1197
+ state.canvasSubchartBrushDragging = false;
1198
+ state.canvasSubchartBrushMode = null;
1199
+ state.canvasSubchartBrushStart = null;
1200
+ state.canvasSubchartBrushOrigin = null;
1201
+ state.canvasSubchartBrushMoved = false;
1202
+ $$.setDragStatus(false);
1203
+ event.preventDefault?.();
1204
+
1205
+ return true;
1206
+ },
1207
+
1208
+ /**
1209
+ * Cancel a canvas subchart brush gesture without applying callbacks.
1210
+ * @param {Event} event Mouse, pointer or touch event
1211
+ * @returns {boolean} Whether brushing was cancelled
1212
+ * @private
1213
+ */
1214
+ cancelCanvasSubchartBrush(event: MouseEvent | PointerEvent | TouchEvent): boolean {
1215
+ const $$ = this;
1216
+ const {state} = $$;
1217
+
1218
+ if (!state.canvasSubchartBrushDragging) {
1219
+ return false;
1220
+ }
1221
+
1222
+ state.canvasSubchartBrushDragging = false;
1223
+ state.canvasSubchartBrushMode = null;
1224
+ state.canvasSubchartBrushStart = null;
1225
+ state.canvasSubchartBrushOrigin = null;
1226
+ state.canvasSubchartBrushMoved = false;
1227
+ $$.setDragStatus(false);
1228
+ event.preventDefault?.();
1229
+
1230
+ return true;
1231
+ },
1232
+
1233
+ /**
1234
+ * Start mouse-driven canvas subchart brushing.
1235
+ * @param {MouseEvent} event Mouse event
1236
+ * @returns {boolean} Whether brushing started
1237
+ * @private
1238
+ */
1239
+ onCanvasSubchartBrushStart(event: MouseEvent): boolean {
1240
+ const $$ = this;
1241
+
1242
+ if (!$$.startCanvasSubchartBrush(event)) {
1243
+ return false;
1244
+ }
1245
+
1246
+ const move = (event: MouseEvent) => {
1247
+ $$.updateCanvasSubchartBrush(event);
1248
+ };
1249
+ const end = (event: MouseEvent) => {
1250
+ $$.endCanvasSubchartBrush(event);
1251
+ window.removeEventListener("mousemove", move);
1252
+ window.removeEventListener("mouseup", end);
1253
+ };
1254
+
1255
+ window.addEventListener("mousemove", move);
1256
+ window.addEventListener("mouseup", end);
1257
+
1258
+ return true;
1259
+ }
1260
+ };
1261
+
1262
+ /**
1263
+ * Canvas drawing of the subchart, its axes and its focus line.
1264
+ * The functions are called with the chart (ChartInternal) as `this`.
1265
+ * Added to the chart by subchart(): bundles without the module do not carry it.
1266
+ * @private
1267
+ */
1268
+ export const subchartDraw = {
1269
+ draw(renderer, shape?): void {
1270
+ drawSubchart(renderer, this, shape);
1271
+ },
1272
+
1273
+ drawXAxis(axisRenderer): void {
1274
+ drawSubXAxis(axisRenderer, this);
1275
+ },
1276
+
1277
+ drawYAxes(axisRenderer): void {
1278
+ drawSubYAxes(axisRenderer, this);
1279
+ },
1280
+
1281
+ drawBrush(renderer): void {
1282
+ drawSubchartBrush(renderer, this);
1283
+ },
1284
+
1285
+ drawBrushHandle(renderer, coord: number, type: "start" | "end"): void {
1286
+ drawSubchartBrushHandle(renderer, this, coord, type);
1287
+ },
1288
+
1289
+ drawFocus(renderer, selectedData): void {
1290
+ drawSubchartFocus(renderer, this, selectedData);
1291
+ }
1292
+ };