billboard.js 4.0.2 → 4.1.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 (272) hide show
  1. package/README.md +82 -7
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +1938 -557
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +19 -25
  6. package/dist/billboard.pkgd.js +1934 -742
  7. package/dist/billboard.pkgd.min.js +24 -30
  8. package/dist/billboard.react.js +205 -0
  9. package/dist/billboard.react.min.js +9 -0
  10. package/dist/billboard.worker.js +10 -0
  11. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-sparkline.js +3 -2
  14. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  15. package/dist/plugin/billboardjs-plugin-stanford.js +3 -2
  16. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  17. package/dist/plugin/billboardjs-plugin-tableview.js +57 -27
  18. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  19. package/dist/plugin/billboardjs-plugin-textoverlap.js +72 -54
  20. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +3 -2
  24. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
  25. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +3 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  27. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +57 -27
  28. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -11
  29. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +65 -3556
  30. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
  31. package/dist/theme/dark.css +1 -1
  32. package/dist/theme/dark.min.css +1 -1
  33. package/dist/theme/datalab.css +1 -1
  34. package/dist/theme/datalab.min.css +1 -1
  35. package/dist/theme/graph.css +1 -1
  36. package/dist/theme/graph.min.css +1 -1
  37. package/dist/theme/insight.css +1 -1
  38. package/dist/theme/insight.min.css +1 -1
  39. package/dist/theme/modern.css +1 -1
  40. package/dist/theme/modern.min.css +1 -1
  41. package/dist-esm/Chart/Chart.js +134 -152
  42. package/dist-esm/Chart/api/axis.js +217 -237
  43. package/dist-esm/Chart/api/category.js +54 -54
  44. package/dist-esm/Chart/api/chart.js +172 -215
  45. package/dist-esm/Chart/api/color.js +21 -21
  46. package/dist-esm/Chart/api/data.js +172 -173
  47. package/dist-esm/Chart/api/export.js +242 -262
  48. package/dist-esm/Chart/api/flow.js +198 -254
  49. package/dist-esm/Chart/api/focus.js +136 -147
  50. package/dist-esm/Chart/api/grid.js +191 -190
  51. package/dist-esm/Chart/api/group.js +31 -34
  52. package/dist-esm/Chart/api/legend.js +54 -63
  53. package/dist-esm/Chart/api/load.js +237 -257
  54. package/dist-esm/Chart/api/regions.js +148 -168
  55. package/dist-esm/Chart/api/selection.js +181 -139
  56. package/dist-esm/Chart/api/show.js +133 -147
  57. package/dist-esm/Chart/api/stubs.js +43 -42
  58. package/dist-esm/Chart/api/subchart.js +155 -172
  59. package/dist-esm/Chart/api/tooltip.js +132 -177
  60. package/dist-esm/Chart/api/x.js +67 -71
  61. package/dist-esm/Chart/api/zoom.js +183 -220
  62. package/dist-esm/ChartInternal/Axis/Axis.js +1059 -1266
  63. package/dist-esm/ChartInternal/Axis/AxisRenderer.js +408 -540
  64. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +113 -149
  65. package/dist-esm/ChartInternal/ChartInternal.js +573 -749
  66. package/dist-esm/ChartInternal/data/convert.helper.js +133 -159
  67. package/dist-esm/ChartInternal/data/convert.js +200 -229
  68. package/dist-esm/ChartInternal/data/data.js +970 -1147
  69. package/dist-esm/ChartInternal/data/load.js +145 -197
  70. package/dist-esm/ChartInternal/interactions/drag.js +86 -122
  71. package/dist-esm/ChartInternal/interactions/eventrect.js +455 -621
  72. package/dist-esm/ChartInternal/interactions/flow.js +151 -215
  73. package/dist-esm/ChartInternal/interactions/interaction.js +214 -252
  74. package/dist-esm/ChartInternal/interactions/subchart.js +425 -300
  75. package/dist-esm/ChartInternal/interactions/zoom.js +321 -440
  76. package/dist-esm/ChartInternal/internals/category.js +18 -18
  77. package/dist-esm/ChartInternal/internals/class.js +89 -99
  78. package/dist-esm/ChartInternal/internals/clip.js +88 -119
  79. package/dist-esm/ChartInternal/internals/color.js +233 -288
  80. package/dist-esm/ChartInternal/internals/domain.js +452 -588
  81. package/dist-esm/ChartInternal/internals/format.js +64 -77
  82. package/dist-esm/ChartInternal/internals/grid.js +333 -457
  83. package/dist-esm/ChartInternal/internals/legend.js +675 -927
  84. package/dist-esm/ChartInternal/internals/redraw.js +200 -289
  85. package/dist-esm/ChartInternal/internals/region.js +106 -159
  86. package/dist-esm/ChartInternal/internals/scale.js +186 -215
  87. package/dist-esm/ChartInternal/internals/selection.js +132 -159
  88. package/dist-esm/ChartInternal/internals/size.axis.js +92 -139
  89. package/dist-esm/ChartInternal/internals/size.js +286 -394
  90. package/dist-esm/ChartInternal/internals/style.js +39 -41
  91. package/dist-esm/ChartInternal/internals/subchart.util.js +49 -0
  92. package/dist-esm/ChartInternal/internals/text.arc.js +155 -219
  93. package/dist-esm/ChartInternal/internals/text.js +368 -528
  94. package/dist-esm/ChartInternal/internals/text.util.js +179 -239
  95. package/dist-esm/ChartInternal/internals/title.js +96 -121
  96. package/dist-esm/ChartInternal/internals/tooltip.js +450 -586
  97. package/dist-esm/ChartInternal/internals/transform.js +79 -97
  98. package/dist-esm/ChartInternal/internals/type.js +286 -245
  99. package/dist-esm/ChartInternal/shape/arc.js +825 -1112
  100. package/dist-esm/ChartInternal/shape/area.js +73 -94
  101. package/dist-esm/ChartInternal/shape/bar.js +227 -272
  102. package/dist-esm/ChartInternal/shape/bubble.js +9 -8
  103. package/dist-esm/ChartInternal/shape/candlestick.js +110 -138
  104. package/dist-esm/ChartInternal/shape/core/barRadius.js +197 -133
  105. package/dist-esm/ChartInternal/shape/core/bubble.js +64 -73
  106. package/dist-esm/ChartInternal/shape/core/candlestick.js +93 -86
  107. package/dist-esm/ChartInternal/shape/core/dataRegion.js +68 -75
  108. package/dist-esm/ChartInternal/shape/core/geometry.js +112 -112
  109. package/dist-esm/ChartInternal/shape/core/path.js +142 -115
  110. package/dist-esm/ChartInternal/shape/core/point.js +105 -125
  111. package/dist-esm/ChartInternal/shape/core/treemap.js +83 -88
  112. package/dist-esm/ChartInternal/shape/funnel.js +310 -338
  113. package/dist-esm/ChartInternal/shape/gauge.js +71 -103
  114. package/dist-esm/ChartInternal/shape/line.js +208 -278
  115. package/dist-esm/ChartInternal/shape/point.js +310 -413
  116. package/dist-esm/ChartInternal/shape/polar.js +84 -109
  117. package/dist-esm/ChartInternal/shape/radar.js +228 -318
  118. package/dist-esm/ChartInternal/shape/shape.js +782 -828
  119. package/dist-esm/ChartInternal/shape/treemap.js +152 -190
  120. package/dist-esm/canvas/CanvasAxisRenderer.js +1180 -1328
  121. package/dist-esm/canvas/CanvasEngine.js +148 -166
  122. package/dist-esm/canvas/CanvasPainter.js +395 -411
  123. package/dist-esm/canvas/CanvasRenderer.js +1584 -1834
  124. package/dist-esm/canvas/CanvasTheme.js +899 -802
  125. package/dist-esm/canvas/HitDetector.js +394 -463
  126. package/dist-esm/canvas/axisTicks.js +672 -786
  127. package/dist-esm/canvas/classes.js +19 -17
  128. package/dist-esm/canvas/color.js +40 -59
  129. package/dist-esm/canvas/geometry.js +38 -38
  130. package/dist-esm/canvas/labels.js +318 -371
  131. package/dist-esm/canvas/pointPattern.js +578 -580
  132. package/dist-esm/canvas/util.js +242 -262
  133. package/dist-esm/config/Options/Options.js +29 -32
  134. package/dist-esm/config/Options/axis/axis.js +101 -101
  135. package/dist-esm/config/Options/axis/x.js +759 -755
  136. package/dist-esm/config/Options/axis/y.js +525 -522
  137. package/dist-esm/config/Options/axis/y2.js +501 -485
  138. package/dist-esm/config/Options/common/boost.js +93 -32
  139. package/dist-esm/config/Options/common/color.js +88 -87
  140. package/dist-esm/config/Options/common/grid.js +74 -73
  141. package/dist-esm/config/Options/common/legend.js +180 -179
  142. package/dist-esm/config/Options/common/main.js +474 -473
  143. package/dist-esm/config/Options/common/point.js +160 -159
  144. package/dist-esm/config/Options/common/title.js +47 -46
  145. package/dist-esm/config/Options/common/tooltip.js +253 -252
  146. package/dist-esm/config/Options/data/axis.js +173 -172
  147. package/dist-esm/config/Options/data/data.js +958 -957
  148. package/dist-esm/config/Options/data/selection.js +131 -130
  149. package/dist-esm/config/Options/interaction/interaction.js +53 -52
  150. package/dist-esm/config/Options/interaction/subchart.js +164 -73
  151. package/dist-esm/config/Options/interaction/zoom.js +86 -85
  152. package/dist-esm/config/Options/shape/arc.js +150 -149
  153. package/dist-esm/config/Options/shape/area.js +69 -68
  154. package/dist-esm/config/Options/shape/bar.js +147 -146
  155. package/dist-esm/config/Options/shape/bubble.js +35 -34
  156. package/dist-esm/config/Options/shape/candlestick.js +61 -60
  157. package/dist-esm/config/Options/shape/donut.js +181 -180
  158. package/dist-esm/config/Options/shape/funnel.js +49 -48
  159. package/dist-esm/config/Options/shape/gauge.js +237 -236
  160. package/dist-esm/config/Options/shape/line.js +58 -57
  161. package/dist-esm/config/Options/shape/pie.js +185 -184
  162. package/dist-esm/config/Options/shape/polar.js +167 -166
  163. package/dist-esm/config/Options/shape/radar.js +76 -75
  164. package/dist-esm/config/Options/shape/scatter.js +36 -36
  165. package/dist-esm/config/Options/shape/spline.js +46 -46
  166. package/dist-esm/config/Options/shape/treemap.js +80 -79
  167. package/dist-esm/config/Store/Element.js +64 -62
  168. package/dist-esm/config/Store/State.js +189 -200
  169. package/dist-esm/config/Store/Store.js +25 -26
  170. package/dist-esm/config/classes.js +157 -155
  171. package/dist-esm/config/config.js +26 -35
  172. package/dist-esm/config/const.js +120 -128
  173. package/dist-esm/config/resolver/axis.core.js +25 -25
  174. package/dist-esm/config/resolver/axis.js +26 -27
  175. package/dist-esm/config/resolver/canvas.js +2071 -2472
  176. package/dist-esm/config/resolver/canvasShape.js +201 -177
  177. package/dist-esm/config/resolver/category.js +26 -27
  178. package/dist-esm/config/resolver/export.js +24 -26
  179. package/dist-esm/config/resolver/flow.js +29 -31
  180. package/dist-esm/config/resolver/grid.js +34 -35
  181. package/dist-esm/config/resolver/interaction/selection.js +17 -17
  182. package/dist-esm/config/resolver/interaction/subchart.js +17 -17
  183. package/dist-esm/config/resolver/interaction/zoom.js +17 -17
  184. package/dist-esm/config/resolver/regions.js +30 -31
  185. package/dist-esm/config/resolver/shape/arc.helpers.js +19 -19
  186. package/dist-esm/config/resolver/shape/area.js +17 -17
  187. package/dist-esm/config/resolver/shape/axis.helpers.js +28 -25
  188. package/dist-esm/config/resolver/shape/bar.js +13 -13
  189. package/dist-esm/config/resolver/shape/bubble.js +18 -14
  190. package/dist-esm/config/resolver/shape/candlestick.js +13 -13
  191. package/dist-esm/config/resolver/shape/donut.js +11 -11
  192. package/dist-esm/config/resolver/shape/funnel.js +11 -11
  193. package/dist-esm/config/resolver/shape/gauge.js +12 -12
  194. package/dist-esm/config/resolver/shape/line.js +10 -10
  195. package/dist-esm/config/resolver/shape/pie.js +11 -11
  196. package/dist-esm/config/resolver/shape/polar.js +12 -12
  197. package/dist-esm/config/resolver/shape/radar.js +22 -14
  198. package/dist-esm/config/resolver/shape/scatter.js +13 -13
  199. package/dist-esm/config/resolver/shape/treemap.js +11 -11
  200. package/dist-esm/core.js +208 -211
  201. package/dist-esm/index.canvas.js +14 -13
  202. package/dist-esm/index.esm.js +25 -24
  203. package/dist-esm/module/Cache.js +117 -129
  204. package/dist-esm/module/browser.js +30 -35
  205. package/dist-esm/module/dsv.js +107 -127
  206. package/dist-esm/module/error.js +45 -52
  207. package/dist-esm/module/generator.js +75 -83
  208. package/dist-esm/module/sanitize.js +302 -399
  209. package/dist-esm/module/util/brush.js +27 -38
  210. package/dist-esm/module/util/dom.js +288 -348
  211. package/dist-esm/module/util/object.js +277 -341
  212. package/dist-esm/module/util/type-checks.js +21 -25
  213. package/dist-esm/module/worker.js +312 -130
  214. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +185 -198
  215. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +442 -450
  216. package/dist-esm/plugin/billboardjs-plugin-stanford.js +813 -950
  217. package/dist-esm/plugin/billboardjs-plugin-tableview.js +708 -788
  218. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +344 -301
  219. package/dist-esm/react/index.js +157 -0
  220. package/package.json +28 -8
  221. package/src/Chart/api/focus.ts +8 -12
  222. package/src/Chart/api/selection.ts +130 -5
  223. package/src/ChartInternal/Axis/Axis.ts +164 -65
  224. package/src/ChartInternal/Axis/AxisRenderer.ts +41 -8
  225. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  226. package/src/ChartInternal/ChartInternal.ts +1 -1
  227. package/src/ChartInternal/data/convert.ts +54 -4
  228. package/src/ChartInternal/data/data.ts +19 -6
  229. package/src/ChartInternal/interactions/eventrect.ts +6 -0
  230. package/src/ChartInternal/interactions/subchart.ts +437 -66
  231. package/src/ChartInternal/internals/color.ts +7 -6
  232. package/src/ChartInternal/internals/domain.ts +15 -3
  233. package/src/ChartInternal/internals/grid.ts +21 -1
  234. package/src/ChartInternal/internals/scale.ts +9 -2
  235. package/src/ChartInternal/internals/selection.ts +1 -1
  236. package/src/ChartInternal/internals/subchart.util.ts +55 -0
  237. package/src/ChartInternal/internals/text.arc.ts +3 -1
  238. package/src/ChartInternal/internals/text.ts +19 -6
  239. package/src/ChartInternal/internals/transform.ts +8 -2
  240. package/src/ChartInternal/internals/type.ts +131 -33
  241. package/src/ChartInternal/shape/IShape.ts +6 -3
  242. package/src/ChartInternal/shape/bar.ts +87 -37
  243. package/src/ChartInternal/shape/core/barRadius.ts +129 -0
  244. package/src/ChartInternal/shape/core/candlestick.ts +1 -1
  245. package/src/ChartInternal/shape/core/path.ts +76 -9
  246. package/src/ChartInternal/shape/funnel.ts +2 -3
  247. package/src/ChartInternal/shape/line.ts +1 -1
  248. package/src/ChartInternal/shape/point.ts +27 -13
  249. package/src/ChartInternal/shape/shape.ts +172 -18
  250. package/src/Plugin/stanford/index.ts +0 -4
  251. package/src/Plugin/tableview/index.ts +85 -3
  252. package/src/Plugin/textoverlap/index.ts +9 -15
  253. package/src/canvas/CanvasAxisRenderer.ts +184 -36
  254. package/src/canvas/CanvasRenderer.ts +247 -160
  255. package/src/canvas/CanvasTheme.ts +212 -0
  256. package/src/canvas/axisTicks.ts +122 -40
  257. package/src/config/Options/axis/y2.ts +13 -0
  258. package/src/config/Options/common/boost.ts +64 -4
  259. package/src/config/Options/common/color.ts +2 -2
  260. package/src/config/Options/interaction/subchart.ts +98 -1
  261. package/src/config/Options/shape/gauge.ts +1 -1
  262. package/src/config/Options/shape/treemap.ts +2 -2
  263. package/src/config/Store/Element.ts +3 -1
  264. package/src/config/Store/State.ts +1 -0
  265. package/src/config/classes.ts +1 -0
  266. package/src/config/resolver/canvas.ts +92 -10
  267. package/src/module/voronoi.ts +119 -0
  268. package/src/module/worker.entry.ts +61 -0
  269. package/src/module/worker.ts +346 -63
  270. package/src/react/index.ts +193 -0
  271. package/types/options.d.ts +206 -3
  272. package/types/react/index.d.ts +27 -0
package/dist/billboard.js CHANGED
@@ -5,18 +5,18 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.0.2
8
+ * @version 4.1.0-next.1
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
12
- module.exports = factory(require("d3-axis"), require("d3-brush"), require("d3-drag"), require("d3-hierarchy"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom"));
12
+ module.exports = factory(require("d3-brush"), require("d3-drag"), require("d3-hierarchy"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom"));
13
13
  else if(typeof define === 'function' && define.amd)
14
- define(["d3-axis", "d3-brush", "d3-drag", "d3-hierarchy", "d3-interpolate", "d3-scale", "d3-selection", "d3-shape", "d3-time-format", "d3-transition", "d3-zoom"], factory);
14
+ define(["d3-brush", "d3-drag", "d3-hierarchy", "d3-interpolate", "d3-scale", "d3-selection", "d3-shape", "d3-time-format", "d3-transition", "d3-zoom"], factory);
15
15
  else {
16
- var a = typeof exports === 'object' ? factory(require("d3-axis"), require("d3-brush"), require("d3-drag"), require("d3-hierarchy"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom")) : factory(root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"]);
16
+ var a = typeof exports === 'object' ? factory(require("d3-brush"), require("d3-drag"), require("d3-hierarchy"), require("d3-interpolate"), require("d3-scale"), require("d3-selection"), require("d3-shape"), require("d3-time-format"), require("d3-transition"), require("d3-zoom")) : factory(root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"], root["d3"]);
17
17
  for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
18
18
  }
19
- })(this, function(__WEBPACK_EXTERNAL_MODULE__10__, __WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__12__, __WEBPACK_EXTERNAL_MODULE__11__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__2__, __WEBPACK_EXTERNAL_MODULE__4__, __WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__9__) {
19
+ })(this, function(__WEBPACK_EXTERNAL_MODULE__7__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__11__, __WEBPACK_EXTERNAL_MODULE__10__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__2__, __WEBPACK_EXTERNAL_MODULE__4__, __WEBPACK_EXTERNAL_MODULE__5__, __WEBPACK_EXTERNAL_MODULE__8__, __WEBPACK_EXTERNAL_MODULE__9__) {
20
20
  return /******/ (function() { // webpackBootstrap
21
21
  /******/ "use strict";
22
22
  /******/ var __webpack_modules__ = ([
@@ -81,12 +81,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__10__;
81
81
 
82
82
  module.exports = __WEBPACK_EXTERNAL_MODULE__11__;
83
83
 
84
- /***/ }),
85
- /* 12 */
86
- /***/ (function(module) {
87
-
88
- module.exports = __WEBPACK_EXTERNAL_MODULE__12__;
89
-
90
84
  /***/ })
91
85
  /******/ ]);
92
86
  /************************************************************************/
@@ -1042,7 +1036,7 @@ function getScale(type = "linear", min, max) {
1042
1036
  * @private
1043
1037
  */
1044
1038
  updateScales(isInit, updateXDomain = true) {
1045
- var _a, _b, _c, _d, _e, _f;
1039
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
1046
1040
  const $$ = this;
1047
1041
  const {
1048
1042
  axis,
@@ -1078,7 +1072,12 @@ function getScale(type = "linear", min, max) {
1078
1072
  format.subXAxisTick = axis.getXAxisTickFormat(true);
1079
1073
  axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
1080
1074
  if (config.subchart_show) {
1081
- axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit);
1075
+ axis.setAxis(
1076
+ "subX",
1077
+ scale.subX,
1078
+ (_f = config.subchart_axis_x_tick_outer) != null ? _f : config.axis_x_tick_outer,
1079
+ isInit
1080
+ );
1082
1081
  }
1083
1082
  scale.y = $$.getYScale(
1084
1083
  "y",
@@ -1095,7 +1094,13 @@ function getScale(type = "linear", min, max) {
1095
1094
  scale.subY
1096
1095
  );
1097
1096
  axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
1098
- if (config.axis_y2_show) {
1097
+ config.subchart_show && config.subchart_axis_y_show && axis.setAxis(
1098
+ "subY",
1099
+ scale.subY,
1100
+ (_g = config.subchart_axis_y_tick_outer) != null ? _g : config.axis_y_tick_outer,
1101
+ isInit
1102
+ );
1103
+ if (config.axis_y2_show || config.subchart_axis_y2_show) {
1099
1104
  scale.y2 = $$.getYScale(
1100
1105
  "y2",
1101
1106
  min.y,
@@ -1111,13 +1116,19 @@ function getScale(type = "linear", min, max) {
1111
1116
  scale.subY2
1112
1117
  );
1113
1118
  axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
1119
+ config.subchart_show && config.subchart_axis_y2_show && axis.setAxis(
1120
+ "subY2",
1121
+ scale.subY2,
1122
+ (_h = config.subchart_axis_y2_tick_outer) != null ? _h : config.axis_y2_tick_outer,
1123
+ isInit
1124
+ );
1114
1125
  }
1115
1126
  } else if (hasTreemap) {
1116
1127
  const padding = $$.getCurrentPadding();
1117
1128
  scale.x = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear)().rangeRound([padding.left, current.width - padding.right]);
1118
1129
  scale.y = (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleLinear)().rangeRound([padding.top, current.height - padding.bottom]);
1119
1130
  } else {
1120
- (_f = $$.updateArc) == null ? void 0 : _f.call($$);
1131
+ (_i = $$.updateArc) == null ? void 0 : _i.call($$);
1121
1132
  }
1122
1133
  },
1123
1134
  /**
@@ -1326,6 +1337,10 @@ function markCanvasPointOccupancy(grid, x, y) {
1326
1337
 
1327
1338
 
1328
1339
 
1340
+ function getAxisTickOption(config, id, key, prefix = `axis_${id}`) {
1341
+ const value = config[`${prefix}_tick_${key}`];
1342
+ return value !== void 0 ? value : config[`axis_${id}_tick_${key}`];
1343
+ }
1329
1344
  function getOptionTickValues(values, api) {
1330
1345
  const resolved = typeof values === "function" ? values.call(api) : values;
1331
1346
  return (resolved == null ? void 0 : resolved.length) ? resolved : void 0;
@@ -1618,52 +1633,59 @@ function getXTickValues($$, cull = true) {
1618
1633
  function getSubXTickCullMax($$) {
1619
1634
  const { config, state: { height2, width2 } } = $$;
1620
1635
  const size = config.axis_rotated ? height2 : width2;
1621
- if (config.axis_x_tick_count) {
1622
- return config.axis_x_tick_count;
1636
+ const count = getAxisTickOption(config, "x", "count", "subchart_axis_x");
1637
+ const culling = getAxisTickOption(config, "x", "culling", "subchart_axis_x");
1638
+ const cullingMax = getAxisTickOption(config, "x", "culling_max", "subchart_axis_x");
1639
+ if (count) {
1640
+ return count;
1623
1641
  }
1624
- if (config.axis_x_tick_culling !== false) {
1642
+ if (culling !== false) {
1625
1643
  return Math.min(
1626
- config.axis_x_tick_culling_max || AXIS_DEFAULT_TICK_COUNT,
1644
+ cullingMax || AXIS_DEFAULT_TICK_COUNT,
1627
1645
  Math.max(2, Math.floor(size / 70))
1628
1646
  );
1629
1647
  }
1630
1648
  return void 0;
1631
1649
  }
1632
- function getSubXTickValues($$) {
1650
+ function getSubXTickValues($$, culling = true) {
1633
1651
  var _a, _b, _c, _d;
1634
1652
  const { axis, config, scale } = $$;
1635
1653
  const targetScale = scale.subX;
1636
1654
  const targetsToShow = ((_a = $$.getTargetsToShow) == null ? void 0 : _a.call($$)) || $$.filterTargetsToShow();
1655
+ const tickCount = getAxisTickOption(config, "x", "count", "subchart_axis_x");
1637
1656
  const cullMax = getSubXTickCullMax($$);
1638
- const cull = (ticks) => cullTicks(ticks, cullMax);
1657
+ const cullData = (ticks, sorted = false) => culling ? cullDataTicks($$, ticks, sorted, "subchart_axis_x", cullMax) : ticks;
1639
1658
  if (!targetScale || !(targetsToShow == null ? void 0 : targetsToShow.length)) {
1640
1659
  return [];
1641
1660
  }
1642
- const explicit = getOptionTickValues(config.axis_x_tick_values, $$.api);
1661
+ const explicit = getOptionTickValues(
1662
+ getAxisTickOption(config, "x", "values", "subchart_axis_x"),
1663
+ $$.api
1664
+ );
1643
1665
  if (explicit) {
1644
- return cull(normalizeXTickValues($$, explicit));
1666
+ return cullData(normalizeXTickValues($$, explicit));
1645
1667
  }
1646
1668
  if (config.axis_x_tick_fit && $$.mapTargetsToUniqueXs) {
1647
1669
  const generated2 = generateTickValues(
1648
1670
  $$,
1649
1671
  $$.mapTargetsToUniqueXs(targetsToShow),
1650
- config.axis_x_tick_count,
1672
+ tickCount,
1651
1673
  (_b = axis == null ? void 0 : axis.isTimeSeries) == null ? void 0 : _b.call(axis)
1652
1674
  );
1653
- return cull(generated2);
1675
+ return cullData(generated2, true);
1654
1676
  }
1655
1677
  if (((_c = axis == null ? void 0 : axis.isCategorized) == null ? void 0 : _c.call(axis)) && ((_d = config.axis_x_categories) == null ? void 0 : _d.length)) {
1656
- return cull(config.axis_x_categories.map((_, i) => i));
1678
+ return cullData(config.axis_x_categories.map((_, i) => i), true);
1657
1679
  }
1658
1680
  const generated = getScaleTicks(
1659
1681
  targetScale,
1660
- config.axis_x_tick_count || AXIS_DEFAULT_TICK_COUNT
1682
+ tickCount || AXIS_DEFAULT_TICK_COUNT
1661
1683
  );
1662
- return cull(generated);
1684
+ return cullData(generated, true);
1663
1685
  }
1664
- function getCategoryXTickLineValues($$) {
1686
+ function getCategoryXTickLineValues($$, targetScale = getXScale($$), outerTick = $$.config.axis_x_tick_outer) {
1665
1687
  var _a, _b;
1666
- const scale = getXScale($$);
1688
+ const scale = targetScale;
1667
1689
  const domain = ((_a = scale.orgDomain) == null ? void 0 : _a.call(scale)) || ((_b = scale.domain) == null ? void 0 : _b.call(scale));
1668
1690
  if (!(domain == null ? void 0 : domain.length)) {
1669
1691
  return [];
@@ -1676,7 +1698,7 @@ function getCategoryXTickLineValues($$) {
1676
1698
  const min = Math.ceil(Math.min(start, end));
1677
1699
  const max = Math.floor(Math.max(start, end));
1678
1700
  const values = Array.from({ length: Math.max(0, max - min + 1) }, (_, i) => min + i);
1679
- return $$.config.axis_x_tick_outer ? values.slice(1, -1) : values;
1701
+ return outerTick ? values.slice(1, -1) : values;
1680
1702
  }
1681
1703
  function getXTickLinePosition($$, value, targetScale = getXScale($$)) {
1682
1704
  var _a, _b, _c, _d, _e;
@@ -1692,12 +1714,12 @@ function getXTickLinePosition($$, value, targetScale = getXScale($$)) {
1692
1714
  }
1693
1715
  return scale(normalized);
1694
1716
  }
1695
- function hasOverlappedXTickLineIntervals($$, ticks, tickLineWidth) {
1717
+ function hasOverlappedXTickLineIntervals($$, ticks, tickLineWidth, targetScale = getXScale($$)) {
1696
1718
  if (ticks.length < 2) {
1697
1719
  return false;
1698
1720
  }
1699
1721
  const halfWidth = Math.max(1, tickLineWidth) / 2;
1700
- const positions = ticks.map((tick) => getXTickLinePosition($$, tick)).filter(Number.isFinite).sort((a, b) => a - b);
1722
+ const positions = ticks.map((tick) => getXTickLinePosition($$, tick, targetScale)).filter(Number.isFinite).sort((a, b) => a - b);
1701
1723
  if (positions.length < 2) {
1702
1724
  return false;
1703
1725
  }
@@ -1712,10 +1734,10 @@ function hasOverlappedXTickLineIntervals($$, ticks, tickLineWidth) {
1712
1734
  }
1713
1735
  return false;
1714
1736
  }
1715
- function dedupeXTickLineValues($$, ticks) {
1737
+ function dedupeXTickLineValues($$, ticks, targetScale = getXScale($$)) {
1716
1738
  const seen = /* @__PURE__ */ new Set();
1717
1739
  return ticks.filter((tick) => {
1718
- const pos = getXTickLinePosition($$, tick);
1740
+ const pos = getXTickLinePosition($$, tick, targetScale);
1719
1741
  const key = Math.round(pos);
1720
1742
  if (!Number.isFinite(pos) || seen.has(key)) {
1721
1743
  return false;
@@ -1737,13 +1759,35 @@ function getXTickLineValues($$, textTicks, tickLineWidth = 1) {
1737
1759
  const lineTicks = getXTickValues($$, false);
1738
1760
  return hasOverlappedXTickLineIntervals($$, lineTicks, tickLineWidth) ? textTicks : dedupeXTickLineValues($$, lineTicks);
1739
1761
  }
1740
- function getYTickValues($$, id = "y", count, culling = true) {
1741
- var _a, _b, _c;
1762
+ function getSubXTickLineValues($$, textTicks, tickLineWidth = 1) {
1763
+ var _a;
1742
1764
  const { axis, config, scale } = $$;
1765
+ const targetScale = scale.subX;
1766
+ const culling = getAxisTickOption(config, "x", "culling", "subchart_axis_x");
1767
+ const cullingLines = getAxisTickOption(config, "x", "culling_lines", "subchart_axis_x");
1768
+ const outerTick = getAxisTickOption(config, "x", "outer", "subchart_axis_x");
1769
+ if (!targetScale) {
1770
+ return [];
1771
+ }
1772
+ if ((_a = axis == null ? void 0 : axis.isCategorized) == null ? void 0 : _a.call(axis)) {
1773
+ const categoryLineTicks = getCategoryXTickLineValues($$, targetScale, outerTick);
1774
+ return dedupeXTickLineValues($$, categoryLineTicks, targetScale);
1775
+ }
1776
+ if (culling === false || cullingLines === false) {
1777
+ return textTicks;
1778
+ }
1779
+ const lineTicks = getSubXTickValues($$, false);
1780
+ return hasOverlappedXTickLineIntervals($$, lineTicks, tickLineWidth, targetScale) ? textTicks : dedupeXTickLineValues($$, lineTicks, targetScale);
1781
+ }
1782
+ function getYTickValues($$, id = "y", count, culling = true, targetScale = $$.scale[id], optionPrefix = `axis_${id}`) {
1783
+ var _a, _b, _c;
1784
+ const { axis, config } = $$;
1743
1785
  const prefix = `axis_${id}`;
1744
- const targetScale = scale[id];
1745
- const explicit = getOptionTickValues(config[`${prefix}_tick_values`], $$.api);
1746
- const maybeCull = (ticks) => culling ? cullAxisTicks($$, id, ticks) : ticks;
1786
+ const explicit = getOptionTickValues(
1787
+ getAxisTickOption(config, id, "values", optionPrefix),
1788
+ $$.api
1789
+ );
1790
+ const maybeCull = (ticks) => culling ? cullAxisTicks($$, id, ticks, optionPrefix) : ticks;
1747
1791
  if (explicit) {
1748
1792
  return maybeCull(normalizeYTickValues($$, explicit, id));
1749
1793
  }
@@ -1751,7 +1795,7 @@ function getYTickValues($$, id = "y", count, culling = true) {
1751
1795
  if (stepTicks.length) {
1752
1796
  return maybeCull(stepTicks);
1753
1797
  }
1754
- const tickCount = count != null ? count : config[`${prefix}_tick_count`];
1798
+ const tickCount = count != null ? count : getAxisTickOption(config, id, "count", optionPrefix);
1755
1799
  if (((_a = axis == null ? void 0 : axis.isTimeSeries) == null ? void 0 : _a.call(axis, id)) && config[`${prefix}_tick_time_value`]) {
1756
1800
  return maybeCull(getScaleTicks(targetScale, config[`${prefix}_tick_time_value`]));
1757
1801
  }
@@ -1805,20 +1849,21 @@ function cullTicks(ticks, count) {
1805
1849
  }
1806
1850
  return ticks;
1807
1851
  }
1808
- function cullAxisTicks($$, id, ticks) {
1852
+ function cullAxisTicks($$, id, ticks, optionPrefix = `axis_${id}`) {
1809
1853
  const { config } = $$;
1810
- const prefix = `axis_${id}_tick_culling`;
1811
- if (!config[prefix]) {
1854
+ const culling = getAxisTickOption(config, id, "culling", optionPrefix);
1855
+ if (!culling) {
1812
1856
  return ticks;
1813
1857
  }
1858
+ const cullingMax = getAxisTickOption(config, id, "culling_max", optionPrefix) || AXIS_DEFAULT_TICK_COUNT;
1859
+ const reverse = getAxisTickOption(config, id, "culling_reverse", optionPrefix);
1814
1860
  const sortedTicks = ticks.slice().sort((a, b) => {
1815
1861
  const av = +a;
1816
1862
  const bv = +b;
1817
1863
  const order = Number.isFinite(av) && Number.isFinite(bv) ? av - bv : String(a).localeCompare(String(b));
1818
- return config[`${prefix}_reverse`] ? -order : order;
1864
+ return reverse ? -order : order;
1819
1865
  });
1820
1866
  const tickSize = sortedTicks.length;
1821
- const cullingMax = config[`${prefix}_max`] || AXIS_DEFAULT_TICK_COUNT;
1822
1867
  let intervalForCulling = 0;
1823
1868
  for (let i = 1; i < tickSize; i++) {
1824
1869
  if (tickSize / i < cullingMax) {
@@ -1834,19 +1879,21 @@ function cullAxisTicks($$, id, ticks) {
1834
1879
  );
1835
1880
  return ticks.filter((tick) => visible.has(tick));
1836
1881
  }
1837
- function cullDataTicks($$, ticks, sorted = false) {
1882
+ function cullDataTicks($$, ticks, sorted = false, optionPrefix = "axis_x", max) {
1838
1883
  const { config } = $$;
1839
- if (config.axis_x_tick_culling === false) {
1884
+ const culling = getAxisTickOption(config, "x", "culling", optionPrefix);
1885
+ if (culling === false) {
1840
1886
  return ticks;
1841
1887
  }
1842
- const cullingMax = config.axis_x_tick_culling_max || AXIS_DEFAULT_TICK_COUNT;
1888
+ const cullingMax = max || getAxisTickOption(config, "x", "culling_max", optionPrefix) || AXIS_DEFAULT_TICK_COUNT;
1889
+ const reverse = getAxisTickOption(config, "x", "culling_reverse", optionPrefix);
1843
1890
  const sortedTicks = sorted ? ticks : ticks.slice().sort((a, b) => {
1844
1891
  const av = +a;
1845
1892
  const bv = +b;
1846
1893
  if (Number.isFinite(av) && Number.isFinite(bv)) {
1847
- return config.axis_x_tick_culling_reverse ? bv - av : av - bv;
1894
+ return reverse ? bv - av : av - bv;
1848
1895
  }
1849
- return config.axis_x_tick_culling_reverse ? String(b).localeCompare(String(a)) : String(a).localeCompare(String(b));
1896
+ return reverse ? String(b).localeCompare(String(a)) : String(a).localeCompare(String(b));
1850
1897
  });
1851
1898
  const tickSize = sortedTicks.length;
1852
1899
  let intervalForCulling = 0;
@@ -1861,7 +1908,7 @@ function cullDataTicks($$, ticks, sorted = false) {
1861
1908
  }
1862
1909
  if (sorted) {
1863
1910
  return ticks.filter(
1864
- (_, i) => config.axis_x_tick_culling_reverse ? (tickSize - 1 - i) % intervalForCulling === 0 : i % intervalForCulling === 0
1911
+ (_, i) => reverse ? (tickSize - 1 - i) % intervalForCulling === 0 : i % intervalForCulling === 0
1865
1912
  );
1866
1913
  }
1867
1914
  const visible = new Set(
@@ -2323,6 +2370,29 @@ function getXTickTextDirection(isRotated) {
2323
2370
  function getYTickTextDirection(isRotated, isY2) {
2324
2371
  return isRotated ? isY2 ? -1 : 1 : isY2 ? 1 : -1;
2325
2372
  }
2373
+ function getSubYTickFormat($$, id) {
2374
+ var _a, _b, _c;
2375
+ const subAxisId = id === "y2" ? "subY2" : "subY";
2376
+ const axisFormat = (_c = (_b = (_a = $$.axis) == null ? void 0 : _a[subAxisId]) == null ? void 0 : _b.tickFormat) == null ? void 0 : _c.call(_b);
2377
+ const configFormat = $$.config[`subchart_axis_${id}_tick_format`] || $$.config[`axis_${id}_tick_format`];
2378
+ if (axisFormat) {
2379
+ return axisFormat;
2380
+ }
2381
+ return typeof configFormat === "function" ? configFormat.bind($$.api) : ((v) => v);
2382
+ }
2383
+ function getGridLineCanvasStyle(style) {
2384
+ return style ? {
2385
+ stroke: style.lineColor,
2386
+ lineWidth: style.lineWidth,
2387
+ lineDash: style.dashArray
2388
+ } : void 0;
2389
+ }
2390
+ function getGridTextCanvasStyle(style) {
2391
+ return style ? {
2392
+ fill: style.labelColor,
2393
+ font: style.labelFont
2394
+ } : void 0;
2395
+ }
2326
2396
  function getHorizontalXAxisClipRect(margin, width, height) {
2327
2397
  return {
2328
2398
  x: margin.left - X_AXIS_TICK_TEXT_HORIZONTAL_CLIP_PADDING,
@@ -2647,7 +2717,7 @@ class CanvasAxisRenderer {
2647
2717
  * @private
2648
2718
  */
2649
2719
  drawSubXAxis($$) {
2650
- var _a, _b, _c;
2720
+ var _a, _b, _c, _d;
2651
2721
  const { ctx, painter, theme: { style: { axis } } } = this;
2652
2722
  const {
2653
2723
  config,
@@ -2668,12 +2738,14 @@ class CanvasAxisRenderer {
2668
2738
  const rangeStart = isRotated ? y1 : x1;
2669
2739
  const rangeEnd = isRotated ? y2 : x2;
2670
2740
  const ticks = getSubXTickValues($$);
2741
+ const lineTicks = getSubXTickLineValues($$, ticks, axis.tickWidth);
2742
+ const outerTick = (_a = config.subchart_axis_x_tick_outer) != null ? _a : config.axis_x_tick_outer;
2671
2743
  const tickDirection = isRotated ? config.axis_x_tick_inner ? 1 : -1 : config.axis_x_tick_inner ? -1 : 1;
2672
2744
  const outerTickDirection = getXOuterTickDirection(isRotated);
2673
2745
  const tickTextDirection = getXTickTextDirection(isRotated);
2674
2746
  const tickTextPosition = config.axis_x_tick_text_position;
2675
- const tickRotate = !isRotated ? ((_a = $$.getAxisTickRotate) == null ? void 0 : _a.call($$, "x")) || 0 : 0;
2676
- const tickFormat = format.subXAxisTick || ((_c = (_b = $$.axis) == null ? void 0 : _b.getXAxisTickFormat) == null ? void 0 : _c.call(_b, true));
2747
+ const tickRotate = !isRotated ? ((_b = $$.getAxisTickRotate) == null ? void 0 : _b.call($$, "x")) || 0 : 0;
2748
+ const tickFormat = format.subXAxisTick || ((_d = (_c = $$.axis) == null ? void 0 : _c.getXAxisTickFormat) == null ? void 0 : _d.call(_c, true));
2677
2749
  painter.clipRect(
2678
2750
  isRotated ? getRotatedXAxisClipRect(margin2, current.width, height2) : __spreadProps(CanvasAxisRenderer_spreadValues({}, getHorizontalXAxisClipRect(
2679
2751
  margin2,
@@ -2683,15 +2755,17 @@ class CanvasAxisRenderer {
2683
2755
  y: margin2.top
2684
2756
  }),
2685
2757
  () => {
2758
+ ctx.globalAlpha = 1;
2686
2759
  ctx.strokeStyle = axis.lineColor;
2687
2760
  ctx.lineWidth = axis.lineWidth;
2761
+ ctx.setLineDash([]);
2688
2762
  painter.strokePath(() => {
2689
2763
  if (isRotated) {
2690
2764
  painter.traceLine(x, y1, x, y2);
2691
2765
  } else {
2692
2766
  painter.traceLine(x1, y, x2, y);
2693
2767
  }
2694
- if (config.axis_x_tick_outer) {
2768
+ if (outerTick) {
2695
2769
  if (isRotated) {
2696
2770
  painter.traceLine(x, y1, x + AXIS_TICK_SIZE * outerTickDirection, y1);
2697
2771
  painter.traceLine(x, y2, x + AXIS_TICK_SIZE * outerTickDirection, y2);
@@ -2710,15 +2784,15 @@ class CanvasAxisRenderer {
2710
2784
  ctx.lineWidth = axis.tickWidth;
2711
2785
  const lineHeight = getXTickTextLineHeight(painter, getFontSize(tickFont));
2712
2786
  const tickTextWidth = getXTickTextWidth($$, ticks, isRotated, scale.subX);
2713
- for (const tick of ticks) {
2714
- const tickPos = scale.subX(normalizeXValue($$, tick));
2715
- const tx = margin2.left + tickPos;
2716
- const ty = margin2.top + tickPos;
2717
- const pos = isRotated ? ty : tx;
2718
- if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
2719
- continue;
2720
- }
2721
- if (config.subchart_axis_x_tick_show) {
2787
+ if (config.subchart_axis_x_tick_show) {
2788
+ for (const tick of lineTicks) {
2789
+ const tickPos = scale.subX(normalizeXValue($$, tick));
2790
+ const tx = margin2.left + tickPos;
2791
+ const ty = margin2.top + tickPos;
2792
+ const pos = isRotated ? ty : tx;
2793
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
2794
+ continue;
2795
+ }
2722
2796
  painter.strokePath(() => {
2723
2797
  if (isRotated) {
2724
2798
  painter.traceLine(x, ty, x + AXIS_TICK_SIZE * tickDirection, ty);
@@ -2727,6 +2801,15 @@ class CanvasAxisRenderer {
2727
2801
  }
2728
2802
  });
2729
2803
  }
2804
+ }
2805
+ for (const tick of ticks) {
2806
+ const tickPos = scale.subX(normalizeXValue($$, tick));
2807
+ const tx = margin2.left + tickPos;
2808
+ const ty = margin2.top + tickPos;
2809
+ const pos = isRotated ? ty : tx;
2810
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
2811
+ continue;
2812
+ }
2730
2813
  if (!config.subchart_axis_x_tick_text_show) {
2731
2814
  continue;
2732
2815
  }
@@ -2764,6 +2847,42 @@ class CanvasAxisRenderer {
2764
2847
  }
2765
2848
  );
2766
2849
  }
2850
+ /**
2851
+ * Draw the canvas subchart y/y2 axes.
2852
+ * @param {object} $$ ChartInternal instance
2853
+ * @private
2854
+ */
2855
+ drawSubYAxes($$) {
2856
+ const {
2857
+ config,
2858
+ scale,
2859
+ state: { margin2, width2, height2 }
2860
+ } = $$;
2861
+ if (!config.subchart_show || width2 <= 0 || height2 <= 0) {
2862
+ return;
2863
+ }
2864
+ ["y", "y2"].forEach((id) => {
2865
+ var _a;
2866
+ const subScale = id === "y2" ? scale.subY2 : scale.subY;
2867
+ if (!config[`subchart_axis_${id}_show`] || !subScale) {
2868
+ return;
2869
+ }
2870
+ this.drawYAxis($$, id, {
2871
+ scale: subScale,
2872
+ ticks: getYTickValues($$, id, void 0, true, subScale, `subchart_axis_${id}`),
2873
+ format: getSubYTickFormat($$, id),
2874
+ index: 0,
2875
+ outerTick: (_a = config[`subchart_axis_${id}_tick_outer`]) != null ? _a : config[`axis_${id}_tick_outer`],
2876
+ margin: margin2,
2877
+ width: width2,
2878
+ height: height2,
2879
+ prefix: `subchart_axis_${id}`,
2880
+ tickShow: config[`subchart_axis_${id}_tick_show`],
2881
+ tickTextShow: config[`subchart_axis_${id}_tick_text_show`],
2882
+ tickTextPosition: config[`axis_${id}_tick_text_position`]
2883
+ });
2884
+ });
2885
+ }
2767
2886
  /**
2768
2887
  * Draw chart title.
2769
2888
  * @param {object} $$ ChartInternal instance
@@ -2994,14 +3113,21 @@ class CanvasAxisRenderer {
2994
3113
  ctx.fillStyle = grid.labelColor;
2995
3114
  ctx.textBaseline = "middle";
2996
3115
  ctx.setLineDash([]);
2997
- const drawLabel = (text, x, y, rotated = false) => {
3116
+ const drawLabel = (text, x, y, rotated = false, style) => {
2998
3117
  if (!text) {
2999
3118
  return;
3000
3119
  }
3001
- painter.text(text, x, y, {
3120
+ painter.text(text, x, y, __spreadProps(CanvasAxisRenderer_spreadValues({}, style), {
3002
3121
  angle: rotated ? -90 : 0
3003
- });
3122
+ }));
3004
3123
  };
3124
+ const drawLine = (line, axisId, draw) => {
3125
+ const style = getGridLineCanvasStyle(
3126
+ this.theme.getGridLineStyle(axisId, line, "line")
3127
+ );
3128
+ painter.strokePath(draw, style);
3129
+ };
3130
+ const getTextStyle = (axisId, line) => getGridTextCanvasStyle(this.theme.getGridLineStyle(axisId, line, "text"));
3005
3131
  const drawXLine = (line) => {
3006
3132
  if (line.value === void 0 || !scale.x) {
3007
3133
  return;
@@ -3012,18 +3138,20 @@ class CanvasAxisRenderer {
3012
3138
  }
3013
3139
  if (isRotated) {
3014
3140
  const y = margin.top + pos;
3015
- painter.strokePath(() => {
3141
+ drawLine(line, "x", () => {
3016
3142
  painter.traceLine(x1, y, x2, y);
3017
3143
  });
3018
3144
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
3019
3145
  drawLabel(
3020
3146
  line.text,
3021
3147
  getLineTextPosition(line.position, x1, x2),
3022
- y - 5
3148
+ y - 5,
3149
+ false,
3150
+ getTextStyle("x", line)
3023
3151
  );
3024
3152
  } else {
3025
3153
  const x = margin.left + pos;
3026
- painter.strokePath(() => {
3154
+ drawLine(line, "x", () => {
3027
3155
  painter.traceLine(x, y1, x, y2);
3028
3156
  });
3029
3157
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
@@ -3031,7 +3159,8 @@ class CanvasAxisRenderer {
3031
3159
  line.text,
3032
3160
  x - 5,
3033
3161
  getRotatedLineTextPosition(line.position, y1, y2),
3034
- true
3162
+ true,
3163
+ getTextStyle("x", line)
3035
3164
  );
3036
3165
  }
3037
3166
  };
@@ -3048,7 +3177,7 @@ class CanvasAxisRenderer {
3048
3177
  }
3049
3178
  if (isRotated) {
3050
3179
  const x = margin.left + pos;
3051
- painter.strokePath(() => {
3180
+ drawLine(line, "y", () => {
3052
3181
  painter.traceLine(x, y1, x, y2);
3053
3182
  });
3054
3183
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
@@ -3056,18 +3185,21 @@ class CanvasAxisRenderer {
3056
3185
  line.text,
3057
3186
  x - 5,
3058
3187
  getRotatedLineTextPosition(line.position, y1, y2),
3059
- true
3188
+ true,
3189
+ getTextStyle("y", line)
3060
3190
  );
3061
3191
  } else {
3062
3192
  const y = margin.top + pos;
3063
- painter.strokePath(() => {
3193
+ drawLine(line, "y", () => {
3064
3194
  painter.traceLine(x1, y, x2, y);
3065
3195
  });
3066
3196
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
3067
3197
  drawLabel(
3068
3198
  line.text,
3069
3199
  getLineTextPosition(line.position, x1, x2),
3070
- y - 5
3200
+ y - 5,
3201
+ false,
3202
+ getTextStyle("y", line)
3071
3203
  );
3072
3204
  }
3073
3205
  };
@@ -3458,31 +3590,37 @@ class CanvasAxisRenderer {
3458
3590
  * @private
3459
3591
  */
3460
3592
  drawYAxis($$, id = "y", axisOptions) {
3461
- var _a, _b, _c, _d;
3593
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3462
3594
  const { ctx, painter, theme: { style: { axis } } } = this;
3463
- const { config, scale, state: { margin, width, height } } = $$;
3464
- const prefix = `axis_${id}`;
3595
+ const { config, scale, state } = $$;
3596
+ const { margin, width, height } = state;
3597
+ const plotMargin = (axisOptions == null ? void 0 : axisOptions.margin) || margin;
3598
+ const plotWidth = (_a = axisOptions == null ? void 0 : axisOptions.width) != null ? _a : width;
3599
+ const plotHeight = (_b = axisOptions == null ? void 0 : axisOptions.height) != null ? _b : height;
3600
+ const prefix = (axisOptions == null ? void 0 : axisOptions.prefix) || `axis_${id}`;
3465
3601
  const targetScale = (axisOptions == null ? void 0 : axisOptions.scale) || scale[id];
3466
3602
  const isY2 = id === "y2";
3467
3603
  const isRotated = config.axis_rotated;
3468
3604
  const axisOffset = (axisOptions == null ? void 0 : axisOptions.index) ? $$.getAxisSize(id) * axisOptions.index : 0;
3469
3605
  const x = painter.crisp(
3470
- margin.left + (isY2 ? width + (isRotated ? 0 : axisOffset) : -axisOffset),
3606
+ plotMargin.left + (isY2 ? plotWidth + (isRotated ? 0 : axisOffset) : -axisOffset),
3471
3607
  axis.lineWidth
3472
3608
  );
3473
- const y = painter.crisp(margin.top + (isRotated ? isY2 ? -axisOffset - 1 : height + axisOffset : 0), axis.lineWidth);
3474
- const x1 = margin.left;
3475
- const x2 = margin.left + width;
3476
- const y1 = margin.top;
3477
- const y2 = margin.top + height;
3609
+ const y = painter.crisp(plotMargin.top + (isRotated ? isY2 ? -axisOffset - 1 : plotHeight + axisOffset : 0), axis.lineWidth);
3610
+ const x1 = plotMargin.left;
3611
+ const x2 = plotMargin.left + plotWidth;
3612
+ const y1 = plotMargin.top;
3613
+ const y2 = plotMargin.top + plotHeight;
3478
3614
  const ticks = (axisOptions == null ? void 0 : axisOptions.ticks) || getYTickValues($$, id);
3479
3615
  const lineTicks = (axisOptions == null ? void 0 : axisOptions.ticks) || (config[`${prefix}_tick_culling`] && config[`${prefix}_tick_culling_lines`] !== false ? getYTickValues($$, id, void 0, false) : ticks);
3480
- const format = (axisOptions == null ? void 0 : axisOptions.format) || ((_c = (_b = (_a = $$.axis) == null ? void 0 : _a[id]) == null ? void 0 : _b.tickFormat) == null ? void 0 : _c.call(_b)) || ((_d = config[`${prefix}_tick_format`]) == null ? void 0 : _d.bind($$.api)) || ((v) => v);
3616
+ const format = (axisOptions == null ? void 0 : axisOptions.format) || ((_e = (_d = (_c = $$.axis) == null ? void 0 : _c[id]) == null ? void 0 : _d.tickFormat) == null ? void 0 : _e.call(_d)) || ((_f = config[`${prefix}_tick_format`]) == null ? void 0 : _f.bind($$.api)) || ((v) => v);
3481
3617
  const outerTick = axisOptions ? axisOptions.outerTick : config[`${prefix}_tick_outer`];
3482
3618
  const tickDirection = isRotated ? isY2 ? config.axis_y2_tick_inner ? 1 : -1 : config.axis_y_tick_inner ? -1 : 1 : isY2 ? config.axis_y2_tick_inner ? -1 : 1 : config.axis_y_tick_inner ? 1 : -1;
3483
3619
  const outerTickDirection = getYOuterTickDirection(config, isRotated, isY2);
3484
3620
  const tickTextDirection = getYTickTextDirection(isRotated, isY2);
3485
- const tickTextPosition = config[`${prefix}_tick_text_position`];
3621
+ const tickTextPosition = (axisOptions == null ? void 0 : axisOptions.tickTextPosition) || config[`${prefix}_tick_text_position`] || config[`axis_${id}_tick_text_position`];
3622
+ const tickShow = (_g = axisOptions == null ? void 0 : axisOptions.tickShow) != null ? _g : axisOptions ? true : config[`${prefix}_tick_show`];
3623
+ const tickTextShow = (_h = axisOptions == null ? void 0 : axisOptions.tickTextShow) != null ? _h : axisOptions ? true : config[`${prefix}_tick_text_show`];
3486
3624
  painter.withState(() => {
3487
3625
  ctx.strokeStyle = axis.lineColor;
3488
3626
  ctx.lineWidth = axis.lineWidth;
@@ -3513,8 +3651,8 @@ class CanvasAxisRenderer {
3513
3651
  const drawableLineTicks = [];
3514
3652
  const addDrawableTick = (tick, target) => {
3515
3653
  const value = normalizeYValue($$, tick, id);
3516
- const tx = margin.left + targetScale(value);
3517
- const ty = margin.top + targetScale(value);
3654
+ const tx = plotMargin.left + targetScale(value);
3655
+ const ty = plotMargin.top + targetScale(value);
3518
3656
  const pos = isRotated ? tx : ty;
3519
3657
  if (!isDrawable(pos)) {
3520
3658
  return;
@@ -3527,7 +3665,7 @@ class CanvasAxisRenderer {
3527
3665
  for (const tick of lineTicks) {
3528
3666
  addDrawableTick(tick, drawableLineTicks);
3529
3667
  }
3530
- if (axisOptions || config[`${prefix}_tick_show`]) {
3668
+ if (tickShow) {
3531
3669
  painter.strokePath(() => {
3532
3670
  for (const { tx, ty } of drawableLineTicks) {
3533
3671
  if (isRotated) {
@@ -3538,7 +3676,7 @@ class CanvasAxisRenderer {
3538
3676
  }
3539
3677
  });
3540
3678
  }
3541
- if (axisOptions || config[`${prefix}_tick_text_show`]) {
3679
+ if (tickTextShow) {
3542
3680
  for (const { tick, tx, ty } of drawableTicks) {
3543
3681
  if (isRotated) {
3544
3682
  painter.text(
@@ -3730,8 +3868,112 @@ class CanvasEngine {
3730
3868
  }
3731
3869
  }
3732
3870
 
3871
+ ;// ./src/ChartInternal/internals/subchart.util.ts
3872
+ function isContinuousGridFocusEnabled($$) {
3873
+ const { config, state } = $$;
3874
+ return !!(config.subchart_grid_focus_continuous && config.subchart_grid_focus !== false && config.subchart_show && config.subchart_brush_enabled === false && state.width2 > 0 && state.height2 > 0);
3875
+ }
3876
+ function getMainCoordFromSubchartCoord($$, subCoord) {
3877
+ var _a;
3878
+ const { config, scale, state } = $$;
3879
+ const mainX = scale.zoom || scale.x;
3880
+ const subX = scale.subX;
3881
+ if (!mainX || !subX) {
3882
+ return null;
3883
+ }
3884
+ const subLength = config.axis_rotated ? state.height2 : state.width2;
3885
+ const mainLength = config.axis_rotated ? state.height : state.width;
3886
+ const domainValue = (_a = subX.invert) == null ? void 0 : _a.call(subX, subCoord);
3887
+ let mainCoord = domainValue == null ? NaN : mainX(domainValue);
3888
+ if (!Number.isFinite(mainCoord) && subLength > 0) {
3889
+ mainCoord = Math.max(0, Math.min(1, subCoord / subLength)) * mainLength;
3890
+ }
3891
+ return Number.isFinite(mainCoord) ? Math.max(0, Math.min(mainLength, mainCoord)) : null;
3892
+ }
3893
+
3733
3894
  ;// ./src/ChartInternal/shape/core/barRadius.ts
3734
3895
 
3896
+ const RE_PATH_NUMBER = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
3897
+ const RE_PATH_TOKEN = /([aAcChHlLmMqQsStTvVzZ])|([-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?)/g;
3898
+ function getArcFlagTokenIndexes(path) {
3899
+ const flags = /* @__PURE__ */ new Set();
3900
+ let numIndex = -1;
3901
+ let argIndex = 0;
3902
+ let inArc = false;
3903
+ let token;
3904
+ RE_PATH_TOKEN.lastIndex = 0;
3905
+ while (token = RE_PATH_TOKEN.exec(path)) {
3906
+ if (token[1]) {
3907
+ inArc = token[1] === "a" || token[1] === "A";
3908
+ argIndex = 0;
3909
+ } else {
3910
+ numIndex++;
3911
+ if (inArc) {
3912
+ const pos = argIndex % 7;
3913
+ if (pos === 2 || pos === 3 || pos === 4) {
3914
+ flags.add(numIndex);
3915
+ }
3916
+ argIndex++;
3917
+ }
3918
+ }
3919
+ }
3920
+ return flags;
3921
+ }
3922
+ function getBarPathInterpolator(a, b) {
3923
+ const flagSet = getArcFlagTokenIndexes(b);
3924
+ const segments = [];
3925
+ const interpolators = [];
3926
+ let bIndex = 0;
3927
+ let segIndex = -1;
3928
+ let numIndex = -1;
3929
+ let am;
3930
+ let bm;
3931
+ const append = (text) => {
3932
+ if (segments[segIndex]) {
3933
+ segments[segIndex] += text;
3934
+ } else {
3935
+ segments[++segIndex] = text;
3936
+ }
3937
+ };
3938
+ RE_PATH_NUMBER.lastIndex = 0;
3939
+ const reA = RE_PATH_NUMBER;
3940
+ const reB = new RegExp(RE_PATH_NUMBER.source, "g");
3941
+ a += "";
3942
+ b += "";
3943
+ while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
3944
+ numIndex++;
3945
+ if (bm.index > bIndex) {
3946
+ append(b.slice(bIndex, bm.index));
3947
+ }
3948
+ if (am[0] === bm[0]) {
3949
+ append(bm[0]);
3950
+ } else {
3951
+ const from = +am[0];
3952
+ const to = +bm[0];
3953
+ const isFlag = flagSet.has(numIndex);
3954
+ segments[++segIndex] = null;
3955
+ interpolators.push({
3956
+ index: segIndex,
3957
+ fn: isFlag ? (t) => Math.round(from + (to - from) * t) : (t) => from + (to - from) * t
3958
+ });
3959
+ }
3960
+ bIndex = reB.lastIndex;
3961
+ }
3962
+ if (bIndex < b.length) {
3963
+ append(b.slice(bIndex));
3964
+ }
3965
+ if (!interpolators.length) {
3966
+ const result = segments.join("");
3967
+ return () => result;
3968
+ }
3969
+ return (t) => {
3970
+ for (let i = 0, len = interpolators.length; i < len; i++) {
3971
+ const { index, fn } = interpolators[i];
3972
+ segments[index] = String(fn(t));
3973
+ }
3974
+ return segments.join("");
3975
+ };
3976
+ }
3735
3977
  function getBarRadiusResolver($$) {
3736
3978
  const { bar_radius: radius, bar_radius_ratio: ratio } = $$.config;
3737
3979
  return isNumber(radius) && radius > 0 ? () => radius : isNumber(ratio) ? (width) => width * ratio : null;
@@ -3969,6 +4211,26 @@ var path_spreadValues = (a, b) => {
3969
4211
  };
3970
4212
  var path_spreadProps = (a, b) => path_defProps(a, path_getOwnPropDescs(b));
3971
4213
 
4214
+ function getPathValueFn($$, isSub) {
4215
+ if (!isSub) {
4216
+ return (d) => $$.getBaseValue(d);
4217
+ }
4218
+ return (d) => {
4219
+ var _a;
4220
+ const value = (_a = $$.getSubchartCandlestickShapeValue) == null ? void 0 : _a.call($$, d, true);
4221
+ return value === void 0 ? $$.getBaseValue(d) : value;
4222
+ };
4223
+ }
4224
+ function getProjectedValues($$, values, isSub) {
4225
+ if (!isSub) {
4226
+ return values;
4227
+ }
4228
+ return values.map((d) => {
4229
+ var _a;
4230
+ const value = (_a = $$.getSubchartCandlestickShapeValue) == null ? void 0 : _a.call($$, d, isSub);
4231
+ return value === void 0 ? d : path_spreadProps(path_spreadValues({}, d), { value });
4232
+ });
4233
+ }
3972
4234
  function getLineValues($$, d, values) {
3973
4235
  return $$.isStepType(d) ? $$.convertValuesToStep(values) : values;
3974
4236
  }
@@ -3978,13 +4240,16 @@ function generateDrawLinePath($$, lineIndices, isSub, context) {
3978
4240
  const isRotated = config.axis_rotated;
3979
4241
  const getPoints = $$.generateGetLinePoints(lineIndices, isSub);
3980
4242
  const yScale = $$.getYScaleById.bind($$);
4243
+ const pathValue = getPathValueFn($$, isSub);
3981
4244
  const xValue = (d) => (isSub ? $$.subxx : $$.xx).call($$, d);
3982
- const yValue = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
4245
+ const yValue = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)(
4246
+ pathValue(d)
4247
+ );
3983
4248
  let line = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.line)();
3984
4249
  line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
3985
4250
  context && (line = line.context(context));
3986
4251
  if (!lineConnectNull) {
3987
- line = line.defined((d) => $$.getBaseValue(d) !== null);
4252
+ line = line.defined((d) => pathValue(d) !== null);
3988
4253
  }
3989
4254
  const x = isSub ? scale.subX : scale.x;
3990
4255
  return (d) => {
@@ -3996,6 +4261,7 @@ function generateDrawLinePath($$, lineIndices, isSub, context) {
3996
4261
  if ($$.isLineType(d)) {
3997
4262
  const regions = config.data_regions[d.id];
3998
4263
  if (regions && !context && $$.lineWithRegions) {
4264
+ values = getProjectedValues($$, values, isSub);
3999
4265
  if ($$.isAreaRangeType(d)) {
4000
4266
  values = values.map((dv) => path_spreadProps(path_spreadValues({}, dv), { value: $$.getRangedData(dv, "mid") }));
4001
4267
  }
@@ -4009,7 +4275,7 @@ function generateDrawLinePath($$, lineIndices, isSub, context) {
4009
4275
  } else {
4010
4276
  if (values[0]) {
4011
4277
  x0 = x(values[0].x);
4012
- y0 = y(values[0].value);
4278
+ y0 = y(pathValue(values[0]));
4013
4279
  }
4014
4280
  path = isRotated ? `M ${y0} ${x0}` : `M ${x0} ${y0}`;
4015
4281
  }
@@ -4022,12 +4288,22 @@ function generateDrawAreaPath($$, areaIndices, isSub, context) {
4022
4288
  const isRotated = config.axis_rotated;
4023
4289
  const getPoints = $$.generateGetAreaPoints(areaIndices, isSub);
4024
4290
  const yScale = $$.getYScaleById.bind($$);
4291
+ const pathValue = getPathValueFn($$, isSub);
4292
+ const shapeYMin = /* @__PURE__ */ new Map();
4293
+ const getShapeYMin = (id) => {
4294
+ let min = shapeYMin.get(id);
4295
+ if (min === void 0) {
4296
+ min = $$.getShapeYMin(id, isSub);
4297
+ shapeYMin.set(id, min);
4298
+ }
4299
+ return min;
4300
+ };
4025
4301
  const xValue = (d) => (isSub ? $$.subxx : $$.xx).call($$, d);
4026
4302
  const value0 = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)(
4027
- $$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id)
4303
+ $$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : getShapeYMin(d.id)
4028
4304
  );
4029
4305
  const value1 = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)(
4030
- $$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value
4306
+ $$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : pathValue(d)
4031
4307
  );
4032
4308
  return (d) => {
4033
4309
  let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values;
@@ -4036,19 +4312,20 @@ function generateDrawAreaPath($$, areaIndices, isSub, context) {
4036
4312
  let path;
4037
4313
  if ($$.isAreaType(d)) {
4038
4314
  let area = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.area)();
4039
- area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue).y0(config.area_above ? 0 : config.area_below ? $$.state.height : value0).y1(value1);
4315
+ area = isRotated ? area.y(xValue).x0(value0).x1(value1) : area.x(xValue).y0(config.area_above ? 0 : config.area_below ? isSub ? $$.state.height2 : $$.state.height : value0).y1(value1);
4040
4316
  context && (area = area.context(context));
4041
4317
  if (!lineConnectNull) {
4042
- area = area.defined((d2) => $$.getBaseValue(d2) !== null);
4318
+ area = area.defined((d2) => pathValue(d2) !== null);
4043
4319
  }
4320
+ values = getProjectedValues($$, values, isSub);
4044
4321
  if ($$.isStepType(d)) {
4045
4322
  values = $$.convertValuesToStep(values);
4046
4323
  }
4047
4324
  path = area.curve($$.getCurve(d))(values);
4048
4325
  } else {
4049
4326
  if (values[0]) {
4050
- x0 = $$.scale.x(values[0].x);
4051
- y0 = $$.getYScaleById(d.id)(values[0].value);
4327
+ x0 = (isSub ? $$.scale.subX : $$.scale.x)(values[0].x);
4328
+ y0 = $$.getYScaleById(d.id, isSub)(pathValue(values[0]));
4052
4329
  }
4053
4330
  path = isRotated ? `M ${y0} ${x0}` : `M ${x0} ${y0}`;
4054
4331
  }
@@ -4908,6 +5185,7 @@ var CanvasRenderer_publicField = (obj, key, value) => CanvasRenderer_defNormalPr
4908
5185
 
4909
5186
 
4910
5187
 
5188
+
4911
5189
  const RENDERER_GROUPED_TYPE_FILTERS = [
4912
5190
  isCanvasAreaType,
4913
5191
  isCanvasBarType,
@@ -5589,165 +5867,175 @@ class CanvasRenderer {
5589
5867
  /**
5590
5868
  * Draw the canvas subchart overview and brush selection.
5591
5869
  * @param {object} $$ ChartInternal instance
5592
- * @param {object} shape Cached draw shape object
5870
+ * @param {object} _shape Cached main shape object
5593
5871
  * @private
5594
5872
  */
5595
- drawSubchart($$, shape) {
5873
+ drawSubchart($$, _shape) {
5596
5874
  const { config, state } = $$;
5875
+ void _shape;
5597
5876
  if (!config.subchart_show || !state.hasAxis || state.width2 <= 0 || state.height2 <= 0) {
5598
5877
  return;
5599
5878
  }
5600
5879
  const { ctx, painter, theme: { style } } = this;
5601
5880
  const { margin2, width2, height2 } = state;
5602
5881
  const rect = { x: margin2.left, y: margin2.top, w: width2, h: height2 };
5603
- const targets = $$.filterTargetsToShow().filter(isCanvasRenderableTarget.bind(null, $$));
5604
- painter.withState(() => {
5605
- ctx.strokeStyle = style.axis.lineColor;
5606
- ctx.lineWidth = style.axis.lineWidth;
5607
- painter.strokePath(() => {
5608
- if (config.axis_rotated) {
5609
- painter.traceLine(rect.x, rect.y, rect.x, rect.y + rect.h);
5610
- } else {
5611
- painter.traceLine(rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
5612
- }
5613
- });
5614
- painter.clipRect(rect, () => {
5615
- painter.withTranslation(rect.x, rect.y, () => {
5616
- var _a, _b, _c, _d, _e, _f;
5617
- const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
5618
- const areaIndices = getCanvasShapeIndices(
5619
- $$,
5620
- shape,
5621
- TYPE.AREA,
5622
- isCanvasAreaType.bind(null, $$)
5623
- );
5624
- ctx.globalAlpha = style.shape.areaOpacity;
5625
- for (const target of areaTargets) {
5626
- if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
5627
- continue;
5628
- }
5629
- ctx.fillStyle = $$.color(target.id);
5630
- drawCanvasArea($$, target, areaIndices, painter, true);
5631
- }
5632
- ctx.globalAlpha = 1;
5633
- const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
5634
- const barIndices = getCanvasShapeIndices(
5635
- $$,
5636
- shape,
5637
- TYPE.BAR,
5638
- isCanvasBarType.bind(null, $$)
5639
- );
5640
- const getBarPoints = (_a = $$.generateGetBarPoints) == null ? void 0 : _a.call($$, barIndices, true);
5641
- if (getBarPoints) {
5642
- ctx.globalAlpha = style.shape.barOpacity;
5643
- for (const target of barTargets) {
5882
+ $$.withSubchartTypeContext(() => {
5883
+ var _a;
5884
+ const targets = $$.filterTargetsToShow().filter(isCanvasRenderableTarget.bind(null, $$));
5885
+ const shape = $$.getDrawShape();
5886
+ (_a = $$.updateSubchartYDomain) == null ? void 0 : _a.call($$, targets);
5887
+ painter.withState(() => {
5888
+ painter.clipRect(rect, () => {
5889
+ painter.withTranslation(rect.x, rect.y, () => {
5890
+ var _a2, _b, _c, _d, _e, _f;
5891
+ const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
5892
+ const areaIndices = getCanvasShapeIndices(
5893
+ $$,
5894
+ shape,
5895
+ TYPE.AREA,
5896
+ isCanvasAreaType.bind(null, $$)
5897
+ );
5898
+ for (const target of areaTargets) {
5899
+ if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
5900
+ continue;
5901
+ }
5902
+ ctx.globalAlpha = style.shape.areaOpacity * getCanvasTargetFocusOpacity($$, target);
5644
5903
  ctx.fillStyle = $$.color(target.id);
5645
- target.values.forEach((d, i) => {
5646
- if (!hasCanvasDrawableValue($$, d)) {
5647
- return;
5648
- }
5649
- const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
5650
- geometry && painter.fillRect(geometry.rect, { fill: ctx.fillStyle });
5651
- });
5904
+ drawCanvasArea($$, target, areaIndices, painter, true);
5652
5905
  }
5653
5906
  ctx.globalAlpha = 1;
5654
- }
5655
- const candlestickTargets = targets.filter(
5656
- isCanvasCandlestickType.bind(null, $$)
5657
- );
5658
- const candlestickIndices = getCanvasShapeIndices(
5659
- $$,
5660
- shape,
5661
- TYPE.CANDLESTICK,
5662
- isCanvasCandlestickType.bind(null, $$)
5663
- );
5664
- const getCandlestickPoints = (_b = $$.generateGetCandlestickPoints) == null ? void 0 : _b.call(
5665
- $$,
5666
- candlestickIndices,
5667
- true
5668
- );
5669
- if (getCandlestickPoints) {
5670
- ctx.lineWidth = style.shape.candlestickLineWidth;
5671
- for (const target of candlestickTargets) {
5672
- target.values.forEach((d, i) => {
5673
- var _a2;
5674
- const value = (_a2 = $$.getCandlestickData) == null ? void 0 : _a2.call($$, d);
5675
- const geometry = value && getCanvasCandlestickGeometry(
5676
- $$,
5677
- getCandlestickPoints,
5678
- d,
5679
- i
5680
- );
5681
- if (!geometry) {
5682
- return;
5683
- }
5684
- const color = getCandlestickColor($$, { id: target.id }, value);
5685
- ctx.strokeStyle = color;
5686
- ctx.fillStyle = color;
5687
- painter.strokePath(() => {
5688
- painter.traceLine(
5689
- geometry.wickStart[0],
5690
- geometry.wickStart[1],
5691
- geometry.wickEnd[0],
5692
- geometry.wickEnd[1]
5693
- );
5694
- });
5695
- painter.fillRect(geometry.body, { fill: ctx.fillStyle });
5696
- });
5697
- }
5698
- }
5699
- const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
5700
- const lineIndices = getCanvasShapeIndices(
5701
- $$,
5702
- shape,
5703
- TYPE.LINE,
5704
- isCanvasLineType.bind(null, $$)
5705
- );
5706
- ctx.globalAlpha = 1;
5707
- ctx.lineWidth = style.shape.lineWidth;
5708
- for (const target of lineTargets) {
5709
- if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
5710
- continue;
5711
- }
5712
- ctx.strokeStyle = $$.color(target.id);
5713
- drawCanvasLine($$, target, lineIndices, painter, true);
5714
- }
5715
- if (config.point_show && !((_c = $$.isPointFocusOnly) == null ? void 0 : _c.call($$))) {
5716
- const cy = (_d = $$.updateCircleY) == null ? void 0 : _d.call($$, true);
5717
- const cx = (_e = $$.subxx) == null ? void 0 : _e.bind($$);
5718
- if (cx && cy) {
5719
- for (const target of targets) {
5720
- if (!isCanvasScatterType($$, target) && !isCanvasBubbleType($$, target)) {
5721
- continue;
5722
- }
5723
- const color = $$.color(target.id);
5724
- const pointFill = style.shape.pointFillColor || color;
5725
- const pointStroke = style.shape.pointStrokeColor || color;
5726
- const pointLineWidth = pointStroke ? (_f = style.shape.pointLineWidth) != null ? _f : 1 : 0;
5727
- const pointStyle = pointStroke && pointLineWidth > 0 ? {
5728
- fill: pointFill,
5729
- stroke: pointStroke,
5730
- lineWidth: pointLineWidth
5731
- } : { fill: pointFill };
5732
- ctx.globalAlpha = getPointOpacity($$, target);
5907
+ const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
5908
+ const barIndices = getCanvasShapeIndices(
5909
+ $$,
5910
+ shape,
5911
+ TYPE.BAR,
5912
+ isCanvasBarType.bind(null, $$)
5913
+ );
5914
+ const getBarPoints = (_a2 = $$.generateGetBarPoints) == null ? void 0 : _a2.call($$, barIndices, true);
5915
+ if (getBarPoints) {
5916
+ for (const target of barTargets) {
5917
+ ctx.globalAlpha = style.shape.barOpacity * getCanvasTargetFocusOpacity($$, target);
5918
+ ctx.fillStyle = $$.color(target.id);
5733
5919
  target.values.forEach((d, i) => {
5920
+ var _a3;
5734
5921
  if (!hasCanvasDrawableValue($$, d)) {
5735
5922
  return;
5736
5923
  }
5737
- const x = config.axis_rotated ? cy(d, i) : cx(d);
5738
- const y = config.axis_rotated ? cx(d) : cy(d, i);
5739
- const r = Math.min(getTargetPointRadius($$, target, d), 3);
5740
- if (isFiniteCanvasCoordinate(x, y)) {
5741
- drawPointPattern(painter, "circle", x, y, r, pointStyle);
5742
- }
5924
+ const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
5925
+ const fill = ((_a3 = $$.getSubchartCandlestickBarColor) == null ? void 0 : _a3.call($$, d, true)) || ctx.fillStyle;
5926
+ geometry && painter.fillRect(geometry.rect, { fill });
5743
5927
  });
5744
5928
  }
5745
5929
  ctx.globalAlpha = 1;
5746
5930
  }
5747
- }
5931
+ const candlestickTargets = targets.filter(
5932
+ isCanvasCandlestickType.bind(null, $$)
5933
+ );
5934
+ const candlestickIndices = getCanvasShapeIndices(
5935
+ $$,
5936
+ shape,
5937
+ TYPE.CANDLESTICK,
5938
+ isCanvasCandlestickType.bind(null, $$)
5939
+ );
5940
+ const getCandlestickPoints = (_b = $$.generateGetCandlestickPoints) == null ? void 0 : _b.call(
5941
+ $$,
5942
+ candlestickIndices,
5943
+ true
5944
+ );
5945
+ if (getCandlestickPoints) {
5946
+ ctx.lineWidth = style.shape.candlestickLineWidth;
5947
+ for (const target of candlestickTargets) {
5948
+ const targetOpacity = getCanvasTargetFocusOpacity($$, target);
5949
+ ctx.globalAlpha = targetOpacity;
5950
+ target.values.forEach((d, i) => {
5951
+ var _a3;
5952
+ const value = (_a3 = $$.getCandlestickData) == null ? void 0 : _a3.call($$, d);
5953
+ const geometry = value && getCanvasCandlestickGeometry(
5954
+ $$,
5955
+ getCandlestickPoints,
5956
+ d,
5957
+ i
5958
+ );
5959
+ if (!geometry) {
5960
+ return;
5961
+ }
5962
+ const color = getCandlestickColor($$, { id: target.id }, value);
5963
+ ctx.strokeStyle = color;
5964
+ ctx.fillStyle = color;
5965
+ painter.strokePath(() => {
5966
+ painter.traceLine(
5967
+ geometry.wickStart[0],
5968
+ geometry.wickStart[1],
5969
+ geometry.wickEnd[0],
5970
+ geometry.wickEnd[1]
5971
+ );
5972
+ });
5973
+ painter.fillRect(geometry.body, { fill: ctx.fillStyle });
5974
+ });
5975
+ }
5976
+ }
5977
+ const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
5978
+ const lineIndices = getCanvasShapeIndices(
5979
+ $$,
5980
+ shape,
5981
+ TYPE.LINE,
5982
+ isCanvasLineType.bind(null, $$)
5983
+ );
5984
+ ctx.globalAlpha = 1;
5985
+ for (const target of lineTargets) {
5986
+ if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
5987
+ continue;
5988
+ }
5989
+ ctx.globalAlpha = getCanvasTargetFocusOpacity($$, target);
5990
+ ctx.lineWidth = isCanvasTargetFocused($$, target) ? style.shape.lineFocusedWidth : style.shape.lineWidth;
5991
+ ctx.strokeStyle = $$.color(target.id);
5992
+ drawCanvasLine($$, target, lineIndices, painter, true);
5993
+ }
5994
+ ctx.globalAlpha = 1;
5995
+ if (config.point_show && !((_c = $$.isPointFocusOnly) == null ? void 0 : _c.call($$))) {
5996
+ const cy = (_d = $$.updateCircleY) == null ? void 0 : _d.call($$, true);
5997
+ const cx = (_e = $$.subxx) == null ? void 0 : _e.bind($$);
5998
+ if (cx && cy) {
5999
+ for (const target of targets) {
6000
+ if (!isCanvasScatterType($$, target) && !isCanvasBubbleType($$, target)) {
6001
+ continue;
6002
+ }
6003
+ const color = $$.color(target.id);
6004
+ const pointFill = style.shape.pointFillColor || color;
6005
+ const pointStroke = style.shape.pointStrokeColor || color;
6006
+ const pointLineWidth = pointStroke ? (_f = style.shape.pointLineWidth) != null ? _f : 1 : 0;
6007
+ const pointStyle = pointStroke && pointLineWidth > 0 ? {
6008
+ fill: pointFill,
6009
+ stroke: pointStroke,
6010
+ lineWidth: pointLineWidth
6011
+ } : { fill: pointFill };
6012
+ ctx.globalAlpha = getPointOpacity($$, target) * getCanvasTargetFocusOpacity($$, target);
6013
+ target.values.forEach((d, i) => {
6014
+ if (!hasCanvasDrawableValue($$, d)) {
6015
+ return;
6016
+ }
6017
+ const x = config.axis_rotated ? cy(d, i) : cx(d);
6018
+ const y = config.axis_rotated ? cx(d) : cy(d, i);
6019
+ const r = Math.min(getTargetPointRadius($$, target, d), 3);
6020
+ if (isFiniteCanvasCoordinate(x, y)) {
6021
+ drawPointPattern(
6022
+ painter,
6023
+ "circle",
6024
+ x,
6025
+ y,
6026
+ r,
6027
+ pointStyle
6028
+ );
6029
+ }
6030
+ });
6031
+ }
6032
+ ctx.globalAlpha = 1;
6033
+ }
6034
+ }
6035
+ });
5748
6036
  });
6037
+ this.drawSubchartBrush($$);
5749
6038
  });
5750
- this.drawSubchartBrush($$);
5751
6039
  });
5752
6040
  }
5753
6041
  /**
@@ -5759,7 +6047,7 @@ class CanvasRenderer {
5759
6047
  var _a, _b;
5760
6048
  const { config, scale, state } = $$;
5761
6049
  const domain = state.domain;
5762
- if (!config.subchart_show || !(domain == null ? void 0 : domain.length) || !scale.subX) {
6050
+ if (!config.subchart_show || config.subchart_brush_enabled === false || !(domain == null ? void 0 : domain.length) || !scale.subX) {
5763
6051
  return;
5764
6052
  }
5765
6053
  const { margin2, width2, height2 } = state;
@@ -6220,7 +6508,7 @@ class CanvasRenderer {
6220
6508
  const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : /* @__PURE__ */ new Set();
6221
6509
  painter.withTranslation(margin.left, margin.top, () => {
6222
6510
  selectedData.forEach((d) => {
6223
- var _a2, _b2, _c, _d, _e, _f;
6511
+ var _a2, _b2, _c, _d, _e, _f, _g;
6224
6512
  const color = $$.color(d.id);
6225
6513
  if (isBar(d) && barPoints) {
6226
6514
  const geometry = getCanvasBarGeometry($$, barPoints, d, d.index);
@@ -6264,11 +6552,13 @@ class CanvasRenderer {
6264
6552
  lineWidth: style.selectedPoint.lineWidth,
6265
6553
  stroke: style.selectedPoint.stroke || color
6266
6554
  });
6267
- drawPointPattern(painter, pointType, x, y, r, {
6268
- fill: style.shape.pointFillColor || color,
6269
- stroke: style.shape.pointStrokeColor || color,
6270
- lineWidth: (_f = style.shape.pointLineWidth) != null ? _f : 1
6271
- });
6555
+ if (!((_f = $$.isPointFocusOnly) == null ? void 0 : _f.call($$))) {
6556
+ drawPointPattern(painter, pointType, x, y, r, {
6557
+ fill: style.shape.pointFillColor || color,
6558
+ stroke: style.shape.pointStrokeColor || color,
6559
+ lineWidth: (_g = style.shape.pointLineWidth) != null ? _g : 1
6560
+ });
6561
+ }
6272
6562
  }
6273
6563
  });
6274
6564
  ctx.globalAlpha = 1;
@@ -6512,6 +6802,37 @@ class CanvasRenderer {
6512
6802
  }
6513
6803
  });
6514
6804
  }
6805
+ /**
6806
+ * Draw synchronized focus grid on the canvas subchart.
6807
+ * @param {object} $$ ChartInternal instance
6808
+ * @param {Array} selectedData Focused data rows
6809
+ * @private
6810
+ */
6811
+ drawSubchartFocus($$, selectedData) {
6812
+ const { config, scale, state } = $$;
6813
+ const focus = selectedData == null ? void 0 : selectedData.find(
6814
+ (d) => d && hasCanvasDrawableValue($$, d)
6815
+ );
6816
+ if (!focus || !config.subchart_show || config.subchart_grid_focus_continuous || config.subchart_brush_enabled !== false || config.grid_focus_show === false || config.subchart_grid_focus === false || !config.tooltip_show || config.axis_tooltip || !scale.subX || state.width2 <= 0 || state.height2 <= 0) {
6817
+ return;
6818
+ }
6819
+ const { margin2, width2, height2 } = state;
6820
+ const pos = scale.subX(focus.x);
6821
+ if (!Number.isFinite(pos)) {
6822
+ return;
6823
+ }
6824
+ const { painter, theme: { style } } = this;
6825
+ const lineWidth = style.axis.lineWidth;
6826
+ const x = painter.crisp(margin2.left + pos, lineWidth);
6827
+ const y = painter.crisp(margin2.top + pos, lineWidth);
6828
+ painter.strokePath(() => {
6829
+ config.axis_rotated ? painter.traceLine(margin2.left, y, margin2.left + width2, y) : painter.traceLine(x, margin2.top, x, margin2.top + height2);
6830
+ }, {
6831
+ lineDash: style.focusGrid.dashArray,
6832
+ lineWidth: style.focusGrid.lineWidth,
6833
+ stroke: style.focusGrid.lineColor
6834
+ });
6835
+ }
6515
6836
  /**
6516
6837
  * Draw focus grid and focused points on canvas.
6517
6838
  * @param {object} $$ ChartInternal instance
@@ -6528,6 +6849,7 @@ class CanvasRenderer {
6528
6849
  const focus = selectedData.find(
6529
6850
  (d) => d && hasCanvasDrawableValue($$, d)
6530
6851
  );
6852
+ $$.config.subchart_grid_focus !== false && !isContinuousGridFocusEnabled($$) && this.drawSubchartFocus($$, selectedData);
6531
6853
  painter.withTranslation(margin.left, margin.top, () => {
6532
6854
  if ($$.config.tooltip_show && $$.config.grid_focus_show !== false && !$$.config.axis_tooltip && focus) {
6533
6855
  const { x, y } = getRenderDataPoint($$, focus);
@@ -6538,6 +6860,9 @@ class CanvasRenderer {
6538
6860
  const crispEdgeX = (value) => painter.crisp(margin.left + value, axisLineWidth) - margin.left;
6539
6861
  const crispEdgeY = (value) => painter.crisp(margin.top + value, axisLineWidth) - margin.top;
6540
6862
  const isEdge = $$.config.grid_focus_edge && !$$.config.tooltip_grouped;
6863
+ const continuousFocus = isContinuousGridFocusEnabled($$);
6864
+ const focusEndX = continuousFocus ? $$.state.margin2.left - margin.left + $$.state.width2 : $$.state.width;
6865
+ const focusEndY = continuousFocus ? $$.state.margin2.top - margin.top + $$.state.height2 : $$.state.height;
6541
6866
  if (hasIndexCoordinate) {
6542
6867
  painter.strokePath(() => {
6543
6868
  var _a, _b;
@@ -6545,7 +6870,7 @@ class CanvasRenderer {
6545
6870
  painter.traceLine(
6546
6871
  crispEdgeX(0),
6547
6872
  y,
6548
- isEdge && hasValueCoordinate ? x : crispEdgeX($$.state.width),
6873
+ isEdge && hasValueCoordinate ? x : crispEdgeX(focusEndX),
6549
6874
  y
6550
6875
  );
6551
6876
  if (hasValueCoordinate && $$.config.grid_focus_y && !$$.config.tooltip_grouped) {
@@ -6562,7 +6887,7 @@ class CanvasRenderer {
6562
6887
  x,
6563
6888
  isEdge && hasValueCoordinate ? y : crispEdgeY(0),
6564
6889
  x,
6565
- crispEdgeY($$.state.height)
6890
+ crispEdgeY(focusEndY)
6566
6891
  );
6567
6892
  if (hasValueCoordinate && $$.config.grid_focus_y && !$$.config.tooltip_grouped) {
6568
6893
  const isY2 = ((_b = $$.axis) == null ? void 0 : _b.getId(focus.id)) === "y2";
@@ -6760,6 +7085,77 @@ function normalizeThemeSelectors(selector) {
6760
7085
  (value) => value.trim().replace(/\s*>\s*/g, " ").replace(/\s+/g, " ").replace(/^(?:svg)?\.bb\s+/, "").replace(/(^|\s)(?:g|path|rect|line|text|circle)\./g, "$1.")
6761
7086
  ).filter(Boolean);
6762
7087
  }
7088
+ function getDefinedKeys(values) {
7089
+ return Object.keys(values).filter((key) => values[key] !== void 0);
7090
+ }
7091
+ function assignDefined(target, source, skip) {
7092
+ getDefinedKeys(source).forEach((key) => {
7093
+ if (!(skip == null ? void 0 : skip.has(key))) {
7094
+ target[key] = source[key];
7095
+ }
7096
+ });
7097
+ return target;
7098
+ }
7099
+ function isSimpleGridLineSelector(selector) {
7100
+ const tokens = selector.split(" ");
7101
+ return tokens.every(
7102
+ (token, index) => token === "line" || token === "text" ? index === tokens.length - 1 : /^(\.[A-Za-z_-][\w-]*)+$/.test(token)
7103
+ );
7104
+ }
7105
+ function getGridLineSelectorTarget(selector) {
7106
+ const tokens = selector.split(" ");
7107
+ const target = tokens[tokens.length - 1];
7108
+ return target === "line" || target === "text" ? target : null;
7109
+ }
7110
+ function getClassNames(className) {
7111
+ return (className || "").split(/\s+/).filter(Boolean);
7112
+ }
7113
+ function getGridLineSelectorStyle(style, target) {
7114
+ const values = target === "text" ? {
7115
+ labelColor: readColorValue(style, "fill"),
7116
+ labelFont: readFontValue(style)
7117
+ } : {
7118
+ lineColor: readColorValue(style, "stroke"),
7119
+ lineWidth: readNumberValue(style, "stroke-width"),
7120
+ dashArray: readDashArrayValue(style)
7121
+ };
7122
+ return assignDefined({}, values);
7123
+ }
7124
+ function getGridLineSelectorOverrides(selectors) {
7125
+ const overrides = [];
7126
+ Object.keys(selectors != null ? selectors : {}).forEach((selector) => {
7127
+ normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
7128
+ const target = getGridLineSelectorTarget(normalizedSelector) || "line";
7129
+ const style = getGridLineSelectorStyle(selectors[selector], target);
7130
+ if (isSimpleGridLineSelector(normalizedSelector) && getDefinedKeys(style).length) {
7131
+ overrides.push({ selector: normalizedSelector, target, style });
7132
+ }
7133
+ });
7134
+ });
7135
+ return overrides;
7136
+ }
7137
+ function matchesGridLineSelector(selector, axis, className, target) {
7138
+ if (!isSimpleGridLineSelector(selector)) {
7139
+ return false;
7140
+ }
7141
+ const selectorTarget = getGridLineSelectorTarget(selector);
7142
+ if (selectorTarget && selectorTarget !== target) {
7143
+ return false;
7144
+ } else if (!selectorTarget && target === "text") {
7145
+ return false;
7146
+ }
7147
+ const customClasses = getClassNames(className);
7148
+ const axisLineClass = `bb-${axis}grid-line`;
7149
+ const availableClasses = /* @__PURE__ */ new Set([
7150
+ "bb-grid",
7151
+ "bb-grid-lines",
7152
+ `bb-${axis}grid-lines`,
7153
+ axisLineClass,
7154
+ ...customClasses
7155
+ ]);
7156
+ const selectorClasses = (selector.match(/\.[A-Za-z_-][\w-]*/g) || []).map((match) => match.slice(1));
7157
+ return !!selectorClasses.length && selectorClasses.every((cls) => availableClasses.has(cls)) && (selectorClasses.includes(axisLineClass) || customClasses.some((cls) => selectorClasses.includes(cls)));
7158
+ }
6763
7159
  function applySelectorStyle(target, selector, style) {
6764
7160
  switch (selector) {
6765
7161
  case ".bb-axis path.domain":
@@ -7036,6 +7432,8 @@ class CanvasTheme {
7036
7432
  CanvasTheme_publicField(this, "style");
7037
7433
  CanvasTheme_publicField(this, "cacheContainer", null);
7038
7434
  CanvasTheme_publicField(this, "cacheKey", null);
7435
+ CanvasTheme_publicField(this, "gridLineSelectorOverrides", []);
7436
+ CanvasTheme_publicField(this, "directGridOverrideKeys", /* @__PURE__ */ new Set());
7039
7437
  }
7040
7438
  /**
7041
7439
  * Read theme values from temporary SVG probes.
@@ -7044,8 +7442,12 @@ class CanvasTheme {
7044
7442
  * @private
7045
7443
  */
7046
7444
  load(container, userOverride) {
7047
- var _a, _b, _c, _d;
7445
+ var _a, _b, _c, _d, _e;
7048
7446
  const svg = browser_doc.createElementNS(SVG_NS, "svg");
7447
+ this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride == null ? void 0 : userOverride.selectors);
7448
+ this.directGridOverrideKeys = new Set(
7449
+ Object.keys((_a = userOverride == null ? void 0 : userOverride.grid) != null ? _a : {})
7450
+ );
7049
7451
  svg.setAttribute("class", "bb");
7050
7452
  svg.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
7051
7453
  container.appendChild(svg);
@@ -7210,7 +7612,7 @@ class CanvasTheme {
7210
7612
  subchartBrushSelection.fill,
7211
7613
  toColor(subchartBrushExtent.fill, zoomBrushFill)
7212
7614
  );
7213
- const subchartBrushOpacity = (_d = (_c = (_b = (_a = toOptionalNumber(subchartBrushSelection["fill-opacity"], 1)) != null ? _a : toOptionalNumber(subchartBrushSelection.opacity, 1)) != null ? _b : toOptionalNumber(subchartBrushExtent["fill-opacity"], 1)) != null ? _c : toOptionalNumber(subchartBrushExtent.opacity, 1)) != null ? _d : zoomBrushOpacity;
7615
+ const subchartBrushOpacity = (_e = (_d = (_c = (_b = toOptionalNumber(subchartBrushSelection["fill-opacity"], 1)) != null ? _b : toOptionalNumber(subchartBrushSelection.opacity, 1)) != null ? _c : toOptionalNumber(subchartBrushExtent["fill-opacity"], 1)) != null ? _d : toOptionalNumber(subchartBrushExtent.opacity, 1)) != null ? _e : zoomBrushOpacity;
7214
7616
  const subchartBrushHandleStroke = toColor(subchartBrushHandle.stroke, "transparent");
7215
7617
  const defaultStyle = {
7216
7618
  axis: {
@@ -7436,6 +7838,25 @@ class CanvasTheme {
7436
7838
  }
7437
7839
  this.load(container, userOverride);
7438
7840
  }
7841
+ /**
7842
+ * Resolve selector based style for one configured optional grid line.
7843
+ * @param {string} axis Grid axis
7844
+ * @param {object} line Grid line options
7845
+ * @param {string} line.class Grid line custom class
7846
+ * @param {string} target Draw target
7847
+ * @returns {object|undefined} Grid line style override
7848
+ * @private
7849
+ */
7850
+ getGridLineStyle(axis, line = {}, target = "line") {
7851
+ const style = {};
7852
+ for (const override of this.gridLineSelectorOverrides) {
7853
+ if (!matchesGridLineSelector(override.selector, axis, line.class, target)) {
7854
+ continue;
7855
+ }
7856
+ assignDefined(style, override.style, this.directGridOverrideKeys);
7857
+ }
7858
+ return getDefinedKeys(style).length ? style : void 0;
7859
+ }
7439
7860
  }
7440
7861
 
7441
7862
  ;// ./src/canvas/HitDetector.ts
@@ -7973,6 +8394,7 @@ const $FOCUS = {
7973
8394
  defocused: "bb-defocused",
7974
8395
  legendItemFocused: "bb-legend-item-focused",
7975
8396
  xgridFocus: "bb-xgrid-focus",
8397
+ xgridFocusContinuous: "bb-xgrid-focus-continuous",
7976
8398
  ygridFocus: "bb-ygrid-focus"
7977
8399
  };
7978
8400
  const $GRID = {
@@ -8050,19 +8472,79 @@ const $ZOOM = {
8050
8472
  * - **NOTE:**
8051
8473
  * - Will append &lt;style> to the head tag and will add shpes' CSS rules dynamically.
8052
8474
  * - For now, covers colors related properties (fill, stroke, etc.) only.
8053
- * @property {boolean} [boost.useWorker=false] Use Web Worker as possible for processing.
8475
+ * @property {boolean|string} [boost.useWorker=false] Use Web Worker as possible for processing.
8476
+ * - **Available values:**
8477
+ * - `false`: never offload.
8478
+ * - `true`: always offload when a Worker can be created.
8479
+ * - `"auto"`: offload only when the given data exceeds ~5,000 cells, since smaller
8480
+ * payloads lose more to structured cloning than they gain.
8054
8481
  * - **NOTE:**
8055
8482
  * - For now, only applies for data conversion at the initial time.
8056
- * - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
8483
+ * - As of Web Worker's async nature, handling chart instance synchronously is not recommended.
8484
+ * - When Worker isn't available, fails or times out, data conversion falls back to main thread.
8057
8485
  * - When given data is empty, useWorker will be ignored.
8486
+ * @property {string} [boost.workerUrl=undefined] Use a custom static worker script URL instead of an inline Blob worker.
8487
+ * - **NOTE:**
8488
+ * - **Requires `boost.useWorker` to be enabled** — this option only selects where the
8489
+ * worker source comes from, it does not turn offloading on by itself.
8490
+ * - Useful for strict CSP environments that disallow `blob:` workers. Without it under
8491
+ * such a policy, worker creation throws and each conversion waits out the 5s timeout
8492
+ * before falling back, so the chart still renders but the initial draw is delayed.
8493
+ * - Point it at `dist/billboard.worker.js`, shipped in the package, or any script
8494
+ * implementing the same protocol: receive `{id, op, args}` and post back
8495
+ * `{id, result}` or `{id, error}`. No `eval()` is involved.
8496
+ * - With a bundler, make sure the file is emitted as a **real asset**, not inlined:
8497
+ * it is ~1.5KB, and inlining turns it into a `data:` URI, which a strict CSP
8498
+ * blocks exactly like `blob:`. Copying it into the static/public directory is the
8499
+ * option that works everywhere.
8500
+ * - Any failure (load error, unknown op, timeout, result mismatch) falls back to the main thread.
8058
8501
  * @example
8502
+ * // offload data conversion on a Worker, using the inline Blob worker
8059
8503
  * boost: {
8060
8504
  * useCssRule: true,
8061
- * useWorker: false
8505
+ * useWorker: true
8506
+ * }
8507
+ * @example
8508
+ * // offload only past ~5,000 cells
8509
+ * boost: {
8510
+ * useWorker: "auto"
8511
+ * }
8512
+ * @example
8513
+ * // strict CSP: serve the shipped script and point at it.
8514
+ * // 'useWorker' still has to be on - 'workerUrl' alone offloads nothing.
8515
+ * boost: {
8516
+ * useWorker: true,
8517
+ * workerUrl: "$YOUR_PATH/dist/billboard.worker.js"
8062
8518
  * }
8519
+ * @example
8520
+ * // ESM: the file is reachable as a package subpath.
8521
+ * // Vite - '?url' resolves it, but assets under 4KB are inlined as a 'data:' URI,
8522
+ * // which a strict CSP rejects. Opt that one file out of inlining:
8523
+ * //
8524
+ * // // vite.config.js
8525
+ * // export default {
8526
+ * // build: {
8527
+ * // assetsInlineLimit: path => /billboard\.worker\.js$/.test(path) ? false : undefined
8528
+ * // }
8529
+ * // };
8530
+ * import bb, {bar} from "billboard.js";
8531
+ * import workerUrl from "billboard.js/dist/billboard.worker.js?url";
8532
+ *
8533
+ * bb.generate({
8534
+ * boost: {useWorker: true, workerUrl},
8535
+ * data: {columns: [["data1", 30, 200, 100]], type: bar()}
8536
+ * });
8537
+ * @example
8538
+ * // ESM, bundler-agnostic: copy the file into the served static directory
8539
+ * // cp node_modules/billboard.js/dist/billboard.worker.js public/
8540
+ * bb.generate({
8541
+ * boost: {useWorker: true, workerUrl: "/billboard.worker.js"},
8542
+ * data: {columns: [["data1", 30, 200, 100]]}
8543
+ * });
8063
8544
  */
8064
8545
  boost_useCssRule: false,
8065
- boost_useWorker: false
8546
+ boost_useWorker: false,
8547
+ boost_workerUrl: void 0
8066
8548
  });
8067
8549
 
8068
8550
  ;// ./src/config/Options/common/color.ts
@@ -8073,9 +8555,9 @@ const $ZOOM = {
8073
8555
  * @memberof Options
8074
8556
  * @type {object}
8075
8557
  * @property {object} color color object
8076
- * @property {string|object|((this: Chart, d: DataItem) => string)} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
8558
+ * @property {string|object|function(DataItem): string} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
8077
8559
  * @property {Array|null} [color.pattern=[]] Set custom color pattern. Passing `null` will not set a color for these elements, which requires the usage of custom CSS-based theming to work.
8078
- * @property {(this: Chart) => SVGPathElement[]} [color.tiles] if defined, allows use svg's patterns to fill data area. It should return an array of [SVGPatternElement](https://developer.mozilla.org/en-US/docs/Web/API/SVGPatternElement).
8560
+ * @property {function(): Array.<SVGPatternElement>} [color.tiles] if defined, allows use svg's patterns to fill data area. It should return an array of [SVGPatternElement](https://developer.mozilla.org/en-US/docs/Web/API/SVGPatternElement).
8079
8561
  * - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
8080
8562
  * ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
8081
8563
  * - `bb-colorize-pattern-red`
@@ -10138,7 +10620,9 @@ class Element {
10138
10620
  x: null,
10139
10621
  y: null,
10140
10622
  y2: null,
10141
- subX: null
10623
+ subX: null,
10624
+ subY: null,
10625
+ subY2: null
10142
10626
  },
10143
10627
  axisTooltip: {
10144
10628
  x: null,
@@ -10253,6 +10737,7 @@ class State {
10253
10737
  loading: void 0,
10254
10738
  // Zoom/subchart domain (different from current.domain which is for rendering)
10255
10739
  domain: void 0,
10740
+ subchartSourceTypes: void 0,
10256
10741
  current: {
10257
10742
  // current domain value. Assigned when is zoom is called
10258
10743
  domain: void 0,
@@ -10928,28 +11413,148 @@ function generateWait() {
10928
11413
  ;// ./src/module/worker.ts
10929
11414
 
10930
11415
  const cache = {};
11416
+ const disabledKeys = /* @__PURE__ */ new Set();
11417
+ const verifiedOps = /* @__PURE__ */ new Map();
11418
+ const DEFAULT_WORKER_TIMEOUT = 5e3;
11419
+ const VERIFY_SAMPLE_SIZE = 3;
10931
11420
  let messageId = 0;
10932
- function getOrCreateWorkerResources(fn, depsFn) {
10933
- var _a;
10934
- const fnString = fn.toString();
10935
- const depsString = (_a = depsFn == null ? void 0 : depsFn.map(String).join(";")) != null ? _a : "";
10936
- const key = (fnString + depsString).replace(/(function|[\s\W\n])/g, "").substring(0, 30);
11421
+ function getWorkerSrc() {
11422
+ try {
11423
+ return "var bbWorker=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){let t=[];return e.forEach(function(e,n){let r=e[0];e.forEach(function(e,i){if(i>0){if(t[i-1]===void 0&&(t[i-1]={}),e===void 0)throw Error(`Source data is missing a component at (${n}, ${i})!`);t[i-1][r]=e}})}),t}function n(e){let t=e[0],n=[];return e.forEach(function(e,r){if(r>0){let i={};e.forEach(function(e,n){if(e===void 0)throw Error(`Source data is missing a component at (${r}, ${n})!`);i[t[n]]=e}),n.push(i)}}),n}function r(e,r){let i=[],a,o;if(Array.isArray(e)){let t=function(e,t){if(e[t]!==void 0)return e[t];let n=t.replace(/\\[(\\w+)\\]/g,`.$1`).replace(/^\\./,``).split(`.`),r=e;return n.some(function(e){return!(r=r&&typeof r==`object`&&e in r?r[e]:void 0)}),r};a=r.x?r.value.concat(r.x):r.value,i.push(a),e.forEach(function(e){let n=a.map(function(n){let r=t(e,n);return r===void 0&&(r=null),r});i.push(n)}),o=n(i)}else Object.keys(e).forEach(function(t){let n=[].concat(e[t]);n.unshift?.(t),i.push(n)}),o=t(i);return o}let i={columns:t,json:r,rows:n},a=self;function o({data:e}){let{args:t,id:n,op:r}=e;try{let e=i[r];if(!e)throw Error(`Unknown worker op: ${r}`);a.postMessage({id:n,result:e(...t)})}catch(e){a.postMessage({id:n,error:e&&(e.message||e.name)||String(e)})}}return typeof window>`u`&&(a.onmessage=o),e.handleMessage=o,e.ops=i,e})({});";
11424
+ } catch (e) {
11425
+ return "";
11426
+ }
11427
+ }
11428
+ function getWorkerAPI() {
11429
+ const { Blob, Worker, URL } = win;
11430
+ return Worker && Blob && (URL == null ? void 0 : URL.createObjectURL) && (URL == null ? void 0 : URL.revokeObjectURL) ? { Blob, Worker, URL } : null;
11431
+ }
11432
+ function getWorkerConstructor() {
11433
+ return win.Worker || null;
11434
+ }
11435
+ function normalizeWorkerOptions(options) {
11436
+ var _a, _b;
11437
+ return typeof options === "number" ? { timeout: options, workerUrl: "" } : {
11438
+ timeout: (_a = options == null ? void 0 : options.timeout) != null ? _a : DEFAULT_WORKER_TIMEOUT,
11439
+ workerUrl: (_b = options == null ? void 0 : options.workerUrl) != null ? _b : ""
11440
+ };
11441
+ }
11442
+ function releaseWorker(key, disable = false) {
11443
+ var _a, _b;
11444
+ const cached = cache[key];
11445
+ if (disable) {
11446
+ disabledKeys.add(key);
11447
+ }
11448
+ if (cached) {
11449
+ (_a = cached.worker) == null ? void 0 : _a.terminate();
11450
+ cached.revoke && ((_b = getWorkerAPI()) == null ? void 0 : _b.URL.revokeObjectURL(cached.src));
11451
+ delete cache[key];
11452
+ }
11453
+ for (const verified of verifiedOps.keys()) {
11454
+ if (verified.startsWith(`${key}:`)) {
11455
+ verifiedOps.delete(verified);
11456
+ }
11457
+ }
11458
+ }
11459
+ function isSameResult(actual, expected) {
11460
+ if (actual === expected) {
11461
+ return true;
11462
+ }
11463
+ try {
11464
+ return JSON.stringify(actual) === JSON.stringify(expected);
11465
+ } catch (e) {
11466
+ return true;
11467
+ }
11468
+ }
11469
+ function getVerifySample(args) {
11470
+ const [data, ...rest] = args;
11471
+ if (!Array.isArray(data)) {
11472
+ return args;
11473
+ }
11474
+ return [
11475
+ data.slice(0, VERIFY_SAMPLE_SIZE).map(
11476
+ (entry) => (
11477
+ // +1: a column/row entry leads with its name, which the values follow
11478
+ Array.isArray(entry) ? entry.slice(0, VERIFY_SAMPLE_SIZE + 1) : entry
11479
+ )
11480
+ ),
11481
+ ...rest
11482
+ ];
11483
+ }
11484
+ function request(worker, op, args, timeout) {
11485
+ const id = ++messageId;
11486
+ let settled = false;
11487
+ let cleanup;
11488
+ const promise = new Promise((resolve, reject) => {
11489
+ const settle = (fn, value) => {
11490
+ if (!settled) {
11491
+ settled = true;
11492
+ cleanup();
11493
+ fn(value);
11494
+ }
11495
+ };
11496
+ const handler = function(e) {
11497
+ var _a;
11498
+ if (((_a = e.data) == null ? void 0 : _a.id) === id) {
11499
+ e.data.error ? settle(reject, new Error(e.data.error)) : settle(resolve, e.data.result);
11500
+ }
11501
+ };
11502
+ const errorHandler = function() {
11503
+ settle(reject, new Error("worker error"));
11504
+ };
11505
+ const timer = setTimeout(() => settle(reject, new Error("worker timeout")), timeout);
11506
+ cleanup = () => {
11507
+ clearTimeout(timer);
11508
+ worker.removeEventListener("message", handler);
11509
+ worker.removeEventListener("error", errorHandler);
11510
+ };
11511
+ worker.addEventListener("message", handler);
11512
+ worker.addEventListener("error", errorHandler);
11513
+ });
11514
+ try {
11515
+ worker.postMessage({ args, id, op });
11516
+ } catch (error) {
11517
+ settled = true;
11518
+ cleanup();
11519
+ throw error;
11520
+ }
11521
+ return promise;
11522
+ }
11523
+ function startVerify(worker, verifyKey, op, fn, args, timeout) {
11524
+ const sample = getVerifySample(args);
11525
+ const check = request(worker, op, sample, timeout).then((result) => isSameResult(result, fn(...sample)), () => false).then((matched) => {
11526
+ matched ? verifiedOps.set(verifyKey, true) : verifiedOps.delete(verifyKey);
11527
+ return matched;
11528
+ });
11529
+ verifiedOps.set(verifyKey, check);
11530
+ return check;
11531
+ }
11532
+ function getOrCreateWorkerResources(op, workerUrl = "") {
11533
+ const hasWorker = !!getWorkerConstructor();
11534
+ const api = workerUrl ? null : getWorkerAPI();
11535
+ const src = workerUrl ? "" : getWorkerSrc();
11536
+ const key = workerUrl || "blob";
11537
+ if (!hasWorker || !workerUrl && (!api || !src) || disabledKeys.has(key)) {
11538
+ return null;
11539
+ }
10937
11540
  if (!(key in cache)) {
10938
11541
  try {
10939
- const blob = new win.Blob([
10940
- `${depsString}
10941
-
10942
- self.onmessage=function({data}) {
10943
- const result = (${fnString}).apply(null, data.args);
10944
- self.postMessage({id: data.id, result});
10945
- };`
10946
- ], {
10947
- type: "text/javascript"
10948
- });
10949
- cache[key] = {
10950
- src: win.URL.createObjectURL(blob),
10951
- worker: null
10952
- };
11542
+ if (workerUrl) {
11543
+ cache[key] = {
11544
+ revoke: false,
11545
+ src: workerUrl,
11546
+ worker: null
11547
+ };
11548
+ } else if (api) {
11549
+ const blob = new api.Blob([src], {
11550
+ type: "text/javascript"
11551
+ });
11552
+ cache[key] = {
11553
+ revoke: true,
11554
+ src: api.URL.createObjectURL(blob),
11555
+ worker: null
11556
+ };
11557
+ }
10953
11558
  } catch (e) {
10954
11559
  return null;
10955
11560
  }
@@ -10958,59 +11563,71 @@ function getOrCreateWorkerResources(fn, depsFn) {
10958
11563
  }
10959
11564
  function getWorker(key, src) {
10960
11565
  const cached = cache[key];
10961
- if (!cached) {
11566
+ const Worker = getWorkerConstructor();
11567
+ if (!cached || !Worker || disabledKeys.has(key)) {
10962
11568
  return null;
10963
11569
  }
10964
11570
  if (!cached.worker) {
10965
11571
  try {
10966
- cached.worker = new win.Worker(src);
11572
+ cached.worker = new Worker(src);
10967
11573
  } catch (e) {
11574
+ releaseWorker(key, true);
10968
11575
  return null;
10969
11576
  }
10970
- if (cached.worker) {
10971
- cached.worker.onerror = function(e) {
10972
- console.error ? console.error(e) : console.log(e);
10973
- };
10974
- }
10975
11577
  }
10976
11578
  return cached.worker;
10977
11579
  }
10978
- function runWorker(useWorker = true, fn, callback, depsFn) {
10979
- let runFn = function(...args) {
11580
+ function runWorker(useWorker = true, op, fn, callback, options) {
11581
+ const { timeout, workerUrl } = normalizeWorkerOptions(options);
11582
+ const runSync = function(...args) {
10980
11583
  const res = fn(...args);
10981
11584
  callback(res);
10982
11585
  };
10983
- if (win.Worker && useWorker) {
10984
- const workerResources = getOrCreateWorkerResources(fn, depsFn);
10985
- const worker = workerResources && getWorker(workerResources.key, workerResources.src);
10986
- if (worker) {
11586
+ let runFn = runSync;
11587
+ if (useWorker) {
11588
+ const workerResources = getOrCreateWorkerResources(op, workerUrl);
11589
+ const worker = workerResources ? getWorker(workerResources.key, workerResources.src) : null;
11590
+ if (worker && workerResources) {
11591
+ const { key } = workerResources;
10987
11592
  runFn = function(...args) {
10988
- const id = ++messageId;
10989
- const handler = function(e) {
10990
- var _a;
10991
- if (((_a = e.data) == null ? void 0 : _a.id) === id) {
10992
- worker.removeEventListener("message", handler);
10993
- callback(e.data.result);
10994
- }
11593
+ var _a;
11594
+ const fallback = () => {
11595
+ releaseWorker(key, true);
11596
+ runFn = runSync;
11597
+ runSync(...args);
10995
11598
  };
10996
- worker.addEventListener("message", handler);
10997
- worker.postMessage({ id, args });
11599
+ try {
11600
+ const verifyKey = `${key}:${op}`;
11601
+ const verified = (_a = verifiedOps.get(verifyKey)) != null ? _a : startVerify(worker, verifyKey, op, fn, args, timeout);
11602
+ request(worker, op, args, timeout).then((result) => {
11603
+ if (verified === true) {
11604
+ callback(result);
11605
+ } else {
11606
+ verified.then((matched) => matched ? callback(result) : fallback());
11607
+ }
11608
+ }, fallback);
11609
+ } catch (e) {
11610
+ fallback();
11611
+ }
10998
11612
  };
10999
11613
  }
11000
11614
  }
11001
11615
  return runFn;
11002
11616
  }
11003
11617
  function cleanupWorkers() {
11618
+ const api = getWorkerAPI();
11004
11619
  for (const key in cache) {
11005
11620
  const cached = cache[key];
11006
11621
  if (cached.worker) {
11007
11622
  cached.worker.terminate();
11008
11623
  }
11009
11624
  if (cached.src) {
11010
- win.URL.revokeObjectURL(cached.src);
11625
+ cached.revoke && (api == null ? void 0 : api.URL.revokeObjectURL(cached.src));
11011
11626
  }
11012
11627
  delete cache[key];
11013
11628
  }
11629
+ disabledKeys.clear();
11630
+ verifiedOps.clear();
11014
11631
  }
11015
11632
 
11016
11633
  ;// ./src/module/dsv.ts
@@ -11249,6 +11866,19 @@ function convert_helper_tsv(tsv2) {
11249
11866
 
11250
11867
 
11251
11868
 
11869
+ const WORKER_CELL_THRESHOLD = 5e3;
11870
+ function _getCellCount(data) {
11871
+ var _a, _b;
11872
+ const first = data[0];
11873
+ if (isArray(first)) {
11874
+ let count = 0;
11875
+ for (let i = 0, len = data.length; i < len; i++) {
11876
+ count += (_b = (_a = data[i]) == null ? void 0 : _a.length) != null ? _b : 0;
11877
+ }
11878
+ return count;
11879
+ }
11880
+ return data.length * Object.keys(first != null ? first : {}).length;
11881
+ }
11252
11882
  function _getDataKeyForJson(keysParam, config) {
11253
11883
  const keys = keysParam || (config == null ? void 0 : config.data_keys);
11254
11884
  if (keys == null ? void 0 : keys.x) {
@@ -11294,7 +11924,15 @@ function _setXS(ids, data, params) {
11294
11924
  */
11295
11925
  convertData(args, callback) {
11296
11926
  const { config } = this;
11297
- const useWorker = (d) => (d == null ? void 0 : d.length) && !isEmpty(d[0]) ? config.boost_useWorker : false;
11927
+ const useWorker = (d) => {
11928
+ if (!(d == null ? void 0 : d.length) || isEmpty(d[0])) {
11929
+ return false;
11930
+ }
11931
+ return config.boost_useWorker === "auto" ? _getCellCount(d) >= WORKER_CELL_THRESHOLD : !!config.boost_useWorker;
11932
+ };
11933
+ const workerOptions = config.boost_workerUrl ? {
11934
+ workerUrl: config.boost_workerUrl
11935
+ } : void 0;
11298
11936
  let data = args;
11299
11937
  if (args.bindto) {
11300
11938
  data = {};
@@ -11314,14 +11952,16 @@ function _setXS(ids, data, params) {
11314
11952
  callback
11315
11953
  );
11316
11954
  } else if (data.json) {
11317
- runWorker(useWorker(data.json), json, callback, [columns, rows])(
11955
+ runWorker(useWorker(data.json), "json", json, callback, workerOptions)(
11318
11956
  data.json,
11319
11957
  _getDataKeyForJson(data.keys, config)
11320
11958
  );
11321
11959
  } else if (data.rows) {
11322
- runWorker(useWorker(data.rows), rows, callback)(data.rows);
11960
+ runWorker(useWorker(data.rows), "rows", rows, callback, workerOptions)(data.rows);
11323
11961
  } else if (data.columns) {
11324
- runWorker(useWorker(data.columns), columns, callback)(data.columns);
11962
+ runWorker(useWorker(data.columns), "columns", columns, callback, workerOptions)(
11963
+ data.columns
11964
+ );
11325
11965
  } else if (args.bindto) {
11326
11966
  throw Error("url or json or rows or columns is required.");
11327
11967
  }
@@ -11438,10 +12078,14 @@ function _setXS(ids, data, params) {
11438
12078
 
11439
12079
 
11440
12080
 
12081
+
11441
12082
  const rangedDataKeyIndex = {
11442
12083
  areaRange: { high: 0, mid: 1, low: 2 },
11443
12084
  candlestick: { open: 0, high: 1, low: 2, close: 3, volume: 4 }
11444
12085
  };
12086
+ function normalizeTargetIds(targetIds) {
12087
+ return isArray(targetIds) ? targetIds : [targetIds];
12088
+ }
11445
12089
  /* harmony default export */ var data_data = ({
11446
12090
  isX(key) {
11447
12091
  const $$ = this;
@@ -11878,8 +12522,7 @@ const rangedDataKeyIndex = {
11878
12522
  */
11879
12523
  addTargetIds(type, targetIds) {
11880
12524
  const { state } = this;
11881
- const ids = isArray(targetIds) ? targetIds : [targetIds];
11882
- ids.forEach((v) => state[type].add(v));
12525
+ normalizeTargetIds(targetIds).forEach((v) => state[type].add(v));
11883
12526
  },
11884
12527
  /**
11885
12528
  * Remove from the state target Ids
@@ -11889,8 +12532,7 @@ const rangedDataKeyIndex = {
11889
12532
  */
11890
12533
  removeTargetIds(type, targetIds) {
11891
12534
  const { state } = this;
11892
- const ids = isArray(targetIds) ? targetIds : [targetIds];
11893
- ids.forEach((v) => state[type].delete(v));
12535
+ normalizeTargetIds(targetIds).forEach((v) => state[type].delete(v));
11894
12536
  },
11895
12537
  addHiddenTargetIds(targetIds) {
11896
12538
  this.addTargetIds("hiddenTargetIds", targetIds);
@@ -12289,7 +12931,9 @@ const rangedDataKeyIndex = {
12289
12931
  const yIndex = +!isRotated;
12290
12932
  const y = $$.circleY(data, data.index);
12291
12933
  const x = (scale.zoom || scale.x)(data.x);
12292
- return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
12934
+ const dx = x - pos[xIndex];
12935
+ const dy = y - pos[yIndex];
12936
+ return Math.sqrt(dx * dx + dy * dy);
12293
12937
  },
12294
12938
  /**
12295
12939
  * Convert data for step type
@@ -12485,9 +13129,10 @@ const rangedDataKeyIndex = {
12485
13129
  * @private
12486
13130
  */
12487
13131
  isBarRangeType(d) {
13132
+ var _a;
12488
13133
  const $$ = this;
12489
13134
  const { value } = d;
12490
- return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(isNumber);
13135
+ return $$.isBarType(d) && !((_a = $$.isSubchartSourceTypeOf) == null ? void 0 : _a.call($$, d, TYPE.CANDLESTICK)) && isArray(value) && value.length >= 2 && value.every(isNumber);
12491
13136
  },
12492
13137
  /**
12493
13138
  * Get data object by id
@@ -13012,7 +13657,6 @@ const RE_SELECTOR_SUFFIX = /[\x00-\x20\x7F-\xA0\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`
13012
13657
 
13013
13658
 
13014
13659
 
13015
-
13016
13660
  const _colorizePattern = (pattern, color, id) => {
13017
13661
  const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(true));
13018
13662
  node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
@@ -13054,7 +13698,7 @@ const schemeCategory10 = [
13054
13698
  const { $el, config } = $$;
13055
13699
  const ids = [];
13056
13700
  const hasGradient = config.area_linearGradient || config.bar_linearGradient || config.point_radialGradient;
13057
- let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(_getColorFromCss($el.chart) || schemeCategory10).range();
13701
+ let pattern = notEmpty(config.color_pattern) ? config.color_pattern : [..._getColorFromCss($el.chart) || schemeCategory10];
13058
13702
  const originalColorPattern = pattern;
13059
13703
  if (isFunction(config.color_tiles)) {
13060
13704
  const tiles = config.color_tiles.bind($$.api)();
@@ -13147,8 +13791,9 @@ const schemeCategory10 = [
13147
13791
  const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${isString(color) ? $$.getTargetSelectorSuffix(color) : ""}`;
13148
13792
  const colorValue = sanitize(v === "" ? color : (color == null ? void 0 : color[v]) || "");
13149
13793
  if (defs.select(`#${id}`).empty()) {
13150
- defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(`<feFlood flood-color="${colorValue}" />
13151
- <feComposite in="SourceGraphic" />`);
13794
+ const filter = defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id);
13795
+ filter.append("feFlood").attr("flood-color", colorValue);
13796
+ filter.append("feComposite").attr("in", "SourceGraphic");
13152
13797
  }
13153
13798
  });
13154
13799
  }
@@ -13266,13 +13911,15 @@ function brushEmpty(ctx) {
13266
13911
 
13267
13912
  function getTargetDomainCacheKey($$, targets) {
13268
13913
  return targets.map((target) => {
13269
- var _a, _b, _c, _d;
13914
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
13270
13915
  const { values } = target;
13271
13916
  const first = values[0];
13272
13917
  const last = values[values.length - 1];
13273
13918
  const firstX = first ? (_b = (_a = $$.getXCacheKey) == null ? void 0 : _a.call($$, first.x)) != null ? _b : first.x : "";
13274
13919
  const lastX = last ? (_d = (_c = $$.getXCacheKey) == null ? void 0 : _c.call($$, last.x)) != null ? _d : last.x : "";
13275
- return `${target.id}:${values.length}:${firstX}:${lastX}`;
13920
+ const targetType = (_f = (_e = $$.getTargetType) == null ? void 0 : _e.call($$, target)) != null ? _f : "";
13921
+ const sourceType = (_i = (_h = (_g = $$.state) == null ? void 0 : _g.subchartSourceTypes) == null ? void 0 : _h[target.id]) != null ? _i : "";
13922
+ return `${target.id}:${targetType}:${sourceType}:${values.length}:${firstX}:${lastX}`;
13276
13923
  }).join("|");
13277
13924
  }
13278
13925
  function canCacheTargetDomain($$, targets) {
@@ -13307,12 +13954,13 @@ function updateMinMaxFromValues(minMax, values) {
13307
13954
  }
13308
13955
  }
13309
13956
  function getTargetValueMinMax($$, targets) {
13310
- var _a, _b;
13957
+ var _a, _b, _c, _d;
13311
13958
  const minMax = { min: void 0, max: void 0 };
13312
13959
  const hasAxis = $$.state.hasAxis;
13313
13960
  for (let i = 0; i < targets.length; i++) {
13314
13961
  const target = targets[i];
13315
13962
  const isCandlestick = (_a = $$.isCandlestickType) == null ? void 0 : _a.call($$, target);
13963
+ const isSubchartCandlestick = !isCandlestick && !!((_b = $$.isSubchartSourceTypeOf) == null ? void 0 : _b.call($$, target, TYPE.CANDLESTICK));
13316
13964
  const { values } = target;
13317
13965
  for (let j = 0; j < values.length; j++) {
13318
13966
  const row = values[j];
@@ -13320,14 +13968,17 @@ function getTargetValueMinMax($$, targets) {
13320
13968
  if (!(isValue(value) || value === null)) {
13321
13969
  continue;
13322
13970
  }
13323
- if (value !== null && isCandlestick) {
13971
+ const subchartCandlestickValue = isSubchartCandlestick ? (_c = $$.getSubchartCandlestickShapeValue) == null ? void 0 : _c.call($$, row, true) : void 0;
13972
+ if (isNumber(subchartCandlestickValue)) {
13973
+ value = subchartCandlestickValue;
13974
+ } else if (value !== null && (isCandlestick || isSubchartCandlestick)) {
13324
13975
  value = Array.isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
13325
13976
  }
13326
13977
  if (Array.isArray(value)) {
13327
13978
  updateMinMaxFromValues(minMax, value);
13328
13979
  } else if (isObject(value) && "high" in value) {
13329
13980
  updateMinMaxFromValues(minMax, Object.values(value));
13330
- } else if ((_b = $$.isBubbleZType) == null ? void 0 : _b.call($$, row)) {
13981
+ } else if ((_d = $$.isBubbleZType) == null ? void 0 : _d.call($$, row)) {
13331
13982
  updateMinMax(minMax, hasAxis && $$.getBubbleZData(value, "y"));
13332
13983
  } else {
13333
13984
  updateMinMax(minMax, value);
@@ -13354,7 +14005,7 @@ function getTargetXMinMax(targets, type) {
13354
14005
  * Get both min and max Y domain values in a single pass.
13355
14006
  * Avoids calling getValuesAsIdKeyed twice.
13356
14007
  * @param {Array} targets Target data
13357
- * @returns {[number|Date|undefined, number|Date|undefined]} [min, max]
14008
+ * @returns {Array.<number|Date|undefined>} [min, max]
13358
14009
  * @private
13359
14010
  */
13360
14011
  getYDomainMinMaxBoth(targets) {
@@ -15799,14 +16450,24 @@ function batchGetBBox(elements) {
15799
16450
  const filteredTextNodes = textNodes.filter((node) => node.data.id !== id);
15800
16451
  const textNode = textNodes.filter((node) => node.data.id === id);
15801
16452
  const translate = getTranslation(textNode.node());
15802
- const calcHypo = (x, y) => Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
15803
- textNode.node() && filteredTextNodes.each(function() {
16453
+ const calcHypo = (x, y) => Math.sqrt(x * x + y * y);
16454
+ if (!textNode.node()) {
16455
+ return;
16456
+ }
16457
+ const fontSize = parseInt(textNode.style("font-size"), 10);
16458
+ const overlapStates = [];
16459
+ filteredTextNodes.each(function() {
15804
16460
  const coordinate = getTranslation(this);
15805
- const filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
15806
- const nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode;
16461
+ const nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
15807
16462
  const overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength());
15808
- const overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
15809
- filteredTextNode.classed($TEXT.TextOverlapping, overlapsX && overlapsY);
16463
+ const overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < fontSize;
16464
+ overlapStates.push({
16465
+ node: this,
16466
+ overlaps: overlapsX && overlapsY
16467
+ });
16468
+ });
16469
+ overlapStates.forEach(({ node, overlaps }) => {
16470
+ (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(node).classed($TEXT.TextOverlapping, overlaps);
15810
16471
  });
15811
16472
  },
15812
16473
  /**
@@ -16490,6 +17151,12 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16490
17151
  } else if (target === "subX") {
16491
17152
  x = 0;
16492
17153
  y = isRotated ? 0 : state.height2;
17154
+ } else if (target === "subY") {
17155
+ x = 0;
17156
+ y = isRotated ? state.height2 : 0;
17157
+ } else if (target === "subY2") {
17158
+ x = isRotated ? 0 : state.width2;
17159
+ y = isRotated ? -1 : 0;
16493
17160
  } else if (target === "arc") {
16494
17161
  x = state.arcWidth / 2;
16495
17162
  y = state.arcHeight / 2;
@@ -16533,6 +17200,23 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16533
17200
  ;// ./src/ChartInternal/internals/type.ts
16534
17201
 
16535
17202
 
17203
+ const INTERPOLATION_TYPES = /* @__PURE__ */ new Set([
17204
+ "basis",
17205
+ "basis-closed",
17206
+ "basis-open",
17207
+ "bundle",
17208
+ "cardinal",
17209
+ "cardinal-closed",
17210
+ "cardinal-open",
17211
+ "catmull-rom",
17212
+ "catmull-rom-closed",
17213
+ "catmull-rom-open",
17214
+ "linear",
17215
+ "linear-closed",
17216
+ "monotone-x",
17217
+ "monotone-y",
17218
+ "natural"
17219
+ ]);
16536
17220
  /* harmony default export */ var type = ({
16537
17221
  /**
16538
17222
  * Check if the given chart type is valid
@@ -16543,6 +17227,96 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16543
17227
  isValidChartType(type) {
16544
17228
  return !!(type && Object.values(TYPE).indexOf(type) > -1);
16545
17229
  },
17230
+ /**
17231
+ * Get the chart type to use for the subchart target.
17232
+ * subchart.types > subchart.type > data.types > data.type > line
17233
+ * @param {object|string} d Target data or id
17234
+ * @returns {string}
17235
+ * @private
17236
+ */
17237
+ getSubchartTargetType(d) {
17238
+ const $$ = this;
17239
+ const { config } = $$;
17240
+ const id = isString(d) ? d : d == null ? void 0 : d.id;
17241
+ const subchartTypes = config.subchart_types || {};
17242
+ const subchartType = config.subchart_type;
17243
+ const dataTypes = config.data_types || {};
17244
+ const targetSubchartType = id && subchartTypes[id];
17245
+ if (targetSubchartType && $$.isValidChartType(targetSubchartType)) {
17246
+ return targetSubchartType;
17247
+ } else if (subchartType && $$.isValidChartType(subchartType)) {
17248
+ return subchartType;
17249
+ }
17250
+ return id && dataTypes[id] || config.data_type || TYPE.LINE;
17251
+ },
17252
+ /**
17253
+ * Get the regular chart type configured for the target.
17254
+ * @param {object|string} d Target data or id
17255
+ * @returns {string}
17256
+ * @private
17257
+ */
17258
+ getTargetType(d) {
17259
+ var _a;
17260
+ const { config } = this;
17261
+ const id = isString(d) ? d : d == null ? void 0 : d.id;
17262
+ return id && ((_a = config.data_types) == null ? void 0 : _a[id]) || config.data_type || TYPE.LINE;
17263
+ },
17264
+ /**
17265
+ * Get the target's original chart type while subchart.type context is active.
17266
+ * @param {object|string} d Target data or id
17267
+ * @returns {string}
17268
+ * @private
17269
+ */
17270
+ getSubchartSourceTargetType(d) {
17271
+ const { state } = this;
17272
+ const id = isString(d) ? d : d == null ? void 0 : d.id;
17273
+ const sourceTypes = state.subchartSourceTypes;
17274
+ return id && (sourceTypes == null ? void 0 : sourceTypes[id]) || this.getTargetType(d);
17275
+ },
17276
+ /**
17277
+ * Check whether a target had the given source type before subchart.type remapping.
17278
+ * @param {object|string} d Target data or id
17279
+ * @param {string|Array} type chart type
17280
+ * @returns {boolean}
17281
+ * @private
17282
+ */
17283
+ isSubchartSourceTypeOf(d, type) {
17284
+ const sourceType = this.getSubchartSourceTargetType(d);
17285
+ return isArray(type) ? type.indexOf(sourceType) >= 0 : sourceType === type;
17286
+ },
17287
+ /**
17288
+ * Run a callback while regular type helpers resolve using subchart.type/types.
17289
+ * @param {function(): unknown} callback Callback to run
17290
+ * @returns {unknown} Callback return value
17291
+ * @private
17292
+ */
17293
+ withSubchartTypeContext(callback) {
17294
+ const $$ = this;
17295
+ const { config, data, state } = $$;
17296
+ const dataType = config.data_type;
17297
+ const dataTypes = config.data_types;
17298
+ const currentTypes = state.current.types;
17299
+ const sourceTypes = state.subchartSourceTypes;
17300
+ const subchartTypes = {};
17301
+ const subchartSourceTypes = {};
17302
+ const subchartType = config.subchart_type;
17303
+ $$.mapToIds(data.targets).forEach((id) => {
17304
+ subchartSourceTypes[id] = $$.getTargetType(id);
17305
+ subchartTypes[id] = $$.getSubchartTargetType(id);
17306
+ });
17307
+ config.data_type = subchartType && $$.isValidChartType(subchartType) ? subchartType : dataType;
17308
+ config.data_types = subchartTypes;
17309
+ state.current.types = [];
17310
+ state.subchartSourceTypes = subchartSourceTypes;
17311
+ try {
17312
+ return callback();
17313
+ } finally {
17314
+ config.data_type = dataType;
17315
+ config.data_types = dataTypes;
17316
+ state.current.types = currentTypes;
17317
+ state.subchartSourceTypes = sourceTypes;
17318
+ }
17319
+ },
16546
17320
  setTargetType(targetIds, type) {
16547
17321
  const $$ = this;
16548
17322
  const { config, state: { withoutFadeIn } } = $$;
@@ -16587,26 +17361,17 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16587
17361
  const { config, state: { current } } = $$;
16588
17362
  const types = config.data_types;
16589
17363
  const targets = targetsValue || $$.data.targets;
16590
- let has = false;
16591
17364
  if (!checkFromData && ((_a = current.types) == null ? void 0 : _a.indexOf(type)) > -1) {
16592
- has = true;
17365
+ return true;
16593
17366
  } else if (targets == null ? void 0 : targets.length) {
16594
- targets.forEach((target) => {
17367
+ return targets.some((target) => {
16595
17368
  const t = types[target.id];
16596
- if (t === type || !t && type === "line") {
16597
- has = true;
16598
- }
17369
+ return t === type || !t && type === "line";
16599
17370
  });
16600
17371
  } else if (Object.keys(types).length) {
16601
- Object.keys(types).forEach((id) => {
16602
- if (types[id] === type) {
16603
- has = true;
16604
- }
16605
- });
16606
- } else {
16607
- has = config.data_type === type;
17372
+ return Object.values(types).some((t) => t === type);
16608
17373
  }
16609
- return has;
17374
+ return config.data_type === type;
16610
17375
  },
16611
17376
  /**
16612
17377
  * Check if contains given chart types
@@ -16630,9 +17395,8 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16630
17395
  * @private
16631
17396
  */
16632
17397
  isTypeOf(d, type) {
16633
- var _a;
16634
17398
  const id = isString(d) ? d : d.id;
16635
- const dataType = this.config && (((_a = this.config.data_types) == null ? void 0 : _a[id]) || this.config.data_type);
17399
+ const dataType = this.config && this.getTargetType(id);
16636
17400
  return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
16637
17401
  },
16638
17402
  hasPointType() {
@@ -16729,25 +17493,8 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16729
17493
  barLineBubbleData(d) {
16730
17494
  return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
16731
17495
  },
16732
- // https://github.com/d3/d3-shape#curves
16733
17496
  isInterpolationType(type) {
16734
- return [
16735
- "basis",
16736
- "basis-closed",
16737
- "basis-open",
16738
- "bundle",
16739
- "cardinal",
16740
- "cardinal-closed",
16741
- "cardinal-open",
16742
- "catmull-rom",
16743
- "catmull-rom-closed",
16744
- "catmull-rom-open",
16745
- "linear",
16746
- "linear-closed",
16747
- "monotone-x",
16748
- "monotone-y",
16749
- "natural"
16750
- ].indexOf(type) >= 0;
17497
+ return INTERPOLATION_TYPES.has(type);
16751
17498
  }
16752
17499
  });
16753
17500
 
@@ -16757,6 +17504,7 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
16757
17504
 
16758
17505
 
16759
17506
 
17507
+
16760
17508
  const CURVE_MAP = {
16761
17509
  basis: external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasis,
16762
17510
  "basis-closed": external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.curveBasisClosed,
@@ -16784,13 +17532,48 @@ function isLinePointGroupType($$, d) {
16784
17532
  function getLinePointGroupTypeFilter($$) {
16785
17533
  return (d) => isLinePointGroupType($$, d);
16786
17534
  }
16787
- function getShapeOffsetValue($$, d) {
17535
+ function getShapeOffsetValue($$, d, isSub) {
16788
17536
  var _a, _b, _c;
17537
+ const subchartCandlestickValue = isSub ? getSubchartCandlestickShapeValue($$, d, isSub) : void 0;
17538
+ if (isNumber(subchartCandlestickValue)) {
17539
+ return subchartCandlestickValue;
17540
+ }
16789
17541
  if ((_a = $$.isCandlestickType) == null ? void 0 : _a.call($$, d)) {
16790
17542
  return (_c = (_b = $$.getCandlestickData) == null ? void 0 : _b.call($$, d)) == null ? void 0 : _c.close;
16791
17543
  }
16792
17544
  return $$.getBaseValue(d);
16793
17545
  }
17546
+ function getSubchartCandlestickShapeValue($$, d, isSub) {
17547
+ var _a, _b, _c;
17548
+ if (!isSub || ((_a = $$.isCandlestickType) == null ? void 0 : _a.call($$, d)) || !((_b = $$.isSubchartSourceTypeOf) == null ? void 0 : _b.call($$, d, TYPE.CANDLESTICK))) {
17549
+ return void 0;
17550
+ }
17551
+ const value = (_c = $$.getCandlestickData) == null ? void 0 : _c.call($$, d);
17552
+ if (!value) {
17553
+ return void 0;
17554
+ }
17555
+ if ($$.isBarType(d)) {
17556
+ return isNumber(value.open) && isNumber(value.close) ? value._isUp ? value.close : value.open : void 0;
17557
+ }
17558
+ return isNumber(value.close) ? value.close : void 0;
17559
+ }
17560
+ function isSubchartCandlestickBarValue($$, d, isSub) {
17561
+ const value = getSubchartCandlestickShapeValue($$, d, isSub);
17562
+ return isNumber(value) && $$.isBarType(d);
17563
+ }
17564
+ function getSubchartCandlestickBarColor($$, d, isSub) {
17565
+ var _a;
17566
+ if (!isSubchartCandlestickBarValue($$, d, isSub)) {
17567
+ return null;
17568
+ }
17569
+ const value = (_a = $$.getCandlestickData) == null ? void 0 : _a.call($$, d);
17570
+ if (value == null ? void 0 : value._isUp) {
17571
+ return $$.color(d);
17572
+ }
17573
+ const downColor = $$.config.candlestick_color_down;
17574
+ const color = downColor && typeof downColor === "object" ? downColor[d.id] : downColor;
17575
+ return color || $$.color(d);
17576
+ }
16794
17577
  function _getGroupedDataPointsFn(d) {
16795
17578
  var _a, _b;
16796
17579
  const $$ = this;
@@ -17019,8 +17802,11 @@ function updateTargetsForShape(targets, config) {
17019
17802
  const isStackNormalized = $$.isStackNormalized();
17020
17803
  return (d) => {
17021
17804
  let { value } = d;
17805
+ const subchartCandlestickValue = isSub ? getSubchartCandlestickShapeValue($$, d, isSub) : void 0;
17022
17806
  if (isNumber(d)) {
17023
17807
  value = d;
17808
+ } else if (isNumber(subchartCandlestickValue)) {
17809
+ value = subchartCandlestickValue;
17024
17810
  } else if ($$.isAreaRangeType(d)) {
17025
17811
  value = $$.getBaseValue(d, "mid");
17026
17812
  } else if (isStackNormalized) {
@@ -17036,13 +17822,14 @@ function updateTargetsForShape(targets, config) {
17036
17822
  /**
17037
17823
  * Get shape based y Axis min value
17038
17824
  * @param {string} id Data id
17825
+ * @param {boolean} isSub Whether to use subchart scale
17039
17826
  * @returns {number}
17040
17827
  * @private
17041
17828
  */
17042
- getShapeYMin(id) {
17829
+ getShapeYMin(id, isSub = false) {
17043
17830
  const $$ = this;
17044
17831
  const axisId = $$.axis.getId(id);
17045
- const scale = $$.scale[axisId];
17832
+ const scale = $$.getYScaleById(id, isSub);
17046
17833
  const [yMin] = scale.domain();
17047
17834
  const inverted = $$.config[`axis_${axisId}_inverted`];
17048
17835
  return !$$.isGrouped(id) && !inverted && yMin > 0 ? yMin : 0;
@@ -17050,17 +17837,18 @@ function updateTargetsForShape(targets, config) {
17050
17837
  /**
17051
17838
  * Get Shape's offset data
17052
17839
  * @param {function} typeFilter Type filter function
17840
+ * @param {boolean} isSub Whether coordinates are for the subchart
17053
17841
  * @returns {object}
17054
17842
  * @private
17055
17843
  */
17056
- getShapeOffsetData(typeFilter) {
17844
+ getShapeOffsetData(typeFilter, isSub) {
17057
17845
  const $$ = this;
17058
17846
  const targets = $$.orderTargets(
17059
17847
  $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
17060
17848
  );
17061
17849
  const dataGeneration = $$.state.dataGeneration;
17062
17850
  const targetIds = targets.map((t) => t.id).join("_");
17063
- const cacheKey = `${KEY.shapeOffset}_${targetIds}`;
17851
+ const cacheKey = `${KEY.shapeOffset}_${isSub ? "sub" : "main"}_${targetIds}`;
17064
17852
  const cachedData = $$.cache.get(cacheKey);
17065
17853
  if ((cachedData == null ? void 0 : cachedData.generation) === dataGeneration) {
17066
17854
  return cachedData;
@@ -17074,7 +17862,7 @@ function updateTargetsForShape(targets, config) {
17074
17862
  }
17075
17863
  const rowValueMapByXValue = rowValues.reduce((out, d) => {
17076
17864
  const key = Number(d.x);
17077
- const value = getShapeOffsetValue($$, d);
17865
+ const value = getShapeOffsetValue($$, d, isSub);
17078
17866
  out[key] = d;
17079
17867
  values[key] = isStackNormalized ? $$.getRatio("index", d, true) : value;
17080
17868
  return out;
@@ -17097,7 +17885,8 @@ function updateTargetsForShape(targets, config) {
17097
17885
  getShapeOffset(typeFilter, indices, isSub) {
17098
17886
  const $$ = this;
17099
17887
  const { shapeOffsetTargets, indexMapByTargetId } = $$.getShapeOffsetData(
17100
- typeFilter
17888
+ typeFilter,
17889
+ isSub
17101
17890
  );
17102
17891
  const groupsZeroAs = $$.config.data_groupsZeroAs;
17103
17892
  let sameGroupByTargetId = null;
@@ -17116,14 +17905,14 @@ function updateTargetsForShape(targets, config) {
17116
17905
  return (d, idx) => {
17117
17906
  var _a;
17118
17907
  const { id, value, x } = d;
17119
- const baseValue = getShapeOffsetValue($$, d);
17908
+ const baseValue = getShapeOffsetValue($$, d, isSub);
17120
17909
  const ind = $$.getIndices(indices, d);
17121
17910
  const scale = $$.getYScaleById(id, isSub);
17122
17911
  if ($$.isBarRangeType(d)) {
17123
17912
  return scale(value[0]);
17124
17913
  }
17125
17914
  const dataXAsNumber = Number(x);
17126
- const y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id));
17915
+ const y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id, isSub));
17127
17916
  let offset = y0;
17128
17917
  const sameGroupTargets = (_a = sameGroupByTargetId == null ? void 0 : sameGroupByTargetId.get(id)) != null ? _a : shapeOffsetTargets.filter((t) => t.id !== id && ind[t.id] === ind[id]);
17129
17918
  for (const t of sameGroupTargets) {
@@ -17139,7 +17928,7 @@ function updateTargetsForShape(targets, config) {
17139
17928
  if (!row || Number(row.x) !== dataXAsNumber) {
17140
17929
  row = rowValueMapByXValue[dataXAsNumber];
17141
17930
  }
17142
- const rowValue = row && getShapeOffsetValue($$, row);
17931
+ const rowValue = row && getShapeOffsetValue($$, row, isSub);
17143
17932
  if (isNumber(rowValue) && isNumber(baseValue) && rowValue * baseValue >= 0 && isNumber(rValue)) {
17144
17933
  const addOffset = baseValue === 0 ? groupsZeroAs === "positive" && rValue > 0 || groupsZeroAs === "negative" && rValue < 0 : true;
17145
17934
  if (addOffset) {
@@ -17166,8 +17955,13 @@ function updateTargetsForShape(targets, config) {
17166
17955
  const y = $$.getShapeY(isSub);
17167
17956
  const lineOffset = $$.getShapeOffset(typeFilter || $$.isLineType, lineIndices, isSub);
17168
17957
  const yScale = $$.getYScaleById.bind($$);
17958
+ const y0Cache = /* @__PURE__ */ new Map();
17169
17959
  return (d, i) => {
17170
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
17960
+ let y0 = y0Cache.get(d.id);
17961
+ if (y0 === void 0) {
17962
+ y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id, isSub));
17963
+ y0Cache.set(d.id, y0);
17964
+ }
17171
17965
  const offset = lineOffset(d, i) || y0;
17172
17966
  const posX = x(d);
17173
17967
  let posY = y(d);
@@ -17197,8 +17991,13 @@ function updateTargetsForShape(targets, config) {
17197
17991
  const y = $$.getShapeY(!!isSub);
17198
17992
  const areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub);
17199
17993
  const yScale = $$.getYScaleById.bind($$);
17994
+ const y0Cache = /* @__PURE__ */ new Map();
17200
17995
  return function(d, i) {
17201
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
17996
+ let y0 = y0Cache.get(d.id);
17997
+ if (y0 === void 0) {
17998
+ y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id, isSub));
17999
+ y0Cache.set(d.id, y0);
18000
+ }
17202
18001
  const offset = areaOffset(d, i) || y0;
17203
18002
  const posX = x(d);
17204
18003
  const value = d.value;
@@ -17231,12 +18030,20 @@ function updateTargetsForShape(targets, config) {
17231
18030
  const barY = $$.getShapeY(!!isSub);
17232
18031
  const barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub);
17233
18032
  const yScale = $$.getYScaleById.bind($$);
18033
+ const idCache = /* @__PURE__ */ new Map();
17234
18034
  return (d, i) => {
17235
18035
  const { id } = d;
17236
- const y0 = yScale.call($$, id, isSub)($$.getShapeYMin(id));
18036
+ let idInfo = idCache.get(id);
18037
+ if (!idInfo) {
18038
+ idInfo = {
18039
+ y0: yScale.call($$, id, isSub)($$.getShapeYMin(id, isSub)),
18040
+ isInverted: config[`axis_${$$.axis.getId(id)}_inverted`]
18041
+ };
18042
+ idCache.set(id, idInfo);
18043
+ }
18044
+ const { y0, isInverted } = idInfo;
17237
18045
  const offset = barOffset(d, i) || y0;
17238
18046
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
17239
- const isInverted = config[`axis_${$$.axis.getId(id)}_inverted`];
17240
18047
  const value = d.value;
17241
18048
  const posX = barX(d);
17242
18049
  let posY = barY(d);
@@ -17294,11 +18101,42 @@ function updateTargetsForShape(targets, config) {
17294
18101
  isSub,
17295
18102
  typeFilter
17296
18103
  );
18104
+ const y = $$.getShapeY(isSub);
17297
18105
  return (d, i) => {
17298
18106
  const id = d.id;
17299
- return $$.isGrouped(id) && isLinePointGroupType($$, d) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
18107
+ return $$.isGrouped(id) && isLinePointGroupType($$, d) ? getPoints(d, i)[0][1] : y(d);
17300
18108
  };
17301
18109
  },
18110
+ /**
18111
+ * Get candlestick data projected for alternate subchart shapes.
18112
+ * @param {object} d Data row
18113
+ * @param {boolean} isSub Whether coordinates are for the subchart
18114
+ * @returns {number|undefined} Projected value
18115
+ * @private
18116
+ */
18117
+ getSubchartCandlestickShapeValue(d, isSub) {
18118
+ return getSubchartCandlestickShapeValue(this, d, isSub);
18119
+ },
18120
+ /**
18121
+ * Check whether the row should be drawn as a candlestick-derived subchart bar.
18122
+ * @param {object} d Data row
18123
+ * @param {boolean} isSub Whether coordinates are for the subchart
18124
+ * @returns {boolean}
18125
+ * @private
18126
+ */
18127
+ isSubchartCandlestickBarValue(d, isSub) {
18128
+ return isSubchartCandlestickBarValue(this, d, isSub);
18129
+ },
18130
+ /**
18131
+ * Get subchart bar color projected from candlestick up/down state.
18132
+ * @param {object} d Data row
18133
+ * @param {boolean} isSub Whether coordinates are for the subchart
18134
+ * @returns {string|null} Bar color
18135
+ * @private
18136
+ */
18137
+ getSubchartCandlestickBarColor(d, isSub) {
18138
+ return getSubchartCandlestickBarColor(this, d, isSub);
18139
+ },
17302
18140
  /**
17303
18141
  * Get point radius.
17304
18142
  * @param {object} d Data row
@@ -17856,7 +18694,7 @@ class ChartInternal {
17856
18694
  if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_b = $$.hasLegendDefsPoint) == null ? void 0 : _b.call($$))) {
17857
18695
  $el.defs = $el.svg.append("defs");
17858
18696
  if (hasAxis) {
17859
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
18697
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
17860
18698
  $$.appendClip($el.defs, state.clip[v]);
17861
18699
  });
17862
18700
  }
@@ -18199,6 +19037,7 @@ extend(ChartInternal.prototype, [
18199
19037
 
18200
19038
 
18201
19039
 
19040
+
18202
19041
  const CANVAS_SELECTABLE_TYPE_FILTERS = [
18203
19042
  isCanvasPointType,
18204
19043
  isCanvasBarType,
@@ -18507,6 +19346,21 @@ function isCanvasSubchartPoint($$, point) {
18507
19346
  const rect = getCanvasSubchartRect($$);
18508
19347
  return !!rect && point[0] >= rect.x && point[0] <= rect.x + rect.w && point[1] >= rect.y && point[1] <= rect.y + rect.h;
18509
19348
  }
19349
+ function getCanvasMainPointFromSubchart($$, point) {
19350
+ const { config, state } = $$;
19351
+ const rect = getCanvasSubchartRect($$);
19352
+ if (config.subchart_brush_enabled !== false || !rect || !isCanvasSubchartPoint($$, point)) {
19353
+ return null;
19354
+ }
19355
+ const mainCoord = getMainCoordFromSubchartCoord(
19356
+ $$,
19357
+ config.axis_rotated ? point[1] - rect.y : point[0] - rect.x
19358
+ );
19359
+ if (mainCoord === null) {
19360
+ return null;
19361
+ }
19362
+ return config.axis_rotated ? [state.margin.left + state.width / 2, state.margin.top + mainCoord] : [state.margin.left + mainCoord, state.margin.top + state.height / 2];
19363
+ }
18510
19364
  function getCanvasSubchartBrushExtent($$) {
18511
19365
  var _a, _b;
18512
19366
  const rect = getCanvasSubchartRect($$);
@@ -18698,15 +19552,17 @@ function getCanvasFlowValueCount($$) {
18698
19552
  return $$.data.targets.reduce((sum, target) => sum + target.values.length, 0);
18699
19553
  }
18700
19554
  function syncCanvasFlowYDomains($$) {
18701
- var _a, _b;
18702
19555
  const { scale } = $$;
18703
19556
  const targetsToShow = $$.filterTargetsToShow($$.data.targets);
18704
19557
  ["y", "y2"].forEach((key) => {
18705
- var _a2;
18706
- (_a2 = scale[key]) == null ? void 0 : _a2.domain($$.getYDomain(targetsToShow, key));
19558
+ var _a;
19559
+ (_a = scale[key]) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, key));
19560
+ });
19561
+ $$.withSubchartTypeContext(() => {
19562
+ var _a, _b;
19563
+ (_a = scale.subY) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, "y"));
19564
+ (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
18707
19565
  });
18708
- (_a = scale.subY) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, "y"));
18709
- (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
18710
19566
  }
18711
19567
  const canvasInternal = {
18712
19568
  /**
@@ -19383,22 +20239,42 @@ const canvasInternal = {
19383
20239
  const { config, state } = $$;
19384
20240
  const selected = state.canvasSelection;
19385
20241
  const selectionGrouped = config.data_selection_grouped;
19386
- const targetIds = getCanvasSelectionIds(ids);
20242
+ let targetIds = getCanvasSelectionIds(ids);
19387
20243
  let changed = false;
20244
+ const singleSelection = isSelection && !config.data_selection_multiple;
20245
+ let resetDone = !singleSelection;
19388
20246
  if (!config.data_selection_enabled) {
19389
20247
  return;
19390
20248
  }
20249
+ if (singleSelection) {
20250
+ indices = (indices == null ? void 0 : indices.length) ? [indices[0]] : [0];
20251
+ if (!selectionGrouped) {
20252
+ if (targetIds) {
20253
+ targetIds = targetIds.slice(0, 1);
20254
+ } else {
20255
+ const [firstTarget] = $$.filterTargetsToShow($$.data.targets);
20256
+ targetIds = firstTarget ? [firstTarget.id] : [];
20257
+ }
20258
+ }
20259
+ }
19391
20260
  eachCanvasSelectableData($$, (d) => {
19392
20261
  const key = getCanvasDataKey(d);
19393
20262
  const isTargetId = selectionGrouped || !targetIds || targetIds.indexOf(d.id) >= 0;
19394
20263
  const isTargetIndex = !indices || indices.indexOf(d.index) >= 0;
19395
20264
  const isSelected = selected.has(key);
19396
20265
  if (isSelection) {
19397
- if (isTargetId && isTargetIndex && !isSelected) {
20266
+ if (isTargetId && isTargetIndex && (!isSelected || singleSelection)) {
20267
+ if (!resetDone) {
20268
+ $$.setCanvasSelection(false);
20269
+ resetDone = true;
20270
+ }
20271
+ if (selected.has(key)) {
20272
+ return;
20273
+ }
19398
20274
  selected.add(key);
19399
20275
  callFn(config.data_onselected, $$.api, d, $$.canvasEngine.canvas);
19400
20276
  changed = true;
19401
- } else if (resetOther && isSelected) {
20277
+ } else if ((!singleSelection || resetDone) && resetOther && isSelected) {
19402
20278
  selected.delete(key);
19403
20279
  callFn(config.data_onunselected, $$.api, d, $$.canvasEngine.canvas);
19404
20280
  changed = true;
@@ -19645,12 +20521,12 @@ const canvasInternal = {
19645
20521
  updateCanvasSubchartBrush(event) {
19646
20522
  var _a, _b;
19647
20523
  const $$ = this;
19648
- const { state } = $$;
20524
+ const { config, state } = $$;
19649
20525
  const start = state.canvasSubchartBrushStart;
19650
20526
  const origin = state.canvasSubchartBrushOrigin;
19651
20527
  const mode = state.canvasSubchartBrushMode;
19652
20528
  const coord = getCanvasSubchartBrushCoord($$, event, true);
19653
- if (!state.canvasSubchartBrushDragging || start === null || coord === null || !mode) {
20529
+ if (config.subchart_brush_enabled === false || !state.canvasSubchartBrushDragging || start === null || coord === null || !mode) {
19654
20530
  return false;
19655
20531
  }
19656
20532
  const delta = coord - start;
@@ -19701,6 +20577,10 @@ const canvasInternal = {
19701
20577
  updateCanvasSubchartCursor(event) {
19702
20578
  const $$ = this;
19703
20579
  const canvas2 = $$.$el.canvas.node();
20580
+ if ($$.config.subchart_brush_enabled === false) {
20581
+ canvas2.style.cursor = "";
20582
+ return false;
20583
+ }
19704
20584
  const coord = getCanvasSubchartBrushCoord($$, event);
19705
20585
  if (coord === null) {
19706
20586
  canvas2.style.cursor = "";
@@ -19720,6 +20600,9 @@ const canvasInternal = {
19720
20600
  var _a;
19721
20601
  const $$ = this;
19722
20602
  const { state } = $$;
20603
+ if ($$.config.subchart_brush_enabled === false) {
20604
+ return false;
20605
+ }
19723
20606
  const coord = getCanvasSubchartBrushCoord($$, event);
19724
20607
  if (coord === null) {
19725
20608
  return false;
@@ -20079,7 +20962,8 @@ const canvasInternal = {
20079
20962
  (_b = $$.hideTooltip) == null ? void 0 : _b.call($$);
20080
20963
  return;
20081
20964
  }
20082
- const point = getCanvasEventPoint($$, event);
20965
+ const rawPoint = getCanvasEventPoint($$, event);
20966
+ const point = rawPoint && (getCanvasMainPointFromSubchart($$, rawPoint) || rawPoint);
20083
20967
  const d = point ? getCanvasHoverDatumFromPoint($$, point) : null;
20084
20968
  if (!d) {
20085
20969
  $$.dispatchCanvasDataOut(canvas2);
@@ -20087,8 +20971,8 @@ const canvasInternal = {
20087
20971
  state.canvasFocusKey = null;
20088
20972
  $$.clearCanvasFocus();
20089
20973
  }
20090
- if (point && config.axis_tooltip && isCanvasAxisTooltipArea($$, point)) {
20091
- $$.renderCanvasAxisTooltip(point);
20974
+ if (rawPoint && config.axis_tooltip && isCanvasAxisTooltipArea($$, rawPoint)) {
20975
+ $$.renderCanvasAxisTooltip(rawPoint);
20092
20976
  (_c = $$.hideTooltip) == null ? void 0 : _c.call($$);
20093
20977
  return;
20094
20978
  }
@@ -20219,6 +21103,7 @@ const canvasInternal = {
20219
21103
  state.hasAxis && $$.config.grid_lines_front && $$.canvasAxisRenderer.drawGridLines($$);
20220
21104
  $$.canvasRenderer.drawSubchart($$, drawShape);
20221
21105
  state.hasAxis && $$.canvasAxisRenderer.drawSubXAxis($$);
21106
+ state.hasAxis && $$.canvasAxisRenderer.drawSubYAxes($$);
20222
21107
  $$.canvasRenderer.drawEmptyLabel($$);
20223
21108
  rebuildHit && $$.hitDetector.rebuild($$, drawShape);
20224
21109
  } finally {
@@ -20250,6 +21135,7 @@ const canvasInternal = {
20250
21135
  state.hasAxis && $$.config.grid_lines_front && $$.canvasAxisRenderer.drawGridLines($$);
20251
21136
  $$.canvasRenderer.drawSubchart($$, drawShape);
20252
21137
  state.hasAxis && $$.canvasAxisRenderer.drawSubXAxis($$);
21138
+ state.hasAxis && $$.canvasAxisRenderer.drawSubYAxes($$);
20253
21139
  $$.canvasRenderer.drawEmptyLabel($$);
20254
21140
  } finally {
20255
21141
  $$.canvasEngine.endFrame();
@@ -20871,14 +21757,17 @@ extend(api_data_data, {
20871
21757
  const $$ = this.internal;
20872
21758
  const { config, state, $el } = $$;
20873
21759
  const targetIds = $$.mapToTargetIds(targetIdsValue);
20874
- if (state.isCanvasMode) {
20875
- const changed = !!((_a = state.focusedTargetIds) == null ? void 0 : _a.size) || !!((_b = state.defocusedTargetIds) == null ? void 0 : _b.size);
21760
+ const resetLegend = () => {
20876
21761
  if (config.legend_show) {
20877
21762
  $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
20878
21763
  $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function() {
20879
21764
  return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused);
20880
21765
  }).classed($FOCUS.legendItemFocused, false);
20881
21766
  }
21767
+ };
21768
+ if (state.isCanvasMode) {
21769
+ const changed = !!((_a = state.focusedTargetIds) == null ? void 0 : _a.size) || !!((_b = state.defocusedTargetIds) == null ? void 0 : _b.size);
21770
+ resetLegend();
20882
21771
  state.focusedTargetIds = /* @__PURE__ */ new Set();
20883
21772
  state.defocusedTargetIds = /* @__PURE__ */ new Set();
20884
21773
  changed && ((_c = $$.renderCanvasFrame) == null ? void 0 : _c.call($$, void 0, null, false));
@@ -20887,12 +21776,7 @@ extend(api_data_data, {
20887
21776
  const candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
20888
21777
  candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, false);
20889
21778
  $$.hasArcType(null, ["polar"]) && $$.unexpandArc(targetIds);
20890
- if (config.legend_show) {
20891
- $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
20892
- $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function() {
20893
- return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($FOCUS.legendItemFocused);
20894
- }).classed($FOCUS.legendItemFocused, false);
20895
- }
21779
+ resetLegend();
20896
21780
  state.focusedTargetIds = /* @__PURE__ */ new Set();
20897
21781
  state.defocusedTargetIds = /* @__PURE__ */ new Set();
20898
21782
  }
@@ -22338,7 +23222,7 @@ extend(ygrids, {
22338
23222
 
22339
23223
 
22340
23224
 
22341
- const GRID_FOCUS_SELECTOR = `line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`;
23225
+ const GRID_FOCUS_SELECTOR = `line.${$FOCUS.xgridFocus}:not(.${$FOCUS.xgridFocusContinuous}), line.${$FOCUS.ygridFocus}`;
22342
23226
  const _getGridTextAnchor = (d) => isValue(d.position) || "end";
22343
23227
  const _getGridTextDx = (d) => d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
22344
23228
  function _getGridFocusEl($$) {
@@ -22349,6 +23233,9 @@ function _getGridFocusEl($$) {
22349
23233
  const cachedNodes = ((_a = cached == null ? void 0 : cached.nodes) == null ? void 0 : _a.call(cached)) || [];
22350
23234
  return cachedNodes.length && cachedNodes.every((node) => mainNode == null ? void 0 : mainNode.contains(node)) ? cached : state._gridFocusEl = main.selectAll(GRID_FOCUS_SELECTOR);
22351
23235
  }
23236
+ function _hideContinuousGridFocus($$) {
23237
+ $$.$el.main.select(`line.${$FOCUS.xgridFocusContinuous}`).style("visibility", "hidden");
23238
+ }
22352
23239
  function _getGridTextX(isX, width, height) {
22353
23240
  return (d) => {
22354
23241
  let x = isX ? 0 : width;
@@ -22519,6 +23406,7 @@ function _smoothLines(el, type) {
22519
23406
  if (config.grid_focus_y && !config.tooltip_grouped) {
22520
23407
  grid.append("g").attr("class", $FOCUS.ygridFocus).append("line").attr("class", $FOCUS.ygridFocus);
22521
23408
  }
23409
+ config.subchart_grid_focus_continuous && config.subchart_grid_focus !== false && $el.main.insert("g", className).attr("class", $FOCUS.xgridFocusContinuous).append("line").attr("class", `${$FOCUS.xgridFocus} ${$FOCUS.xgridFocusContinuous}`).style("visibility", "hidden");
22522
23410
  }
22523
23411
  },
22524
23412
  showAxisGridFocus() {
@@ -22627,6 +23515,7 @@ function _smoothLines(el, type) {
22627
23515
  if (force || inputType === "mouse" || !resizing) {
22628
23516
  const focusEl = _getGridFocusEl($$);
22629
23517
  focusEl.style("visibility", "hidden");
23518
+ _hideContinuousGridFocus($$);
22630
23519
  (_a = $$.hideCircleFocus) == null ? void 0 : _a.call($$);
22631
23520
  }
22632
23521
  },
@@ -22644,6 +23533,7 @@ function _smoothLines(el, type) {
22644
23533
  } else {
22645
23534
  const isRotated = $$.config.axis_rotated;
22646
23535
  xgridFocus.attr("x1", isRotated ? 0 : -10).attr("x2", isRotated ? width : -10).attr("y1", isRotated ? -10 : 0).attr("y2", isRotated ? -10 : height);
23536
+ _hideContinuousGridFocus($$);
22647
23537
  }
22648
23538
  return true;
22649
23539
  },
@@ -22782,28 +23672,85 @@ let grid_grid = () => {
22782
23672
 
22783
23673
 
22784
23674
 
23675
+ function setSelectionForFocusOnly(isSelection, ids, indices, resetOther) {
23676
+ const $$ = this;
23677
+ const { config, $el: { main } } = $$;
23678
+ const selectionGrouped = config.data_selection_grouped;
23679
+ const isSelectable = config.data_selection_isselectable.bind($$.api);
23680
+ const targetIds = isDefined(ids) ? [].concat(ids) : null;
23681
+ const singleSelection = isSelection && !config.data_selection_multiple;
23682
+ let resetDone = !singleSelection;
23683
+ const unselect = (circle, d, index) => {
23684
+ $$.unselectPoint(circle, d, index);
23685
+ circle.interrupt().remove();
23686
+ };
23687
+ $$.getTargetsToShow().forEach((target) => {
23688
+ const { id } = target;
23689
+ const isTargetId = selectionGrouped || !targetIds || targetIds.indexOf(id) >= 0;
23690
+ const selectedCircles = main.select(
23691
+ `.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(id)}`
23692
+ );
23693
+ target.values.forEach((d) => {
23694
+ const { index } = d;
23695
+ const isTargetIndex = !indices || indices.indexOf(index) >= 0;
23696
+ const circle = selectedCircles.selectAll(`.${$SELECT.selectedCircle}-${index}`);
23697
+ const isSelected = !circle.empty();
23698
+ if (isSelection) {
23699
+ if (isTargetId && isTargetIndex && isSelectable(d) && (!isSelected || singleSelection)) {
23700
+ if (!resetDone) {
23701
+ setSelectionForFocusOnly.call($$, false);
23702
+ resetDone = true;
23703
+ }
23704
+ $$.selectPoint(null, d, index);
23705
+ } else if ((!singleSelection || resetDone) && isDefined(resetOther) && resetOther && isSelected) {
23706
+ unselect(circle, d, index);
23707
+ }
23708
+ } else if (isTargetId && isTargetIndex && isSelected) {
23709
+ unselect(circle, d, index);
23710
+ }
23711
+ });
23712
+ });
23713
+ }
22785
23714
  function setSelection(isSelection = false, ids, indices, resetOther) {
23715
+ var _a;
22786
23716
  const $$ = this;
22787
23717
  const { config, $el: { main } } = $$;
22788
23718
  const selectionGrouped = config.data_selection_grouped;
22789
23719
  const isSelectable = config.data_selection_isselectable.bind($$.api);
23720
+ const singleSelection = isSelection && !config.data_selection_multiple;
23721
+ let resetDone = !singleSelection;
22790
23722
  if (!config.data_selection_enabled) {
22791
23723
  return;
22792
23724
  }
23725
+ if (singleSelection) {
23726
+ indices = (indices == null ? void 0 : indices.length) ? [indices[0]] : [0];
23727
+ if (!selectionGrouped) {
23728
+ const targetIds = isDefined(ids) ? [].concat(ids) : $$.getTargetsToShow().map((t) => t.id);
23729
+ ids = targetIds.slice(0, 1);
23730
+ }
23731
+ }
23732
+ if ((_a = $$.isPointFocusOnly) == null ? void 0 : _a.call($$)) {
23733
+ setSelectionForFocusOnly.call($$, isSelection, ids, indices, resetOther);
23734
+ return;
23735
+ }
22793
23736
  main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).each(function(d) {
22794
23737
  const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
22795
23738
  const { id, index } = d.data ? d.data : d;
22796
- const toggle = $$.getToggle(this, d).bind($$);
22797
23739
  const isTargetId = selectionGrouped || !ids || ids.indexOf(id) >= 0;
22798
23740
  const isTargetIndex = !indices || indices.indexOf(index) >= 0;
22799
- const isSelected = shape.classed($SELECT.SELECTED);
22800
23741
  if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
22801
23742
  return;
22802
23743
  }
23744
+ const toggle = $$.getToggle(this, d).bind($$);
23745
+ const isSelected = shape.classed($SELECT.SELECTED);
22803
23746
  if (isSelection) {
22804
- if (isTargetId && isTargetIndex && isSelectable(d) && !isSelected) {
22805
- toggle(true, shape.classed($SELECT.SELECTED, true), d, index);
22806
- } else if (isDefined(resetOther) && resetOther && isSelected) {
23747
+ if (isTargetId && isTargetIndex && isSelectable(d) && (!isSelected || singleSelection)) {
23748
+ if (!resetDone) {
23749
+ setSelection.call($$, false);
23750
+ resetDone = true;
23751
+ }
23752
+ !shape.classed($SELECT.SELECTED) && toggle(true, shape.classed($SELECT.SELECTED, true), d, index);
23753
+ } else if ((!singleSelection || resetDone) && isDefined(resetOther) && resetOther && isSelected) {
22807
23754
  toggle(false, shape.classed($SELECT.SELECTED, false), d, index);
22808
23755
  }
22809
23756
  } else {
@@ -22831,12 +23778,16 @@ function setSelection(isSelection = false, ids, indices, resetOther) {
22831
23778
  * chart.selected("data1");
22832
23779
  */
22833
23780
  selected(targetId) {
22834
- var _a;
23781
+ var _a, _b;
22835
23782
  const $$ = this.internal;
22836
23783
  const dataPoint = [];
22837
23784
  if ($$.state.isCanvasMode) {
22838
23785
  return ((_a = $$.getCanvasSelectedData) == null ? void 0 : _a.call($$, targetId)) || dataPoint;
22839
23786
  }
23787
+ if ((_b = $$.isPointFocusOnly) == null ? void 0 : _b.call($$)) {
23788
+ $$.$el.main.selectAll(`.${$SELECT.selectedCircles + $$.getTargetSelectorSuffix(targetId)}`).selectAll(`.${$SELECT.selectedCircle}`).each((d) => dataPoint.push(d));
23789
+ return dataPoint;
23790
+ }
22840
23791
  $$.$el.main.selectAll(`.${$SHAPE.shapes + $$.getTargetSelectorSuffix(targetId)}`).selectAll(`.${$SHAPE.shape}`).filter(function() {
22841
23792
  return (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).classed($SELECT.SELECTED);
22842
23793
  }).each((d) => dataPoint.push(d));
@@ -23034,7 +23985,7 @@ var selection_spreadProps = (a, b) => selection_defProps(a, selection_getOwnProp
23034
23985
  const cx = (isRotated ? $$.circleY : $$.circleX).bind($$);
23035
23986
  const cy = (isRotated ? $$.circleX : $$.circleY).bind($$);
23036
23987
  const r = $$.pointSelectR.bind($$);
23037
- callFn(config.data_onselected, $$.api, d, target.node());
23988
+ callFn(config.data_onselected, $$.api, d, target == null ? void 0 : target.node());
23038
23989
  $T(main.select(`.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(d.id)}`).selectAll(`.${$SELECT.selectedCircle}-${i}`).data([d]).enter().append("circle").attr("class", () => $$.generateClass($SELECT.selectedCircle, i)).attr("cx", cx).attr("cy", cy).attr("stroke", $$.color).attr("r", (d2) => $$.pointSelectR(d2) * 1.4)).attr("r", r);
23039
23990
  },
23040
23991
  /**
@@ -23463,7 +24414,134 @@ extend(subchart, {
23463
24414
 
23464
24415
 
23465
24416
 
24417
+
24418
+
24419
+ const SUBCHART_TYPES = ["bar", "line", "bubble", "candlestick", "scatter"];
24420
+ const FOCUS_GRID_STYLE_PROPS = [
24421
+ "opacity",
24422
+ "stroke",
24423
+ "stroke-dasharray",
24424
+ "stroke-dashoffset",
24425
+ "stroke-linecap",
24426
+ "stroke-linejoin",
24427
+ "stroke-miterlimit",
24428
+ "stroke-opacity",
24429
+ "stroke-width"
24430
+ ];
24431
+ function syncSubchartGridFocusStyle($$, line) {
24432
+ var _a, _b;
24433
+ const source = (_b = (_a = $$.$el.grid) == null ? void 0 : _a.main) == null ? void 0 : _b.select(`line.${config_classes.xgridFocus}`).node();
24434
+ if (!source || !win.getComputedStyle) {
24435
+ return;
24436
+ }
24437
+ const style = win.getComputedStyle(source);
24438
+ FOCUS_GRID_STYLE_PROPS.forEach((prop) => {
24439
+ const value = style.getPropertyValue(prop);
24440
+ value && line.style(prop, value);
24441
+ });
24442
+ }
24443
+ function getFiniteAttr(value, fallback) {
24444
+ const parsed = Number(value);
24445
+ return Number.isFinite(parsed) ? parsed : fallback;
24446
+ }
24447
+ function showContinuousSubchartGridFocus($$) {
24448
+ var _a, _b;
24449
+ if (!isContinuousGridFocusEnabled($$)) {
24450
+ return false;
24451
+ }
24452
+ const { config, state, $el } = $$;
24453
+ const mainLine = (_b = (_a = $el.grid) == null ? void 0 : _a.main) == null ? void 0 : _b.select(
24454
+ `line.${config_classes.xgridFocus}:not(.${config_classes.xgridFocusContinuous})`
24455
+ );
24456
+ const line = $el.main.select(`line.${config_classes.xgridFocusContinuous}`);
24457
+ if (!(mainLine == null ? void 0 : mainLine.node()) || !line.node()) {
24458
+ return false;
24459
+ }
24460
+ const x2 = state.margin2.left - state.margin.left + state.width2;
24461
+ const y2 = state.margin2.top - state.margin.top + state.height2;
24462
+ syncSubchartGridFocusStyle($$, line);
24463
+ config.axis_rotated ? line.attr("x1", getFiniteAttr(mainLine.attr("x1"), 0)).attr("x2", x2).attr("y1", getFiniteAttr(mainLine.attr("y1"), -10)).attr("y2", getFiniteAttr(mainLine.attr("y2"), -10)) : line.attr("x1", getFiniteAttr(mainLine.attr("x1"), -10)).attr("x2", getFiniteAttr(mainLine.attr("x2"), -10)).attr("y1", getFiniteAttr(mainLine.attr("y1"), 0)).attr("y2", y2);
24464
+ line.style("visibility", null);
24465
+ mainLine.style("visibility", "hidden");
24466
+ return true;
24467
+ }
24468
+ function hideContinuousSubchartGridFocus($$) {
24469
+ var _a;
24470
+ (_a = $$.$el.main) == null ? void 0 : _a.select(`line.${config_classes.xgridFocusContinuous}`).style("visibility", "hidden");
24471
+ }
24472
+ function getMainPointFromSubchartEvent($$, event, context) {
24473
+ const { config, state } = $$;
24474
+ const [x, y] = getPointer(event, context);
24475
+ const mainCoord = getMainCoordFromSubchartCoord($$, config.axis_rotated ? y : x);
24476
+ if (mainCoord === null) {
24477
+ return null;
24478
+ }
24479
+ return config.axis_rotated ? [state.width / 2, mainCoord] : [mainCoord, state.height / 2];
24480
+ }
24481
+ function dispatchSubchartEvent($$, type, event, context) {
24482
+ var _a, _b;
24483
+ const mainEventRect = (_b = (_a = $$.$el.eventRect) == null ? void 0 : _a.node) == null ? void 0 : _b.call(_a);
24484
+ if (!mainEventRect) {
24485
+ return;
24486
+ }
24487
+ const point = getMainPointFromSubchartEvent($$, event, context) || [0, 0];
24488
+ const rect = getBoundingRect(mainEventRect, true);
24489
+ const clientX = rect.left + point[0];
24490
+ const clientY = rect.top + point[1];
24491
+ const params = {
24492
+ bubbles: true,
24493
+ cancelable: true,
24494
+ screenX: clientX,
24495
+ screenY: clientY,
24496
+ clientX,
24497
+ clientY
24498
+ };
24499
+ /^touch/.test(type) ? emulateEvent.touch(mainEventRect, type, params) : emulateEvent.mouse(mainEventRect, type, params);
24500
+ }
23466
24501
  /* harmony default export */ var interactions_subchart = ({
24502
+ /**
24503
+ * Whether subchart brush interaction is enabled.
24504
+ * @returns {boolean}
24505
+ * @private
24506
+ */
24507
+ isSubchartBrushEnabled() {
24508
+ const { config } = this;
24509
+ return config.subchart_show && config.subchart_brush_enabled !== false;
24510
+ },
24511
+ /**
24512
+ * Bind event rect handlers for subchart hover interactions.
24513
+ * @param {d3Selection} eventRect Subchart event rect selection
24514
+ * @private
24515
+ */
24516
+ bindSubchartEventRect(eventRect) {
24517
+ const $$ = this;
24518
+ const { config, state } = $$;
24519
+ eventRect.on("mouseover mousemove mouseout touchstart touchmove touchend", null);
24520
+ if (!config.interaction_enabled) {
24521
+ return;
24522
+ }
24523
+ if (state.inputType === "mouse") {
24524
+ eventRect.on("mouseover mousemove", function(event) {
24525
+ if ($$.isSubchartBrushEnabled()) {
24526
+ return;
24527
+ }
24528
+ dispatchSubchartEvent($$, event.type, event, this);
24529
+ }).on("mouseout", function(event) {
24530
+ if ($$.isSubchartBrushEnabled()) {
24531
+ return;
24532
+ }
24533
+ dispatchSubchartEvent($$, "mouseout", event, this);
24534
+ });
24535
+ } else if (state.inputType === "touch") {
24536
+ eventRect.on("touchstart touchmove touchend", function(event) {
24537
+ var _a;
24538
+ if ($$.isSubchartBrushEnabled() || ((_a = event.touches) == null ? void 0 : _a.length) > 1) {
24539
+ return;
24540
+ }
24541
+ dispatchSubchartEvent($$, event.type, event, this);
24542
+ });
24543
+ }
24544
+ },
23467
24545
  /**
23468
24546
  * Initialize the brush.
23469
24547
  * @private
@@ -23557,19 +24635,26 @@ extend(subchart, {
23557
24635
  const { main } = subchart;
23558
24636
  main.style("visibility", visibility);
23559
24637
  main.append("g").attr("clip-path", clipPath).attr("class", config_classes.chart);
23560
- ["bar", "line", "bubble", "candlestick", "scatter"].forEach((v) => {
23561
- const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
23562
- if ($$.hasType(v) || $$.hasTypeOf(type)) {
23563
- const chart = main.select(`.${config_classes.chart}`);
23564
- const chartClassName = config_classes[`chart${type}s`];
23565
- if (chart.select(`.${chartClassName}`).empty()) {
23566
- chart.append("g").attr("class", chartClassName);
24638
+ $$.withSubchartTypeContext(() => {
24639
+ SUBCHART_TYPES.forEach((v) => {
24640
+ const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
24641
+ if ($$.hasType(v) || $$.hasTypeOf(type)) {
24642
+ const chart = main.select(`.${config_classes.chart}`);
24643
+ const chartClassName = config_classes[`chart${type}s`];
24644
+ if (chart.select(`.${chartClassName}`).empty()) {
24645
+ chart.append("g").attr("class", chartClassName);
24646
+ }
23567
24647
  }
23568
- }
24648
+ });
23569
24649
  });
23570
- const brush = main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).call($$.brush);
24650
+ const brush = main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).style("pointer-events", $$.isSubchartBrushEnabled() ? null : "none").call($$.brush);
23571
24651
  config.subchart_showHandle && $$.addBrushHandle(brush);
24652
+ subchart.eventRect = main.append("g").attr("clip-path", clipPath).attr("class", `${config_classes.eventRects} ${config_classes.eventRects}-subchart`).style("fill-opacity", "0").style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all").append("rect").attr("class", `${config_classes.eventRect} ${config_classes.eventRect}-subchart`).attr("width", $$.state.width2).attr("height", $$.state.height2);
24653
+ $$.bindSubchartEventRect(subchart.eventRect);
24654
+ main.append("g").attr("clip-path", clipPath).attr("class", config_classes.xgridFocus).append("line").attr("class", config_classes.xgridFocus).style("visibility", "hidden");
23572
24655
  axis.subX = main.append("g").attr("class", config_classes.axisX).attr("transform", $$.getTranslate("subX")).attr("clip-path", config.axis_rotated ? "" : clip.pathXAxis).style("visibility", config.subchart_axis_x_show ? visibility : "hidden");
24656
+ axis.subY = main.append("g").attr("class", config_classes.axisY).attr("transform", $$.getTranslate("subY")).style("visibility", config.subchart_axis_y_show ? visibility : "hidden");
24657
+ axis.subY2 = main.append("g").attr("class", config_classes.axisY2).attr("transform", $$.getTranslate("subY2")).style("visibility", config.subchart_axis_y2_show ? visibility : "hidden");
23573
24658
  },
23574
24659
  /**
23575
24660
  * Add brush handle
@@ -23592,64 +24677,89 @@ extend(subchart, {
23592
24677
  * @private
23593
24678
  */
23594
24679
  updateTargetsForSubchart(targets) {
24680
+ var _a;
23595
24681
  const $$ = this;
23596
24682
  const { config, state, $el: { subchart: { main } } } = $$;
23597
24683
  if (config.subchart_show) {
23598
- ["bar", "line", "bubble", "candlestick", "scatter"].filter((v) => $$.hasType(v) || $$.hasTypeOf(capitalize(v))).forEach((v) => {
23599
- const isPointType = /^(bubble|scatter)$/.test(v);
23600
- const name = capitalize(isPointType ? "circle" : v);
23601
- const chartClass = $$.getChartClass(name, true);
23602
- const shapeClass = $$.getClass(isPointType ? "circles" : `${v}s`, true);
23603
- const shapeChart = main.select(`.${config_classes[`chart${`${name}s`}`]}`);
23604
- if (isPointType) {
23605
- const circle = shapeChart.selectAll(`.${config_classes.circles}`).data(targets.filter($$[`is${capitalize(v)}Type`].bind($$))).attr("class", shapeClass);
23606
- circle.exit().remove();
23607
- circle.enter().append("g").attr("class", shapeClass);
23608
- } else {
23609
- const shapeUpdate = shapeChart.selectAll(`.${config_classes[`chart${name}`]}`).attr("class", chartClass).data(targets.filter($$[`is${name}Type`].bind($$)));
23610
- const shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
23611
- shapeUpdate.exit().remove();
23612
- v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", true));
23613
- }
24684
+ $$.withSubchartTypeContext(() => {
24685
+ SUBCHART_TYPES.filter((v) => $$.hasType(v) || $$.hasTypeOf(capitalize(v))).forEach((v) => {
24686
+ const isPointType = /^(bubble|scatter)$/.test(v);
24687
+ const name = capitalize(isPointType ? "circle" : v);
24688
+ const chartClass = $$.getChartClass(name, true);
24689
+ const shapeClass = $$.getClass(isPointType ? "circles" : `${v}s`, true);
24690
+ const shapeChart = main.select(`.${config_classes[`chart${`${name}s`}`]}`);
24691
+ if (isPointType) {
24692
+ const circle = shapeChart.selectAll(`.${config_classes.circles}`).data(targets.filter($$[`is${capitalize(v)}Type`].bind($$))).attr("class", shapeClass);
24693
+ circle.exit().remove();
24694
+ circle.enter().append("g").attr("class", shapeClass);
24695
+ } else {
24696
+ const shapeUpdate = shapeChart.selectAll(`.${config_classes[`chart${name}`]}`).attr("class", chartClass).data(targets.filter($$[`is${name}Type`].bind($$)));
24697
+ const shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
24698
+ shapeUpdate.exit().remove();
24699
+ v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", true));
24700
+ }
24701
+ });
23614
24702
  });
23615
24703
  main.selectAll(`.${config_classes.brush} rect`).attr(
23616
24704
  config.axis_rotated ? "width" : "height",
23617
24705
  config.axis_rotated ? state.width2 : state.height2
23618
24706
  );
24707
+ (_a = $$.$el.subchart.eventRect) == null ? void 0 : _a.attr("width", state.width2).attr("height", state.height2).style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all");
23619
24708
  }
23620
24709
  },
24710
+ /**
24711
+ * Update subchart y domains using subchart type options.
24712
+ * @param {object} targets Targets to show
24713
+ * @private
24714
+ */
24715
+ updateSubchartYDomain(targets) {
24716
+ var _a, _b;
24717
+ const $$ = this;
24718
+ const { scale } = $$;
24719
+ const targetsToShow = targets || $$.filterTargetsToShow($$.data.targets);
24720
+ (_a = scale.subY) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, "y"));
24721
+ (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
24722
+ },
23621
24723
  /**
23622
24724
  * Redraw subchart.
23623
24725
  * @private
23624
24726
  * @param {boolean} withSubchart whether or not to show subchart
23625
24727
  * @param {number} duration duration
23626
- * @param {object} shape Shape's info
23627
24728
  */
23628
- redrawSubchart(withSubchart, duration, shape) {
23629
- var _a;
24729
+ redrawSubchart(withSubchart, duration) {
24730
+ var _a, _b, _c, _d;
23630
24731
  const $$ = this;
23631
24732
  const { config, $el: { subchart: { main } }, state } = $$;
23632
24733
  const withTransition = !!duration;
23633
24734
  main.style("visibility", config.subchart_show ? null : "hidden");
24735
+ main.select(`.${config_classes.brush}`).style("pointer-events", $$.isSubchartBrushEnabled() ? null : "none");
24736
+ (_a = $$.$el.subchart.eventRect) == null ? void 0 : _a.style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all");
24737
+ (_b = $$.$el.axis.subY) == null ? void 0 : _b.style("visibility", config.subchart_axis_y_show ? null : "hidden");
24738
+ (_c = $$.$el.axis.subY2) == null ? void 0 : _c.style("visibility", config.subchart_axis_y2_show ? null : "hidden");
23634
24739
  if (config.subchart_show) {
23635
- if (((_a = state.event) == null ? void 0 : _a.type) === "zoom") {
24740
+ if (((_d = state.event) == null ? void 0 : _d.type) === "zoom") {
23636
24741
  $$.brush.update();
23637
24742
  }
23638
24743
  if (withSubchart) {
23639
24744
  const initRange = config.subchart_init_range;
23640
24745
  !brushEmpty($$) && $$.brush.update();
23641
- Object.keys(shape.type).forEach((v) => {
23642
- const name = capitalize(v);
23643
- const drawFn = $$[`generateDraw${name}`](shape.indices[v], true);
23644
- $$[`update${name}`](withTransition, true);
23645
- $$[`redraw${name}`](drawFn, withTransition, true);
24746
+ $$.withSubchartTypeContext(() => {
24747
+ const targetsToShow = state._targetsToShow || $$.filterTargetsToShow($$.data.targets);
24748
+ $$.updateSubchartYDomain(targetsToShow);
24749
+ const subchartShape = $$.getDrawShape();
24750
+ Object.keys(subchartShape.type).forEach((v) => {
24751
+ const name = capitalize(v);
24752
+ const drawFn = $$[`generateDraw${name}`](subchartShape.indices[v], true);
24753
+ $$[`update${name}`](withTransition, true);
24754
+ $$[`redraw${name}`](drawFn, withTransition, true);
24755
+ });
24756
+ if ($$.hasType("bubble") || $$.hasType("scatter")) {
24757
+ const { cx } = subchartShape.pos;
24758
+ const cy = $$.updateCircleY(true);
24759
+ $$.updateCircle(true);
24760
+ $$.redrawCircle(cx, cy, withTransition, void 0, true);
24761
+ }
23646
24762
  });
23647
- if ($$.hasType("bubble") || $$.hasType("scatter")) {
23648
- const { cx } = shape.pos;
23649
- const cy = $$.updateCircleY(true);
23650
- $$.updateCircle(true);
23651
- $$.redrawCircle(cx, cy, withTransition, void 0, true);
23652
- }
23653
24763
  if (!state.rendered && initRange) {
23654
24764
  state.domain = initRange;
23655
24765
  $$.brush.move(
@@ -23660,6 +24770,46 @@ extend(subchart, {
23660
24770
  }
23661
24771
  }
23662
24772
  },
24773
+ /**
24774
+ * Show a focus grid line on subchart following main chart focus.
24775
+ * @param {Array} data Selected data
24776
+ * @private
24777
+ */
24778
+ showSubchartGridFocus(data) {
24779
+ const $$ = this;
24780
+ const { config, state, $el: { subchart: { main } } } = $$;
24781
+ if (!main || !config.subchart_show || $$.isSubchartBrushEnabled() || config.grid_focus_show === false || config.subchart_grid_focus === false || !config.tooltip_show || config.axis_tooltip) {
24782
+ return;
24783
+ }
24784
+ const focusData = Array.isArray(data) ? data : [data];
24785
+ const focus = focusData.find((d) => d && $$.getBaseValue(d) != null);
24786
+ if (!focus) {
24787
+ $$.hideSubchartGridFocus();
24788
+ return;
24789
+ }
24790
+ const pos = $$.scale.subX(focus.x);
24791
+ if (!Number.isFinite(pos)) {
24792
+ $$.hideSubchartGridFocus();
24793
+ return;
24794
+ }
24795
+ const line = main.select(`g.${config_classes.xgridFocus} line.${config_classes.xgridFocus}`);
24796
+ if (showContinuousSubchartGridFocus($$)) {
24797
+ line.style("visibility", "hidden");
24798
+ return;
24799
+ }
24800
+ syncSubchartGridFocusStyle($$, line);
24801
+ config.axis_rotated ? line.attr("x1", 0).attr("x2", state.width2).attr("y1", pos).attr("y2", pos) : line.attr("x1", pos).attr("x2", pos).attr("y1", 0).attr("y2", state.height2);
24802
+ line.style("visibility", null);
24803
+ },
24804
+ /**
24805
+ * Hide subchart focus grid line.
24806
+ * @private
24807
+ */
24808
+ hideSubchartGridFocus() {
24809
+ var _a;
24810
+ hideContinuousSubchartGridFocus(this);
24811
+ (_a = this.$el.subchart.main) == null ? void 0 : _a.select(`g.${config_classes.xgridFocus} line.${config_classes.xgridFocus}`).style("visibility", "hidden");
24812
+ },
23663
24813
  /**
23664
24814
  * Redraw the brush.
23665
24815
  * @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
@@ -23695,8 +24845,12 @@ extend(subchart, {
23695
24845
  const $$ = this;
23696
24846
  const { $el: { subchart }, $T } = $$;
23697
24847
  const subXAxis = (transitions == null ? void 0 : transitions.axisSubX) ? transitions.axisSubX : $T(subchart.main.select(`.${config_classes.axisX}`), withTransition);
24848
+ const subYAxis = (transitions == null ? void 0 : transitions.axisSubY) ? transitions.axisSubY : $T(subchart.main.select(`.${config_classes.axisY}`), withTransition);
24849
+ const subY2Axis = (transitions == null ? void 0 : transitions.axisSubY2) ? transitions.axisSubY2 : $T(subchart.main.select(`.${config_classes.axisY2}`), withTransition);
23698
24850
  subchart.main.attr("transform", $$.getTranslate("context"));
23699
24851
  subXAxis.attr("transform", $$.getTranslate("subX"));
24852
+ subYAxis.attr("transform", $$.getTranslate("subY"));
24853
+ subY2Axis.attr("transform", $$.getTranslate("subY2"));
23700
24854
  }
23701
24855
  });
23702
24856
 
@@ -23704,7 +24858,7 @@ extend(subchart, {
23704
24858
  /* harmony default export */ var interaction_subchart = ({
23705
24859
  /**
23706
24860
  * Set subchart options.
23707
- * - **NOTE:** Not supported for `bubble`, `scatter` and non-Axis based(pie, donut, gauge, radar) types.
24861
+ * - **NOTE:** Not supported for non-Axis based(pie, donut, gauge, radar) types.
23708
24862
  * @name subchart
23709
24863
  * @memberof Options
23710
24864
  * @type {object}
@@ -23712,11 +24866,45 @@ extend(subchart, {
23712
24866
  * @property {boolean} [subchart.show=false] Show sub chart on the bottom of the chart.
23713
24867
  * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
23714
24868
  * - `show: subchart()`
24869
+ * @property {string} [subchart.type] Set chart type for the subchart. Defaults to data.type.
24870
+ * @property {object} [subchart.types] Set chart type for each data in the subchart. Defaults to data.types.
24871
+ * @property {boolean} [subchart.brush.enabled=true] Enable subchart brush interaction.
23715
24872
  * @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
24873
+ * @property {boolean|object} [subchart.grid.focus=true] Show x focus grid line in subchart when subchart brush is disabled.
24874
+ * @property {boolean} [subchart.grid.focus.continuous=false] Render x focus grid line as one continuous line across main chart and subchart when subchart brush is disabled.
23716
24875
  * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
23717
24876
  * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
24877
+ * @property {number} [subchart.axis.x.tick.count] Set the number of x axis ticks.
24878
+ * @property {Array|function} [subchart.axis.x.tick.values] Set x axis tick values manually.
24879
+ * @property {boolean|object} [subchart.axis.x.tick.culling] Setting for culling x axis ticks.
24880
+ * @property {number} [subchart.axis.x.tick.culling.max] The number of x axis tick texts will be adjusted to less than this value.
24881
+ * @property {boolean} [subchart.axis.x.tick.culling.lines=true] Control x axis tick line visibility within culling option.
24882
+ * @property {boolean} [subchart.axis.x.tick.culling.reverse=false] Control x axis culling start point to be reversed.
24883
+ * @property {boolean} [subchart.axis.x.tick.outer] Show or hide x axis outer tick.
23718
24884
  * @property {function|string} [subchart.axis.x.tick.format] Use custom format for x axis ticks - see [axis.x.tick.format](#.axis․x․tick․format) for details.
23719
24885
  * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
24886
+ * @property {boolean} [subchart.axis.y.show=false] Show or hide y axis.
24887
+ * @property {boolean} [subchart.axis.y.tick.show=true] Show or hide y axis tick line.
24888
+ * @property {number} [subchart.axis.y.tick.count] Set the number of y axis ticks.
24889
+ * @property {Array|function} [subchart.axis.y.tick.values] Set y axis tick values manually.
24890
+ * @property {boolean|object} [subchart.axis.y.tick.culling] Setting for culling y axis ticks.
24891
+ * @property {number} [subchart.axis.y.tick.culling.max] The number of y axis tick texts will be adjusted to less than this value.
24892
+ * @property {boolean} [subchart.axis.y.tick.culling.lines=true] Control y axis tick line visibility within culling option.
24893
+ * @property {boolean} [subchart.axis.y.tick.culling.reverse=false] Control y axis culling start point to be reversed.
24894
+ * @property {boolean} [subchart.axis.y.tick.outer] Show or hide y axis outer tick.
24895
+ * @property {function|string} [subchart.axis.y.tick.format] Use custom format for y axis ticks - see [axis.y.tick.format](#.axis․y․tick․format) for details.
24896
+ * @property {boolean} [subchart.axis.y.tick.text.show=true] Show or hide y axis tick text.
24897
+ * @property {boolean} [subchart.axis.y2.show=false] Show or hide y2 axis.
24898
+ * @property {boolean} [subchart.axis.y2.tick.show=true] Show or hide y2 axis tick line.
24899
+ * @property {number} [subchart.axis.y2.tick.count] Set the number of y2 axis ticks.
24900
+ * @property {Array|function} [subchart.axis.y2.tick.values] Set y2 axis tick values manually.
24901
+ * @property {boolean|object} [subchart.axis.y2.tick.culling] Setting for culling y2 axis ticks.
24902
+ * @property {number} [subchart.axis.y2.tick.culling.max] The number of y2 axis tick texts will be adjusted to less than this value.
24903
+ * @property {boolean} [subchart.axis.y2.tick.culling.lines=true] Control y2 axis tick line visibility within culling option.
24904
+ * @property {boolean} [subchart.axis.y2.tick.culling.reverse=false] Control y2 axis culling start point to be reversed.
24905
+ * @property {boolean} [subchart.axis.y2.tick.outer] Show or hide y2 axis outer tick.
24906
+ * @property {function|string} [subchart.axis.y2.tick.format] Use custom format for y2 axis ticks - see [axis.y2.tick.format](#.axis․y2․tick․format) for details.
24907
+ * @property {boolean} [subchart.axis.y2.tick.text.show=true] Show or hide y2 axis tick text.
23720
24908
  * @property {Array} [subchart.init.range] Set initial selection domain range.
23721
24909
  * @property {number} [subchart.size.height] Change the height of the subchart.
23722
24910
  * @property {function} [subchart.onbrush] Set callback for brush event.<br>
@@ -23726,9 +24914,29 @@ extend(subchart, {
23726
24914
  * subchart: {
23727
24915
  * show: true,
23728
24916
  * showHandle: true,
24917
+ *
24918
+ * // render the overview with a different chart type than the main chart
24919
+ * type: "bar",
24920
+ *
24921
+ * // override the type per data series
24922
+ * types: {
24923
+ * data2: "area"
24924
+ * },
23729
24925
  * size: {
23730
24926
  * height: 20
23731
24927
  * },
24928
+ * brush: {
24929
+ * // disable brush(zoom) interaction, rendering the subchart as a static overview
24930
+ * enabled: false
24931
+ * },
24932
+ * grid: {
24933
+ * // set false to hide focus grid line in subchart
24934
+ * // focus: false,
24935
+ * focus: {
24936
+ * // NOTE: works only when 'brush.enabled=false'
24937
+ * continuous: true
24938
+ * }
24939
+ * },
23732
24940
  * init: {
23733
24941
  * // specify initial range domain selection
23734
24942
  * range: [1, 2]
@@ -23743,6 +24951,12 @@ extend(subchart, {
23743
24951
  * show: false
23744
24952
  * }
23745
24953
  * }
24954
+ * },
24955
+ * y: {
24956
+ * show: true,
24957
+ * tick: {
24958
+ * count: 3
24959
+ * }
23746
24960
  * }
23747
24961
  * },
23748
24962
  * onbrush: function(domain) { ... }
@@ -23757,12 +24971,46 @@ extend(subchart, {
23757
24971
  * }
23758
24972
  */
23759
24973
  subchart_show: false,
24974
+ subchart_type: void 0,
24975
+ subchart_types: {},
24976
+ subchart_brush_enabled: true,
23760
24977
  subchart_showHandle: false,
23761
24978
  subchart_size_height: 60,
24979
+ subchart_grid_focus: true,
24980
+ subchart_grid_focus_continuous: false,
23762
24981
  subchart_axis_x_show: true,
23763
24982
  subchart_axis_x_tick_show: true,
24983
+ subchart_axis_x_tick_count: void 0,
24984
+ subchart_axis_x_tick_values: void 0,
24985
+ subchart_axis_x_tick_culling: void 0,
24986
+ subchart_axis_x_tick_culling_max: void 0,
24987
+ subchart_axis_x_tick_culling_lines: void 0,
24988
+ subchart_axis_x_tick_culling_reverse: void 0,
24989
+ subchart_axis_x_tick_outer: void 0,
23764
24990
  subchart_axis_x_tick_format: void 0,
23765
24991
  subchart_axis_x_tick_text_show: true,
24992
+ subchart_axis_y_show: false,
24993
+ subchart_axis_y_tick_show: true,
24994
+ subchart_axis_y_tick_count: void 0,
24995
+ subchart_axis_y_tick_values: void 0,
24996
+ subchart_axis_y_tick_culling: void 0,
24997
+ subchart_axis_y_tick_culling_max: void 0,
24998
+ subchart_axis_y_tick_culling_lines: void 0,
24999
+ subchart_axis_y_tick_culling_reverse: void 0,
25000
+ subchart_axis_y_tick_outer: void 0,
25001
+ subchart_axis_y_tick_format: void 0,
25002
+ subchart_axis_y_tick_text_show: true,
25003
+ subchart_axis_y2_show: false,
25004
+ subchart_axis_y2_tick_show: true,
25005
+ subchart_axis_y2_tick_count: void 0,
25006
+ subchart_axis_y2_tick_values: void 0,
25007
+ subchart_axis_y2_tick_culling: void 0,
25008
+ subchart_axis_y2_tick_culling_max: void 0,
25009
+ subchart_axis_y2_tick_culling_lines: void 0,
25010
+ subchart_axis_y2_tick_culling_reverse: void 0,
25011
+ subchart_axis_y2_tick_outer: void 0,
25012
+ subchart_axis_y2_tick_format: void 0,
25013
+ subchart_axis_y2_tick_text_show: true,
23766
25014
  subchart_init_range: void 0,
23767
25015
  subchart_onbrush: () => {
23768
25016
  }
@@ -25162,7 +26410,7 @@ function _getStrokeDashArray(start, end, pattern, isLastX = false) {
25162
26410
  if (hasNullDataValue) {
25163
26411
  const dx = x(data.x) - x(prevData.x);
25164
26412
  const dy = y(data.value) - y(prevData.value);
25165
- const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
26413
+ const dd = Math.sqrt(dx * dx + dy * dy);
25166
26414
  diff = style[0] / dd;
25167
26415
  diffx2 = diff * style[1];
25168
26416
  for (let j = diff; j <= 1; j += diffx2) {
@@ -25318,12 +26566,23 @@ function getPointBBox(node) {
25318
26566
  });
25319
26567
  circles.exit().remove();
25320
26568
  const pointR = $$.pointR.bind($$);
25321
- const updateCircleColor = $$.updateCircleColor.bind($$);
26569
+ const updateCircleColor = $$.generateUpdateCircleColor();
25322
26570
  const initialOpacityForCircle = $$.initialOpacityForCircle.bind($$);
25323
26571
  circles.enter().filter(Boolean).append($$.point("create", this, pointR, updateCircleColor));
25324
26572
  $root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`).style("stroke", $$.getStylePropValue($$.color)).style("opacity", initialOpacityForCircle);
25325
26573
  }
25326
26574
  },
26575
+ /**
26576
+ * Generate circle color accessor, hoisting the bound color function
26577
+ * to be created once per call (not per datum)
26578
+ * @returns {function} Color accessor
26579
+ * @private
26580
+ */
26581
+ generateUpdateCircleColor() {
26582
+ const $$ = this;
26583
+ const fn = $$.getStylePropValue($$.color);
26584
+ return (d) => $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
26585
+ },
25327
26586
  /**
25328
26587
  * Update circle color
25329
26588
  * @param {object} d Data object
@@ -25331,9 +26590,7 @@ function getPointBBox(node) {
25331
26590
  * @private
25332
26591
  */
25333
26592
  updateCircleColor(d) {
25334
- const $$ = this;
25335
- const fn = $$.getStylePropValue($$.color);
25336
- return $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
26593
+ return this.generateUpdateCircleColor()(d);
25337
26594
  },
25338
26595
  redrawCircle(cx, cy, withTransition, flow, isSub = false) {
25339
26596
  const $$ = this;
@@ -25346,6 +26603,7 @@ function getPointBBox(node) {
25346
26603
  const posAttr = $$.isCirclePoint() ? "c" : "";
25347
26604
  const t = getRandom();
25348
26605
  const opacityStyleFn = $$.opacityForCircle.bind($$);
26606
+ const updateCircleColor = $$.generateUpdateCircleColor();
25349
26607
  if ($$.isCirclePoint()) {
25350
26608
  const sel = $root.circle;
25351
26609
  if ($$.hasType("bubble")) {
@@ -25355,12 +26613,12 @@ function getPointBBox(node) {
25355
26613
  flow && sel.attr("cx", cx);
25356
26614
  $T(sel.filter(function() {
25357
26615
  return !!this.getAttribute("cx");
25358
- }), true, `${t}-pos`).attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
26616
+ }), true, `${t}-pos`).attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
25359
26617
  sel.filter(function() {
25360
26618
  return !this.getAttribute("cx");
25361
- }).attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
26619
+ }).attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
25362
26620
  } else {
25363
- sel.attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
26621
+ sel.attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
25364
26622
  }
25365
26623
  const result = $T(sel, withTransition || !rendered, t).style("opacity", opacityStyleFn);
25366
26624
  return [
@@ -25373,7 +26631,7 @@ function getPointBBox(node) {
25373
26631
  $$,
25374
26632
  cx,
25375
26633
  cy,
25376
- $$.updateCircleColor.bind($$),
26634
+ updateCircleColor,
25377
26635
  withTransition,
25378
26636
  flow,
25379
26637
  selectedCircles
@@ -25489,9 +26747,9 @@ function getPointBBox(node) {
25489
26747
  cx = x;
25490
26748
  cy = y;
25491
26749
  }
25492
- return Math.sqrt(
25493
- Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)
25494
- ) < (r || pointSensitivity);
26750
+ const dx = cx - mouse[0];
26751
+ const dy = cy - mouse[1];
26752
+ return Math.sqrt(dx * dx + dy * dy) < (r || pointSensitivity);
25495
26753
  },
25496
26754
  updatePointClass(d) {
25497
26755
  const $$ = this;
@@ -26086,8 +27344,6 @@ const axis = {
26086
27344
  }
26087
27345
  });
26088
27346
 
26089
- // EXTERNAL MODULE: external {"commonjs":"d3-axis","commonjs2":"d3-axis","amd":"d3-axis","root":"d3"}
26090
- var external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_ = __webpack_require__(10);
26091
27347
  ;// ./src/ChartInternal/Axis/AxisRendererHelper.ts
26092
27348
  var AxisRendererHelper_defProp = Object.defineProperty;
26093
27349
  var AxisRendererHelper_defNormalProp = (obj, key, value) => key in obj ? AxisRendererHelper_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -26143,7 +27399,7 @@ class AxisRendererHelper {
26143
27399
  /**
26144
27400
  * Get tick transform setter function
26145
27401
  * @param {string} id Axis id
26146
- * @returns {(selection: d3Selection, scale) => void} transfrom setter function
27402
+ * @returns {function(d3Selection, d3Scale): void} transform setter function
26147
27403
  * @private
26148
27404
  */
26149
27405
  getTickTransformSetter(id) {
@@ -26225,6 +27481,13 @@ var AxisRenderer_publicField = (obj, key, value) => AxisRenderer_defNormalProp(o
26225
27481
 
26226
27482
 
26227
27483
 
27484
+ function getBaseAxisId(id) {
27485
+ return id === "subX" ? "x" : id === "subY" ? "y" : id === "subY2" ? "y2" : id;
27486
+ }
27487
+ function getAxisOptionPrefix(id) {
27488
+ const type = getBaseAxisId(id);
27489
+ return /^sub/.test(id) ? `subchart_axis_${type}` : `axis_${type}`;
27490
+ }
26228
27491
  class AxisRenderer {
26229
27492
  constructor(params = {}) {
26230
27493
  AxisRenderer_publicField(this, "helper");
@@ -26257,8 +27520,8 @@ class AxisRenderer {
26257
27520
  const { config, params } = this;
26258
27521
  const { config: chartConfig, id, owner } = params;
26259
27522
  const isX = /^(x|subX)$/.test(id);
26260
- const type = id === "subX" ? "x" : id;
26261
- const customTickFormat = id === "subX" ? chartConfig.subchart_axis_x_tick_format || chartConfig.axis_x_tick_format : chartConfig[`axis_${type}_tick_format`];
27523
+ const type = getBaseAxisId(id);
27524
+ const customTickFormat = /^sub/.test(id) ? chartConfig[`subchart_axis_${type}_tick_format`] || chartConfig[`axis_${type}_tick_format`] : chartConfig[`axis_${type}_tick_format`];
26262
27525
  const categoryAutoWrap = params.tickMultiline && params.isCategory && !isLeftRight && !(params.tickWidth > 0);
26263
27526
  return !!(owner.state.resizing && !owner.state.flowing && !isFunction(chartConfig.axis_evalTextSize) && !customTickFormat && !params.tickTitle && !(isX && chartConfig.axis_x_tick_autorotate) && !categoryAutoWrap && config.withoutTransition);
26264
27527
  }
@@ -26300,10 +27563,12 @@ class AxisRenderer {
26300
27563
  this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
26301
27564
  const { innerTickSize, tickLength, range } = config;
26302
27565
  const id = params.id;
26303
- const tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config[`axis_${id}_tick_text_position`] : { x: 0, y: 0 };
26304
- const prefix = id === "subX" ? `subchart_axis_x` : `axis_${id}`;
27566
+ const type = getBaseAxisId(id);
27567
+ const { isSubAxes } = params;
27568
+ const tickTextPos = !isSubAxes && type && /^(x|y|y2)$/.test(type) ? params.config[`axis_${type}_tick_text_position`] : { x: 0, y: 0 };
27569
+ const prefix = getAxisOptionPrefix(id);
26305
27570
  const axisShow = params.config[`${prefix}_show`];
26306
- const tickShow = {
27571
+ const tickShow = isSubAxes ? { tick: true, text: true } : {
26307
27572
  tick: axisShow ? params.config[`${prefix}_tick_show`] : false,
26308
27573
  text: axisShow ? params.config[`${prefix}_tick_text_show`] : false
26309
27574
  };
@@ -26502,7 +27767,7 @@ class AxisRenderer {
26502
27767
  axis_x_tick_text_inner: inner
26503
27768
  }
26504
27769
  } = this.params.owner;
26505
- const tickLineInner = this.params.config[`axis_${axisId}_tick_inner`];
27770
+ const tickLineInner = this.params.config[`axis_${getBaseAxisId(axisId)}_tick_inner`];
26506
27771
  switch (orient) {
26507
27772
  case "bottom":
26508
27773
  lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", (d) => this.getTickSize.bind(this)(d) * (tickLineInner ? -1 : 1));
@@ -26697,7 +27962,17 @@ var Axis_publicField = (obj, key, value) => Axis_defNormalProp(obj, typeof key !
26697
27962
 
26698
27963
 
26699
27964
 
26700
-
27965
+ function Axis_getBaseAxisId(id) {
27966
+ return id === "subX" ? "x" : id === "subY" ? "y" : id === "subY2" ? "y2" : id;
27967
+ }
27968
+ function isSubAxis(id) {
27969
+ return /^sub/.test(id);
27970
+ }
27971
+ function Axis_getAxisTickOption(config, id, key) {
27972
+ const type = Axis_getBaseAxisId(id);
27973
+ const subValue = config[`subchart_axis_${type}_tick_${key}`];
27974
+ return isSubAxis(id) && subValue !== void 0 ? subValue : config[`axis_${type}_tick_${key}`];
27975
+ }
26701
27976
  function _sampleTickNodes(nodes) {
26702
27977
  var _a, _b;
26703
27978
  const sampled = [nodes[0], nodes[nodes.length - 1]];
@@ -26901,6 +28176,8 @@ class Axis_Axis {
26901
28176
  Axis_publicField(this, "owner");
26902
28177
  Axis_publicField(this, "x");
26903
28178
  Axis_publicField(this, "subX");
28179
+ Axis_publicField(this, "subY");
28180
+ Axis_publicField(this, "subY2");
26904
28181
  Axis_publicField(this, "y");
26905
28182
  Axis_publicField(this, "y2");
26906
28183
  Axis_publicField(this, "axesList", {});
@@ -26914,7 +28191,9 @@ class Axis_Axis {
26914
28191
  x: "bottom",
26915
28192
  y: "left",
26916
28193
  y2: "right",
26917
- subX: "bottom"
28194
+ subX: "bottom",
28195
+ subY: "left",
28196
+ subY2: "right"
26918
28197
  });
26919
28198
  this.owner = owner;
26920
28199
  this.setOrient();
@@ -27005,7 +28284,9 @@ class Axis_Axis {
27005
28284
  x: isRotated ? "left" : "bottom",
27006
28285
  y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
27007
28286
  y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
27008
- subX: isRotated ? "left" : "bottom"
28287
+ subX: isRotated ? "left" : "bottom",
28288
+ subY: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
28289
+ subY2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right"
27009
28290
  };
27010
28291
  }
27011
28292
  /**
@@ -27020,24 +28301,32 @@ class Axis_Axis {
27020
28301
  const axes = [];
27021
28302
  const axesConfig = config[`axis_${id}_axes`];
27022
28303
  const isRotated = config.axis_rotated;
27023
- let d3Axis;
28304
+ let orient;
27024
28305
  if (id === "x") {
27025
- d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom;
28306
+ orient = isRotated ? "left" : "bottom";
27026
28307
  } else if (id === "y") {
27027
- d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisBottom : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisLeft;
28308
+ orient = isRotated ? "bottom" : "left";
27028
28309
  } else if (id === "y2") {
27029
- d3Axis = isRotated ? external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisTop : external_commonjs_d3_axis_commonjs2_d3_axis_amd_d3_axis_root_d3_.axisRight;
28310
+ orient = isRotated ? "top" : "right";
27030
28311
  }
27031
28312
  if (axesConfig.length) {
27032
28313
  axesConfig.forEach((v) => {
27033
28314
  const tick = v.tick || {};
27034
28315
  const scale = $$.scale[id].copy();
27035
28316
  v.domain && scale.domain(v.domain);
27036
- axes.push(
27037
- d3Axis(scale).ticks(tick.count).tickFormat(
27038
- isFunction(tick.format) ? tick.format.bind($$.api) : ((x) => x)
27039
- ).tickValues(tick.values).tickSizeOuter(tick.outer === false ? 0 : AXIS_TICK_SIZE)
28317
+ const axis = new AxisRenderer({
28318
+ outerTick: tick.outer !== false,
28319
+ noTransition: false,
28320
+ config,
28321
+ id,
28322
+ isSubAxes: true,
28323
+ owner: $$
28324
+ }).scale(scale).orient(orient).tickFormat(
28325
+ isFunction(tick.format) ? tick.format.bind($$.api) : ((x) => x)
27040
28326
  );
28327
+ isValue(tick.count) && axis.ticks(tick.count);
28328
+ tick.values && axis.tickValues(tick.values);
28329
+ axes.push(axis);
27041
28330
  });
27042
28331
  }
27043
28332
  this.axesList[id] = axes;
@@ -27061,10 +28350,11 @@ class Axis_Axis {
27061
28350
  const className = `${this.getAxisClassName(id)}-${i + 1}`;
27062
28351
  let g = main.select(`.${className.replace(/\s/, ".")}`);
27063
28352
  if (g.empty()) {
27064
- g = main.append("g").attr("class", className).style("visibility", config[`axis_${id}_show`] ? null : "hidden").call(v);
28353
+ g = main.append("g").attr("class", className).style("visibility", config[`axis_${id}_show`] ? null : "hidden");
28354
+ v.create(g);
27065
28355
  } else {
27066
28356
  axesConfig[i].domain && scale.domain(axesConfig[i].domain);
27067
- $T(g).call(v.scale(scale));
28357
+ v.scale(scale).create($T(g));
27068
28358
  }
27069
28359
  g.attr("transform", $$.getTranslate(id, i + 1));
27070
28360
  });
@@ -27081,8 +28371,9 @@ class Axis_Axis {
27081
28371
  */
27082
28372
  setAxis(id, scale, outerTick, noTransition) {
27083
28373
  const $$ = this.owner;
27084
- if (id !== "subX") {
27085
- this.tick[id] = this.getTickValues(id);
28374
+ const type = Axis_getBaseAxisId(id);
28375
+ if (!isSubAxis(id)) {
28376
+ this.tick[type] = this.getTickValues(type);
27086
28377
  }
27087
28378
  this[id] = this.getAxis(
27088
28379
  id,
@@ -27098,7 +28389,7 @@ class Axis_Axis {
27098
28389
  const $$ = this.owner;
27099
28390
  const { config } = $$;
27100
28391
  const isX = /^(x|subX)$/.test(id);
27101
- const type = isX ? "x" : id;
28392
+ const type = Axis_getBaseAxisId(id);
27102
28393
  const isCategory = isX && this.isCategorized();
27103
28394
  const orient = this.orient[id];
27104
28395
  const tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type);
@@ -27106,12 +28397,12 @@ class Axis_Axis {
27106
28397
  if (isX) {
27107
28398
  tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
27108
28399
  } else {
27109
- const fn = config[`axis_${id}_tick_format`];
28400
+ const fn = isSubAxis(id) ? config[`subchart_axis_${type}_tick_format`] || config[`axis_${type}_tick_format`] : config[`axis_${type}_tick_format`];
27110
28401
  if (isFunction(fn)) {
27111
28402
  tickFormat = fn.bind($$.api);
27112
28403
  }
27113
28404
  }
27114
- let tickValues = this.tick[type];
28405
+ let tickValues = isSubAxis(id) ? this.getTickValues(type, true) : this.tick[type];
27115
28406
  const axisParams = mergeObj({
27116
28407
  outerTick,
27117
28408
  noTransition,
@@ -27140,7 +28431,7 @@ class Axis_Axis {
27140
28431
  }
27141
28432
  tickValues && axis.tickValues(tickValues);
27142
28433
  axis.tickFormat(
27143
- tickFormat || !isX && ($$.isStackNormalized() && $$.hasAxisGroupedData(id) && ((x) => `${x}%`))
28434
+ tickFormat || !isX && ($$.isStackNormalized() && $$.hasAxisGroupedData(type) && ((x) => `${x}%`))
27144
28435
  );
27145
28436
  if (isCategory) {
27146
28437
  axis.tickCentered(config.axis_x_tick_centered);
@@ -27148,7 +28439,7 @@ class Axis_Axis {
27148
28439
  config.axis_x_tick_culling = false;
27149
28440
  }
27150
28441
  }
27151
- const tickCount = config[`axis_${type}_tick_count`];
28442
+ const tickCount = Axis_getAxisTickOption(config, id, "count");
27152
28443
  tickCount && axis.ticks(tickCount);
27153
28444
  return axis;
27154
28445
  }
@@ -27157,24 +28448,31 @@ class Axis_Axis {
27157
28448
  const $$ = this.owner;
27158
28449
  const { config } = $$;
27159
28450
  const fit = config.axis_x_tick_fit;
27160
- let count = config.axis_x_tick_count;
27161
- let values;
27162
- if (fit) {
27163
- values = $$.mapTargetsToUniqueXs(targets);
27164
- if (this.isCategorized() && count > values.length) {
27165
- count = values.length;
27166
- }
27167
- values = this.generateTickValues(
27168
- values,
27169
- count,
27170
- this.isTimeSeries()
27171
- );
27172
- }
28451
+ const generateValues = (countOption = config.axis_x_tick_count) => {
28452
+ let count = countOption;
28453
+ let values2;
28454
+ if (fit) {
28455
+ values2 = $$.mapTargetsToUniqueXs(targets);
28456
+ if (this.isCategorized() && count > values2.length) {
28457
+ count = values2.length;
28458
+ }
28459
+ values2 = this.generateTickValues(
28460
+ values2,
28461
+ count,
28462
+ this.isTimeSeries()
28463
+ );
28464
+ }
28465
+ return values2;
28466
+ };
28467
+ const values = generateValues();
27173
28468
  if (axis) {
27174
28469
  axis.tickValues(values);
27175
28470
  } else if (this.x) {
28471
+ const subTickValues = this.getTickValues("x", true);
28472
+ const subTickCount = Axis_getAxisTickOption(config, "subX", "count");
28473
+ const subValues = subTickValues != null ? subTickValues : subTickCount !== config.axis_x_tick_count ? generateValues(subTickCount) : values;
27176
28474
  this.x.tickValues(values);
27177
- (_a = this.subX) == null ? void 0 : _a.tickValues(values);
28475
+ (_a = this.subX) == null ? void 0 : _a.tickValues(subValues);
27178
28476
  }
27179
28477
  return values;
27180
28478
  }
@@ -27204,11 +28502,12 @@ class Axis_Axis {
27204
28502
  }
27205
28503
  return isFunction(currFormat) ? (v) => currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]) : currFormat;
27206
28504
  }
27207
- getTickValues(id) {
28505
+ getTickValues(id, isSub = false) {
27208
28506
  const $$ = this.owner;
27209
- const tickValues = $$.config[`axis_${id}_tick_values`];
28507
+ const tickValues = isSub ? Axis_getAxisTickOption($$.config, `sub${capitalize(id)}`, "values") : $$.config[`axis_${id}_tick_values`];
28508
+ const values = isFunction(tickValues) ? tickValues.call($$.api) : tickValues;
27210
28509
  const axis = $$[`${id}Axis`];
27211
- return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : void 0);
28510
+ return isSub ? values != null ? values : void 0 : values || (axis ? axis.tickValues() : void 0);
27212
28511
  }
27213
28512
  getLabelOptionByAxisId(id) {
27214
28513
  return this.owner.config[`axis_${id}_label`];
@@ -27643,14 +28942,21 @@ class Axis_Axis {
27643
28942
  generateTransitions(withTransition) {
27644
28943
  const $$ = this.owner;
27645
28944
  const { $el: { axis }, $T } = $$;
27646
- const [axisX, axisY, axisY2, axisSubX] = ["x", "y", "y2", "subX"].map((v) => $T(axis[v], withTransition));
27647
- return { axisX, axisY, axisY2, axisSubX };
28945
+ const [axisX, axisY, axisY2, axisSubX, axisSubY, axisSubY2] = [
28946
+ "x",
28947
+ "y",
28948
+ "y2",
28949
+ "subX",
28950
+ "subY",
28951
+ "subY2"
28952
+ ].map((v) => $T(axis[v], withTransition));
28953
+ return { axisX, axisY, axisY2, axisSubX, axisSubY, axisSubY2 };
27648
28954
  }
27649
28955
  redraw(transitions, isHidden, isInit) {
27650
28956
  const $$ = this.owner;
27651
28957
  const { config, state, $el } = $$;
27652
28958
  const opacity = isHidden ? "0" : null;
27653
- ["x", "y", "y2", "subX"].forEach((id) => {
28959
+ ["x", "y", "y2", "subX", "subY", "subY2"].forEach((id) => {
27654
28960
  const axis = this[id];
27655
28961
  const $axis = $el.axis[id];
27656
28962
  if (axis && $axis) {
@@ -27672,7 +28978,7 @@ class Axis_Axis {
27672
28978
  * @private
27673
28979
  */
27674
28980
  syncAxisDomains(targetsToShow, wth, flow) {
27675
- var _a, _b, _c;
28981
+ var _a;
27676
28982
  const $$ = this.owner;
27677
28983
  const { config, scale, $el } = $$;
27678
28984
  const hasZoom = !!scale.zoom;
@@ -27718,8 +29024,30 @@ class Axis_Axis {
27718
29024
  }
27719
29025
  });
27720
29026
  if (wth.Y) {
27721
- (_b = scale.subY) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y"));
27722
- (_c = scale.subY2) == null ? void 0 : _c.domain($$.getYDomain(targetsToShow, "y2"));
29027
+ const updateSubDomain = () => {
29028
+ var _a2, _b;
29029
+ (_a2 = scale.subY) == null ? void 0 : _a2.domain($$.getYDomain(targetsToShow, "y"));
29030
+ (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
29031
+ ["y", "y2"].forEach((key) => {
29032
+ const subAxisId = key === "y2" ? "subY2" : "subY";
29033
+ const axisScale = scale[subAxisId];
29034
+ const axis = $$.axis[subAxisId];
29035
+ const tickValues = this.getTickValues(key, true);
29036
+ const tickCount = Axis_getAxisTickOption(config, subAxisId, "count");
29037
+ if (!axisScale || !axis || tickValues || !tickCount) {
29038
+ return;
29039
+ }
29040
+ const domain = axisScale.domain();
29041
+ axis.tickValues(
29042
+ this.generateTickValues(
29043
+ domain,
29044
+ domain.every((v) => v === 0) ? 1 : tickCount,
29045
+ this.isTimeSeriesY()
29046
+ )
29047
+ );
29048
+ });
29049
+ };
29050
+ config.subchart_show ? $$.withSubchartTypeContext(updateSubDomain) : updateSubDomain();
27723
29051
  }
27724
29052
  }
27725
29053
  /**
@@ -27747,20 +29075,18 @@ class Axis_Axis {
27747
29075
  setCulling() {
27748
29076
  const $$ = this.owner;
27749
29077
  const { config, state: { clip, current }, $el } = $$;
27750
- ["subX", "x", "y", "y2"].forEach((type) => {
29078
+ ["subX", "x", "y", "y2", "subY", "subY2"].forEach((type) => {
27751
29079
  const axis = $el.axis[type];
27752
- const id = type === "subX" ? "x" : type;
27753
- const cullingOptionPrefix = `axis_${id}_tick_culling`;
27754
- const toCull = config[cullingOptionPrefix];
29080
+ const toCull = Axis_getAxisTickOption(config, type, "culling");
27755
29081
  if (axis && toCull) {
27756
29082
  const tickNodes = axis.selectAll(".tick");
27757
29083
  const tickValues = sortValue(
27758
29084
  tickNodes.data(),
27759
- !config[`${cullingOptionPrefix}_reverse`]
29085
+ !Axis_getAxisTickOption(config, type, "culling_reverse")
27760
29086
  );
27761
29087
  const tickSize = tickValues.length;
27762
- const cullingMax = config[`${cullingOptionPrefix}_max`];
27763
- const lines = config[`${cullingOptionPrefix}_lines`];
29088
+ const cullingMax = Axis_getAxisTickOption(config, type, "culling_max");
29089
+ const lines = Axis_getAxisTickOption(config, type, "culling_lines");
27764
29090
  const cullTickLine = !lines || _hasOverlappedTickLineIntervals(
27765
29091
  this[type],
27766
29092
  tickValues,
@@ -28080,7 +29406,7 @@ var __pow = Math.pow;
28080
29406
  * @private
28081
29407
  */
28082
29408
  selectRectForSingle(context, index) {
28083
- var _a, _b, _c, _d;
29409
+ var _a, _b, _c, _d, _e, _f, _g;
28084
29410
  const $$ = this;
28085
29411
  const { config, state, $el: { main, circle } } = $$;
28086
29412
  const isSelectionEnabled = config.data_selection_enabled;
@@ -28091,6 +29417,7 @@ var __pow = Math.pow;
28091
29417
  if (isTooltipGrouped) {
28092
29418
  $$.showTooltip(selectedData, context);
28093
29419
  (_a = $$.showGridFocus) == null ? void 0 : _a.call($$, selectedData);
29420
+ (_b = $$.showSubchartGridFocus) == null ? void 0 : _b.call($$, selectedData);
28094
29421
  if (!isSelectionEnabled || isSelectionGrouped) {
28095
29422
  return;
28096
29423
  }
@@ -28103,7 +29430,7 @@ var __pow = Math.pow;
28103
29430
  return $$.isWithinShape(this, d);
28104
29431
  });
28105
29432
  shapeAtIndex.call((selected) => {
28106
- var _a2, _b2;
29433
+ var _a2, _b2, _c2;
28107
29434
  const d = selected.data();
28108
29435
  if (isSelectionEnabled && (isSelectionGrouped || (isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)))) {
28109
29436
  context.style.cursor = "pointer";
@@ -28111,7 +29438,8 @@ var __pow = Math.pow;
28111
29438
  if (!isTooltipGrouped) {
28112
29439
  $$.showTooltip(d, context);
28113
29440
  (_a2 = $$.showGridFocus) == null ? void 0 : _a2.call($$, d);
28114
- (_b2 = $$.unexpandCircles) == null ? void 0 : _b2.call($$);
29441
+ (_b2 = $$.showSubchartGridFocus) == null ? void 0 : _b2.call($$, d);
29442
+ (_c2 = $$.unexpandCircles) == null ? void 0 : _c2.call($$);
28115
29443
  selected.each((d2) => $$.setExpand(index, d2.id));
28116
29444
  }
28117
29445
  });
@@ -28136,14 +29464,16 @@ var __pow = Math.pow;
28136
29464
  }
28137
29465
  }
28138
29466
  $$.showTooltip([closest], context);
28139
- (_b = $$.showGridFocus) == null ? void 0 : _b.call($$, [closest]);
28140
- (_c = $$.unexpandCircles) == null ? void 0 : _c.call($$);
29467
+ (_c = $$.showGridFocus) == null ? void 0 : _c.call($$, [closest]);
29468
+ (_d = $$.showSubchartGridFocus) == null ? void 0 : _d.call($$, [closest]);
29469
+ (_e = $$.unexpandCircles) == null ? void 0 : _e.call($$);
28141
29470
  $$.setExpand(index, closest.id, true);
28142
29471
  if (isSelectionEnabled && (isSelectionGrouped || (isSelectable == null ? void 0 : isSelectable.bind($$.api)(closest)))) {
28143
29472
  context.style.cursor = "pointer";
28144
29473
  }
28145
29474
  } else if (config.interaction_onout) {
28146
- (_d = $$.hideGridFocus) == null ? void 0 : _d.call($$);
29475
+ (_f = $$.hideGridFocus) == null ? void 0 : _f.call($$);
29476
+ (_g = $$.hideSubchartGridFocus) == null ? void 0 : _g.call($$);
28147
29477
  $$.hideTooltip();
28148
29478
  !isSelectionGrouped && $$.setExpand(index);
28149
29479
  }
@@ -28156,7 +29486,7 @@ var __pow = Math.pow;
28156
29486
  * @private
28157
29487
  */
28158
29488
  selectRectForMultipleXs(context, triggerEvent = true) {
28159
- var _a;
29489
+ var _a, _b;
28160
29490
  const $$ = this;
28161
29491
  const { config, state } = $$;
28162
29492
  const targetsToShow = $$.getTargetsToShow();
@@ -28178,6 +29508,7 @@ var __pow = Math.pow;
28178
29508
  $$.showTooltip(selectedData, context);
28179
29509
  $$.setExpand(closest.index, closest.id, true);
28180
29510
  (_a = $$.showGridFocus) == null ? void 0 : _a.call($$, selectedData);
29511
+ (_b = $$.showSubchartGridFocus) == null ? void 0 : _b.call($$, selectedData);
28181
29512
  const dist = $$.dist(closest, mouse);
28182
29513
  if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
28183
29514
  $$.$el.eventRect.style("cursor", "pointer");
@@ -28192,7 +29523,7 @@ var __pow = Math.pow;
28192
29523
  * @private
28193
29524
  */
28194
29525
  unselectRect() {
28195
- var _a, _b, _c;
29526
+ var _a, _b, _c, _d;
28196
29527
  const $$ = this;
28197
29528
  const { state, $el: { circle, tooltip } } = $$;
28198
29529
  state._lastTooltipMouse = null;
@@ -28203,6 +29534,7 @@ var __pow = Math.pow;
28203
29534
  }
28204
29535
  (_b = $$.$el.eventRect) == null ? void 0 : _b.style("cursor", null);
28205
29536
  (_c = $$.hideGridFocus) == null ? void 0 : _c.call($$);
29537
+ (_d = $$.hideSubchartGridFocus) == null ? void 0 : _d.call($$);
28206
29538
  if (tooltip) {
28207
29539
  $$.hideTooltip();
28208
29540
  $$._handleLinkedCharts(false);
@@ -29835,6 +31167,18 @@ var __pow = Math.pow;
29835
31167
 
29836
31168
  ;// ./src/config/Options/axis/y2.ts
29837
31169
  /* harmony default export */ var y2 = ({
31170
+ /**
31171
+ * Set clip-path attribute for y2 axis element
31172
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
31173
+ * @name axis․y2․clipPath
31174
+ * @memberof Options
31175
+ * @type {boolean}
31176
+ * @default true
31177
+ * @example
31178
+ * // don't set 'clip-path' attribute
31179
+ * clipPath: false
31180
+ */
31181
+ axis_y2_clipPath: true,
29838
31182
  /**
29839
31183
  * Show or hide y2 axis.
29840
31184
  * - **NOTE**:
@@ -30726,9 +32070,20 @@ function _getConnectLineType(id) {
30726
32070
  config.bar_linearGradient && $$.updateLinearGradient();
30727
32071
  const bar = $root.main.selectAll(`.${$BAR.bars}`).selectAll(`.${$BAR.bar}`).data($$.labelishData.bind($$));
30728
32072
  $T(bar.exit(), withTransition).style("opacity", "0").remove();
30729
- $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.updateBarColor.bind($$)).merge(bar).style("opacity", initialOpacity);
32073
+ $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.generateUpdateBarColor()).merge(bar).style("opacity", initialOpacity);
30730
32074
  $$.setRatioForGroupedData($root.bar.data());
30731
32075
  },
32076
+ /**
32077
+ * Generate bar color accessor, hoisting the bound color function
32078
+ * to be created once per call (not per datum)
32079
+ * @returns {function} Color accessor
32080
+ * @private
32081
+ */
32082
+ generateUpdateBarColor() {
32083
+ const $$ = this;
32084
+ const fn = $$.getStylePropValue($$.color) || (() => null);
32085
+ return (d) => getShapeColorWithGradient.call($$, d, "bar_linearGradient", fn);
32086
+ },
30732
32087
  /**
30733
32088
  * Update bar color
30734
32089
  * @param {object} d Data object
@@ -30736,9 +32091,7 @@ function _getConnectLineType(id) {
30736
32091
  * @private
30737
32092
  */
30738
32093
  updateBarColor(d) {
30739
- const $$ = this;
30740
- const fn = $$.getStylePropValue($$.color);
30741
- return getShapeColorWithGradient.call($$, d, "bar_linearGradient", fn || (() => null));
32094
+ return this.generateUpdateBarColor()(d);
30742
32095
  },
30743
32096
  /**
30744
32097
  * Redraw function
@@ -30756,28 +32109,51 @@ function _getConnectLineType(id) {
30756
32109
  const { bar } = isSub ? $$.$el.subchart : $$.$el;
30757
32110
  const barPath = [];
30758
32111
  const connectLineCache = /* @__PURE__ */ new Map();
30759
- return [
30760
- $$.$T(bar, withTransition, getRandom()).attr("d", function(d, i, arr) {
30761
- const path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
30762
- let connectLineType = connectLineCache.get(d.id);
30763
- if (connectLineType === void 0) {
30764
- connectLineType = _getConnectLineType.call($$, d.id);
30765
- connectLineCache.set(d.id, connectLineType);
30766
- }
30767
- if (path.length > 1) {
30768
- barPath.push(path[1]);
30769
- }
30770
- if (i === arr.length - 1 && barPath.length) {
30771
- const barConnectLineNode = $$.$T(
30772
- (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode.querySelector(`.${$BAR.barConnectLine}`)),
30773
- withTransition,
30774
- getRandom()
30775
- );
30776
- $$.updateConnectLine(barConnectLineNode, connectLineType, barPath);
30777
- barPath.splice(0);
32112
+ const getRadius = getBarRadiusResolver($$);
32113
+ const barColor = $$.generateUpdateBarColor();
32114
+ const getBarPath = function(d, i, arr) {
32115
+ var _a;
32116
+ const isDrawable = isNumber(d.value) || $$.isBarRangeType(d) || ((_a = $$.isSubchartCandlestickBarValue) == null ? void 0 : _a.call($$, d, isSub));
32117
+ const path = isDrawable ? drawFn(d, i) : [""];
32118
+ let connectLineType = connectLineCache.get(d.id);
32119
+ if (connectLineType === void 0) {
32120
+ connectLineType = _getConnectLineType.call($$, d.id);
32121
+ connectLineCache.set(d.id, connectLineType);
32122
+ }
32123
+ if (path.length > 1) {
32124
+ barPath.push(path[1]);
32125
+ }
32126
+ if (i === arr.length - 1 && barPath.length) {
32127
+ const barConnectLineNode = $$.$T(
32128
+ (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(
32129
+ this.parentNode.querySelector(`.${$BAR.barConnectLine}`)
32130
+ ),
32131
+ withTransition,
32132
+ getRandom()
32133
+ );
32134
+ $$.updateConnectLine(barConnectLineNode, connectLineType, barPath);
32135
+ barPath.splice(0);
32136
+ }
32137
+ return path[0];
32138
+ };
32139
+ const barTransition = $$.$T(bar, withTransition, getRandom());
32140
+ if (getRadius && typeof barTransition.attrTween === "function") {
32141
+ barTransition.attrTween(
32142
+ "d",
32143
+ function(d, i, arr) {
32144
+ var _a;
32145
+ const target = getBarPath.call(this, d, i, arr);
32146
+ return getBarPathInterpolator((_a = this.getAttribute("d")) != null ? _a : "", target);
30778
32147
  }
30779
- return path[0];
30780
- }).style("fill", $$.updateBarColor.bind($$)).style("clip-path", (d) => d.clipPath).style("opacity", null)
32148
+ );
32149
+ } else {
32150
+ barTransition.attr("d", getBarPath);
32151
+ }
32152
+ return [
32153
+ barTransition.style("fill", (d) => {
32154
+ var _a;
32155
+ return ((_a = $$.getSubchartCandlestickBarColor) == null ? void 0 : _a.call($$, d, isSub)) || barColor(d);
32156
+ }).style("clip-path", (d) => d.clipPath).style("opacity", null)
30781
32157
  ];
30782
32158
  },
30783
32159
  /**
@@ -30806,6 +32182,7 @@ function _getConnectLineType(id) {
30806
32182
  const getPoints = $$.generateGetBarPoints(barIndices, isSub);
30807
32183
  const getRadius = getBarRadiusResolver($$);
30808
32184
  const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : /* @__PURE__ */ new Set();
32185
+ const connectLineCache = /* @__PURE__ */ new Map();
30809
32186
  return (d, i) => {
30810
32187
  const points = getPoints(d, i);
30811
32188
  const {
@@ -30833,7 +32210,12 @@ function _getConnectLineType(id) {
30833
32210
  }
30834
32211
  const path = config.axis_rotated ? `H${pos} ${pathRadius[0]}V${points[2][indexY] - radius} ${pathRadius[1]}H${points[3][indexX]}` : `V${pos} ${pathRadius[0]}H${points[2][indexX] - radius} ${pathRadius[1]}V${points[3][indexY]}`;
30835
32212
  const coords = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
30836
- if (_getConnectLineType.call($$, d.id)) {
32213
+ let connectLineType = connectLineCache.get(d.id);
32214
+ if (connectLineType === void 0) {
32215
+ connectLineType = _getConnectLineType.call($$, d.id);
32216
+ connectLineCache.set(d.id, connectLineType);
32217
+ }
32218
+ if (connectLineType) {
30837
32219
  coords.push(config.axis_rotated ? {
30838
32220
  x: points[0][indexX],
30839
32221
  y: points[0][indexY],
@@ -31205,7 +32587,7 @@ var candlestick_spreadValues = (a, b) => {
31205
32587
  const shapeOffset = $$.getShapeOffset($$.isCandlestickType, indices, !!isSub);
31206
32588
  const yScale = $$.getYScaleById.bind($$);
31207
32589
  return (d, i) => {
31208
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
32590
+ const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id, isSub));
31209
32591
  const offset = shapeOffset(d, i) || y0;
31210
32592
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
31211
32593
  const value = $$.getCandlestickData(d);
@@ -31786,7 +33168,7 @@ let candlestick_candlestick = () => (extendAxis(
31786
33168
  });
31787
33169
 
31788
33170
  // EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
31789
- var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(11);
33171
+ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(10);
31790
33172
  ;// ./src/ChartInternal/internals/text.arc.ts
31791
33173
 
31792
33174
 
@@ -32894,7 +34276,6 @@ var funnel_spreadValues = (a, b) => {
32894
34276
 
32895
34277
 
32896
34278
 
32897
-
32898
34279
  function _getSize(checkNeck = false) {
32899
34280
  const $$ = this;
32900
34281
  const { config, state: { current: { width, height } } } = $$;
@@ -33127,7 +34508,7 @@ function _getSplineClipPath() {
33127
34508
  },
33128
34509
  /**
33129
34510
  * Generate funnel coordinate points data for text labels
33130
- * @returns {(d: IDataRow) => [number, number][]} Point getter function
34511
+ * @returns {function(IDataRow): Array.<Array.<number>>} Point getter function
33131
34512
  * @private
33132
34513
  */
33133
34514
  generateGetFunnelPoints() {
@@ -33343,7 +34724,7 @@ let funnel_funnel = () => (extendArc([funnel], [shape_funnel]), (funnel_funnel =
33343
34724
  * @property {number} [gauge.expand.rate=0.98] Set expand rate.
33344
34725
  * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
33345
34726
  * @property {boolean} [gauge.enforceMinMax=false] Enforce to given min/max value.
33346
- * - **Note:** Only works for single data series.
34727
+ * - **Note:** Applies only to unstacked/multi-arc gauges; stacked gauge data is not supported.
33347
34728
  * - When `gauge.min=50` and given value is `30`, gauge will render as empty value.
33348
34729
  * - When `gauge.max=100` and given value is `120`, gauge will render till 100, not surpassing max value.
33349
34730
  * @property {number} [gauge.min=0] Set min value of the gauge.
@@ -34373,7 +35754,7 @@ let scatter_scatter = () => (extendAxis(
34373
35754
  ), (scatter_scatter = () => TYPE.SCATTER)());
34374
35755
 
34375
35756
  // EXTERNAL MODULE: external {"commonjs":"d3-hierarchy","commonjs2":"d3-hierarchy","amd":"d3-hierarchy","root":"d3"}
34376
- var external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_ = __webpack_require__(12);
35757
+ var external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_d3_ = __webpack_require__(11);
34377
35758
  ;// ./src/ChartInternal/shape/core/treemap.ts
34378
35759
 
34379
35760
  function convertDataToTreemapData(data) {
@@ -34647,7 +36028,7 @@ ${percentValue}%`;
34647
36028
  * - dice ([d3.treemapDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapDice))
34648
36029
  * - slice ([d3.treemapSlice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSlice))
34649
36030
  * - sliceDice ([d3.treemapSliceDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSliceDice))
34650
- * - squrify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
36031
+ * - squarify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
34651
36032
  * - resquarify ([d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapResquarify))
34652
36033
  * @property {function} [treemap.label.format] Set formatter for the label text.<br>
34653
36034
  * - **Arguments:**
@@ -34660,7 +36041,7 @@ ${percentValue}%`;
34660
36041
  * @see [Demo: treemap](https://naver.github.io/billboard.js/demo/#Chart.TreemapChart)
34661
36042
  * @example
34662
36043
  * treemap: {
34663
- * // "binary", "dice", "slice", "sliceDice", "squrify", "resquarify"
36044
+ * // "binary", "dice", "slice", "sliceDice", "squarify", "resquarify"
34664
36045
  * tile: "dice",
34665
36046
  *
34666
36047
  * label: {
@@ -34741,7 +36122,7 @@ const bb = {
34741
36122
  * bb.version; // "1.0.0"
34742
36123
  * @memberof bb
34743
36124
  */
34744
- version: "4.0.2",
36125
+ version: "4.1.0-next.1",
34745
36126
  /**
34746
36127
  * Generate chart
34747
36128
  * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when: