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
@@ -5,7 +5,7 @@
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
  * All-in-one packaged file for ease use of 'billboard.js' with dependant d3.js modules & polyfills.
11
11
  * - @types/d3-selection ^3.0.11
@@ -27088,7 +27088,7 @@ function getScale(type = "linear", min, max) {
27088
27088
  * @private
27089
27089
  */
27090
27090
  updateScales(isInit, updateXDomain = true) {
27091
- var _a, _b, _c, _d, _e, _f;
27091
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
27092
27092
  const $$ = this;
27093
27093
  const {
27094
27094
  axis,
@@ -27124,7 +27124,12 @@ function getScale(type = "linear", min, max) {
27124
27124
  format.subXAxisTick = axis.getXAxisTickFormat(true);
27125
27125
  axis.setAxis("x", scale.x, config.axis_x_tick_outer, isInit);
27126
27126
  if (config.subchart_show) {
27127
- axis.setAxis("subX", scale.subX, config.axis_x_tick_outer, isInit);
27127
+ axis.setAxis(
27128
+ "subX",
27129
+ scale.subX,
27130
+ (_f = config.subchart_axis_x_tick_outer) != null ? _f : config.axis_x_tick_outer,
27131
+ isInit
27132
+ );
27128
27133
  }
27129
27134
  scale.y = $$.getYScale(
27130
27135
  "y",
@@ -27141,7 +27146,13 @@ function getScale(type = "linear", min, max) {
27141
27146
  scale.subY
27142
27147
  );
27143
27148
  axis.setAxis("y", scale.y, config.axis_y_tick_outer, isInit);
27144
- if (config.axis_y2_show) {
27149
+ config.subchart_show && config.subchart_axis_y_show && axis.setAxis(
27150
+ "subY",
27151
+ scale.subY,
27152
+ (_g = config.subchart_axis_y_tick_outer) != null ? _g : config.axis_y_tick_outer,
27153
+ isInit
27154
+ );
27155
+ if (config.axis_y2_show || config.subchart_axis_y2_show) {
27145
27156
  scale.y2 = $$.getYScale(
27146
27157
  "y2",
27147
27158
  min.y,
@@ -27157,13 +27168,19 @@ function getScale(type = "linear", min, max) {
27157
27168
  scale.subY2
27158
27169
  );
27159
27170
  axis.setAxis("y2", scale.y2, config.axis_y2_tick_outer, isInit);
27171
+ config.subchart_show && config.subchart_axis_y2_show && axis.setAxis(
27172
+ "subY2",
27173
+ scale.subY2,
27174
+ (_h = config.subchart_axis_y2_tick_outer) != null ? _h : config.axis_y2_tick_outer,
27175
+ isInit
27176
+ );
27160
27177
  }
27161
27178
  } else if (hasTreemap) {
27162
27179
  const padding = $$.getCurrentPadding();
27163
27180
  scale.x = linear_linear().rangeRound([padding.left, current.width - padding.right]);
27164
27181
  scale.y = linear_linear().rangeRound([padding.top, current.height - padding.bottom]);
27165
27182
  } else {
27166
- (_f = $$.updateArc) == null ? void 0 : _f.call($$);
27183
+ (_i = $$.updateArc) == null ? void 0 : _i.call($$);
27167
27184
  }
27168
27185
  },
27169
27186
  /**
@@ -27372,6 +27389,10 @@ function markCanvasPointOccupancy(grid, x, y) {
27372
27389
 
27373
27390
 
27374
27391
 
27392
+ function getAxisTickOption(config, id, key, prefix = `axis_${id}`) {
27393
+ const value = config[`${prefix}_tick_${key}`];
27394
+ return value !== void 0 ? value : config[`axis_${id}_tick_${key}`];
27395
+ }
27375
27396
  function getOptionTickValues(values, api) {
27376
27397
  const resolved = typeof values === "function" ? values.call(api) : values;
27377
27398
  return (resolved == null ? void 0 : resolved.length) ? resolved : void 0;
@@ -27664,52 +27685,59 @@ function getXTickValues($$, cull = true) {
27664
27685
  function getSubXTickCullMax($$) {
27665
27686
  const { config, state: { height2, width2 } } = $$;
27666
27687
  const size = config.axis_rotated ? height2 : width2;
27667
- if (config.axis_x_tick_count) {
27668
- return config.axis_x_tick_count;
27688
+ const count = getAxisTickOption(config, "x", "count", "subchart_axis_x");
27689
+ const culling = getAxisTickOption(config, "x", "culling", "subchart_axis_x");
27690
+ const cullingMax = getAxisTickOption(config, "x", "culling_max", "subchart_axis_x");
27691
+ if (count) {
27692
+ return count;
27669
27693
  }
27670
- if (config.axis_x_tick_culling !== false) {
27694
+ if (culling !== false) {
27671
27695
  return Math.min(
27672
- config.axis_x_tick_culling_max || AXIS_DEFAULT_TICK_COUNT,
27696
+ cullingMax || AXIS_DEFAULT_TICK_COUNT,
27673
27697
  Math.max(2, Math.floor(size / 70))
27674
27698
  );
27675
27699
  }
27676
27700
  return void 0;
27677
27701
  }
27678
- function getSubXTickValues($$) {
27702
+ function getSubXTickValues($$, culling = true) {
27679
27703
  var _a, _b, _c, _d;
27680
27704
  const { axis, config, scale } = $$;
27681
27705
  const targetScale = scale.subX;
27682
27706
  const targetsToShow = ((_a = $$.getTargetsToShow) == null ? void 0 : _a.call($$)) || $$.filterTargetsToShow();
27707
+ const tickCount = getAxisTickOption(config, "x", "count", "subchart_axis_x");
27683
27708
  const cullMax = getSubXTickCullMax($$);
27684
- const cull = (ticks) => cullTicks(ticks, cullMax);
27709
+ const cullData = (ticks, sorted = false) => culling ? cullDataTicks($$, ticks, sorted, "subchart_axis_x", cullMax) : ticks;
27685
27710
  if (!targetScale || !(targetsToShow == null ? void 0 : targetsToShow.length)) {
27686
27711
  return [];
27687
27712
  }
27688
- const explicit = getOptionTickValues(config.axis_x_tick_values, $$.api);
27713
+ const explicit = getOptionTickValues(
27714
+ getAxisTickOption(config, "x", "values", "subchart_axis_x"),
27715
+ $$.api
27716
+ );
27689
27717
  if (explicit) {
27690
- return cull(normalizeXTickValues($$, explicit));
27718
+ return cullData(normalizeXTickValues($$, explicit));
27691
27719
  }
27692
27720
  if (config.axis_x_tick_fit && $$.mapTargetsToUniqueXs) {
27693
27721
  const generated2 = generateTickValues(
27694
27722
  $$,
27695
27723
  $$.mapTargetsToUniqueXs(targetsToShow),
27696
- config.axis_x_tick_count,
27724
+ tickCount,
27697
27725
  (_b = axis == null ? void 0 : axis.isTimeSeries) == null ? void 0 : _b.call(axis)
27698
27726
  );
27699
- return cull(generated2);
27727
+ return cullData(generated2, true);
27700
27728
  }
27701
27729
  if (((_c = axis == null ? void 0 : axis.isCategorized) == null ? void 0 : _c.call(axis)) && ((_d = config.axis_x_categories) == null ? void 0 : _d.length)) {
27702
- return cull(config.axis_x_categories.map((_, i) => i));
27730
+ return cullData(config.axis_x_categories.map((_, i) => i), true);
27703
27731
  }
27704
27732
  const generated = getScaleTicks(
27705
27733
  targetScale,
27706
- config.axis_x_tick_count || AXIS_DEFAULT_TICK_COUNT
27734
+ tickCount || AXIS_DEFAULT_TICK_COUNT
27707
27735
  );
27708
- return cull(generated);
27736
+ return cullData(generated, true);
27709
27737
  }
27710
- function getCategoryXTickLineValues($$) {
27738
+ function getCategoryXTickLineValues($$, targetScale = getXScale($$), outerTick = $$.config.axis_x_tick_outer) {
27711
27739
  var _a, _b;
27712
- const scale = getXScale($$);
27740
+ const scale = targetScale;
27713
27741
  const domain = ((_a = scale.orgDomain) == null ? void 0 : _a.call(scale)) || ((_b = scale.domain) == null ? void 0 : _b.call(scale));
27714
27742
  if (!(domain == null ? void 0 : domain.length)) {
27715
27743
  return [];
@@ -27722,7 +27750,7 @@ function getCategoryXTickLineValues($$) {
27722
27750
  const min = Math.ceil(Math.min(start, end));
27723
27751
  const max = Math.floor(Math.max(start, end));
27724
27752
  const values = Array.from({ length: Math.max(0, max - min + 1) }, (_, i) => min + i);
27725
- return $$.config.axis_x_tick_outer ? values.slice(1, -1) : values;
27753
+ return outerTick ? values.slice(1, -1) : values;
27726
27754
  }
27727
27755
  function getXTickLinePosition($$, value, targetScale = getXScale($$)) {
27728
27756
  var _a, _b, _c, _d, _e;
@@ -27738,12 +27766,12 @@ function getXTickLinePosition($$, value, targetScale = getXScale($$)) {
27738
27766
  }
27739
27767
  return scale(normalized);
27740
27768
  }
27741
- function hasOverlappedXTickLineIntervals($$, ticks, tickLineWidth) {
27769
+ function hasOverlappedXTickLineIntervals($$, ticks, tickLineWidth, targetScale = getXScale($$)) {
27742
27770
  if (ticks.length < 2) {
27743
27771
  return false;
27744
27772
  }
27745
27773
  const halfWidth = Math.max(1, tickLineWidth) / 2;
27746
- const positions = ticks.map((tick) => getXTickLinePosition($$, tick)).filter(Number.isFinite).sort((a, b) => a - b);
27774
+ const positions = ticks.map((tick) => getXTickLinePosition($$, tick, targetScale)).filter(Number.isFinite).sort((a, b) => a - b);
27747
27775
  if (positions.length < 2) {
27748
27776
  return false;
27749
27777
  }
@@ -27758,10 +27786,10 @@ function hasOverlappedXTickLineIntervals($$, ticks, tickLineWidth) {
27758
27786
  }
27759
27787
  return false;
27760
27788
  }
27761
- function dedupeXTickLineValues($$, ticks) {
27789
+ function dedupeXTickLineValues($$, ticks, targetScale = getXScale($$)) {
27762
27790
  const seen = /* @__PURE__ */ new Set();
27763
27791
  return ticks.filter((tick) => {
27764
- const pos = getXTickLinePosition($$, tick);
27792
+ const pos = getXTickLinePosition($$, tick, targetScale);
27765
27793
  const key = Math.round(pos);
27766
27794
  if (!Number.isFinite(pos) || seen.has(key)) {
27767
27795
  return false;
@@ -27783,13 +27811,35 @@ function getXTickLineValues($$, textTicks, tickLineWidth = 1) {
27783
27811
  const lineTicks = getXTickValues($$, false);
27784
27812
  return hasOverlappedXTickLineIntervals($$, lineTicks, tickLineWidth) ? textTicks : dedupeXTickLineValues($$, lineTicks);
27785
27813
  }
27786
- function getYTickValues($$, id = "y", count, culling = true) {
27787
- var _a, _b, _c;
27814
+ function getSubXTickLineValues($$, textTicks, tickLineWidth = 1) {
27815
+ var _a;
27788
27816
  const { axis, config, scale } = $$;
27817
+ const targetScale = scale.subX;
27818
+ const culling = getAxisTickOption(config, "x", "culling", "subchart_axis_x");
27819
+ const cullingLines = getAxisTickOption(config, "x", "culling_lines", "subchart_axis_x");
27820
+ const outerTick = getAxisTickOption(config, "x", "outer", "subchart_axis_x");
27821
+ if (!targetScale) {
27822
+ return [];
27823
+ }
27824
+ if ((_a = axis == null ? void 0 : axis.isCategorized) == null ? void 0 : _a.call(axis)) {
27825
+ const categoryLineTicks = getCategoryXTickLineValues($$, targetScale, outerTick);
27826
+ return dedupeXTickLineValues($$, categoryLineTicks, targetScale);
27827
+ }
27828
+ if (culling === false || cullingLines === false) {
27829
+ return textTicks;
27830
+ }
27831
+ const lineTicks = getSubXTickValues($$, false);
27832
+ return hasOverlappedXTickLineIntervals($$, lineTicks, tickLineWidth, targetScale) ? textTicks : dedupeXTickLineValues($$, lineTicks, targetScale);
27833
+ }
27834
+ function getYTickValues($$, id = "y", count, culling = true, targetScale = $$.scale[id], optionPrefix = `axis_${id}`) {
27835
+ var _a, _b, _c;
27836
+ const { axis, config } = $$;
27789
27837
  const prefix = `axis_${id}`;
27790
- const targetScale = scale[id];
27791
- const explicit = getOptionTickValues(config[`${prefix}_tick_values`], $$.api);
27792
- const maybeCull = (ticks) => culling ? cullAxisTicks($$, id, ticks) : ticks;
27838
+ const explicit = getOptionTickValues(
27839
+ getAxisTickOption(config, id, "values", optionPrefix),
27840
+ $$.api
27841
+ );
27842
+ const maybeCull = (ticks) => culling ? cullAxisTicks($$, id, ticks, optionPrefix) : ticks;
27793
27843
  if (explicit) {
27794
27844
  return maybeCull(normalizeYTickValues($$, explicit, id));
27795
27845
  }
@@ -27797,7 +27847,7 @@ function getYTickValues($$, id = "y", count, culling = true) {
27797
27847
  if (stepTicks.length) {
27798
27848
  return maybeCull(stepTicks);
27799
27849
  }
27800
- const tickCount = count != null ? count : config[`${prefix}_tick_count`];
27850
+ const tickCount = count != null ? count : getAxisTickOption(config, id, "count", optionPrefix);
27801
27851
  if (((_a = axis == null ? void 0 : axis.isTimeSeries) == null ? void 0 : _a.call(axis, id)) && config[`${prefix}_tick_time_value`]) {
27802
27852
  return maybeCull(getScaleTicks(targetScale, config[`${prefix}_tick_time_value`]));
27803
27853
  }
@@ -27851,20 +27901,21 @@ function cullTicks(ticks, count) {
27851
27901
  }
27852
27902
  return ticks;
27853
27903
  }
27854
- function cullAxisTicks($$, id, ticks) {
27904
+ function cullAxisTicks($$, id, ticks, optionPrefix = `axis_${id}`) {
27855
27905
  const { config } = $$;
27856
- const prefix = `axis_${id}_tick_culling`;
27857
- if (!config[prefix]) {
27906
+ const culling = getAxisTickOption(config, id, "culling", optionPrefix);
27907
+ if (!culling) {
27858
27908
  return ticks;
27859
27909
  }
27910
+ const cullingMax = getAxisTickOption(config, id, "culling_max", optionPrefix) || AXIS_DEFAULT_TICK_COUNT;
27911
+ const reverse = getAxisTickOption(config, id, "culling_reverse", optionPrefix);
27860
27912
  const sortedTicks = ticks.slice().sort((a, b) => {
27861
27913
  const av = +a;
27862
27914
  const bv = +b;
27863
27915
  const order = Number.isFinite(av) && Number.isFinite(bv) ? av - bv : String(a).localeCompare(String(b));
27864
- return config[`${prefix}_reverse`] ? -order : order;
27916
+ return reverse ? -order : order;
27865
27917
  });
27866
27918
  const tickSize = sortedTicks.length;
27867
- const cullingMax = config[`${prefix}_max`] || AXIS_DEFAULT_TICK_COUNT;
27868
27919
  let intervalForCulling = 0;
27869
27920
  for (let i = 1; i < tickSize; i++) {
27870
27921
  if (tickSize / i < cullingMax) {
@@ -27880,19 +27931,21 @@ function cullAxisTicks($$, id, ticks) {
27880
27931
  );
27881
27932
  return ticks.filter((tick) => visible.has(tick));
27882
27933
  }
27883
- function cullDataTicks($$, ticks, sorted = false) {
27934
+ function cullDataTicks($$, ticks, sorted = false, optionPrefix = "axis_x", max) {
27884
27935
  const { config } = $$;
27885
- if (config.axis_x_tick_culling === false) {
27936
+ const culling = getAxisTickOption(config, "x", "culling", optionPrefix);
27937
+ if (culling === false) {
27886
27938
  return ticks;
27887
27939
  }
27888
- const cullingMax = config.axis_x_tick_culling_max || AXIS_DEFAULT_TICK_COUNT;
27940
+ const cullingMax = max || getAxisTickOption(config, "x", "culling_max", optionPrefix) || AXIS_DEFAULT_TICK_COUNT;
27941
+ const reverse = getAxisTickOption(config, "x", "culling_reverse", optionPrefix);
27889
27942
  const sortedTicks = sorted ? ticks : ticks.slice().sort((a, b) => {
27890
27943
  const av = +a;
27891
27944
  const bv = +b;
27892
27945
  if (Number.isFinite(av) && Number.isFinite(bv)) {
27893
- return config.axis_x_tick_culling_reverse ? bv - av : av - bv;
27946
+ return reverse ? bv - av : av - bv;
27894
27947
  }
27895
- return config.axis_x_tick_culling_reverse ? String(b).localeCompare(String(a)) : String(a).localeCompare(String(b));
27948
+ return reverse ? String(b).localeCompare(String(a)) : String(a).localeCompare(String(b));
27896
27949
  });
27897
27950
  const tickSize = sortedTicks.length;
27898
27951
  let intervalForCulling = 0;
@@ -27907,7 +27960,7 @@ function cullDataTicks($$, ticks, sorted = false) {
27907
27960
  }
27908
27961
  if (sorted) {
27909
27962
  return ticks.filter(
27910
- (_, i) => config.axis_x_tick_culling_reverse ? (tickSize - 1 - i) % intervalForCulling === 0 : i % intervalForCulling === 0
27963
+ (_, i) => reverse ? (tickSize - 1 - i) % intervalForCulling === 0 : i % intervalForCulling === 0
27911
27964
  );
27912
27965
  }
27913
27966
  const visible = new Set(
@@ -28369,6 +28422,29 @@ function getXTickTextDirection(isRotated) {
28369
28422
  function getYTickTextDirection(isRotated, isY2) {
28370
28423
  return isRotated ? isY2 ? -1 : 1 : isY2 ? 1 : -1;
28371
28424
  }
28425
+ function getSubYTickFormat($$, id) {
28426
+ var _a, _b, _c;
28427
+ const subAxisId = id === "y2" ? "subY2" : "subY";
28428
+ const axisFormat = (_c = (_b = (_a = $$.axis) == null ? void 0 : _a[subAxisId]) == null ? void 0 : _b.tickFormat) == null ? void 0 : _c.call(_b);
28429
+ const configFormat = $$.config[`subchart_axis_${id}_tick_format`] || $$.config[`axis_${id}_tick_format`];
28430
+ if (axisFormat) {
28431
+ return axisFormat;
28432
+ }
28433
+ return typeof configFormat === "function" ? configFormat.bind($$.api) : ((v) => v);
28434
+ }
28435
+ function getGridLineCanvasStyle(style) {
28436
+ return style ? {
28437
+ stroke: style.lineColor,
28438
+ lineWidth: style.lineWidth,
28439
+ lineDash: style.dashArray
28440
+ } : void 0;
28441
+ }
28442
+ function getGridTextCanvasStyle(style) {
28443
+ return style ? {
28444
+ fill: style.labelColor,
28445
+ font: style.labelFont
28446
+ } : void 0;
28447
+ }
28372
28448
  function getHorizontalXAxisClipRect(margin, width, height) {
28373
28449
  return {
28374
28450
  x: margin.left - X_AXIS_TICK_TEXT_HORIZONTAL_CLIP_PADDING,
@@ -28693,7 +28769,7 @@ class CanvasAxisRenderer {
28693
28769
  * @private
28694
28770
  */
28695
28771
  drawSubXAxis($$) {
28696
- var _a, _b, _c;
28772
+ var _a, _b, _c, _d;
28697
28773
  const { ctx, painter, theme: { style: { axis } } } = this;
28698
28774
  const {
28699
28775
  config,
@@ -28714,12 +28790,14 @@ class CanvasAxisRenderer {
28714
28790
  const rangeStart = isRotated ? y1 : x1;
28715
28791
  const rangeEnd = isRotated ? y2 : x2;
28716
28792
  const ticks = getSubXTickValues($$);
28793
+ const lineTicks = getSubXTickLineValues($$, ticks, axis.tickWidth);
28794
+ const outerTick = (_a = config.subchart_axis_x_tick_outer) != null ? _a : config.axis_x_tick_outer;
28717
28795
  const tickDirection = isRotated ? config.axis_x_tick_inner ? 1 : -1 : config.axis_x_tick_inner ? -1 : 1;
28718
28796
  const outerTickDirection = getXOuterTickDirection(isRotated);
28719
28797
  const tickTextDirection = getXTickTextDirection(isRotated);
28720
28798
  const tickTextPosition = config.axis_x_tick_text_position;
28721
- const tickRotate = !isRotated ? ((_a = $$.getAxisTickRotate) == null ? void 0 : _a.call($$, "x")) || 0 : 0;
28722
- const tickFormat = format.subXAxisTick || ((_c = (_b = $$.axis) == null ? void 0 : _b.getXAxisTickFormat) == null ? void 0 : _c.call(_b, true));
28799
+ const tickRotate = !isRotated ? ((_b = $$.getAxisTickRotate) == null ? void 0 : _b.call($$, "x")) || 0 : 0;
28800
+ const tickFormat = format.subXAxisTick || ((_d = (_c = $$.axis) == null ? void 0 : _c.getXAxisTickFormat) == null ? void 0 : _d.call(_c, true));
28723
28801
  painter.clipRect(
28724
28802
  isRotated ? getRotatedXAxisClipRect(margin2, current.width, height2) : __spreadProps(CanvasAxisRenderer_spreadValues({}, getHorizontalXAxisClipRect(
28725
28803
  margin2,
@@ -28729,15 +28807,17 @@ class CanvasAxisRenderer {
28729
28807
  y: margin2.top
28730
28808
  }),
28731
28809
  () => {
28810
+ ctx.globalAlpha = 1;
28732
28811
  ctx.strokeStyle = axis.lineColor;
28733
28812
  ctx.lineWidth = axis.lineWidth;
28813
+ ctx.setLineDash([]);
28734
28814
  painter.strokePath(() => {
28735
28815
  if (isRotated) {
28736
28816
  painter.traceLine(x, y1, x, y2);
28737
28817
  } else {
28738
28818
  painter.traceLine(x1, y, x2, y);
28739
28819
  }
28740
- if (config.axis_x_tick_outer) {
28820
+ if (outerTick) {
28741
28821
  if (isRotated) {
28742
28822
  painter.traceLine(x, y1, x + AXIS_TICK_SIZE * outerTickDirection, y1);
28743
28823
  painter.traceLine(x, y2, x + AXIS_TICK_SIZE * outerTickDirection, y2);
@@ -28756,15 +28836,15 @@ class CanvasAxisRenderer {
28756
28836
  ctx.lineWidth = axis.tickWidth;
28757
28837
  const lineHeight = getXTickTextLineHeight(painter, getFontSize(tickFont));
28758
28838
  const tickTextWidth = getXTickTextWidth($$, ticks, isRotated, scale.subX);
28759
- for (const tick of ticks) {
28760
- const tickPos = scale.subX(normalizeXValue($$, tick));
28761
- const tx = margin2.left + tickPos;
28762
- const ty = margin2.top + tickPos;
28763
- const pos = isRotated ? ty : tx;
28764
- if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
28765
- continue;
28766
- }
28767
- if (config.subchart_axis_x_tick_show) {
28839
+ if (config.subchart_axis_x_tick_show) {
28840
+ for (const tick of lineTicks) {
28841
+ const tickPos = scale.subX(normalizeXValue($$, tick));
28842
+ const tx = margin2.left + tickPos;
28843
+ const ty = margin2.top + tickPos;
28844
+ const pos = isRotated ? ty : tx;
28845
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
28846
+ continue;
28847
+ }
28768
28848
  painter.strokePath(() => {
28769
28849
  if (isRotated) {
28770
28850
  painter.traceLine(x, ty, x + AXIS_TICK_SIZE * tickDirection, ty);
@@ -28773,6 +28853,15 @@ class CanvasAxisRenderer {
28773
28853
  }
28774
28854
  });
28775
28855
  }
28856
+ }
28857
+ for (const tick of ticks) {
28858
+ const tickPos = scale.subX(normalizeXValue($$, tick));
28859
+ const tx = margin2.left + tickPos;
28860
+ const ty = margin2.top + tickPos;
28861
+ const pos = isRotated ? ty : tx;
28862
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
28863
+ continue;
28864
+ }
28776
28865
  if (!config.subchart_axis_x_tick_text_show) {
28777
28866
  continue;
28778
28867
  }
@@ -28810,6 +28899,42 @@ class CanvasAxisRenderer {
28810
28899
  }
28811
28900
  );
28812
28901
  }
28902
+ /**
28903
+ * Draw the canvas subchart y/y2 axes.
28904
+ * @param {object} $$ ChartInternal instance
28905
+ * @private
28906
+ */
28907
+ drawSubYAxes($$) {
28908
+ const {
28909
+ config,
28910
+ scale,
28911
+ state: { margin2, width2, height2 }
28912
+ } = $$;
28913
+ if (!config.subchart_show || width2 <= 0 || height2 <= 0) {
28914
+ return;
28915
+ }
28916
+ ["y", "y2"].forEach((id) => {
28917
+ var _a;
28918
+ const subScale = id === "y2" ? scale.subY2 : scale.subY;
28919
+ if (!config[`subchart_axis_${id}_show`] || !subScale) {
28920
+ return;
28921
+ }
28922
+ this.drawYAxis($$, id, {
28923
+ scale: subScale,
28924
+ ticks: getYTickValues($$, id, void 0, true, subScale, `subchart_axis_${id}`),
28925
+ format: getSubYTickFormat($$, id),
28926
+ index: 0,
28927
+ outerTick: (_a = config[`subchart_axis_${id}_tick_outer`]) != null ? _a : config[`axis_${id}_tick_outer`],
28928
+ margin: margin2,
28929
+ width: width2,
28930
+ height: height2,
28931
+ prefix: `subchart_axis_${id}`,
28932
+ tickShow: config[`subchart_axis_${id}_tick_show`],
28933
+ tickTextShow: config[`subchart_axis_${id}_tick_text_show`],
28934
+ tickTextPosition: config[`axis_${id}_tick_text_position`]
28935
+ });
28936
+ });
28937
+ }
28813
28938
  /**
28814
28939
  * Draw chart title.
28815
28940
  * @param {object} $$ ChartInternal instance
@@ -29040,14 +29165,21 @@ class CanvasAxisRenderer {
29040
29165
  ctx.fillStyle = grid.labelColor;
29041
29166
  ctx.textBaseline = "middle";
29042
29167
  ctx.setLineDash([]);
29043
- const drawLabel = (text, x, y, rotated = false) => {
29168
+ const drawLabel = (text, x, y, rotated = false, style) => {
29044
29169
  if (!text) {
29045
29170
  return;
29046
29171
  }
29047
- painter.text(text, x, y, {
29172
+ painter.text(text, x, y, __spreadProps(CanvasAxisRenderer_spreadValues({}, style), {
29048
29173
  angle: rotated ? -90 : 0
29049
- });
29174
+ }));
29050
29175
  };
29176
+ const drawLine = (line, axisId, draw) => {
29177
+ const style = getGridLineCanvasStyle(
29178
+ this.theme.getGridLineStyle(axisId, line, "line")
29179
+ );
29180
+ painter.strokePath(draw, style);
29181
+ };
29182
+ const getTextStyle = (axisId, line) => getGridTextCanvasStyle(this.theme.getGridLineStyle(axisId, line, "text"));
29051
29183
  const drawXLine = (line) => {
29052
29184
  if (line.value === void 0 || !scale.x) {
29053
29185
  return;
@@ -29058,18 +29190,20 @@ class CanvasAxisRenderer {
29058
29190
  }
29059
29191
  if (isRotated) {
29060
29192
  const y = margin.top + pos;
29061
- painter.strokePath(() => {
29193
+ drawLine(line, "x", () => {
29062
29194
  painter.traceLine(x1, y, x2, y);
29063
29195
  });
29064
29196
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
29065
29197
  drawLabel(
29066
29198
  line.text,
29067
29199
  getLineTextPosition(line.position, x1, x2),
29068
- y - 5
29200
+ y - 5,
29201
+ false,
29202
+ getTextStyle("x", line)
29069
29203
  );
29070
29204
  } else {
29071
29205
  const x = margin.left + pos;
29072
- painter.strokePath(() => {
29206
+ drawLine(line, "x", () => {
29073
29207
  painter.traceLine(x, y1, x, y2);
29074
29208
  });
29075
29209
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
@@ -29077,7 +29211,8 @@ class CanvasAxisRenderer {
29077
29211
  line.text,
29078
29212
  x - 5,
29079
29213
  getRotatedLineTextPosition(line.position, y1, y2),
29080
- true
29214
+ true,
29215
+ getTextStyle("x", line)
29081
29216
  );
29082
29217
  }
29083
29218
  };
@@ -29094,7 +29229,7 @@ class CanvasAxisRenderer {
29094
29229
  }
29095
29230
  if (isRotated) {
29096
29231
  const x = margin.left + pos;
29097
- painter.strokePath(() => {
29232
+ drawLine(line, "y", () => {
29098
29233
  painter.traceLine(x, y1, x, y2);
29099
29234
  });
29100
29235
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
@@ -29102,18 +29237,21 @@ class CanvasAxisRenderer {
29102
29237
  line.text,
29103
29238
  x - 5,
29104
29239
  getRotatedLineTextPosition(line.position, y1, y2),
29105
- true
29240
+ true,
29241
+ getTextStyle("y", line)
29106
29242
  );
29107
29243
  } else {
29108
29244
  const y = margin.top + pos;
29109
- painter.strokePath(() => {
29245
+ drawLine(line, "y", () => {
29110
29246
  painter.traceLine(x1, y, x2, y);
29111
29247
  });
29112
29248
  ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
29113
29249
  drawLabel(
29114
29250
  line.text,
29115
29251
  getLineTextPosition(line.position, x1, x2),
29116
- y - 5
29252
+ y - 5,
29253
+ false,
29254
+ getTextStyle("y", line)
29117
29255
  );
29118
29256
  }
29119
29257
  };
@@ -29504,31 +29642,37 @@ class CanvasAxisRenderer {
29504
29642
  * @private
29505
29643
  */
29506
29644
  drawYAxis($$, id = "y", axisOptions) {
29507
- var _a, _b, _c, _d;
29645
+ var _a, _b, _c, _d, _e, _f, _g, _h;
29508
29646
  const { ctx, painter, theme: { style: { axis } } } = this;
29509
- const { config, scale, state: { margin, width, height } } = $$;
29510
- const prefix = `axis_${id}`;
29647
+ const { config, scale, state } = $$;
29648
+ const { margin, width, height } = state;
29649
+ const plotMargin = (axisOptions == null ? void 0 : axisOptions.margin) || margin;
29650
+ const plotWidth = (_a = axisOptions == null ? void 0 : axisOptions.width) != null ? _a : width;
29651
+ const plotHeight = (_b = axisOptions == null ? void 0 : axisOptions.height) != null ? _b : height;
29652
+ const prefix = (axisOptions == null ? void 0 : axisOptions.prefix) || `axis_${id}`;
29511
29653
  const targetScale = (axisOptions == null ? void 0 : axisOptions.scale) || scale[id];
29512
29654
  const isY2 = id === "y2";
29513
29655
  const isRotated = config.axis_rotated;
29514
29656
  const axisOffset = (axisOptions == null ? void 0 : axisOptions.index) ? $$.getAxisSize(id) * axisOptions.index : 0;
29515
29657
  const x = painter.crisp(
29516
- margin.left + (isY2 ? width + (isRotated ? 0 : axisOffset) : -axisOffset),
29658
+ plotMargin.left + (isY2 ? plotWidth + (isRotated ? 0 : axisOffset) : -axisOffset),
29517
29659
  axis.lineWidth
29518
29660
  );
29519
- const y = painter.crisp(margin.top + (isRotated ? isY2 ? -axisOffset - 1 : height + axisOffset : 0), axis.lineWidth);
29520
- const x1 = margin.left;
29521
- const x2 = margin.left + width;
29522
- const y1 = margin.top;
29523
- const y2 = margin.top + height;
29661
+ const y = painter.crisp(plotMargin.top + (isRotated ? isY2 ? -axisOffset - 1 : plotHeight + axisOffset : 0), axis.lineWidth);
29662
+ const x1 = plotMargin.left;
29663
+ const x2 = plotMargin.left + plotWidth;
29664
+ const y1 = plotMargin.top;
29665
+ const y2 = plotMargin.top + plotHeight;
29524
29666
  const ticks = (axisOptions == null ? void 0 : axisOptions.ticks) || getYTickValues($$, id);
29525
29667
  const lineTicks = (axisOptions == null ? void 0 : axisOptions.ticks) || (config[`${prefix}_tick_culling`] && config[`${prefix}_tick_culling_lines`] !== false ? getYTickValues($$, id, void 0, false) : ticks);
29526
- 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);
29668
+ 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);
29527
29669
  const outerTick = axisOptions ? axisOptions.outerTick : config[`${prefix}_tick_outer`];
29528
29670
  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;
29529
29671
  const outerTickDirection = getYOuterTickDirection(config, isRotated, isY2);
29530
29672
  const tickTextDirection = getYTickTextDirection(isRotated, isY2);
29531
- const tickTextPosition = config[`${prefix}_tick_text_position`];
29673
+ const tickTextPosition = (axisOptions == null ? void 0 : axisOptions.tickTextPosition) || config[`${prefix}_tick_text_position`] || config[`axis_${id}_tick_text_position`];
29674
+ const tickShow = (_g = axisOptions == null ? void 0 : axisOptions.tickShow) != null ? _g : axisOptions ? true : config[`${prefix}_tick_show`];
29675
+ const tickTextShow = (_h = axisOptions == null ? void 0 : axisOptions.tickTextShow) != null ? _h : axisOptions ? true : config[`${prefix}_tick_text_show`];
29532
29676
  painter.withState(() => {
29533
29677
  ctx.strokeStyle = axis.lineColor;
29534
29678
  ctx.lineWidth = axis.lineWidth;
@@ -29559,8 +29703,8 @@ class CanvasAxisRenderer {
29559
29703
  const drawableLineTicks = [];
29560
29704
  const addDrawableTick = (tick, target) => {
29561
29705
  const value = normalizeYValue($$, tick, id);
29562
- const tx = margin.left + targetScale(value);
29563
- const ty = margin.top + targetScale(value);
29706
+ const tx = plotMargin.left + targetScale(value);
29707
+ const ty = plotMargin.top + targetScale(value);
29564
29708
  const pos = isRotated ? tx : ty;
29565
29709
  if (!isDrawable(pos)) {
29566
29710
  return;
@@ -29573,7 +29717,7 @@ class CanvasAxisRenderer {
29573
29717
  for (const tick of lineTicks) {
29574
29718
  addDrawableTick(tick, drawableLineTicks);
29575
29719
  }
29576
- if (axisOptions || config[`${prefix}_tick_show`]) {
29720
+ if (tickShow) {
29577
29721
  painter.strokePath(() => {
29578
29722
  for (const { tx, ty } of drawableLineTicks) {
29579
29723
  if (isRotated) {
@@ -29584,7 +29728,7 @@ class CanvasAxisRenderer {
29584
29728
  }
29585
29729
  });
29586
29730
  }
29587
- if (axisOptions || config[`${prefix}_tick_text_show`]) {
29731
+ if (tickTextShow) {
29588
29732
  for (const { tick, tx, ty } of drawableTicks) {
29589
29733
  if (isRotated) {
29590
29734
  painter.text(
@@ -29776,8 +29920,112 @@ class CanvasEngine {
29776
29920
  }
29777
29921
  }
29778
29922
 
29923
+ ;// ./src/ChartInternal/internals/subchart.util.ts
29924
+ function isContinuousGridFocusEnabled($$) {
29925
+ const { config, state } = $$;
29926
+ 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);
29927
+ }
29928
+ function getMainCoordFromSubchartCoord($$, subCoord) {
29929
+ var _a;
29930
+ const { config, scale, state } = $$;
29931
+ const mainX = scale.zoom || scale.x;
29932
+ const subX = scale.subX;
29933
+ if (!mainX || !subX) {
29934
+ return null;
29935
+ }
29936
+ const subLength = config.axis_rotated ? state.height2 : state.width2;
29937
+ const mainLength = config.axis_rotated ? state.height : state.width;
29938
+ const domainValue = (_a = subX.invert) == null ? void 0 : _a.call(subX, subCoord);
29939
+ let mainCoord = domainValue == null ? NaN : mainX(domainValue);
29940
+ if (!Number.isFinite(mainCoord) && subLength > 0) {
29941
+ mainCoord = Math.max(0, Math.min(1, subCoord / subLength)) * mainLength;
29942
+ }
29943
+ return Number.isFinite(mainCoord) ? Math.max(0, Math.min(mainLength, mainCoord)) : null;
29944
+ }
29945
+
29779
29946
  ;// ./src/ChartInternal/shape/core/barRadius.ts
29780
29947
 
29948
+ const RE_PATH_NUMBER = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
29949
+ const RE_PATH_TOKEN = /([aAcChHlLmMqQsStTvVzZ])|([-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?)/g;
29950
+ function getArcFlagTokenIndexes(path) {
29951
+ const flags = /* @__PURE__ */ new Set();
29952
+ let numIndex = -1;
29953
+ let argIndex = 0;
29954
+ let inArc = false;
29955
+ let token;
29956
+ RE_PATH_TOKEN.lastIndex = 0;
29957
+ while (token = RE_PATH_TOKEN.exec(path)) {
29958
+ if (token[1]) {
29959
+ inArc = token[1] === "a" || token[1] === "A";
29960
+ argIndex = 0;
29961
+ } else {
29962
+ numIndex++;
29963
+ if (inArc) {
29964
+ const pos = argIndex % 7;
29965
+ if (pos === 2 || pos === 3 || pos === 4) {
29966
+ flags.add(numIndex);
29967
+ }
29968
+ argIndex++;
29969
+ }
29970
+ }
29971
+ }
29972
+ return flags;
29973
+ }
29974
+ function getBarPathInterpolator(a, b) {
29975
+ const flagSet = getArcFlagTokenIndexes(b);
29976
+ const segments = [];
29977
+ const interpolators = [];
29978
+ let bIndex = 0;
29979
+ let segIndex = -1;
29980
+ let numIndex = -1;
29981
+ let am;
29982
+ let bm;
29983
+ const append = (text) => {
29984
+ if (segments[segIndex]) {
29985
+ segments[segIndex] += text;
29986
+ } else {
29987
+ segments[++segIndex] = text;
29988
+ }
29989
+ };
29990
+ RE_PATH_NUMBER.lastIndex = 0;
29991
+ const reA = RE_PATH_NUMBER;
29992
+ const reB = new RegExp(RE_PATH_NUMBER.source, "g");
29993
+ a += "";
29994
+ b += "";
29995
+ while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
29996
+ numIndex++;
29997
+ if (bm.index > bIndex) {
29998
+ append(b.slice(bIndex, bm.index));
29999
+ }
30000
+ if (am[0] === bm[0]) {
30001
+ append(bm[0]);
30002
+ } else {
30003
+ const from = +am[0];
30004
+ const to = +bm[0];
30005
+ const isFlag = flagSet.has(numIndex);
30006
+ segments[++segIndex] = null;
30007
+ interpolators.push({
30008
+ index: segIndex,
30009
+ fn: isFlag ? (t) => Math.round(from + (to - from) * t) : (t) => from + (to - from) * t
30010
+ });
30011
+ }
30012
+ bIndex = reB.lastIndex;
30013
+ }
30014
+ if (bIndex < b.length) {
30015
+ append(b.slice(bIndex));
30016
+ }
30017
+ if (!interpolators.length) {
30018
+ const result = segments.join("");
30019
+ return () => result;
30020
+ }
30021
+ return (t) => {
30022
+ for (let i = 0, len = interpolators.length; i < len; i++) {
30023
+ const { index, fn } = interpolators[i];
30024
+ segments[index] = String(fn(t));
30025
+ }
30026
+ return segments.join("");
30027
+ };
30028
+ }
29781
30029
  function getBarRadiusResolver($$) {
29782
30030
  const { bar_radius: radius, bar_radius_ratio: ratio } = $$.config;
29783
30031
  return isNumber(radius) && radius > 0 ? () => radius : isNumber(ratio) ? (width) => width * ratio : null;
@@ -30305,6 +30553,26 @@ var path_spreadValues = (a, b) => {
30305
30553
  };
30306
30554
  var path_spreadProps = (a, b) => path_defProps(a, path_getOwnPropDescs(b));
30307
30555
 
30556
+ function getPathValueFn($$, isSub) {
30557
+ if (!isSub) {
30558
+ return (d) => $$.getBaseValue(d);
30559
+ }
30560
+ return (d) => {
30561
+ var _a;
30562
+ const value = (_a = $$.getSubchartCandlestickShapeValue) == null ? void 0 : _a.call($$, d, true);
30563
+ return value === void 0 ? $$.getBaseValue(d) : value;
30564
+ };
30565
+ }
30566
+ function getProjectedValues($$, values, isSub) {
30567
+ if (!isSub) {
30568
+ return values;
30569
+ }
30570
+ return values.map((d) => {
30571
+ var _a;
30572
+ const value = (_a = $$.getSubchartCandlestickShapeValue) == null ? void 0 : _a.call($$, d, isSub);
30573
+ return value === void 0 ? d : path_spreadProps(path_spreadValues({}, d), { value });
30574
+ });
30575
+ }
30308
30576
  function getLineValues($$, d, values) {
30309
30577
  return $$.isStepType(d) ? $$.convertValuesToStep(values) : values;
30310
30578
  }
@@ -30314,13 +30582,16 @@ function generateDrawLinePath($$, lineIndices, isSub, context) {
30314
30582
  const isRotated = config.axis_rotated;
30315
30583
  const getPoints = $$.generateGetLinePoints(lineIndices, isSub);
30316
30584
  const yScale = $$.getYScaleById.bind($$);
30585
+ const pathValue = getPathValueFn($$, isSub);
30317
30586
  const xValue = (d) => (isSub ? $$.subxx : $$.xx).call($$, d);
30318
- const yValue = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)($$.getBaseValue(d));
30587
+ const yValue = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)(
30588
+ pathValue(d)
30589
+ );
30319
30590
  let line = src_line();
30320
30591
  line = isRotated ? line.x(yValue).y(xValue) : line.x(xValue).y(yValue);
30321
30592
  context && (line = line.context(context));
30322
30593
  if (!lineConnectNull) {
30323
- line = line.defined((d) => $$.getBaseValue(d) !== null);
30594
+ line = line.defined((d) => pathValue(d) !== null);
30324
30595
  }
30325
30596
  const x = isSub ? scale.subX : scale.x;
30326
30597
  return (d) => {
@@ -30332,6 +30603,7 @@ function generateDrawLinePath($$, lineIndices, isSub, context) {
30332
30603
  if ($$.isLineType(d)) {
30333
30604
  const regions = config.data_regions[d.id];
30334
30605
  if (regions && !context && $$.lineWithRegions) {
30606
+ values = getProjectedValues($$, values, isSub);
30335
30607
  if ($$.isAreaRangeType(d)) {
30336
30608
  values = values.map((dv) => path_spreadProps(path_spreadValues({}, dv), { value: $$.getRangedData(dv, "mid") }));
30337
30609
  }
@@ -30345,7 +30617,7 @@ function generateDrawLinePath($$, lineIndices, isSub, context) {
30345
30617
  } else {
30346
30618
  if (values[0]) {
30347
30619
  x0 = x(values[0].x);
30348
- y0 = y(values[0].value);
30620
+ y0 = y(pathValue(values[0]));
30349
30621
  }
30350
30622
  path = isRotated ? `M ${y0} ${x0}` : `M ${x0} ${y0}`;
30351
30623
  }
@@ -30358,12 +30630,22 @@ function generateDrawAreaPath($$, areaIndices, isSub, context) {
30358
30630
  const isRotated = config.axis_rotated;
30359
30631
  const getPoints = $$.generateGetAreaPoints(areaIndices, isSub);
30360
30632
  const yScale = $$.getYScaleById.bind($$);
30633
+ const pathValue = getPathValueFn($$, isSub);
30634
+ const shapeYMin = /* @__PURE__ */ new Map();
30635
+ const getShapeYMin = (id) => {
30636
+ let min = shapeYMin.get(id);
30637
+ if (min === void 0) {
30638
+ min = $$.getShapeYMin(id, isSub);
30639
+ shapeYMin.set(id, min);
30640
+ }
30641
+ return min;
30642
+ };
30361
30643
  const xValue = (d) => (isSub ? $$.subxx : $$.xx).call($$, d);
30362
30644
  const value0 = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[0][1] : yScale(d.id, isSub)(
30363
- $$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : $$.getShapeYMin(d.id)
30645
+ $$.isAreaRangeType(d) ? $$.getRangedData(d, "high") : getShapeYMin(d.id)
30364
30646
  );
30365
30647
  const value1 = (d, i) => $$.isGrouped(d.id) ? getPoints(d, i)[1][1] : yScale(d.id, isSub)(
30366
- $$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : d.value
30648
+ $$.isAreaRangeType(d) ? $$.getRangedData(d, "low") : pathValue(d)
30367
30649
  );
30368
30650
  return (d) => {
30369
30651
  let values = lineConnectNull ? $$.filterRemoveNull(d.values) : d.values;
@@ -30372,19 +30654,20 @@ function generateDrawAreaPath($$, areaIndices, isSub, context) {
30372
30654
  let path;
30373
30655
  if ($$.isAreaType(d)) {
30374
30656
  let area = src_area();
30375
- 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);
30657
+ 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);
30376
30658
  context && (area = area.context(context));
30377
30659
  if (!lineConnectNull) {
30378
- area = area.defined((d2) => $$.getBaseValue(d2) !== null);
30660
+ area = area.defined((d2) => pathValue(d2) !== null);
30379
30661
  }
30662
+ values = getProjectedValues($$, values, isSub);
30380
30663
  if ($$.isStepType(d)) {
30381
30664
  values = $$.convertValuesToStep(values);
30382
30665
  }
30383
30666
  path = area.curve($$.getCurve(d))(values);
30384
30667
  } else {
30385
30668
  if (values[0]) {
30386
- x0 = $$.scale.x(values[0].x);
30387
- y0 = $$.getYScaleById(d.id)(values[0].value);
30669
+ x0 = (isSub ? $$.scale.subX : $$.scale.x)(values[0].x);
30670
+ y0 = $$.getYScaleById(d.id, isSub)(pathValue(values[0]));
30388
30671
  }
30389
30672
  path = isRotated ? `M ${y0} ${x0}` : `M ${x0} ${y0}`;
30390
30673
  }
@@ -31244,6 +31527,7 @@ var CanvasRenderer_publicField = (obj, key, value) => CanvasRenderer_defNormalPr
31244
31527
 
31245
31528
 
31246
31529
 
31530
+
31247
31531
  const RENDERER_GROUPED_TYPE_FILTERS = [
31248
31532
  isCanvasAreaType,
31249
31533
  isCanvasBarType,
@@ -31925,165 +32209,175 @@ class CanvasRenderer {
31925
32209
  /**
31926
32210
  * Draw the canvas subchart overview and brush selection.
31927
32211
  * @param {object} $$ ChartInternal instance
31928
- * @param {object} shape Cached draw shape object
32212
+ * @param {object} _shape Cached main shape object
31929
32213
  * @private
31930
32214
  */
31931
- drawSubchart($$, shape) {
32215
+ drawSubchart($$, _shape) {
31932
32216
  const { config, state } = $$;
32217
+ void _shape;
31933
32218
  if (!config.subchart_show || !state.hasAxis || state.width2 <= 0 || state.height2 <= 0) {
31934
32219
  return;
31935
32220
  }
31936
32221
  const { ctx, painter, theme: { style } } = this;
31937
32222
  const { margin2, width2, height2 } = state;
31938
32223
  const rect = { x: margin2.left, y: margin2.top, w: width2, h: height2 };
31939
- const targets = $$.filterTargetsToShow().filter(isCanvasRenderableTarget.bind(null, $$));
31940
- painter.withState(() => {
31941
- ctx.strokeStyle = style.axis.lineColor;
31942
- ctx.lineWidth = style.axis.lineWidth;
31943
- painter.strokePath(() => {
31944
- if (config.axis_rotated) {
31945
- painter.traceLine(rect.x, rect.y, rect.x, rect.y + rect.h);
31946
- } else {
31947
- painter.traceLine(rect.x, rect.y + rect.h, rect.x + rect.w, rect.y + rect.h);
31948
- }
31949
- });
31950
- painter.clipRect(rect, () => {
31951
- painter.withTranslation(rect.x, rect.y, () => {
31952
- var _a, _b, _c, _d, _e, _f;
31953
- const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
31954
- const areaIndices = getCanvasShapeIndices(
31955
- $$,
31956
- shape,
31957
- TYPE.AREA,
31958
- isCanvasAreaType.bind(null, $$)
31959
- );
31960
- ctx.globalAlpha = style.shape.areaOpacity;
31961
- for (const target of areaTargets) {
31962
- if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
31963
- continue;
31964
- }
31965
- ctx.fillStyle = $$.color(target.id);
31966
- drawCanvasArea($$, target, areaIndices, painter, true);
31967
- }
31968
- ctx.globalAlpha = 1;
31969
- const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
31970
- const barIndices = getCanvasShapeIndices(
31971
- $$,
31972
- shape,
31973
- TYPE.BAR,
31974
- isCanvasBarType.bind(null, $$)
31975
- );
31976
- const getBarPoints = (_a = $$.generateGetBarPoints) == null ? void 0 : _a.call($$, barIndices, true);
31977
- if (getBarPoints) {
31978
- ctx.globalAlpha = style.shape.barOpacity;
31979
- for (const target of barTargets) {
32224
+ $$.withSubchartTypeContext(() => {
32225
+ var _a;
32226
+ const targets = $$.filterTargetsToShow().filter(isCanvasRenderableTarget.bind(null, $$));
32227
+ const shape = $$.getDrawShape();
32228
+ (_a = $$.updateSubchartYDomain) == null ? void 0 : _a.call($$, targets);
32229
+ painter.withState(() => {
32230
+ painter.clipRect(rect, () => {
32231
+ painter.withTranslation(rect.x, rect.y, () => {
32232
+ var _a2, _b, _c, _d, _e, _f;
32233
+ const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
32234
+ const areaIndices = getCanvasShapeIndices(
32235
+ $$,
32236
+ shape,
32237
+ TYPE.AREA,
32238
+ isCanvasAreaType.bind(null, $$)
32239
+ );
32240
+ for (const target of areaTargets) {
32241
+ if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
32242
+ continue;
32243
+ }
32244
+ ctx.globalAlpha = style.shape.areaOpacity * getCanvasTargetFocusOpacity($$, target);
31980
32245
  ctx.fillStyle = $$.color(target.id);
31981
- target.values.forEach((d, i) => {
31982
- if (!hasCanvasDrawableValue($$, d)) {
31983
- return;
31984
- }
31985
- const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
31986
- geometry && painter.fillRect(geometry.rect, { fill: ctx.fillStyle });
31987
- });
32246
+ drawCanvasArea($$, target, areaIndices, painter, true);
31988
32247
  }
31989
32248
  ctx.globalAlpha = 1;
31990
- }
31991
- const candlestickTargets = targets.filter(
31992
- isCanvasCandlestickType.bind(null, $$)
31993
- );
31994
- const candlestickIndices = getCanvasShapeIndices(
31995
- $$,
31996
- shape,
31997
- TYPE.CANDLESTICK,
31998
- isCanvasCandlestickType.bind(null, $$)
31999
- );
32000
- const getCandlestickPoints = (_b = $$.generateGetCandlestickPoints) == null ? void 0 : _b.call(
32001
- $$,
32002
- candlestickIndices,
32003
- true
32004
- );
32005
- if (getCandlestickPoints) {
32006
- ctx.lineWidth = style.shape.candlestickLineWidth;
32007
- for (const target of candlestickTargets) {
32008
- target.values.forEach((d, i) => {
32009
- var _a2;
32010
- const value = (_a2 = $$.getCandlestickData) == null ? void 0 : _a2.call($$, d);
32011
- const geometry = value && getCanvasCandlestickGeometry(
32012
- $$,
32013
- getCandlestickPoints,
32014
- d,
32015
- i
32016
- );
32017
- if (!geometry) {
32018
- return;
32019
- }
32020
- const color = getCandlestickColor($$, { id: target.id }, value);
32021
- ctx.strokeStyle = color;
32022
- ctx.fillStyle = color;
32023
- painter.strokePath(() => {
32024
- painter.traceLine(
32025
- geometry.wickStart[0],
32026
- geometry.wickStart[1],
32027
- geometry.wickEnd[0],
32028
- geometry.wickEnd[1]
32029
- );
32030
- });
32031
- painter.fillRect(geometry.body, { fill: ctx.fillStyle });
32032
- });
32033
- }
32034
- }
32035
- const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
32036
- const lineIndices = getCanvasShapeIndices(
32037
- $$,
32038
- shape,
32039
- TYPE.LINE,
32040
- isCanvasLineType.bind(null, $$)
32041
- );
32042
- ctx.globalAlpha = 1;
32043
- ctx.lineWidth = style.shape.lineWidth;
32044
- for (const target of lineTargets) {
32045
- if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
32046
- continue;
32047
- }
32048
- ctx.strokeStyle = $$.color(target.id);
32049
- drawCanvasLine($$, target, lineIndices, painter, true);
32050
- }
32051
- if (config.point_show && !((_c = $$.isPointFocusOnly) == null ? void 0 : _c.call($$))) {
32052
- const cy = (_d = $$.updateCircleY) == null ? void 0 : _d.call($$, true);
32053
- const cx = (_e = $$.subxx) == null ? void 0 : _e.bind($$);
32054
- if (cx && cy) {
32055
- for (const target of targets) {
32056
- if (!isCanvasScatterType($$, target) && !isCanvasBubbleType($$, target)) {
32057
- continue;
32058
- }
32059
- const color = $$.color(target.id);
32060
- const pointFill = style.shape.pointFillColor || color;
32061
- const pointStroke = style.shape.pointStrokeColor || color;
32062
- const pointLineWidth = pointStroke ? (_f = style.shape.pointLineWidth) != null ? _f : 1 : 0;
32063
- const pointStyle = pointStroke && pointLineWidth > 0 ? {
32064
- fill: pointFill,
32065
- stroke: pointStroke,
32066
- lineWidth: pointLineWidth
32067
- } : { fill: pointFill };
32068
- ctx.globalAlpha = getPointOpacity($$, target);
32249
+ const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
32250
+ const barIndices = getCanvasShapeIndices(
32251
+ $$,
32252
+ shape,
32253
+ TYPE.BAR,
32254
+ isCanvasBarType.bind(null, $$)
32255
+ );
32256
+ const getBarPoints = (_a2 = $$.generateGetBarPoints) == null ? void 0 : _a2.call($$, barIndices, true);
32257
+ if (getBarPoints) {
32258
+ for (const target of barTargets) {
32259
+ ctx.globalAlpha = style.shape.barOpacity * getCanvasTargetFocusOpacity($$, target);
32260
+ ctx.fillStyle = $$.color(target.id);
32069
32261
  target.values.forEach((d, i) => {
32262
+ var _a3;
32070
32263
  if (!hasCanvasDrawableValue($$, d)) {
32071
32264
  return;
32072
32265
  }
32073
- const x = config.axis_rotated ? cy(d, i) : cx(d);
32074
- const y = config.axis_rotated ? cx(d) : cy(d, i);
32075
- const r = Math.min(getTargetPointRadius($$, target, d), 3);
32076
- if (isFiniteCanvasCoordinate(x, y)) {
32077
- drawPointPattern(painter, "circle", x, y, r, pointStyle);
32078
- }
32266
+ const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
32267
+ const fill = ((_a3 = $$.getSubchartCandlestickBarColor) == null ? void 0 : _a3.call($$, d, true)) || ctx.fillStyle;
32268
+ geometry && painter.fillRect(geometry.rect, { fill });
32079
32269
  });
32080
32270
  }
32081
32271
  ctx.globalAlpha = 1;
32082
32272
  }
32083
- }
32273
+ const candlestickTargets = targets.filter(
32274
+ isCanvasCandlestickType.bind(null, $$)
32275
+ );
32276
+ const candlestickIndices = getCanvasShapeIndices(
32277
+ $$,
32278
+ shape,
32279
+ TYPE.CANDLESTICK,
32280
+ isCanvasCandlestickType.bind(null, $$)
32281
+ );
32282
+ const getCandlestickPoints = (_b = $$.generateGetCandlestickPoints) == null ? void 0 : _b.call(
32283
+ $$,
32284
+ candlestickIndices,
32285
+ true
32286
+ );
32287
+ if (getCandlestickPoints) {
32288
+ ctx.lineWidth = style.shape.candlestickLineWidth;
32289
+ for (const target of candlestickTargets) {
32290
+ const targetOpacity = getCanvasTargetFocusOpacity($$, target);
32291
+ ctx.globalAlpha = targetOpacity;
32292
+ target.values.forEach((d, i) => {
32293
+ var _a3;
32294
+ const value = (_a3 = $$.getCandlestickData) == null ? void 0 : _a3.call($$, d);
32295
+ const geometry = value && getCanvasCandlestickGeometry(
32296
+ $$,
32297
+ getCandlestickPoints,
32298
+ d,
32299
+ i
32300
+ );
32301
+ if (!geometry) {
32302
+ return;
32303
+ }
32304
+ const color = getCandlestickColor($$, { id: target.id }, value);
32305
+ ctx.strokeStyle = color;
32306
+ ctx.fillStyle = color;
32307
+ painter.strokePath(() => {
32308
+ painter.traceLine(
32309
+ geometry.wickStart[0],
32310
+ geometry.wickStart[1],
32311
+ geometry.wickEnd[0],
32312
+ geometry.wickEnd[1]
32313
+ );
32314
+ });
32315
+ painter.fillRect(geometry.body, { fill: ctx.fillStyle });
32316
+ });
32317
+ }
32318
+ }
32319
+ const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
32320
+ const lineIndices = getCanvasShapeIndices(
32321
+ $$,
32322
+ shape,
32323
+ TYPE.LINE,
32324
+ isCanvasLineType.bind(null, $$)
32325
+ );
32326
+ ctx.globalAlpha = 1;
32327
+ for (const target of lineTargets) {
32328
+ if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) {
32329
+ continue;
32330
+ }
32331
+ ctx.globalAlpha = getCanvasTargetFocusOpacity($$, target);
32332
+ ctx.lineWidth = isCanvasTargetFocused($$, target) ? style.shape.lineFocusedWidth : style.shape.lineWidth;
32333
+ ctx.strokeStyle = $$.color(target.id);
32334
+ drawCanvasLine($$, target, lineIndices, painter, true);
32335
+ }
32336
+ ctx.globalAlpha = 1;
32337
+ if (config.point_show && !((_c = $$.isPointFocusOnly) == null ? void 0 : _c.call($$))) {
32338
+ const cy = (_d = $$.updateCircleY) == null ? void 0 : _d.call($$, true);
32339
+ const cx = (_e = $$.subxx) == null ? void 0 : _e.bind($$);
32340
+ if (cx && cy) {
32341
+ for (const target of targets) {
32342
+ if (!isCanvasScatterType($$, target) && !isCanvasBubbleType($$, target)) {
32343
+ continue;
32344
+ }
32345
+ const color = $$.color(target.id);
32346
+ const pointFill = style.shape.pointFillColor || color;
32347
+ const pointStroke = style.shape.pointStrokeColor || color;
32348
+ const pointLineWidth = pointStroke ? (_f = style.shape.pointLineWidth) != null ? _f : 1 : 0;
32349
+ const pointStyle = pointStroke && pointLineWidth > 0 ? {
32350
+ fill: pointFill,
32351
+ stroke: pointStroke,
32352
+ lineWidth: pointLineWidth
32353
+ } : { fill: pointFill };
32354
+ ctx.globalAlpha = getPointOpacity($$, target) * getCanvasTargetFocusOpacity($$, target);
32355
+ target.values.forEach((d, i) => {
32356
+ if (!hasCanvasDrawableValue($$, d)) {
32357
+ return;
32358
+ }
32359
+ const x = config.axis_rotated ? cy(d, i) : cx(d);
32360
+ const y = config.axis_rotated ? cx(d) : cy(d, i);
32361
+ const r = Math.min(getTargetPointRadius($$, target, d), 3);
32362
+ if (isFiniteCanvasCoordinate(x, y)) {
32363
+ drawPointPattern(
32364
+ painter,
32365
+ "circle",
32366
+ x,
32367
+ y,
32368
+ r,
32369
+ pointStyle
32370
+ );
32371
+ }
32372
+ });
32373
+ }
32374
+ ctx.globalAlpha = 1;
32375
+ }
32376
+ }
32377
+ });
32084
32378
  });
32379
+ this.drawSubchartBrush($$);
32085
32380
  });
32086
- this.drawSubchartBrush($$);
32087
32381
  });
32088
32382
  }
32089
32383
  /**
@@ -32095,7 +32389,7 @@ class CanvasRenderer {
32095
32389
  var _a, _b;
32096
32390
  const { config, scale, state } = $$;
32097
32391
  const domain = state.domain;
32098
- if (!config.subchart_show || !(domain == null ? void 0 : domain.length) || !scale.subX) {
32392
+ if (!config.subchart_show || config.subchart_brush_enabled === false || !(domain == null ? void 0 : domain.length) || !scale.subX) {
32099
32393
  return;
32100
32394
  }
32101
32395
  const { margin2, width2, height2 } = state;
@@ -32556,7 +32850,7 @@ class CanvasRenderer {
32556
32850
  const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : /* @__PURE__ */ new Set();
32557
32851
  painter.withTranslation(margin.left, margin.top, () => {
32558
32852
  selectedData.forEach((d) => {
32559
- var _a2, _b2, _c, _d, _e, _f;
32853
+ var _a2, _b2, _c, _d, _e, _f, _g;
32560
32854
  const color = $$.color(d.id);
32561
32855
  if (isBar(d) && barPoints) {
32562
32856
  const geometry = getCanvasBarGeometry($$, barPoints, d, d.index);
@@ -32600,11 +32894,13 @@ class CanvasRenderer {
32600
32894
  lineWidth: style.selectedPoint.lineWidth,
32601
32895
  stroke: style.selectedPoint.stroke || color
32602
32896
  });
32603
- drawPointPattern(painter, pointType, x, y, r, {
32604
- fill: style.shape.pointFillColor || color,
32605
- stroke: style.shape.pointStrokeColor || color,
32606
- lineWidth: (_f = style.shape.pointLineWidth) != null ? _f : 1
32607
- });
32897
+ if (!((_f = $$.isPointFocusOnly) == null ? void 0 : _f.call($$))) {
32898
+ drawPointPattern(painter, pointType, x, y, r, {
32899
+ fill: style.shape.pointFillColor || color,
32900
+ stroke: style.shape.pointStrokeColor || color,
32901
+ lineWidth: (_g = style.shape.pointLineWidth) != null ? _g : 1
32902
+ });
32903
+ }
32608
32904
  }
32609
32905
  });
32610
32906
  ctx.globalAlpha = 1;
@@ -32848,6 +33144,37 @@ class CanvasRenderer {
32848
33144
  }
32849
33145
  });
32850
33146
  }
33147
+ /**
33148
+ * Draw synchronized focus grid on the canvas subchart.
33149
+ * @param {object} $$ ChartInternal instance
33150
+ * @param {Array} selectedData Focused data rows
33151
+ * @private
33152
+ */
33153
+ drawSubchartFocus($$, selectedData) {
33154
+ const { config, scale, state } = $$;
33155
+ const focus = selectedData == null ? void 0 : selectedData.find(
33156
+ (d) => d && hasCanvasDrawableValue($$, d)
33157
+ );
33158
+ 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) {
33159
+ return;
33160
+ }
33161
+ const { margin2, width2, height2 } = state;
33162
+ const pos = scale.subX(focus.x);
33163
+ if (!Number.isFinite(pos)) {
33164
+ return;
33165
+ }
33166
+ const { painter, theme: { style } } = this;
33167
+ const lineWidth = style.axis.lineWidth;
33168
+ const x = painter.crisp(margin2.left + pos, lineWidth);
33169
+ const y = painter.crisp(margin2.top + pos, lineWidth);
33170
+ painter.strokePath(() => {
33171
+ config.axis_rotated ? painter.traceLine(margin2.left, y, margin2.left + width2, y) : painter.traceLine(x, margin2.top, x, margin2.top + height2);
33172
+ }, {
33173
+ lineDash: style.focusGrid.dashArray,
33174
+ lineWidth: style.focusGrid.lineWidth,
33175
+ stroke: style.focusGrid.lineColor
33176
+ });
33177
+ }
32851
33178
  /**
32852
33179
  * Draw focus grid and focused points on canvas.
32853
33180
  * @param {object} $$ ChartInternal instance
@@ -32864,6 +33191,7 @@ class CanvasRenderer {
32864
33191
  const focus = selectedData.find(
32865
33192
  (d) => d && hasCanvasDrawableValue($$, d)
32866
33193
  );
33194
+ $$.config.subchart_grid_focus !== false && !isContinuousGridFocusEnabled($$) && this.drawSubchartFocus($$, selectedData);
32867
33195
  painter.withTranslation(margin.left, margin.top, () => {
32868
33196
  if ($$.config.tooltip_show && $$.config.grid_focus_show !== false && !$$.config.axis_tooltip && focus) {
32869
33197
  const { x, y } = getRenderDataPoint($$, focus);
@@ -32874,6 +33202,9 @@ class CanvasRenderer {
32874
33202
  const crispEdgeX = (value) => painter.crisp(margin.left + value, axisLineWidth) - margin.left;
32875
33203
  const crispEdgeY = (value) => painter.crisp(margin.top + value, axisLineWidth) - margin.top;
32876
33204
  const isEdge = $$.config.grid_focus_edge && !$$.config.tooltip_grouped;
33205
+ const continuousFocus = isContinuousGridFocusEnabled($$);
33206
+ const focusEndX = continuousFocus ? $$.state.margin2.left - margin.left + $$.state.width2 : $$.state.width;
33207
+ const focusEndY = continuousFocus ? $$.state.margin2.top - margin.top + $$.state.height2 : $$.state.height;
32877
33208
  if (hasIndexCoordinate) {
32878
33209
  painter.strokePath(() => {
32879
33210
  var _a, _b;
@@ -32881,7 +33212,7 @@ class CanvasRenderer {
32881
33212
  painter.traceLine(
32882
33213
  crispEdgeX(0),
32883
33214
  y,
32884
- isEdge && hasValueCoordinate ? x : crispEdgeX($$.state.width),
33215
+ isEdge && hasValueCoordinate ? x : crispEdgeX(focusEndX),
32885
33216
  y
32886
33217
  );
32887
33218
  if (hasValueCoordinate && $$.config.grid_focus_y && !$$.config.tooltip_grouped) {
@@ -32898,7 +33229,7 @@ class CanvasRenderer {
32898
33229
  x,
32899
33230
  isEdge && hasValueCoordinate ? y : crispEdgeY(0),
32900
33231
  x,
32901
- crispEdgeY($$.state.height)
33232
+ crispEdgeY(focusEndY)
32902
33233
  );
32903
33234
  if (hasValueCoordinate && $$.config.grid_focus_y && !$$.config.tooltip_grouped) {
32904
33235
  const isY2 = ((_b = $$.axis) == null ? void 0 : _b.getId(focus.id)) === "y2";
@@ -33096,6 +33427,77 @@ function normalizeThemeSelectors(selector) {
33096
33427
  (value) => value.trim().replace(/\s*>\s*/g, " ").replace(/\s+/g, " ").replace(/^(?:svg)?\.bb\s+/, "").replace(/(^|\s)(?:g|path|rect|line|text|circle)\./g, "$1.")
33097
33428
  ).filter(Boolean);
33098
33429
  }
33430
+ function getDefinedKeys(values) {
33431
+ return Object.keys(values).filter((key) => values[key] !== void 0);
33432
+ }
33433
+ function assignDefined(target, source, skip) {
33434
+ getDefinedKeys(source).forEach((key) => {
33435
+ if (!(skip == null ? void 0 : skip.has(key))) {
33436
+ target[key] = source[key];
33437
+ }
33438
+ });
33439
+ return target;
33440
+ }
33441
+ function isSimpleGridLineSelector(selector) {
33442
+ const tokens = selector.split(" ");
33443
+ return tokens.every(
33444
+ (token, index) => token === "line" || token === "text" ? index === tokens.length - 1 : /^(\.[A-Za-z_-][\w-]*)+$/.test(token)
33445
+ );
33446
+ }
33447
+ function getGridLineSelectorTarget(selector) {
33448
+ const tokens = selector.split(" ");
33449
+ const target = tokens[tokens.length - 1];
33450
+ return target === "line" || target === "text" ? target : null;
33451
+ }
33452
+ function getClassNames(className) {
33453
+ return (className || "").split(/\s+/).filter(Boolean);
33454
+ }
33455
+ function getGridLineSelectorStyle(style, target) {
33456
+ const values = target === "text" ? {
33457
+ labelColor: readColorValue(style, "fill"),
33458
+ labelFont: readFontValue(style)
33459
+ } : {
33460
+ lineColor: readColorValue(style, "stroke"),
33461
+ lineWidth: readNumberValue(style, "stroke-width"),
33462
+ dashArray: readDashArrayValue(style)
33463
+ };
33464
+ return assignDefined({}, values);
33465
+ }
33466
+ function getGridLineSelectorOverrides(selectors) {
33467
+ const overrides = [];
33468
+ Object.keys(selectors != null ? selectors : {}).forEach((selector) => {
33469
+ normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
33470
+ const target = getGridLineSelectorTarget(normalizedSelector) || "line";
33471
+ const style = getGridLineSelectorStyle(selectors[selector], target);
33472
+ if (isSimpleGridLineSelector(normalizedSelector) && getDefinedKeys(style).length) {
33473
+ overrides.push({ selector: normalizedSelector, target, style });
33474
+ }
33475
+ });
33476
+ });
33477
+ return overrides;
33478
+ }
33479
+ function matchesGridLineSelector(selector, axis, className, target) {
33480
+ if (!isSimpleGridLineSelector(selector)) {
33481
+ return false;
33482
+ }
33483
+ const selectorTarget = getGridLineSelectorTarget(selector);
33484
+ if (selectorTarget && selectorTarget !== target) {
33485
+ return false;
33486
+ } else if (!selectorTarget && target === "text") {
33487
+ return false;
33488
+ }
33489
+ const customClasses = getClassNames(className);
33490
+ const axisLineClass = `bb-${axis}grid-line`;
33491
+ const availableClasses = /* @__PURE__ */ new Set([
33492
+ "bb-grid",
33493
+ "bb-grid-lines",
33494
+ `bb-${axis}grid-lines`,
33495
+ axisLineClass,
33496
+ ...customClasses
33497
+ ]);
33498
+ const selectorClasses = (selector.match(/\.[A-Za-z_-][\w-]*/g) || []).map((match) => match.slice(1));
33499
+ return !!selectorClasses.length && selectorClasses.every((cls) => availableClasses.has(cls)) && (selectorClasses.includes(axisLineClass) || customClasses.some((cls) => selectorClasses.includes(cls)));
33500
+ }
33099
33501
  function applySelectorStyle(target, selector, style) {
33100
33502
  switch (selector) {
33101
33503
  case ".bb-axis path.domain":
@@ -33372,6 +33774,8 @@ class CanvasTheme {
33372
33774
  CanvasTheme_publicField(this, "style");
33373
33775
  CanvasTheme_publicField(this, "cacheContainer", null);
33374
33776
  CanvasTheme_publicField(this, "cacheKey", null);
33777
+ CanvasTheme_publicField(this, "gridLineSelectorOverrides", []);
33778
+ CanvasTheme_publicField(this, "directGridOverrideKeys", /* @__PURE__ */ new Set());
33375
33779
  }
33376
33780
  /**
33377
33781
  * Read theme values from temporary SVG probes.
@@ -33380,8 +33784,12 @@ class CanvasTheme {
33380
33784
  * @private
33381
33785
  */
33382
33786
  load(container, userOverride) {
33383
- var _a, _b, _c, _d;
33787
+ var _a, _b, _c, _d, _e;
33384
33788
  const svg = browser_doc.createElementNS(SVG_NS, "svg");
33789
+ this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride == null ? void 0 : userOverride.selectors);
33790
+ this.directGridOverrideKeys = new Set(
33791
+ Object.keys((_a = userOverride == null ? void 0 : userOverride.grid) != null ? _a : {})
33792
+ );
33385
33793
  svg.setAttribute("class", "bb");
33386
33794
  svg.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
33387
33795
  container.appendChild(svg);
@@ -33546,7 +33954,7 @@ class CanvasTheme {
33546
33954
  subchartBrushSelection.fill,
33547
33955
  toColor(subchartBrushExtent.fill, zoomBrushFill)
33548
33956
  );
33549
- 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;
33957
+ 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;
33550
33958
  const subchartBrushHandleStroke = toColor(subchartBrushHandle.stroke, "transparent");
33551
33959
  const defaultStyle = {
33552
33960
  axis: {
@@ -33772,6 +34180,25 @@ class CanvasTheme {
33772
34180
  }
33773
34181
  this.load(container, userOverride);
33774
34182
  }
34183
+ /**
34184
+ * Resolve selector based style for one configured optional grid line.
34185
+ * @param {string} axis Grid axis
34186
+ * @param {object} line Grid line options
34187
+ * @param {string} line.class Grid line custom class
34188
+ * @param {string} target Draw target
34189
+ * @returns {object|undefined} Grid line style override
34190
+ * @private
34191
+ */
34192
+ getGridLineStyle(axis, line = {}, target = "line") {
34193
+ const style = {};
34194
+ for (const override of this.gridLineSelectorOverrides) {
34195
+ if (!matchesGridLineSelector(override.selector, axis, line.class, target)) {
34196
+ continue;
34197
+ }
34198
+ assignDefined(style, override.style, this.directGridOverrideKeys);
34199
+ }
34200
+ return getDefinedKeys(style).length ? style : void 0;
34201
+ }
33775
34202
  }
33776
34203
 
33777
34204
  ;// ./src/canvas/HitDetector.ts
@@ -34307,6 +34734,7 @@ const $FOCUS = {
34307
34734
  defocused: "bb-defocused",
34308
34735
  legendItemFocused: "bb-legend-item-focused",
34309
34736
  xgridFocus: "bb-xgrid-focus",
34737
+ xgridFocusContinuous: "bb-xgrid-focus-continuous",
34310
34738
  ygridFocus: "bb-ygrid-focus"
34311
34739
  };
34312
34740
  const $GRID = {
@@ -34384,19 +34812,79 @@ const $ZOOM = {
34384
34812
  * - **NOTE:**
34385
34813
  * - Will append &lt;style> to the head tag and will add shpes' CSS rules dynamically.
34386
34814
  * - For now, covers colors related properties (fill, stroke, etc.) only.
34387
- * @property {boolean} [boost.useWorker=false] Use Web Worker as possible for processing.
34815
+ * @property {boolean|string} [boost.useWorker=false] Use Web Worker as possible for processing.
34816
+ * - **Available values:**
34817
+ * - `false`: never offload.
34818
+ * - `true`: always offload when a Worker can be created.
34819
+ * - `"auto"`: offload only when the given data exceeds ~5,000 cells, since smaller
34820
+ * payloads lose more to structured cloning than they gain.
34388
34821
  * - **NOTE:**
34389
34822
  * - For now, only applies for data conversion at the initial time.
34390
- * - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
34823
+ * - As of Web Worker's async nature, handling chart instance synchronously is not recommended.
34824
+ * - When Worker isn't available, fails or times out, data conversion falls back to main thread.
34391
34825
  * - When given data is empty, useWorker will be ignored.
34826
+ * @property {string} [boost.workerUrl=undefined] Use a custom static worker script URL instead of an inline Blob worker.
34827
+ * - **NOTE:**
34828
+ * - **Requires `boost.useWorker` to be enabled** — this option only selects where the
34829
+ * worker source comes from, it does not turn offloading on by itself.
34830
+ * - Useful for strict CSP environments that disallow `blob:` workers. Without it under
34831
+ * such a policy, worker creation throws and each conversion waits out the 5s timeout
34832
+ * before falling back, so the chart still renders but the initial draw is delayed.
34833
+ * - Point it at `dist/billboard.worker.js`, shipped in the package, or any script
34834
+ * implementing the same protocol: receive `{id, op, args}` and post back
34835
+ * `{id, result}` or `{id, error}`. No `eval()` is involved.
34836
+ * - With a bundler, make sure the file is emitted as a **real asset**, not inlined:
34837
+ * it is ~1.5KB, and inlining turns it into a `data:` URI, which a strict CSP
34838
+ * blocks exactly like `blob:`. Copying it into the static/public directory is the
34839
+ * option that works everywhere.
34840
+ * - Any failure (load error, unknown op, timeout, result mismatch) falls back to the main thread.
34392
34841
  * @example
34842
+ * // offload data conversion on a Worker, using the inline Blob worker
34393
34843
  * boost: {
34394
34844
  * useCssRule: true,
34395
- * useWorker: false
34845
+ * useWorker: true
34846
+ * }
34847
+ * @example
34848
+ * // offload only past ~5,000 cells
34849
+ * boost: {
34850
+ * useWorker: "auto"
34851
+ * }
34852
+ * @example
34853
+ * // strict CSP: serve the shipped script and point at it.
34854
+ * // 'useWorker' still has to be on - 'workerUrl' alone offloads nothing.
34855
+ * boost: {
34856
+ * useWorker: true,
34857
+ * workerUrl: "$YOUR_PATH/dist/billboard.worker.js"
34396
34858
  * }
34859
+ * @example
34860
+ * // ESM: the file is reachable as a package subpath.
34861
+ * // Vite - '?url' resolves it, but assets under 4KB are inlined as a 'data:' URI,
34862
+ * // which a strict CSP rejects. Opt that one file out of inlining:
34863
+ * //
34864
+ * // // vite.config.js
34865
+ * // export default {
34866
+ * // build: {
34867
+ * // assetsInlineLimit: path => /billboard\.worker\.js$/.test(path) ? false : undefined
34868
+ * // }
34869
+ * // };
34870
+ * import bb, {bar} from "billboard.js";
34871
+ * import workerUrl from "billboard.js/dist/billboard.worker.js?url";
34872
+ *
34873
+ * bb.generate({
34874
+ * boost: {useWorker: true, workerUrl},
34875
+ * data: {columns: [["data1", 30, 200, 100]], type: bar()}
34876
+ * });
34877
+ * @example
34878
+ * // ESM, bundler-agnostic: copy the file into the served static directory
34879
+ * // cp node_modules/billboard.js/dist/billboard.worker.js public/
34880
+ * bb.generate({
34881
+ * boost: {useWorker: true, workerUrl: "/billboard.worker.js"},
34882
+ * data: {columns: [["data1", 30, 200, 100]]}
34883
+ * });
34397
34884
  */
34398
34885
  boost_useCssRule: false,
34399
- boost_useWorker: false
34886
+ boost_useWorker: false,
34887
+ boost_workerUrl: void 0
34400
34888
  });
34401
34889
 
34402
34890
  ;// ./src/config/Options/common/color.ts
@@ -34407,9 +34895,9 @@ const $ZOOM = {
34407
34895
  * @memberof Options
34408
34896
  * @type {object}
34409
34897
  * @property {object} color color object
34410
- * @property {string|object|((this: Chart, d: DataItem) => string)} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
34898
+ * @property {string|object|function(DataItem): string} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
34411
34899
  * @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.
34412
- * @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).
34900
+ * @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).
34413
34901
  * - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
34414
34902
  * ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
34415
34903
  * - `bb-colorize-pattern-red`
@@ -36472,7 +36960,9 @@ class Element {
36472
36960
  x: null,
36473
36961
  y: null,
36474
36962
  y2: null,
36475
- subX: null
36963
+ subX: null,
36964
+ subY: null,
36965
+ subY2: null
36476
36966
  },
36477
36967
  axisTooltip: {
36478
36968
  x: null,
@@ -36587,6 +37077,7 @@ class State {
36587
37077
  loading: void 0,
36588
37078
  // Zoom/subchart domain (different from current.domain which is for rendering)
36589
37079
  domain: void 0,
37080
+ subchartSourceTypes: void 0,
36590
37081
  current: {
36591
37082
  // current domain value. Assigned when is zoom is called
36592
37083
  domain: void 0,
@@ -37290,28 +37781,148 @@ function generateWait() {
37290
37781
  ;// ./src/module/worker.ts
37291
37782
 
37292
37783
  const cache = {};
37784
+ const disabledKeys = /* @__PURE__ */ new Set();
37785
+ const verifiedOps = /* @__PURE__ */ new Map();
37786
+ const DEFAULT_WORKER_TIMEOUT = 5e3;
37787
+ const VERIFY_SAMPLE_SIZE = 3;
37293
37788
  let messageId = 0;
37294
- function getOrCreateWorkerResources(fn, depsFn) {
37295
- var _a;
37296
- const fnString = fn.toString();
37297
- const depsString = (_a = depsFn == null ? void 0 : depsFn.map(String).join(";")) != null ? _a : "";
37298
- const key = (fnString + depsString).replace(/(function|[\s\W\n])/g, "").substring(0, 30);
37789
+ function getWorkerSrc() {
37790
+ try {
37791
+ 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})({});";
37792
+ } catch (e) {
37793
+ return "";
37794
+ }
37795
+ }
37796
+ function getWorkerAPI() {
37797
+ const { Blob, Worker, URL } = win;
37798
+ return Worker && Blob && (URL == null ? void 0 : URL.createObjectURL) && (URL == null ? void 0 : URL.revokeObjectURL) ? { Blob, Worker, URL } : null;
37799
+ }
37800
+ function getWorkerConstructor() {
37801
+ return win.Worker || null;
37802
+ }
37803
+ function normalizeWorkerOptions(options) {
37804
+ var _a, _b;
37805
+ return typeof options === "number" ? { timeout: options, workerUrl: "" } : {
37806
+ timeout: (_a = options == null ? void 0 : options.timeout) != null ? _a : DEFAULT_WORKER_TIMEOUT,
37807
+ workerUrl: (_b = options == null ? void 0 : options.workerUrl) != null ? _b : ""
37808
+ };
37809
+ }
37810
+ function releaseWorker(key, disable = false) {
37811
+ var _a, _b;
37812
+ const cached = cache[key];
37813
+ if (disable) {
37814
+ disabledKeys.add(key);
37815
+ }
37816
+ if (cached) {
37817
+ (_a = cached.worker) == null ? void 0 : _a.terminate();
37818
+ cached.revoke && ((_b = getWorkerAPI()) == null ? void 0 : _b.URL.revokeObjectURL(cached.src));
37819
+ delete cache[key];
37820
+ }
37821
+ for (const verified of verifiedOps.keys()) {
37822
+ if (verified.startsWith(`${key}:`)) {
37823
+ verifiedOps.delete(verified);
37824
+ }
37825
+ }
37826
+ }
37827
+ function isSameResult(actual, expected) {
37828
+ if (actual === expected) {
37829
+ return true;
37830
+ }
37831
+ try {
37832
+ return JSON.stringify(actual) === JSON.stringify(expected);
37833
+ } catch (e) {
37834
+ return true;
37835
+ }
37836
+ }
37837
+ function getVerifySample(args) {
37838
+ const [data, ...rest] = args;
37839
+ if (!Array.isArray(data)) {
37840
+ return args;
37841
+ }
37842
+ return [
37843
+ data.slice(0, VERIFY_SAMPLE_SIZE).map(
37844
+ (entry) => (
37845
+ // +1: a column/row entry leads with its name, which the values follow
37846
+ Array.isArray(entry) ? entry.slice(0, VERIFY_SAMPLE_SIZE + 1) : entry
37847
+ )
37848
+ ),
37849
+ ...rest
37850
+ ];
37851
+ }
37852
+ function request(worker, op, args, timeout) {
37853
+ const id = ++messageId;
37854
+ let settled = false;
37855
+ let cleanup;
37856
+ const promise = new Promise((resolve, reject) => {
37857
+ const settle = (fn, value) => {
37858
+ if (!settled) {
37859
+ settled = true;
37860
+ cleanup();
37861
+ fn(value);
37862
+ }
37863
+ };
37864
+ const handler = function(e) {
37865
+ var _a;
37866
+ if (((_a = e.data) == null ? void 0 : _a.id) === id) {
37867
+ e.data.error ? settle(reject, new Error(e.data.error)) : settle(resolve, e.data.result);
37868
+ }
37869
+ };
37870
+ const errorHandler = function() {
37871
+ settle(reject, new Error("worker error"));
37872
+ };
37873
+ const timer = setTimeout(() => settle(reject, new Error("worker timeout")), timeout);
37874
+ cleanup = () => {
37875
+ clearTimeout(timer);
37876
+ worker.removeEventListener("message", handler);
37877
+ worker.removeEventListener("error", errorHandler);
37878
+ };
37879
+ worker.addEventListener("message", handler);
37880
+ worker.addEventListener("error", errorHandler);
37881
+ });
37882
+ try {
37883
+ worker.postMessage({ args, id, op });
37884
+ } catch (error) {
37885
+ settled = true;
37886
+ cleanup();
37887
+ throw error;
37888
+ }
37889
+ return promise;
37890
+ }
37891
+ function startVerify(worker, verifyKey, op, fn, args, timeout) {
37892
+ const sample = getVerifySample(args);
37893
+ const check = request(worker, op, sample, timeout).then((result) => isSameResult(result, fn(...sample)), () => false).then((matched) => {
37894
+ matched ? verifiedOps.set(verifyKey, true) : verifiedOps.delete(verifyKey);
37895
+ return matched;
37896
+ });
37897
+ verifiedOps.set(verifyKey, check);
37898
+ return check;
37899
+ }
37900
+ function getOrCreateWorkerResources(op, workerUrl = "") {
37901
+ const hasWorker = !!getWorkerConstructor();
37902
+ const api = workerUrl ? null : getWorkerAPI();
37903
+ const src = workerUrl ? "" : getWorkerSrc();
37904
+ const key = workerUrl || "blob";
37905
+ if (!hasWorker || !workerUrl && (!api || !src) || disabledKeys.has(key)) {
37906
+ return null;
37907
+ }
37299
37908
  if (!(key in cache)) {
37300
37909
  try {
37301
- const blob = new win.Blob([
37302
- `${depsString}
37303
-
37304
- self.onmessage=function({data}) {
37305
- const result = (${fnString}).apply(null, data.args);
37306
- self.postMessage({id: data.id, result});
37307
- };`
37308
- ], {
37309
- type: "text/javascript"
37310
- });
37311
- cache[key] = {
37312
- src: win.URL.createObjectURL(blob),
37313
- worker: null
37314
- };
37910
+ if (workerUrl) {
37911
+ cache[key] = {
37912
+ revoke: false,
37913
+ src: workerUrl,
37914
+ worker: null
37915
+ };
37916
+ } else if (api) {
37917
+ const blob = new api.Blob([src], {
37918
+ type: "text/javascript"
37919
+ });
37920
+ cache[key] = {
37921
+ revoke: true,
37922
+ src: api.URL.createObjectURL(blob),
37923
+ worker: null
37924
+ };
37925
+ }
37315
37926
  } catch (e) {
37316
37927
  return null;
37317
37928
  }
@@ -37320,59 +37931,71 @@ function getOrCreateWorkerResources(fn, depsFn) {
37320
37931
  }
37321
37932
  function getWorker(key, src) {
37322
37933
  const cached = cache[key];
37323
- if (!cached) {
37934
+ const Worker = getWorkerConstructor();
37935
+ if (!cached || !Worker || disabledKeys.has(key)) {
37324
37936
  return null;
37325
37937
  }
37326
37938
  if (!cached.worker) {
37327
37939
  try {
37328
- cached.worker = new win.Worker(src);
37940
+ cached.worker = new Worker(src);
37329
37941
  } catch (e) {
37942
+ releaseWorker(key, true);
37330
37943
  return null;
37331
37944
  }
37332
- if (cached.worker) {
37333
- cached.worker.onerror = function(e) {
37334
- console.error ? console.error(e) : console.log(e);
37335
- };
37336
- }
37337
37945
  }
37338
37946
  return cached.worker;
37339
37947
  }
37340
- function runWorker(useWorker = true, fn, callback, depsFn) {
37341
- let runFn = function(...args) {
37948
+ function runWorker(useWorker = true, op, fn, callback, options) {
37949
+ const { timeout, workerUrl } = normalizeWorkerOptions(options);
37950
+ const runSync = function(...args) {
37342
37951
  const res = fn(...args);
37343
37952
  callback(res);
37344
37953
  };
37345
- if (win.Worker && useWorker) {
37346
- const workerResources = getOrCreateWorkerResources(fn, depsFn);
37347
- const worker = workerResources && getWorker(workerResources.key, workerResources.src);
37348
- if (worker) {
37954
+ let runFn = runSync;
37955
+ if (useWorker) {
37956
+ const workerResources = getOrCreateWorkerResources(op, workerUrl);
37957
+ const worker = workerResources ? getWorker(workerResources.key, workerResources.src) : null;
37958
+ if (worker && workerResources) {
37959
+ const { key } = workerResources;
37349
37960
  runFn = function(...args) {
37350
- const id = ++messageId;
37351
- const handler = function(e) {
37352
- var _a;
37353
- if (((_a = e.data) == null ? void 0 : _a.id) === id) {
37354
- worker.removeEventListener("message", handler);
37355
- callback(e.data.result);
37356
- }
37961
+ var _a;
37962
+ const fallback = () => {
37963
+ releaseWorker(key, true);
37964
+ runFn = runSync;
37965
+ runSync(...args);
37357
37966
  };
37358
- worker.addEventListener("message", handler);
37359
- worker.postMessage({ id, args });
37967
+ try {
37968
+ const verifyKey = `${key}:${op}`;
37969
+ const verified = (_a = verifiedOps.get(verifyKey)) != null ? _a : startVerify(worker, verifyKey, op, fn, args, timeout);
37970
+ request(worker, op, args, timeout).then((result) => {
37971
+ if (verified === true) {
37972
+ callback(result);
37973
+ } else {
37974
+ verified.then((matched) => matched ? callback(result) : fallback());
37975
+ }
37976
+ }, fallback);
37977
+ } catch (e) {
37978
+ fallback();
37979
+ }
37360
37980
  };
37361
37981
  }
37362
37982
  }
37363
37983
  return runFn;
37364
37984
  }
37365
37985
  function cleanupWorkers() {
37986
+ const api = getWorkerAPI();
37366
37987
  for (const key in cache) {
37367
37988
  const cached = cache[key];
37368
37989
  if (cached.worker) {
37369
37990
  cached.worker.terminate();
37370
37991
  }
37371
37992
  if (cached.src) {
37372
- win.URL.revokeObjectURL(cached.src);
37993
+ cached.revoke && (api == null ? void 0 : api.URL.revokeObjectURL(cached.src));
37373
37994
  }
37374
37995
  delete cache[key];
37375
37996
  }
37997
+ disabledKeys.clear();
37998
+ verifiedOps.clear();
37376
37999
  }
37377
38000
 
37378
38001
  ;// ./src/module/dsv.ts
@@ -37611,6 +38234,19 @@ function convert_helper_tsv(tsv2) {
37611
38234
 
37612
38235
 
37613
38236
 
38237
+ const WORKER_CELL_THRESHOLD = 5e3;
38238
+ function _getCellCount(data) {
38239
+ var _a, _b;
38240
+ const first = data[0];
38241
+ if (isArray(first)) {
38242
+ let count = 0;
38243
+ for (let i = 0, len = data.length; i < len; i++) {
38244
+ count += (_b = (_a = data[i]) == null ? void 0 : _a.length) != null ? _b : 0;
38245
+ }
38246
+ return count;
38247
+ }
38248
+ return data.length * Object.keys(first != null ? first : {}).length;
38249
+ }
37614
38250
  function _getDataKeyForJson(keysParam, config) {
37615
38251
  const keys = keysParam || (config == null ? void 0 : config.data_keys);
37616
38252
  if (keys == null ? void 0 : keys.x) {
@@ -37656,7 +38292,15 @@ function _setXS(ids, data, params) {
37656
38292
  */
37657
38293
  convertData(args, callback) {
37658
38294
  const { config } = this;
37659
- const useWorker = (d) => (d == null ? void 0 : d.length) && !isEmpty(d[0]) ? config.boost_useWorker : false;
38295
+ const useWorker = (d) => {
38296
+ if (!(d == null ? void 0 : d.length) || isEmpty(d[0])) {
38297
+ return false;
38298
+ }
38299
+ return config.boost_useWorker === "auto" ? _getCellCount(d) >= WORKER_CELL_THRESHOLD : !!config.boost_useWorker;
38300
+ };
38301
+ const workerOptions = config.boost_workerUrl ? {
38302
+ workerUrl: config.boost_workerUrl
38303
+ } : void 0;
37660
38304
  let data = args;
37661
38305
  if (args.bindto) {
37662
38306
  data = {};
@@ -37676,14 +38320,16 @@ function _setXS(ids, data, params) {
37676
38320
  callback
37677
38321
  );
37678
38322
  } else if (data.json) {
37679
- runWorker(useWorker(data.json), json, callback, [columns, rows])(
38323
+ runWorker(useWorker(data.json), "json", json, callback, workerOptions)(
37680
38324
  data.json,
37681
38325
  _getDataKeyForJson(data.keys, config)
37682
38326
  );
37683
38327
  } else if (data.rows) {
37684
- runWorker(useWorker(data.rows), rows, callback)(data.rows);
38328
+ runWorker(useWorker(data.rows), "rows", rows, callback, workerOptions)(data.rows);
37685
38329
  } else if (data.columns) {
37686
- runWorker(useWorker(data.columns), columns, callback)(data.columns);
38330
+ runWorker(useWorker(data.columns), "columns", columns, callback, workerOptions)(
38331
+ data.columns
38332
+ );
37687
38333
  } else if (args.bindto) {
37688
38334
  throw Error("url or json or rows or columns is required.");
37689
38335
  }
@@ -37800,10 +38446,14 @@ function _setXS(ids, data, params) {
37800
38446
 
37801
38447
 
37802
38448
 
38449
+
37803
38450
  const rangedDataKeyIndex = {
37804
38451
  areaRange: { high: 0, mid: 1, low: 2 },
37805
38452
  candlestick: { open: 0, high: 1, low: 2, close: 3, volume: 4 }
37806
38453
  };
38454
+ function normalizeTargetIds(targetIds) {
38455
+ return isArray(targetIds) ? targetIds : [targetIds];
38456
+ }
37807
38457
  /* harmony default export */ var ChartInternal_data_data = ({
37808
38458
  isX(key) {
37809
38459
  const $$ = this;
@@ -38240,8 +38890,7 @@ const rangedDataKeyIndex = {
38240
38890
  */
38241
38891
  addTargetIds(type, targetIds) {
38242
38892
  const { state } = this;
38243
- const ids = isArray(targetIds) ? targetIds : [targetIds];
38244
- ids.forEach((v) => state[type].add(v));
38893
+ normalizeTargetIds(targetIds).forEach((v) => state[type].add(v));
38245
38894
  },
38246
38895
  /**
38247
38896
  * Remove from the state target Ids
@@ -38251,8 +38900,7 @@ const rangedDataKeyIndex = {
38251
38900
  */
38252
38901
  removeTargetIds(type, targetIds) {
38253
38902
  const { state } = this;
38254
- const ids = isArray(targetIds) ? targetIds : [targetIds];
38255
- ids.forEach((v) => state[type].delete(v));
38903
+ normalizeTargetIds(targetIds).forEach((v) => state[type].delete(v));
38256
38904
  },
38257
38905
  addHiddenTargetIds(targetIds) {
38258
38906
  this.addTargetIds("hiddenTargetIds", targetIds);
@@ -38651,7 +39299,9 @@ const rangedDataKeyIndex = {
38651
39299
  const yIndex = +!isRotated;
38652
39300
  const y = $$.circleY(data, data.index);
38653
39301
  const x = (scale.zoom || scale.x)(data.x);
38654
- return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
39302
+ const dx = x - pos[xIndex];
39303
+ const dy = y - pos[yIndex];
39304
+ return Math.sqrt(dx * dx + dy * dy);
38655
39305
  },
38656
39306
  /**
38657
39307
  * Convert data for step type
@@ -38847,9 +39497,10 @@ const rangedDataKeyIndex = {
38847
39497
  * @private
38848
39498
  */
38849
39499
  isBarRangeType(d) {
39500
+ var _a;
38850
39501
  const $$ = this;
38851
39502
  const { value } = d;
38852
- return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(isNumber);
39503
+ return $$.isBarType(d) && !((_a = $$.isSubchartSourceTypeOf) == null ? void 0 : _a.call($$, d, TYPE.CANDLESTICK)) && isArray(value) && value.length >= 2 && value.every(isNumber);
38853
39504
  },
38854
39505
  /**
38855
39506
  * Get data object by id
@@ -39661,107 +40312,12 @@ const RE_SELECTOR_SUFFIX = /[\x00-\x20\x7F-\xA0\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`
39661
40312
  }
39662
40313
  });
39663
40314
 
39664
- ;// ./node_modules/.pnpm/internmap@2.0.3/node_modules/internmap/src/index.js
39665
- class InternMap extends Map {
39666
- constructor(entries, key = keyof) {
39667
- super();
39668
- Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
39669
- if (entries != null) for (const [key2, value] of entries) this.set(key2, value);
39670
- }
39671
- get(key) {
39672
- return super.get(intern_get(this, key));
39673
- }
39674
- has(key) {
39675
- return super.has(intern_get(this, key));
39676
- }
39677
- set(key, value) {
39678
- return super.set(intern_set(this, key), value);
39679
- }
39680
- delete(key) {
39681
- return super.delete(intern_delete(this, key));
39682
- }
39683
- }
39684
- class InternSet extends Set {
39685
- constructor(values, key = keyof) {
39686
- super();
39687
- Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: key } });
39688
- if (values != null) for (const value of values) this.add(value);
39689
- }
39690
- has(value) {
39691
- return super.has(intern_get(this, value));
39692
- }
39693
- add(value) {
39694
- return super.add(intern_set(this, value));
39695
- }
39696
- delete(value) {
39697
- return super.delete(intern_delete(this, value));
39698
- }
39699
- }
39700
- function intern_get({ _intern, _key }, value) {
39701
- const key = _key(value);
39702
- return _intern.has(key) ? _intern.get(key) : value;
39703
- }
39704
- function intern_set({ _intern, _key }, value) {
39705
- const key = _key(value);
39706
- if (_intern.has(key)) return _intern.get(key);
39707
- _intern.set(key, value);
39708
- return value;
39709
- }
39710
- function intern_delete({ _intern, _key }, value) {
39711
- const key = _key(value);
39712
- if (_intern.has(key)) {
39713
- value = _intern.get(key);
39714
- _intern.delete(key);
39715
- }
39716
- return value;
39717
- }
39718
- function keyof(value) {
39719
- return value !== null && typeof value === "object" ? value.valueOf() : value;
39720
- }
39721
-
39722
- ;// ./node_modules/.pnpm/d3-scale@4.0.2/node_modules/d3-scale/src/ordinal.js
39723
-
39724
-
39725
- const implicit = /* @__PURE__ */ Symbol("implicit");
39726
- function ordinal() {
39727
- var index = new InternMap(), domain = [], range = [], unknown = implicit;
39728
- function scale(d) {
39729
- let i = index.get(d);
39730
- if (i === void 0) {
39731
- if (unknown !== implicit) return unknown;
39732
- index.set(d, i = domain.push(d) - 1);
39733
- }
39734
- return range[i % range.length];
39735
- }
39736
- scale.domain = function(_) {
39737
- if (!arguments.length) return domain.slice();
39738
- domain = [], index = new InternMap();
39739
- for (const value of _) {
39740
- if (index.has(value)) continue;
39741
- index.set(value, domain.push(value) - 1);
39742
- }
39743
- return scale;
39744
- };
39745
- scale.range = function(_) {
39746
- return arguments.length ? (range = Array.from(_), scale) : range.slice();
39747
- };
39748
- scale.unknown = function(_) {
39749
- return arguments.length ? (unknown = _, scale) : unknown;
39750
- };
39751
- scale.copy = function() {
39752
- return ordinal(domain, range).unknown(unknown);
39753
- };
39754
- initRange.apply(scale, arguments);
39755
- return scale;
39756
- }
39757
-
39758
40315
  ;// ./src/ChartInternal/internals/color.ts
39759
40316
 
39760
40317
 
39761
40318
 
39762
40319
 
39763
40320
 
39764
-
39765
40321
  const _colorizePattern = (pattern, color, id) => {
39766
40322
  const node = src_select(pattern.cloneNode(true));
39767
40323
  node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
@@ -39803,7 +40359,7 @@ const schemeCategory10 = [
39803
40359
  const { $el, config } = $$;
39804
40360
  const ids = [];
39805
40361
  const hasGradient = config.area_linearGradient || config.bar_linearGradient || config.point_radialGradient;
39806
- let pattern = notEmpty(config.color_pattern) ? config.color_pattern : ordinal(_getColorFromCss($el.chart) || schemeCategory10).range();
40362
+ let pattern = notEmpty(config.color_pattern) ? config.color_pattern : [..._getColorFromCss($el.chart) || schemeCategory10];
39807
40363
  const originalColorPattern = pattern;
39808
40364
  if (isFunction(config.color_tiles)) {
39809
40365
  const tiles = config.color_tiles.bind($$.api)();
@@ -39896,8 +40452,9 @@ const schemeCategory10 = [
39896
40452
  const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${isString(color) ? $$.getTargetSelectorSuffix(color) : ""}`;
39897
40453
  const colorValue = sanitize(v === "" ? color : (color == null ? void 0 : color[v]) || "");
39898
40454
  if (defs.select(`#${id}`).empty()) {
39899
- 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}" />
39900
- <feComposite in="SourceGraphic" />`);
40455
+ const filter = defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id);
40456
+ filter.append("feFlood").attr("flood-color", colorValue);
40457
+ filter.append("feComposite").attr("in", "SourceGraphic");
39901
40458
  }
39902
40459
  });
39903
40460
  }
@@ -41504,13 +42061,15 @@ function brushEmpty(ctx) {
41504
42061
 
41505
42062
  function getTargetDomainCacheKey($$, targets) {
41506
42063
  return targets.map((target) => {
41507
- var _a, _b, _c, _d;
42064
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
41508
42065
  const { values } = target;
41509
42066
  const first = values[0];
41510
42067
  const last = values[values.length - 1];
41511
42068
  const firstX = first ? (_b = (_a = $$.getXCacheKey) == null ? void 0 : _a.call($$, first.x)) != null ? _b : first.x : "";
41512
42069
  const lastX = last ? (_d = (_c = $$.getXCacheKey) == null ? void 0 : _c.call($$, last.x)) != null ? _d : last.x : "";
41513
- return `${target.id}:${values.length}:${firstX}:${lastX}`;
42070
+ const targetType = (_f = (_e = $$.getTargetType) == null ? void 0 : _e.call($$, target)) != null ? _f : "";
42071
+ const sourceType = (_i = (_h = (_g = $$.state) == null ? void 0 : _g.subchartSourceTypes) == null ? void 0 : _h[target.id]) != null ? _i : "";
42072
+ return `${target.id}:${targetType}:${sourceType}:${values.length}:${firstX}:${lastX}`;
41514
42073
  }).join("|");
41515
42074
  }
41516
42075
  function canCacheTargetDomain($$, targets) {
@@ -41545,12 +42104,13 @@ function updateMinMaxFromValues(minMax, values) {
41545
42104
  }
41546
42105
  }
41547
42106
  function getTargetValueMinMax($$, targets) {
41548
- var _a, _b;
42107
+ var _a, _b, _c, _d;
41549
42108
  const minMax = { min: void 0, max: void 0 };
41550
42109
  const hasAxis = $$.state.hasAxis;
41551
42110
  for (let i = 0; i < targets.length; i++) {
41552
42111
  const target = targets[i];
41553
42112
  const isCandlestick = (_a = $$.isCandlestickType) == null ? void 0 : _a.call($$, target);
42113
+ const isSubchartCandlestick = !isCandlestick && !!((_b = $$.isSubchartSourceTypeOf) == null ? void 0 : _b.call($$, target, TYPE.CANDLESTICK));
41554
42114
  const { values } = target;
41555
42115
  for (let j = 0; j < values.length; j++) {
41556
42116
  const row = values[j];
@@ -41558,14 +42118,17 @@ function getTargetValueMinMax($$, targets) {
41558
42118
  if (!(isValue(value) || value === null)) {
41559
42119
  continue;
41560
42120
  }
41561
- if (value !== null && isCandlestick) {
42121
+ const subchartCandlestickValue = isSubchartCandlestick ? (_c = $$.getSubchartCandlestickShapeValue) == null ? void 0 : _c.call($$, row, true) : void 0;
42122
+ if (isNumber(subchartCandlestickValue)) {
42123
+ value = subchartCandlestickValue;
42124
+ } else if (value !== null && (isCandlestick || isSubchartCandlestick)) {
41562
42125
  value = Array.isArray(value) ? value.slice(0, 4) : [value.open, value.high, value.low, value.close];
41563
42126
  }
41564
42127
  if (Array.isArray(value)) {
41565
42128
  updateMinMaxFromValues(minMax, value);
41566
42129
  } else if (isObject(value) && "high" in value) {
41567
42130
  updateMinMaxFromValues(minMax, Object.values(value));
41568
- } else if ((_b = $$.isBubbleZType) == null ? void 0 : _b.call($$, row)) {
42131
+ } else if ((_d = $$.isBubbleZType) == null ? void 0 : _d.call($$, row)) {
41569
42132
  updateMinMax(minMax, hasAxis && $$.getBubbleZData(value, "y"));
41570
42133
  } else {
41571
42134
  updateMinMax(minMax, value);
@@ -41592,7 +42155,7 @@ function getTargetXMinMax(targets, type) {
41592
42155
  * Get both min and max Y domain values in a single pass.
41593
42156
  * Avoids calling getValuesAsIdKeyed twice.
41594
42157
  * @param {Array} targets Target data
41595
- * @returns {[number|Date|undefined, number|Date|undefined]} [min, max]
42158
+ * @returns {Array.<number|Date|undefined>} [min, max]
41596
42159
  * @private
41597
42160
  */
41598
42161
  getYDomainMinMaxBoth(targets) {
@@ -44042,14 +44605,24 @@ function batchGetBBox(elements) {
44042
44605
  const filteredTextNodes = textNodes.filter((node) => node.data.id !== id);
44043
44606
  const textNode = textNodes.filter((node) => node.data.id === id);
44044
44607
  const translate = getTranslation(textNode.node());
44045
- const calcHypo = (x, y) => Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
44046
- textNode.node() && filteredTextNodes.each(function() {
44608
+ const calcHypo = (x, y) => Math.sqrt(x * x + y * y);
44609
+ if (!textNode.node()) {
44610
+ return;
44611
+ }
44612
+ const fontSize = parseInt(textNode.style("font-size"), 10);
44613
+ const overlapStates = [];
44614
+ filteredTextNodes.each(function() {
44047
44615
  const coordinate = getTranslation(this);
44048
- const filteredTextNode = src_select(this);
44049
- const nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : filteredTextNode;
44616
+ const nodeForWidth = calcHypo(translate.e, translate.f) > calcHypo(coordinate.e, coordinate.f) ? textNode : src_select(this);
44050
44617
  const overlapsX = Math.ceil(Math.abs(translate.e - coordinate.e)) < Math.ceil(nodeForWidth.node().getComputedTextLength());
44051
- const overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < parseInt(textNode.style("font-size"), 10);
44052
- filteredTextNode.classed($TEXT.TextOverlapping, overlapsX && overlapsY);
44618
+ const overlapsY = Math.ceil(Math.abs(translate.f - coordinate.f)) < fontSize;
44619
+ overlapStates.push({
44620
+ node: this,
44621
+ overlaps: overlapsX && overlapsY
44622
+ });
44623
+ });
44624
+ overlapStates.forEach(({ node, overlaps }) => {
44625
+ src_select(node).classed($TEXT.TextOverlapping, overlaps);
44053
44626
  });
44054
44627
  },
44055
44628
  /**
@@ -44733,6 +45306,12 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
44733
45306
  } else if (target === "subX") {
44734
45307
  x = 0;
44735
45308
  y = isRotated ? 0 : state.height2;
45309
+ } else if (target === "subY") {
45310
+ x = 0;
45311
+ y = isRotated ? state.height2 : 0;
45312
+ } else if (target === "subY2") {
45313
+ x = isRotated ? 0 : state.width2;
45314
+ y = isRotated ? -1 : 0;
44736
45315
  } else if (target === "arc") {
44737
45316
  x = state.arcWidth / 2;
44738
45317
  y = state.arcHeight / 2;
@@ -44776,6 +45355,23 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
44776
45355
  ;// ./src/ChartInternal/internals/type.ts
44777
45356
 
44778
45357
 
45358
+ const INTERPOLATION_TYPES = /* @__PURE__ */ new Set([
45359
+ "basis",
45360
+ "basis-closed",
45361
+ "basis-open",
45362
+ "bundle",
45363
+ "cardinal",
45364
+ "cardinal-closed",
45365
+ "cardinal-open",
45366
+ "catmull-rom",
45367
+ "catmull-rom-closed",
45368
+ "catmull-rom-open",
45369
+ "linear",
45370
+ "linear-closed",
45371
+ "monotone-x",
45372
+ "monotone-y",
45373
+ "natural"
45374
+ ]);
44779
45375
  /* harmony default export */ var internals_type = ({
44780
45376
  /**
44781
45377
  * Check if the given chart type is valid
@@ -44786,6 +45382,96 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
44786
45382
  isValidChartType(type) {
44787
45383
  return !!(type && Object.values(TYPE).indexOf(type) > -1);
44788
45384
  },
45385
+ /**
45386
+ * Get the chart type to use for the subchart target.
45387
+ * subchart.types > subchart.type > data.types > data.type > line
45388
+ * @param {object|string} d Target data or id
45389
+ * @returns {string}
45390
+ * @private
45391
+ */
45392
+ getSubchartTargetType(d) {
45393
+ const $$ = this;
45394
+ const { config } = $$;
45395
+ const id = isString(d) ? d : d == null ? void 0 : d.id;
45396
+ const subchartTypes = config.subchart_types || {};
45397
+ const subchartType = config.subchart_type;
45398
+ const dataTypes = config.data_types || {};
45399
+ const targetSubchartType = id && subchartTypes[id];
45400
+ if (targetSubchartType && $$.isValidChartType(targetSubchartType)) {
45401
+ return targetSubchartType;
45402
+ } else if (subchartType && $$.isValidChartType(subchartType)) {
45403
+ return subchartType;
45404
+ }
45405
+ return id && dataTypes[id] || config.data_type || TYPE.LINE;
45406
+ },
45407
+ /**
45408
+ * Get the regular chart type configured for the target.
45409
+ * @param {object|string} d Target data or id
45410
+ * @returns {string}
45411
+ * @private
45412
+ */
45413
+ getTargetType(d) {
45414
+ var _a;
45415
+ const { config } = this;
45416
+ const id = isString(d) ? d : d == null ? void 0 : d.id;
45417
+ return id && ((_a = config.data_types) == null ? void 0 : _a[id]) || config.data_type || TYPE.LINE;
45418
+ },
45419
+ /**
45420
+ * Get the target's original chart type while subchart.type context is active.
45421
+ * @param {object|string} d Target data or id
45422
+ * @returns {string}
45423
+ * @private
45424
+ */
45425
+ getSubchartSourceTargetType(d) {
45426
+ const { state } = this;
45427
+ const id = isString(d) ? d : d == null ? void 0 : d.id;
45428
+ const sourceTypes = state.subchartSourceTypes;
45429
+ return id && (sourceTypes == null ? void 0 : sourceTypes[id]) || this.getTargetType(d);
45430
+ },
45431
+ /**
45432
+ * Check whether a target had the given source type before subchart.type remapping.
45433
+ * @param {object|string} d Target data or id
45434
+ * @param {string|Array} type chart type
45435
+ * @returns {boolean}
45436
+ * @private
45437
+ */
45438
+ isSubchartSourceTypeOf(d, type) {
45439
+ const sourceType = this.getSubchartSourceTargetType(d);
45440
+ return isArray(type) ? type.indexOf(sourceType) >= 0 : sourceType === type;
45441
+ },
45442
+ /**
45443
+ * Run a callback while regular type helpers resolve using subchart.type/types.
45444
+ * @param {function(): unknown} callback Callback to run
45445
+ * @returns {unknown} Callback return value
45446
+ * @private
45447
+ */
45448
+ withSubchartTypeContext(callback) {
45449
+ const $$ = this;
45450
+ const { config, data, state } = $$;
45451
+ const dataType = config.data_type;
45452
+ const dataTypes = config.data_types;
45453
+ const currentTypes = state.current.types;
45454
+ const sourceTypes = state.subchartSourceTypes;
45455
+ const subchartTypes = {};
45456
+ const subchartSourceTypes = {};
45457
+ const subchartType = config.subchart_type;
45458
+ $$.mapToIds(data.targets).forEach((id) => {
45459
+ subchartSourceTypes[id] = $$.getTargetType(id);
45460
+ subchartTypes[id] = $$.getSubchartTargetType(id);
45461
+ });
45462
+ config.data_type = subchartType && $$.isValidChartType(subchartType) ? subchartType : dataType;
45463
+ config.data_types = subchartTypes;
45464
+ state.current.types = [];
45465
+ state.subchartSourceTypes = subchartSourceTypes;
45466
+ try {
45467
+ return callback();
45468
+ } finally {
45469
+ config.data_type = dataType;
45470
+ config.data_types = dataTypes;
45471
+ state.current.types = currentTypes;
45472
+ state.subchartSourceTypes = sourceTypes;
45473
+ }
45474
+ },
44789
45475
  setTargetType(targetIds, type) {
44790
45476
  const $$ = this;
44791
45477
  const { config, state: { withoutFadeIn } } = $$;
@@ -44830,26 +45516,17 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
44830
45516
  const { config, state: { current } } = $$;
44831
45517
  const types = config.data_types;
44832
45518
  const targets = targetsValue || $$.data.targets;
44833
- let has = false;
44834
45519
  if (!checkFromData && ((_a = current.types) == null ? void 0 : _a.indexOf(type)) > -1) {
44835
- has = true;
45520
+ return true;
44836
45521
  } else if (targets == null ? void 0 : targets.length) {
44837
- targets.forEach((target) => {
45522
+ return targets.some((target) => {
44838
45523
  const t = types[target.id];
44839
- if (t === type || !t && type === "line") {
44840
- has = true;
44841
- }
45524
+ return t === type || !t && type === "line";
44842
45525
  });
44843
45526
  } else if (Object.keys(types).length) {
44844
- Object.keys(types).forEach((id) => {
44845
- if (types[id] === type) {
44846
- has = true;
44847
- }
44848
- });
44849
- } else {
44850
- has = config.data_type === type;
45527
+ return Object.values(types).some((t) => t === type);
44851
45528
  }
44852
- return has;
45529
+ return config.data_type === type;
44853
45530
  },
44854
45531
  /**
44855
45532
  * Check if contains given chart types
@@ -44873,9 +45550,8 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
44873
45550
  * @private
44874
45551
  */
44875
45552
  isTypeOf(d, type) {
44876
- var _a;
44877
45553
  const id = isString(d) ? d : d.id;
44878
- const dataType = this.config && (((_a = this.config.data_types) == null ? void 0 : _a[id]) || this.config.data_type);
45554
+ const dataType = this.config && this.getTargetType(id);
44879
45555
  return isArray(type) ? type.indexOf(dataType) >= 0 : dataType === type;
44880
45556
  },
44881
45557
  hasPointType() {
@@ -44972,25 +45648,8 @@ const RE_TOOLTIP_TPL = /{{(.*)}}/;
44972
45648
  barLineBubbleData(d) {
44973
45649
  return this.isBarType(d) || this.isLineType(d) || this.isBubbleType(d) ? d.values : [];
44974
45650
  },
44975
- // https://github.com/d3/d3-shape#curves
44976
45651
  isInterpolationType(type) {
44977
- return [
44978
- "basis",
44979
- "basis-closed",
44980
- "basis-open",
44981
- "bundle",
44982
- "cardinal",
44983
- "cardinal-closed",
44984
- "cardinal-open",
44985
- "catmull-rom",
44986
- "catmull-rom-closed",
44987
- "catmull-rom-open",
44988
- "linear",
44989
- "linear-closed",
44990
- "monotone-x",
44991
- "monotone-y",
44992
- "natural"
44993
- ].indexOf(type) >= 0;
45652
+ return INTERPOLATION_TYPES.has(type);
44994
45653
  }
44995
45654
  });
44996
45655
 
@@ -45878,6 +46537,7 @@ function stepAfter(context) {
45878
46537
 
45879
46538
 
45880
46539
 
46540
+
45881
46541
  const CURVE_MAP = {
45882
46542
  basis: curve_basis,
45883
46543
  "basis-closed": curve_basisClosed,
@@ -45905,13 +46565,48 @@ function isLinePointGroupType($$, d) {
45905
46565
  function getLinePointGroupTypeFilter($$) {
45906
46566
  return (d) => isLinePointGroupType($$, d);
45907
46567
  }
45908
- function getShapeOffsetValue($$, d) {
46568
+ function getShapeOffsetValue($$, d, isSub) {
45909
46569
  var _a, _b, _c;
46570
+ const subchartCandlestickValue = isSub ? getSubchartCandlestickShapeValue($$, d, isSub) : void 0;
46571
+ if (isNumber(subchartCandlestickValue)) {
46572
+ return subchartCandlestickValue;
46573
+ }
45910
46574
  if ((_a = $$.isCandlestickType) == null ? void 0 : _a.call($$, d)) {
45911
46575
  return (_c = (_b = $$.getCandlestickData) == null ? void 0 : _b.call($$, d)) == null ? void 0 : _c.close;
45912
46576
  }
45913
46577
  return $$.getBaseValue(d);
45914
46578
  }
46579
+ function getSubchartCandlestickShapeValue($$, d, isSub) {
46580
+ var _a, _b, _c;
46581
+ if (!isSub || ((_a = $$.isCandlestickType) == null ? void 0 : _a.call($$, d)) || !((_b = $$.isSubchartSourceTypeOf) == null ? void 0 : _b.call($$, d, TYPE.CANDLESTICK))) {
46582
+ return void 0;
46583
+ }
46584
+ const value = (_c = $$.getCandlestickData) == null ? void 0 : _c.call($$, d);
46585
+ if (!value) {
46586
+ return void 0;
46587
+ }
46588
+ if ($$.isBarType(d)) {
46589
+ return isNumber(value.open) && isNumber(value.close) ? value._isUp ? value.close : value.open : void 0;
46590
+ }
46591
+ return isNumber(value.close) ? value.close : void 0;
46592
+ }
46593
+ function isSubchartCandlestickBarValue($$, d, isSub) {
46594
+ const value = getSubchartCandlestickShapeValue($$, d, isSub);
46595
+ return isNumber(value) && $$.isBarType(d);
46596
+ }
46597
+ function getSubchartCandlestickBarColor($$, d, isSub) {
46598
+ var _a;
46599
+ if (!isSubchartCandlestickBarValue($$, d, isSub)) {
46600
+ return null;
46601
+ }
46602
+ const value = (_a = $$.getCandlestickData) == null ? void 0 : _a.call($$, d);
46603
+ if (value == null ? void 0 : value._isUp) {
46604
+ return $$.color(d);
46605
+ }
46606
+ const downColor = $$.config.candlestick_color_down;
46607
+ const color = downColor && typeof downColor === "object" ? downColor[d.id] : downColor;
46608
+ return color || $$.color(d);
46609
+ }
45915
46610
  function _getGroupedDataPointsFn(d) {
45916
46611
  var _a, _b;
45917
46612
  const $$ = this;
@@ -46140,8 +46835,11 @@ function updateTargetsForShape(targets, config) {
46140
46835
  const isStackNormalized = $$.isStackNormalized();
46141
46836
  return (d) => {
46142
46837
  let { value } = d;
46838
+ const subchartCandlestickValue = isSub ? getSubchartCandlestickShapeValue($$, d, isSub) : void 0;
46143
46839
  if (isNumber(d)) {
46144
46840
  value = d;
46841
+ } else if (isNumber(subchartCandlestickValue)) {
46842
+ value = subchartCandlestickValue;
46145
46843
  } else if ($$.isAreaRangeType(d)) {
46146
46844
  value = $$.getBaseValue(d, "mid");
46147
46845
  } else if (isStackNormalized) {
@@ -46157,13 +46855,14 @@ function updateTargetsForShape(targets, config) {
46157
46855
  /**
46158
46856
  * Get shape based y Axis min value
46159
46857
  * @param {string} id Data id
46858
+ * @param {boolean} isSub Whether to use subchart scale
46160
46859
  * @returns {number}
46161
46860
  * @private
46162
46861
  */
46163
- getShapeYMin(id) {
46862
+ getShapeYMin(id, isSub = false) {
46164
46863
  const $$ = this;
46165
46864
  const axisId = $$.axis.getId(id);
46166
- const scale = $$.scale[axisId];
46865
+ const scale = $$.getYScaleById(id, isSub);
46167
46866
  const [yMin] = scale.domain();
46168
46867
  const inverted = $$.config[`axis_${axisId}_inverted`];
46169
46868
  return !$$.isGrouped(id) && !inverted && yMin > 0 ? yMin : 0;
@@ -46171,17 +46870,18 @@ function updateTargetsForShape(targets, config) {
46171
46870
  /**
46172
46871
  * Get Shape's offset data
46173
46872
  * @param {function} typeFilter Type filter function
46873
+ * @param {boolean} isSub Whether coordinates are for the subchart
46174
46874
  * @returns {object}
46175
46875
  * @private
46176
46876
  */
46177
- getShapeOffsetData(typeFilter) {
46877
+ getShapeOffsetData(typeFilter, isSub) {
46178
46878
  const $$ = this;
46179
46879
  const targets = $$.orderTargets(
46180
46880
  $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
46181
46881
  );
46182
46882
  const dataGeneration = $$.state.dataGeneration;
46183
46883
  const targetIds = targets.map((t) => t.id).join("_");
46184
- const cacheKey = `${KEY.shapeOffset}_${targetIds}`;
46884
+ const cacheKey = `${KEY.shapeOffset}_${isSub ? "sub" : "main"}_${targetIds}`;
46185
46885
  const cachedData = $$.cache.get(cacheKey);
46186
46886
  if ((cachedData == null ? void 0 : cachedData.generation) === dataGeneration) {
46187
46887
  return cachedData;
@@ -46195,7 +46895,7 @@ function updateTargetsForShape(targets, config) {
46195
46895
  }
46196
46896
  const rowValueMapByXValue = rowValues.reduce((out, d) => {
46197
46897
  const key = Number(d.x);
46198
- const value = getShapeOffsetValue($$, d);
46898
+ const value = getShapeOffsetValue($$, d, isSub);
46199
46899
  out[key] = d;
46200
46900
  values[key] = isStackNormalized ? $$.getRatio("index", d, true) : value;
46201
46901
  return out;
@@ -46218,7 +46918,8 @@ function updateTargetsForShape(targets, config) {
46218
46918
  getShapeOffset(typeFilter, indices, isSub) {
46219
46919
  const $$ = this;
46220
46920
  const { shapeOffsetTargets, indexMapByTargetId } = $$.getShapeOffsetData(
46221
- typeFilter
46921
+ typeFilter,
46922
+ isSub
46222
46923
  );
46223
46924
  const groupsZeroAs = $$.config.data_groupsZeroAs;
46224
46925
  let sameGroupByTargetId = null;
@@ -46237,14 +46938,14 @@ function updateTargetsForShape(targets, config) {
46237
46938
  return (d, idx) => {
46238
46939
  var _a;
46239
46940
  const { id, value, x } = d;
46240
- const baseValue = getShapeOffsetValue($$, d);
46941
+ const baseValue = getShapeOffsetValue($$, d, isSub);
46241
46942
  const ind = $$.getIndices(indices, d);
46242
46943
  const scale = $$.getYScaleById(id, isSub);
46243
46944
  if ($$.isBarRangeType(d)) {
46244
46945
  return scale(value[0]);
46245
46946
  }
46246
46947
  const dataXAsNumber = Number(x);
46247
- const y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id));
46948
+ const y0 = scale(groupsZeroAs === "zero" ? 0 : $$.getShapeYMin(id, isSub));
46248
46949
  let offset = y0;
46249
46950
  const sameGroupTargets = (_a = sameGroupByTargetId == null ? void 0 : sameGroupByTargetId.get(id)) != null ? _a : shapeOffsetTargets.filter((t) => t.id !== id && ind[t.id] === ind[id]);
46250
46951
  for (const t of sameGroupTargets) {
@@ -46260,7 +46961,7 @@ function updateTargetsForShape(targets, config) {
46260
46961
  if (!row || Number(row.x) !== dataXAsNumber) {
46261
46962
  row = rowValueMapByXValue[dataXAsNumber];
46262
46963
  }
46263
- const rowValue = row && getShapeOffsetValue($$, row);
46964
+ const rowValue = row && getShapeOffsetValue($$, row, isSub);
46264
46965
  if (isNumber(rowValue) && isNumber(baseValue) && rowValue * baseValue >= 0 && isNumber(rValue)) {
46265
46966
  const addOffset = baseValue === 0 ? groupsZeroAs === "positive" && rValue > 0 || groupsZeroAs === "negative" && rValue < 0 : true;
46266
46967
  if (addOffset) {
@@ -46287,8 +46988,13 @@ function updateTargetsForShape(targets, config) {
46287
46988
  const y = $$.getShapeY(isSub);
46288
46989
  const lineOffset = $$.getShapeOffset(typeFilter || $$.isLineType, lineIndices, isSub);
46289
46990
  const yScale = $$.getYScaleById.bind($$);
46991
+ const y0Cache = /* @__PURE__ */ new Map();
46290
46992
  return (d, i) => {
46291
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
46993
+ let y0 = y0Cache.get(d.id);
46994
+ if (y0 === void 0) {
46995
+ y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id, isSub));
46996
+ y0Cache.set(d.id, y0);
46997
+ }
46292
46998
  const offset = lineOffset(d, i) || y0;
46293
46999
  const posX = x(d);
46294
47000
  let posY = y(d);
@@ -46318,8 +47024,13 @@ function updateTargetsForShape(targets, config) {
46318
47024
  const y = $$.getShapeY(!!isSub);
46319
47025
  const areaOffset = $$.getShapeOffset($$.isAreaType, areaIndices, isSub);
46320
47026
  const yScale = $$.getYScaleById.bind($$);
47027
+ const y0Cache = /* @__PURE__ */ new Map();
46321
47028
  return function(d, i) {
46322
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
47029
+ let y0 = y0Cache.get(d.id);
47030
+ if (y0 === void 0) {
47031
+ y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id, isSub));
47032
+ y0Cache.set(d.id, y0);
47033
+ }
46323
47034
  const offset = areaOffset(d, i) || y0;
46324
47035
  const posX = x(d);
46325
47036
  const value = d.value;
@@ -46352,12 +47063,20 @@ function updateTargetsForShape(targets, config) {
46352
47063
  const barY = $$.getShapeY(!!isSub);
46353
47064
  const barOffset = $$.getShapeOffset($$.isBarType, barIndices, !!isSub);
46354
47065
  const yScale = $$.getYScaleById.bind($$);
47066
+ const idCache = /* @__PURE__ */ new Map();
46355
47067
  return (d, i) => {
46356
47068
  const { id } = d;
46357
- const y0 = yScale.call($$, id, isSub)($$.getShapeYMin(id));
47069
+ let idInfo = idCache.get(id);
47070
+ if (!idInfo) {
47071
+ idInfo = {
47072
+ y0: yScale.call($$, id, isSub)($$.getShapeYMin(id, isSub)),
47073
+ isInverted: config[`axis_${$$.axis.getId(id)}_inverted`]
47074
+ };
47075
+ idCache.set(id, idInfo);
47076
+ }
47077
+ const { y0, isInverted } = idInfo;
46358
47078
  const offset = barOffset(d, i) || y0;
46359
47079
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
46360
- const isInverted = config[`axis_${$$.axis.getId(id)}_inverted`];
46361
47080
  const value = d.value;
46362
47081
  const posX = barX(d);
46363
47082
  let posY = barY(d);
@@ -46415,11 +47134,42 @@ function updateTargetsForShape(targets, config) {
46415
47134
  isSub,
46416
47135
  typeFilter
46417
47136
  );
47137
+ const y = $$.getShapeY(isSub);
46418
47138
  return (d, i) => {
46419
47139
  const id = d.id;
46420
- return $$.isGrouped(id) && isLinePointGroupType($$, d) ? getPoints(d, i)[0][1] : $$.getYScaleById(id, isSub)($$.getBaseValue(d));
47140
+ return $$.isGrouped(id) && isLinePointGroupType($$, d) ? getPoints(d, i)[0][1] : y(d);
46421
47141
  };
46422
47142
  },
47143
+ /**
47144
+ * Get candlestick data projected for alternate subchart shapes.
47145
+ * @param {object} d Data row
47146
+ * @param {boolean} isSub Whether coordinates are for the subchart
47147
+ * @returns {number|undefined} Projected value
47148
+ * @private
47149
+ */
47150
+ getSubchartCandlestickShapeValue(d, isSub) {
47151
+ return getSubchartCandlestickShapeValue(this, d, isSub);
47152
+ },
47153
+ /**
47154
+ * Check whether the row should be drawn as a candlestick-derived subchart bar.
47155
+ * @param {object} d Data row
47156
+ * @param {boolean} isSub Whether coordinates are for the subchart
47157
+ * @returns {boolean}
47158
+ * @private
47159
+ */
47160
+ isSubchartCandlestickBarValue(d, isSub) {
47161
+ return isSubchartCandlestickBarValue(this, d, isSub);
47162
+ },
47163
+ /**
47164
+ * Get subchart bar color projected from candlestick up/down state.
47165
+ * @param {object} d Data row
47166
+ * @param {boolean} isSub Whether coordinates are for the subchart
47167
+ * @returns {string|null} Bar color
47168
+ * @private
47169
+ */
47170
+ getSubchartCandlestickBarColor(d, isSub) {
47171
+ return getSubchartCandlestickBarColor(this, d, isSub);
47172
+ },
46423
47173
  /**
46424
47174
  * Get point radius.
46425
47175
  * @param {object} d Data row
@@ -46977,7 +47727,7 @@ class ChartInternal {
46977
47727
  if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_b = $$.hasLegendDefsPoint) == null ? void 0 : _b.call($$))) {
46978
47728
  $el.defs = $el.svg.append("defs");
46979
47729
  if (hasAxis) {
46980
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
47730
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
46981
47731
  $$.appendClip($el.defs, state.clip[v]);
46982
47732
  });
46983
47733
  }
@@ -47320,6 +48070,7 @@ object_extend(ChartInternal.prototype, [
47320
48070
 
47321
48071
 
47322
48072
 
48073
+
47323
48074
  const CANVAS_SELECTABLE_TYPE_FILTERS = [
47324
48075
  isCanvasPointType,
47325
48076
  isCanvasBarType,
@@ -47628,6 +48379,21 @@ function isCanvasSubchartPoint($$, point) {
47628
48379
  const rect = getCanvasSubchartRect($$);
47629
48380
  return !!rect && point[0] >= rect.x && point[0] <= rect.x + rect.w && point[1] >= rect.y && point[1] <= rect.y + rect.h;
47630
48381
  }
48382
+ function getCanvasMainPointFromSubchart($$, point) {
48383
+ const { config, state } = $$;
48384
+ const rect = getCanvasSubchartRect($$);
48385
+ if (config.subchart_brush_enabled !== false || !rect || !isCanvasSubchartPoint($$, point)) {
48386
+ return null;
48387
+ }
48388
+ const mainCoord = getMainCoordFromSubchartCoord(
48389
+ $$,
48390
+ config.axis_rotated ? point[1] - rect.y : point[0] - rect.x
48391
+ );
48392
+ if (mainCoord === null) {
48393
+ return null;
48394
+ }
48395
+ return config.axis_rotated ? [state.margin.left + state.width / 2, state.margin.top + mainCoord] : [state.margin.left + mainCoord, state.margin.top + state.height / 2];
48396
+ }
47631
48397
  function getCanvasSubchartBrushExtent($$) {
47632
48398
  var _a, _b;
47633
48399
  const rect = getCanvasSubchartRect($$);
@@ -47819,15 +48585,17 @@ function getCanvasFlowValueCount($$) {
47819
48585
  return $$.data.targets.reduce((sum, target) => sum + target.values.length, 0);
47820
48586
  }
47821
48587
  function syncCanvasFlowYDomains($$) {
47822
- var _a, _b;
47823
48588
  const { scale } = $$;
47824
48589
  const targetsToShow = $$.filterTargetsToShow($$.data.targets);
47825
48590
  ["y", "y2"].forEach((key) => {
47826
- var _a2;
47827
- (_a2 = scale[key]) == null ? void 0 : _a2.domain($$.getYDomain(targetsToShow, key));
48591
+ var _a;
48592
+ (_a = scale[key]) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, key));
48593
+ });
48594
+ $$.withSubchartTypeContext(() => {
48595
+ var _a, _b;
48596
+ (_a = scale.subY) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, "y"));
48597
+ (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
47828
48598
  });
47829
- (_a = scale.subY) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, "y"));
47830
- (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
47831
48599
  }
47832
48600
  const canvasInternal = {
47833
48601
  /**
@@ -48504,22 +49272,42 @@ const canvasInternal = {
48504
49272
  const { config, state } = $$;
48505
49273
  const selected = state.canvasSelection;
48506
49274
  const selectionGrouped = config.data_selection_grouped;
48507
- const targetIds = getCanvasSelectionIds(ids);
49275
+ let targetIds = getCanvasSelectionIds(ids);
48508
49276
  let changed = false;
49277
+ const singleSelection = isSelection && !config.data_selection_multiple;
49278
+ let resetDone = !singleSelection;
48509
49279
  if (!config.data_selection_enabled) {
48510
49280
  return;
48511
49281
  }
49282
+ if (singleSelection) {
49283
+ indices = (indices == null ? void 0 : indices.length) ? [indices[0]] : [0];
49284
+ if (!selectionGrouped) {
49285
+ if (targetIds) {
49286
+ targetIds = targetIds.slice(0, 1);
49287
+ } else {
49288
+ const [firstTarget] = $$.filterTargetsToShow($$.data.targets);
49289
+ targetIds = firstTarget ? [firstTarget.id] : [];
49290
+ }
49291
+ }
49292
+ }
48512
49293
  eachCanvasSelectableData($$, (d) => {
48513
49294
  const key = getCanvasDataKey(d);
48514
49295
  const isTargetId = selectionGrouped || !targetIds || targetIds.indexOf(d.id) >= 0;
48515
49296
  const isTargetIndex = !indices || indices.indexOf(d.index) >= 0;
48516
49297
  const isSelected = selected.has(key);
48517
49298
  if (isSelection) {
48518
- if (isTargetId && isTargetIndex && !isSelected) {
49299
+ if (isTargetId && isTargetIndex && (!isSelected || singleSelection)) {
49300
+ if (!resetDone) {
49301
+ $$.setCanvasSelection(false);
49302
+ resetDone = true;
49303
+ }
49304
+ if (selected.has(key)) {
49305
+ return;
49306
+ }
48519
49307
  selected.add(key);
48520
49308
  callFn(config.data_onselected, $$.api, d, $$.canvasEngine.canvas);
48521
49309
  changed = true;
48522
- } else if (resetOther && isSelected) {
49310
+ } else if ((!singleSelection || resetDone) && resetOther && isSelected) {
48523
49311
  selected.delete(key);
48524
49312
  callFn(config.data_onunselected, $$.api, d, $$.canvasEngine.canvas);
48525
49313
  changed = true;
@@ -48766,12 +49554,12 @@ const canvasInternal = {
48766
49554
  updateCanvasSubchartBrush(event) {
48767
49555
  var _a, _b;
48768
49556
  const $$ = this;
48769
- const { state } = $$;
49557
+ const { config, state } = $$;
48770
49558
  const start = state.canvasSubchartBrushStart;
48771
49559
  const origin = state.canvasSubchartBrushOrigin;
48772
49560
  const mode = state.canvasSubchartBrushMode;
48773
49561
  const coord = getCanvasSubchartBrushCoord($$, event, true);
48774
- if (!state.canvasSubchartBrushDragging || start === null || coord === null || !mode) {
49562
+ if (config.subchart_brush_enabled === false || !state.canvasSubchartBrushDragging || start === null || coord === null || !mode) {
48775
49563
  return false;
48776
49564
  }
48777
49565
  const delta = coord - start;
@@ -48822,6 +49610,10 @@ const canvasInternal = {
48822
49610
  updateCanvasSubchartCursor(event) {
48823
49611
  const $$ = this;
48824
49612
  const canvas2 = $$.$el.canvas.node();
49613
+ if ($$.config.subchart_brush_enabled === false) {
49614
+ canvas2.style.cursor = "";
49615
+ return false;
49616
+ }
48825
49617
  const coord = getCanvasSubchartBrushCoord($$, event);
48826
49618
  if (coord === null) {
48827
49619
  canvas2.style.cursor = "";
@@ -48841,6 +49633,9 @@ const canvasInternal = {
48841
49633
  var _a;
48842
49634
  const $$ = this;
48843
49635
  const { state } = $$;
49636
+ if ($$.config.subchart_brush_enabled === false) {
49637
+ return false;
49638
+ }
48844
49639
  const coord = getCanvasSubchartBrushCoord($$, event);
48845
49640
  if (coord === null) {
48846
49641
  return false;
@@ -49200,7 +49995,8 @@ const canvasInternal = {
49200
49995
  (_b = $$.hideTooltip) == null ? void 0 : _b.call($$);
49201
49996
  return;
49202
49997
  }
49203
- const point = getCanvasEventPoint($$, event);
49998
+ const rawPoint = getCanvasEventPoint($$, event);
49999
+ const point = rawPoint && (getCanvasMainPointFromSubchart($$, rawPoint) || rawPoint);
49204
50000
  const d = point ? getCanvasHoverDatumFromPoint($$, point) : null;
49205
50001
  if (!d) {
49206
50002
  $$.dispatchCanvasDataOut(canvas2);
@@ -49208,8 +50004,8 @@ const canvasInternal = {
49208
50004
  state.canvasFocusKey = null;
49209
50005
  $$.clearCanvasFocus();
49210
50006
  }
49211
- if (point && config.axis_tooltip && isCanvasAxisTooltipArea($$, point)) {
49212
- $$.renderCanvasAxisTooltip(point);
50007
+ if (rawPoint && config.axis_tooltip && isCanvasAxisTooltipArea($$, rawPoint)) {
50008
+ $$.renderCanvasAxisTooltip(rawPoint);
49213
50009
  (_c = $$.hideTooltip) == null ? void 0 : _c.call($$);
49214
50010
  return;
49215
50011
  }
@@ -49340,6 +50136,7 @@ const canvasInternal = {
49340
50136
  state.hasAxis && $$.config.grid_lines_front && $$.canvasAxisRenderer.drawGridLines($$);
49341
50137
  $$.canvasRenderer.drawSubchart($$, drawShape);
49342
50138
  state.hasAxis && $$.canvasAxisRenderer.drawSubXAxis($$);
50139
+ state.hasAxis && $$.canvasAxisRenderer.drawSubYAxes($$);
49343
50140
  $$.canvasRenderer.drawEmptyLabel($$);
49344
50141
  rebuildHit && $$.hitDetector.rebuild($$, drawShape);
49345
50142
  } finally {
@@ -49371,6 +50168,7 @@ const canvasInternal = {
49371
50168
  state.hasAxis && $$.config.grid_lines_front && $$.canvasAxisRenderer.drawGridLines($$);
49372
50169
  $$.canvasRenderer.drawSubchart($$, drawShape);
49373
50170
  state.hasAxis && $$.canvasAxisRenderer.drawSubXAxis($$);
50171
+ state.hasAxis && $$.canvasAxisRenderer.drawSubYAxes($$);
49374
50172
  $$.canvasRenderer.drawEmptyLabel($$);
49375
50173
  } finally {
49376
50174
  $$.canvasEngine.endFrame();
@@ -49992,14 +50790,17 @@ object_extend(api_data_data, {
49992
50790
  const $$ = this.internal;
49993
50791
  const { config, state, $el } = $$;
49994
50792
  const targetIds = $$.mapToTargetIds(targetIdsValue);
49995
- if (state.isCanvasMode) {
49996
- const changed = !!((_a = state.focusedTargetIds) == null ? void 0 : _a.size) || !!((_b = state.defocusedTargetIds) == null ? void 0 : _b.size);
50793
+ const resetLegend = () => {
49997
50794
  if (config.legend_show) {
49998
50795
  $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
49999
50796
  $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function() {
50000
50797
  return src_select(this).classed($FOCUS.legendItemFocused);
50001
50798
  }).classed($FOCUS.legendItemFocused, false);
50002
50799
  }
50800
+ };
50801
+ if (state.isCanvasMode) {
50802
+ const changed = !!((_a = state.focusedTargetIds) == null ? void 0 : _a.size) || !!((_b = state.defocusedTargetIds) == null ? void 0 : _b.size);
50803
+ resetLegend();
50003
50804
  state.focusedTargetIds = /* @__PURE__ */ new Set();
50004
50805
  state.defocusedTargetIds = /* @__PURE__ */ new Set();
50005
50806
  changed && ((_c = $$.renderCanvasFrame) == null ? void 0 : _c.call($$, void 0, null, false));
@@ -50008,12 +50809,7 @@ object_extend(api_data_data, {
50008
50809
  const candidates = $el.svg.selectAll($$.selectorTargets(targetIds));
50009
50810
  candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, false);
50010
50811
  $$.hasArcType(null, ["polar"]) && $$.unexpandArc(targetIds);
50011
- if (config.legend_show) {
50012
- $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
50013
- $el.legend.selectAll($$.selectorLegends(targetIds)).filter(function() {
50014
- return src_select(this).classed($FOCUS.legendItemFocused);
50015
- }).classed($FOCUS.legendItemFocused, false);
50016
- }
50812
+ resetLegend();
50017
50813
  state.focusedTargetIds = /* @__PURE__ */ new Set();
50018
50814
  state.defocusedTargetIds = /* @__PURE__ */ new Set();
50019
50815
  }
@@ -51459,7 +52255,7 @@ object_extend(ygrids, {
51459
52255
 
51460
52256
 
51461
52257
 
51462
- const GRID_FOCUS_SELECTOR = `line.${$FOCUS.xgridFocus}, line.${$FOCUS.ygridFocus}`;
52258
+ const GRID_FOCUS_SELECTOR = `line.${$FOCUS.xgridFocus}:not(.${$FOCUS.xgridFocusContinuous}), line.${$FOCUS.ygridFocus}`;
51463
52259
  const _getGridTextAnchor = (d) => isValue(d.position) || "end";
51464
52260
  const _getGridTextDx = (d) => d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
51465
52261
  function _getGridFocusEl($$) {
@@ -51470,6 +52266,9 @@ function _getGridFocusEl($$) {
51470
52266
  const cachedNodes = ((_a = cached == null ? void 0 : cached.nodes) == null ? void 0 : _a.call(cached)) || [];
51471
52267
  return cachedNodes.length && cachedNodes.every((node) => mainNode == null ? void 0 : mainNode.contains(node)) ? cached : state._gridFocusEl = main.selectAll(GRID_FOCUS_SELECTOR);
51472
52268
  }
52269
+ function _hideContinuousGridFocus($$) {
52270
+ $$.$el.main.select(`line.${$FOCUS.xgridFocusContinuous}`).style("visibility", "hidden");
52271
+ }
51473
52272
  function _getGridTextX(isX, width, height) {
51474
52273
  return (d) => {
51475
52274
  let x = isX ? 0 : width;
@@ -51640,6 +52439,7 @@ function _smoothLines(el, type) {
51640
52439
  if (config.grid_focus_y && !config.tooltip_grouped) {
51641
52440
  grid.append("g").attr("class", $FOCUS.ygridFocus).append("line").attr("class", $FOCUS.ygridFocus);
51642
52441
  }
52442
+ 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");
51643
52443
  }
51644
52444
  },
51645
52445
  showAxisGridFocus() {
@@ -51748,6 +52548,7 @@ function _smoothLines(el, type) {
51748
52548
  if (force || inputType === "mouse" || !resizing) {
51749
52549
  const focusEl = _getGridFocusEl($$);
51750
52550
  focusEl.style("visibility", "hidden");
52551
+ _hideContinuousGridFocus($$);
51751
52552
  (_a = $$.hideCircleFocus) == null ? void 0 : _a.call($$);
51752
52553
  }
51753
52554
  },
@@ -51765,6 +52566,7 @@ function _smoothLines(el, type) {
51765
52566
  } else {
51766
52567
  const isRotated = $$.config.axis_rotated;
51767
52568
  xgridFocus.attr("x1", isRotated ? 0 : -10).attr("x2", isRotated ? width : -10).attr("y1", isRotated ? -10 : 0).attr("y2", isRotated ? -10 : height);
52569
+ _hideContinuousGridFocus($$);
51768
52570
  }
51769
52571
  return true;
51770
52572
  },
@@ -51903,28 +52705,85 @@ let grid_grid = () => {
51903
52705
 
51904
52706
 
51905
52707
 
52708
+ function setSelectionForFocusOnly(isSelection, ids, indices, resetOther) {
52709
+ const $$ = this;
52710
+ const { config, $el: { main } } = $$;
52711
+ const selectionGrouped = config.data_selection_grouped;
52712
+ const isSelectable = config.data_selection_isselectable.bind($$.api);
52713
+ const targetIds = isDefined(ids) ? [].concat(ids) : null;
52714
+ const singleSelection = isSelection && !config.data_selection_multiple;
52715
+ let resetDone = !singleSelection;
52716
+ const unselect = (circle, d, index) => {
52717
+ $$.unselectPoint(circle, d, index);
52718
+ circle.interrupt().remove();
52719
+ };
52720
+ $$.getTargetsToShow().forEach((target) => {
52721
+ const { id } = target;
52722
+ const isTargetId = selectionGrouped || !targetIds || targetIds.indexOf(id) >= 0;
52723
+ const selectedCircles = main.select(
52724
+ `.${$SELECT.selectedCircles}${$$.getTargetSelectorSuffix(id)}`
52725
+ );
52726
+ target.values.forEach((d) => {
52727
+ const { index } = d;
52728
+ const isTargetIndex = !indices || indices.indexOf(index) >= 0;
52729
+ const circle = selectedCircles.selectAll(`.${$SELECT.selectedCircle}-${index}`);
52730
+ const isSelected = !circle.empty();
52731
+ if (isSelection) {
52732
+ if (isTargetId && isTargetIndex && isSelectable(d) && (!isSelected || singleSelection)) {
52733
+ if (!resetDone) {
52734
+ setSelectionForFocusOnly.call($$, false);
52735
+ resetDone = true;
52736
+ }
52737
+ $$.selectPoint(null, d, index);
52738
+ } else if ((!singleSelection || resetDone) && isDefined(resetOther) && resetOther && isSelected) {
52739
+ unselect(circle, d, index);
52740
+ }
52741
+ } else if (isTargetId && isTargetIndex && isSelected) {
52742
+ unselect(circle, d, index);
52743
+ }
52744
+ });
52745
+ });
52746
+ }
51906
52747
  function setSelection(isSelection = false, ids, indices, resetOther) {
52748
+ var _a;
51907
52749
  const $$ = this;
51908
52750
  const { config, $el: { main } } = $$;
51909
52751
  const selectionGrouped = config.data_selection_grouped;
51910
52752
  const isSelectable = config.data_selection_isselectable.bind($$.api);
52753
+ const singleSelection = isSelection && !config.data_selection_multiple;
52754
+ let resetDone = !singleSelection;
51911
52755
  if (!config.data_selection_enabled) {
51912
52756
  return;
51913
52757
  }
52758
+ if (singleSelection) {
52759
+ indices = (indices == null ? void 0 : indices.length) ? [indices[0]] : [0];
52760
+ if (!selectionGrouped) {
52761
+ const targetIds = isDefined(ids) ? [].concat(ids) : $$.getTargetsToShow().map((t) => t.id);
52762
+ ids = targetIds.slice(0, 1);
52763
+ }
52764
+ }
52765
+ if ((_a = $$.isPointFocusOnly) == null ? void 0 : _a.call($$)) {
52766
+ setSelectionForFocusOnly.call($$, isSelection, ids, indices, resetOther);
52767
+ return;
52768
+ }
51914
52769
  main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).each(function(d) {
51915
52770
  const shape = src_select(this);
51916
52771
  const { id, index } = d.data ? d.data : d;
51917
- const toggle = $$.getToggle(this, d).bind($$);
51918
52772
  const isTargetId = selectionGrouped || !ids || ids.indexOf(id) >= 0;
51919
52773
  const isTargetIndex = !indices || indices.indexOf(index) >= 0;
51920
- const isSelected = shape.classed($SELECT.SELECTED);
51921
52774
  if (shape.classed($LINE.line) || shape.classed($AREA.area)) {
51922
52775
  return;
51923
52776
  }
52777
+ const toggle = $$.getToggle(this, d).bind($$);
52778
+ const isSelected = shape.classed($SELECT.SELECTED);
51924
52779
  if (isSelection) {
51925
- if (isTargetId && isTargetIndex && isSelectable(d) && !isSelected) {
51926
- toggle(true, shape.classed($SELECT.SELECTED, true), d, index);
51927
- } else if (isDefined(resetOther) && resetOther && isSelected) {
52780
+ if (isTargetId && isTargetIndex && isSelectable(d) && (!isSelected || singleSelection)) {
52781
+ if (!resetDone) {
52782
+ setSelection.call($$, false);
52783
+ resetDone = true;
52784
+ }
52785
+ !shape.classed($SELECT.SELECTED) && toggle(true, shape.classed($SELECT.SELECTED, true), d, index);
52786
+ } else if ((!singleSelection || resetDone) && isDefined(resetOther) && resetOther && isSelected) {
51928
52787
  toggle(false, shape.classed($SELECT.SELECTED, false), d, index);
51929
52788
  }
51930
52789
  } else {
@@ -51952,12 +52811,16 @@ function setSelection(isSelection = false, ids, indices, resetOther) {
51952
52811
  * chart.selected("data1");
51953
52812
  */
51954
52813
  selected(targetId) {
51955
- var _a;
52814
+ var _a, _b;
51956
52815
  const $$ = this.internal;
51957
52816
  const dataPoint = [];
51958
52817
  if ($$.state.isCanvasMode) {
51959
52818
  return ((_a = $$.getCanvasSelectedData) == null ? void 0 : _a.call($$, targetId)) || dataPoint;
51960
52819
  }
52820
+ if ((_b = $$.isPointFocusOnly) == null ? void 0 : _b.call($$)) {
52821
+ $$.$el.main.selectAll(`.${$SELECT.selectedCircles + $$.getTargetSelectorSuffix(targetId)}`).selectAll(`.${$SELECT.selectedCircle}`).each((d) => dataPoint.push(d));
52822
+ return dataPoint;
52823
+ }
51961
52824
  $$.$el.main.selectAll(`.${$SHAPE.shapes + $$.getTargetSelectorSuffix(targetId)}`).selectAll(`.${$SHAPE.shape}`).filter(function() {
51962
52825
  return src_select(this).classed($SELECT.SELECTED);
51963
52826
  }).each((d) => dataPoint.push(d));
@@ -52155,7 +53018,7 @@ var selection_spreadProps = (a, b) => selection_defProps(a, selection_getOwnProp
52155
53018
  const cx = (isRotated ? $$.circleY : $$.circleX).bind($$);
52156
53019
  const cy = (isRotated ? $$.circleX : $$.circleY).bind($$);
52157
53020
  const r = $$.pointSelectR.bind($$);
52158
- callFn(config.data_onselected, $$.api, d, target.node());
53021
+ callFn(config.data_onselected, $$.api, d, target == null ? void 0 : target.node());
52159
53022
  $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);
52160
53023
  },
52161
53024
  /**
@@ -52584,7 +53447,134 @@ object_extend(subchart, {
52584
53447
 
52585
53448
 
52586
53449
 
53450
+
53451
+
53452
+ const SUBCHART_TYPES = ["bar", "line", "bubble", "candlestick", "scatter"];
53453
+ const FOCUS_GRID_STYLE_PROPS = [
53454
+ "opacity",
53455
+ "stroke",
53456
+ "stroke-dasharray",
53457
+ "stroke-dashoffset",
53458
+ "stroke-linecap",
53459
+ "stroke-linejoin",
53460
+ "stroke-miterlimit",
53461
+ "stroke-opacity",
53462
+ "stroke-width"
53463
+ ];
53464
+ function syncSubchartGridFocusStyle($$, line) {
53465
+ var _a, _b;
53466
+ const source = (_b = (_a = $$.$el.grid) == null ? void 0 : _a.main) == null ? void 0 : _b.select(`line.${config_classes.xgridFocus}`).node();
53467
+ if (!source || !win.getComputedStyle) {
53468
+ return;
53469
+ }
53470
+ const style = win.getComputedStyle(source);
53471
+ FOCUS_GRID_STYLE_PROPS.forEach((prop) => {
53472
+ const value = style.getPropertyValue(prop);
53473
+ value && line.style(prop, value);
53474
+ });
53475
+ }
53476
+ function getFiniteAttr(value, fallback) {
53477
+ const parsed = Number(value);
53478
+ return Number.isFinite(parsed) ? parsed : fallback;
53479
+ }
53480
+ function showContinuousSubchartGridFocus($$) {
53481
+ var _a, _b;
53482
+ if (!isContinuousGridFocusEnabled($$)) {
53483
+ return false;
53484
+ }
53485
+ const { config, state, $el } = $$;
53486
+ const mainLine = (_b = (_a = $el.grid) == null ? void 0 : _a.main) == null ? void 0 : _b.select(
53487
+ `line.${config_classes.xgridFocus}:not(.${config_classes.xgridFocusContinuous})`
53488
+ );
53489
+ const line = $el.main.select(`line.${config_classes.xgridFocusContinuous}`);
53490
+ if (!(mainLine == null ? void 0 : mainLine.node()) || !line.node()) {
53491
+ return false;
53492
+ }
53493
+ const x2 = state.margin2.left - state.margin.left + state.width2;
53494
+ const y2 = state.margin2.top - state.margin.top + state.height2;
53495
+ syncSubchartGridFocusStyle($$, line);
53496
+ 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);
53497
+ line.style("visibility", null);
53498
+ mainLine.style("visibility", "hidden");
53499
+ return true;
53500
+ }
53501
+ function hideContinuousSubchartGridFocus($$) {
53502
+ var _a;
53503
+ (_a = $$.$el.main) == null ? void 0 : _a.select(`line.${config_classes.xgridFocusContinuous}`).style("visibility", "hidden");
53504
+ }
53505
+ function getMainPointFromSubchartEvent($$, event, context) {
53506
+ const { config, state } = $$;
53507
+ const [x, y] = getPointer(event, context);
53508
+ const mainCoord = getMainCoordFromSubchartCoord($$, config.axis_rotated ? y : x);
53509
+ if (mainCoord === null) {
53510
+ return null;
53511
+ }
53512
+ return config.axis_rotated ? [state.width / 2, mainCoord] : [mainCoord, state.height / 2];
53513
+ }
53514
+ function dispatchSubchartEvent($$, type, event, context) {
53515
+ var _a, _b;
53516
+ const mainEventRect = (_b = (_a = $$.$el.eventRect) == null ? void 0 : _a.node) == null ? void 0 : _b.call(_a);
53517
+ if (!mainEventRect) {
53518
+ return;
53519
+ }
53520
+ const point = getMainPointFromSubchartEvent($$, event, context) || [0, 0];
53521
+ const rect = getBoundingRect(mainEventRect, true);
53522
+ const clientX = rect.left + point[0];
53523
+ const clientY = rect.top + point[1];
53524
+ const params = {
53525
+ bubbles: true,
53526
+ cancelable: true,
53527
+ screenX: clientX,
53528
+ screenY: clientY,
53529
+ clientX,
53530
+ clientY
53531
+ };
53532
+ /^touch/.test(type) ? emulateEvent.touch(mainEventRect, type, params) : emulateEvent.mouse(mainEventRect, type, params);
53533
+ }
52587
53534
  /* harmony default export */ var interactions_subchart = ({
53535
+ /**
53536
+ * Whether subchart brush interaction is enabled.
53537
+ * @returns {boolean}
53538
+ * @private
53539
+ */
53540
+ isSubchartBrushEnabled() {
53541
+ const { config } = this;
53542
+ return config.subchart_show && config.subchart_brush_enabled !== false;
53543
+ },
53544
+ /**
53545
+ * Bind event rect handlers for subchart hover interactions.
53546
+ * @param {d3Selection} eventRect Subchart event rect selection
53547
+ * @private
53548
+ */
53549
+ bindSubchartEventRect(eventRect) {
53550
+ const $$ = this;
53551
+ const { config, state } = $$;
53552
+ eventRect.on("mouseover mousemove mouseout touchstart touchmove touchend", null);
53553
+ if (!config.interaction_enabled) {
53554
+ return;
53555
+ }
53556
+ if (state.inputType === "mouse") {
53557
+ eventRect.on("mouseover mousemove", function(event) {
53558
+ if ($$.isSubchartBrushEnabled()) {
53559
+ return;
53560
+ }
53561
+ dispatchSubchartEvent($$, event.type, event, this);
53562
+ }).on("mouseout", function(event) {
53563
+ if ($$.isSubchartBrushEnabled()) {
53564
+ return;
53565
+ }
53566
+ dispatchSubchartEvent($$, "mouseout", event, this);
53567
+ });
53568
+ } else if (state.inputType === "touch") {
53569
+ eventRect.on("touchstart touchmove touchend", function(event) {
53570
+ var _a;
53571
+ if ($$.isSubchartBrushEnabled() || ((_a = event.touches) == null ? void 0 : _a.length) > 1) {
53572
+ return;
53573
+ }
53574
+ dispatchSubchartEvent($$, event.type, event, this);
53575
+ });
53576
+ }
53577
+ },
52588
53578
  /**
52589
53579
  * Initialize the brush.
52590
53580
  * @private
@@ -52678,19 +53668,26 @@ object_extend(subchart, {
52678
53668
  const { main } = subchart;
52679
53669
  main.style("visibility", visibility);
52680
53670
  main.append("g").attr("clip-path", clipPath).attr("class", config_classes.chart);
52681
- ["bar", "line", "bubble", "candlestick", "scatter"].forEach((v) => {
52682
- const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
52683
- if ($$.hasType(v) || $$.hasTypeOf(type)) {
52684
- const chart = main.select(`.${config_classes.chart}`);
52685
- const chartClassName = config_classes[`chart${type}s`];
52686
- if (chart.select(`.${chartClassName}`).empty()) {
52687
- chart.append("g").attr("class", chartClassName);
53671
+ $$.withSubchartTypeContext(() => {
53672
+ SUBCHART_TYPES.forEach((v) => {
53673
+ const type = capitalize(/^(bubble|scatter)$/.test(v) ? "circle" : v);
53674
+ if ($$.hasType(v) || $$.hasTypeOf(type)) {
53675
+ const chart = main.select(`.${config_classes.chart}`);
53676
+ const chartClassName = config_classes[`chart${type}s`];
53677
+ if (chart.select(`.${chartClassName}`).empty()) {
53678
+ chart.append("g").attr("class", chartClassName);
53679
+ }
52688
53680
  }
52689
- }
53681
+ });
52690
53682
  });
52691
- const brush = main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).call($$.brush);
53683
+ const brush = main.append("g").attr("clip-path", clipPath).attr("class", config_classes.brush).style("pointer-events", $$.isSubchartBrushEnabled() ? null : "none").call($$.brush);
52692
53684
  config.subchart_showHandle && $$.addBrushHandle(brush);
53685
+ 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);
53686
+ $$.bindSubchartEventRect(subchart.eventRect);
53687
+ main.append("g").attr("clip-path", clipPath).attr("class", config_classes.xgridFocus).append("line").attr("class", config_classes.xgridFocus).style("visibility", "hidden");
52693
53688
  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");
53689
+ axis.subY = main.append("g").attr("class", config_classes.axisY).attr("transform", $$.getTranslate("subY")).style("visibility", config.subchart_axis_y_show ? visibility : "hidden");
53690
+ axis.subY2 = main.append("g").attr("class", config_classes.axisY2).attr("transform", $$.getTranslate("subY2")).style("visibility", config.subchart_axis_y2_show ? visibility : "hidden");
52694
53691
  },
52695
53692
  /**
52696
53693
  * Add brush handle
@@ -52713,64 +53710,89 @@ object_extend(subchart, {
52713
53710
  * @private
52714
53711
  */
52715
53712
  updateTargetsForSubchart(targets) {
53713
+ var _a;
52716
53714
  const $$ = this;
52717
53715
  const { config, state, $el: { subchart: { main } } } = $$;
52718
53716
  if (config.subchart_show) {
52719
- ["bar", "line", "bubble", "candlestick", "scatter"].filter((v) => $$.hasType(v) || $$.hasTypeOf(capitalize(v))).forEach((v) => {
52720
- const isPointType = /^(bubble|scatter)$/.test(v);
52721
- const name = capitalize(isPointType ? "circle" : v);
52722
- const chartClass = $$.getChartClass(name, true);
52723
- const shapeClass = $$.getClass(isPointType ? "circles" : `${v}s`, true);
52724
- const shapeChart = main.select(`.${config_classes[`chart${`${name}s`}`]}`);
52725
- if (isPointType) {
52726
- const circle = shapeChart.selectAll(`.${config_classes.circles}`).data(targets.filter($$[`is${capitalize(v)}Type`].bind($$))).attr("class", shapeClass);
52727
- circle.exit().remove();
52728
- circle.enter().append("g").attr("class", shapeClass);
52729
- } else {
52730
- const shapeUpdate = shapeChart.selectAll(`.${config_classes[`chart${name}`]}`).attr("class", chartClass).data(targets.filter($$[`is${name}Type`].bind($$)));
52731
- const shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
52732
- shapeUpdate.exit().remove();
52733
- v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", true));
52734
- }
53717
+ $$.withSubchartTypeContext(() => {
53718
+ SUBCHART_TYPES.filter((v) => $$.hasType(v) || $$.hasTypeOf(capitalize(v))).forEach((v) => {
53719
+ const isPointType = /^(bubble|scatter)$/.test(v);
53720
+ const name = capitalize(isPointType ? "circle" : v);
53721
+ const chartClass = $$.getChartClass(name, true);
53722
+ const shapeClass = $$.getClass(isPointType ? "circles" : `${v}s`, true);
53723
+ const shapeChart = main.select(`.${config_classes[`chart${`${name}s`}`]}`);
53724
+ if (isPointType) {
53725
+ const circle = shapeChart.selectAll(`.${config_classes.circles}`).data(targets.filter($$[`is${capitalize(v)}Type`].bind($$))).attr("class", shapeClass);
53726
+ circle.exit().remove();
53727
+ circle.enter().append("g").attr("class", shapeClass);
53728
+ } else {
53729
+ const shapeUpdate = shapeChart.selectAll(`.${config_classes[`chart${name}`]}`).attr("class", chartClass).data(targets.filter($$[`is${name}Type`].bind($$)));
53730
+ const shapeEnter = shapeUpdate.enter().append("g").style("opacity", "0").attr("class", chartClass).append("g").attr("class", shapeClass);
53731
+ shapeUpdate.exit().remove();
53732
+ v === "line" && $$.hasTypeOf("Area") && shapeEnter.append("g").attr("class", $$.getClass("areas", true));
53733
+ }
53734
+ });
52735
53735
  });
52736
53736
  main.selectAll(`.${config_classes.brush} rect`).attr(
52737
53737
  config.axis_rotated ? "width" : "height",
52738
53738
  config.axis_rotated ? state.width2 : state.height2
52739
53739
  );
53740
+ (_a = $$.$el.subchart.eventRect) == null ? void 0 : _a.attr("width", state.width2).attr("height", state.height2).style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all");
52740
53741
  }
52741
53742
  },
53743
+ /**
53744
+ * Update subchart y domains using subchart type options.
53745
+ * @param {object} targets Targets to show
53746
+ * @private
53747
+ */
53748
+ updateSubchartYDomain(targets) {
53749
+ var _a, _b;
53750
+ const $$ = this;
53751
+ const { scale } = $$;
53752
+ const targetsToShow = targets || $$.filterTargetsToShow($$.data.targets);
53753
+ (_a = scale.subY) == null ? void 0 : _a.domain($$.getYDomain(targetsToShow, "y"));
53754
+ (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
53755
+ },
52742
53756
  /**
52743
53757
  * Redraw subchart.
52744
53758
  * @private
52745
53759
  * @param {boolean} withSubchart whether or not to show subchart
52746
53760
  * @param {number} duration duration
52747
- * @param {object} shape Shape's info
52748
53761
  */
52749
- redrawSubchart(withSubchart, duration, shape) {
52750
- var _a;
53762
+ redrawSubchart(withSubchart, duration) {
53763
+ var _a, _b, _c, _d;
52751
53764
  const $$ = this;
52752
53765
  const { config, $el: { subchart: { main } }, state } = $$;
52753
53766
  const withTransition = !!duration;
52754
53767
  main.style("visibility", config.subchart_show ? null : "hidden");
53768
+ main.select(`.${config_classes.brush}`).style("pointer-events", $$.isSubchartBrushEnabled() ? null : "none");
53769
+ (_a = $$.$el.subchart.eventRect) == null ? void 0 : _a.style("pointer-events", $$.isSubchartBrushEnabled() ? "none" : "all");
53770
+ (_b = $$.$el.axis.subY) == null ? void 0 : _b.style("visibility", config.subchart_axis_y_show ? null : "hidden");
53771
+ (_c = $$.$el.axis.subY2) == null ? void 0 : _c.style("visibility", config.subchart_axis_y2_show ? null : "hidden");
52755
53772
  if (config.subchart_show) {
52756
- if (((_a = state.event) == null ? void 0 : _a.type) === "zoom") {
53773
+ if (((_d = state.event) == null ? void 0 : _d.type) === "zoom") {
52757
53774
  $$.brush.update();
52758
53775
  }
52759
53776
  if (withSubchart) {
52760
53777
  const initRange = config.subchart_init_range;
52761
53778
  !brushEmpty($$) && $$.brush.update();
52762
- Object.keys(shape.type).forEach((v) => {
52763
- const name = capitalize(v);
52764
- const drawFn = $$[`generateDraw${name}`](shape.indices[v], true);
52765
- $$[`update${name}`](withTransition, true);
52766
- $$[`redraw${name}`](drawFn, withTransition, true);
53779
+ $$.withSubchartTypeContext(() => {
53780
+ const targetsToShow = state._targetsToShow || $$.filterTargetsToShow($$.data.targets);
53781
+ $$.updateSubchartYDomain(targetsToShow);
53782
+ const subchartShape = $$.getDrawShape();
53783
+ Object.keys(subchartShape.type).forEach((v) => {
53784
+ const name = capitalize(v);
53785
+ const drawFn = $$[`generateDraw${name}`](subchartShape.indices[v], true);
53786
+ $$[`update${name}`](withTransition, true);
53787
+ $$[`redraw${name}`](drawFn, withTransition, true);
53788
+ });
53789
+ if ($$.hasType("bubble") || $$.hasType("scatter")) {
53790
+ const { cx } = subchartShape.pos;
53791
+ const cy = $$.updateCircleY(true);
53792
+ $$.updateCircle(true);
53793
+ $$.redrawCircle(cx, cy, withTransition, void 0, true);
53794
+ }
52767
53795
  });
52768
- if ($$.hasType("bubble") || $$.hasType("scatter")) {
52769
- const { cx } = shape.pos;
52770
- const cy = $$.updateCircleY(true);
52771
- $$.updateCircle(true);
52772
- $$.redrawCircle(cx, cy, withTransition, void 0, true);
52773
- }
52774
53796
  if (!state.rendered && initRange) {
52775
53797
  state.domain = initRange;
52776
53798
  $$.brush.move(
@@ -52781,6 +53803,46 @@ object_extend(subchart, {
52781
53803
  }
52782
53804
  }
52783
53805
  },
53806
+ /**
53807
+ * Show a focus grid line on subchart following main chart focus.
53808
+ * @param {Array} data Selected data
53809
+ * @private
53810
+ */
53811
+ showSubchartGridFocus(data) {
53812
+ const $$ = this;
53813
+ const { config, state, $el: { subchart: { main } } } = $$;
53814
+ if (!main || !config.subchart_show || $$.isSubchartBrushEnabled() || config.grid_focus_show === false || config.subchart_grid_focus === false || !config.tooltip_show || config.axis_tooltip) {
53815
+ return;
53816
+ }
53817
+ const focusData = Array.isArray(data) ? data : [data];
53818
+ const focus = focusData.find((d) => d && $$.getBaseValue(d) != null);
53819
+ if (!focus) {
53820
+ $$.hideSubchartGridFocus();
53821
+ return;
53822
+ }
53823
+ const pos = $$.scale.subX(focus.x);
53824
+ if (!Number.isFinite(pos)) {
53825
+ $$.hideSubchartGridFocus();
53826
+ return;
53827
+ }
53828
+ const line = main.select(`g.${config_classes.xgridFocus} line.${config_classes.xgridFocus}`);
53829
+ if (showContinuousSubchartGridFocus($$)) {
53830
+ line.style("visibility", "hidden");
53831
+ return;
53832
+ }
53833
+ syncSubchartGridFocusStyle($$, line);
53834
+ 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);
53835
+ line.style("visibility", null);
53836
+ },
53837
+ /**
53838
+ * Hide subchart focus grid line.
53839
+ * @private
53840
+ */
53841
+ hideSubchartGridFocus() {
53842
+ var _a;
53843
+ hideContinuousSubchartGridFocus(this);
53844
+ (_a = this.$el.subchart.main) == null ? void 0 : _a.select(`g.${config_classes.xgridFocus} line.${config_classes.xgridFocus}`).style("visibility", "hidden");
53845
+ },
52784
53846
  /**
52785
53847
  * Redraw the brush.
52786
53848
  * @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
@@ -52816,8 +53878,12 @@ object_extend(subchart, {
52816
53878
  const $$ = this;
52817
53879
  const { $el: { subchart }, $T } = $$;
52818
53880
  const subXAxis = (transitions == null ? void 0 : transitions.axisSubX) ? transitions.axisSubX : $T(subchart.main.select(`.${config_classes.axisX}`), withTransition);
53881
+ const subYAxis = (transitions == null ? void 0 : transitions.axisSubY) ? transitions.axisSubY : $T(subchart.main.select(`.${config_classes.axisY}`), withTransition);
53882
+ const subY2Axis = (transitions == null ? void 0 : transitions.axisSubY2) ? transitions.axisSubY2 : $T(subchart.main.select(`.${config_classes.axisY2}`), withTransition);
52819
53883
  subchart.main.attr("transform", $$.getTranslate("context"));
52820
53884
  subXAxis.attr("transform", $$.getTranslate("subX"));
53885
+ subYAxis.attr("transform", $$.getTranslate("subY"));
53886
+ subY2Axis.attr("transform", $$.getTranslate("subY2"));
52821
53887
  }
52822
53888
  });
52823
53889
 
@@ -52825,7 +53891,7 @@ object_extend(subchart, {
52825
53891
  /* harmony default export */ var interaction_subchart = ({
52826
53892
  /**
52827
53893
  * Set subchart options.
52828
- * - **NOTE:** Not supported for `bubble`, `scatter` and non-Axis based(pie, donut, gauge, radar) types.
53894
+ * - **NOTE:** Not supported for non-Axis based(pie, donut, gauge, radar) types.
52829
53895
  * @name subchart
52830
53896
  * @memberof Options
52831
53897
  * @type {object}
@@ -52833,11 +53899,45 @@ object_extend(subchart, {
52833
53899
  * @property {boolean} [subchart.show=false] Show sub chart on the bottom of the chart.
52834
53900
  * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
52835
53901
  * - `show: subchart()`
53902
+ * @property {string} [subchart.type] Set chart type for the subchart. Defaults to data.type.
53903
+ * @property {object} [subchart.types] Set chart type for each data in the subchart. Defaults to data.types.
53904
+ * @property {boolean} [subchart.brush.enabled=true] Enable subchart brush interaction.
52836
53905
  * @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
53906
+ * @property {boolean|object} [subchart.grid.focus=true] Show x focus grid line in subchart when subchart brush is disabled.
53907
+ * @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.
52837
53908
  * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
52838
53909
  * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
53910
+ * @property {number} [subchart.axis.x.tick.count] Set the number of x axis ticks.
53911
+ * @property {Array|function} [subchart.axis.x.tick.values] Set x axis tick values manually.
53912
+ * @property {boolean|object} [subchart.axis.x.tick.culling] Setting for culling x axis ticks.
53913
+ * @property {number} [subchart.axis.x.tick.culling.max] The number of x axis tick texts will be adjusted to less than this value.
53914
+ * @property {boolean} [subchart.axis.x.tick.culling.lines=true] Control x axis tick line visibility within culling option.
53915
+ * @property {boolean} [subchart.axis.x.tick.culling.reverse=false] Control x axis culling start point to be reversed.
53916
+ * @property {boolean} [subchart.axis.x.tick.outer] Show or hide x axis outer tick.
52839
53917
  * @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.
52840
53918
  * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
53919
+ * @property {boolean} [subchart.axis.y.show=false] Show or hide y axis.
53920
+ * @property {boolean} [subchart.axis.y.tick.show=true] Show or hide y axis tick line.
53921
+ * @property {number} [subchart.axis.y.tick.count] Set the number of y axis ticks.
53922
+ * @property {Array|function} [subchart.axis.y.tick.values] Set y axis tick values manually.
53923
+ * @property {boolean|object} [subchart.axis.y.tick.culling] Setting for culling y axis ticks.
53924
+ * @property {number} [subchart.axis.y.tick.culling.max] The number of y axis tick texts will be adjusted to less than this value.
53925
+ * @property {boolean} [subchart.axis.y.tick.culling.lines=true] Control y axis tick line visibility within culling option.
53926
+ * @property {boolean} [subchart.axis.y.tick.culling.reverse=false] Control y axis culling start point to be reversed.
53927
+ * @property {boolean} [subchart.axis.y.tick.outer] Show or hide y axis outer tick.
53928
+ * @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.
53929
+ * @property {boolean} [subchart.axis.y.tick.text.show=true] Show or hide y axis tick text.
53930
+ * @property {boolean} [subchart.axis.y2.show=false] Show or hide y2 axis.
53931
+ * @property {boolean} [subchart.axis.y2.tick.show=true] Show or hide y2 axis tick line.
53932
+ * @property {number} [subchart.axis.y2.tick.count] Set the number of y2 axis ticks.
53933
+ * @property {Array|function} [subchart.axis.y2.tick.values] Set y2 axis tick values manually.
53934
+ * @property {boolean|object} [subchart.axis.y2.tick.culling] Setting for culling y2 axis ticks.
53935
+ * @property {number} [subchart.axis.y2.tick.culling.max] The number of y2 axis tick texts will be adjusted to less than this value.
53936
+ * @property {boolean} [subchart.axis.y2.tick.culling.lines=true] Control y2 axis tick line visibility within culling option.
53937
+ * @property {boolean} [subchart.axis.y2.tick.culling.reverse=false] Control y2 axis culling start point to be reversed.
53938
+ * @property {boolean} [subchart.axis.y2.tick.outer] Show or hide y2 axis outer tick.
53939
+ * @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.
53940
+ * @property {boolean} [subchart.axis.y2.tick.text.show=true] Show or hide y2 axis tick text.
52841
53941
  * @property {Array} [subchart.init.range] Set initial selection domain range.
52842
53942
  * @property {number} [subchart.size.height] Change the height of the subchart.
52843
53943
  * @property {function} [subchart.onbrush] Set callback for brush event.<br>
@@ -52847,9 +53947,29 @@ object_extend(subchart, {
52847
53947
  * subchart: {
52848
53948
  * show: true,
52849
53949
  * showHandle: true,
53950
+ *
53951
+ * // render the overview with a different chart type than the main chart
53952
+ * type: "bar",
53953
+ *
53954
+ * // override the type per data series
53955
+ * types: {
53956
+ * data2: "area"
53957
+ * },
52850
53958
  * size: {
52851
53959
  * height: 20
52852
53960
  * },
53961
+ * brush: {
53962
+ * // disable brush(zoom) interaction, rendering the subchart as a static overview
53963
+ * enabled: false
53964
+ * },
53965
+ * grid: {
53966
+ * // set false to hide focus grid line in subchart
53967
+ * // focus: false,
53968
+ * focus: {
53969
+ * // NOTE: works only when 'brush.enabled=false'
53970
+ * continuous: true
53971
+ * }
53972
+ * },
52853
53973
  * init: {
52854
53974
  * // specify initial range domain selection
52855
53975
  * range: [1, 2]
@@ -52864,6 +53984,12 @@ object_extend(subchart, {
52864
53984
  * show: false
52865
53985
  * }
52866
53986
  * }
53987
+ * },
53988
+ * y: {
53989
+ * show: true,
53990
+ * tick: {
53991
+ * count: 3
53992
+ * }
52867
53993
  * }
52868
53994
  * },
52869
53995
  * onbrush: function(domain) { ... }
@@ -52878,12 +54004,46 @@ object_extend(subchart, {
52878
54004
  * }
52879
54005
  */
52880
54006
  subchart_show: false,
54007
+ subchart_type: void 0,
54008
+ subchart_types: {},
54009
+ subchart_brush_enabled: true,
52881
54010
  subchart_showHandle: false,
52882
54011
  subchart_size_height: 60,
54012
+ subchart_grid_focus: true,
54013
+ subchart_grid_focus_continuous: false,
52883
54014
  subchart_axis_x_show: true,
52884
54015
  subchart_axis_x_tick_show: true,
54016
+ subchart_axis_x_tick_count: void 0,
54017
+ subchart_axis_x_tick_values: void 0,
54018
+ subchart_axis_x_tick_culling: void 0,
54019
+ subchart_axis_x_tick_culling_max: void 0,
54020
+ subchart_axis_x_tick_culling_lines: void 0,
54021
+ subchart_axis_x_tick_culling_reverse: void 0,
54022
+ subchart_axis_x_tick_outer: void 0,
52885
54023
  subchart_axis_x_tick_format: void 0,
52886
54024
  subchart_axis_x_tick_text_show: true,
54025
+ subchart_axis_y_show: false,
54026
+ subchart_axis_y_tick_show: true,
54027
+ subchart_axis_y_tick_count: void 0,
54028
+ subchart_axis_y_tick_values: void 0,
54029
+ subchart_axis_y_tick_culling: void 0,
54030
+ subchart_axis_y_tick_culling_max: void 0,
54031
+ subchart_axis_y_tick_culling_lines: void 0,
54032
+ subchart_axis_y_tick_culling_reverse: void 0,
54033
+ subchart_axis_y_tick_outer: void 0,
54034
+ subchart_axis_y_tick_format: void 0,
54035
+ subchart_axis_y_tick_text_show: true,
54036
+ subchart_axis_y2_show: false,
54037
+ subchart_axis_y2_tick_show: true,
54038
+ subchart_axis_y2_tick_count: void 0,
54039
+ subchart_axis_y2_tick_values: void 0,
54040
+ subchart_axis_y2_tick_culling: void 0,
54041
+ subchart_axis_y2_tick_culling_max: void 0,
54042
+ subchart_axis_y2_tick_culling_lines: void 0,
54043
+ subchart_axis_y2_tick_culling_reverse: void 0,
54044
+ subchart_axis_y2_tick_outer: void 0,
54045
+ subchart_axis_y2_tick_format: void 0,
54046
+ subchart_axis_y2_tick_text_show: true,
52887
54047
  subchart_init_range: void 0,
52888
54048
  subchart_onbrush: () => {
52889
54049
  }
@@ -54731,7 +55891,7 @@ function _getStrokeDashArray(start, end, pattern, isLastX = false) {
54731
55891
  if (hasNullDataValue) {
54732
55892
  const dx = x(data.x) - x(prevData.x);
54733
55893
  const dy = y(data.value) - y(prevData.value);
54734
- const dd = Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2));
55894
+ const dd = Math.sqrt(dx * dx + dy * dy);
54735
55895
  diff = style[0] / dd;
54736
55896
  diffx2 = diff * style[1];
54737
55897
  for (let j = diff; j <= 1; j += diffx2) {
@@ -54887,12 +56047,23 @@ function getPointBBox(node) {
54887
56047
  });
54888
56048
  circles.exit().remove();
54889
56049
  const pointR = $$.pointR.bind($$);
54890
- const updateCircleColor = $$.updateCircleColor.bind($$);
56050
+ const updateCircleColor = $$.generateUpdateCircleColor();
54891
56051
  const initialOpacityForCircle = $$.initialOpacityForCircle.bind($$);
54892
56052
  circles.enter().filter(Boolean).append($$.point("create", this, pointR, updateCircleColor));
54893
56053
  $root.circle = $root.main.selectAll(`.${$CIRCLE.circles} .${$CIRCLE.circle}`).style("stroke", $$.getStylePropValue($$.color)).style("opacity", initialOpacityForCircle);
54894
56054
  }
54895
56055
  },
56056
+ /**
56057
+ * Generate circle color accessor, hoisting the bound color function
56058
+ * to be created once per call (not per datum)
56059
+ * @returns {function} Color accessor
56060
+ * @private
56061
+ */
56062
+ generateUpdateCircleColor() {
56063
+ const $$ = this;
56064
+ const fn = $$.getStylePropValue($$.color);
56065
+ return (d) => $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
56066
+ },
54896
56067
  /**
54897
56068
  * Update circle color
54898
56069
  * @param {object} d Data object
@@ -54900,9 +56071,7 @@ function getPointBBox(node) {
54900
56071
  * @private
54901
56072
  */
54902
56073
  updateCircleColor(d) {
54903
- const $$ = this;
54904
- const fn = $$.getStylePropValue($$.color);
54905
- return $$.config.point_radialGradient ? $$.getGradienColortUrl(d.id) : fn ? fn(d) : null;
56074
+ return this.generateUpdateCircleColor()(d);
54906
56075
  },
54907
56076
  redrawCircle(cx, cy, withTransition, flow, isSub = false) {
54908
56077
  const $$ = this;
@@ -54915,6 +56084,7 @@ function getPointBBox(node) {
54915
56084
  const posAttr = $$.isCirclePoint() ? "c" : "";
54916
56085
  const t = getRandom();
54917
56086
  const opacityStyleFn = $$.opacityForCircle.bind($$);
56087
+ const updateCircleColor = $$.generateUpdateCircleColor();
54918
56088
  if ($$.isCirclePoint()) {
54919
56089
  const sel = $root.circle;
54920
56090
  if ($$.hasType("bubble")) {
@@ -54924,12 +56094,12 @@ function getPointBBox(node) {
54924
56094
  flow && sel.attr("cx", cx);
54925
56095
  $T(sel.filter(function() {
54926
56096
  return !!this.getAttribute("cx");
54927
- }), true, `${t}-pos`).attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
56097
+ }), true, `${t}-pos`).attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
54928
56098
  sel.filter(function() {
54929
56099
  return !this.getAttribute("cx");
54930
- }).attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
56100
+ }).attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
54931
56101
  } else {
54932
- sel.attr("cx", cx).attr("cy", cy).style("fill", $$.updateCircleColor.bind($$));
56102
+ sel.attr("cx", cx).attr("cy", cy).style("fill", updateCircleColor);
54933
56103
  }
54934
56104
  const result = $T(sel, withTransition || !rendered, t).style("opacity", opacityStyleFn);
54935
56105
  return [
@@ -54942,7 +56112,7 @@ function getPointBBox(node) {
54942
56112
  $$,
54943
56113
  cx,
54944
56114
  cy,
54945
- $$.updateCircleColor.bind($$),
56115
+ updateCircleColor,
54946
56116
  withTransition,
54947
56117
  flow,
54948
56118
  selectedCircles
@@ -55058,9 +56228,9 @@ function getPointBBox(node) {
55058
56228
  cx = x;
55059
56229
  cy = y;
55060
56230
  }
55061
- return Math.sqrt(
55062
- Math.pow(cx - mouse[0], 2) + Math.pow(cy - mouse[1], 2)
55063
- ) < (r || pointSensitivity);
56231
+ const dx = cx - mouse[0];
56232
+ const dy = cy - mouse[1];
56233
+ return Math.sqrt(dx * dx + dy * dy) < (r || pointSensitivity);
55064
56234
  },
55065
56235
  updatePointClass(d) {
55066
56236
  const $$ = this;
@@ -55655,109 +56825,6 @@ const axis = {
55655
56825
  }
55656
56826
  });
55657
56827
 
55658
- ;// ./node_modules/.pnpm/d3-axis@3.0.0/node_modules/d3-axis/src/identity.js
55659
- /* harmony default export */ function d3_axis_src_identity(x) {
55660
- return x;
55661
- }
55662
-
55663
- ;// ./node_modules/.pnpm/d3-axis@3.0.0/node_modules/d3-axis/src/axis.js
55664
-
55665
- var axis_top = 1, right = 2, bottom = 3, left = 4, axis_epsilon = 1e-6;
55666
- function translateX(x) {
55667
- return "translate(" + x + ",0)";
55668
- }
55669
- function translateY(y) {
55670
- return "translate(0," + y + ")";
55671
- }
55672
- function axis_number(scale) {
55673
- return (d) => +scale(d);
55674
- }
55675
- function center(scale, offset) {
55676
- offset = Math.max(0, scale.bandwidth() - offset * 2) / 2;
55677
- if (scale.round()) offset = Math.round(offset);
55678
- return (d) => +scale(d) + offset;
55679
- }
55680
- function entering() {
55681
- return !this.__axis;
55682
- }
55683
- function axis_axis(orient, scale) {
55684
- var tickArguments = [], tickValues = null, tickFormat = null, tickSizeInner = 6, tickSizeOuter = 6, tickPadding = 3, offset = typeof window !== "undefined" && window.devicePixelRatio > 1 ? 0 : 0.5, k = orient === axis_top || orient === left ? -1 : 1, x = orient === left || orient === right ? "x" : "y", transform = orient === axis_top || orient === bottom ? translateX : translateY;
55685
- function axis2(context) {
55686
- var values = tickValues == null ? scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain() : tickValues, format = tickFormat == null ? scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : d3_axis_src_identity : tickFormat, spacing = Math.max(tickSizeInner, 0) + tickPadding, range = scale.range(), range0 = +range[0] + offset, range1 = +range[range.length - 1] + offset, position = (scale.bandwidth ? center : axis_number)(scale.copy(), offset), selection = context.selection ? context.selection() : context, path = selection.selectAll(".domain").data([null]), tick = selection.selectAll(".tick").data(values, scale).order(), tickExit = tick.exit(), tickEnter = tick.enter().append("g").attr("class", "tick"), line = tick.select("line"), text = tick.select("text");
55687
- path = path.merge(path.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor"));
55688
- tick = tick.merge(tickEnter);
55689
- line = line.merge(tickEnter.append("line").attr("stroke", "currentColor").attr(x + "2", k * tickSizeInner));
55690
- text = text.merge(tickEnter.append("text").attr("fill", "currentColor").attr(x, k * spacing).attr("dy", orient === axis_top ? "0em" : orient === bottom ? "0.71em" : "0.32em"));
55691
- if (context !== selection) {
55692
- path = path.transition(context);
55693
- tick = tick.transition(context);
55694
- line = line.transition(context);
55695
- text = text.transition(context);
55696
- tickExit = tickExit.transition(context).attr("opacity", axis_epsilon).attr("transform", function(d) {
55697
- return isFinite(d = position(d)) ? transform(d + offset) : this.getAttribute("transform");
55698
- });
55699
- tickEnter.attr("opacity", axis_epsilon).attr("transform", function(d) {
55700
- var p = this.parentNode.__axis;
55701
- return transform((p && isFinite(p = p(d)) ? p : position(d)) + offset);
55702
- });
55703
- }
55704
- tickExit.remove();
55705
- path.attr("d", orient === left || orient === right ? tickSizeOuter ? "M" + k * tickSizeOuter + "," + range0 + "H" + offset + "V" + range1 + "H" + k * tickSizeOuter : "M" + offset + "," + range0 + "V" + range1 : tickSizeOuter ? "M" + range0 + "," + k * tickSizeOuter + "V" + offset + "H" + range1 + "V" + k * tickSizeOuter : "M" + range0 + "," + offset + "H" + range1);
55706
- tick.attr("opacity", 1).attr("transform", function(d) {
55707
- return transform(position(d) + offset);
55708
- });
55709
- line.attr(x + "2", k * tickSizeInner);
55710
- text.attr(x, k * spacing).text(format);
55711
- selection.filter(entering).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle");
55712
- selection.each(function() {
55713
- this.__axis = position;
55714
- });
55715
- }
55716
- axis2.scale = function(_) {
55717
- return arguments.length ? (scale = _, axis2) : scale;
55718
- };
55719
- axis2.ticks = function() {
55720
- return tickArguments = Array.from(arguments), axis2;
55721
- };
55722
- axis2.tickArguments = function(_) {
55723
- return arguments.length ? (tickArguments = _ == null ? [] : Array.from(_), axis2) : tickArguments.slice();
55724
- };
55725
- axis2.tickValues = function(_) {
55726
- return arguments.length ? (tickValues = _ == null ? null : Array.from(_), axis2) : tickValues && tickValues.slice();
55727
- };
55728
- axis2.tickFormat = function(_) {
55729
- return arguments.length ? (tickFormat = _, axis2) : tickFormat;
55730
- };
55731
- axis2.tickSize = function(_) {
55732
- return arguments.length ? (tickSizeInner = tickSizeOuter = +_, axis2) : tickSizeInner;
55733
- };
55734
- axis2.tickSizeInner = function(_) {
55735
- return arguments.length ? (tickSizeInner = +_, axis2) : tickSizeInner;
55736
- };
55737
- axis2.tickSizeOuter = function(_) {
55738
- return arguments.length ? (tickSizeOuter = +_, axis2) : tickSizeOuter;
55739
- };
55740
- axis2.tickPadding = function(_) {
55741
- return arguments.length ? (tickPadding = +_, axis2) : tickPadding;
55742
- };
55743
- axis2.offset = function(_) {
55744
- return arguments.length ? (offset = +_, axis2) : offset;
55745
- };
55746
- return axis2;
55747
- }
55748
- function axisTop(scale) {
55749
- return axis_axis(axis_top, scale);
55750
- }
55751
- function axisRight(scale) {
55752
- return axis_axis(right, scale);
55753
- }
55754
- function axisBottom(scale) {
55755
- return axis_axis(bottom, scale);
55756
- }
55757
- function axisLeft(scale) {
55758
- return axis_axis(left, scale);
55759
- }
55760
-
55761
56828
  ;// ./src/ChartInternal/Axis/AxisRendererHelper.ts
55762
56829
  var AxisRendererHelper_defProp = Object.defineProperty;
55763
56830
  var AxisRendererHelper_defNormalProp = (obj, key, value) => key in obj ? AxisRendererHelper_defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -55813,7 +56880,7 @@ class AxisRendererHelper {
55813
56880
  /**
55814
56881
  * Get tick transform setter function
55815
56882
  * @param {string} id Axis id
55816
- * @returns {(selection: d3Selection, scale) => void} transfrom setter function
56883
+ * @returns {function(d3Selection, d3Scale): void} transform setter function
55817
56884
  * @private
55818
56885
  */
55819
56886
  getTickTransformSetter(id) {
@@ -55895,6 +56962,13 @@ var AxisRenderer_publicField = (obj, key, value) => AxisRenderer_defNormalProp(o
55895
56962
 
55896
56963
 
55897
56964
 
56965
+ function getBaseAxisId(id) {
56966
+ return id === "subX" ? "x" : id === "subY" ? "y" : id === "subY2" ? "y2" : id;
56967
+ }
56968
+ function getAxisOptionPrefix(id) {
56969
+ const type = getBaseAxisId(id);
56970
+ return /^sub/.test(id) ? `subchart_axis_${type}` : `axis_${type}`;
56971
+ }
55898
56972
  class AxisRenderer {
55899
56973
  constructor(params = {}) {
55900
56974
  AxisRenderer_publicField(this, "helper");
@@ -55927,8 +57001,8 @@ class AxisRenderer {
55927
57001
  const { config, params } = this;
55928
57002
  const { config: chartConfig, id, owner } = params;
55929
57003
  const isX = /^(x|subX)$/.test(id);
55930
- const type = id === "subX" ? "x" : id;
55931
- const customTickFormat = id === "subX" ? chartConfig.subchart_axis_x_tick_format || chartConfig.axis_x_tick_format : chartConfig[`axis_${type}_tick_format`];
57004
+ const type = getBaseAxisId(id);
57005
+ const customTickFormat = /^sub/.test(id) ? chartConfig[`subchart_axis_${type}_tick_format`] || chartConfig[`axis_${type}_tick_format`] : chartConfig[`axis_${type}_tick_format`];
55932
57006
  const categoryAutoWrap = params.tickMultiline && params.isCategory && !isLeftRight && !(params.tickWidth > 0);
55933
57007
  return !!(owner.state.resizing && !owner.state.flowing && !isFunction(chartConfig.axis_evalTextSize) && !customTickFormat && !params.tickTitle && !(isX && chartConfig.axis_x_tick_autorotate) && !categoryAutoWrap && config.withoutTransition);
55934
57008
  }
@@ -55970,10 +57044,12 @@ class AxisRenderer {
55970
57044
  this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
55971
57045
  const { innerTickSize, tickLength, range } = config;
55972
57046
  const id = params.id;
55973
- const tickTextPos = id && /^(x|y|y2)$/.test(id) ? params.config[`axis_${id}_tick_text_position`] : { x: 0, y: 0 };
55974
- const prefix = id === "subX" ? `subchart_axis_x` : `axis_${id}`;
57047
+ const type = getBaseAxisId(id);
57048
+ const { isSubAxes } = params;
57049
+ const tickTextPos = !isSubAxes && type && /^(x|y|y2)$/.test(type) ? params.config[`axis_${type}_tick_text_position`] : { x: 0, y: 0 };
57050
+ const prefix = getAxisOptionPrefix(id);
55975
57051
  const axisShow = params.config[`${prefix}_show`];
55976
- const tickShow = {
57052
+ const tickShow = isSubAxes ? { tick: true, text: true } : {
55977
57053
  tick: axisShow ? params.config[`${prefix}_tick_show`] : false,
55978
57054
  text: axisShow ? params.config[`${prefix}_tick_text_show`] : false
55979
57055
  };
@@ -56172,7 +57248,7 @@ class AxisRenderer {
56172
57248
  axis_x_tick_text_inner: inner
56173
57249
  }
56174
57250
  } = this.params.owner;
56175
- const tickLineInner = this.params.config[`axis_${axisId}_tick_inner`];
57251
+ const tickLineInner = this.params.config[`axis_${getBaseAxisId(axisId)}_tick_inner`];
56176
57252
  switch (orient) {
56177
57253
  case "bottom":
56178
57254
  lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", (d) => this.getTickSize.bind(this)(d) * (tickLineInner ? -1 : 1));
@@ -56367,7 +57443,17 @@ var Axis_publicField = (obj, key, value) => Axis_defNormalProp(obj, typeof key !
56367
57443
 
56368
57444
 
56369
57445
 
56370
-
57446
+ function Axis_getBaseAxisId(id) {
57447
+ return id === "subX" ? "x" : id === "subY" ? "y" : id === "subY2" ? "y2" : id;
57448
+ }
57449
+ function isSubAxis(id) {
57450
+ return /^sub/.test(id);
57451
+ }
57452
+ function Axis_getAxisTickOption(config, id, key) {
57453
+ const type = Axis_getBaseAxisId(id);
57454
+ const subValue = config[`subchart_axis_${type}_tick_${key}`];
57455
+ return isSubAxis(id) && subValue !== void 0 ? subValue : config[`axis_${type}_tick_${key}`];
57456
+ }
56371
57457
  function _sampleTickNodes(nodes) {
56372
57458
  var _a, _b;
56373
57459
  const sampled = [nodes[0], nodes[nodes.length - 1]];
@@ -56571,6 +57657,8 @@ class Axis_Axis {
56571
57657
  Axis_publicField(this, "owner");
56572
57658
  Axis_publicField(this, "x");
56573
57659
  Axis_publicField(this, "subX");
57660
+ Axis_publicField(this, "subY");
57661
+ Axis_publicField(this, "subY2");
56574
57662
  Axis_publicField(this, "y");
56575
57663
  Axis_publicField(this, "y2");
56576
57664
  Axis_publicField(this, "axesList", {});
@@ -56584,7 +57672,9 @@ class Axis_Axis {
56584
57672
  x: "bottom",
56585
57673
  y: "left",
56586
57674
  y2: "right",
56587
- subX: "bottom"
57675
+ subX: "bottom",
57676
+ subY: "left",
57677
+ subY2: "right"
56588
57678
  });
56589
57679
  this.owner = owner;
56590
57680
  this.setOrient();
@@ -56675,7 +57765,9 @@ class Axis_Axis {
56675
57765
  x: isRotated ? "left" : "bottom",
56676
57766
  y: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
56677
57767
  y2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right",
56678
- subX: isRotated ? "left" : "bottom"
57768
+ subX: isRotated ? "left" : "bottom",
57769
+ subY: isRotated ? yInner ? "top" : "bottom" : yInner ? "right" : "left",
57770
+ subY2: isRotated ? y2Inner ? "bottom" : "top" : y2Inner ? "left" : "right"
56679
57771
  };
56680
57772
  }
56681
57773
  /**
@@ -56690,24 +57782,32 @@ class Axis_Axis {
56690
57782
  const axes = [];
56691
57783
  const axesConfig = config[`axis_${id}_axes`];
56692
57784
  const isRotated = config.axis_rotated;
56693
- let d3Axis;
57785
+ let orient;
56694
57786
  if (id === "x") {
56695
- d3Axis = isRotated ? axisLeft : axisBottom;
57787
+ orient = isRotated ? "left" : "bottom";
56696
57788
  } else if (id === "y") {
56697
- d3Axis = isRotated ? axisBottom : axisLeft;
57789
+ orient = isRotated ? "bottom" : "left";
56698
57790
  } else if (id === "y2") {
56699
- d3Axis = isRotated ? axisTop : axisRight;
57791
+ orient = isRotated ? "top" : "right";
56700
57792
  }
56701
57793
  if (axesConfig.length) {
56702
57794
  axesConfig.forEach((v) => {
56703
57795
  const tick = v.tick || {};
56704
57796
  const scale = $$.scale[id].copy();
56705
57797
  v.domain && scale.domain(v.domain);
56706
- axes.push(
56707
- d3Axis(scale).ticks(tick.count).tickFormat(
56708
- isFunction(tick.format) ? tick.format.bind($$.api) : ((x) => x)
56709
- ).tickValues(tick.values).tickSizeOuter(tick.outer === false ? 0 : AXIS_TICK_SIZE)
57798
+ const axis = new AxisRenderer({
57799
+ outerTick: tick.outer !== false,
57800
+ noTransition: false,
57801
+ config,
57802
+ id,
57803
+ isSubAxes: true,
57804
+ owner: $$
57805
+ }).scale(scale).orient(orient).tickFormat(
57806
+ isFunction(tick.format) ? tick.format.bind($$.api) : ((x) => x)
56710
57807
  );
57808
+ isValue(tick.count) && axis.ticks(tick.count);
57809
+ tick.values && axis.tickValues(tick.values);
57810
+ axes.push(axis);
56711
57811
  });
56712
57812
  }
56713
57813
  this.axesList[id] = axes;
@@ -56731,10 +57831,11 @@ class Axis_Axis {
56731
57831
  const className = `${this.getAxisClassName(id)}-${i + 1}`;
56732
57832
  let g = main.select(`.${className.replace(/\s/, ".")}`);
56733
57833
  if (g.empty()) {
56734
- g = main.append("g").attr("class", className).style("visibility", config[`axis_${id}_show`] ? null : "hidden").call(v);
57834
+ g = main.append("g").attr("class", className).style("visibility", config[`axis_${id}_show`] ? null : "hidden");
57835
+ v.create(g);
56735
57836
  } else {
56736
57837
  axesConfig[i].domain && scale.domain(axesConfig[i].domain);
56737
- $T(g).call(v.scale(scale));
57838
+ v.scale(scale).create($T(g));
56738
57839
  }
56739
57840
  g.attr("transform", $$.getTranslate(id, i + 1));
56740
57841
  });
@@ -56751,8 +57852,9 @@ class Axis_Axis {
56751
57852
  */
56752
57853
  setAxis(id, scale, outerTick, noTransition) {
56753
57854
  const $$ = this.owner;
56754
- if (id !== "subX") {
56755
- this.tick[id] = this.getTickValues(id);
57855
+ const type = Axis_getBaseAxisId(id);
57856
+ if (!isSubAxis(id)) {
57857
+ this.tick[type] = this.getTickValues(type);
56756
57858
  }
56757
57859
  this[id] = this.getAxis(
56758
57860
  id,
@@ -56768,7 +57870,7 @@ class Axis_Axis {
56768
57870
  const $$ = this.owner;
56769
57871
  const { config } = $$;
56770
57872
  const isX = /^(x|subX)$/.test(id);
56771
- const type = isX ? "x" : id;
57873
+ const type = Axis_getBaseAxisId(id);
56772
57874
  const isCategory = isX && this.isCategorized();
56773
57875
  const orient = this.orient[id];
56774
57876
  const tickTextRotate = noTickTextRotate ? 0 : $$.getAxisTickRotate(type);
@@ -56776,12 +57878,12 @@ class Axis_Axis {
56776
57878
  if (isX) {
56777
57879
  tickFormat = id === "subX" ? $$.format.subXAxisTick : $$.format.xAxisTick;
56778
57880
  } else {
56779
- const fn = config[`axis_${id}_tick_format`];
57881
+ const fn = isSubAxis(id) ? config[`subchart_axis_${type}_tick_format`] || config[`axis_${type}_tick_format`] : config[`axis_${type}_tick_format`];
56780
57882
  if (isFunction(fn)) {
56781
57883
  tickFormat = fn.bind($$.api);
56782
57884
  }
56783
57885
  }
56784
- let tickValues = this.tick[type];
57886
+ let tickValues = isSubAxis(id) ? this.getTickValues(type, true) : this.tick[type];
56785
57887
  const axisParams = mergeObj({
56786
57888
  outerTick,
56787
57889
  noTransition,
@@ -56810,7 +57912,7 @@ class Axis_Axis {
56810
57912
  }
56811
57913
  tickValues && axis.tickValues(tickValues);
56812
57914
  axis.tickFormat(
56813
- tickFormat || !isX && ($$.isStackNormalized() && $$.hasAxisGroupedData(id) && ((x) => `${x}%`))
57915
+ tickFormat || !isX && ($$.isStackNormalized() && $$.hasAxisGroupedData(type) && ((x) => `${x}%`))
56814
57916
  );
56815
57917
  if (isCategory) {
56816
57918
  axis.tickCentered(config.axis_x_tick_centered);
@@ -56818,7 +57920,7 @@ class Axis_Axis {
56818
57920
  config.axis_x_tick_culling = false;
56819
57921
  }
56820
57922
  }
56821
- const tickCount = config[`axis_${type}_tick_count`];
57923
+ const tickCount = Axis_getAxisTickOption(config, id, "count");
56822
57924
  tickCount && axis.ticks(tickCount);
56823
57925
  return axis;
56824
57926
  }
@@ -56827,24 +57929,31 @@ class Axis_Axis {
56827
57929
  const $$ = this.owner;
56828
57930
  const { config } = $$;
56829
57931
  const fit = config.axis_x_tick_fit;
56830
- let count = config.axis_x_tick_count;
56831
- let values;
56832
- if (fit) {
56833
- values = $$.mapTargetsToUniqueXs(targets);
56834
- if (this.isCategorized() && count > values.length) {
56835
- count = values.length;
56836
- }
56837
- values = this.generateTickValues(
56838
- values,
56839
- count,
56840
- this.isTimeSeries()
56841
- );
56842
- }
57932
+ const generateValues = (countOption = config.axis_x_tick_count) => {
57933
+ let count = countOption;
57934
+ let values2;
57935
+ if (fit) {
57936
+ values2 = $$.mapTargetsToUniqueXs(targets);
57937
+ if (this.isCategorized() && count > values2.length) {
57938
+ count = values2.length;
57939
+ }
57940
+ values2 = this.generateTickValues(
57941
+ values2,
57942
+ count,
57943
+ this.isTimeSeries()
57944
+ );
57945
+ }
57946
+ return values2;
57947
+ };
57948
+ const values = generateValues();
56843
57949
  if (axis) {
56844
57950
  axis.tickValues(values);
56845
57951
  } else if (this.x) {
57952
+ const subTickValues = this.getTickValues("x", true);
57953
+ const subTickCount = Axis_getAxisTickOption(config, "subX", "count");
57954
+ const subValues = subTickValues != null ? subTickValues : subTickCount !== config.axis_x_tick_count ? generateValues(subTickCount) : values;
56846
57955
  this.x.tickValues(values);
56847
- (_a = this.subX) == null ? void 0 : _a.tickValues(values);
57956
+ (_a = this.subX) == null ? void 0 : _a.tickValues(subValues);
56848
57957
  }
56849
57958
  return values;
56850
57959
  }
@@ -56874,11 +57983,12 @@ class Axis_Axis {
56874
57983
  }
56875
57984
  return isFunction(currFormat) ? (v) => currFormat.apply($$, isCategorized ? [v, $$.categoryName(v)] : [v]) : currFormat;
56876
57985
  }
56877
- getTickValues(id) {
57986
+ getTickValues(id, isSub = false) {
56878
57987
  const $$ = this.owner;
56879
- const tickValues = $$.config[`axis_${id}_tick_values`];
57988
+ const tickValues = isSub ? Axis_getAxisTickOption($$.config, `sub${capitalize(id)}`, "values") : $$.config[`axis_${id}_tick_values`];
57989
+ const values = isFunction(tickValues) ? tickValues.call($$.api) : tickValues;
56880
57990
  const axis = $$[`${id}Axis`];
56881
- return (isFunction(tickValues) ? tickValues.call($$.api) : tickValues) || (axis ? axis.tickValues() : void 0);
57991
+ return isSub ? values != null ? values : void 0 : values || (axis ? axis.tickValues() : void 0);
56882
57992
  }
56883
57993
  getLabelOptionByAxisId(id) {
56884
57994
  return this.owner.config[`axis_${id}_label`];
@@ -57313,14 +58423,21 @@ class Axis_Axis {
57313
58423
  generateTransitions(withTransition) {
57314
58424
  const $$ = this.owner;
57315
58425
  const { $el: { axis }, $T } = $$;
57316
- const [axisX, axisY, axisY2, axisSubX] = ["x", "y", "y2", "subX"].map((v) => $T(axis[v], withTransition));
57317
- return { axisX, axisY, axisY2, axisSubX };
58426
+ const [axisX, axisY, axisY2, axisSubX, axisSubY, axisSubY2] = [
58427
+ "x",
58428
+ "y",
58429
+ "y2",
58430
+ "subX",
58431
+ "subY",
58432
+ "subY2"
58433
+ ].map((v) => $T(axis[v], withTransition));
58434
+ return { axisX, axisY, axisY2, axisSubX, axisSubY, axisSubY2 };
57318
58435
  }
57319
58436
  redraw(transitions, isHidden, isInit) {
57320
58437
  const $$ = this.owner;
57321
58438
  const { config, state, $el } = $$;
57322
58439
  const opacity = isHidden ? "0" : null;
57323
- ["x", "y", "y2", "subX"].forEach((id) => {
58440
+ ["x", "y", "y2", "subX", "subY", "subY2"].forEach((id) => {
57324
58441
  const axis = this[id];
57325
58442
  const $axis = $el.axis[id];
57326
58443
  if (axis && $axis) {
@@ -57342,7 +58459,7 @@ class Axis_Axis {
57342
58459
  * @private
57343
58460
  */
57344
58461
  syncAxisDomains(targetsToShow, wth, flow) {
57345
- var _a, _b, _c;
58462
+ var _a;
57346
58463
  const $$ = this.owner;
57347
58464
  const { config, scale, $el } = $$;
57348
58465
  const hasZoom = !!scale.zoom;
@@ -57388,8 +58505,30 @@ class Axis_Axis {
57388
58505
  }
57389
58506
  });
57390
58507
  if (wth.Y) {
57391
- (_b = scale.subY) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y"));
57392
- (_c = scale.subY2) == null ? void 0 : _c.domain($$.getYDomain(targetsToShow, "y2"));
58508
+ const updateSubDomain = () => {
58509
+ var _a2, _b;
58510
+ (_a2 = scale.subY) == null ? void 0 : _a2.domain($$.getYDomain(targetsToShow, "y"));
58511
+ (_b = scale.subY2) == null ? void 0 : _b.domain($$.getYDomain(targetsToShow, "y2"));
58512
+ ["y", "y2"].forEach((key) => {
58513
+ const subAxisId = key === "y2" ? "subY2" : "subY";
58514
+ const axisScale = scale[subAxisId];
58515
+ const axis = $$.axis[subAxisId];
58516
+ const tickValues = this.getTickValues(key, true);
58517
+ const tickCount = Axis_getAxisTickOption(config, subAxisId, "count");
58518
+ if (!axisScale || !axis || tickValues || !tickCount) {
58519
+ return;
58520
+ }
58521
+ const domain = axisScale.domain();
58522
+ axis.tickValues(
58523
+ this.generateTickValues(
58524
+ domain,
58525
+ domain.every((v) => v === 0) ? 1 : tickCount,
58526
+ this.isTimeSeriesY()
58527
+ )
58528
+ );
58529
+ });
58530
+ };
58531
+ config.subchart_show ? $$.withSubchartTypeContext(updateSubDomain) : updateSubDomain();
57393
58532
  }
57394
58533
  }
57395
58534
  /**
@@ -57417,20 +58556,18 @@ class Axis_Axis {
57417
58556
  setCulling() {
57418
58557
  const $$ = this.owner;
57419
58558
  const { config, state: { clip, current }, $el } = $$;
57420
- ["subX", "x", "y", "y2"].forEach((type) => {
58559
+ ["subX", "x", "y", "y2", "subY", "subY2"].forEach((type) => {
57421
58560
  const axis = $el.axis[type];
57422
- const id = type === "subX" ? "x" : type;
57423
- const cullingOptionPrefix = `axis_${id}_tick_culling`;
57424
- const toCull = config[cullingOptionPrefix];
58561
+ const toCull = Axis_getAxisTickOption(config, type, "culling");
57425
58562
  if (axis && toCull) {
57426
58563
  const tickNodes = axis.selectAll(".tick");
57427
58564
  const tickValues = sortValue(
57428
58565
  tickNodes.data(),
57429
- !config[`${cullingOptionPrefix}_reverse`]
58566
+ !Axis_getAxisTickOption(config, type, "culling_reverse")
57430
58567
  );
57431
58568
  const tickSize = tickValues.length;
57432
- const cullingMax = config[`${cullingOptionPrefix}_max`];
57433
- const lines = config[`${cullingOptionPrefix}_lines`];
58569
+ const cullingMax = Axis_getAxisTickOption(config, type, "culling_max");
58570
+ const lines = Axis_getAxisTickOption(config, type, "culling_lines");
57434
58571
  const cullTickLine = !lines || _hasOverlappedTickLineIntervals(
57435
58572
  this[type],
57436
58573
  tickValues,
@@ -57750,7 +58887,7 @@ var eventrect_pow = Math.pow;
57750
58887
  * @private
57751
58888
  */
57752
58889
  selectRectForSingle(context, index) {
57753
- var _a, _b, _c, _d;
58890
+ var _a, _b, _c, _d, _e, _f, _g;
57754
58891
  const $$ = this;
57755
58892
  const { config, state, $el: { main, circle } } = $$;
57756
58893
  const isSelectionEnabled = config.data_selection_enabled;
@@ -57761,6 +58898,7 @@ var eventrect_pow = Math.pow;
57761
58898
  if (isTooltipGrouped) {
57762
58899
  $$.showTooltip(selectedData, context);
57763
58900
  (_a = $$.showGridFocus) == null ? void 0 : _a.call($$, selectedData);
58901
+ (_b = $$.showSubchartGridFocus) == null ? void 0 : _b.call($$, selectedData);
57764
58902
  if (!isSelectionEnabled || isSelectionGrouped) {
57765
58903
  return;
57766
58904
  }
@@ -57773,7 +58911,7 @@ var eventrect_pow = Math.pow;
57773
58911
  return $$.isWithinShape(this, d);
57774
58912
  });
57775
58913
  shapeAtIndex.call((selected) => {
57776
- var _a2, _b2;
58914
+ var _a2, _b2, _c2;
57777
58915
  const d = selected.data();
57778
58916
  if (isSelectionEnabled && (isSelectionGrouped || (isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)))) {
57779
58917
  context.style.cursor = "pointer";
@@ -57781,7 +58919,8 @@ var eventrect_pow = Math.pow;
57781
58919
  if (!isTooltipGrouped) {
57782
58920
  $$.showTooltip(d, context);
57783
58921
  (_a2 = $$.showGridFocus) == null ? void 0 : _a2.call($$, d);
57784
- (_b2 = $$.unexpandCircles) == null ? void 0 : _b2.call($$);
58922
+ (_b2 = $$.showSubchartGridFocus) == null ? void 0 : _b2.call($$, d);
58923
+ (_c2 = $$.unexpandCircles) == null ? void 0 : _c2.call($$);
57785
58924
  selected.each((d2) => $$.setExpand(index, d2.id));
57786
58925
  }
57787
58926
  });
@@ -57806,14 +58945,16 @@ var eventrect_pow = Math.pow;
57806
58945
  }
57807
58946
  }
57808
58947
  $$.showTooltip([closest], context);
57809
- (_b = $$.showGridFocus) == null ? void 0 : _b.call($$, [closest]);
57810
- (_c = $$.unexpandCircles) == null ? void 0 : _c.call($$);
58948
+ (_c = $$.showGridFocus) == null ? void 0 : _c.call($$, [closest]);
58949
+ (_d = $$.showSubchartGridFocus) == null ? void 0 : _d.call($$, [closest]);
58950
+ (_e = $$.unexpandCircles) == null ? void 0 : _e.call($$);
57811
58951
  $$.setExpand(index, closest.id, true);
57812
58952
  if (isSelectionEnabled && (isSelectionGrouped || (isSelectable == null ? void 0 : isSelectable.bind($$.api)(closest)))) {
57813
58953
  context.style.cursor = "pointer";
57814
58954
  }
57815
58955
  } else if (config.interaction_onout) {
57816
- (_d = $$.hideGridFocus) == null ? void 0 : _d.call($$);
58956
+ (_f = $$.hideGridFocus) == null ? void 0 : _f.call($$);
58957
+ (_g = $$.hideSubchartGridFocus) == null ? void 0 : _g.call($$);
57817
58958
  $$.hideTooltip();
57818
58959
  !isSelectionGrouped && $$.setExpand(index);
57819
58960
  }
@@ -57826,7 +58967,7 @@ var eventrect_pow = Math.pow;
57826
58967
  * @private
57827
58968
  */
57828
58969
  selectRectForMultipleXs(context, triggerEvent = true) {
57829
- var _a;
58970
+ var _a, _b;
57830
58971
  const $$ = this;
57831
58972
  const { config, state } = $$;
57832
58973
  const targetsToShow = $$.getTargetsToShow();
@@ -57848,6 +58989,7 @@ var eventrect_pow = Math.pow;
57848
58989
  $$.showTooltip(selectedData, context);
57849
58990
  $$.setExpand(closest.index, closest.id, true);
57850
58991
  (_a = $$.showGridFocus) == null ? void 0 : _a.call($$, selectedData);
58992
+ (_b = $$.showSubchartGridFocus) == null ? void 0 : _b.call($$, selectedData);
57851
58993
  const dist = $$.dist(closest, mouse);
57852
58994
  if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
57853
58995
  $$.$el.eventRect.style("cursor", "pointer");
@@ -57862,7 +59004,7 @@ var eventrect_pow = Math.pow;
57862
59004
  * @private
57863
59005
  */
57864
59006
  unselectRect() {
57865
- var _a, _b, _c;
59007
+ var _a, _b, _c, _d;
57866
59008
  const $$ = this;
57867
59009
  const { state, $el: { circle, tooltip } } = $$;
57868
59010
  state._lastTooltipMouse = null;
@@ -57873,6 +59015,7 @@ var eventrect_pow = Math.pow;
57873
59015
  }
57874
59016
  (_b = $$.$el.eventRect) == null ? void 0 : _b.style("cursor", null);
57875
59017
  (_c = $$.hideGridFocus) == null ? void 0 : _c.call($$);
59018
+ (_d = $$.hideSubchartGridFocus) == null ? void 0 : _d.call($$);
57876
59019
  if (tooltip) {
57877
59020
  $$.hideTooltip();
57878
59021
  $$._handleLinkedCharts(false);
@@ -59505,6 +60648,18 @@ var eventrect_pow = Math.pow;
59505
60648
 
59506
60649
  ;// ./src/config/Options/axis/y2.ts
59507
60650
  /* harmony default export */ var y2 = ({
60651
+ /**
60652
+ * Set clip-path attribute for y2 axis element
60653
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
60654
+ * @name axis․y2․clipPath
60655
+ * @memberof Options
60656
+ * @type {boolean}
60657
+ * @default true
60658
+ * @example
60659
+ * // don't set 'clip-path' attribute
60660
+ * clipPath: false
60661
+ */
60662
+ axis_y2_clipPath: true,
59508
60663
  /**
59509
60664
  * Show or hide y2 axis.
59510
60665
  * - **NOTE**:
@@ -60003,7 +61158,7 @@ var axis_spreadValues = (a, b) => {
60003
61158
 
60004
61159
 
60005
61160
 
60006
- /* harmony default export */ var Options_axis_axis = (axis_spreadValues(axis_spreadValues(axis_spreadValues({
61161
+ /* harmony default export */ var axis_axis = (axis_spreadValues(axis_spreadValues(axis_spreadValues({
60007
61162
  /**
60008
61163
  * Setup the way to evaluate tick text size.
60009
61164
  * - **NOTE:**
@@ -60284,7 +61439,7 @@ const internal = {
60284
61439
  };
60285
61440
  const options = {
60286
61441
  optDataAxis: data_axis,
60287
- optAxis: Options_axis_axis
61442
+ optAxis: axis_axis
60288
61443
  };
60289
61444
 
60290
61445
  ;// ./src/config/resolver/axis.core.ts
@@ -60396,9 +61551,20 @@ function _getConnectLineType(id) {
60396
61551
  config.bar_linearGradient && $$.updateLinearGradient();
60397
61552
  const bar = $root.main.selectAll(`.${$BAR.bars}`).selectAll(`.${$BAR.bar}`).data($$.labelishData.bind($$));
60398
61553
  $T(bar.exit(), withTransition).style("opacity", "0").remove();
60399
- $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.updateBarColor.bind($$)).merge(bar).style("opacity", initialOpacity);
61554
+ $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.generateUpdateBarColor()).merge(bar).style("opacity", initialOpacity);
60400
61555
  $$.setRatioForGroupedData($root.bar.data());
60401
61556
  },
61557
+ /**
61558
+ * Generate bar color accessor, hoisting the bound color function
61559
+ * to be created once per call (not per datum)
61560
+ * @returns {function} Color accessor
61561
+ * @private
61562
+ */
61563
+ generateUpdateBarColor() {
61564
+ const $$ = this;
61565
+ const fn = $$.getStylePropValue($$.color) || (() => null);
61566
+ return (d) => getShapeColorWithGradient.call($$, d, "bar_linearGradient", fn);
61567
+ },
60402
61568
  /**
60403
61569
  * Update bar color
60404
61570
  * @param {object} d Data object
@@ -60406,9 +61572,7 @@ function _getConnectLineType(id) {
60406
61572
  * @private
60407
61573
  */
60408
61574
  updateBarColor(d) {
60409
- const $$ = this;
60410
- const fn = $$.getStylePropValue($$.color);
60411
- return getShapeColorWithGradient.call($$, d, "bar_linearGradient", fn || (() => null));
61575
+ return this.generateUpdateBarColor()(d);
60412
61576
  },
60413
61577
  /**
60414
61578
  * Redraw function
@@ -60426,28 +61590,51 @@ function _getConnectLineType(id) {
60426
61590
  const { bar } = isSub ? $$.$el.subchart : $$.$el;
60427
61591
  const barPath = [];
60428
61592
  const connectLineCache = /* @__PURE__ */ new Map();
60429
- return [
60430
- $$.$T(bar, withTransition, getRandom()).attr("d", function(d, i, arr) {
60431
- const path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
60432
- let connectLineType = connectLineCache.get(d.id);
60433
- if (connectLineType === void 0) {
60434
- connectLineType = _getConnectLineType.call($$, d.id);
60435
- connectLineCache.set(d.id, connectLineType);
60436
- }
60437
- if (path.length > 1) {
60438
- barPath.push(path[1]);
60439
- }
60440
- if (i === arr.length - 1 && barPath.length) {
60441
- const barConnectLineNode = $$.$T(
60442
- src_select(this.parentNode.querySelector(`.${$BAR.barConnectLine}`)),
60443
- withTransition,
60444
- getRandom()
60445
- );
60446
- $$.updateConnectLine(barConnectLineNode, connectLineType, barPath);
60447
- barPath.splice(0);
61593
+ const getRadius = getBarRadiusResolver($$);
61594
+ const barColor = $$.generateUpdateBarColor();
61595
+ const getBarPath = function(d, i, arr) {
61596
+ var _a;
61597
+ const isDrawable = isNumber(d.value) || $$.isBarRangeType(d) || ((_a = $$.isSubchartCandlestickBarValue) == null ? void 0 : _a.call($$, d, isSub));
61598
+ const path = isDrawable ? drawFn(d, i) : [""];
61599
+ let connectLineType = connectLineCache.get(d.id);
61600
+ if (connectLineType === void 0) {
61601
+ connectLineType = _getConnectLineType.call($$, d.id);
61602
+ connectLineCache.set(d.id, connectLineType);
61603
+ }
61604
+ if (path.length > 1) {
61605
+ barPath.push(path[1]);
61606
+ }
61607
+ if (i === arr.length - 1 && barPath.length) {
61608
+ const barConnectLineNode = $$.$T(
61609
+ src_select(
61610
+ this.parentNode.querySelector(`.${$BAR.barConnectLine}`)
61611
+ ),
61612
+ withTransition,
61613
+ getRandom()
61614
+ );
61615
+ $$.updateConnectLine(barConnectLineNode, connectLineType, barPath);
61616
+ barPath.splice(0);
61617
+ }
61618
+ return path[0];
61619
+ };
61620
+ const barTransition = $$.$T(bar, withTransition, getRandom());
61621
+ if (getRadius && typeof barTransition.attrTween === "function") {
61622
+ barTransition.attrTween(
61623
+ "d",
61624
+ function(d, i, arr) {
61625
+ var _a;
61626
+ const target = getBarPath.call(this, d, i, arr);
61627
+ return getBarPathInterpolator((_a = this.getAttribute("d")) != null ? _a : "", target);
60448
61628
  }
60449
- return path[0];
60450
- }).style("fill", $$.updateBarColor.bind($$)).style("clip-path", (d) => d.clipPath).style("opacity", null)
61629
+ );
61630
+ } else {
61631
+ barTransition.attr("d", getBarPath);
61632
+ }
61633
+ return [
61634
+ barTransition.style("fill", (d) => {
61635
+ var _a;
61636
+ return ((_a = $$.getSubchartCandlestickBarColor) == null ? void 0 : _a.call($$, d, isSub)) || barColor(d);
61637
+ }).style("clip-path", (d) => d.clipPath).style("opacity", null)
60451
61638
  ];
60452
61639
  },
60453
61640
  /**
@@ -60476,6 +61663,7 @@ function _getConnectLineType(id) {
60476
61663
  const getPoints = $$.generateGetBarPoints(barIndices, isSub);
60477
61664
  const getRadius = getBarRadiusResolver($$);
60478
61665
  const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : /* @__PURE__ */ new Set();
61666
+ const connectLineCache = /* @__PURE__ */ new Map();
60479
61667
  return (d, i) => {
60480
61668
  const points = getPoints(d, i);
60481
61669
  const {
@@ -60503,7 +61691,12 @@ function _getConnectLineType(id) {
60503
61691
  }
60504
61692
  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]}`;
60505
61693
  const coords = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
60506
- if (_getConnectLineType.call($$, d.id)) {
61694
+ let connectLineType = connectLineCache.get(d.id);
61695
+ if (connectLineType === void 0) {
61696
+ connectLineType = _getConnectLineType.call($$, d.id);
61697
+ connectLineCache.set(d.id, connectLineType);
61698
+ }
61699
+ if (connectLineType) {
60507
61700
  coords.push(config.axis_rotated ? {
60508
61701
  x: points[0][indexX],
60509
61702
  y: points[0][indexY],
@@ -60875,7 +62068,7 @@ var candlestick_spreadValues = (a, b) => {
60875
62068
  const shapeOffset = $$.getShapeOffset($$.isCandlestickType, indices, !!isSub);
60876
62069
  const yScale = $$.getYScaleById.bind($$);
60877
62070
  return (d, i) => {
60878
- const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id));
62071
+ const y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id, isSub));
60879
62072
  const offset = shapeOffset(d, i) || y0;
60880
62073
  const width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
60881
62074
  const value = $$.getCandlestickData(d);
@@ -62758,7 +63951,6 @@ var funnel_spreadValues = (a, b) => {
62758
63951
 
62759
63952
 
62760
63953
 
62761
-
62762
63954
  function _getSize(checkNeck = false) {
62763
63955
  const $$ = this;
62764
63956
  const { config, state: { current: { width, height } } } = $$;
@@ -62991,7 +64183,7 @@ function _getSplineClipPath() {
62991
64183
  },
62992
64184
  /**
62993
64185
  * Generate funnel coordinate points data for text labels
62994
- * @returns {(d: IDataRow) => [number, number][]} Point getter function
64186
+ * @returns {function(IDataRow): Array.<Array.<number>>} Point getter function
62995
64187
  * @private
62996
64188
  */
62997
64189
  generateGetFunnelPoints() {
@@ -63207,7 +64399,7 @@ let funnel_funnel = () => (extendArc([funnel], [shape_funnel]), (funnel_funnel =
63207
64399
  * @property {number} [gauge.expand.rate=0.98] Set expand rate.
63208
64400
  * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
63209
64401
  * @property {boolean} [gauge.enforceMinMax=false] Enforce to given min/max value.
63210
- * - **Note:** Only works for single data series.
64402
+ * - **Note:** Applies only to unstacked/multi-arc gauges; stacked gauge data is not supported.
63211
64403
  * - When `gauge.min=50` and given value is `30`, gauge will render as empty value.
63212
64404
  * - When `gauge.max=100` and given value is `120`, gauge will render till 100, not surpassing max value.
63213
64405
  * @property {number} [gauge.min=0] Set min value of the gauge.
@@ -64967,7 +66159,7 @@ ${percentValue}%`;
64967
66159
  * - dice ([d3.treemapDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapDice))
64968
66160
  * - slice ([d3.treemapSlice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSlice))
64969
66161
  * - sliceDice ([d3.treemapSliceDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSliceDice))
64970
- * - squrify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
66162
+ * - squarify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
64971
66163
  * - resquarify ([d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapResquarify))
64972
66164
  * @property {function} [treemap.label.format] Set formatter for the label text.<br>
64973
66165
  * - **Arguments:**
@@ -64980,7 +66172,7 @@ ${percentValue}%`;
64980
66172
  * @see [Demo: treemap](https://naver.github.io/billboard.js/demo/#Chart.TreemapChart)
64981
66173
  * @example
64982
66174
  * treemap: {
64983
- * // "binary", "dice", "slice", "sliceDice", "squrify", "resquarify"
66175
+ * // "binary", "dice", "slice", "sliceDice", "squarify", "resquarify"
64984
66176
  * tile: "dice",
64985
66177
  *
64986
66178
  * label: {
@@ -65061,7 +66253,7 @@ const bb = {
65061
66253
  * bb.version; // "1.0.0"
65062
66254
  * @memberof bb
65063
66255
  */
65064
- version: "4.0.2",
66256
+ version: "4.1.0-next.1",
65065
66257
  /**
65066
66258
  * Generate chart
65067
66259
  * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when: