billboard.js 4.0.0-next.1 → 4.0.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 (226) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +279 -73
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +17 -17
  5. package/dist/billboard.pkgd.js +279 -73
  6. package/dist/billboard.pkgd.min.js +23 -23
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2 -2
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  27. package/dist/theme/dark.css +1 -1
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +1 -1
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +1 -1
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +1 -1
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +1 -1
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/Chart/Chart.js +1 -1
  38. package/dist-esm/Chart/api/axis.js +1 -1
  39. package/dist-esm/Chart/api/category.js +1 -1
  40. package/dist-esm/Chart/api/chart.js +2 -1
  41. package/dist-esm/Chart/api/color.js +1 -1
  42. package/dist-esm/Chart/api/data.js +1 -1
  43. package/dist-esm/Chart/api/export.js +1 -1
  44. package/dist-esm/Chart/api/flow.js +1 -1
  45. package/dist-esm/Chart/api/focus.js +1 -1
  46. package/dist-esm/Chart/api/grid.js +1 -1
  47. package/dist-esm/Chart/api/group.js +1 -1
  48. package/dist-esm/Chart/api/legend.js +1 -1
  49. package/dist-esm/Chart/api/load.js +1 -1
  50. package/dist-esm/Chart/api/regions.js +1 -1
  51. package/dist-esm/Chart/api/selection.js +1 -1
  52. package/dist-esm/Chart/api/show.js +1 -1
  53. package/dist-esm/Chart/api/subchart.js +1 -1
  54. package/dist-esm/Chart/api/tooltip.js +1 -1
  55. package/dist-esm/Chart/api/x.js +1 -1
  56. package/dist-esm/Chart/api/zoom.js +1 -1
  57. package/dist-esm/ChartInternal/Axis/Axis.js +1 -1
  58. package/dist-esm/ChartInternal/Axis/AxisRenderer.js +1 -1
  59. package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +1 -1
  60. package/dist-esm/ChartInternal/ChartInternal.js +33 -1
  61. package/dist-esm/ChartInternal/data/convert.helper.js +1 -1
  62. package/dist-esm/ChartInternal/data/convert.js +1 -1
  63. package/dist-esm/ChartInternal/data/data.js +1 -1
  64. package/dist-esm/ChartInternal/data/load.js +1 -1
  65. package/dist-esm/ChartInternal/interactions/drag.js +1 -1
  66. package/dist-esm/ChartInternal/interactions/eventrect.js +1 -1
  67. package/dist-esm/ChartInternal/interactions/flow.js +1 -1
  68. package/dist-esm/ChartInternal/interactions/interaction.js +1 -1
  69. package/dist-esm/ChartInternal/interactions/subchart.js +1 -1
  70. package/dist-esm/ChartInternal/interactions/zoom.js +1 -1
  71. package/dist-esm/ChartInternal/internals/category.js +1 -1
  72. package/dist-esm/ChartInternal/internals/class.js +1 -1
  73. package/dist-esm/ChartInternal/internals/clip.js +1 -1
  74. package/dist-esm/ChartInternal/internals/color.js +1 -1
  75. package/dist-esm/ChartInternal/internals/domain.js +1 -1
  76. package/dist-esm/ChartInternal/internals/format.js +1 -1
  77. package/dist-esm/ChartInternal/internals/grid.js +1 -1
  78. package/dist-esm/ChartInternal/internals/legend.js +1 -1
  79. package/dist-esm/ChartInternal/internals/redraw.js +1 -1
  80. package/dist-esm/ChartInternal/internals/region.js +1 -1
  81. package/dist-esm/ChartInternal/internals/scale.js +1 -1
  82. package/dist-esm/ChartInternal/internals/selection.js +1 -1
  83. package/dist-esm/ChartInternal/internals/size.axis.js +1 -1
  84. package/dist-esm/ChartInternal/internals/size.js +1 -1
  85. package/dist-esm/ChartInternal/internals/style.js +1 -1
  86. package/dist-esm/ChartInternal/internals/text.arc.js +1 -1
  87. package/dist-esm/ChartInternal/internals/text.js +1 -1
  88. package/dist-esm/ChartInternal/internals/text.util.js +1 -1
  89. package/dist-esm/ChartInternal/internals/title.js +1 -1
  90. package/dist-esm/ChartInternal/internals/tooltip.js +1 -1
  91. package/dist-esm/ChartInternal/internals/transform.js +1 -1
  92. package/dist-esm/ChartInternal/internals/type.js +1 -1
  93. package/dist-esm/ChartInternal/shape/arc.js +1 -1
  94. package/dist-esm/ChartInternal/shape/area.js +1 -1
  95. package/dist-esm/ChartInternal/shape/bar.js +1 -1
  96. package/dist-esm/ChartInternal/shape/bubble.js +1 -1
  97. package/dist-esm/ChartInternal/shape/candlestick.js +1 -1
  98. package/dist-esm/ChartInternal/shape/core/barRadius.js +1 -1
  99. package/dist-esm/ChartInternal/shape/core/bubble.js +1 -1
  100. package/dist-esm/ChartInternal/shape/core/candlestick.js +1 -1
  101. package/dist-esm/ChartInternal/shape/core/dataRegion.js +1 -1
  102. package/dist-esm/ChartInternal/shape/core/geometry.js +1 -1
  103. package/dist-esm/ChartInternal/shape/core/path.js +1 -1
  104. package/dist-esm/ChartInternal/shape/core/point.js +1 -1
  105. package/dist-esm/ChartInternal/shape/core/treemap.js +1 -1
  106. package/dist-esm/ChartInternal/shape/funnel.js +1 -1
  107. package/dist-esm/ChartInternal/shape/gauge.js +1 -1
  108. package/dist-esm/ChartInternal/shape/line.js +1 -1
  109. package/dist-esm/ChartInternal/shape/point.js +1 -1
  110. package/dist-esm/ChartInternal/shape/polar.js +1 -1
  111. package/dist-esm/ChartInternal/shape/radar.js +1 -1
  112. package/dist-esm/ChartInternal/shape/shape.js +1 -1
  113. package/dist-esm/ChartInternal/shape/treemap.js +1 -1
  114. package/dist-esm/canvas/CanvasAxisRenderer.js +74 -32
  115. package/dist-esm/canvas/CanvasEngine.js +1 -1
  116. package/dist-esm/canvas/CanvasPainter.js +5 -3
  117. package/dist-esm/canvas/CanvasRenderer.js +91 -24
  118. package/dist-esm/canvas/CanvasTheme.js +35 -2
  119. package/dist-esm/canvas/HitDetector.js +32 -1
  120. package/dist-esm/canvas/axisTicks.js +49 -10
  121. package/dist-esm/canvas/classes.js +1 -1
  122. package/dist-esm/canvas/color.js +1 -1
  123. package/dist-esm/canvas/geometry.js +1 -1
  124. package/dist-esm/canvas/labels.js +1 -1
  125. package/dist-esm/canvas/pointPattern.js +2 -2
  126. package/dist-esm/canvas/util.js +1 -1
  127. package/dist-esm/config/Options/Options.js +1 -1
  128. package/dist-esm/config/Options/axis/axis.js +1 -1
  129. package/dist-esm/config/Options/axis/x.js +1 -1
  130. package/dist-esm/config/Options/axis/y.js +1 -1
  131. package/dist-esm/config/Options/axis/y2.js +1 -1
  132. package/dist-esm/config/Options/common/boost.js +1 -1
  133. package/dist-esm/config/Options/common/color.js +1 -1
  134. package/dist-esm/config/Options/common/grid.js +1 -1
  135. package/dist-esm/config/Options/common/legend.js +1 -1
  136. package/dist-esm/config/Options/common/main.js +2 -2
  137. package/dist-esm/config/Options/common/point.js +1 -1
  138. package/dist-esm/config/Options/common/title.js +1 -1
  139. package/dist-esm/config/Options/common/tooltip.js +1 -1
  140. package/dist-esm/config/Options/data/axis.js +1 -1
  141. package/dist-esm/config/Options/data/data.js +1 -1
  142. package/dist-esm/config/Options/data/selection.js +1 -1
  143. package/dist-esm/config/Options/interaction/interaction.js +1 -1
  144. package/dist-esm/config/Options/interaction/subchart.js +1 -1
  145. package/dist-esm/config/Options/interaction/zoom.js +1 -1
  146. package/dist-esm/config/Options/shape/arc.js +1 -1
  147. package/dist-esm/config/Options/shape/area.js +1 -1
  148. package/dist-esm/config/Options/shape/bar.js +1 -1
  149. package/dist-esm/config/Options/shape/bubble.js +1 -1
  150. package/dist-esm/config/Options/shape/candlestick.js +1 -1
  151. package/dist-esm/config/Options/shape/donut.js +1 -1
  152. package/dist-esm/config/Options/shape/funnel.js +1 -1
  153. package/dist-esm/config/Options/shape/gauge.js +1 -1
  154. package/dist-esm/config/Options/shape/line.js +1 -1
  155. package/dist-esm/config/Options/shape/pie.js +1 -1
  156. package/dist-esm/config/Options/shape/polar.js +1 -1
  157. package/dist-esm/config/Options/shape/radar.js +1 -1
  158. package/dist-esm/config/Options/shape/scatter.js +1 -1
  159. package/dist-esm/config/Options/shape/spline.js +1 -1
  160. package/dist-esm/config/Options/shape/treemap.js +1 -1
  161. package/dist-esm/config/Store/Element.js +1 -1
  162. package/dist-esm/config/Store/State.js +3 -1
  163. package/dist-esm/config/Store/Store.js +1 -1
  164. package/dist-esm/config/classes.js +1 -1
  165. package/dist-esm/config/config.js +1 -1
  166. package/dist-esm/config/const.js +1 -1
  167. package/dist-esm/config/resolver/axis.core.js +1 -1
  168. package/dist-esm/config/resolver/axis.js +1 -1
  169. package/dist-esm/config/resolver/canvas.js +27 -7
  170. package/dist-esm/config/resolver/canvasShape.js +1 -1
  171. package/dist-esm/config/resolver/category.js +1 -1
  172. package/dist-esm/config/resolver/export.js +1 -1
  173. package/dist-esm/config/resolver/flow.js +1 -1
  174. package/dist-esm/config/resolver/grid.js +1 -1
  175. package/dist-esm/config/resolver/interaction/selection.js +1 -1
  176. package/dist-esm/config/resolver/interaction/subchart.js +1 -1
  177. package/dist-esm/config/resolver/interaction/zoom.js +1 -1
  178. package/dist-esm/config/resolver/regions.js +1 -1
  179. package/dist-esm/config/resolver/shape/arc.helpers.js +1 -1
  180. package/dist-esm/config/resolver/shape/area.js +1 -1
  181. package/dist-esm/config/resolver/shape/axis.helpers.js +1 -1
  182. package/dist-esm/config/resolver/shape/bar.js +1 -1
  183. package/dist-esm/config/resolver/shape/bubble.js +1 -1
  184. package/dist-esm/config/resolver/shape/candlestick.js +1 -1
  185. package/dist-esm/config/resolver/shape/donut.js +1 -1
  186. package/dist-esm/config/resolver/shape/funnel.js +1 -1
  187. package/dist-esm/config/resolver/shape/gauge.js +1 -1
  188. package/dist-esm/config/resolver/shape/line.js +1 -1
  189. package/dist-esm/config/resolver/shape/pie.js +1 -1
  190. package/dist-esm/config/resolver/shape/polar.js +1 -1
  191. package/dist-esm/config/resolver/shape/radar.js +1 -1
  192. package/dist-esm/config/resolver/shape/scatter.js +1 -1
  193. package/dist-esm/config/resolver/shape/treemap.js +1 -1
  194. package/dist-esm/core.js +3 -3
  195. package/dist-esm/index.canvas.js +1 -1
  196. package/dist-esm/index.esm.js +1 -1
  197. package/dist-esm/module/Cache.js +1 -1
  198. package/dist-esm/module/browser.js +1 -1
  199. package/dist-esm/module/dsv.js +1 -1
  200. package/dist-esm/module/error.js +1 -1
  201. package/dist-esm/module/generator.js +1 -1
  202. package/dist-esm/module/sanitize.js +1 -1
  203. package/dist-esm/module/util/brush.js +1 -1
  204. package/dist-esm/module/util/dom.js +1 -1
  205. package/dist-esm/module/util/object.js +1 -1
  206. package/dist-esm/module/util/type-checks.js +1 -1
  207. package/dist-esm/module/worker.js +1 -1
  208. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  209. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  210. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  211. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  212. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  213. package/package.json +1 -1
  214. package/src/Chart/api/chart.ts +1 -0
  215. package/src/ChartInternal/ChartInternal.ts +40 -0
  216. package/src/canvas/CanvasAxisRenderer.ts +83 -32
  217. package/src/canvas/CanvasPainter.ts +5 -2
  218. package/src/canvas/CanvasRenderer.ts +112 -27
  219. package/src/canvas/CanvasTheme.ts +45 -1
  220. package/src/canvas/HitDetector.ts +39 -0
  221. package/src/canvas/axisTicks.ts +64 -10
  222. package/src/canvas/pointPattern.ts +2 -1
  223. package/src/config/Options/common/main.ts +1 -1
  224. package/src/config/Store/State.ts +2 -0
  225. package/src/config/resolver/canvas.ts +27 -6
  226. package/types/options.d.ts +13 -8
package/dist/billboard.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 4.0.0-next.1
8
+ * @version 4.0.0-next.2
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -1707,36 +1707,37 @@ function getXTickLineValues($$, textTicks, tickLineWidth = 1) {
1707
1707
  const lineTicks = getXTickValues($$, false);
1708
1708
  return hasOverlappedXTickLineIntervals($$, lineTicks, tickLineWidth) ? textTicks : dedupeXTickLineValues($$, lineTicks);
1709
1709
  }
1710
- function getYTickValues($$, id = "y", count) {
1710
+ function getYTickValues($$, id = "y", count, culling = true) {
1711
1711
  var _a, _b, _c;
1712
1712
  const { axis, config, scale } = $$;
1713
1713
  const prefix = `axis_${id}`;
1714
1714
  const targetScale = scale[id];
1715
1715
  const explicit = getOptionTickValues(config[`${prefix}_tick_values`], $$.api);
1716
+ const maybeCull = (ticks) => culling ? cullAxisTicks($$, id, ticks) : ticks;
1716
1717
  if (explicit) {
1717
- return normalizeYTickValues($$, explicit, id);
1718
+ return maybeCull(normalizeYTickValues($$, explicit, id));
1718
1719
  }
1719
1720
  const stepTicks = getStepTicks(targetScale.domain(), config[`${prefix}_tick_stepSize`]);
1720
1721
  if (stepTicks.length) {
1721
- return stepTicks;
1722
+ return maybeCull(stepTicks);
1722
1723
  }
1723
1724
  const tickCount = count != null ? count : config[`${prefix}_tick_count`];
1724
1725
  if (((_a = axis == null ? void 0 : axis.isTimeSeries) == null ? void 0 : _a.call(axis, id)) && config[`${prefix}_tick_time_value`]) {
1725
- return getScaleTicks(targetScale, config[`${prefix}_tick_time_value`]);
1726
+ return maybeCull(getScaleTicks(targetScale, config[`${prefix}_tick_time_value`]));
1726
1727
  }
1727
1728
  if ((_b = axis == null ? void 0 : axis.isLog) == null ? void 0 : _b.call(axis, id)) {
1728
- return getLogScaleTicks(targetScale, tickCount);
1729
+ return maybeCull(getLogScaleTicks(targetScale, tickCount));
1729
1730
  }
1730
1731
  if (tickCount) {
1731
1732
  const domain = targetScale.domain();
1732
- return generateTickValues(
1733
+ return maybeCull(generateTickValues(
1733
1734
  $$,
1734
1735
  domain,
1735
1736
  domain.every((v) => v === 0) ? 1 : tickCount,
1736
1737
  (_c = axis == null ? void 0 : axis.isTimeSeries) == null ? void 0 : _c.call(axis, id)
1737
- );
1738
+ ));
1738
1739
  }
1739
- return getScaleTicks(targetScale, AXIS_DEFAULT_TICK_COUNT);
1740
+ return maybeCull(getScaleTicks(targetScale, AXIS_DEFAULT_TICK_COUNT));
1740
1741
  }
1741
1742
  function getAdditionalAxisScale($$, id, axisConfig) {
1742
1743
  const baseScale = id === "x" ? getXScale($$) : $$.scale[id];
@@ -1774,6 +1775,35 @@ function cullTicks(ticks, count) {
1774
1775
  }
1775
1776
  return ticks;
1776
1777
  }
1778
+ function cullAxisTicks($$, id, ticks) {
1779
+ const { config } = $$;
1780
+ const prefix = `axis_${id}_tick_culling`;
1781
+ if (!config[prefix]) {
1782
+ return ticks;
1783
+ }
1784
+ const sortedTicks = ticks.slice().sort((a, b) => {
1785
+ const av = +a;
1786
+ const bv = +b;
1787
+ const order = Number.isFinite(av) && Number.isFinite(bv) ? av - bv : String(a).localeCompare(String(b));
1788
+ return config[`${prefix}_reverse`] ? -order : order;
1789
+ });
1790
+ const tickSize = sortedTicks.length;
1791
+ const cullingMax = config[`${prefix}_max`] || AXIS_DEFAULT_TICK_COUNT;
1792
+ let intervalForCulling = 0;
1793
+ for (let i = 1; i < tickSize; i++) {
1794
+ if (tickSize / i < cullingMax) {
1795
+ intervalForCulling = i;
1796
+ break;
1797
+ }
1798
+ }
1799
+ if (!intervalForCulling) {
1800
+ return ticks;
1801
+ }
1802
+ const visible = new Set(
1803
+ sortedTicks.filter((_, i) => i % intervalForCulling === 0)
1804
+ );
1805
+ return ticks.filter((tick) => visible.has(tick));
1806
+ }
1777
1807
  function cullDataTicks($$, ticks, sorted = false) {
1778
1808
  const { config } = $$;
1779
1809
  if (config.axis_x_tick_culling === false) {
@@ -1830,7 +1860,7 @@ function getYGridTickValues($$) {
1830
1860
  if (generated == null ? void 0 : generated.length) {
1831
1861
  return generated;
1832
1862
  }
1833
- return config.grid_y_ticks ? cullTicks(getYTickValues($$, "y"), config.grid_y_ticks) : getYTickValues($$);
1863
+ return config.grid_y_ticks ? cullTicks(getYTickValues($$, "y", void 0, false), config.grid_y_ticks) : getYTickValues($$, "y", void 0, false);
1834
1864
  }
1835
1865
 
1836
1866
  ;// ./src/canvas/CanvasPainter.ts
@@ -2086,11 +2116,13 @@ class CanvasPainter {
2086
2116
  this.withState((ctx) => {
2087
2117
  const lines = text.split("\n");
2088
2118
  const lineHeight = parseFloat((style == null ? void 0 : style.font) || ctx.font) || 12;
2119
+ const firstLineY = lines.length > 1 ? -((lines.length - 1) * lineHeight) : 0;
2089
2120
  this.applyStyle(style);
2090
2121
  ctx.translate(x, y);
2091
2122
  (style == null ? void 0 : style.angle) && ctx.rotate(style.angle * Math.PI / 180);
2092
2123
  lines.forEach((line, i) => {
2093
- (style == null ? void 0 : style.maxWidth) === void 0 ? ctx.fillText(line, 0, i * lineHeight) : ctx.fillText(line, 0, i * lineHeight, style.maxWidth);
2124
+ const lineY = firstLineY + i * lineHeight;
2125
+ (style == null ? void 0 : style.maxWidth) === void 0 ? ctx.fillText(line, 0, lineY) : ctx.fillText(line, 0, lineY, style.maxWidth);
2094
2126
  });
2095
2127
  });
2096
2128
  }
@@ -2368,7 +2400,7 @@ function splitTickTextByWidth(text, width, painter) {
2368
2400
  if (width < charWidth * (i + 1)) {
2369
2401
  const splitIndex = spaceIndex || i;
2370
2402
  return split(
2371
- lines.concat(value.substr(0, splitIndex)),
2403
+ lines.concat(value.slice(0, splitIndex)),
2372
2404
  value.slice(spaceIndex ? spaceIndex + 1 : i)
2373
2405
  );
2374
2406
  }
@@ -2444,6 +2476,15 @@ function isDrawable(value) {
2444
2476
  function isInAxisRange(value, start, end) {
2445
2477
  return isDrawable(value) && value >= Math.min(start, end) && value <= Math.max(start, end);
2446
2478
  }
2479
+ function getXOuterTickDirection(isRotated) {
2480
+ return isRotated ? -1 : 1;
2481
+ }
2482
+ function getYOuterTickDirection(config, isRotated, isY2) {
2483
+ if (isRotated) {
2484
+ return isY2 ? config.axis_y2_inner ? 1 : -1 : config.axis_y_inner ? -1 : 1;
2485
+ }
2486
+ return isY2 ? config.axis_y2_inner ? -1 : 1 : config.axis_y_inner ? 1 : -1;
2487
+ }
2447
2488
  function getXPosition($$, value, targetScale = getXScale($$)) {
2448
2489
  return targetScale(normalizeXValue($$, value));
2449
2490
  }
@@ -2593,6 +2634,7 @@ class CanvasAxisRenderer {
2593
2634
  const rangeEnd = isRotated ? y2 : x2;
2594
2635
  const ticks = getSubXTickValues($$);
2595
2636
  const tickDirection = isRotated ? config.axis_x_tick_inner ? 1 : -1 : config.axis_x_tick_inner ? -1 : 1;
2637
+ const outerTickDirection = getXOuterTickDirection(isRotated);
2596
2638
  const tickTextDirection = getXTickTextDirection(isRotated);
2597
2639
  const tickTextPosition = config.axis_x_tick_text_position;
2598
2640
  const tickRotate = !isRotated ? ((_a = $$.getAxisTickRotate) == null ? void 0 : _a.call($$, "x")) || 0 : 0;
@@ -2616,11 +2658,11 @@ class CanvasAxisRenderer {
2616
2658
  }
2617
2659
  if (config.axis_x_tick_outer) {
2618
2660
  if (isRotated) {
2619
- painter.traceLine(x, y1, x + AXIS_TICK_SIZE * tickDirection, y1);
2620
- painter.traceLine(x, y2, x + AXIS_TICK_SIZE * tickDirection, y2);
2661
+ painter.traceLine(x, y1, x + AXIS_TICK_SIZE * outerTickDirection, y1);
2662
+ painter.traceLine(x, y2, x + AXIS_TICK_SIZE * outerTickDirection, y2);
2621
2663
  } else {
2622
- painter.traceLine(x1, y, x1, y + AXIS_TICK_SIZE * tickDirection);
2623
- painter.traceLine(x2, y, x2, y + AXIS_TICK_SIZE * tickDirection);
2664
+ painter.traceLine(x1, y, x1, y + AXIS_TICK_SIZE * outerTickDirection);
2665
+ painter.traceLine(x2, y, x2, y + AXIS_TICK_SIZE * outerTickDirection);
2624
2666
  }
2625
2667
  }
2626
2668
  });
@@ -3051,6 +3093,7 @@ class CanvasAxisRenderer {
3051
3093
  const format = (axisOptions == null ? void 0 : axisOptions.format) || axisInstance.getXAxisTickFormat();
3052
3094
  const outerTick = axisOptions ? axisOptions.outerTick : config.axis_x_tick_outer;
3053
3095
  const tickDirection = isRotated ? config.axis_x_tick_inner ? 1 : -1 : config.axis_x_tick_inner ? -1 : 1;
3096
+ const outerTickDirection = getXOuterTickDirection(isRotated);
3054
3097
  const tickTextDirection = getXTickTextDirection(isRotated);
3055
3098
  const tickTextPosition = config.axis_x_tick_text_position;
3056
3099
  const tickRotate = !isRotated ? ((_a = $$.getAxisTickRotate) == null ? void 0 : _a.call($$, "x")) || 0 : 0;
@@ -3067,11 +3110,11 @@ class CanvasAxisRenderer {
3067
3110
  }
3068
3111
  if (outerTick) {
3069
3112
  if (isRotated) {
3070
- painter.traceLine(x, y1, x + AXIS_TICK_SIZE * tickDirection, y1);
3071
- painter.traceLine(x, y2, x + AXIS_TICK_SIZE * tickDirection, y2);
3113
+ painter.traceLine(x, y1, x + AXIS_TICK_SIZE * outerTickDirection, y1);
3114
+ painter.traceLine(x, y2, x + AXIS_TICK_SIZE * outerTickDirection, y2);
3072
3115
  } else {
3073
- painter.traceLine(x1, y, x1, y + AXIS_TICK_SIZE * tickDirection);
3074
- painter.traceLine(x2, y, x2, y + AXIS_TICK_SIZE * tickDirection);
3116
+ painter.traceLine(x1, y, x1, y + AXIS_TICK_SIZE * outerTickDirection);
3117
+ painter.traceLine(x2, y, x2, y + AXIS_TICK_SIZE * outerTickDirection);
3075
3118
  }
3076
3119
  }
3077
3120
  });
@@ -3082,22 +3125,22 @@ class CanvasAxisRenderer {
3082
3125
  ctx.strokeStyle = axis.tickColor;
3083
3126
  ctx.lineWidth = axis.tickWidth;
3084
3127
  if (config.axis_x_tick_show) {
3085
- for (const tick of lineTicks) {
3086
- const tickPos = getXTickLinePosition($$, tick, targetScale);
3087
- const tx = margin.left + tickPos;
3088
- const ty = margin.top + tickPos;
3089
- const pos = isRotated ? ty : tx;
3090
- if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
3091
- continue;
3092
- }
3093
- painter.strokePath(() => {
3128
+ painter.strokePath(() => {
3129
+ for (const tick of lineTicks) {
3130
+ const tickPos = getXTickLinePosition($$, tick, targetScale);
3131
+ const tx = margin.left + tickPos;
3132
+ const ty = margin.top + tickPos;
3133
+ const pos = isRotated ? ty : tx;
3134
+ if (!isInAxisRange(pos, rangeStart, rangeEnd)) {
3135
+ continue;
3136
+ }
3094
3137
  if (isRotated) {
3095
3138
  painter.traceLine(x, ty, x + AXIS_TICK_SIZE * tickDirection, ty);
3096
3139
  } else {
3097
3140
  painter.traceLine(tx, y, tx, y + AXIS_TICK_SIZE * tickDirection);
3098
3141
  }
3099
- });
3100
- }
3142
+ }
3143
+ });
3101
3144
  }
3102
3145
  if (!axisOptions && !config.axis_x_tick_text_show) {
3103
3146
  return;
@@ -3371,9 +3414,11 @@ class CanvasAxisRenderer {
3371
3414
  const y1 = margin.top;
3372
3415
  const y2 = margin.top + height;
3373
3416
  const ticks = (axisOptions == null ? void 0 : axisOptions.ticks) || getYTickValues($$, id);
3417
+ const lineTicks = (axisOptions == null ? void 0 : axisOptions.ticks) || (config[`${prefix}_tick_culling`] && config[`${prefix}_tick_culling_lines`] !== false ? getYTickValues($$, id, void 0, false) : ticks);
3374
3418
  const format = (axisOptions == null ? void 0 : axisOptions.format) || ((_c = (_b = (_a = $$.axis) == null ? void 0 : _a[id]) == null ? void 0 : _b.tickFormat) == null ? void 0 : _c.call(_b)) || ((_d = config[`${prefix}_tick_format`]) == null ? void 0 : _d.bind($$.api)) || ((v) => v);
3375
3419
  const outerTick = axisOptions ? axisOptions.outerTick : config[`${prefix}_tick_outer`];
3376
3420
  const tickDirection = isRotated ? isY2 ? config.axis_y2_tick_inner ? 1 : -1 : config.axis_y_tick_inner ? -1 : 1 : isY2 ? config.axis_y2_tick_inner ? -1 : 1 : config.axis_y_tick_inner ? 1 : -1;
3421
+ const outerTickDirection = getYOuterTickDirection(config, isRotated, isY2);
3377
3422
  const tickTextDirection = getYTickTextDirection(isRotated, isY2);
3378
3423
  const tickTextPosition = config[`${prefix}_tick_text_position`];
3379
3424
  painter.withState(() => {
@@ -3387,11 +3432,11 @@ class CanvasAxisRenderer {
3387
3432
  }
3388
3433
  if (outerTick) {
3389
3434
  if (isRotated) {
3390
- painter.traceLine(x1, y, x1, y + AXIS_TICK_SIZE * tickDirection);
3391
- painter.traceLine(x2, y, x2, y + AXIS_TICK_SIZE * tickDirection);
3435
+ painter.traceLine(x1, y, x1, y + AXIS_TICK_SIZE * outerTickDirection);
3436
+ painter.traceLine(x2, y, x2, y + AXIS_TICK_SIZE * outerTickDirection);
3392
3437
  } else {
3393
- painter.traceLine(x, y1, x + AXIS_TICK_SIZE * tickDirection, y1);
3394
- painter.traceLine(x, y2, x + AXIS_TICK_SIZE * tickDirection, y2);
3438
+ painter.traceLine(x, y1, x + AXIS_TICK_SIZE * outerTickDirection, y1);
3439
+ painter.traceLine(x, y2, x + AXIS_TICK_SIZE * outerTickDirection, y2);
3395
3440
  }
3396
3441
  }
3397
3442
  });
@@ -3402,24 +3447,37 @@ class CanvasAxisRenderer {
3402
3447
  ctx.textBaseline = isRotated ? tickTextDirection > 0 ? "top" : "bottom" : "middle";
3403
3448
  ctx.strokeStyle = axis.tickColor;
3404
3449
  ctx.lineWidth = axis.tickWidth;
3405
- for (const tick of ticks) {
3450
+ const drawableTicks = [];
3451
+ const drawableLineTicks = [];
3452
+ const addDrawableTick = (tick, target) => {
3406
3453
  const value = normalizeYValue($$, tick, id);
3407
3454
  const tx = margin.left + targetScale(value);
3408
3455
  const ty = margin.top + targetScale(value);
3409
3456
  const pos = isRotated ? tx : ty;
3410
3457
  if (!isDrawable(pos)) {
3411
- continue;
3458
+ return;
3412
3459
  }
3413
- if (axisOptions || config[`${prefix}_tick_show`]) {
3414
- painter.strokePath(() => {
3460
+ target.push({ tick, tx, ty });
3461
+ };
3462
+ for (const tick of ticks) {
3463
+ addDrawableTick(tick, drawableTicks);
3464
+ }
3465
+ for (const tick of lineTicks) {
3466
+ addDrawableTick(tick, drawableLineTicks);
3467
+ }
3468
+ if (axisOptions || config[`${prefix}_tick_show`]) {
3469
+ painter.strokePath(() => {
3470
+ for (const { tx, ty } of drawableLineTicks) {
3415
3471
  if (isRotated) {
3416
3472
  painter.traceLine(tx, y, tx, y + AXIS_TICK_SIZE * tickDirection);
3417
3473
  } else {
3418
3474
  painter.traceLine(x, ty, x + AXIS_TICK_SIZE * tickDirection, ty);
3419
3475
  }
3420
- });
3421
- }
3422
- if (axisOptions || config[`${prefix}_tick_text_show`]) {
3476
+ }
3477
+ });
3478
+ }
3479
+ if (axisOptions || config[`${prefix}_tick_text_show`]) {
3480
+ for (const { tick, tx, ty } of drawableTicks) {
3423
3481
  if (isRotated) {
3424
3482
  painter.text(
3425
3483
  formatTick(format, tick),
@@ -4724,7 +4782,7 @@ function drawPointPattern(painter, pattern, x, y, r, style, baseR = r) {
4724
4782
  ctx.beginPath();
4725
4783
  if (shape.type === "path") {
4726
4784
  if (win.Path2D) {
4727
- const path = new win.Path2D(shape.d);
4785
+ const path = shape.path2D || (shape.path2D = new win.Path2D(shape.d));
4728
4786
  shouldFill && ctx.fill(path);
4729
4787
  shouldStroke && ctx.stroke(path);
4730
4788
  }
@@ -4795,6 +4853,8 @@ const SUBCHART_BRUSH_HANDLE_PATH = {
4795
4853
  end: "M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"
4796
4854
  }
4797
4855
  };
4856
+ const canvasFocusLookupCache = /* @__PURE__ */ new WeakMap();
4857
+ const subchartBrushHandlePathCache = /* @__PURE__ */ new Map();
4798
4858
  function applyCssMatrixTransform(ctx, transform) {
4799
4859
  if (!transform || transform === "none") {
4800
4860
  return;
@@ -4819,13 +4879,42 @@ function drawCanvasArea($$, target, indices, painter, isSub = false) {
4819
4879
  generateDrawAreaPath($$, indices, isSub, ctx)(target);
4820
4880
  });
4821
4881
  }
4822
- function isFocusedCanvasDatum(focus, d) {
4823
- return Boolean(
4824
- focus && d && focus.id === d.id && ("index" in d ? focus.index === d.index : true)
4825
- );
4826
- }
4827
4882
  function getFocusedCanvasDatum(focusData, d) {
4828
- return (focusData == null ? void 0 : focusData.find((focus) => isFocusedCanvasDatum(focus, d))) || null;
4883
+ if (!(focusData == null ? void 0 : focusData.length) || !(d == null ? void 0 : d.id)) {
4884
+ return null;
4885
+ }
4886
+ let lookup = canvasFocusLookupCache.get(focusData);
4887
+ if (!lookup) {
4888
+ lookup = /* @__PURE__ */ new Map();
4889
+ for (const focus of focusData) {
4890
+ if (!(focus == null ? void 0 : focus.id)) {
4891
+ continue;
4892
+ }
4893
+ const targetKey = `${focus.id}:*`;
4894
+ if (!lookup.has(targetKey)) {
4895
+ lookup.set(targetKey, focus);
4896
+ }
4897
+ if ("index" in focus) {
4898
+ lookup.set(`${focus.id}:${focus.index}`, focus);
4899
+ }
4900
+ }
4901
+ canvasFocusLookupCache.set(focusData, lookup);
4902
+ }
4903
+ return "index" in d ? lookup.get(`${d.id}:${d.index}`) || null : lookup.get(`${d.id}:*`) || null;
4904
+ }
4905
+ function getSubchartBrushHandlePath(axis, type) {
4906
+ const Path2DCtor = win.Path2D;
4907
+ if (!Path2DCtor) {
4908
+ return null;
4909
+ }
4910
+ const key = `${axis}:${type}`;
4911
+ const cached = subchartBrushHandlePathCache.get(key);
4912
+ if (cached) {
4913
+ return cached;
4914
+ }
4915
+ const path = new Path2DCtor(SUBCHART_BRUSH_HANDLE_PATH[axis][type]);
4916
+ subchartBrushHandlePathCache.set(key, path);
4917
+ return path;
4829
4918
  }
4830
4919
  function getCanvasOverColor($$, d) {
4831
4920
  const onover = $$.config.color_onover;
@@ -5116,6 +5205,21 @@ class CanvasRenderer {
5116
5205
  withContext(ctx, draw) {
5117
5206
  this.painter.withContext(ctx, draw);
5118
5207
  }
5208
+ /**
5209
+ * Release renderer caches that can hold chart or DOM references.
5210
+ * @private
5211
+ */
5212
+ destroy() {
5213
+ const clearImageHandler = (entry) => {
5214
+ entry.image.onload = null;
5215
+ entry.image.onerror = null;
5216
+ };
5217
+ this.labelImageCache.forEach(clearImageHandler);
5218
+ this.backgroundImageCache.forEach(clearImageHandler);
5219
+ this.labelImageCache.clear();
5220
+ this.backgroundImageCache.clear();
5221
+ this.backgroundClassStyleCache.clear();
5222
+ }
5119
5223
  /**
5120
5224
  * Get cached image for data label.
5121
5225
  * @param {string} url Image URL
@@ -5594,9 +5698,10 @@ class CanvasRenderer {
5594
5698
  const stroke = style.subchartBrush.handleStroke;
5595
5699
  const x = isRotated ? margin2.left + width2 / 2 : margin2.left + coord;
5596
5700
  const y = isRotated ? margin2.top + coord : margin2.top + height2 / 2;
5597
- const path = new Path2D(
5598
- SUBCHART_BRUSH_HANDLE_PATH[isRotated ? "y" : "x"][type]
5599
- );
5701
+ const path = getSubchartBrushHandlePath(isRotated ? "y" : "x", type);
5702
+ if (!path) {
5703
+ return;
5704
+ }
5600
5705
  painter.withState(() => {
5601
5706
  ctx.translate(x, y);
5602
5707
  ctx.fillStyle = fill;
@@ -5724,6 +5829,8 @@ class CanvasRenderer {
5724
5829
  for (const target of targets) {
5725
5830
  const range = getCanvasTargetVisibleRange($$, target);
5726
5831
  const targetOpacity = getCanvasTargetFocusOpacity($$, target);
5832
+ const lineWidth = style.shape.candlestickLineWidth;
5833
+ const strokeColor = style.shape.candlestickStrokeColor || "#000";
5727
5834
  for (let i = range.start; i < range.end; i++) {
5728
5835
  const d = target.values[i];
5729
5836
  const value = (_a2 = $$.getCandlestickData) == null ? void 0 : _a2.call($$, d);
@@ -5736,14 +5843,19 @@ class CanvasRenderer {
5736
5843
  }
5737
5844
  const { body: rect, wickStart, wickEnd } = geometry;
5738
5845
  ctx.fillStyle = getCanvasOverColor($$, getFocusedCanvasDatum(focusData, d)) || getCandlestickColor($$, d, value);
5739
- ctx.strokeStyle = ctx.fillStyle;
5846
+ ctx.strokeStyle = strokeColor;
5740
5847
  ctx.globalAlpha = targetOpacity;
5741
- painter.strokePath(() => {
5848
+ lineWidth > 0 && painter.strokePath(() => {
5742
5849
  painter.traceLine(wickStart[0], wickStart[1], wickEnd[0], wickEnd[1]);
5743
5850
  });
5744
5851
  painter.fillRect(rect, {
5745
5852
  alpha: (isExpanded(d) ? style.shape.candlestickExpandedOpacity : 1) * targetOpacity
5746
5853
  });
5854
+ lineWidth > 0 && painter.strokeRect(rect, {
5855
+ alpha: targetOpacity,
5856
+ lineWidth,
5857
+ stroke: strokeColor
5858
+ });
5747
5859
  }
5748
5860
  }
5749
5861
  ctx.globalAlpha = 1;
@@ -6241,6 +6353,7 @@ class CanvasRenderer {
6241
6353
  const root = (_a = $$.getTreemapRoot) == null ? void 0 : _a.call($$, $$.data.targets);
6242
6354
  const nodes = (root == null ? void 0 : root.children) || [];
6243
6355
  painter.withState(() => {
6356
+ var _a2;
6244
6357
  ctx.lineWidth = style.treemap.lineWidth;
6245
6358
  ctx.strokeStyle = style.treemap.stroke;
6246
6359
  for (const node of nodes) {
@@ -6259,6 +6372,9 @@ class CanvasRenderer {
6259
6372
  if (!config.treemap_label_show || (data.ratio || 0) < (config.treemap_label_threshold || 0)) {
6260
6373
  continue;
6261
6374
  }
6375
+ if ((_a2 = getLabelImageOption($$, data)) == null ? void 0 : _a2.url) {
6376
+ continue;
6377
+ }
6262
6378
  const label = getTreemapLabelText($$, data, w, h);
6263
6379
  if (!label) {
6264
6380
  continue;
@@ -6298,20 +6414,23 @@ class CanvasRenderer {
6298
6414
  if ($$.config.tooltip_show && $$.config.grid_focus_show !== false && !$$.config.axis_tooltip && focus) {
6299
6415
  const { x, y } = getRenderDataPoint($$, focus);
6300
6416
  const axisLineWidth = style.axis.lineWidth;
6417
+ const isRotated = $$.config.axis_rotated;
6418
+ const hasIndexCoordinate = Number.isFinite(isRotated ? y : x);
6419
+ const hasValueCoordinate = Number.isFinite(isRotated ? x : y);
6301
6420
  const crispEdgeX = (value) => painter.crisp(margin.left + value, axisLineWidth) - margin.left;
6302
6421
  const crispEdgeY = (value) => painter.crisp(margin.top + value, axisLineWidth) - margin.top;
6303
6422
  const isEdge = $$.config.grid_focus_edge && !$$.config.tooltip_grouped;
6304
- if (isFiniteCanvasCoordinate(x, y)) {
6423
+ if (hasIndexCoordinate) {
6305
6424
  painter.strokePath(() => {
6306
6425
  var _a, _b;
6307
- if ($$.config.axis_rotated) {
6426
+ if (isRotated) {
6308
6427
  painter.traceLine(
6309
6428
  crispEdgeX(0),
6310
6429
  y,
6311
- isEdge ? x : crispEdgeX($$.state.width),
6430
+ isEdge && hasValueCoordinate ? x : crispEdgeX($$.state.width),
6312
6431
  y
6313
6432
  );
6314
- if ($$.config.grid_focus_y && !$$.config.tooltip_grouped) {
6433
+ if (hasValueCoordinate && $$.config.grid_focus_y && !$$.config.tooltip_grouped) {
6315
6434
  const isY2 = ((_a = $$.axis) == null ? void 0 : _a.getId(focus.id)) === "y2";
6316
6435
  painter.traceLine(
6317
6436
  x,
@@ -6323,11 +6442,11 @@ class CanvasRenderer {
6323
6442
  } else {
6324
6443
  painter.traceLine(
6325
6444
  x,
6326
- isEdge ? y : crispEdgeY(0),
6445
+ isEdge && hasValueCoordinate ? y : crispEdgeY(0),
6327
6446
  x,
6328
6447
  crispEdgeY($$.state.height)
6329
6448
  );
6330
- if ($$.config.grid_focus_y && !$$.config.tooltip_grouped) {
6449
+ if (hasValueCoordinate && $$.config.grid_focus_y && !$$.config.tooltip_grouped) {
6331
6450
  const isY2 = ((_b = $$.axis) == null ? void 0 : _b.getId(focus.id)) === "y2";
6332
6451
  painter.traceLine(
6333
6452
  isEdge && isY2 ? x : crispEdgeX(0),
@@ -6654,6 +6773,7 @@ function applySelectorStyle(target, selector, style) {
6654
6773
  break;
6655
6774
  case ".bb-candlestick":
6656
6775
  mergeThemeSection(target, "shape", {
6776
+ candlestickStrokeColor: readColorValue(style, "stroke"),
6657
6777
  candlestickLineWidth: readNumberValue(style, "stroke-width")
6658
6778
  });
6659
6779
  break;
@@ -6772,9 +6892,22 @@ function getThemeOverride(userOverride) {
6772
6892
  const _a = userOverride, { selectors } = _a, styleOverride = __objRest(_a, ["selectors"]);
6773
6893
  return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
6774
6894
  }
6895
+ function getThemeCacheKey(container, userOverride) {
6896
+ try {
6897
+ return JSON.stringify({
6898
+ className: container.className,
6899
+ style: container.getAttribute("style") || "",
6900
+ override: userOverride || null
6901
+ });
6902
+ } catch (e) {
6903
+ return null;
6904
+ }
6905
+ }
6775
6906
  class CanvasTheme {
6776
6907
  constructor() {
6777
6908
  CanvasTheme_publicField(this, "style");
6909
+ CanvasTheme_publicField(this, "cacheContainer", null);
6910
+ CanvasTheme_publicField(this, "cacheKey", null);
6778
6911
  }
6779
6912
  /**
6780
6913
  * Read theme values from temporary SVG probes.
@@ -6903,7 +7036,7 @@ class CanvasTheme {
6903
7036
  const regionLabel = probeIn("bb-region", "text", "", ["fill", "font"]);
6904
7037
  const bar = probe("path", "bb-bar", ["opacity", "fill-opacity", "stroke", "stroke-width"]);
6905
7038
  const barExpanded = probe("path", "bb-bar _expanded_", ["opacity", "fill-opacity"]);
6906
- const candlestick = probe("path", "bb-candlestick", ["stroke-width"]);
7039
+ const candlestick = probe("path", "bb-candlestick", ["stroke", "stroke-width"]);
6907
7040
  const candlestickExpanded = probe("path", "bb-candlestick _expanded_", [
6908
7041
  "opacity",
6909
7042
  "fill-opacity"
@@ -7010,6 +7143,7 @@ class CanvasTheme {
7010
7143
  barLineWidth: toNumber(bar["stroke-width"], 0),
7011
7144
  barConnectLineColor: toColor(line.stroke, "#000"),
7012
7145
  barConnectLineWidth: toNumber(line["stroke-width"], 1),
7146
+ candlestickStrokeColor: toColor(candlestick.stroke, "#000"),
7013
7147
  candlestickLineWidth: toNumber(candlestick["stroke-width"], 1),
7014
7148
  candlestickExpandedOpacity: toNumber(
7015
7149
  toPaintOpacity(candlestickExpanded, 1),
@@ -7115,6 +7249,10 @@ class CanvasTheme {
7115
7249
  style.shape.candlestickLineWidth,
7116
7250
  defaultStyle.shape.candlestickLineWidth
7117
7251
  );
7252
+ style.shape.candlestickStrokeColor = toColor(
7253
+ style.shape.candlestickStrokeColor,
7254
+ defaultStyle.shape.candlestickStrokeColor
7255
+ );
7118
7256
  style.shape.candlestickExpandedOpacity = toNumber(
7119
7257
  style.shape.candlestickExpandedOpacity,
7120
7258
  defaultStyle.shape.candlestickExpandedOpacity
@@ -7153,6 +7291,8 @@ class CanvasTheme {
7153
7291
  );
7154
7292
  style.treemap.lineWidth = toNumber(style.treemap.lineWidth, defaultStyle.treemap.lineWidth);
7155
7293
  this.style = style;
7294
+ this.cacheContainer = container;
7295
+ this.cacheKey = getThemeCacheKey(container, userOverride);
7156
7296
  svg.remove();
7157
7297
  }
7158
7298
  /**
@@ -7162,6 +7302,10 @@ class CanvasTheme {
7162
7302
  * @private
7163
7303
  */
7164
7304
  reload(container, userOverride) {
7305
+ const key = getThemeCacheKey(container, userOverride);
7306
+ if (key !== null && this.style && this.cacheContainer === container && this.cacheKey === key) {
7307
+ return;
7308
+ }
7165
7309
  this.load(container, userOverride);
7166
7310
  }
7167
7311
  }
@@ -7421,6 +7565,35 @@ class HitDetector {
7421
7565
  }
7422
7566
  return (_b = nearest == null ? void 0 : nearest.data) != null ? _b : null;
7423
7567
  }
7568
+ /**
7569
+ * Find the nearest directly hit shape row, excluding grouped index fallback.
7570
+ * @param {number} mx Mouse x coordinate
7571
+ * @param {number} my Mouse y coordinate
7572
+ * @returns {object|null} Matching data row
7573
+ * @private
7574
+ */
7575
+ findNearestShape(mx, my) {
7576
+ var _a, _b;
7577
+ for (const item of getGridItems(this.barGrid, mx, my, BAR_CELL_SIZE)) {
7578
+ const { w = 0, h = 0 } = item;
7579
+ if (mx >= item.x && mx <= item.x + w && my >= item.y && my <= item.y + h) {
7580
+ return item.data;
7581
+ }
7582
+ }
7583
+ let nearest = null;
7584
+ let min = Number.POSITIVE_INFINITY;
7585
+ for (const item of getGridItems(this.pointGrid, mx, my, this.pointCellSize, 1)) {
7586
+ const dx = item.x - mx;
7587
+ const dy = item.y - my;
7588
+ const dist = Math.sqrt(dx * dx + dy * dy);
7589
+ const sensitivity = (_a = item.sensitivity) != null ? _a : HIT_DISTANCE;
7590
+ if (dist <= sensitivity && dist < min) {
7591
+ min = dist;
7592
+ nearest = item;
7593
+ }
7594
+ }
7595
+ return (_b = nearest == null ? void 0 : nearest.data) != null ? _b : null;
7596
+ }
7424
7597
  /**
7425
7598
  * Find the nearest grouped x-index row for an axis-adjacent pointer coordinate.
7426
7599
  * @param {number} mx Mouse x coordinate
@@ -8361,7 +8534,7 @@ const $ZOOM = {
8361
8534
  * @property {boolean} [render.observe=true] Observe bind element's visibility(`display` or `visibility` inline css property or class value) & render when it is visible automatically (for IEs, only works IE11+). When set to **false**, call [`.flush()`](./Chart.html#flush) to render.
8362
8535
  * @property {"svg"|"canvas"} [render.mode="svg"] Select rendering backend. Available values are `"svg"` and `"canvas"`. In canvas mode, chart primitives are rendered to a single `<canvas>` instead of SVG nodes.
8363
8536
  * - **NOTE:** Canvas mode doesn't create per-shape, per-tick, grid, region and label SVG DOM nodes/classes. SVG CSS selectors that depend on those nodes, such as `.bb-target-data1 .bb-bar`, `.bb-bar-0` or `.bb-axis .tick text`, won't style canvas-drawn primitives. Use chart options, supported CSS theme probes or `canvas.theme` overrides.
8364
- * - **NOTE:** Arc chart types (`pie`, `donut`, `gauge`, `polar` and `radar`) don't get meaningful rendering benefit from canvas mode. They are rendered as SVG only and `render.mode="canvas"` is ignored for those types.
8537
+ * - **NOTE:** Arc chart types (`pie`, `donut`, `gauge`, `polar` and `radar`) and funnel charts don't get meaningful rendering benefit from canvas mode. They are rendered as SVG only and `render.mode="canvas"` is ignored for those types.
8365
8538
  * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
8366
8539
  * @example
8367
8540
  * render: {
@@ -9930,6 +10103,8 @@ class State {
9930
10103
  hasRadar: false,
9931
10104
  hasTreemap: false,
9932
10105
  isCanvasMode: false,
10106
+ canvasShape: null,
10107
+ canvasFocusKey: null,
9933
10108
  canvasSubchartBrushDragging: false,
9934
10109
  canvasSubchartBrushMode: null,
9935
10110
  canvasSubchartBrushStart: null,
@@ -17122,6 +17297,28 @@ var ChartInternal_publicField = (obj, key, value) => ChartInternal_defNormalProp
17122
17297
 
17123
17298
 
17124
17299
 
17300
+ function getUnsupportedCanvasRenderType($$) {
17301
+ if ($$.hasArcType()) {
17302
+ return "arc charts";
17303
+ }
17304
+ if ($$.hasType("funnel")) {
17305
+ return "funnel chart";
17306
+ }
17307
+ return null;
17308
+ }
17309
+ function fallbackUnsupportedCanvasRenderMode($$) {
17310
+ var _a, _b;
17311
+ const { config } = $$;
17312
+ const unsupportedType = config.render_mode === "canvas" ? getUnsupportedCanvasRenderType($$) : null;
17313
+ if (!unsupportedType) {
17314
+ return;
17315
+ }
17316
+ (_b = (_a = win.console) == null ? void 0 : _a.warn) == null ? void 0 : _b.call(
17317
+ _a,
17318
+ `[billboard.js] render.mode='canvas' is ignored for ${unsupportedType}; falling back to SVG.`
17319
+ );
17320
+ config.render_mode = "svg";
17321
+ }
17125
17322
  class ChartInternal {
17126
17323
  constructor(api) {
17127
17324
  ChartInternal_publicField(this, "api");
@@ -17222,6 +17419,7 @@ class ChartInternal {
17222
17419
  const { config, state, $el } = $$;
17223
17420
  const { boost_useCssRule, bindto } = config;
17224
17421
  checkModuleImport($$);
17422
+ fallbackUnsupportedCanvasRenderMode($$);
17225
17423
  const hasArcType = $$.hasArcType();
17226
17424
  state.hasRadar = !state.hasAxis && $$.hasType("radar");
17227
17425
  state.hasFunnel = !state.hasAxis && $$.hasType("funnel");
@@ -17916,9 +18114,10 @@ function getCanvasEventClientPoint(event) {
17916
18114
  const touch = ((_a = touchEvent.changedTouches) == null ? void 0 : _a[0]) || ((_b = touchEvent.touches) == null ? void 0 : _b[0]);
17917
18115
  return touch || ("clientX" in event ? event : null);
17918
18116
  }
17919
- function getCanvasEventDatum($$, event) {
18117
+ function getCanvasEventDatum($$, event, shapeOnly = false) {
18118
+ var _a, _b;
17920
18119
  const point = getCanvasEventPoint($$, event);
17921
- return point ? $$.hitDetector.findNearest(point[0], point[1]) : null;
18120
+ return point ? shapeOnly ? (_b = (_a = $$.hitDetector).findNearestShape) == null ? void 0 : _b.call(_a, point[0], point[1]) : $$.hitDetector.findNearest(point[0], point[1]) : null;
17922
18121
  }
17923
18122
  function isCanvasXIndexHoverArea($$, point) {
17924
18123
  var _a;
@@ -17955,6 +18154,10 @@ function getCanvasTooltipData($$, d) {
17955
18154
  return ((_a2 = $$.addName) == null ? void 0 : _a2.call($$, v)) || v;
17956
18155
  });
17957
18156
  }
18157
+ function getCanvasFocusData($$, d, selectedData) {
18158
+ var _a, _b;
18159
+ return ((_a = $$.isMultipleX) == null ? void 0 : _a.call($$)) && !isCanvasPointBasedInteraction($$, d) ? [((_b = $$.addName) == null ? void 0 : _b.call($$, d)) || d] : selectedData;
18160
+ }
17958
18161
  function getCanvasEventPoint($$, event) {
17959
18162
  const point = getCanvasEventClientPoint(event);
17960
18163
  if (!point) {
@@ -18456,13 +18659,14 @@ const canvasInternal = {
18456
18659
  !isSupportedCanvasYType(config.axis_y2_type),
18457
18660
  "axis.y2.type other than indexed/log/timeseries"
18458
18661
  ],
18662
+ [config.boost_useCssRule, "boost.useCssRule"],
18459
18663
  [(_a = this.hasArcType) == null ? void 0 : _a.call(this), "arc charts"],
18460
18664
  [(_b = this.hasType) == null ? void 0 : _b.call(this, "radar"), "radar chart"],
18461
18665
  [(_c = this.hasType) == null ? void 0 : _c.call(this, "polar"), "polar chart"],
18462
18666
  [(_d = this.hasType) == null ? void 0 : _d.call(this, "funnel"), "funnel chart"]
18463
18667
  ];
18464
18668
  unsupported.forEach(([condition, name]) => {
18465
- condition && warn(`canvas mode: ${name} is not supported in v1.`);
18669
+ condition && warn(`canvas mode: ${name} is not yet supported.`);
18466
18670
  });
18467
18671
  },
18468
18672
  /**
@@ -19104,7 +19308,7 @@ const canvasInternal = {
19104
19308
  const $$ = this;
19105
19309
  const { config, $el } = $$;
19106
19310
  const canvas2 = $el.canvas.node();
19107
- const d = getCanvasEventDatum($$, event);
19311
+ const d = getCanvasEventDatum($$, event, true);
19108
19312
  if (!d || isDuplicateCanvasInputClick($$, d)) {
19109
19313
  return d;
19110
19314
  }
@@ -19577,10 +19781,11 @@ const canvasInternal = {
19577
19781
  }
19578
19782
  $$.dispatchCanvasDataOver(d, canvas2);
19579
19783
  const selectedData = getCanvasTooltipData($$, d);
19580
- const focusKey = selectedData.map((v) => `${v.id}:${v.index}`).join("|");
19784
+ const focusData = getCanvasFocusData($$, d, selectedData);
19785
+ const focusKey = focusData.map((v) => `${v.id}:${v.index}`).join("|");
19581
19786
  if (state.canvasFocusKey !== focusKey || config.axis_tooltip) {
19582
19787
  state.canvasFocusKey = focusKey;
19583
- $$.renderCanvasFocus(selectedData, point);
19788
+ $$.renderCanvasFocus(focusData, point);
19584
19789
  }
19585
19790
  (_e = $$.showTooltip) == null ? void 0 : _e.call($$, selectedData, canvas2);
19586
19791
  },
@@ -19959,7 +20164,7 @@ function loadConfig(config) {
19959
20164
  * chart.destroy();
19960
20165
  */
19961
20166
  destroy() {
19962
- var _a, _b, _c, _d, _e, _f, _g;
20167
+ var _a, _b, _c, _d, _e, _f, _g, _h;
19963
20168
  const $$ = this.internal;
19964
20169
  const { state, $el: { chart, style, svg } } = $$;
19965
20170
  if (notEmpty($$)) {
@@ -19971,9 +20176,10 @@ function loadConfig(config) {
19971
20176
  state.canvasFlowFrame !== null && ((_c = (_b = win).cancelAnimationFrame) == null ? void 0 : _c.call(_b, state.canvasFlowFrame));
19972
20177
  state.canvasFlowFrame = null;
19973
20178
  state.canvasFlowFinish = null;
19974
- (_d = $$.canvasEngine) == null ? void 0 : _d.destroy();
19975
- (_e = $$.resizeFunction) == null ? void 0 : _e.clear();
19976
- (_g = (_f = $$.resizeFunction) == null ? void 0 : _f.resizeObserver) == null ? void 0 : _g.disconnect();
20179
+ (_d = $$.canvasRenderer) == null ? void 0 : _d.destroy();
20180
+ (_e = $$.canvasEngine) == null ? void 0 : _e.destroy();
20181
+ (_f = $$.resizeFunction) == null ? void 0 : _f.clear();
20182
+ (_h = (_g = $$.resizeFunction) == null ? void 0 : _g.resizeObserver) == null ? void 0 : _h.disconnect();
19977
20183
  $$.resizeFunction && win.removeEventListener("resize", $$.resizeFunction);
19978
20184
  chart.classed("bb", false).style("position", null);
19979
20185
  if (state.isCanvasMode) {
@@ -34063,7 +34269,7 @@ const bb = {
34063
34269
  * bb.version; // "1.0.0"
34064
34270
  * @memberof bb
34065
34271
  */
34066
- version: "4.0.0-next.1",
34272
+ version: "4.0.0-next.2",
34067
34273
  /**
34068
34274
  * Generate chart
34069
34275
  * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when: