billboard.js 3.18.0-next.1 → 3.18.0

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 (72) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +650 -199
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +10 -9
  5. package/dist/billboard.pkgd.js +2390 -1724
  6. package/dist/billboard.pkgd.min.js +22 -21
  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 +352 -36
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  11. package/dist/plugin/billboardjs-plugin-stanford.js +352 -36
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +5 -5
  13. package/dist/plugin/billboardjs-plugin-tableview.js +352 -36
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +6 -5
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +352 -36
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +4 -4
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1743 -1528
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2094 -1563
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2095 -1564
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2096 -1565
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -11
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2097 -1566
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
  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/billboard.js +889 -242
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +420 -28
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +16 -16
  44. package/src/ChartInternal/ChartInternal.ts +1 -1
  45. package/src/ChartInternal/data/convert.ts +8 -7
  46. package/src/ChartInternal/data/data.ts +38 -3
  47. package/src/ChartInternal/interactions/drag.ts +53 -42
  48. package/src/ChartInternal/interactions/zoom.ts +23 -19
  49. package/src/ChartInternal/internals/color.ts +4 -4
  50. package/src/ChartInternal/internals/domain.ts +9 -4
  51. package/src/ChartInternal/internals/format.ts +3 -3
  52. package/src/ChartInternal/internals/grid.ts +10 -10
  53. package/src/ChartInternal/internals/legend.ts +78 -17
  54. package/src/ChartInternal/internals/text.ts +37 -8
  55. package/src/ChartInternal/internals/text.util.ts +19 -0
  56. package/src/ChartInternal/internals/title.ts +3 -3
  57. package/src/ChartInternal/internals/tooltip.ts +11 -9
  58. package/src/ChartInternal/shape/arc.ts +15 -15
  59. package/src/ChartInternal/shape/bar.ts +5 -4
  60. package/src/ChartInternal/shape/funnel.ts +17 -17
  61. package/src/ChartInternal/shape/line.ts +5 -6
  62. package/src/ChartInternal/shape/point.common.ts +23 -5
  63. package/src/ChartInternal/shape/radar.ts +2 -2
  64. package/src/ChartInternal/shape/shape.ts +21 -3
  65. package/src/config/Options/axis/y2.ts +0 -13
  66. package/src/config/Options/common/legend.ts +2 -0
  67. package/src/config/Options/common/point.ts +1 -0
  68. package/src/config/Options/common/tooltip.ts +4 -1
  69. package/src/config/Store/State.ts +11 -1
  70. package/src/module/Cache.ts +26 -1
  71. package/src/module/sanitize.ts +471 -0
  72. package/src/module/util.ts +192 -131
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 3.18.0-next.1
8
+ * @version 3.18.0
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -523,6 +523,7 @@ const $ZOOM = {
523
523
  * @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
524
524
  * - **NOTE:** Should be used along with `legend.contents.template`.
525
525
  * @property {string|function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
526
+ * - **NOTE:** Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.
526
527
  * - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
527
528
  * - {=COLOR}: data color value
528
529
  * - {=TITLE}: data title value
@@ -530,6 +531,7 @@ const $ZOOM = {
530
531
  * - title {string}: data's id value
531
532
  * - color {string}: color string
532
533
  * - data {Array}: data array
534
+ * - **NOTE:** While basic XSS sanitization is applied, if you're allowing user-provided chart options in a service exposed to other users, you should implement additional security measures to prevent sophisticated XSS attacks.
533
535
  * @property {string} [legend.position=bottom] Change the position of legend.<br>
534
536
  * Available values are: `bottom`, `right` and `inset` are supported.
535
537
  * @property {object} [legend.inset={anchor: 'top-left',x: 10,y: 0,step: undefined}] Change inset legend attributes.<br>
@@ -1184,6 +1186,7 @@ const $ZOOM = {
1184
1186
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
1185
1187
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
1186
1188
  * - **Note:**
1189
+ * - Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.<br><br>
1187
1190
  * - defaultTitleFormat:
1188
1191
  * - if `axis.x.tick.format` option will be used if set.
1189
1192
  * - otherwise, will return function based on tick format type(category, timeseries).
@@ -1193,7 +1196,8 @@ const $ZOOM = {
1193
1196
  * - otherwise, will parse value and return as number.
1194
1197
  * @property {string|HTMLElement} [tooltip.contents.bindto=undefined] Set CSS selector or element reference to bind tooltip.
1195
1198
  * - **NOTE:** When is specified, will not be updating tooltip's position.
1196
- * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.<br><br>
1199
+ * @property {string} [tooltip.contents.template=undefined] Set tooltip's template.
1200
+ * - **NOTE:** Only common HTML tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.<br><br>
1197
1201
  * Within template, below syntax will be replaced using template-like syntax string:
1198
1202
  * - **{{ ... }}**: the doubly curly brackets indicate loop block for data rows.
1199
1203
  * - **{=CLASS_TOOLTIP}**: default tooltip class name `bb-tooltip`.
@@ -1202,6 +1206,7 @@ const $ZOOM = {
1202
1206
  * - **{=COLOR}**: data color.
1203
1207
  * - **{=NAME}**: data id value.
1204
1208
  * - **{=VALUE}**: data value.
1209
+ * - **NOTE:** While basic XSS sanitization is applied, if you're allowing user-provided chart options in a service exposed to other users, you should implement additional security measures to prevent sophisticated XSS attacks.
1205
1210
  * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
1206
1211
  * - **NOTE:** It should contain `{ key: Array, ... }` value
1207
1212
  * - 'key' name is used as substitution within template as '{=KEY}'
@@ -2429,6 +2434,308 @@ const [
2429
2434
  ] = getFallback(win);
2430
2435
 
2431
2436
 
2437
+ ;// ./src/module/sanitize.ts
2438
+ const ALLOWED_TAGS = /* @__PURE__ */ new Set([
2439
+ // HTML tags for tooltip/legend templates
2440
+ "span",
2441
+ "div",
2442
+ "p",
2443
+ "br",
2444
+ "b",
2445
+ "i",
2446
+ "em",
2447
+ "strong",
2448
+ "u",
2449
+ "s",
2450
+ "sub",
2451
+ "sup",
2452
+ "ul",
2453
+ "ol",
2454
+ "li",
2455
+ "dl",
2456
+ "dt",
2457
+ "dd",
2458
+ "table",
2459
+ "thead",
2460
+ "tbody",
2461
+ "tfoot",
2462
+ "tr",
2463
+ "th",
2464
+ "td",
2465
+ "caption",
2466
+ "colgroup",
2467
+ "col",
2468
+ "hr",
2469
+ "pre",
2470
+ "code",
2471
+ "blockquote",
2472
+ "a",
2473
+ "img",
2474
+ // SVG tags for point patterns
2475
+ "svg",
2476
+ "g",
2477
+ "path",
2478
+ "circle",
2479
+ "ellipse",
2480
+ "rect",
2481
+ "line",
2482
+ "polyline",
2483
+ "polygon",
2484
+ "text",
2485
+ "tspan",
2486
+ "textPath",
2487
+ "use",
2488
+ "defs",
2489
+ "symbol",
2490
+ "clipPath",
2491
+ "mask",
2492
+ "linearGradient",
2493
+ "radialGradient",
2494
+ "stop",
2495
+ "pattern",
2496
+ "marker",
2497
+ "title",
2498
+ "desc"
2499
+ ]);
2500
+ const ALLOWED_ATTRS = /* @__PURE__ */ new Set([
2501
+ // Common attributes
2502
+ "class",
2503
+ "id",
2504
+ "style",
2505
+ "title",
2506
+ "lang",
2507
+ "dir",
2508
+ // HTML specific
2509
+ "href",
2510
+ "src",
2511
+ "alt",
2512
+ "width",
2513
+ "height",
2514
+ "colspan",
2515
+ "rowspan",
2516
+ "scope",
2517
+ "headers",
2518
+ // SVG presentation attributes
2519
+ "d",
2520
+ "points",
2521
+ "x",
2522
+ "y",
2523
+ "x1",
2524
+ "x2",
2525
+ "y1",
2526
+ "y2",
2527
+ "cx",
2528
+ "cy",
2529
+ "r",
2530
+ "rx",
2531
+ "ry",
2532
+ "dx",
2533
+ "dy",
2534
+ "viewBox",
2535
+ "preserveAspectRatio",
2536
+ "transform",
2537
+ "fill",
2538
+ "fill-opacity",
2539
+ "fill-rule",
2540
+ "stroke",
2541
+ "stroke-width",
2542
+ "stroke-opacity",
2543
+ "stroke-linecap",
2544
+ "stroke-linejoin",
2545
+ "stroke-dasharray",
2546
+ "stroke-dashoffset",
2547
+ "opacity",
2548
+ "clip-path",
2549
+ "clip-rule",
2550
+ "mask",
2551
+ "font-family",
2552
+ "font-size",
2553
+ "font-weight",
2554
+ "font-style",
2555
+ "text-anchor",
2556
+ "dominant-baseline",
2557
+ "offset",
2558
+ "stop-color",
2559
+ "stop-opacity",
2560
+ "gradientUnits",
2561
+ "gradientTransform",
2562
+ "spreadMethod",
2563
+ "patternUnits",
2564
+ "patternTransform",
2565
+ "marker-start",
2566
+ "marker-mid",
2567
+ "marker-end",
2568
+ "markerWidth",
2569
+ "markerHeight",
2570
+ "refX",
2571
+ "refY",
2572
+ "xlink:href"
2573
+ ]);
2574
+ const ALLOWED_URI_PROTOCOLS = /* @__PURE__ */ new Set([
2575
+ "http:",
2576
+ "https:",
2577
+ "mailto:"
2578
+ ]);
2579
+ const URI_ATTRS = /* @__PURE__ */ new Set(["href", "src", "xlink:href"]);
2580
+ const TAG_NAME_REGEX = /^<\/?([a-zA-Z][a-zA-Z0-9]*)/;
2581
+ const CLOSING_TAG_REGEX = /^<\/([a-zA-Z][a-zA-Z0-9]*)\s*>$/;
2582
+ const OPENING_TAG_REGEX = /^<([a-zA-Z][a-zA-Z0-9]*)([\s\S]*?)(\/?)>$/;
2583
+ const ATTR_REGEX = /([a-zA-Z][\w:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/g;
2584
+ const URL_IN_STYLE_REGEX = /url\s*\(\s*["']?([^"')]+)["']?\s*\)/gi;
2585
+ const DANGEROUS_CSS_PATTERNS = [
2586
+ "expression(",
2587
+ "behavior:",
2588
+ "binding:",
2589
+ "@import",
2590
+ "@charset",
2591
+ "-moz-binding:"
2592
+ ];
2593
+ function decodeHTMLEntities(str) {
2594
+ return str.replace(/&colon;/gi, ":").replace(/&newline;/gi, "\n").replace(/&tab;/gi, " ").replace(/&nbsp;/gi, " ").replace(/&lt;/gi, "<").replace(/&gt;/gi, ">").replace(/&amp;/gi, "&").replace(/&quot;/gi, '"').replace(/&apos;/gi, "'").replace(/&#(\d+);/gi, (_, code) => String.fromCharCode(parseInt(code, 10))).replace(/&#x([0-9a-f]+);/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
2595
+ }
2596
+ function isSafeURI(uri) {
2597
+ const decoded = decodeHTMLEntities(uri).trim();
2598
+ const normalized = decoded.replace(/[\s\u0000-\u001f]/g, "").toLowerCase();
2599
+ if (!normalized || normalized.startsWith("#")) {
2600
+ return true;
2601
+ }
2602
+ if (normalized.startsWith("/") || normalized.startsWith("./") || normalized.startsWith("../") || !normalized.includes(":")) {
2603
+ return true;
2604
+ }
2605
+ const colonIndex = normalized.indexOf(":");
2606
+ if (colonIndex > 0) {
2607
+ const protocol = normalized.substring(0, colonIndex + 1);
2608
+ return ALLOWED_URI_PROTOCOLS.has(protocol);
2609
+ }
2610
+ return false;
2611
+ }
2612
+ function sanitizeStyleValue(style) {
2613
+ const decoded = decodeHTMLEntities(style);
2614
+ const cleaned = decoded.replace(/[\u0000-\u001f]/g, "");
2615
+ URL_IN_STYLE_REGEX.lastIndex = 0;
2616
+ let match;
2617
+ while ((match = URL_IN_STYLE_REGEX.exec(cleaned)) !== null) {
2618
+ if (!isSafeURI(match[1])) {
2619
+ return null;
2620
+ }
2621
+ }
2622
+ const normalizedLower = cleaned.toLowerCase().replace(/\s/g, "");
2623
+ for (const pattern of DANGEROUS_CSS_PATTERNS) {
2624
+ if (normalizedLower.includes(pattern)) {
2625
+ return null;
2626
+ }
2627
+ }
2628
+ return style;
2629
+ }
2630
+ const ATTR_ENCODE_MAP = {
2631
+ '"': "&quot;",
2632
+ "'": "&#39;",
2633
+ "`": "&#96;"
2634
+ };
2635
+ const ATTR_ENCODE_REGEX = /["'`]/g;
2636
+ function encodeAttrValue(value) {
2637
+ return value.replace(ATTR_ENCODE_REGEX, (char) => ATTR_ENCODE_MAP[char]);
2638
+ }
2639
+ function sanitizeAttrValue(name, value, wasUnquoted = false) {
2640
+ if (URI_ATTRS.has(name)) {
2641
+ if (!isSafeURI(value)) {
2642
+ return null;
2643
+ }
2644
+ return wasUnquoted ? encodeAttrValue(value) : value;
2645
+ }
2646
+ if (name === "style") {
2647
+ const sanitizedStyle = sanitizeStyleValue(value);
2648
+ if (sanitizedStyle === null) {
2649
+ return null;
2650
+ }
2651
+ return wasUnquoted ? encodeAttrValue(sanitizedStyle) : sanitizedStyle;
2652
+ }
2653
+ const decoded = decodeHTMLEntities(value).toLowerCase().replace(/\s/g, "");
2654
+ if (/\bon\w+=/.test(decoded)) {
2655
+ return null;
2656
+ }
2657
+ return wasUnquoted ? encodeAttrValue(value) : value;
2658
+ }
2659
+ function extractTagName(tag) {
2660
+ const match = tag.match(TAG_NAME_REGEX);
2661
+ return match ? match[1].toLowerCase() : null;
2662
+ }
2663
+ function isAllowedTag(tag) {
2664
+ const tagName = extractTagName(tag);
2665
+ return tagName !== null && ALLOWED_TAGS.has(tagName);
2666
+ }
2667
+ function sanitizeTag(fullTag) {
2668
+ const closingMatch = fullTag.match(CLOSING_TAG_REGEX);
2669
+ if (closingMatch) {
2670
+ return `</${closingMatch[1].toLowerCase()}>`;
2671
+ }
2672
+ const openingMatch = fullTag.match(OPENING_TAG_REGEX);
2673
+ if (!openingMatch) {
2674
+ return "";
2675
+ }
2676
+ const [, tagName, attrString, selfClose] = openingMatch;
2677
+ const lowerTagName = tagName.toLowerCase();
2678
+ const allowedAttrs = [];
2679
+ ATTR_REGEX.lastIndex = 0;
2680
+ let attrMatch;
2681
+ while ((attrMatch = ATTR_REGEX.exec(attrString)) !== null) {
2682
+ const attrName = attrMatch[1].toLowerCase();
2683
+ const doubleQuotedValue = attrMatch[2];
2684
+ const singleQuotedValue = attrMatch[3];
2685
+ const unquotedValue = attrMatch[4];
2686
+ if (attrName.startsWith("on")) {
2687
+ continue;
2688
+ }
2689
+ let attrValue;
2690
+ let quoteChar;
2691
+ if (doubleQuotedValue !== void 0) {
2692
+ attrValue = doubleQuotedValue;
2693
+ quoteChar = '"';
2694
+ } else if (singleQuotedValue !== void 0) {
2695
+ attrValue = singleQuotedValue;
2696
+ quoteChar = "'";
2697
+ } else if (unquotedValue !== void 0) {
2698
+ attrValue = unquotedValue;
2699
+ quoteChar = '"';
2700
+ } else {
2701
+ if (ALLOWED_ATTRS.has(attrName)) {
2702
+ allowedAttrs.push(attrName);
2703
+ }
2704
+ continue;
2705
+ }
2706
+ if (ALLOWED_ATTRS.has(attrName)) {
2707
+ const wasUnquoted = unquotedValue !== void 0;
2708
+ const sanitizedValue = sanitizeAttrValue(attrName, attrValue, wasUnquoted);
2709
+ if (sanitizedValue !== null) {
2710
+ allowedAttrs.push(`${attrName}=${quoteChar}${sanitizedValue}${quoteChar}`);
2711
+ }
2712
+ }
2713
+ }
2714
+ const attrsStr = allowedAttrs.length > 0 ? ` ${allowedAttrs.join(" ")}` : "";
2715
+ const selfCloseStr = selfClose ? "/>" : ">";
2716
+ return `<${lowerTagName}${attrsStr}${selfCloseStr}`;
2717
+ }
2718
+ function sanitize(str) {
2719
+ if (typeof str !== "string" || !str || str.indexOf("<") === -1) {
2720
+ return str;
2721
+ }
2722
+ return str.replace(
2723
+ /<\/?[^>]*>|[^<>\s]+>/g,
2724
+ (match) => {
2725
+ if (match.startsWith("<!--")) {
2726
+ return "";
2727
+ }
2728
+ if (!match.startsWith("<")) {
2729
+ return match.slice(0, -1) + "&gt;";
2730
+ }
2731
+ if (isAllowedTag(match)) {
2732
+ return sanitizeTag(match);
2733
+ }
2734
+ return match.replace(/</g, "&lt;");
2735
+ }
2736
+ );
2737
+ }
2738
+
2432
2739
  ;// ./src/module/util.ts
2433
2740
  var util_defProp = Object.defineProperty;
2434
2741
  var util_getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -2450,6 +2757,23 @@ var util_spreadValues = (a, b) => {
2450
2757
 
2451
2758
 
2452
2759
 
2760
+ function _getRect(relativeViewport, node, forceEval = false) {
2761
+ const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
2762
+ if (forceEval) {
2763
+ return _(node);
2764
+ } else {
2765
+ const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
2766
+ return needEvaluate ? node.rect = _(node) : node.rect;
2767
+ }
2768
+ }
2769
+ function _forEachValidItem(items, callback) {
2770
+ for (let i = 0; i < items.length; i++) {
2771
+ const item = items[i];
2772
+ if (item) {
2773
+ callback(item, i);
2774
+ }
2775
+ }
2776
+ }
2453
2777
  const isValue = (v) => v || v === 0;
2454
2778
  const isFunction = (v) => typeof v === "function";
2455
2779
  const isString = (v) => typeof v === "string";
@@ -2496,29 +2820,6 @@ function endall(transition, cb) {
2496
2820
  transition.call(end);
2497
2821
  }
2498
2822
  }
2499
- const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
2500
- const sanitizeRx = {
2501
- tags: new RegExp(
2502
- `<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
2503
- "gi"
2504
- ),
2505
- // Handles: whitespace, slash, quotes before event handlers (e.g., <img/onerror=...>, <img src="x"onerror=...>)
2506
- eventHandlers: /[\s/"']+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,
2507
- // Handles: javascript/data/vbscript URIs with optional whitespace/newlines between protocol and colon
2508
- dangerousURIs: /(href|src|action|xlink:href)\s*=\s*["']?\s*(javascript|data|vbscript)\s*:/gi
2509
- };
2510
- function sanitize(str) {
2511
- if (!isString(str) || !str || str.indexOf("<") === -1) {
2512
- return str;
2513
- }
2514
- let result = str;
2515
- let prev;
2516
- do {
2517
- prev = result;
2518
- result = result.replace(sanitizeRx.tags, "").replace(sanitizeRx.eventHandlers, "").replace(sanitizeRx.dangerousURIs, '$1=""');
2519
- } while (result !== prev);
2520
- return result;
2521
- }
2522
2823
  function setTextValue(node, text, dy = [-1, 1], toMiddle = false) {
2523
2824
  if (!node || !isString(text)) {
2524
2825
  return;
@@ -2583,20 +2884,11 @@ function getBrushSelection(ctx) {
2583
2884
  }
2584
2885
  return selection;
2585
2886
  }
2586
- function getRect(relativeViewport, node, forceEval = false) {
2587
- const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
2588
- if (forceEval) {
2589
- return _(node);
2590
- } else {
2591
- const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
2592
- return needEvaluate ? node.rect = _(node) : node.rect;
2593
- }
2594
- }
2595
2887
  function getBoundingRect(node, forceEval = false) {
2596
- return getRect(true, node, forceEval);
2888
+ return _getRect(true, node, forceEval);
2597
2889
  }
2598
2890
  function getBBox(node, forceEval = false) {
2599
- return getRect(false, node, forceEval);
2891
+ return _getRect(false, node, forceEval);
2600
2892
  }
2601
2893
  function getRandom(asStr = true, min = 0, max = 1e4) {
2602
2894
  const crpt = win.crypto || win.msCrypto;
@@ -2908,6 +3200,35 @@ function parseShorthand(value) {
2908
3200
  const [a, b = a, c = a, d = b] = values;
2909
3201
  return { top: a, right: b, bottom: c, left: d };
2910
3202
  }
3203
+ function scheduleRAFUpdate(rafState, callback) {
3204
+ if (rafState.pendingRaf !== null) {
3205
+ win.cancelAnimationFrame(rafState.pendingRaf);
3206
+ rafState.pendingRaf = win.requestAnimationFrame(() => {
3207
+ rafState.pendingRaf = null;
3208
+ callback();
3209
+ });
3210
+ } else {
3211
+ rafState.pendingRaf = win.requestAnimationFrame(() => {
3212
+ rafState.pendingRaf = null;
3213
+ });
3214
+ callback();
3215
+ }
3216
+ }
3217
+ function toSet(items, keyFn = ((item) => item)) {
3218
+ const set = /* @__PURE__ */ new Set();
3219
+ _forEachValidItem(items, (item, i) => {
3220
+ set.add(keyFn(item, i));
3221
+ });
3222
+ return set;
3223
+ }
3224
+ function toMap(items, keyFn, valueFn = ((item) => item)) {
3225
+ const map = /* @__PURE__ */ new Map();
3226
+ _forEachValidItem(items, (item, i) => {
3227
+ map.set(keyFn(item, i), valueFn(item, i));
3228
+ });
3229
+ return map;
3230
+ }
3231
+
2911
3232
 
2912
3233
  ;// ./src/config/Options/Options.ts
2913
3234
  var Options_defProp = Object.defineProperty;
@@ -3070,6 +3391,10 @@ class State {
3070
3391
  hasTreemap: false,
3071
3392
  // for data CSS rule index (used when boost.useCssRule is true)
3072
3393
  cssRule: {},
3394
+ // Data loading state (used in scale calculation)
3395
+ loading: void 0,
3396
+ // Zoom/subchart domain (different from current.domain which is for rendering)
3397
+ domain: void 0,
3073
3398
  current: {
3074
3399
  // current domain value. Assigned when is zoom is called
3075
3400
  domain: void 0,
@@ -3183,7 +3508,10 @@ class State {
3183
3508
  x2: null,
3184
3509
  y1: null,
3185
3510
  y2: null
3186
- }
3511
+ },
3512
+ // RAF batching for zoom/drag interactions
3513
+ pendingRaf: null,
3514
+ rafBatchQueue: []
3187
3515
  };
3188
3516
  }
3189
3517
  }
@@ -3217,12 +3545,18 @@ const KEY = {
3217
3545
  dataMinMax: "$dataMinMax",
3218
3546
  dataTotalSum: "$dataTotalSum",
3219
3547
  dataTotalPerIndex: "$totalPerIndex",
3548
+ domainMinMax: "$domainMinMax",
3549
+ filteredTargets: "$filteredTargets",
3550
+ filteredNullish: "$filteredNullish",
3551
+ visibilityChecksum: "visibilityChecksum",
3220
3552
  legendItemTextBox: "legendItemTextBox",
3553
+ legendItemMap: "$legendItemMap",
3221
3554
  radarPoints: "$radarPoints",
3222
3555
  radarTextWidth: "$radarTextWidth",
3223
3556
  setOverOut: "setOverOut",
3224
3557
  callOverOutForTouch: "callOverOutForTouch",
3225
- textRect: "textRect"
3558
+ textRect: "textRect",
3559
+ shapeOffset: "$shapeOffset"
3226
3560
  };
3227
3561
  class Cache {
3228
3562
  constructor() {
@@ -3269,6 +3603,23 @@ class Cache {
3269
3603
  return isValue(value) ? value : null;
3270
3604
  }
3271
3605
  }
3606
+ /**
3607
+ * Check if cache key exists
3608
+ * @param {string} key Cache key
3609
+ * @returns {boolean} True if key exists in cache
3610
+ * @private
3611
+ */
3612
+ has(key) {
3613
+ return key in this.cache && this.cache[key] !== null;
3614
+ }
3615
+ /**
3616
+ * Get all cache keys
3617
+ * @returns {string[]} Array of cache keys
3618
+ * @private
3619
+ */
3620
+ getKeys() {
3621
+ return Object.keys(this.cache);
3622
+ }
3272
3623
  /**
3273
3624
  * Reset cached data
3274
3625
  * @param {boolean} all true: reset all data, false: reset only '$' prefixed key data
@@ -3676,14 +4027,14 @@ function tsv(tsv2) {
3676
4027
 
3677
4028
 
3678
4029
 
3679
- function getDataKeyForJson(keysParam, config) {
4030
+ function _getDataKeyForJson(keysParam, config) {
3680
4031
  const keys = keysParam || (config == null ? void 0 : config.data_keys);
3681
4032
  if (keys == null ? void 0 : keys.x) {
3682
4033
  config.data_x = keys.x;
3683
4034
  }
3684
4035
  return keys;
3685
4036
  }
3686
- function setXS(ids, data, params) {
4037
+ function _setXS(ids, data, params) {
3687
4038
  const $$ = this;
3688
4039
  const { config } = $$;
3689
4040
  let xsData;
@@ -3737,13 +4088,13 @@ function setXS(ids, data, params) {
3737
4088
  data.url,
3738
4089
  data.mimeType,
3739
4090
  data.headers,
3740
- getDataKeyForJson(data.keys, config),
4091
+ _getDataKeyForJson(data.keys, config),
3741
4092
  callback
3742
4093
  );
3743
4094
  } else if (data.json) {
3744
4095
  runWorker(useWorker(data.json), json, callback, [columns, rows])(
3745
4096
  data.json,
3746
- getDataKeyForJson(data.keys, config)
4097
+ _getDataKeyForJson(data.keys, config)
3747
4098
  );
3748
4099
  } else if (data.rows) {
3749
4100
  runWorker(useWorker(data.rows), rows, callback)(data.rows);
@@ -3781,13 +4132,13 @@ function setXS(ids, data, params) {
3781
4132
  timeSeries: axis == null ? void 0 : axis.isTimeSeries(),
3782
4133
  customX: axis == null ? void 0 : axis.isCustomX()
3783
4134
  };
3784
- setXS.bind($$)(ids, data, params);
4135
+ _setXS.bind($$)(ids, data, params);
3785
4136
  const targets = ids.map((id, index) => {
3786
4137
  const convertedId = config.data_idConverter.bind($$.api)(id);
3787
4138
  const xKey = $$.getXKey(id);
3788
4139
  const isCategory = params.customX && params.categorized;
3789
4140
  const hasCategory = isCategory && (() => {
3790
- const categorySet = new Set(config.axis_x_categories);
4141
+ const categorySet = toSet(config.axis_x_categories);
3791
4142
  return data.every((v) => categorySet.has(v.x));
3792
4143
  })();
3793
4144
  const isDataAppend = data.__append__;
@@ -4220,7 +4571,23 @@ function setXS(ids, data, params) {
4220
4571
  },
4221
4572
  filterTargetsToShow(targets) {
4222
4573
  const $$ = this;
4223
- return (targets || $$.data.targets).filter((t) => $$.isTargetToShow(t.id));
4574
+ if (!targets) {
4575
+ const { cache, data, state } = $$;
4576
+ const cacheKey = KEY.filteredTargets;
4577
+ const visibilityChecksum = state.hiddenTargetIds.join(",");
4578
+ const storedChecksum = cache.get(KEY.visibilityChecksum);
4579
+ if (visibilityChecksum !== storedChecksum) {
4580
+ cache.remove(cacheKey);
4581
+ cache.add(KEY.visibilityChecksum, visibilityChecksum);
4582
+ }
4583
+ if (cache.has(cacheKey)) {
4584
+ return cache.get(cacheKey);
4585
+ }
4586
+ const filtered = data.targets.filter((t) => $$.isTargetToShow(t.id));
4587
+ cache.add(cacheKey, filtered);
4588
+ return filtered;
4589
+ }
4590
+ return targets.filter((t) => $$.isTargetToShow(t.id));
4224
4591
  },
4225
4592
  mapTargetsToUniqueXs(targets) {
4226
4593
  const $$ = this;
@@ -4279,6 +4646,7 @@ function setXS(ids, data, params) {
4279
4646
  const ys = {};
4280
4647
  const isMultipleX = $$.isMultipleX();
4281
4648
  const xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map((v) => isString(v) ? v : +v) : null;
4649
+ const xIndexMap = xs ? new Map(xs.map((x, i) => [x, i])) : null;
4282
4650
  targets.forEach((t) => {
4283
4651
  const data = [];
4284
4652
  t.values.filter(({ value }) => isValue(value) || value === null).forEach((v) => {
@@ -4293,8 +4661,12 @@ function setXS(ids, data, params) {
4293
4661
  } else if ($$.isBubbleZType(v)) {
4294
4662
  data.push(hasAxis && $$.getBubbleZData(value, "y"));
4295
4663
  } else {
4296
- if (isMultipleX) {
4297
- data[$$.getIndexByX(v.x, xs)] = value;
4664
+ if (isMultipleX && xIndexMap) {
4665
+ const xKey = isString(v.x) ? v.x : +v.x;
4666
+ const index = xIndexMap.get(xKey);
4667
+ if (index !== void 0) {
4668
+ data[index] = value;
4669
+ }
4298
4670
  } else {
4299
4671
  data.push(value);
4300
4672
  }
@@ -5174,7 +5546,7 @@ var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webp
5174
5546
 
5175
5547
 
5176
5548
 
5177
- const colorizePattern = (pattern, color, id) => {
5549
+ const _colorizePattern = (pattern, color, id) => {
5178
5550
  const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(true));
5179
5551
  node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
5180
5552
  return {
@@ -5182,7 +5554,7 @@ const colorizePattern = (pattern, color, id) => {
5182
5554
  node: node.node()
5183
5555
  };
5184
5556
  };
5185
- function getColorFromCss(element) {
5557
+ function _getColorFromCss(element) {
5186
5558
  const cacheKey = KEY.colorPattern;
5187
5559
  const { body } = browser_doc;
5188
5560
  let pattern = body[cacheKey];
@@ -5215,14 +5587,14 @@ const schemeCategory10 = [
5215
5587
  const { $el, config } = $$;
5216
5588
  const ids = [];
5217
5589
  const hasGradient = config.area_linearGradient || config.bar_linearGradient || config.point_radialGradient;
5218
- let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(getColorFromCss($el.chart) || schemeCategory10).range();
5590
+ let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(_getColorFromCss($el.chart) || schemeCategory10).range();
5219
5591
  const originalColorPattern = pattern;
5220
5592
  if (isFunction(config.color_tiles)) {
5221
5593
  const tiles = config.color_tiles.bind($$.api)();
5222
5594
  const colorizedPatterns = pattern.map((p, index) => {
5223
5595
  const color = p.replace(/[#\(\)\s,]/g, "");
5224
5596
  const id = `${$$.state.datetimeId}-pattern-${color}-${index}`;
5225
- return colorizePattern(tiles[index % tiles.length], p, id);
5597
+ return _colorizePattern(tiles[index % tiles.length], p, id);
5226
5598
  });
5227
5599
  pattern = colorizedPatterns.map((p) => `url(#${p.id})`);
5228
5600
  $$.patterns = colorizedPatterns;
@@ -5405,20 +5777,22 @@ const schemeCategory10 = [
5405
5777
  const isMin = type === "min";
5406
5778
  const dataGroups = config.data_groups;
5407
5779
  const ids = $$.mapToIds(targets);
5780
+ const idsSet = toSet(ids);
5408
5781
  const ys = $$.getValuesAsIdKeyed(targets);
5409
5782
  if (dataGroups.length > 0) {
5410
5783
  const hasValue = $$[`has${isMin ? "Negative" : "Positive"}ValueInTargets`](targets);
5784
+ const axisIdMap = new Map(ids.map((id) => [id, axis.getId(id)]));
5411
5785
  dataGroups.forEach((groupIds) => {
5412
- const idsInGroup = groupIds.filter((v) => ids.indexOf(v) >= 0);
5786
+ const idsInGroup = groupIds.filter((v) => idsSet.has(v));
5413
5787
  if (idsInGroup.length) {
5414
5788
  const baseId = idsInGroup[0];
5415
- const baseAxisId = axis.getId(baseId);
5789
+ const baseAxisId = axisIdMap.get(baseId);
5416
5790
  if (hasValue && ys[baseId]) {
5417
5791
  ys[baseId] = ys[baseId].map((v) => (isMin ? v < 0 : v > 0) ? v : 0);
5418
5792
  }
5419
5793
  idsInGroup.filter((v, i) => i > 0).forEach((id) => {
5420
5794
  if (ys[id]) {
5421
- const axisId = axis.getId(id);
5795
+ const axisId = axisIdMap.get(id);
5422
5796
  ys[id].forEach((v, i) => {
5423
5797
  const val = +v;
5424
5798
  const meetCondition = isMin ? val > 0 : val < 0;
@@ -5755,7 +6129,7 @@ const schemeCategory10 = [
5755
6129
 
5756
6130
  ;// ./src/ChartInternal/internals/format.ts
5757
6131
 
5758
- function getFormat($$, typeValue, v) {
6132
+ function _getFormat($$, typeValue, v) {
5759
6133
  const { config } = $$;
5760
6134
  const type = `axis_${typeValue}_tick_format`;
5761
6135
  const format = config[type] ? config[type] : $$.defaultValueFormat;
@@ -5763,10 +6137,10 @@ function getFormat($$, typeValue, v) {
5763
6137
  }
5764
6138
  /* harmony default export */ var format = ({
5765
6139
  yFormat(v) {
5766
- return getFormat(this, "y", v);
6140
+ return _getFormat(this, "y", v);
5767
6141
  },
5768
6142
  y2Format(v) {
5769
- return getFormat(this, "y2", v);
6143
+ return _getFormat(this, "y2", v);
5770
6144
  },
5771
6145
  /**
5772
6146
  * Get default value format function
@@ -5824,13 +6198,13 @@ function getFormat($$, typeValue, v) {
5824
6198
 
5825
6199
 
5826
6200
 
5827
- function getLegendColor(id) {
6201
+ function _getLegendColor(id) {
5828
6202
  const $$ = this;
5829
6203
  const data = $$.getDataById(id);
5830
6204
  const color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
5831
6205
  return color;
5832
6206
  }
5833
- function getFormattedText(id, formatted = true) {
6207
+ function _getFormattedText(id, formatted = true) {
5834
6208
  var _a;
5835
6209
  const { config } = this;
5836
6210
  let text = (_a = config.data_names[id]) != null ? _a : id;
@@ -5839,6 +6213,21 @@ function getFormattedText(id, formatted = true) {
5839
6213
  }
5840
6214
  return text;
5841
6215
  }
6216
+ function _buildLegendItemMap($$, legendItems) {
6217
+ if (!legendItems || legendItems.empty()) {
6218
+ return;
6219
+ }
6220
+ const items = [];
6221
+ legendItems.each(function(id) {
6222
+ items.push({ id, node: this });
6223
+ });
6224
+ const itemMap = toMap(
6225
+ items,
6226
+ (item) => item.id,
6227
+ (item) => item.node
6228
+ );
6229
+ $$.cache.add(KEY.legendItemMap, itemMap);
6230
+ }
5842
6231
  /* harmony default export */ var internals_legend = ({
5843
6232
  /**
5844
6233
  * Initialize the legend.
@@ -5997,9 +6386,13 @@ function getFormattedText(id, formatted = true) {
5997
6386
  * @private
5998
6387
  */
5999
6388
  updateLegendItemColor(id, color) {
6000
- const { legend } = this.$el;
6389
+ const $$ = this;
6390
+ const { legend } = $$.$el;
6001
6391
  if (legend) {
6002
- legend.select(`.${$LEGEND.legendItem}-${id} line`).style("stroke", color);
6392
+ const legendItem = $$.getLegendItemById(id);
6393
+ if (legendItem) {
6394
+ (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(legendItem).select("line").style("stroke", color);
6395
+ }
6003
6396
  }
6004
6397
  },
6005
6398
  /**
@@ -6200,6 +6593,24 @@ function getFormattedText(id, formatted = true) {
6200
6593
  } : null);
6201
6594
  !item.empty() && item.on("click mouseout mouseover") && item.style("cursor", $$.getStylePropValue("pointer"));
6202
6595
  }
6596
+ _buildLegendItemMap($$, item);
6597
+ },
6598
+ /**
6599
+ * Get legend item node by ID using cached Map for O(1) lookup
6600
+ * Falls back to D3 selection if map is not available
6601
+ * @param {string} id Data ID
6602
+ * @returns {HTMLElement | null} Legend item node
6603
+ * @private
6604
+ */
6605
+ getLegendItemById(id) {
6606
+ var _a;
6607
+ const $$ = this;
6608
+ const itemMap = $$.cache.get(KEY.legendItemMap);
6609
+ if (itemMap && itemMap instanceof Map) {
6610
+ return itemMap.get(id) || null;
6611
+ }
6612
+ const item = (_a = $$.$el.legend) == null ? void 0 : _a.selectAll(`.${$LEGEND.legendItem}`).filter((d) => d === id);
6613
+ return (item == null ? void 0 : item.node()) || null;
6203
6614
  },
6204
6615
  /**
6205
6616
  * Update the legend
@@ -6273,9 +6684,9 @@ function getFormattedText(id, formatted = true) {
6273
6684
  background = legend.insert("g", `.${$LEGEND.legendItem}`).attr("class", $LEGEND.legendBackground).append("rect");
6274
6685
  }
6275
6686
  if (config.legend_tooltip) {
6276
- legend.selectAll("title").data(targetIdz).text((id) => getFormattedText.bind($$)(id, false));
6687
+ legend.selectAll("title").data(targetIdz).text((id) => _getFormattedText.bind($$)(id, false));
6277
6688
  }
6278
- const texts = legend.selectAll("text").data(targetIdz).text((id) => getFormattedText.bind($$)(id)).each(function(id, i) {
6689
+ const texts = legend.selectAll("text").data(targetIdz).text((id) => _getFormattedText.bind($$)(id)).each(function(id, i) {
6279
6690
  updatePositions(this, id, i);
6280
6691
  });
6281
6692
  $T(texts, withTransition).attr("x", posFn.xText).attr("y", posFn.yText);
@@ -6386,14 +6797,14 @@ function getFormattedText(id, formatted = true) {
6386
6797
  if (config.legend_tooltip) {
6387
6798
  l.append("title").text((id) => id);
6388
6799
  }
6389
- l.append("text").text((id) => getFormattedText.bind($$)(id)).each(function(id, i) {
6800
+ l.append("text").text((id) => _getFormattedText.bind($$)(id)).each(function(id, i) {
6390
6801
  updatePositions(this, id, i);
6391
6802
  }).style("pointer-events", $$.getStylePropValue("none")).attr("x", isLegendRightOrInset ? posFn.xText : pos).attr("y", isLegendRightOrInset ? pos : posFn.yText);
6392
6803
  l.append("rect").attr("class", $LEGEND.legendItemEvent).style("fill-opacity", $$.getStylePropValue("0")).attr("x", isLegendRightOrInset ? posFn.xRect : pos).attr("y", isLegendRightOrInset ? pos : posFn.yRect);
6393
6804
  if (usePoint) {
6394
6805
  const ids = [];
6806
+ const pattern = $$.getValidPointPattern();
6395
6807
  l.append((d) => {
6396
- const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
6397
6808
  ids.indexOf(d) === -1 && ids.push(d);
6398
6809
  let point = pattern[ids.indexOf(d) % pattern.length];
6399
6810
  if (point === "rectangle") {
@@ -6403,16 +6814,16 @@ function getFormattedText(id, formatted = true) {
6403
6814
  external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg,
6404
6815
  "hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use"
6405
6816
  );
6406
- }).attr("class", $LEGEND.legendItemPoint).style("fill", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).attr("href", (data, idx, selection) => {
6817
+ }).attr("class", $LEGEND.legendItemPoint).style("fill", _getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).attr("href", (data, idx, selection) => {
6407
6818
  const node = selection[idx];
6408
6819
  const nodeName = node.nodeName.toLowerCase();
6409
6820
  const id = $$.getTargetSelectorSuffix(data);
6410
6821
  return nodeName === "use" ? `#${state.datetimeId}-point${id}` : void 0;
6411
6822
  });
6412
6823
  } else {
6413
- l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke", getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).call((selection) => {
6824
+ l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke", _getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).call((selection) => {
6414
6825
  if (legendType === "circle") {
6415
- selection.attr("r", legendItemR).style("fill", getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos).attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
6826
+ selection.attr("r", legendItemR).style("fill", _getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos).attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
6416
6827
  } else if (isRectangle) {
6417
6828
  selection.attr("stroke-width", itemTileSize.height).attr("x1", isLegendRightOrInset ? posFn.x1Tile : pos).attr("y1", isLegendRightOrInset ? pos : posFn.yTile).attr("x2", isLegendRightOrInset ? posFn.x2Tile : pos).attr("y2", isLegendRightOrInset ? pos : posFn.yTile);
6418
6829
  }
@@ -6461,7 +6872,7 @@ function getFormattedText(id, formatted = true) {
6461
6872
  });
6462
6873
  } else {
6463
6874
  const tiles = legend.selectAll(`.${$LEGEND.legendItemTile}`).data(targetIdz);
6464
- $T(tiles, withTransition).style("stroke", getLegendColor.bind($$)).call((selection) => {
6875
+ $T(tiles, withTransition).style("stroke", _getLegendColor.bind($$)).call((selection) => {
6465
6876
  if (legendType === "circle") {
6466
6877
  selection.attr("cx", (d) => {
6467
6878
  const x2 = posFn.x2Tile(d);
@@ -7366,6 +7777,13 @@ function updateTextImagePos(textNode, pos) {
7366
7777
  $$.$T(image).style("opacity", isShown(textNode) ? null : "0").attr("x", x).attr("y", y);
7367
7778
  }
7368
7779
  }
7780
+ function batchGetBBox(elements) {
7781
+ return toMap(
7782
+ elements,
7783
+ (element) => element,
7784
+ (element) => getBBox(element)
7785
+ );
7786
+ }
7369
7787
 
7370
7788
 
7371
7789
  ;// ./src/ChartInternal/internals/text.ts
@@ -7519,10 +7937,23 @@ function updateTextImagePos(textNode, pos) {
7519
7937
  const angle = config.data_labels.rotate;
7520
7938
  const anchorString = getRotateAnchor(angle);
7521
7939
  const rotateString = angle ? `rotate(${angle})` : "";
7940
+ let bboxCache = /* @__PURE__ */ new Map();
7941
+ if (config.data_labels.centered) {
7942
+ const elementsToMeasure = [];
7943
+ $$.$el.text.each(function(d) {
7944
+ if ($$.isBarType(d) || $$.isTreemapType(d)) {
7945
+ elementsToMeasure.push(this);
7946
+ }
7947
+ });
7948
+ if (elementsToMeasure.length > 0) {
7949
+ bboxCache = batchGetBBox(elementsToMeasure);
7950
+ }
7951
+ }
7522
7952
  $$.$el.text.style("fill", $$.getStylePropValue($$.updateTextColor)).attr(
7523
7953
  "filter",
7524
7954
  (d) => $$.updateTextBGColor.bind($$)(d, config.data_labels_backgroundColors)
7525
7955
  ).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function(d, i) {
7956
+ const cachedBbox = bboxCache.get(this);
7526
7957
  const node = $T(
7527
7958
  hasTreemap && this.childElementCount ? this.parentNode : this,
7528
7959
  !!(withTransition && (this.getAttribute("x") || this.getAttribute("transform"))),
@@ -7530,8 +7961,8 @@ function updateTextImagePos(textNode, pos) {
7530
7961
  );
7531
7962
  const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
7532
7963
  let pos = {
7533
- x: getX.bind(this)(d, i),
7534
- y: getY.bind(this)(d, i)
7964
+ x: getX.bind(this)(d, i, cachedBbox),
7965
+ y: getY.bind(this)(d, i, cachedBbox)
7535
7966
  };
7536
7967
  if (angle) {
7537
7968
  pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
@@ -7609,17 +8040,18 @@ function updateTextImagePos(textNode, pos) {
7609
8040
  * @param {Array} points Data points position
7610
8041
  * @param {HTMLElement} textElement Data label text element
7611
8042
  * @param {string} type 'x' or 'y'
8043
+ * @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
7612
8044
  * @returns {number} Position value
7613
8045
  * @private
7614
8046
  */
7615
- getCenteredTextPos(d, points, textElement, type) {
8047
+ getCenteredTextPos(d, points, textElement, type, cachedBbox) {
7616
8048
  const $$ = this;
7617
8049
  const { config } = $$;
7618
8050
  const isRotated = config.axis_rotated;
7619
8051
  const isBarType = $$.isBarType(d);
7620
8052
  const isTreemapType = $$.isTreemapType(d);
7621
8053
  if (config.data_labels.centered && (isBarType || isTreemapType)) {
7622
- const rect = getBBox(textElement);
8054
+ const rect = cachedBbox || getBBox(textElement);
7623
8055
  if (isBarType) {
7624
8056
  const isPositive = $$.getRangedData(d, null, "bar") >= 0;
7625
8057
  if (isRotated) {
@@ -7643,10 +8075,11 @@ function updateTextImagePos(textNode, pos) {
7643
8075
  * @param {object} points Data points position
7644
8076
  * @param {object} d Data object
7645
8077
  * @param {HTMLElement} textElement Data label text element
8078
+ * @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
7646
8079
  * @returns {number} x coordinate
7647
8080
  * @private
7648
8081
  */
7649
- getXForText(points, d, textElement) {
8082
+ getXForText(points, d, textElement, cachedBbox) {
7650
8083
  var _a;
7651
8084
  const $$ = this;
7652
8085
  const { config } = $$;
@@ -7680,7 +8113,7 @@ function updateTextImagePos(textNode, pos) {
7680
8113
  }
7681
8114
  }
7682
8115
  if (isRotated || isTreemapType) {
7683
- xPos += $$.getCenteredTextPos(d, points, textElement, "x");
8116
+ xPos += $$.getCenteredTextPos(d, points, textElement, "x", cachedBbox);
7684
8117
  }
7685
8118
  return xPos + getTextPos.call(this, d, "x");
7686
8119
  },
@@ -7689,10 +8122,11 @@ function updateTextImagePos(textNode, pos) {
7689
8122
  * @param {object} points Data points position
7690
8123
  * @param {object} d Data object
7691
8124
  * @param {HTMLElement} textElement Data label text element
8125
+ * @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
7692
8126
  * @returns {number} y coordinate
7693
8127
  * @private
7694
8128
  */
7695
- getYForText(points, d, textElement) {
8129
+ getYForText(points, d, textElement, cachedBbox) {
7696
8130
  const $$ = this;
7697
8131
  const { axis, config, state } = $$;
7698
8132
  const isRotated = config.axis_rotated;
@@ -7745,7 +8179,7 @@ function updateTextImagePos(textNode, pos) {
7745
8179
  }
7746
8180
  }
7747
8181
  if (!isRotated || isTreemapType) {
7748
- yPos += $$.getCenteredTextPos(d, points, textElement, "y");
8182
+ yPos += $$.getCenteredTextPos(d, points, textElement, "y", cachedBbox);
7749
8183
  }
7750
8184
  return yPos + getTextPos.call(this, d, "y");
7751
8185
  },
@@ -7789,7 +8223,7 @@ function updateTextImagePos(textNode, pos) {
7789
8223
  ;// ./src/ChartInternal/internals/title.ts
7790
8224
 
7791
8225
 
7792
- function getTextXPos(pos = "left", width) {
8226
+ function _getTextXPos(pos = "left", width) {
7793
8227
  const isNum = isNumber(width);
7794
8228
  let position;
7795
8229
  if (pos.indexOf("center") > -1) {
@@ -7811,7 +8245,7 @@ function getTextXPos(pos = "left", width) {
7811
8245
  const { config, $el } = $$;
7812
8246
  if (config.title_text) {
7813
8247
  $el.title = $el.svg.append("g");
7814
- const text = $el.title.append("text").style("text-anchor", getTextXPos(config.title_position)).attr("class", $TEXT.title);
8248
+ const text = $el.title.append("text").style("text-anchor", _getTextXPos(config.title_position)).attr("class", $TEXT.title);
7815
8249
  setTextValue(text, config.title_text, [0.3, 1.5]);
7816
8250
  }
7817
8251
  },
@@ -7823,7 +8257,7 @@ function getTextXPos(pos = "left", width) {
7823
8257
  const $$ = this;
7824
8258
  const { config, state: { current }, $el: { title } } = $$;
7825
8259
  if (title) {
7826
- const x = getTextXPos(config.title_position, current.width);
8260
+ const x = _getTextXPos(config.title_position, current.width);
7827
8261
  const y = (config.title_padding.top || 0) + $$.getTextRect($$.$el.title, $TEXT.title).height;
7828
8262
  title.attr("transform", `translate(${x}, ${y})`);
7829
8263
  }
@@ -7894,7 +8328,9 @@ function getTextXPos(pos = "left", width) {
7894
8328
  getTooltipHTML(...args) {
7895
8329
  const $$ = this;
7896
8330
  const { api, config } = $$;
7897
- return isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api)(...args) : $$.getTooltipContent(...args);
8331
+ return sanitize(
8332
+ isFunction(config.tooltip_contents) ? config.tooltip_contents.bind(api)(...args) : $$.getTooltipContent(...args)
8333
+ );
7898
8334
  },
7899
8335
  /**
7900
8336
  * Returns the tooltip content(HTML string)
@@ -7913,8 +8349,8 @@ function getTextXPos(pos = "left", width) {
7913
8349
  const fn = config[`tooltip_format_${v}`];
7914
8350
  return isFunction(fn) ? fn.bind(api) : fn;
7915
8351
  });
7916
- const titleFormat = (...arg) => sanitize((titleFn || defaultTitleFormat)(...arg));
7917
- const nameFormat = (...arg) => sanitize((nameFn || ((name) => name))(...arg));
8352
+ const titleFormat = (...arg) => (titleFn || defaultTitleFormat)(...arg);
8353
+ const nameFormat = (...arg) => (nameFn || ((name) => name))(...arg);
7918
8354
  const valueFormat = (v, ratio, id, index) => {
7919
8355
  let fn = valueFn;
7920
8356
  if (!fn) {
@@ -7924,7 +8360,7 @@ function getTextXPos(pos = "left", width) {
7924
8360
  fn = defaultValueFormat;
7925
8361
  }
7926
8362
  }
7927
- return sanitize(fn(v, ratio, id, index));
8363
+ return fn(v, ratio, id, index);
7928
8364
  };
7929
8365
  const order = config.tooltip_order;
7930
8366
  const getRowValue = (row2) => $$.axis && $$.isBubbleZType(row2) ? $$.getBubbleZData(row2.value, "z") : $$.getBaseValue(row2);
@@ -8210,7 +8646,7 @@ function getTextXPos(pos = "left", width) {
8210
8646
  if (!datum || datum.current !== dataStr) {
8211
8647
  const { index, x } = selectedData.concat().sort()[0];
8212
8648
  callFn(config.tooltip_onshow, $$.api, selectedData);
8213
- tooltip.html(sanitize($$.getTooltipHTML(
8649
+ tooltip.html($$.getTooltipHTML(
8214
8650
  selectedData,
8215
8651
  // data
8216
8652
  $$.axis ? $$.axis.getXAxisTickFormat() : $$.categoryName.bind($$),
@@ -8219,7 +8655,7 @@ function getTextXPos(pos = "left", width) {
8219
8655
  // defaultValueFormat
8220
8656
  $$.color
8221
8657
  // color
8222
- ))).style("display", null).style("visibility", null).datum(datum = {
8658
+ )).style("display", null).style("visibility", null).datum(datum = {
8223
8659
  index,
8224
8660
  x,
8225
8661
  current: dataStr,
@@ -8647,7 +9083,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8647
9083
 
8648
9084
 
8649
9085
 
8650
- function getGroupedDataPointsFn(d) {
9086
+
9087
+ function _getGroupedDataPointsFn(d) {
8651
9088
  const $$ = this;
8652
9089
  let fn;
8653
9090
  if ($$.isLineType(d)) {
@@ -8859,6 +9296,12 @@ function getGroupedDataPointsFn(d) {
8859
9296
  const targets = $$.orderTargets(
8860
9297
  $$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
8861
9298
  );
9299
+ const targetIds = targets.map((t) => t.id).join("_");
9300
+ const cacheKey = `${KEY.shapeOffset}_${targetIds}`;
9301
+ const cachedData = $$.cache.get(cacheKey);
9302
+ if (cachedData) {
9303
+ return cachedData;
9304
+ }
8862
9305
  const isStackNormalized = $$.isStackNormalized();
8863
9306
  const shapeOffsetTargets = targets.map((target) => {
8864
9307
  let rowValues = target.values;
@@ -8883,7 +9326,9 @@ function getGroupedDataPointsFn(d) {
8883
9326
  out[id] = index;
8884
9327
  return out;
8885
9328
  }, {});
8886
- return { indexMapByTargetId, shapeOffsetTargets };
9329
+ const result = { indexMapByTargetId, shapeOffsetTargets };
9330
+ $$.cache.add(cacheKey, result);
9331
+ return result;
8887
9332
  },
8888
9333
  getShapeOffset(typeFilter, indices, isSub) {
8889
9334
  const $$ = this;
@@ -8937,7 +9382,7 @@ function getGroupedDataPointsFn(d) {
8937
9382
  const id = d.id;
8938
9383
  let points;
8939
9384
  if ($$.isGrouped(id)) {
8940
- points = getGroupedDataPointsFn.bind($$)(d);
9385
+ points = _getGroupedDataPointsFn.bind($$)(d);
8941
9386
  }
8942
9387
  return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
8943
9388
  },
@@ -9362,7 +9807,7 @@ class ChartInternal {
9362
9807
  if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
9363
9808
  $el.defs = $el.svg.append("defs");
9364
9809
  if (hasAxis) {
9365
- ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
9810
+ ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
9366
9811
  $$.appendClip($el.defs, state.clip[v]);
9367
9812
  });
9368
9813
  }
@@ -11624,9 +12069,6 @@ extend(zoom, {
11624
12069
  external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.translate(tX, tY).scale(transform.k)
11625
12070
  );
11626
12071
  }
11627
- if (!$$.state.xTickOffset) {
11628
- $$.state.xTickOffset = $$.axis.x.tickOffset();
11629
- }
11630
12072
  scale.zoom = $$.getCustomizedXScale(newScale);
11631
12073
  $$.axis.x.scale(scale.zoom);
11632
12074
  if (rescale) {
@@ -11667,7 +12109,6 @@ extend(zoom, {
11667
12109
  * @private
11668
12110
  */
11669
12111
  onZoom(event) {
11670
- var _a;
11671
12112
  const $$ = this;
11672
12113
  const { config, scale, state, org } = $$;
11673
12114
  const { sourceEvent } = event;
@@ -11687,19 +12128,24 @@ extend(zoom, {
11687
12128
  }
11688
12129
  $$.zoom.updateTransformScale(transform, config.zoom_type === "wheel" && sourceEvent);
11689
12130
  const doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
11690
- $$.redraw({
11691
- withTransition: doTransition,
11692
- withY: config.zoom_rescale,
11693
- withSubchart: false,
11694
- withEventRect: false,
11695
- withDimension: false
11696
- });
11697
- $$.state.cancelClick = isMousemove;
11698
- !isUnZoom && callFn(
11699
- config.zoom_onzoom,
11700
- $$.api,
11701
- (_a = $$.state.domain) != null ? _a : $$.zoom.getDomain()
11702
- );
12131
+ const useRAF = sourceEvent && isMousemove && config.zoom_type !== "wheel";
12132
+ const executeRedraw = () => {
12133
+ var _a;
12134
+ $$.redraw({
12135
+ withTransition: doTransition,
12136
+ withY: config.zoom_rescale,
12137
+ withSubchart: false,
12138
+ withEventRect: false,
12139
+ withDimension: false
12140
+ });
12141
+ $$.state.cancelClick = isMousemove;
12142
+ !isUnZoom && callFn(
12143
+ config.zoom_onzoom,
12144
+ $$.api,
12145
+ (_a = $$.state.domain) != null ? _a : $$.zoom.getDomain()
12146
+ );
12147
+ };
12148
+ useRAF ? scheduleRAFUpdate($$.state, executeRedraw) : executeRedraw();
11703
12149
  },
11704
12150
  /**
11705
12151
  * 'end' event listener
@@ -11892,31 +12338,37 @@ extend(zoom, {
11892
12338
  const maxX = Math.max(sx, mx);
11893
12339
  const minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my);
11894
12340
  const maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
11895
- main.select(`.${$DRAG.dragarea}`).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY);
11896
- main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).filter((d) => isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)).each(function(d, i) {
11897
- const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
11898
- const isSelected = shape.classed($SELECT.SELECTED);
11899
- const isIncluded = shape.classed($DRAG.INCLUDED);
11900
- let isWithin = false;
11901
- let toggle;
11902
- if (shape.classed($CIRCLE.circle)) {
11903
- const x = +shape.attr("cx") * 1;
11904
- const y = +shape.attr("cy") * 1;
11905
- toggle = $$.togglePoint;
11906
- isWithin = minX < x && x < maxX && minY < y && y < maxY;
11907
- } else if (shape.classed($BAR.bar)) {
11908
- const { x, y, width, height } = getPathBox(this);
11909
- toggle = $$.togglePath;
11910
- isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
11911
- } else {
12341
+ const executeDrag = () => {
12342
+ if (!$$ || !$$.$el || !$$.$el.main) {
11912
12343
  return;
11913
12344
  }
11914
- if (isWithin ^ isIncluded) {
11915
- shape.classed($DRAG.INCLUDED, !isIncluded);
11916
- shape.classed($SELECT.SELECTED, !isSelected);
11917
- toggle.call($$, !isSelected, shape, d, i);
11918
- }
11919
- });
12345
+ main.select(`.${$DRAG.dragarea}`).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY);
12346
+ main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).filter((d) => isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)).each(function(d, i) {
12347
+ const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
12348
+ const isSelected = shape.classed($SELECT.SELECTED);
12349
+ const isIncluded = shape.classed($DRAG.INCLUDED);
12350
+ let isWithin = false;
12351
+ let toggle;
12352
+ if (shape.classed($CIRCLE.circle)) {
12353
+ const x = +shape.attr("cx") * 1;
12354
+ const y = +shape.attr("cy") * 1;
12355
+ toggle = $$.togglePoint;
12356
+ isWithin = minX < x && x < maxX && minY < y && y < maxY;
12357
+ } else if (shape.classed($BAR.bar)) {
12358
+ const { x, y, width, height } = getPathBox(this);
12359
+ toggle = $$.togglePath;
12360
+ isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
12361
+ } else {
12362
+ return;
12363
+ }
12364
+ if (isWithin ^ isIncluded) {
12365
+ shape.classed($DRAG.INCLUDED, !isIncluded);
12366
+ shape.classed($SELECT.SELECTED, !isSelected);
12367
+ toggle.call($$, !isSelected, shape, d, i);
12368
+ }
12369
+ });
12370
+ };
12371
+ scheduleRAFUpdate($$.state, executeDrag);
11920
12372
  },
11921
12373
  /**
11922
12374
  * Called when the drag starts.
@@ -15275,9 +15727,9 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15275
15727
 
15276
15728
 
15277
15729
 
15278
- const getGridTextAnchor = (d) => isValue(d.position) || "end";
15279
- const getGridTextDx = (d) => d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
15280
- function getGridTextX(isX, width, height) {
15730
+ const _getGridTextAnchor = (d) => isValue(d.position) || "end";
15731
+ const _getGridTextDx = (d) => d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
15732
+ function _getGridTextX(isX, width, height) {
15281
15733
  return (d) => {
15282
15734
  let x = isX ? 0 : width;
15283
15735
  if (d.position === "start") {
@@ -15288,7 +15740,7 @@ function getGridTextX(isX, width, height) {
15288
15740
  return x;
15289
15741
  };
15290
15742
  }
15291
- function smoothLines(el, type) {
15743
+ function _smoothLines(el, type) {
15292
15744
  if (type === "grid") {
15293
15745
  el.each(function() {
15294
15746
  const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
@@ -15359,7 +15811,7 @@ function smoothLines(el, type) {
15359
15811
  grid.y.exit().remove();
15360
15812
  grid.y = grid.y.enter().append("line").attr("class", $GRID.ygrid).merge(grid.y);
15361
15813
  grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos);
15362
- smoothLines(grid.y, "grid");
15814
+ _smoothLines(grid.y, "grid");
15363
15815
  },
15364
15816
  updateGrid() {
15365
15817
  const $$ = this;
@@ -15392,10 +15844,10 @@ function smoothLines(el, type) {
15392
15844
  g.append("text").style("opacity", "0");
15393
15845
  }
15394
15846
  });
15395
- $T(lines.attr("class", (d) => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim()).select("text").attr("text-anchor", getGridTextAnchor).attr(
15847
+ $T(lines.attr("class", (d) => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim()).select("text").attr("text-anchor", _getGridTextAnchor).attr(
15396
15848
  "transform",
15397
15849
  () => isX ? isRotated ? null : "rotate(-90)" : isRotated ? "rotate(-90)" : null
15398
- ).attr("dx", getGridTextDx).attr("dy", -5)).text(function(d) {
15850
+ ).attr("dx", _getGridTextDx).attr("dy", -5)).text(function(d) {
15399
15851
  var _a;
15400
15852
  return (_a = d.text) != null ? _a : this.remove();
15401
15853
  });
@@ -15416,9 +15868,9 @@ function smoothLines(el, type) {
15416
15868
  let yLines = gridLines.y.select("line");
15417
15869
  let yTexts = gridLines.y.select("text");
15418
15870
  xLines = $T(xLines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
15419
- xTexts = $T(xTexts, withTransition).attr("x", getGridTextX(!isRotated, width, height)).attr("y", xv);
15871
+ xTexts = $T(xTexts, withTransition).attr("x", _getGridTextX(!isRotated, width, height)).attr("y", xv);
15420
15872
  yLines = $T(yLines, withTransition).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv);
15421
- yTexts = $T(yTexts, withTransition).attr("x", getGridTextX(isRotated, width, height)).attr("y", yv);
15873
+ yTexts = $T(yTexts, withTransition).attr("x", _getGridTextX(isRotated, width, height)).attr("y", yv);
15422
15874
  return [
15423
15875
  xLines.style("opacity", null),
15424
15876
  xTexts.style("opacity", null),
@@ -15545,7 +15997,7 @@ function smoothLines(el, type) {
15545
15997
  }
15546
15998
  ["x1", "y1", "x2", "y2"].forEach((v, i) => el.attr(v, xy[i]));
15547
15999
  });
15548
- smoothLines(focusEl, "grid");
16000
+ _smoothLines(focusEl, "grid");
15549
16001
  (_a = $$.showCircleFocus) == null ? void 0 : _a.call($$, data);
15550
16002
  },
15551
16003
  hideGridFocus() {
@@ -17126,18 +17578,6 @@ function smoothLines(el, type) {
17126
17578
 
17127
17579
  ;// ./src/config/Options/axis/y2.ts
17128
17580
  /* harmony default export */ var y2 = ({
17129
- /**
17130
- * Set clip-path attribute for y2 axis element
17131
- * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
17132
- * @name axis․y2․clipPath
17133
- * @memberof Options
17134
- * @type {boolean}
17135
- * @default true
17136
- * @example
17137
- * // don't set 'clip-path' attribute
17138
- * clipPath: false
17139
- */
17140
- axis_y2_clipPath: true,
17141
17581
  /**
17142
17582
  * Show or hide y2 axis.
17143
17583
  * - **NOTE**:
@@ -18188,10 +18628,10 @@ var arc_spreadProps = (a, b) => arc_defProps(a, arc_getOwnPropDescs(b));
18188
18628
 
18189
18629
 
18190
18630
 
18191
- function arc_getArcType($$) {
18631
+ function _getArcType($$) {
18192
18632
  return ["donut", "pie", "polar", "gauge"].find((type) => $$.hasType(type));
18193
18633
  }
18194
- function calculateRangeOrGaugePosition($$, d, updated, forRange) {
18634
+ function _calculateRangeOrGaugePosition($$, d, updated, forRange) {
18195
18635
  var _a, _b;
18196
18636
  const { config, state: { radiusExpanded } } = $$;
18197
18637
  const angle = updated.endAngle - Math.PI / 2;
@@ -18213,9 +18653,9 @@ function calculateRangeOrGaugePosition($$, d, updated, forRange) {
18213
18653
  }
18214
18654
  return pos;
18215
18655
  }
18216
- function calculateLabelRatio($$, d, outerRadius, distance) {
18656
+ function _calculateLabelRatio($$, d, outerRadius, distance) {
18217
18657
  const { config } = $$;
18218
- const chartType = arc_getArcType($$);
18658
+ const chartType = _getArcType($$);
18219
18659
  let ratio = chartType ? config[`${chartType}_label_ratio`] : void 0;
18220
18660
  if (ratio) {
18221
18661
  ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, distance) : ratio;
@@ -18230,20 +18670,20 @@ function calculateLabelRatio($$, d, outerRadius, distance) {
18230
18670
  }
18231
18671
  return ratio;
18232
18672
  }
18233
- function calculateStandardArcPosition($$, d, updated) {
18673
+ function _calculateStandardArcPosition($$, d, updated) {
18234
18674
  let { outerRadius } = $$.getRadius(d);
18235
18675
  if ($$.hasType("polar")) {
18236
18676
  outerRadius = $$.getPolarOuterRadius(d, outerRadius);
18237
18677
  }
18238
18678
  const [x, y] = $$.svgArc.centroid(updated).map((v) => isNaN(v) ? 0 : v);
18239
18679
  const distance = Math.sqrt(x * x + y * y);
18240
- const ratio = calculateLabelRatio($$, d, outerRadius, distance);
18680
+ const ratio = _calculateLabelRatio($$, d, outerRadius, distance);
18241
18681
  return {
18242
18682
  pos: { x, y },
18243
18683
  ratio
18244
18684
  };
18245
18685
  }
18246
- function getRadiusFn(expandRate = 0) {
18686
+ function _getRadiusFn(expandRate = 0) {
18247
18687
  const $$ = this;
18248
18688
  const { config, state } = $$;
18249
18689
  const hasMultiArcGauge = $$.hasMultiArcGauge();
@@ -18311,7 +18751,7 @@ function getRadiusFn(expandRate = 0) {
18311
18751
  }
18312
18752
  };
18313
18753
  }
18314
- function getAttrTweenFn(fn) {
18754
+ function _getAttrTweenFn(fn) {
18315
18755
  return function(d) {
18316
18756
  const getAngleKeyValue = ({ startAngle = 0, endAngle = 0, padAngle = 0 }) => ({
18317
18757
  startAngle,
@@ -18470,7 +18910,7 @@ function getAttrTweenFn(fn) {
18470
18910
  },
18471
18911
  getSvgArc() {
18472
18912
  const $$ = this;
18473
- const { inner, outer, corner } = getRadiusFn.call($$);
18913
+ const { inner, outer, corner } = _getRadiusFn.call($$);
18474
18914
  const arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
18475
18915
  const newArc = function(d, withoutUpdate) {
18476
18916
  var _a;
@@ -18496,7 +18936,7 @@ function getAttrTweenFn(fn) {
18496
18936
  */
18497
18937
  getSvgArcExpanded(rate = 1) {
18498
18938
  const $$ = this;
18499
- const { inner, outer, corner } = getRadiusFn.call($$, rate);
18939
+ const { inner, outer, corner } = _getRadiusFn.call($$, rate);
18500
18940
  const arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
18501
18941
  return (d) => {
18502
18942
  const updated = $$.updateAngle(d);
@@ -18562,9 +19002,9 @@ function getAttrTweenFn(fn) {
18562
19002
  let pos;
18563
19003
  let ratio = 1;
18564
19004
  if (forRange || $$.hasMultiArcGauge()) {
18565
- pos = calculateRangeOrGaugePosition($$, d, updated, forRange);
19005
+ pos = _calculateRangeOrGaugePosition($$, d, updated, forRange);
18566
19006
  } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
18567
- const result = calculateStandardArcPosition($$, d, updated);
19007
+ const result = _calculateStandardArcPosition($$, d, updated);
18568
19008
  pos = result.pos;
18569
19009
  ratio = result.ratio;
18570
19010
  } else {
@@ -18624,7 +19064,7 @@ function getAttrTweenFn(fn) {
18624
19064
  const svgArcExpandedSub = $$.getSvgArcExpanded(
18625
19065
  $$.getExpandConfig(d.data.id, "rate")
18626
19066
  );
18627
- (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$))).transition().duration(expandDuration * 2).attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
19067
+ (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d", _getAttrTweenFn($$.svgArcExpanded.bind($$))).transition().duration(expandDuration * 2).attrTween("d", _getAttrTweenFn(svgArcExpandedSub.bind($$)));
18628
19068
  });
18629
19069
  },
18630
19070
  unexpandArc(targetIds) {
@@ -18634,7 +19074,7 @@ function getAttrTweenFn(fn) {
18634
19074
  return;
18635
19075
  }
18636
19076
  const newTargetIds = $$.mapToTargetIds(targetIds);
18637
- svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`)).selectAll("path").transition().duration((d) => $$.getExpandConfig(d.data.id, "duration")).attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
19077
+ svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`)).selectAll("path").transition().duration((d) => $$.getExpandConfig(d.data.id, "duration")).attrTween("d", _getAttrTweenFn($$.svgArc.bind($$)));
18638
19078
  svg.selectAll(`${$ARC.arc}`).style("opacity", null);
18639
19079
  },
18640
19080
  /**
@@ -19193,7 +19633,7 @@ function getAttrTweenFn(fn) {
19193
19633
 
19194
19634
 
19195
19635
 
19196
- function getConnectLineType(id) {
19636
+ function _getConnectLineType(id) {
19197
19637
  const connectLine = this.config.bar_connectLine;
19198
19638
  const type = (connectLine == null ? void 0 : connectLine[id]) || connectLine;
19199
19639
  return /^(start|end)\-(start|end)$/.test(type) ? type : null;
@@ -19226,7 +19666,7 @@ function getConnectLineType(id) {
19226
19666
  }).call((selection) => {
19227
19667
  $$.setCssRule(true, ` .${$BAR.bar}`, ["fill"], $$.color)(selection);
19228
19668
  selection.each(function(d) {
19229
- if (getConnectLineType.call($$, d.id)) {
19669
+ if (_getConnectLineType.call($$, d.id)) {
19230
19670
  (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).append("path").attr("class", $BAR.barConnectLine);
19231
19671
  }
19232
19672
  });
@@ -19276,7 +19716,7 @@ function getConnectLineType(id) {
19276
19716
  return [
19277
19717
  $$.$T(bar, withTransition, getRandom()).attr("d", function(d, i, arr) {
19278
19718
  const path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
19279
- const connectLineType = getConnectLineType.call($$, d.id);
19719
+ const connectLineType = _getConnectLineType.call($$, d.id);
19280
19720
  if (path.length > 1) {
19281
19721
  barPath.push(path[1]);
19282
19722
  if (i === arr.length - 1) {
@@ -19368,7 +19808,7 @@ function getConnectLineType(id) {
19368
19808
  }
19369
19809
  const path = isRotated ? `H${pos} ${pathRadius[0]}V${points[2][indexY] - radius} ${pathRadius[1]}H${points[3][indexX]}` : `V${pos} ${pathRadius[0]}H${points[2][indexX] - radius} ${pathRadius[1]}V${points[3][indexY]}`;
19370
19810
  const coords = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
19371
- if (getConnectLineType.call($$, d.id)) {
19811
+ if (_getConnectLineType.call($$, d.id)) {
19372
19812
  coords.push(isRotated ? {
19373
19813
  x: points[0][indexX],
19374
19814
  y: points[0][indexY],
@@ -19757,7 +20197,7 @@ var funnel_spreadValues = (a, b) => {
19757
20197
 
19758
20198
 
19759
20199
 
19760
- function getSize(checkNeck = false) {
20200
+ function _getSize(checkNeck = false) {
19761
20201
  const $$ = this;
19762
20202
  const { config, state: { current: { width, height } } } = $$;
19763
20203
  const padding = $$.getCurrentPadding();
@@ -19766,7 +20206,7 @@ function getSize(checkNeck = false) {
19766
20206
  height: height - (config.legend_show ? $$.getLegendHeight() + 10 : 0) - (padding.top + padding.bottom)
19767
20207
  }, padding);
19768
20208
  if (checkNeck) {
19769
- const { width: neckWidth, height: neckHeight } = getNecklSize.call($$, {
20209
+ const { width: neckWidth, height: neckHeight } = _getNeckSize.call($$, {
19770
20210
  width: size.width,
19771
20211
  height: size.height
19772
20212
  });
@@ -19779,7 +20219,7 @@ function getSize(checkNeck = false) {
19779
20219
  }
19780
20220
  return size;
19781
20221
  }
19782
- function getNecklSize(current) {
20222
+ function _getNeckSize(current) {
19783
20223
  const $$ = this;
19784
20224
  const { config } = $$;
19785
20225
  let width = config.funnel_neck_width;
@@ -19796,9 +20236,9 @@ function getNecklSize(current) {
19796
20236
  height
19797
20237
  };
19798
20238
  }
19799
- function getCoord(d) {
20239
+ function _getCoord(d) {
19800
20240
  const $$ = this;
19801
- const { top, left, width } = getSize.call($$, true);
20241
+ const { top, left, width } = _getSize.call($$, true);
19802
20242
  const coords = [];
19803
20243
  d.forEach((d2, i) => {
19804
20244
  const { ratio } = d2;
@@ -19818,10 +20258,10 @@ function getCoord(d) {
19818
20258
  });
19819
20259
  return coords;
19820
20260
  }
19821
- function getClipPath(forBackground = false) {
20261
+ function _getClipPath(forBackground = false) {
19822
20262
  const $$ = this;
19823
- const { width, height, top, left } = getSize.call($$, true);
19824
- const neck = getNecklSize.call($$, { width, height });
20263
+ const { width, height, top, left } = _getSize.call($$, true);
20264
+ const neck = _getNeckSize.call($$, { width, height });
19825
20265
  const leftX = (width - neck.width) / 2;
19826
20266
  const rightX = (width + neck.width) / 2;
19827
20267
  const bodyHeigth = height - neck.height;
@@ -19849,7 +20289,7 @@ function getClipPath(forBackground = false) {
19849
20289
  }
19850
20290
  return `M${coords.join("L")}z`;
19851
20291
  }
19852
- function getFunnelData(d) {
20292
+ function _getFunnelData(d) {
19853
20293
  const $$ = this;
19854
20294
  const { config } = $$;
19855
20295
  const data = d.map((d2) => ({
@@ -19859,11 +20299,11 @@ function getFunnelData(d) {
19859
20299
  if (config.data_order) {
19860
20300
  data.sort($$.getSortCompareFn.bind($$)(true));
19861
20301
  }
19862
- return updateRatio.call($$, data);
20302
+ return _updateRatio.call($$, data);
19863
20303
  }
19864
- function updateRatio(data) {
20304
+ function _updateRatio(data) {
19865
20305
  const $$ = this;
19866
- const { height } = getSize.call($$);
20306
+ const { height } = _getSize.call($$);
19867
20307
  const total = $$.getTotalDataSum(true);
19868
20308
  data.forEach((d) => {
19869
20309
  d.ratio = d.value / total * height;
@@ -19929,7 +20369,7 @@ function updateRatio(data) {
19929
20369
  if (!funnel) {
19930
20370
  $$.initFunnel();
19931
20371
  }
19932
- const targets = getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
20372
+ const targets = _getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
19933
20373
  const mainFunnelUpdate = funnel.selectAll(`.${$FUNNEL.chartFunnel}`).data($$.filterNullish(targets));
19934
20374
  mainFunnelUpdate.exit().remove();
19935
20375
  const mainFunnelEnter = mainFunnelUpdate.enter().insert("g", `.${$FUNNEL.funnelBackground}`);
@@ -19956,7 +20396,7 @@ function updateRatio(data) {
19956
20396
  const $$ = this;
19957
20397
  const { $el: { funnel } } = $$;
19958
20398
  const targets = $$.filterTargetsToShow(funnel.path);
19959
- const { top, left, right } = getSize.call($$);
20399
+ const { top, left, right } = _getSize.call($$);
19960
20400
  const center = (left - right) / 2;
19961
20401
  const points = {};
19962
20402
  let accumulatedHeight = top != null ? top : 0;
@@ -19977,9 +20417,9 @@ function updateRatio(data) {
19977
20417
  const $$ = this;
19978
20418
  const { $T, $el: { funnel } } = $$;
19979
20419
  const targets = $$.filterTargetsToShow(funnel.path);
19980
- const coords = getCoord.call($$, updateRatio.call($$, targets.data()));
19981
- funnel.attr("clip-path", `path('${getClipPath.bind($$)()}')`);
19982
- funnel.background.attr("d", getClipPath.call($$, true));
20420
+ const coords = _getCoord.call($$, _updateRatio.call($$, targets.data()));
20421
+ funnel.attr("clip-path", `path('${_getClipPath.bind($$)()}')`);
20422
+ funnel.background.attr("d", _getClipPath.call($$, true));
19983
20423
  $T(targets).attr("d", (d, i) => `M${coords[i].join("L")}z`).style("opacity", "1");
19984
20424
  funnel.selectAll("g").style("opacity", null);
19985
20425
  }
@@ -20087,7 +20527,7 @@ var line_spreadProps = (a, b) => line_defProps(a, line_getOwnPropDescs(b));
20087
20527
 
20088
20528
 
20089
20529
 
20090
- function getStrokeDashArray(start, end, pattern, isLastX = false) {
20530
+ function _getStrokeDashArray(start, end, pattern, isLastX = false) {
20091
20531
  const dash = start ? [start, 0] : pattern;
20092
20532
  for (let i = start ? start : pattern.reduce((a, c) => a + c); i <= end; ) {
20093
20533
  pattern.forEach((v) => {
@@ -20103,7 +20543,7 @@ function getStrokeDashArray(start, end, pattern, isLastX = false) {
20103
20543
  length: dash.reduce((a, b) => a + b, 0)
20104
20544
  };
20105
20545
  }
20106
- function getRegions(d, _regions, isTimeSeries) {
20546
+ function _getRegions(d, _regions, isTimeSeries) {
20107
20547
  const $$ = this;
20108
20548
  const regions = [];
20109
20549
  const dasharray = "2 2";
@@ -20257,7 +20697,7 @@ function getRegions(d, _regions, isTimeSeries) {
20257
20697
  const isRotated = config.axis_rotated;
20258
20698
  const isTimeSeries = $$.axis.isTimeSeries();
20259
20699
  const dasharray = "2 2";
20260
- const regions = getRegions.bind($$)(d, _regions, isTimeSeries);
20700
+ const regions = _getRegions.bind($$)(d, _regions, isTimeSeries);
20261
20701
  const hasNullDataValue = $$.hasNullDataValue(d);
20262
20702
  let xp;
20263
20703
  let yp;
@@ -20353,7 +20793,7 @@ function getRegions(d, _regions, isTimeSeries) {
20353
20793
  isRotated && points.forEach((v) => v.reverse());
20354
20794
  const startLength = getLength(tempNode, path);
20355
20795
  const endLength = getLength(tempNode, path += `L${points[1].join(",")}`);
20356
- const strokeDashArray = getStrokeDashArray(
20796
+ const strokeDashArray = _getStrokeDashArray(
20357
20797
  startLength - dashArray.lastLength,
20358
20798
  endLength - dashArray.lastLength,
20359
20799
  style,
@@ -20785,10 +21225,10 @@ const getTransitionName = () => getRandom();
20785
21225
 
20786
21226
 
20787
21227
 
20788
- function hasValidPointDrawMethods(point) {
21228
+ function _hasValidPointDrawMethods(point) {
20789
21229
  return isObjectType(point) && isFunction(point.create) && isFunction(point.update);
20790
21230
  }
20791
- function insertPointInfoDefs(point, id) {
21231
+ function _insertPointInfoDefs(point, id) {
20792
21232
  var _a;
20793
21233
  const $$ = this;
20794
21234
  const copyAttr = (from, target) => {
@@ -20841,6 +21281,16 @@ function insertPointInfoDefs(point, id) {
20841
21281
  const { state: { datetimeId } } = this;
20842
21282
  return `${datetimeId}-point${id}`;
20843
21283
  },
21284
+ /**
21285
+ * Get validated point pattern array
21286
+ * @returns {Array} Array of point types
21287
+ * @private
21288
+ */
21289
+ getValidPointPattern() {
21290
+ const { config } = this;
21291
+ const validPointType = /^(circle|rect(angle)?)$/i.test(config.point_type) ? config.point_type : "circle";
21292
+ return notEmpty(config.point_pattern) ? config.point_pattern : [validPointType];
21293
+ },
20844
21294
  /**
20845
21295
  * Get generate point function
20846
21296
  * @returns {function}
@@ -20850,7 +21300,7 @@ function insertPointInfoDefs(point, id) {
20850
21300
  const $$ = this;
20851
21301
  const { $el, config } = $$;
20852
21302
  const ids = [];
20853
- const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
21303
+ const pattern = $$.getValidPointPattern();
20854
21304
  return function(method, context, ...args) {
20855
21305
  return function(d) {
20856
21306
  var _a, _b, _c, _d;
@@ -20860,11 +21310,11 @@ function insertPointInfoDefs(point, id) {
20860
21310
  let point = pattern[ids.indexOf(id) % pattern.length];
20861
21311
  if ($$.hasValidPointType(point)) {
20862
21312
  point = $$[point];
20863
- } else if (!hasValidPointDrawMethods(point || config.point_type)) {
21313
+ } else if (!_hasValidPointDrawMethods(point || config.point_type)) {
20864
21314
  const pointId = $$.getDefsPointId(id);
20865
21315
  const defsPoint = $el.defs.select(`#${pointId}`);
20866
21316
  if (defsPoint.size() < 1) {
20867
- insertPointInfoDefs.call($$, point, pointId);
21317
+ _insertPointInfoDefs.call($$, point, pointId);
20868
21318
  }
20869
21319
  if (method === "create") {
20870
21320
  return (_b = $$.custom) == null ? void 0 : _b.create.bind(context)(element, pointId, ...args);
@@ -20966,7 +21416,7 @@ function getDataMax($$) {
20966
21416
 
20967
21417
 
20968
21418
 
20969
- function getPosition(isClockwise, type, edge, pos, range, ratio) {
21419
+ function _getPosition(isClockwise, type, edge, pos, range, ratio) {
20970
21420
  const index = isClockwise && pos > 0 ? edge - pos : pos;
20971
21421
  const r = 2 * Math.PI;
20972
21422
  const func = type === "x" ? Math.sin : Math.cos;
@@ -21015,7 +21465,7 @@ const cacheKeyTextWidth = KEY.radarTextWidth;
21015
21465
  const edge = config.axis_x_categories.length;
21016
21466
  const isClockwise = config.radar_direction_clockwise;
21017
21467
  const pos = toArray(type).map(
21018
- (v) => getPosition(
21468
+ (v) => _getPosition(
21019
21469
  isClockwise,
21020
21470
  v,
21021
21471
  edge,
@@ -21498,6 +21948,7 @@ ${percentValue}%`;
21498
21948
  * - This is an `experimental` feature and can have some unexpected behaviors.
21499
21949
  * - If chart has 'bubble' type, only circle can be used.
21500
21950
  * - For IE, non circle point expansions are not supported due to lack of transform support.
21951
+ * - Only common SVG tags are allowed to prevent XSS attacks. If creating charts from user input, it is recommended to sanitize input values to avoid potential vulnerabilities.
21501
21952
  * - **Available Values:**
21502
21953
  * - circle
21503
21954
  * - rectangle
@@ -23179,7 +23630,7 @@ const bb = {
23179
23630
  * bb.version; // "1.0.0"
23180
23631
  * @memberof bb
23181
23632
  */
23182
- version: "3.18.0-next.1",
23633
+ version: "3.18.0",
23183
23634
  /**
23184
23635
  * Generate chart
23185
23636
  * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when: