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
@@ -83,6 +83,14 @@ export type CanvasThemeSelectorMap = Record<string, CanvasThemeSelectorStyle>;
83
83
  export type CanvasThemeOverride = CanvasThemeDeepPartial<CanvasThemeStyle> & {
84
84
  selectors?: CanvasThemeSelectorMap
85
85
  };
86
+ export type CanvasGridLineThemeStyle = Partial<CanvasThemeStyle["grid"]>;
87
+
88
+ type CanvasGridLineSelectorTarget = "line" | "text";
89
+ type CanvasGridLineSelectorOverride = {
90
+ selector: string,
91
+ target: CanvasGridLineSelectorTarget,
92
+ style: CanvasGridLineThemeStyle
93
+ };
86
94
 
87
95
  const SVG_NS = "http://www.w3.org/2000/svg";
88
96
 
@@ -372,6 +380,176 @@ function normalizeThemeSelectors(selector: string): string[] {
372
380
  .filter(Boolean);
373
381
  }
374
382
 
383
+ /**
384
+ * Get own keys from a style object whose values are set.
385
+ * @param {object} values Style values
386
+ * @returns {Array} Defined keys
387
+ * @private
388
+ */
389
+ function getDefinedKeys<T extends Record<string, any>>(values: T): Array<keyof T> {
390
+ return Object.keys(values).filter(key => values[key] !== undefined) as Array<keyof T>;
391
+ }
392
+
393
+ /**
394
+ * Copy the defined entries of an object into a target of the same shape.
395
+ * @param {object} target Object to copy into
396
+ * @param {object} source Object to copy from
397
+ * @param {Set} skip Keys to leave untouched
398
+ * @returns {object} The target object
399
+ * @private
400
+ */
401
+ function assignDefined<T extends Record<string, any>>(
402
+ target: T,
403
+ source: T,
404
+ skip?: Set<keyof T>
405
+ ): T {
406
+ getDefinedKeys(source).forEach(<K extends keyof T>(key: K) => {
407
+ if (!skip?.has(key)) {
408
+ target[key] = source[key];
409
+ }
410
+ });
411
+
412
+ return target;
413
+ }
414
+
415
+ /**
416
+ * Check whether a selector is simple enough for virtual optional grid line matching.
417
+ * @param {string} selector Normalized SVG selector
418
+ * @returns {boolean} Whether selector can be matched
419
+ * @private
420
+ */
421
+ function isSimpleGridLineSelector(selector: string): boolean {
422
+ const tokens = selector.split(" ");
423
+
424
+ return tokens.every((token, index) =>
425
+ (token === "line" || token === "text") ?
426
+ index === tokens.length - 1 :
427
+ /^(\.[A-Za-z_-][\w-]*)+$/.test(token)
428
+ );
429
+ }
430
+
431
+ /**
432
+ * Get optional grid line selector target.
433
+ * @param {string} selector Normalized SVG selector
434
+ * @returns {string|null} Selector target
435
+ * @private
436
+ */
437
+ function getGridLineSelectorTarget(
438
+ selector: string
439
+ ): CanvasGridLineSelectorTarget | null {
440
+ const tokens = selector.split(" ");
441
+ const target = tokens[tokens.length - 1];
442
+
443
+ return target === "line" || target === "text" ? target : null;
444
+ }
445
+
446
+ /**
447
+ * Split custom class value.
448
+ * @param {string} className Custom class value
449
+ * @returns {Array} Class names
450
+ * @private
451
+ */
452
+ function getClassNames(className?: string): string[] {
453
+ return (className || "").split(/\s+/).filter(Boolean);
454
+ }
455
+
456
+ /**
457
+ * Read optional grid line or label style from selector style declaration.
458
+ * @param {object} style Style declaration object
459
+ * @param {string} target Selector target
460
+ * @returns {object} Grid line style
461
+ * @private
462
+ */
463
+ function getGridLineSelectorStyle(
464
+ style: CanvasThemeSelectorStyle,
465
+ target: CanvasGridLineSelectorTarget
466
+ ): CanvasGridLineThemeStyle {
467
+ const values: CanvasGridLineThemeStyle = target === "text" ?
468
+ {
469
+ labelColor: readColorValue(style, "fill"),
470
+ labelFont: readFontValue(style)
471
+ } :
472
+ {
473
+ lineColor: readColorValue(style, "stroke"),
474
+ lineWidth: readNumberValue(style, "stroke-width"),
475
+ dashArray: readDashArrayValue(style)
476
+ };
477
+
478
+ return assignDefined({} as CanvasGridLineThemeStyle, values);
479
+ }
480
+
481
+ /**
482
+ * Convert selector based optional grid line overrides to ordered matcher entries.
483
+ * @param {object} selectors Selector style declarations
484
+ * @returns {Array} Optional grid line selector overrides
485
+ * @private
486
+ */
487
+ function getGridLineSelectorOverrides(
488
+ selectors?: CanvasThemeSelectorMap
489
+ ): CanvasGridLineSelectorOverride[] {
490
+ const overrides: CanvasGridLineSelectorOverride[] = [];
491
+
492
+ Object.keys(selectors ?? {}).forEach(selector => {
493
+ normalizeThemeSelectors(selector).forEach(normalizedSelector => {
494
+ const target = getGridLineSelectorTarget(normalizedSelector) || "line";
495
+ const style = getGridLineSelectorStyle(selectors![selector], target);
496
+
497
+ if (isSimpleGridLineSelector(normalizedSelector) && getDefinedKeys(style).length) {
498
+ overrides.push({selector: normalizedSelector, target, style});
499
+ }
500
+ });
501
+ });
502
+
503
+ return overrides;
504
+ }
505
+
506
+ /**
507
+ * Check whether a virtual optional grid line selector matches a grid line config.
508
+ * @param {string} selector Normalized SVG selector
509
+ * @param {string} axis Grid axis
510
+ * @param {string} className Grid line custom class
511
+ * @param {string} target Draw target
512
+ * @returns {boolean} Whether selector matches
513
+ * @private
514
+ */
515
+ function matchesGridLineSelector(
516
+ selector: string,
517
+ axis: "x" | "y",
518
+ className: string | undefined,
519
+ target: CanvasGridLineSelectorTarget
520
+ ): boolean {
521
+ if (!isSimpleGridLineSelector(selector)) {
522
+ return false;
523
+ }
524
+
525
+ const selectorTarget = getGridLineSelectorTarget(selector);
526
+
527
+ if (selectorTarget && selectorTarget !== target) {
528
+ return false;
529
+ } else if (!selectorTarget && target === "text") {
530
+ return false;
531
+ }
532
+
533
+ const customClasses = getClassNames(className);
534
+ const axisLineClass = `bb-${axis}grid-line`;
535
+ const availableClasses = new Set([
536
+ "bb-grid",
537
+ "bb-grid-lines",
538
+ `bb-${axis}grid-lines`,
539
+ axisLineClass,
540
+ ...customClasses
541
+ ]);
542
+ const selectorClasses = (selector.match(/\.[A-Za-z_-][\w-]*/g) || [])
543
+ .map(match => match.slice(1));
544
+
545
+ return !!selectorClasses.length &&
546
+ selectorClasses.every(cls => availableClasses.has(cls)) &&
547
+ (
548
+ selectorClasses.includes(axisLineClass) ||
549
+ customClasses.some(cls => selectorClasses.includes(cls))
550
+ );
551
+ }
552
+
375
553
  /**
376
554
  * Apply one selector style declaration to canvas theme override.
377
555
  * @param {object} target Theme override target
@@ -697,6 +875,8 @@ export default class CanvasTheme {
697
875
  public style!: CanvasThemeStyle;
698
876
  private cacheContainer: HTMLElement | null = null;
699
877
  private cacheKey: string | null = null;
878
+ private gridLineSelectorOverrides: CanvasGridLineSelectorOverride[] = [];
879
+ private directGridOverrideKeys = new Set<keyof CanvasThemeStyle["grid"]>();
700
880
 
701
881
  /**
702
882
  * Read theme values from temporary SVG probes.
@@ -707,6 +887,11 @@ export default class CanvasTheme {
707
887
  load(container: HTMLElement, userOverride?: CanvasThemeOverride): void {
708
888
  const svg = document.createElementNS(SVG_NS, "svg");
709
889
 
890
+ this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride?.selectors);
891
+ this.directGridOverrideKeys = new Set(
892
+ Object.keys(userOverride?.grid ?? {})
893
+ ) as Set<keyof CanvasThemeStyle["grid"]>;
894
+
710
895
  svg.setAttribute("class", "bb");
711
896
  svg.style.cssText =
712
897
  "position:absolute;visibility:hidden;pointer-events:none;width:0;height:0;overflow:hidden";
@@ -1163,4 +1348,31 @@ export default class CanvasTheme {
1163
1348
 
1164
1349
  this.load(container, userOverride);
1165
1350
  }
1351
+
1352
+ /**
1353
+ * Resolve selector based style for one configured optional grid line.
1354
+ * @param {string} axis Grid axis
1355
+ * @param {object} line Grid line options
1356
+ * @param {string} line.class Grid line custom class
1357
+ * @param {string} target Draw target
1358
+ * @returns {object|undefined} Grid line style override
1359
+ * @private
1360
+ */
1361
+ getGridLineStyle(
1362
+ axis: "x" | "y",
1363
+ line: {class?: string} = {},
1364
+ target: CanvasGridLineSelectorTarget = "line"
1365
+ ): CanvasGridLineThemeStyle | undefined {
1366
+ const style: CanvasGridLineThemeStyle = {};
1367
+
1368
+ for (const override of this.gridLineSelectorOverrides) {
1369
+ if (!matchesGridLineSelector(override.selector, axis, line.class, target)) {
1370
+ continue;
1371
+ }
1372
+
1373
+ assignDefined(style, override.style, this.directGridOverrideKeys);
1374
+ }
1375
+
1376
+ return getDefinedKeys(style).length ? style : undefined;
1377
+ }
1166
1378
  }
@@ -12,6 +12,21 @@ import {getCanvasComparableValue, getCanvasComparableXDomain} from "./util";
12
12
  export type YAxisId = Exclude<AxisType, "x">;
13
13
  type XDataTickCache = {key: string, values: AxisTickValue[], comparable: number[]};
14
14
 
15
+ /**
16
+ * Get tick option value for main/subchart canvas axes.
17
+ * @param {object} config Chart config
18
+ * @param {string} id Base axis id
19
+ * @param {string} key Tick option key
20
+ * @param {string} prefix Option prefix
21
+ * @returns {boolean|number|string|Array|object|function|null|undefined} Tick option value
22
+ * @private
23
+ */
24
+ function getAxisTickOption(config, id: AxisType, key: string, prefix = `axis_${id}`) {
25
+ const value = config[`${prefix}_tick_${key}`];
26
+
27
+ return value !== undefined ? value : config[`axis_${id}_tick_${key}`];
28
+ }
29
+
15
30
  /**
16
31
  * Get explicitly configured tick values.
17
32
  * @param {Array|function} values Tick values option
@@ -578,14 +593,17 @@ export function getXTickValues($$, cull = true): AxisTickValue[] {
578
593
  function getSubXTickCullMax($$): number | undefined {
579
594
  const {config, state: {height2, width2}} = $$;
580
595
  const size = config.axis_rotated ? height2 : width2;
596
+ const count = getAxisTickOption(config, "x", "count", "subchart_axis_x");
597
+ const culling = getAxisTickOption(config, "x", "culling", "subchart_axis_x");
598
+ const cullingMax = getAxisTickOption(config, "x", "culling_max", "subchart_axis_x");
581
599
 
582
- if (config.axis_x_tick_count) {
583
- return config.axis_x_tick_count;
600
+ if (count) {
601
+ return count;
584
602
  }
585
603
 
586
- if (config.axis_x_tick_culling !== false) {
604
+ if (culling !== false) {
587
605
  return Math.min(
588
- config.axis_x_tick_culling_max || AXIS_DEFAULT_TICK_COUNT,
606
+ cullingMax || AXIS_DEFAULT_TICK_COUNT,
589
607
  Math.max(2, Math.floor(size / 70))
590
608
  );
591
609
  }
@@ -596,57 +614,66 @@ function getSubXTickCullMax($$): number | undefined {
596
614
  /**
597
615
  * Get x ticks for the canvas subchart axis.
598
616
  * @param {object} $$ ChartInternal context
617
+ * @param {boolean} culling Whether to cull tick values
599
618
  * @returns {Array} Tick values
600
619
  * @private
601
620
  */
602
- export function getSubXTickValues($$): AxisTickValue[] {
621
+ export function getSubXTickValues($$, culling = true): AxisTickValue[] {
603
622
  const {axis, config, scale} = $$;
604
623
  const targetScale = scale.subX;
605
624
  const targetsToShow = $$.getTargetsToShow?.() || $$.filterTargetsToShow();
625
+ const tickCount = getAxisTickOption(config, "x", "count", "subchart_axis_x");
606
626
  const cullMax = getSubXTickCullMax($$);
607
- const cull = (ticks: AxisTickValue[]): AxisTickValue[] => cullTicks(ticks, cullMax);
627
+ const cullData = (ticks: AxisTickValue[], sorted = false): AxisTickValue[] =>
628
+ culling ? cullDataTicks($$, ticks, sorted, "subchart_axis_x", cullMax) : ticks;
608
629
 
609
630
  if (!targetScale || !targetsToShow?.length) {
610
631
  return [];
611
632
  }
612
633
 
613
- const explicit = getOptionTickValues(config.axis_x_tick_values, $$.api);
634
+ const explicit = getOptionTickValues(
635
+ getAxisTickOption(config, "x", "values", "subchart_axis_x"),
636
+ $$.api
637
+ );
614
638
 
615
639
  if (explicit) {
616
- return cull(normalizeXTickValues($$, explicit));
640
+ return cullData(normalizeXTickValues($$, explicit));
617
641
  }
618
642
 
619
643
  if (config.axis_x_tick_fit && $$.mapTargetsToUniqueXs) {
620
644
  const generated = generateTickValues(
621
645
  $$,
622
646
  $$.mapTargetsToUniqueXs(targetsToShow),
623
- config.axis_x_tick_count,
647
+ tickCount,
624
648
  axis?.isTimeSeries?.()
625
649
  );
626
650
 
627
- return cull(generated);
651
+ return cullData(generated, true);
628
652
  }
629
653
 
630
654
  if (axis?.isCategorized?.() && config.axis_x_categories?.length) {
631
- return cull(config.axis_x_categories.map((_, i) => i));
655
+ return cullData(config.axis_x_categories.map((_, i) => i), true);
632
656
  }
633
657
 
634
658
  const generated = getScaleTicks(
635
659
  targetScale,
636
- config.axis_x_tick_count || AXIS_DEFAULT_TICK_COUNT
660
+ tickCount || AXIS_DEFAULT_TICK_COUNT
637
661
  );
638
662
 
639
- return cull(generated);
663
+ return cullData(generated, true);
640
664
  }
641
665
 
642
666
  /**
643
667
  * Get raw category boundary tick values for x axis tick lines.
644
668
  * @param {object} $$ ChartInternal context
669
+ * @param {function} targetScale X scale
670
+ * @param {boolean} outerTick Whether outer ticks are shown
645
671
  * @returns {Array} Category boundary values
646
672
  * @private
647
673
  */
648
- function getCategoryXTickLineValues($$): AxisTickValue[] {
649
- const scale = getXScale($$);
674
+ function getCategoryXTickLineValues($$, targetScale = getXScale($$),
675
+ outerTick = $$.config.axis_x_tick_outer): AxisTickValue[] {
676
+ const scale = targetScale;
650
677
  const domain = scale.orgDomain?.() || scale.domain?.();
651
678
 
652
679
  if (!domain?.length) {
@@ -664,7 +691,7 @@ function getCategoryXTickLineValues($$): AxisTickValue[] {
664
691
  const max = Math.floor(Math.max(start, end));
665
692
  const values = Array.from({length: Math.max(0, max - min + 1)}, (_, i) => min + i);
666
693
 
667
- return $$.config.axis_x_tick_outer ? values.slice(1, -1) : values;
694
+ return outerTick ? values.slice(1, -1) : values;
668
695
  }
669
696
 
670
697
  /**
@@ -700,18 +727,19 @@ export function getXTickLinePosition($$, value: AxisTickValue,
700
727
  * @param {object} $$ ChartInternal context
701
728
  * @param {Array} ticks Sorted tick values
702
729
  * @param {number} tickLineWidth Tick line stroke width
730
+ * @param {function} targetScale X scale
703
731
  * @returns {boolean} Whether tick lines should follow culled text ticks
704
732
  * @private
705
733
  */
706
- function hasOverlappedXTickLineIntervals($$, ticks: AxisTickValue[],
707
- tickLineWidth: number): boolean {
734
+ function hasOverlappedXTickLineIntervals($$, ticks: AxisTickValue[], tickLineWidth: number,
735
+ targetScale = getXScale($$)): boolean {
708
736
  if (ticks.length < 2) {
709
737
  return false;
710
738
  }
711
739
 
712
740
  const halfWidth = Math.max(1, tickLineWidth) / 2;
713
741
  const positions = ticks
714
- .map(tick => getXTickLinePosition($$, tick))
742
+ .map(tick => getXTickLinePosition($$, tick, targetScale))
715
743
  .filter(Number.isFinite)
716
744
  .sort((a, b) => a - b);
717
745
 
@@ -739,14 +767,16 @@ function hasOverlappedXTickLineIntervals($$, ticks: AxisTickValue[],
739
767
  * Remove line ticks that map to the same canvas pixel.
740
768
  * @param {object} $$ ChartInternal context
741
769
  * @param {Array} ticks Tick values
770
+ * @param {function} targetScale X scale
742
771
  * @returns {Array} Pixel-deduped tick values
743
772
  * @private
744
773
  */
745
- function dedupeXTickLineValues($$, ticks: AxisTickValue[]): AxisTickValue[] {
774
+ function dedupeXTickLineValues($$, ticks: AxisTickValue[],
775
+ targetScale = getXScale($$)): AxisTickValue[] {
746
776
  const seen = new Set<number>();
747
777
 
748
778
  return ticks.filter(tick => {
749
- const pos = getXTickLinePosition($$, tick);
779
+ const pos = getXTickLinePosition($$, tick, targetScale);
750
780
  const key = Math.round(pos);
751
781
 
752
782
  if (!Number.isFinite(pos) || seen.has(key)) {
@@ -788,12 +818,51 @@ export function getXTickLineValues($$, textTicks: AxisTickValue[],
788
818
  dedupeXTickLineValues($$, lineTicks);
789
819
  }
790
820
 
821
+ /**
822
+ * Get subchart x tick values for tick lines, following SVG culling options.
823
+ * @param {object} $$ ChartInternal context
824
+ * @param {Array} textTicks Text tick values
825
+ * @param {number} tickLineWidth Tick line stroke width
826
+ * @returns {Array} Tick line values
827
+ * @private
828
+ */
829
+ export function getSubXTickLineValues($$, textTicks: AxisTickValue[],
830
+ tickLineWidth = 1): AxisTickValue[] {
831
+ const {axis, config, scale} = $$;
832
+ const targetScale = scale.subX;
833
+ const culling = getAxisTickOption(config, "x", "culling", "subchart_axis_x");
834
+ const cullingLines = getAxisTickOption(config, "x", "culling_lines", "subchart_axis_x");
835
+ const outerTick = getAxisTickOption(config, "x", "outer", "subchart_axis_x");
836
+
837
+ if (!targetScale) {
838
+ return [];
839
+ }
840
+
841
+ if (axis?.isCategorized?.()) {
842
+ const categoryLineTicks = getCategoryXTickLineValues($$, targetScale, outerTick);
843
+
844
+ return dedupeXTickLineValues($$, categoryLineTicks, targetScale);
845
+ }
846
+
847
+ if (culling === false || cullingLines === false) {
848
+ return textTicks;
849
+ }
850
+
851
+ const lineTicks = getSubXTickValues($$, false);
852
+
853
+ return hasOverlappedXTickLineIntervals($$, lineTicks, tickLineWidth, targetScale) ?
854
+ textTicks :
855
+ dedupeXTickLineValues($$, lineTicks, targetScale);
856
+ }
857
+
791
858
  /**
792
859
  * Get y ticks for indexed/linear canvas mode.
793
860
  * @param {object} $$ ChartInternal context
794
861
  * @param {string} id Axis id
795
862
  * @param {number} count Optional tick count override
796
863
  * @param {boolean} culling Whether to apply tick culling
864
+ * @param {d3Scale} targetScale Scale to generate ticks from
865
+ * @param {string} optionPrefix Tick option prefix
797
866
  * @returns {Array} Tick values
798
867
  * @private
799
868
  */
@@ -801,13 +870,18 @@ export function getYTickValues(
801
870
  $$,
802
871
  id: YAxisId = "y",
803
872
  count?: number,
804
- culling = true
873
+ culling = true,
874
+ targetScale = $$.scale[id],
875
+ optionPrefix = `axis_${id}`
805
876
  ): AxisTickValue[] {
806
- const {axis, config, scale} = $$;
877
+ const {axis, config} = $$;
807
878
  const prefix = `axis_${id}`;
808
- const targetScale = scale[id];
809
- const explicit = getOptionTickValues(config[`${prefix}_tick_values`], $$.api);
810
- const maybeCull = (ticks: AxisTickValue[]) => culling ? cullAxisTicks($$, id, ticks) : ticks;
879
+ const explicit = getOptionTickValues(
880
+ getAxisTickOption(config, id, "values", optionPrefix),
881
+ $$.api
882
+ );
883
+ const maybeCull = (ticks: AxisTickValue[]) =>
884
+ culling ? cullAxisTicks($$, id, ticks, optionPrefix) : ticks;
811
885
 
812
886
  if (explicit) {
813
887
  return maybeCull(normalizeYTickValues($$, explicit, id));
@@ -819,7 +893,7 @@ export function getYTickValues(
819
893
  return maybeCull(stepTicks);
820
894
  }
821
895
 
822
- const tickCount = count ?? config[`${prefix}_tick_count`];
896
+ const tickCount = count ?? getAxisTickOption(config, id, "count", optionPrefix);
823
897
 
824
898
  if (axis?.isTimeSeries?.(id) && config[`${prefix}_tick_time_value`]) {
825
899
  return maybeCull(getScaleTicks(targetScale, config[`${prefix}_tick_time_value`]));
@@ -929,17 +1003,22 @@ function cullTicks(ticks: AxisTickValue[], count?: number): AxisTickValue[] {
929
1003
  * @param {object} $$ ChartInternal context
930
1004
  * @param {string} id Axis id
931
1005
  * @param {Array} ticks Tick values
1006
+ * @param {string} optionPrefix Tick option prefix
932
1007
  * @returns {Array} Culled tick values
933
1008
  * @private
934
1009
  */
935
- function cullAxisTicks($$, id: AxisType, ticks: AxisTickValue[]): AxisTickValue[] {
1010
+ function cullAxisTicks($$, id: AxisType, ticks: AxisTickValue[],
1011
+ optionPrefix = `axis_${id}`): AxisTickValue[] {
936
1012
  const {config} = $$;
937
- const prefix = `axis_${id}_tick_culling`;
1013
+ const culling = getAxisTickOption(config, id, "culling", optionPrefix);
938
1014
 
939
- if (!config[prefix]) {
1015
+ if (!culling) {
940
1016
  return ticks;
941
1017
  }
942
1018
 
1019
+ const cullingMax = getAxisTickOption(config, id, "culling_max", optionPrefix) ||
1020
+ AXIS_DEFAULT_TICK_COUNT;
1021
+ const reverse = getAxisTickOption(config, id, "culling_reverse", optionPrefix);
943
1022
  const sortedTicks = ticks.slice().sort((a, b) => {
944
1023
  const av = +a;
945
1024
  const bv = +b;
@@ -947,10 +1026,9 @@ function cullAxisTicks($$, id: AxisType, ticks: AxisTickValue[]): AxisTickValue[
947
1026
  av - bv :
948
1027
  String(a).localeCompare(String(b));
949
1028
 
950
- return config[`${prefix}_reverse`] ? -order : order;
1029
+ return reverse ? -order : order;
951
1030
  });
952
1031
  const tickSize = sortedTicks.length;
953
- const cullingMax = config[`${prefix}_max`] || AXIS_DEFAULT_TICK_COUNT;
954
1032
  let intervalForCulling = 0;
955
1033
 
956
1034
  for (let i = 1; i < tickSize; i++) {
@@ -976,17 +1054,23 @@ function cullAxisTicks($$, id: AxisType, ticks: AxisTickValue[]): AxisTickValue[
976
1054
  * @param {object} $$ ChartInternal context
977
1055
  * @param {Array} ticks Tick values
978
1056
  * @param {boolean} sorted Whether ticks are already sorted in x order
1057
+ * @param {string} optionPrefix Tick option prefix
1058
+ * @param {number} max Optional culling max override
979
1059
  * @returns {Array} Culled tick values
980
1060
  * @private
981
1061
  */
982
- function cullDataTicks($$, ticks: AxisTickValue[], sorted = false): AxisTickValue[] {
1062
+ function cullDataTicks($$, ticks: AxisTickValue[], sorted = false, optionPrefix = "axis_x",
1063
+ max?: number): AxisTickValue[] {
983
1064
  const {config} = $$;
1065
+ const culling = getAxisTickOption(config, "x", "culling", optionPrefix);
984
1066
 
985
- if (config.axis_x_tick_culling === false) {
1067
+ if (culling === false) {
986
1068
  return ticks;
987
1069
  }
988
1070
 
989
- const cullingMax = config.axis_x_tick_culling_max || AXIS_DEFAULT_TICK_COUNT;
1071
+ const cullingMax = max || getAxisTickOption(config, "x", "culling_max", optionPrefix) ||
1072
+ AXIS_DEFAULT_TICK_COUNT;
1073
+ const reverse = getAxisTickOption(config, "x", "culling_reverse", optionPrefix);
990
1074
  const sortedTicks = sorted ? ticks : ticks
991
1075
  .slice()
992
1076
  .sort((a, b) => {
@@ -994,10 +1078,10 @@ function cullDataTicks($$, ticks: AxisTickValue[], sorted = false): AxisTickValu
994
1078
  const bv = +b;
995
1079
 
996
1080
  if (Number.isFinite(av) && Number.isFinite(bv)) {
997
- return config.axis_x_tick_culling_reverse ? bv - av : av - bv;
1081
+ return reverse ? bv - av : av - bv;
998
1082
  }
999
1083
 
1000
- return config.axis_x_tick_culling_reverse ?
1084
+ return reverse ?
1001
1085
  String(b).localeCompare(String(a)) :
1002
1086
  String(a).localeCompare(String(b));
1003
1087
  });
@@ -1017,9 +1101,7 @@ function cullDataTicks($$, ticks: AxisTickValue[], sorted = false): AxisTickValu
1017
1101
 
1018
1102
  if (sorted) {
1019
1103
  return ticks.filter((_, i) =>
1020
- config.axis_x_tick_culling_reverse ?
1021
- (tickSize - 1 - i) % intervalForCulling === 0 :
1022
- i % intervalForCulling === 0
1104
+ reverse ? (tickSize - 1 - i) % intervalForCulling === 0 : i % intervalForCulling === 0
1023
1105
  );
1024
1106
  }
1025
1107
 
@@ -6,6 +6,19 @@
6
6
  * y2 Axis config options
7
7
  */
8
8
  export default {
9
+ /**
10
+ * Set clip-path attribute for y2 axis element
11
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
12
+ * @name axis․y2․clipPath
13
+ * @memberof Options
14
+ * @type {boolean}
15
+ * @default true
16
+ * @example
17
+ * // don't set 'clip-path' attribute
18
+ * clipPath: false
19
+ */
20
+ axis_y2_clipPath: true,
21
+
9
22
  /**
10
23
  * Show or hide y2 axis.
11
24
  * - **NOTE**:
@@ -16,17 +16,77 @@ export default {
16
16
  * - **NOTE:**
17
17
  * - Will append &lt;style> to the head tag and will add shpes' CSS rules dynamically.
18
18
  * - For now, covers colors related properties (fill, stroke, etc.) only.
19
- * @property {boolean} [boost.useWorker=false] Use Web Worker as possible for processing.
19
+ * @property {boolean|string} [boost.useWorker=false] Use Web Worker as possible for processing.
20
+ * - **Available values:**
21
+ * - `false`: never offload.
22
+ * - `true`: always offload when a Worker can be created.
23
+ * - `"auto"`: offload only when the given data exceeds ~5,000 cells, since smaller
24
+ * payloads lose more to structured cloning than they gain.
20
25
  * - **NOTE:**
21
26
  * - For now, only applies for data conversion at the initial time.
22
- * - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
27
+ * - As of Web Worker's async nature, handling chart instance synchronously is not recommended.
28
+ * - When Worker isn't available, fails or times out, data conversion falls back to main thread.
23
29
  * - When given data is empty, useWorker will be ignored.
30
+ * @property {string} [boost.workerUrl=undefined] Use a custom static worker script URL instead of an inline Blob worker.
31
+ * - **NOTE:**
32
+ * - **Requires `boost.useWorker` to be enabled** — this option only selects where the
33
+ * worker source comes from, it does not turn offloading on by itself.
34
+ * - Useful for strict CSP environments that disallow `blob:` workers. Without it under
35
+ * such a policy, worker creation throws and each conversion waits out the 5s timeout
36
+ * before falling back, so the chart still renders but the initial draw is delayed.
37
+ * - Point it at `dist/billboard.worker.js`, shipped in the package, or any script
38
+ * implementing the same protocol: receive `{id, op, args}` and post back
39
+ * `{id, result}` or `{id, error}`. No `eval()` is involved.
40
+ * - With a bundler, make sure the file is emitted as a **real asset**, not inlined:
41
+ * it is ~1.5KB, and inlining turns it into a `data:` URI, which a strict CSP
42
+ * blocks exactly like `blob:`. Copying it into the static/public directory is the
43
+ * option that works everywhere.
44
+ * - Any failure (load error, unknown op, timeout, result mismatch) falls back to the main thread.
24
45
  * @example
46
+ * // offload data conversion on a Worker, using the inline Blob worker
25
47
  * boost: {
26
48
  * useCssRule: true,
27
- * useWorker: false
49
+ * useWorker: true
28
50
  * }
51
+ * @example
52
+ * // offload only past ~5,000 cells
53
+ * boost: {
54
+ * useWorker: "auto"
55
+ * }
56
+ * @example
57
+ * // strict CSP: serve the shipped script and point at it.
58
+ * // 'useWorker' still has to be on - 'workerUrl' alone offloads nothing.
59
+ * boost: {
60
+ * useWorker: true,
61
+ * workerUrl: "$YOUR_PATH/dist/billboard.worker.js"
62
+ * }
63
+ * @example
64
+ * // ESM: the file is reachable as a package subpath.
65
+ * // Vite - '?url' resolves it, but assets under 4KB are inlined as a 'data:' URI,
66
+ * // which a strict CSP rejects. Opt that one file out of inlining:
67
+ * //
68
+ * // // vite.config.js
69
+ * // export default {
70
+ * // build: {
71
+ * // assetsInlineLimit: path => /billboard\.worker\.js$/.test(path) ? false : undefined
72
+ * // }
73
+ * // };
74
+ * import bb, {bar} from "billboard.js";
75
+ * import workerUrl from "billboard.js/dist/billboard.worker.js?url";
76
+ *
77
+ * bb.generate({
78
+ * boost: {useWorker: true, workerUrl},
79
+ * data: {columns: [["data1", 30, 200, 100]], type: bar()}
80
+ * });
81
+ * @example
82
+ * // ESM, bundler-agnostic: copy the file into the served static directory
83
+ * // cp node_modules/billboard.js/dist/billboard.worker.js public/
84
+ * bb.generate({
85
+ * boost: {useWorker: true, workerUrl: "/billboard.worker.js"},
86
+ * data: {columns: [["data1", 30, 200, 100]]}
87
+ * });
29
88
  */
30
89
  boost_useCssRule: false,
31
- boost_useWorker: false
90
+ boost_useWorker: false,
91
+ boost_workerUrl: undefined
32
92
  };