billboard.js 4.0.3 → 4.1.0-next.2

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 (271) hide show
  1. package/README.md +82 -7
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +1848 -494
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +19 -24
  6. package/dist/billboard.pkgd.js +1844 -679
  7. package/dist/billboard.pkgd.min.js +24 -29
  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 +5 -3
  12. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-sparkline.js +6 -3
  14. package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
  15. package/dist/plugin/billboardjs-plugin-stanford.js +6 -3
  16. package/dist/plugin/billboardjs-plugin-stanford.min.js +3 -3
  17. package/dist/plugin/billboardjs-plugin-tableview.js +59 -27
  18. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  19. package/dist/plugin/billboardjs-plugin-textoverlap.js +75 -55
  20. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +5 -3
  22. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +6 -3
  24. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +3 -3
  25. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6 -3
  26. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  27. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +59 -27
  28. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +11 -11
  29. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +68 -3557
  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 -143
  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 +967 -1153
  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 +285 -236
  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 -288
  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 -425
  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 -843
  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/selection.ts +130 -5
  222. package/src/ChartInternal/Axis/Axis.ts +164 -65
  223. package/src/ChartInternal/Axis/AxisRenderer.ts +41 -8
  224. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  225. package/src/ChartInternal/ChartInternal.ts +1 -1
  226. package/src/ChartInternal/data/convert.ts +54 -4
  227. package/src/ChartInternal/data/data.ts +4 -1
  228. package/src/ChartInternal/interactions/eventrect.ts +8 -2
  229. package/src/ChartInternal/interactions/subchart.ts +437 -66
  230. package/src/ChartInternal/internals/color.ts +2 -2
  231. package/src/ChartInternal/internals/domain.ts +15 -3
  232. package/src/ChartInternal/internals/grid.ts +21 -1
  233. package/src/ChartInternal/internals/scale.ts +9 -2
  234. package/src/ChartInternal/internals/selection.ts +1 -1
  235. package/src/ChartInternal/internals/subchart.util.ts +55 -0
  236. package/src/ChartInternal/internals/text.arc.ts +3 -1
  237. package/src/ChartInternal/internals/text.ts +18 -5
  238. package/src/ChartInternal/internals/transform.ts +8 -2
  239. package/src/ChartInternal/internals/type.ts +105 -1
  240. package/src/ChartInternal/shape/IShape.ts +6 -3
  241. package/src/ChartInternal/shape/bar.ts +62 -31
  242. package/src/ChartInternal/shape/core/barRadius.ts +129 -0
  243. package/src/ChartInternal/shape/core/candlestick.ts +1 -1
  244. package/src/ChartInternal/shape/core/path.ts +76 -9
  245. package/src/ChartInternal/shape/funnel.ts +2 -3
  246. package/src/ChartInternal/shape/point.ts +2 -2
  247. package/src/ChartInternal/shape/shape.ts +149 -17
  248. package/src/Plugin/stanford/index.ts +0 -4
  249. package/src/Plugin/tableview/index.ts +85 -3
  250. package/src/Plugin/textoverlap/index.ts +9 -15
  251. package/src/canvas/CanvasAxisRenderer.ts +184 -36
  252. package/src/canvas/CanvasRenderer.ts +247 -160
  253. package/src/canvas/CanvasTheme.ts +212 -0
  254. package/src/canvas/axisTicks.ts +122 -40
  255. package/src/config/Options/axis/y2.ts +13 -0
  256. package/src/config/Options/common/boost.ts +64 -4
  257. package/src/config/Options/common/color.ts +2 -2
  258. package/src/config/Options/interaction/subchart.ts +98 -1
  259. package/src/config/Options/shape/gauge.ts +1 -1
  260. package/src/config/Options/shape/treemap.ts +2 -2
  261. package/src/config/Store/Element.ts +3 -1
  262. package/src/config/Store/State.ts +1 -0
  263. package/src/config/classes.ts +1 -0
  264. package/src/config/resolver/canvas.ts +92 -10
  265. package/src/module/util/type-checks.ts +3 -1
  266. package/src/module/voronoi.ts +119 -0
  267. package/src/module/worker.entry.ts +61 -0
  268. package/src/module/worker.ts +346 -63
  269. package/src/react/index.ts +193 -0
  270. package/types/options.d.ts +206 -3
  271. package/types/react/index.d.ts +27 -0
@@ -5,872 +5,969 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.0.3
8
+ * @version 4.1.0-next.2
9
9
  */
10
- import { document as doc, window as win } from '../module/browser.js';
11
- import { mergeObj } from '../module/util/object.js';
12
-
10
+ import { document as doc, window as win } from "../module/browser.js";
11
+ import { mergeObj } from "../module/util/object.js";
12
+ //#region src/canvas/CanvasTheme.ts
13
13
  /**
14
- * Copyright (c) 2017 ~ present NAVER Corp.
15
- * billboard.js project is licensed under the MIT license
16
- */
14
+ * Copyright (c) 2017 ~ present NAVER Corp.
15
+ * billboard.js project is licensed under the MIT license
16
+ */
17
17
  const SVG_NS = "http://www.w3.org/2000/svg";
18
18
  /**
19
- * Parse CSS numeric value.
20
- * @param {string|number} value CSS value
21
- * @param {number} fallback Fallback value
22
- * @returns {number} Parsed number
23
- * @private
24
- */
19
+ * Parse CSS numeric value.
20
+ * @param {string|number} value CSS value
21
+ * @param {number} fallback Fallback value
22
+ * @returns {number} Parsed number
23
+ * @private
24
+ */
25
25
  function toNumber(value, fallback) {
26
- const parsed = typeof value === "number" ? value : parseFloat(value ?? "");
27
- return Number.isFinite(parsed) ? parsed : fallback;
26
+ const parsed = typeof value === "number" ? value : parseFloat(value ?? "");
27
+ return Number.isFinite(parsed) ? parsed : fallback;
28
28
  }
29
29
  /**
30
- * Resolve effective SVG paint opacity from element opacity and fill-opacity.
31
- * @param {object} value Computed opacity values
32
- * @param {number} fallback Fallback opacity
33
- * @returns {number} Effective opacity
34
- * @private
35
- */
30
+ * Resolve effective SVG paint opacity from element opacity and fill-opacity.
31
+ * @param {object} value Computed opacity values
32
+ * @param {number} fallback Fallback opacity
33
+ * @returns {number} Effective opacity
34
+ * @private
35
+ */
36
36
  function toPaintOpacity(value, fallback) {
37
- const opacity = toNumber(value.opacity, 1);
38
- const fillOpacity = toNumber(value["fill-opacity"], 1);
39
- const result = opacity * fillOpacity;
40
- return Number.isFinite(result) ? result : fallback;
37
+ const result = toNumber(value.opacity, 1) * toNumber(value["fill-opacity"], 1);
38
+ return Number.isFinite(result) ? result : fallback;
41
39
  }
42
40
  /**
43
- * Parse CSS color value.
44
- * @param {string} value CSS color value
45
- * @param {string} fallback Fallback value
46
- * @returns {string} CSS color
47
- * @private
48
- */
41
+ * Parse CSS color value.
42
+ * @param {string} value CSS color value
43
+ * @param {string} fallback Fallback value
44
+ * @returns {string} CSS color
45
+ * @private
46
+ */
49
47
  function toColor(value, fallback) {
50
- const color = value?.trim();
51
- return color && !/^(none|transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i.test(color) ?
52
- color :
53
- fallback;
48
+ const color = value?.trim();
49
+ return color && !/^(none|transparent|rgba\(0,\s*0,\s*0,\s*0\))$/i.test(color) ? color : fallback;
54
50
  }
55
51
  /**
56
- * Parse CSS color value only when it is different from an ignored baseline.
57
- * @param {string} value CSS color value
58
- * @param {string} ignored Ignored baseline color
59
- * @returns {string|undefined} CSS color
60
- * @private
61
- */
52
+ * Parse CSS color value only when it is different from an ignored baseline.
53
+ * @param {string} value CSS color value
54
+ * @param {string} ignored Ignored baseline color
55
+ * @returns {string|undefined} CSS color
56
+ * @private
57
+ */
62
58
  function toOptionalColor(value, ignored) {
63
- const color = toColor(value, "");
64
- const ignoredColor = ignored ? toColor(ignored, "") : "";
65
- return color && color !== ignoredColor ? color : undefined;
59
+ const color = toColor(value, "");
60
+ const ignoredColor = ignored ? toColor(ignored, "") : "";
61
+ return color && color !== ignoredColor ? color : void 0;
66
62
  }
67
63
  /**
68
- * Parse CSS numeric value only when it is different from an ignored baseline.
69
- * @param {string|number} value CSS value
70
- * @param {number} ignored Ignored baseline value
71
- * @returns {number|undefined} Parsed number
72
- * @private
73
- */
64
+ * Parse CSS numeric value only when it is different from an ignored baseline.
65
+ * @param {string|number} value CSS value
66
+ * @param {number} ignored Ignored baseline value
67
+ * @returns {number|undefined} Parsed number
68
+ * @private
69
+ */
74
70
  function toOptionalNumber(value, ignored) {
75
- const parsed = typeof value === "number" ? value : parseFloat(value ?? "");
76
- const ignoredParsed = typeof ignored === "number" ? ignored : parseFloat(ignored ?? "");
77
- return Number.isFinite(parsed) &&
78
- (!Number.isFinite(ignoredParsed) || parsed !== ignoredParsed) ?
79
- parsed :
80
- undefined;
71
+ const parsed = typeof value === "number" ? value : parseFloat(value ?? "");
72
+ const ignoredParsed = typeof ignored === "number" ? ignored : parseFloat(ignored ?? "");
73
+ return Number.isFinite(parsed) && (!Number.isFinite(ignoredParsed) || parsed !== ignoredParsed) ? parsed : void 0;
81
74
  }
82
75
  /**
83
- * Parse CSS dash array value.
84
- * @param {string|Array} value CSS stroke-dasharray value
85
- * @returns {Array} Dash array
86
- * @private
87
- */
76
+ * Parse CSS dash array value.
77
+ * @param {string|Array} value CSS stroke-dasharray value
78
+ * @returns {Array} Dash array
79
+ * @private
80
+ */
88
81
  function toDashArray(value) {
89
- if (Array.isArray(value)) {
90
- return value.filter(v => Number.isFinite(v) && v > 0);
91
- }
92
- return (value || "")
93
- .split(/[,\s]+/)
94
- .map(v => parseFloat(v))
95
- .filter(v => Number.isFinite(v) && v > 0);
82
+ if (Array.isArray(value)) return value.filter((v) => Number.isFinite(v) && v > 0);
83
+ return (value || "").split(/[,\s]+/).map((v) => parseFloat(v)).filter((v) => Number.isFinite(v) && v > 0);
96
84
  }
97
85
  /**
98
- * Get CSS font shorthand usable by canvas.
99
- * @param {CSSStyleDeclaration} style Computed style
100
- * @param {string} fallback Fallback value
101
- * @returns {string} Font shorthand
102
- * @private
103
- */
86
+ * Get CSS font shorthand usable by canvas.
87
+ * @param {CSSStyleDeclaration} style Computed style
88
+ * @param {string} fallback Fallback value
89
+ * @returns {string} Font shorthand
90
+ * @private
91
+ */
104
92
  function toFont(style, fallback) {
105
- const font = style.getPropertyValue("font").trim();
106
- if (font) {
107
- return font;
108
- }
109
- const fontSize = style.getPropertyValue("font-size").trim();
110
- const fontFamily = style.getPropertyValue("font-family").trim();
111
- if (!fontSize || !fontFamily) {
112
- return fallback;
113
- }
114
- const fontStyle = style.getPropertyValue("font-style").trim();
115
- const fontVariant = style.getPropertyValue("font-variant").trim();
116
- const fontWeight = style.getPropertyValue("font-weight").trim();
117
- const lineHeight = style.getPropertyValue("line-height").trim();
118
- const size = lineHeight && lineHeight !== "normal" ? `${fontSize}/${lineHeight}` : fontSize;
119
- return [
120
- fontStyle && fontStyle !== "normal" ? fontStyle : "",
121
- fontVariant && fontVariant !== "normal" ? fontVariant : "",
122
- fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
123
- size,
124
- fontFamily
125
- ].filter(Boolean).join(" ");
93
+ const font = style.getPropertyValue("font").trim();
94
+ if (font) return font;
95
+ const fontSize = style.getPropertyValue("font-size").trim();
96
+ const fontFamily = style.getPropertyValue("font-family").trim();
97
+ if (!fontSize || !fontFamily) return fallback;
98
+ const fontStyle = style.getPropertyValue("font-style").trim();
99
+ const fontVariant = style.getPropertyValue("font-variant").trim();
100
+ const fontWeight = style.getPropertyValue("font-weight").trim();
101
+ const lineHeight = style.getPropertyValue("line-height").trim();
102
+ const size = lineHeight && lineHeight !== "normal" ? `${fontSize}/${lineHeight}` : fontSize;
103
+ return [
104
+ fontStyle && fontStyle !== "normal" ? fontStyle : "",
105
+ fontVariant && fontVariant !== "normal" ? fontVariant : "",
106
+ fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
107
+ size,
108
+ fontFamily
109
+ ].filter(Boolean).join(" ");
126
110
  }
127
111
  /**
128
- * Get style declaration value by CSS property name.
129
- * @param {object} style Style declaration object
130
- * @param {string} prop CSS property name
131
- * @returns {string|number|Array|undefined} Style value
132
- * @private
133
- */
112
+ * Get style declaration value by CSS property name.
113
+ * @param {object} style Style declaration object
114
+ * @param {string} prop CSS property name
115
+ * @returns {string|number|Array|undefined} Style value
116
+ * @private
117
+ */
134
118
  function getStyleValue(style, prop) {
135
- const camelProp = prop.replace(/-([a-z])/g, (all, chr) => chr.toUpperCase());
136
- return style[prop] ?? style[camelProp];
119
+ const camelProp = prop.replace(/-([a-z])/g, (all, chr) => chr.toUpperCase());
120
+ return style[prop] ?? style[camelProp];
137
121
  }
138
122
  /**
139
- * Read color from selector style declaration.
140
- * @param {object} style Style declaration object
141
- * @param {string} prop CSS property name
142
- * @returns {string|undefined} Color value
143
- * @private
144
- */
123
+ * Read color from selector style declaration.
124
+ * @param {object} style Style declaration object
125
+ * @param {string} prop CSS property name
126
+ * @returns {string|undefined} Color value
127
+ * @private
128
+ */
145
129
  function readColorValue(style, prop) {
146
- const value = getStyleValue(style, prop);
147
- const color = value == null ? "" : toColor(String(value), "");
148
- return color || undefined;
130
+ const value = getStyleValue(style, prop);
131
+ return (value == null ? "" : toColor(String(value), "")) || void 0;
149
132
  }
150
133
  /**
151
- * Read numeric value from selector style declaration.
152
- * @param {object} style Style declaration object
153
- * @param {string} prop CSS property name
154
- * @returns {number|undefined} Numeric value
155
- * @private
156
- */
134
+ * Read numeric value from selector style declaration.
135
+ * @param {object} style Style declaration object
136
+ * @param {string} prop CSS property name
137
+ * @returns {number|undefined} Numeric value
138
+ * @private
139
+ */
157
140
  function readNumberValue(style, prop) {
158
- const value = getStyleValue(style, prop);
159
- const parsed = typeof value === "number" ? value : parseFloat(String(value ?? ""));
160
- return Number.isFinite(parsed) ? parsed : undefined;
141
+ const value = getStyleValue(style, prop);
142
+ const parsed = typeof value === "number" ? value : parseFloat(String(value ?? ""));
143
+ return Number.isFinite(parsed) ? parsed : void 0;
161
144
  }
162
145
  /**
163
- * Read paint opacity from selector style declaration.
164
- * @param {object} style Style declaration object
165
- * @returns {number|undefined} Paint opacity
166
- * @private
167
- */
146
+ * Read paint opacity from selector style declaration.
147
+ * @param {object} style Style declaration object
148
+ * @returns {number|undefined} Paint opacity
149
+ * @private
150
+ */
168
151
  function readPaintOpacityValue(style) {
169
- const opacity = readNumberValue(style, "opacity");
170
- const fillOpacity = readNumberValue(style, "fill-opacity");
171
- return opacity === undefined && fillOpacity === undefined ?
172
- undefined :
173
- (opacity ?? 1) * (fillOpacity ?? 1);
152
+ const opacity = readNumberValue(style, "opacity");
153
+ const fillOpacity = readNumberValue(style, "fill-opacity");
154
+ return opacity === void 0 && fillOpacity === void 0 ? void 0 : (opacity ?? 1) * (fillOpacity ?? 1);
174
155
  }
175
156
  /**
176
- * Read dash array from selector style declaration.
177
- * @param {object} style Style declaration object
178
- * @returns {Array|undefined} Dash array
179
- * @private
180
- */
157
+ * Read dash array from selector style declaration.
158
+ * @param {object} style Style declaration object
159
+ * @returns {Array|undefined} Dash array
160
+ * @private
161
+ */
181
162
  function readDashArrayValue(style) {
182
- const value = getStyleValue(style, "stroke-dasharray");
183
- const dashArray = value == null ? [] : toDashArray(value);
184
- return dashArray.length ? dashArray : undefined;
163
+ const value = getStyleValue(style, "stroke-dasharray");
164
+ const dashArray = value == null ? [] : toDashArray(value);
165
+ return dashArray.length ? dashArray : void 0;
185
166
  }
186
167
  /**
187
- * Read font shorthand from selector style declaration.
188
- * @param {object} style Style declaration object
189
- * @returns {string|undefined} Font shorthand
190
- * @private
191
- */
168
+ * Read font shorthand from selector style declaration.
169
+ * @param {object} style Style declaration object
170
+ * @returns {string|undefined} Font shorthand
171
+ * @private
172
+ */
192
173
  function readFontValue(style) {
193
- const font = getStyleValue(style, "font");
194
- if (font != null && String(font).trim()) {
195
- return String(font).trim();
196
- }
197
- const fontSize = getStyleValue(style, "font-size");
198
- const fontFamily = getStyleValue(style, "font-family");
199
- if (fontSize == null || fontFamily == null) {
200
- return undefined;
201
- }
202
- const size = String(fontSize).trim();
203
- const family = String(fontFamily).trim();
204
- if (!size || !family) {
205
- return undefined;
206
- }
207
- const fontStyle = String(getStyleValue(style, "font-style") ?? "").trim();
208
- const fontVariant = String(getStyleValue(style, "font-variant") ?? "").trim();
209
- const fontWeight = String(getStyleValue(style, "font-weight") ?? "").trim();
210
- const lineHeight = String(getStyleValue(style, "line-height") ?? "").trim();
211
- return [
212
- fontStyle && fontStyle !== "normal" ? fontStyle : "",
213
- fontVariant && fontVariant !== "normal" ? fontVariant : "",
214
- fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
215
- lineHeight && lineHeight !== "normal" ? `${size}/${lineHeight}` : size,
216
- family
217
- ].filter(Boolean).join(" ");
174
+ const font = getStyleValue(style, "font");
175
+ if (font != null && String(font).trim()) return String(font).trim();
176
+ const fontSize = getStyleValue(style, "font-size");
177
+ const fontFamily = getStyleValue(style, "font-family");
178
+ if (fontSize == null || fontFamily == null) return;
179
+ const size = String(fontSize).trim();
180
+ const family = String(fontFamily).trim();
181
+ if (!size || !family) return;
182
+ const fontStyle = String(getStyleValue(style, "font-style") ?? "").trim();
183
+ const fontVariant = String(getStyleValue(style, "font-variant") ?? "").trim();
184
+ const fontWeight = String(getStyleValue(style, "font-weight") ?? "").trim();
185
+ const lineHeight = String(getStyleValue(style, "line-height") ?? "").trim();
186
+ return [
187
+ fontStyle && fontStyle !== "normal" ? fontStyle : "",
188
+ fontVariant && fontVariant !== "normal" ? fontVariant : "",
189
+ fontWeight && !/^(normal|400)$/.test(fontWeight) ? fontWeight : "",
190
+ lineHeight && lineHeight !== "normal" ? `${size}/${lineHeight}` : size,
191
+ family
192
+ ].filter(Boolean).join(" ");
218
193
  }
219
194
  /**
220
- * Merge selector style values to a canvas theme section.
221
- * @param {object} target Theme override target
222
- * @param {string} section Theme section name
223
- * @param {object} values Theme section values
224
- * @private
225
- */
195
+ * Merge selector style values to a canvas theme section.
196
+ * @param {object} target Theme override target
197
+ * @param {string} section Theme section name
198
+ * @param {object} values Theme section values
199
+ * @private
200
+ */
226
201
  function mergeThemeSection(target, section, values) {
227
- const override = Object.keys(values).reduce((acc, key) => {
228
- values[key] !== undefined && (acc[key] = values[key]);
229
- return acc;
230
- }, {});
231
- if (Object.keys(override).length) {
232
- target[section] = mergeObj(target[section] ?? {}, override);
233
- }
202
+ const override = Object.keys(values).reduce((acc, key) => {
203
+ values[key] !== void 0 && (acc[key] = values[key]);
204
+ return acc;
205
+ }, {});
206
+ if (Object.keys(override).length) target[section] = mergeObj(target[section] ?? {}, override);
234
207
  }
235
208
  /**
236
- * Normalize a supported SVG selector for canvas theme matching.
237
- * @param {string} selector SVG selector
238
- * @returns {Array} Normalized selector list
239
- * @private
240
- */
209
+ * Normalize a supported SVG selector for canvas theme matching.
210
+ * @param {string} selector SVG selector
211
+ * @returns {Array} Normalized selector list
212
+ * @private
213
+ */
241
214
  function normalizeThemeSelectors(selector) {
242
- return selector.split(",")
243
- .map(value => value.trim()
244
- .replace(/\s*>\s*/g, " ")
245
- .replace(/\s+/g, " ")
246
- .replace(/^(?:svg)?\.bb\s+/, "")
247
- .replace(/(^|\s)(?:g|path|rect|line|text|circle)\./g, "$1."))
248
- .filter(Boolean);
215
+ return selector.split(",").map((value) => value.trim().replace(/\s*>\s*/g, " ").replace(/\s+/g, " ").replace(/^(?:svg)?\.bb\s+/, "").replace(/(^|\s)(?:g|path|rect|line|text|circle)\./g, "$1.")).filter(Boolean);
216
+ }
217
+ /**
218
+ * Get own keys from a style object whose values are set.
219
+ * @param {object} values Style values
220
+ * @returns {Array} Defined keys
221
+ * @private
222
+ */
223
+ function getDefinedKeys(values) {
224
+ return Object.keys(values).filter((key) => values[key] !== void 0);
225
+ }
226
+ /**
227
+ * Copy the defined entries of an object into a target of the same shape.
228
+ * @param {object} target Object to copy into
229
+ * @param {object} source Object to copy from
230
+ * @param {Set} skip Keys to leave untouched
231
+ * @returns {object} The target object
232
+ * @private
233
+ */
234
+ function assignDefined(target, source, skip) {
235
+ getDefinedKeys(source).forEach((key) => {
236
+ if (!skip?.has(key)) target[key] = source[key];
237
+ });
238
+ return target;
239
+ }
240
+ /**
241
+ * Check whether a selector is simple enough for virtual optional grid line matching.
242
+ * @param {string} selector Normalized SVG selector
243
+ * @returns {boolean} Whether selector can be matched
244
+ * @private
245
+ */
246
+ function isSimpleGridLineSelector(selector) {
247
+ const tokens = selector.split(" ");
248
+ return tokens.every((token, index) => token === "line" || token === "text" ? index === tokens.length - 1 : /^(\.[A-Za-z_-][\w-]*)+$/.test(token));
249
+ }
250
+ /**
251
+ * Get optional grid line selector target.
252
+ * @param {string} selector Normalized SVG selector
253
+ * @returns {string|null} Selector target
254
+ * @private
255
+ */
256
+ function getGridLineSelectorTarget(selector) {
257
+ const tokens = selector.split(" ");
258
+ const target = tokens[tokens.length - 1];
259
+ return target === "line" || target === "text" ? target : null;
260
+ }
261
+ /**
262
+ * Split custom class value.
263
+ * @param {string} className Custom class value
264
+ * @returns {Array} Class names
265
+ * @private
266
+ */
267
+ function getClassNames(className) {
268
+ return (className || "").split(/\s+/).filter(Boolean);
269
+ }
270
+ /**
271
+ * Read optional grid line or label style from selector style declaration.
272
+ * @param {object} style Style declaration object
273
+ * @param {string} target Selector target
274
+ * @returns {object} Grid line style
275
+ * @private
276
+ */
277
+ function getGridLineSelectorStyle(style, target) {
278
+ return assignDefined({}, target === "text" ? {
279
+ labelColor: readColorValue(style, "fill"),
280
+ labelFont: readFontValue(style)
281
+ } : {
282
+ lineColor: readColorValue(style, "stroke"),
283
+ lineWidth: readNumberValue(style, "stroke-width"),
284
+ dashArray: readDashArrayValue(style)
285
+ });
249
286
  }
250
287
  /**
251
- * Apply one selector style declaration to canvas theme override.
252
- * @param {object} target Theme override target
253
- * @param {string} selector SVG selector
254
- * @param {object} style Style declaration object
255
- * @private
256
- */
288
+ * Convert selector based optional grid line overrides to ordered matcher entries.
289
+ * @param {object} selectors Selector style declarations
290
+ * @returns {Array} Optional grid line selector overrides
291
+ * @private
292
+ */
293
+ function getGridLineSelectorOverrides(selectors) {
294
+ const overrides = [];
295
+ Object.keys(selectors ?? {}).forEach((selector) => {
296
+ normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
297
+ const target = getGridLineSelectorTarget(normalizedSelector) || "line";
298
+ const style = getGridLineSelectorStyle(selectors[selector], target);
299
+ if (isSimpleGridLineSelector(normalizedSelector) && getDefinedKeys(style).length) overrides.push({
300
+ selector: normalizedSelector,
301
+ target,
302
+ style
303
+ });
304
+ });
305
+ });
306
+ return overrides;
307
+ }
308
+ /**
309
+ * Check whether a virtual optional grid line selector matches a grid line config.
310
+ * @param {string} selector Normalized SVG selector
311
+ * @param {string} axis Grid axis
312
+ * @param {string} className Grid line custom class
313
+ * @param {string} target Draw target
314
+ * @returns {boolean} Whether selector matches
315
+ * @private
316
+ */
317
+ function matchesGridLineSelector(selector, axis, className, target) {
318
+ if (!isSimpleGridLineSelector(selector)) return false;
319
+ const selectorTarget = getGridLineSelectorTarget(selector);
320
+ if (selectorTarget && selectorTarget !== target) return false;
321
+ else if (!selectorTarget && target === "text") return false;
322
+ const customClasses = getClassNames(className);
323
+ const axisLineClass = `bb-${axis}grid-line`;
324
+ const availableClasses = /* @__PURE__ */ new Set([
325
+ "bb-grid",
326
+ "bb-grid-lines",
327
+ `bb-${axis}grid-lines`,
328
+ axisLineClass,
329
+ ...customClasses
330
+ ]);
331
+ const selectorClasses = (selector.match(/\.[A-Za-z_-][\w-]*/g) || []).map((match) => match.slice(1));
332
+ return !!selectorClasses.length && selectorClasses.every((cls) => availableClasses.has(cls)) && (selectorClasses.includes(axisLineClass) || customClasses.some((cls) => selectorClasses.includes(cls)));
333
+ }
334
+ /**
335
+ * Apply one selector style declaration to canvas theme override.
336
+ * @param {object} target Theme override target
337
+ * @param {string} selector SVG selector
338
+ * @param {object} style Style declaration object
339
+ * @private
340
+ */
257
341
  function applySelectorStyle(target, selector, style) {
258
- switch (selector) {
259
- case ".bb-axis path.domain":
260
- case ".bb-axis .domain":
261
- case ".bb-axis-x path.domain":
262
- case ".bb-axis-x .domain":
263
- case ".bb-axis-y path.domain":
264
- case ".bb-axis-y .domain":
265
- case ".bb-axis-y2 path.domain":
266
- case ".bb-axis-y2 .domain":
267
- mergeThemeSection(target, "axis", {
268
- lineColor: readColorValue(style, "stroke"),
269
- lineWidth: readNumberValue(style, "stroke-width")
270
- });
271
- break;
272
- case ".bb-axis line":
273
- case ".bb-axis .tick line":
274
- case ".bb-axis-x line":
275
- case ".bb-axis-x .tick line":
276
- case ".bb-axis-y line":
277
- case ".bb-axis-y .tick line":
278
- case ".bb-axis-y2 line":
279
- case ".bb-axis-y2 .tick line":
280
- mergeThemeSection(target, "axis", {
281
- tickColor: readColorValue(style, "stroke"),
282
- tickWidth: readNumberValue(style, "stroke-width")
283
- });
284
- break;
285
- case ".bb-axis text":
286
- case ".bb-axis .tick text": {
287
- const font = readFontValue(style);
288
- mergeThemeSection(target, "axis", {
289
- labelColor: readColorValue(style, "fill"),
290
- xTickFont: font,
291
- yTickFont: font,
292
- y2TickFont: font
293
- });
294
- break;
295
- }
296
- case ".bb-axis-x text":
297
- case ".bb-axis-x .tick text":
298
- mergeThemeSection(target, "axis", {
299
- labelColor: readColorValue(style, "fill"),
300
- xTickFont: readFontValue(style)
301
- });
302
- break;
303
- case ".bb-axis-y text":
304
- case ".bb-axis-y .tick text":
305
- mergeThemeSection(target, "axis", {
306
- labelColor: readColorValue(style, "fill"),
307
- yTickFont: readFontValue(style)
308
- });
309
- break;
310
- case ".bb-axis-y2 text":
311
- case ".bb-axis-y2 .tick text":
312
- mergeThemeSection(target, "axis", {
313
- labelColor: readColorValue(style, "fill"),
314
- y2TickFont: readFontValue(style)
315
- });
316
- break;
317
- case ".tick._active_ text":
318
- case ".bb-axis .tick._active_ text":
319
- case ".bb-axis-x .tick._active_ text":
320
- mergeThemeSection(target, "axis", {
321
- activeLabelColor: readColorValue(style, "fill")
322
- });
323
- break;
324
- case ".bb-axis-x-label":
325
- case ".bb-axis-x .bb-axis-x-label":
326
- mergeThemeSection(target, "axis", {
327
- labelFont: readFontValue(style),
328
- xLabelColor: readColorValue(style, "fill")
329
- });
330
- break;
331
- case ".bb-axis-y-label":
332
- case ".bb-axis-y .bb-axis-y-label":
333
- mergeThemeSection(target, "axis", {
334
- labelFont: readFontValue(style),
335
- yLabelColor: readColorValue(style, "fill")
336
- });
337
- break;
338
- case ".bb-axis-y2-label":
339
- case ".bb-axis-y2 .bb-axis-y2-label":
340
- mergeThemeSection(target, "axis", {
341
- labelFont: readFontValue(style),
342
- y2LabelColor: readColorValue(style, "fill")
343
- });
344
- break;
345
- case ".bb-grid line":
346
- case ".bb-grid .bb-xgrid":
347
- case ".bb-grid .bb-ygrid":
348
- case ".bb-xgrid":
349
- case ".bb-ygrid":
350
- mergeThemeSection(target, "grid", {
351
- lineColor: readColorValue(style, "stroke"),
352
- lineWidth: readNumberValue(style, "stroke-width"),
353
- dashArray: readDashArrayValue(style)
354
- });
355
- break;
356
- case ".bb-grid text":
357
- mergeThemeSection(target, "grid", {
358
- labelColor: readColorValue(style, "fill"),
359
- labelFont: readFontValue(style)
360
- });
361
- break;
362
- case ".bb-xgrid-focus line":
363
- case ".bb-grid .bb-xgrid-focus line":
364
- case ".bb-grid .bb-xgrid-focus":
365
- mergeThemeSection(target, "focusGrid", {
366
- lineColor: readColorValue(style, "stroke"),
367
- lineWidth: readNumberValue(style, "stroke-width"),
368
- dashArray: readDashArrayValue(style)
369
- });
370
- break;
371
- case ".bb-region rect":
372
- case ".bb-region":
373
- mergeThemeSection(target, "region", {
374
- fill: readColorValue(style, "fill"),
375
- opacity: readPaintOpacityValue(style)
376
- });
377
- break;
378
- case ".bb-region text":
379
- mergeThemeSection(target, "region", {
380
- labelColor: readColorValue(style, "fill"),
381
- labelFont: readFontValue(style)
382
- });
383
- break;
384
- case ".bb-bar":
385
- mergeThemeSection(target, "shape", {
386
- barOpacity: readPaintOpacityValue(style),
387
- barStrokeColor: readColorValue(style, "stroke"),
388
- barLineWidth: readNumberValue(style, "stroke-width")
389
- });
390
- break;
391
- case ".bb-bar._expanded_":
392
- mergeThemeSection(target, "shape", {
393
- barExpandedOpacity: readPaintOpacityValue(style)
394
- });
395
- break;
396
- case ".bb-candlestick":
397
- mergeThemeSection(target, "shape", {
398
- candlestickStrokeColor: readColorValue(style, "stroke"),
399
- candlestickLineWidth: readNumberValue(style, "stroke-width")
400
- });
401
- break;
402
- case ".bb-candlestick._expanded_":
403
- mergeThemeSection(target, "shape", {
404
- candlestickExpandedOpacity: readPaintOpacityValue(style)
405
- });
406
- break;
407
- case ".bb-line":
408
- mergeThemeSection(target, "shape", {
409
- barConnectLineColor: readColorValue(style, "stroke"),
410
- barConnectLineWidth: readNumberValue(style, "stroke-width"),
411
- lineWidth: readNumberValue(style, "stroke-width")
412
- });
413
- break;
414
- case ".bb-target.bb-focused .bb-line":
415
- case ".bb-target.bb-focused path.bb-line":
416
- mergeThemeSection(target, "shape", {
417
- lineFocusedWidth: readNumberValue(style, "stroke-width")
418
- });
419
- break;
420
- case ".bb-target.bb-defocused":
421
- mergeThemeSection(target, "shape", {
422
- targetDefocusedOpacity: readNumberValue(style, "opacity")
423
- });
424
- break;
425
- case ".bb-area":
426
- mergeThemeSection(target, "shape", {
427
- areaOpacity: readPaintOpacityValue(style)
428
- });
429
- break;
430
- case ".bb-circle":
431
- mergeThemeSection(target, "shape", {
432
- pointFillColor: readColorValue(style, "fill"),
433
- pointStrokeColor: readColorValue(style, "stroke"),
434
- pointLineWidth: readNumberValue(style, "stroke-width")
435
- });
436
- break;
437
- case ".bb-selected-circle":
438
- mergeThemeSection(target, "selectedPoint", {
439
- fill: readColorValue(style, "fill"),
440
- stroke: readColorValue(style, "stroke"),
441
- lineWidth: readNumberValue(style, "stroke-width")
442
- });
443
- break;
444
- case ".bb-circle._expanded_":
445
- mergeThemeSection(target, "focusPoint", {
446
- fill: readColorValue(style, "fill"),
447
- stroke: readColorValue(style, "stroke"),
448
- lineWidth: readNumberValue(style, "stroke-width")
449
- });
450
- break;
451
- case ".bb-zoom-brush":
452
- mergeThemeSection(target, "zoomBrush", {
453
- fill: readColorValue(style, "fill"),
454
- opacity: readPaintOpacityValue(style)
455
- });
456
- break;
457
- case ".bb-brush .extent":
458
- case ".bb-brush .selection":
459
- mergeThemeSection(target, "subchartBrush", {
460
- fill: readColorValue(style, "fill"),
461
- opacity: readPaintOpacityValue(style)
462
- });
463
- break;
464
- case ".bb-brush .handle--custom":
465
- mergeThemeSection(target, "subchartBrush", {
466
- handleFill: readColorValue(style, "fill"),
467
- handleOpacity: readPaintOpacityValue(style),
468
- handleStroke: readColorValue(style, "stroke"),
469
- handleLineWidth: readNumberValue(style, "stroke-width")
470
- });
471
- break;
472
- case ".bb-chart-treemaps rect":
473
- case ".bb-chart-treemaps":
474
- mergeThemeSection(target, "treemap", {
475
- stroke: readColorValue(style, "stroke"),
476
- lineWidth: readNumberValue(style, "stroke-width")
477
- });
478
- break;
479
- case ".bb-text.bb-empty":
480
- case ".bb-text .bb-empty":
481
- case ".bb-empty":
482
- mergeThemeSection(target, "emptyLabel", {
483
- color: readColorValue(style, "fill"),
484
- font: readFontValue(style)
485
- });
486
- break;
487
- case ".bb-text":
488
- mergeThemeSection(target, "label", {
489
- color: readColorValue(style, "fill"),
490
- font: readFontValue(style)
491
- });
492
- break;
493
- case ".bb-title":
494
- mergeThemeSection(target, "title", {
495
- color: readColorValue(style, "fill"),
496
- font: readFontValue(style)
497
- });
498
- break;
499
- }
342
+ switch (selector) {
343
+ case ".bb-axis path.domain":
344
+ case ".bb-axis .domain":
345
+ case ".bb-axis-x path.domain":
346
+ case ".bb-axis-x .domain":
347
+ case ".bb-axis-y path.domain":
348
+ case ".bb-axis-y .domain":
349
+ case ".bb-axis-y2 path.domain":
350
+ case ".bb-axis-y2 .domain":
351
+ mergeThemeSection(target, "axis", {
352
+ lineColor: readColorValue(style, "stroke"),
353
+ lineWidth: readNumberValue(style, "stroke-width")
354
+ });
355
+ break;
356
+ case ".bb-axis line":
357
+ case ".bb-axis .tick line":
358
+ case ".bb-axis-x line":
359
+ case ".bb-axis-x .tick line":
360
+ case ".bb-axis-y line":
361
+ case ".bb-axis-y .tick line":
362
+ case ".bb-axis-y2 line":
363
+ case ".bb-axis-y2 .tick line":
364
+ mergeThemeSection(target, "axis", {
365
+ tickColor: readColorValue(style, "stroke"),
366
+ tickWidth: readNumberValue(style, "stroke-width")
367
+ });
368
+ break;
369
+ case ".bb-axis text":
370
+ case ".bb-axis .tick text": {
371
+ const font = readFontValue(style);
372
+ mergeThemeSection(target, "axis", {
373
+ labelColor: readColorValue(style, "fill"),
374
+ xTickFont: font,
375
+ yTickFont: font,
376
+ y2TickFont: font
377
+ });
378
+ break;
379
+ }
380
+ case ".bb-axis-x text":
381
+ case ".bb-axis-x .tick text":
382
+ mergeThemeSection(target, "axis", {
383
+ labelColor: readColorValue(style, "fill"),
384
+ xTickFont: readFontValue(style)
385
+ });
386
+ break;
387
+ case ".bb-axis-y text":
388
+ case ".bb-axis-y .tick text":
389
+ mergeThemeSection(target, "axis", {
390
+ labelColor: readColorValue(style, "fill"),
391
+ yTickFont: readFontValue(style)
392
+ });
393
+ break;
394
+ case ".bb-axis-y2 text":
395
+ case ".bb-axis-y2 .tick text":
396
+ mergeThemeSection(target, "axis", {
397
+ labelColor: readColorValue(style, "fill"),
398
+ y2TickFont: readFontValue(style)
399
+ });
400
+ break;
401
+ case ".tick._active_ text":
402
+ case ".bb-axis .tick._active_ text":
403
+ case ".bb-axis-x .tick._active_ text":
404
+ mergeThemeSection(target, "axis", { activeLabelColor: readColorValue(style, "fill") });
405
+ break;
406
+ case ".bb-axis-x-label":
407
+ case ".bb-axis-x .bb-axis-x-label":
408
+ mergeThemeSection(target, "axis", {
409
+ labelFont: readFontValue(style),
410
+ xLabelColor: readColorValue(style, "fill")
411
+ });
412
+ break;
413
+ case ".bb-axis-y-label":
414
+ case ".bb-axis-y .bb-axis-y-label":
415
+ mergeThemeSection(target, "axis", {
416
+ labelFont: readFontValue(style),
417
+ yLabelColor: readColorValue(style, "fill")
418
+ });
419
+ break;
420
+ case ".bb-axis-y2-label":
421
+ case ".bb-axis-y2 .bb-axis-y2-label":
422
+ mergeThemeSection(target, "axis", {
423
+ labelFont: readFontValue(style),
424
+ y2LabelColor: readColorValue(style, "fill")
425
+ });
426
+ break;
427
+ case ".bb-grid line":
428
+ case ".bb-grid .bb-xgrid":
429
+ case ".bb-grid .bb-ygrid":
430
+ case ".bb-xgrid":
431
+ case ".bb-ygrid":
432
+ mergeThemeSection(target, "grid", {
433
+ lineColor: readColorValue(style, "stroke"),
434
+ lineWidth: readNumberValue(style, "stroke-width"),
435
+ dashArray: readDashArrayValue(style)
436
+ });
437
+ break;
438
+ case ".bb-grid text":
439
+ mergeThemeSection(target, "grid", {
440
+ labelColor: readColorValue(style, "fill"),
441
+ labelFont: readFontValue(style)
442
+ });
443
+ break;
444
+ case ".bb-xgrid-focus line":
445
+ case ".bb-grid .bb-xgrid-focus line":
446
+ case ".bb-grid .bb-xgrid-focus":
447
+ mergeThemeSection(target, "focusGrid", {
448
+ lineColor: readColorValue(style, "stroke"),
449
+ lineWidth: readNumberValue(style, "stroke-width"),
450
+ dashArray: readDashArrayValue(style)
451
+ });
452
+ break;
453
+ case ".bb-region rect":
454
+ case ".bb-region":
455
+ mergeThemeSection(target, "region", {
456
+ fill: readColorValue(style, "fill"),
457
+ opacity: readPaintOpacityValue(style)
458
+ });
459
+ break;
460
+ case ".bb-region text":
461
+ mergeThemeSection(target, "region", {
462
+ labelColor: readColorValue(style, "fill"),
463
+ labelFont: readFontValue(style)
464
+ });
465
+ break;
466
+ case ".bb-bar":
467
+ mergeThemeSection(target, "shape", {
468
+ barOpacity: readPaintOpacityValue(style),
469
+ barStrokeColor: readColorValue(style, "stroke"),
470
+ barLineWidth: readNumberValue(style, "stroke-width")
471
+ });
472
+ break;
473
+ case ".bb-bar._expanded_":
474
+ mergeThemeSection(target, "shape", { barExpandedOpacity: readPaintOpacityValue(style) });
475
+ break;
476
+ case ".bb-candlestick":
477
+ mergeThemeSection(target, "shape", {
478
+ candlestickStrokeColor: readColorValue(style, "stroke"),
479
+ candlestickLineWidth: readNumberValue(style, "stroke-width")
480
+ });
481
+ break;
482
+ case ".bb-candlestick._expanded_":
483
+ mergeThemeSection(target, "shape", { candlestickExpandedOpacity: readPaintOpacityValue(style) });
484
+ break;
485
+ case ".bb-line":
486
+ mergeThemeSection(target, "shape", {
487
+ barConnectLineColor: readColorValue(style, "stroke"),
488
+ barConnectLineWidth: readNumberValue(style, "stroke-width"),
489
+ lineWidth: readNumberValue(style, "stroke-width")
490
+ });
491
+ break;
492
+ case ".bb-target.bb-focused .bb-line":
493
+ case ".bb-target.bb-focused path.bb-line":
494
+ mergeThemeSection(target, "shape", { lineFocusedWidth: readNumberValue(style, "stroke-width") });
495
+ break;
496
+ case ".bb-target.bb-defocused":
497
+ mergeThemeSection(target, "shape", { targetDefocusedOpacity: readNumberValue(style, "opacity") });
498
+ break;
499
+ case ".bb-area":
500
+ mergeThemeSection(target, "shape", { areaOpacity: readPaintOpacityValue(style) });
501
+ break;
502
+ case ".bb-circle":
503
+ mergeThemeSection(target, "shape", {
504
+ pointFillColor: readColorValue(style, "fill"),
505
+ pointStrokeColor: readColorValue(style, "stroke"),
506
+ pointLineWidth: readNumberValue(style, "stroke-width")
507
+ });
508
+ break;
509
+ case ".bb-selected-circle":
510
+ mergeThemeSection(target, "selectedPoint", {
511
+ fill: readColorValue(style, "fill"),
512
+ stroke: readColorValue(style, "stroke"),
513
+ lineWidth: readNumberValue(style, "stroke-width")
514
+ });
515
+ break;
516
+ case ".bb-circle._expanded_":
517
+ mergeThemeSection(target, "focusPoint", {
518
+ fill: readColorValue(style, "fill"),
519
+ stroke: readColorValue(style, "stroke"),
520
+ lineWidth: readNumberValue(style, "stroke-width")
521
+ });
522
+ break;
523
+ case ".bb-zoom-brush":
524
+ mergeThemeSection(target, "zoomBrush", {
525
+ fill: readColorValue(style, "fill"),
526
+ opacity: readPaintOpacityValue(style)
527
+ });
528
+ break;
529
+ case ".bb-brush .extent":
530
+ case ".bb-brush .selection":
531
+ mergeThemeSection(target, "subchartBrush", {
532
+ fill: readColorValue(style, "fill"),
533
+ opacity: readPaintOpacityValue(style)
534
+ });
535
+ break;
536
+ case ".bb-brush .handle--custom":
537
+ mergeThemeSection(target, "subchartBrush", {
538
+ handleFill: readColorValue(style, "fill"),
539
+ handleOpacity: readPaintOpacityValue(style),
540
+ handleStroke: readColorValue(style, "stroke"),
541
+ handleLineWidth: readNumberValue(style, "stroke-width")
542
+ });
543
+ break;
544
+ case ".bb-chart-treemaps rect":
545
+ case ".bb-chart-treemaps":
546
+ mergeThemeSection(target, "treemap", {
547
+ stroke: readColorValue(style, "stroke"),
548
+ lineWidth: readNumberValue(style, "stroke-width")
549
+ });
550
+ break;
551
+ case ".bb-text.bb-empty":
552
+ case ".bb-text .bb-empty":
553
+ case ".bb-empty":
554
+ mergeThemeSection(target, "emptyLabel", {
555
+ color: readColorValue(style, "fill"),
556
+ font: readFontValue(style)
557
+ });
558
+ break;
559
+ case ".bb-text":
560
+ mergeThemeSection(target, "label", {
561
+ color: readColorValue(style, "fill"),
562
+ font: readFontValue(style)
563
+ });
564
+ break;
565
+ case ".bb-title":
566
+ mergeThemeSection(target, "title", {
567
+ color: readColorValue(style, "fill"),
568
+ font: readFontValue(style)
569
+ });
570
+ break;
571
+ }
500
572
  }
501
573
  /**
502
- * Convert selector based canvas theme overrides to renderer theme slots.
503
- * @param {object} selectors Selector style declarations
504
- * @returns {object} Canvas theme override
505
- * @private
506
- */
574
+ * Convert selector based canvas theme overrides to renderer theme slots.
575
+ * @param {object} selectors Selector style declarations
576
+ * @returns {object} Canvas theme override
577
+ * @private
578
+ */
507
579
  function getSelectorThemeOverride(selectors) {
508
- const override = {};
509
- Object.keys(selectors ?? {}).forEach(selector => {
510
- normalizeThemeSelectors(selector).forEach(normalizedSelector => {
511
- applySelectorStyle(override, normalizedSelector, selectors[selector]);
512
- });
513
- });
514
- return override;
580
+ const override = {};
581
+ Object.keys(selectors ?? {}).forEach((selector) => {
582
+ normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
583
+ applySelectorStyle(override, normalizedSelector, selectors[selector]);
584
+ });
585
+ });
586
+ return override;
515
587
  }
516
588
  /**
517
- * Resolve user canvas theme override.
518
- * @param {object} userOverride Canvas theme override
519
- * @returns {object} Canvas theme override
520
- * @private
521
- */
589
+ * Resolve user canvas theme override.
590
+ * @param {object} userOverride Canvas theme override
591
+ * @returns {object} Canvas theme override
592
+ * @private
593
+ */
522
594
  function getThemeOverride(userOverride) {
523
- if (!userOverride) {
524
- return {};
525
- }
526
- const { selectors, ...styleOverride } = userOverride;
527
- return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
595
+ if (!userOverride) return {};
596
+ const { selectors, ...styleOverride } = userOverride;
597
+ return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
528
598
  }
529
599
  /**
530
- * Build a stable enough cache key for theme reloads.
531
- * @param {HTMLElement} container Chart container
532
- * @param {object} userOverride Canvas theme override
533
- * @returns {string|null} Cache key
534
- * @private
535
- */
600
+ * Build a stable enough cache key for theme reloads.
601
+ * @param {HTMLElement} container Chart container
602
+ * @param {object} userOverride Canvas theme override
603
+ * @returns {string|null} Cache key
604
+ * @private
605
+ */
536
606
  function getThemeCacheKey(container, userOverride) {
537
- try {
538
- return JSON.stringify({
539
- className: container.className,
540
- style: container.getAttribute("style") || "",
541
- override: userOverride || null
542
- });
543
- }
544
- catch {
545
- return null;
546
- }
607
+ try {
608
+ return JSON.stringify({
609
+ className: container.className,
610
+ style: container.getAttribute("style") || "",
611
+ override: userOverride || null
612
+ });
613
+ } catch {
614
+ return null;
615
+ }
547
616
  }
548
617
  /**
549
- * Resolve canvas drawing styles from the existing SVG CSS theme.
550
- * @private
551
- */
552
- class CanvasTheme {
553
- style;
554
- cacheContainer = null;
555
- cacheKey = null;
556
- /**
557
- * Read theme values from temporary SVG probes.
558
- * @param {HTMLElement} container Chart container
559
- * @param {object} userOverride Canvas theme override
560
- * @private
561
- */
562
- load(container, userOverride) {
563
- const svg = doc.createElementNS(SVG_NS, "svg");
564
- svg.setAttribute("class", "bb");
565
- svg.style.cssText =
566
- "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
567
- container.appendChild(svg);
568
- const read = (el, props) => {
569
- const style = win.getComputedStyle(el);
570
- const values = {};
571
- for (const prop of props) {
572
- values[prop] = prop === "font" ?
573
- toFont(style, "") :
574
- style.getPropertyValue(prop).trim();
575
- }
576
- return values;
577
- };
578
- const probe = (tag, cls, props) => {
579
- const el = doc.createElementNS(SVG_NS, tag);
580
- el.setAttribute("class", cls);
581
- svg.appendChild(el);
582
- const value = read(el, props);
583
- svg.removeChild(el);
584
- return value;
585
- };
586
- const probeIn = (parentCls, tag, cls, props) => {
587
- const parent = doc.createElementNS(SVG_NS, "g");
588
- const el = doc.createElementNS(SVG_NS, tag);
589
- parent.setAttribute("class", parentCls);
590
- cls && el.setAttribute("class", cls);
591
- parent.appendChild(el);
592
- svg.appendChild(parent);
593
- const value = read(el, props);
594
- svg.removeChild(parent);
595
- return value;
596
- };
597
- const probeInNested = (parentCls, groupCls, tag, cls, props) => {
598
- const parent = doc.createElementNS(SVG_NS, "g");
599
- const group = doc.createElementNS(SVG_NS, "g");
600
- const el = doc.createElementNS(SVG_NS, tag);
601
- parent.setAttribute("class", parentCls);
602
- group.setAttribute("class", groupCls);
603
- el.setAttribute("class", cls);
604
- group.appendChild(el);
605
- parent.appendChild(group);
606
- svg.appendChild(parent);
607
- const value = read(el, props);
608
- svg.removeChild(parent);
609
- return value;
610
- };
611
- const probeTick = (axisCls, tag, props, tickCls = "") => {
612
- const axis = doc.createElementNS(SVG_NS, "g");
613
- const tick = doc.createElementNS(SVG_NS, "g");
614
- const el = doc.createElementNS(SVG_NS, tag);
615
- axis.setAttribute("class", `bb-axis ${axisCls}`);
616
- tick.setAttribute("class", ["tick", tickCls].filter(Boolean).join(" "));
617
- el.textContent = tag === "text" ? "0" : "";
618
- tick.appendChild(el);
619
- axis.appendChild(tick);
620
- svg.appendChild(axis);
621
- const value = read(el, props);
622
- svg.removeChild(axis);
623
- return value;
624
- };
625
- const targetPointPaint = "rgb(1, 2, 3)";
626
- const probeTargetPoint = (cls, props) => {
627
- const style = doc.createElement("style");
628
- style.textContent = `
618
+ * Resolve canvas drawing styles from the existing SVG CSS theme.
619
+ * @private
620
+ */
621
+ var CanvasTheme = class {
622
+ style;
623
+ cacheContainer = null;
624
+ cacheKey = null;
625
+ gridLineSelectorOverrides = [];
626
+ directGridOverrideKeys = /* @__PURE__ */ new Set();
627
+ /**
628
+ * Read theme values from temporary SVG probes.
629
+ * @param {HTMLElement} container Chart container
630
+ * @param {object} userOverride Canvas theme override
631
+ * @private
632
+ */
633
+ load(container, userOverride) {
634
+ const svg = doc.createElementNS(SVG_NS, "svg");
635
+ this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride?.selectors);
636
+ this.directGridOverrideKeys = new Set(Object.keys(userOverride?.grid ?? {}));
637
+ svg.setAttribute("class", "bb");
638
+ svg.style.cssText = "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
639
+ container.appendChild(svg);
640
+ const read = (el, props) => {
641
+ const style = win.getComputedStyle(el);
642
+ const values = {};
643
+ for (const prop of props) values[prop] = prop === "font" ? toFont(style, "") : style.getPropertyValue(prop).trim();
644
+ return values;
645
+ };
646
+ const probe = (tag, cls, props) => {
647
+ const el = doc.createElementNS(SVG_NS, tag);
648
+ el.setAttribute("class", cls);
649
+ svg.appendChild(el);
650
+ const value = read(el, props);
651
+ svg.removeChild(el);
652
+ return value;
653
+ };
654
+ const probeIn = (parentCls, tag, cls, props) => {
655
+ const parent = doc.createElementNS(SVG_NS, "g");
656
+ const el = doc.createElementNS(SVG_NS, tag);
657
+ parent.setAttribute("class", parentCls);
658
+ cls && el.setAttribute("class", cls);
659
+ parent.appendChild(el);
660
+ svg.appendChild(parent);
661
+ const value = read(el, props);
662
+ svg.removeChild(parent);
663
+ return value;
664
+ };
665
+ const probeInNested = (parentCls, groupCls, tag, cls, props) => {
666
+ const parent = doc.createElementNS(SVG_NS, "g");
667
+ const group = doc.createElementNS(SVG_NS, "g");
668
+ const el = doc.createElementNS(SVG_NS, tag);
669
+ parent.setAttribute("class", parentCls);
670
+ group.setAttribute("class", groupCls);
671
+ cls && el.setAttribute("class", cls);
672
+ group.appendChild(el);
673
+ parent.appendChild(group);
674
+ svg.appendChild(parent);
675
+ const value = read(el, props);
676
+ svg.removeChild(parent);
677
+ return value;
678
+ };
679
+ const probeTick = (axisCls, tag, props, tickCls = "") => {
680
+ const axis = doc.createElementNS(SVG_NS, "g");
681
+ const tick = doc.createElementNS(SVG_NS, "g");
682
+ const el = doc.createElementNS(SVG_NS, tag);
683
+ axis.setAttribute("class", `bb-axis ${axisCls}`);
684
+ tick.setAttribute("class", ["tick", tickCls].filter(Boolean).join(" "));
685
+ el.textContent = tag === "text" ? "0" : "";
686
+ tick.appendChild(el);
687
+ axis.appendChild(tick);
688
+ svg.appendChild(axis);
689
+ const value = read(el, props);
690
+ svg.removeChild(axis);
691
+ return value;
692
+ };
693
+ const targetPointPaint = "rgb(1, 2, 3)";
694
+ const probeTargetPoint = (cls, props) => {
695
+ const style = doc.createElement("style");
696
+ style.textContent = `
629
697
  .bb-shapes-canvas-probe .bb-circle {
630
698
  fill: ${targetPointPaint};
631
699
  stroke: ${targetPointPaint};
632
700
  }
633
701
  `;
634
- doc.head.appendChild(style);
635
- try {
636
- return probeIn("bb-shapes bb-shapes-canvas-probe", "circle", cls, props);
637
- }
638
- finally {
639
- style.remove();
640
- }
641
- };
642
- const axisLine = probeIn("bb-axis bb-axis-x", "path", "domain", ["stroke", "stroke-width"]);
643
- const tickLine = probeTick("bb-axis-x", "line", ["stroke", "stroke-width"]);
644
- const xAxisText = probeTick("bb-axis-x", "text", ["fill", "font"]);
645
- const activeAxisText = probeTick("bb-axis-x", "text", ["fill"], "_active_");
646
- const axisText = probeTick("bb-axis-y", "text", ["fill", "font"]);
647
- const y2AxisText = probeTick("bb-axis-y2", "text", ["fill", "font"]);
648
- const xAxisLabel = probeIn("bb-axis bb-axis-x", "text", "bb-axis-x-label", ["fill", "font"]);
649
- const yAxisLabel = probeIn("bb-axis bb-axis-y", "text", "bb-axis-y-label", ["fill", "font"]);
650
- const y2AxisLabel = probeIn("bb-axis bb-axis-y2", "text", "bb-axis-y2-label", ["fill", "font"]);
651
- const plainCircle = probe("circle", "", ["fill", "stroke", "stroke-width"]);
652
- const gridLine = probeIn("bb-grid", "line", "bb-ygrid", ["stroke", "stroke-width", "stroke-dasharray"]);
653
- const gridText = probeIn("bb-grid", "text", "", ["fill", "font"]);
654
- const focusGridLine = probeInNested("bb-grid", "bb-xgrid-focus", "line", "bb-xgrid-focus", ["stroke", "stroke-width", "stroke-dasharray"]);
655
- const emptyLabel = probe("text", "bb-text bb-empty", ["fill", "font"]);
656
- const regionRect = probeIn("bb-region", "rect", "", ["fill", "fill-opacity"]);
657
- const regionLabel = probeIn("bb-region", "text", "", ["fill", "font"]);
658
- const bar = probe("path", "bb-bar", ["opacity", "fill-opacity", "stroke", "stroke-width"]);
659
- const barExpanded = probe("path", "bb-bar _expanded_", ["opacity", "fill-opacity"]);
660
- const candlestick = probe("path", "bb-candlestick", ["stroke", "stroke-width"]);
661
- const candlestickExpanded = probe("path", "bb-candlestick _expanded_", [
662
- "opacity",
663
- "fill-opacity"
664
- ]);
665
- const line = probe("path", "bb-line", ["stroke-width"]);
666
- const focusedLine = probeIn("bb-target bb-focused", "path", "bb-line", ["stroke-width"]);
667
- const defocusedTarget = probe("g", "bb-target bb-defocused", ["opacity"]);
668
- const area = probe("path", "bb-area", ["opacity", "fill-opacity"]);
669
- const point = probe("circle", "bb-circle", ["fill", "stroke", "stroke-width"]);
670
- const selectedPoint = probe("circle", "bb-selected-circle", [
671
- "fill",
672
- "stroke",
673
- "stroke-width"
674
- ]);
675
- const focusPoint = probeTargetPoint("bb-circle _expanded_", ["fill", "stroke", "stroke-width"]);
676
- const zoomBrush = probe("rect", "bb-zoom-brush", ["fill", "fill-opacity", "opacity"]);
677
- const subchartBrushExtent = probeIn("bb-brush", "rect", "extent", [
678
- "fill",
679
- "fill-opacity",
680
- "opacity"
681
- ]);
682
- const subchartBrushSelection = probeIn("bb-brush", "rect", "selection", [
683
- "fill",
684
- "fill-opacity",
685
- "opacity"
686
- ]);
687
- const subchartBrushHandle = probeIn("bb-brush", "path", "handle--custom", [
688
- "fill",
689
- "fill-opacity",
690
- "opacity",
691
- "stroke",
692
- "stroke-width"
693
- ]);
694
- const treemap = probeIn("bb-chart-treemaps", "rect", "", ["stroke", "stroke-width"]);
695
- const label = probe("text", "bb-text", ["fill", "font"]);
696
- const title = probeIn("", "text", "bb-title", ["fill", "font"]);
697
- const zoomBrushFill = toColor(zoomBrush.fill, "#000");
698
- const zoomBrushOpacity = toNumber(zoomBrush["fill-opacity"] || zoomBrush.opacity, 0.1);
699
- const subchartBrushFill = toColor(subchartBrushSelection.fill, toColor(subchartBrushExtent.fill, zoomBrushFill));
700
- const subchartBrushOpacity = toOptionalNumber(subchartBrushSelection["fill-opacity"], 1) ??
701
- toOptionalNumber(subchartBrushSelection.opacity, 1) ??
702
- toOptionalNumber(subchartBrushExtent["fill-opacity"], 1) ??
703
- toOptionalNumber(subchartBrushExtent.opacity, 1) ??
704
- zoomBrushOpacity;
705
- const subchartBrushHandleStroke = toColor(subchartBrushHandle.stroke, "transparent");
706
- const defaultStyle = {
707
- axis: {
708
- lineColor: toColor(axisLine.stroke, "#000"),
709
- lineWidth: toNumber(axisLine["stroke-width"], 1),
710
- tickColor: toColor(tickLine.stroke, toColor(axisLine.stroke, "#000")),
711
- tickWidth: toNumber(tickLine["stroke-width"], toNumber(axisLine["stroke-width"], 1)),
712
- labelFont: yAxisLabel.font || axisText.font || "10px sans-serif",
713
- xTickFont: xAxisText.font || axisText.font || "10px sans-serif",
714
- yTickFont: axisText.font || "10px sans-serif",
715
- y2TickFont: y2AxisText.font || axisText.font || "10px sans-serif",
716
- labelColor: toColor(axisText.fill, "#000"),
717
- xLabelColor: toColor(xAxisLabel.fill, toColor(xAxisText.fill, "#000")),
718
- yLabelColor: toColor(yAxisLabel.fill, toColor(axisText.fill, "#000")),
719
- y2LabelColor: toColor(y2AxisLabel.fill, toColor(yAxisLabel.fill, toColor(axisText.fill, "#000"))),
720
- activeLabelColor: toOptionalColor(activeAxisText.fill, xAxisText.fill) ||
721
- toColor(axisText.fill, "#000")
722
- },
723
- grid: {
724
- lineColor: toColor(gridLine.stroke, "#aaa"),
725
- lineWidth: toNumber(gridLine["stroke-width"], 1),
726
- dashArray: toDashArray(gridLine["stroke-dasharray"]),
727
- labelFont: gridText.font || axisText.font || "10px sans-serif",
728
- labelColor: toColor(gridText.fill, "#aaa")
729
- },
730
- focusGrid: {
731
- lineColor: toColor(focusGridLine.stroke, toColor(gridLine.stroke, "#aaa")),
732
- lineWidth: toNumber(focusGridLine["stroke-width"], toNumber(gridLine["stroke-width"], 1)),
733
- dashArray: toDashArray(focusGridLine["stroke-dasharray"] || gridLine["stroke-dasharray"])
734
- },
735
- emptyLabel: {
736
- font: emptyLabel.font || label.font || axisText.font || "20px sans-serif",
737
- color: toColor(emptyLabel.fill, "#808080")
738
- },
739
- region: {
740
- fill: toColor(regionRect.fill, "steelblue"),
741
- opacity: toNumber(regionRect["fill-opacity"], 0.1),
742
- labelFont: regionLabel.font || axisText.font || "10px sans-serif",
743
- labelColor: toColor(regionLabel.fill, "#000")
744
- },
745
- shape: {
746
- barOpacity: toPaintOpacity(bar, 1),
747
- barExpandedOpacity: toNumber(toPaintOpacity(barExpanded, toPaintOpacity(bar, 1)), toPaintOpacity(bar, 1)),
748
- barStrokeColor: toColor(bar.stroke, "#000"),
749
- barLineWidth: toNumber(bar["stroke-width"], 0),
750
- barConnectLineColor: toColor(line.stroke, "#000"),
751
- barConnectLineWidth: toNumber(line["stroke-width"], 1),
752
- candlestickStrokeColor: toColor(candlestick.stroke, "#000"),
753
- candlestickLineWidth: toNumber(candlestick["stroke-width"], 1),
754
- candlestickExpandedOpacity: toNumber(toPaintOpacity(candlestickExpanded, 1), 1),
755
- lineWidth: toNumber(line["stroke-width"], 1),
756
- lineFocusedWidth: toNumber(focusedLine["stroke-width"], 2),
757
- areaOpacity: toPaintOpacity(area, 0.2),
758
- targetDefocusedOpacity: toNumber(defocusedTarget.opacity, 0.3),
759
- pointFillColor: toOptionalColor(point.fill, plainCircle.fill),
760
- pointStrokeColor: toOptionalColor(point.stroke, plainCircle.stroke),
761
- pointLineWidth: toOptionalNumber(point["stroke-width"], plainCircle["stroke-width"])
762
- },
763
- selectedPoint: {
764
- fill: toColor(selectedPoint.fill, "#fff"),
765
- stroke: toOptionalColor(selectedPoint.stroke),
766
- lineWidth: toNumber(selectedPoint["stroke-width"], 2)
767
- },
768
- focusPoint: {
769
- fill: toOptionalColor(focusPoint.fill, targetPointPaint),
770
- stroke: toOptionalColor(focusPoint.stroke, targetPointPaint),
771
- lineWidth: toNumber(focusPoint["stroke-width"], 1)
772
- },
773
- zoomBrush: {
774
- fill: zoomBrushFill,
775
- opacity: zoomBrushOpacity
776
- },
777
- subchartBrush: {
778
- fill: subchartBrushFill,
779
- opacity: subchartBrushOpacity,
780
- handleFill: toColor(subchartBrushHandle.fill, "transparent"),
781
- handleOpacity: toPaintOpacity(subchartBrushHandle, 1),
782
- handleStroke: subchartBrushHandleStroke,
783
- handleLineWidth: toNumber(subchartBrushHandle["stroke-width"], subchartBrushHandleStroke === "transparent" ? 0 : 1)
784
- },
785
- treemap: {
786
- stroke: toColor(treemap.stroke, "#fff"),
787
- lineWidth: toNumber(treemap["stroke-width"], 1)
788
- },
789
- label: {
790
- font: label.font || axisText.font || "10px sans-serif",
791
- color: toColor(label.fill, "#000")
792
- },
793
- title: {
794
- font: title.font || label.font || axisText.font || "14px sans-serif",
795
- color: toColor(title.fill, "#000")
796
- }
797
- };
798
- const themeOverride = getThemeOverride(userOverride);
799
- const style = mergeObj(defaultStyle, themeOverride);
800
- const userAxisOverride = userOverride?.axis;
801
- const hasUserAxisLabelColor = !!userAxisOverride &&
802
- Object.prototype.hasOwnProperty.call(userAxisOverride, "labelColor");
803
- const hasUserAxisLabelFont = !!userAxisOverride &&
804
- Object.prototype.hasOwnProperty.call(userAxisOverride, "labelFont");
805
- style.axis.lineWidth = toNumber(style.axis.lineWidth, defaultStyle.axis.lineWidth);
806
- style.axis.tickWidth = toNumber(style.axis.tickWidth, style.axis.lineWidth);
807
- if (hasUserAxisLabelFont) {
808
- const axisOverride = userAxisOverride;
809
- const labelFont = style.axis.labelFont;
810
- axisOverride.xTickFont === undefined && (style.axis.xTickFont = labelFont);
811
- axisOverride.yTickFont === undefined && (style.axis.yTickFont = labelFont);
812
- axisOverride.y2TickFont === undefined && (style.axis.y2TickFont = labelFont);
813
- }
814
- style.axis.labelFont = style.axis.labelFont || defaultStyle.axis.labelFont;
815
- style.axis.xTickFont = style.axis.xTickFont || style.axis.labelFont;
816
- style.axis.yTickFont = style.axis.yTickFont || style.axis.labelFont;
817
- style.axis.y2TickFont = style.axis.y2TickFont || style.axis.yTickFont;
818
- style.axis.labelColor = toColor(style.axis.labelColor, defaultStyle.axis.labelColor);
819
- if (hasUserAxisLabelColor) {
820
- const labelColor = style.axis.labelColor;
821
- userAxisOverride.xLabelColor === undefined && (style.axis.xLabelColor = labelColor);
822
- userAxisOverride.yLabelColor === undefined && (style.axis.yLabelColor = labelColor);
823
- userAxisOverride.y2LabelColor === undefined && (style.axis.y2LabelColor = labelColor);
824
- }
825
- style.axis.xLabelColor = toColor(style.axis.xLabelColor, style.axis.labelColor);
826
- style.axis.yLabelColor = toColor(style.axis.yLabelColor, style.axis.labelColor);
827
- style.axis.y2LabelColor = toColor(style.axis.y2LabelColor, style.axis.yLabelColor);
828
- style.axis.activeLabelColor = toColor(style.axis.activeLabelColor, style.axis.labelColor);
829
- style.grid.lineWidth = toNumber(style.grid.lineWidth, defaultStyle.grid.lineWidth);
830
- style.grid.dashArray = toDashArray(style.grid.dashArray);
831
- style.focusGrid.lineWidth = toNumber(style.focusGrid.lineWidth, defaultStyle.focusGrid.lineWidth);
832
- style.focusGrid.dashArray = toDashArray(style.focusGrid.dashArray);
833
- style.region.opacity = toNumber(style.region.opacity, defaultStyle.region.opacity);
834
- style.shape.barOpacity = toNumber(style.shape.barOpacity, defaultStyle.shape.barOpacity);
835
- style.shape.barExpandedOpacity = toNumber(style.shape.barExpandedOpacity, style.shape.barOpacity);
836
- style.shape.barLineWidth = toNumber(style.shape.barLineWidth, defaultStyle.shape.barLineWidth);
837
- style.shape.barConnectLineWidth = toNumber(style.shape.barConnectLineWidth, defaultStyle.shape.barConnectLineWidth);
838
- style.shape.candlestickLineWidth = toNumber(style.shape.candlestickLineWidth, defaultStyle.shape.candlestickLineWidth);
839
- style.shape.candlestickStrokeColor = toColor(style.shape.candlestickStrokeColor, defaultStyle.shape.candlestickStrokeColor);
840
- style.shape.candlestickExpandedOpacity = toNumber(style.shape.candlestickExpandedOpacity, defaultStyle.shape.candlestickExpandedOpacity);
841
- style.shape.lineWidth = toNumber(style.shape.lineWidth, defaultStyle.shape.lineWidth);
842
- style.shape.lineFocusedWidth = toNumber(style.shape.lineFocusedWidth, defaultStyle.shape.lineFocusedWidth);
843
- style.shape.areaOpacity = toNumber(style.shape.areaOpacity, defaultStyle.shape.areaOpacity);
844
- style.shape.targetDefocusedOpacity = toNumber(style.shape.targetDefocusedOpacity, defaultStyle.shape.targetDefocusedOpacity);
845
- style.shape.pointLineWidth = toOptionalNumber(style.shape.pointLineWidth);
846
- style.selectedPoint.lineWidth = toNumber(style.selectedPoint.lineWidth, defaultStyle.selectedPoint.lineWidth);
847
- style.focusPoint.lineWidth = toNumber(style.focusPoint.lineWidth, defaultStyle.focusPoint.lineWidth);
848
- style.zoomBrush.opacity = toNumber(style.zoomBrush.opacity, defaultStyle.zoomBrush.opacity);
849
- style.subchartBrush.opacity = toNumber(style.subchartBrush.opacity, defaultStyle.subchartBrush.opacity);
850
- style.subchartBrush.handleOpacity = toNumber(style.subchartBrush.handleOpacity, defaultStyle.subchartBrush.handleOpacity);
851
- style.subchartBrush.handleLineWidth = toNumber(style.subchartBrush.handleLineWidth, defaultStyle.subchartBrush.handleLineWidth);
852
- style.treemap.lineWidth = toNumber(style.treemap.lineWidth, defaultStyle.treemap.lineWidth);
853
- this.style = style;
854
- this.cacheContainer = container;
855
- this.cacheKey = getThemeCacheKey(container, userOverride);
856
- svg.remove();
857
- }
858
- /**
859
- * Reload theme values after resize or option changes.
860
- * @param {HTMLElement} container Chart container
861
- * @param {object} userOverride Canvas theme override
862
- * @private
863
- */
864
- reload(container, userOverride) {
865
- const key = getThemeCacheKey(container, userOverride);
866
- if (key !== null &&
867
- this.style &&
868
- this.cacheContainer === container &&
869
- this.cacheKey === key) {
870
- return;
871
- }
872
- this.load(container, userOverride);
873
- }
874
- }
875
-
702
+ doc.head.appendChild(style);
703
+ try {
704
+ return probeIn("bb-shapes bb-shapes-canvas-probe", "circle", cls, props);
705
+ } finally {
706
+ style.remove();
707
+ }
708
+ };
709
+ const axisLine = probeIn("bb-axis bb-axis-x", "path", "domain", ["stroke", "stroke-width"]);
710
+ const tickLine = probeTick("bb-axis-x", "line", ["stroke", "stroke-width"]);
711
+ const xAxisText = probeTick("bb-axis-x", "text", ["fill", "font"]);
712
+ const activeAxisText = probeTick("bb-axis-x", "text", ["fill"], "_active_");
713
+ const axisText = probeTick("bb-axis-y", "text", ["fill", "font"]);
714
+ const y2AxisText = probeTick("bb-axis-y2", "text", ["fill", "font"]);
715
+ const xAxisLabel = probeIn("bb-axis bb-axis-x", "text", "bb-axis-x-label", ["fill", "font"]);
716
+ const yAxisLabel = probeIn("bb-axis bb-axis-y", "text", "bb-axis-y-label", ["fill", "font"]);
717
+ const y2AxisLabel = probeIn("bb-axis bb-axis-y2", "text", "bb-axis-y2-label", ["fill", "font"]);
718
+ const plainCircle = probe("circle", "", [
719
+ "fill",
720
+ "stroke",
721
+ "stroke-width"
722
+ ]);
723
+ const gridLine = probeIn("bb-grid", "line", "bb-ygrid", [
724
+ "stroke",
725
+ "stroke-width",
726
+ "stroke-dasharray"
727
+ ]);
728
+ const gridText = probeIn("bb-grid", "text", "", ["fill", "font"]);
729
+ const focusGridLine = probeInNested("bb-grid", "bb-xgrid-focus", "line", "bb-xgrid-focus", [
730
+ "stroke",
731
+ "stroke-width",
732
+ "stroke-dasharray"
733
+ ]);
734
+ const emptyLabel = probe("text", "bb-text bb-empty", ["fill", "font"]);
735
+ const regionRect = probeIn("bb-region", "rect", "", ["fill", "fill-opacity"]);
736
+ const regionLabel = probeIn("bb-region", "text", "", ["fill", "font"]);
737
+ const bar = probe("path", "bb-bar", [
738
+ "opacity",
739
+ "fill-opacity",
740
+ "stroke",
741
+ "stroke-width"
742
+ ]);
743
+ const barExpanded = probe("path", "bb-bar _expanded_", ["opacity", "fill-opacity"]);
744
+ const candlestick = probe("path", "bb-candlestick", ["stroke", "stroke-width"]);
745
+ const candlestickExpanded = probe("path", "bb-candlestick _expanded_", ["opacity", "fill-opacity"]);
746
+ const line = probe("path", "bb-line", ["stroke-width"]);
747
+ const focusedLine = probeIn("bb-target bb-focused", "path", "bb-line", ["stroke-width"]);
748
+ const defocusedTarget = probe("g", "bb-target bb-defocused", ["opacity"]);
749
+ const area = probe("path", "bb-area", ["opacity", "fill-opacity"]);
750
+ const point = probe("circle", "bb-circle", [
751
+ "fill",
752
+ "stroke",
753
+ "stroke-width"
754
+ ]);
755
+ const selectedPoint = probe("circle", "bb-selected-circle", [
756
+ "fill",
757
+ "stroke",
758
+ "stroke-width"
759
+ ]);
760
+ const focusPoint = probeTargetPoint("bb-circle _expanded_", [
761
+ "fill",
762
+ "stroke",
763
+ "stroke-width"
764
+ ]);
765
+ const zoomBrush = probe("rect", "bb-zoom-brush", [
766
+ "fill",
767
+ "fill-opacity",
768
+ "opacity"
769
+ ]);
770
+ const subchartBrushExtent = probeIn("bb-brush", "rect", "extent", [
771
+ "fill",
772
+ "fill-opacity",
773
+ "opacity"
774
+ ]);
775
+ const subchartBrushSelection = probeIn("bb-brush", "rect", "selection", [
776
+ "fill",
777
+ "fill-opacity",
778
+ "opacity"
779
+ ]);
780
+ const subchartBrushHandle = probeIn("bb-brush", "path", "handle--custom", [
781
+ "fill",
782
+ "fill-opacity",
783
+ "opacity",
784
+ "stroke",
785
+ "stroke-width"
786
+ ]);
787
+ const treemap = probeIn("bb-chart-treemaps", "rect", "", ["stroke", "stroke-width"]);
788
+ const label = probe("text", "bb-text", ["fill", "font"]);
789
+ const title = probeIn("", "text", "bb-title", ["fill", "font"]);
790
+ const zoomBrushFill = toColor(zoomBrush.fill, "#000");
791
+ const zoomBrushOpacity = toNumber(zoomBrush["fill-opacity"] || zoomBrush.opacity, .1);
792
+ const subchartBrushFill = toColor(subchartBrushSelection.fill, toColor(subchartBrushExtent.fill, zoomBrushFill));
793
+ const subchartBrushOpacity = toOptionalNumber(subchartBrushSelection["fill-opacity"], 1) ?? toOptionalNumber(subchartBrushSelection.opacity, 1) ?? toOptionalNumber(subchartBrushExtent["fill-opacity"], 1) ?? toOptionalNumber(subchartBrushExtent.opacity, 1) ?? zoomBrushOpacity;
794
+ const subchartBrushHandleStroke = toColor(subchartBrushHandle.stroke, "transparent");
795
+ const defaultStyle = {
796
+ axis: {
797
+ lineColor: toColor(axisLine.stroke, "#000"),
798
+ lineWidth: toNumber(axisLine["stroke-width"], 1),
799
+ tickColor: toColor(tickLine.stroke, toColor(axisLine.stroke, "#000")),
800
+ tickWidth: toNumber(tickLine["stroke-width"], toNumber(axisLine["stroke-width"], 1)),
801
+ labelFont: yAxisLabel.font || axisText.font || "10px sans-serif",
802
+ xTickFont: xAxisText.font || axisText.font || "10px sans-serif",
803
+ yTickFont: axisText.font || "10px sans-serif",
804
+ y2TickFont: y2AxisText.font || axisText.font || "10px sans-serif",
805
+ labelColor: toColor(axisText.fill, "#000"),
806
+ xLabelColor: toColor(xAxisLabel.fill, toColor(xAxisText.fill, "#000")),
807
+ yLabelColor: toColor(yAxisLabel.fill, toColor(axisText.fill, "#000")),
808
+ y2LabelColor: toColor(y2AxisLabel.fill, toColor(yAxisLabel.fill, toColor(axisText.fill, "#000"))),
809
+ activeLabelColor: toOptionalColor(activeAxisText.fill, xAxisText.fill) || toColor(axisText.fill, "#000")
810
+ },
811
+ grid: {
812
+ lineColor: toColor(gridLine.stroke, "#aaa"),
813
+ lineWidth: toNumber(gridLine["stroke-width"], 1),
814
+ dashArray: toDashArray(gridLine["stroke-dasharray"]),
815
+ labelFont: gridText.font || axisText.font || "10px sans-serif",
816
+ labelColor: toColor(gridText.fill, "#aaa")
817
+ },
818
+ focusGrid: {
819
+ lineColor: toColor(focusGridLine.stroke, toColor(gridLine.stroke, "#aaa")),
820
+ lineWidth: toNumber(focusGridLine["stroke-width"], toNumber(gridLine["stroke-width"], 1)),
821
+ dashArray: toDashArray(focusGridLine["stroke-dasharray"] || gridLine["stroke-dasharray"])
822
+ },
823
+ emptyLabel: {
824
+ font: emptyLabel.font || label.font || axisText.font || "20px sans-serif",
825
+ color: toColor(emptyLabel.fill, "#808080")
826
+ },
827
+ region: {
828
+ fill: toColor(regionRect.fill, "steelblue"),
829
+ opacity: toNumber(regionRect["fill-opacity"], .1),
830
+ labelFont: regionLabel.font || axisText.font || "10px sans-serif",
831
+ labelColor: toColor(regionLabel.fill, "#000")
832
+ },
833
+ shape: {
834
+ barOpacity: toPaintOpacity(bar, 1),
835
+ barExpandedOpacity: toNumber(toPaintOpacity(barExpanded, toPaintOpacity(bar, 1)), toPaintOpacity(bar, 1)),
836
+ barStrokeColor: toColor(bar.stroke, "#000"),
837
+ barLineWidth: toNumber(bar["stroke-width"], 0),
838
+ barConnectLineColor: toColor(line.stroke, "#000"),
839
+ barConnectLineWidth: toNumber(line["stroke-width"], 1),
840
+ candlestickStrokeColor: toColor(candlestick.stroke, "#000"),
841
+ candlestickLineWidth: toNumber(candlestick["stroke-width"], 1),
842
+ candlestickExpandedOpacity: toNumber(toPaintOpacity(candlestickExpanded, 1), 1),
843
+ lineWidth: toNumber(line["stroke-width"], 1),
844
+ lineFocusedWidth: toNumber(focusedLine["stroke-width"], 2),
845
+ areaOpacity: toPaintOpacity(area, .2),
846
+ targetDefocusedOpacity: toNumber(defocusedTarget.opacity, .3),
847
+ pointFillColor: toOptionalColor(point.fill, plainCircle.fill),
848
+ pointStrokeColor: toOptionalColor(point.stroke, plainCircle.stroke),
849
+ pointLineWidth: toOptionalNumber(point["stroke-width"], plainCircle["stroke-width"])
850
+ },
851
+ selectedPoint: {
852
+ fill: toColor(selectedPoint.fill, "#fff"),
853
+ stroke: toOptionalColor(selectedPoint.stroke),
854
+ lineWidth: toNumber(selectedPoint["stroke-width"], 2)
855
+ },
856
+ focusPoint: {
857
+ fill: toOptionalColor(focusPoint.fill, targetPointPaint),
858
+ stroke: toOptionalColor(focusPoint.stroke, targetPointPaint),
859
+ lineWidth: toNumber(focusPoint["stroke-width"], 1)
860
+ },
861
+ zoomBrush: {
862
+ fill: zoomBrushFill,
863
+ opacity: zoomBrushOpacity
864
+ },
865
+ subchartBrush: {
866
+ fill: subchartBrushFill,
867
+ opacity: subchartBrushOpacity,
868
+ handleFill: toColor(subchartBrushHandle.fill, "transparent"),
869
+ handleOpacity: toPaintOpacity(subchartBrushHandle, 1),
870
+ handleStroke: subchartBrushHandleStroke,
871
+ handleLineWidth: toNumber(subchartBrushHandle["stroke-width"], subchartBrushHandleStroke === "transparent" ? 0 : 1)
872
+ },
873
+ treemap: {
874
+ stroke: toColor(treemap.stroke, "#fff"),
875
+ lineWidth: toNumber(treemap["stroke-width"], 1)
876
+ },
877
+ label: {
878
+ font: label.font || axisText.font || "10px sans-serif",
879
+ color: toColor(label.fill, "#000")
880
+ },
881
+ title: {
882
+ font: title.font || label.font || axisText.font || "14px sans-serif",
883
+ color: toColor(title.fill, "#000")
884
+ }
885
+ };
886
+ const style = mergeObj(defaultStyle, getThemeOverride(userOverride));
887
+ const userAxisOverride = userOverride?.axis;
888
+ const hasUserAxisLabelColor = !!userAxisOverride && Object.prototype.hasOwnProperty.call(userAxisOverride, "labelColor");
889
+ const hasUserAxisLabelFont = !!userAxisOverride && Object.prototype.hasOwnProperty.call(userAxisOverride, "labelFont");
890
+ style.axis.lineWidth = toNumber(style.axis.lineWidth, defaultStyle.axis.lineWidth);
891
+ style.axis.tickWidth = toNumber(style.axis.tickWidth, style.axis.lineWidth);
892
+ if (hasUserAxisLabelFont) {
893
+ const axisOverride = userAxisOverride;
894
+ const labelFont = style.axis.labelFont;
895
+ axisOverride.xTickFont === void 0 && (style.axis.xTickFont = labelFont);
896
+ axisOverride.yTickFont === void 0 && (style.axis.yTickFont = labelFont);
897
+ axisOverride.y2TickFont === void 0 && (style.axis.y2TickFont = labelFont);
898
+ }
899
+ style.axis.labelFont = style.axis.labelFont || defaultStyle.axis.labelFont;
900
+ style.axis.xTickFont = style.axis.xTickFont || style.axis.labelFont;
901
+ style.axis.yTickFont = style.axis.yTickFont || style.axis.labelFont;
902
+ style.axis.y2TickFont = style.axis.y2TickFont || style.axis.yTickFont;
903
+ style.axis.labelColor = toColor(style.axis.labelColor, defaultStyle.axis.labelColor);
904
+ if (hasUserAxisLabelColor) {
905
+ const labelColor = style.axis.labelColor;
906
+ userAxisOverride.xLabelColor === void 0 && (style.axis.xLabelColor = labelColor);
907
+ userAxisOverride.yLabelColor === void 0 && (style.axis.yLabelColor = labelColor);
908
+ userAxisOverride.y2LabelColor === void 0 && (style.axis.y2LabelColor = labelColor);
909
+ }
910
+ style.axis.xLabelColor = toColor(style.axis.xLabelColor, style.axis.labelColor);
911
+ style.axis.yLabelColor = toColor(style.axis.yLabelColor, style.axis.labelColor);
912
+ style.axis.y2LabelColor = toColor(style.axis.y2LabelColor, style.axis.yLabelColor);
913
+ style.axis.activeLabelColor = toColor(style.axis.activeLabelColor, style.axis.labelColor);
914
+ style.grid.lineWidth = toNumber(style.grid.lineWidth, defaultStyle.grid.lineWidth);
915
+ style.grid.dashArray = toDashArray(style.grid.dashArray);
916
+ style.focusGrid.lineWidth = toNumber(style.focusGrid.lineWidth, defaultStyle.focusGrid.lineWidth);
917
+ style.focusGrid.dashArray = toDashArray(style.focusGrid.dashArray);
918
+ style.region.opacity = toNumber(style.region.opacity, defaultStyle.region.opacity);
919
+ style.shape.barOpacity = toNumber(style.shape.barOpacity, defaultStyle.shape.barOpacity);
920
+ style.shape.barExpandedOpacity = toNumber(style.shape.barExpandedOpacity, style.shape.barOpacity);
921
+ style.shape.barLineWidth = toNumber(style.shape.barLineWidth, defaultStyle.shape.barLineWidth);
922
+ style.shape.barConnectLineWidth = toNumber(style.shape.barConnectLineWidth, defaultStyle.shape.barConnectLineWidth);
923
+ style.shape.candlestickLineWidth = toNumber(style.shape.candlestickLineWidth, defaultStyle.shape.candlestickLineWidth);
924
+ style.shape.candlestickStrokeColor = toColor(style.shape.candlestickStrokeColor, defaultStyle.shape.candlestickStrokeColor);
925
+ style.shape.candlestickExpandedOpacity = toNumber(style.shape.candlestickExpandedOpacity, defaultStyle.shape.candlestickExpandedOpacity);
926
+ style.shape.lineWidth = toNumber(style.shape.lineWidth, defaultStyle.shape.lineWidth);
927
+ style.shape.lineFocusedWidth = toNumber(style.shape.lineFocusedWidth, defaultStyle.shape.lineFocusedWidth);
928
+ style.shape.areaOpacity = toNumber(style.shape.areaOpacity, defaultStyle.shape.areaOpacity);
929
+ style.shape.targetDefocusedOpacity = toNumber(style.shape.targetDefocusedOpacity, defaultStyle.shape.targetDefocusedOpacity);
930
+ style.shape.pointLineWidth = toOptionalNumber(style.shape.pointLineWidth);
931
+ style.selectedPoint.lineWidth = toNumber(style.selectedPoint.lineWidth, defaultStyle.selectedPoint.lineWidth);
932
+ style.focusPoint.lineWidth = toNumber(style.focusPoint.lineWidth, defaultStyle.focusPoint.lineWidth);
933
+ style.zoomBrush.opacity = toNumber(style.zoomBrush.opacity, defaultStyle.zoomBrush.opacity);
934
+ style.subchartBrush.opacity = toNumber(style.subchartBrush.opacity, defaultStyle.subchartBrush.opacity);
935
+ style.subchartBrush.handleOpacity = toNumber(style.subchartBrush.handleOpacity, defaultStyle.subchartBrush.handleOpacity);
936
+ style.subchartBrush.handleLineWidth = toNumber(style.subchartBrush.handleLineWidth, defaultStyle.subchartBrush.handleLineWidth);
937
+ style.treemap.lineWidth = toNumber(style.treemap.lineWidth, defaultStyle.treemap.lineWidth);
938
+ this.style = style;
939
+ this.cacheContainer = container;
940
+ this.cacheKey = getThemeCacheKey(container, userOverride);
941
+ svg.remove();
942
+ }
943
+ /**
944
+ * Reload theme values after resize or option changes.
945
+ * @param {HTMLElement} container Chart container
946
+ * @param {object} userOverride Canvas theme override
947
+ * @private
948
+ */
949
+ reload(container, userOverride) {
950
+ const key = getThemeCacheKey(container, userOverride);
951
+ if (key !== null && this.style && this.cacheContainer === container && this.cacheKey === key) return;
952
+ this.load(container, userOverride);
953
+ }
954
+ /**
955
+ * Resolve selector based style for one configured optional grid line.
956
+ * @param {string} axis Grid axis
957
+ * @param {object} line Grid line options
958
+ * @param {string} line.class Grid line custom class
959
+ * @param {string} target Draw target
960
+ * @returns {object|undefined} Grid line style override
961
+ * @private
962
+ */
963
+ getGridLineStyle(axis, line = {}, target = "line") {
964
+ const style = {};
965
+ for (const override of this.gridLineSelectorOverrides) {
966
+ if (!matchesGridLineSelector(override.selector, axis, line.class, target)) continue;
967
+ assignDefined(style, override.style, this.directGridOverrideKeys);
968
+ }
969
+ return getDefinedKeys(style).length ? style : void 0;
970
+ }
971
+ };
972
+ //#endregion
876
973
  export { CanvasTheme as default };