billboard.js 3.17.4 → 3.18.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 (137) hide show
  1. package/CONTRIBUTING.md +12 -12
  2. package/README.md +12 -12
  3. package/dist/billboard.css +15 -1
  4. package/dist/billboard.js +1146 -463
  5. package/dist/billboard.min.css +2 -2
  6. package/dist/billboard.min.js +10 -10
  7. package/dist/billboard.pkgd.js +1147 -464
  8. package/dist/billboard.pkgd.min.js +21 -21
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-sparkline.js +117 -26
  12. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  13. package/dist/plugin/billboardjs-plugin-stanford.js +119 -28
  14. package/dist/plugin/billboardjs-plugin-stanford.min.js +10 -10
  15. package/dist/plugin/billboardjs-plugin-tableview.js +117 -27
  16. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  17. package/dist/plugin/billboardjs-plugin-textoverlap.js +116 -26
  18. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +117 -26
  22. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +120 -29
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +117 -27
  26. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -12
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +116 -26
  28. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
  29. package/dist/theme/dark.css +15 -1
  30. package/dist/theme/dark.min.css +2 -2
  31. package/dist/theme/datalab.css +15 -1
  32. package/dist/theme/datalab.min.css +2 -2
  33. package/dist/theme/graph.css +15 -1
  34. package/dist/theme/graph.min.css +2 -2
  35. package/dist/theme/insight.css +15 -1
  36. package/dist/theme/insight.min.css +2 -2
  37. package/dist/theme/modern.css +15 -1
  38. package/dist/theme/modern.min.css +2 -2
  39. package/dist-esm/billboard.js +1467 -536
  40. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -2
  42. package/dist-esm/plugin/billboardjs-plugin-stanford.js +5 -4
  43. package/dist-esm/plugin/billboardjs-plugin-tableview.js +94 -16
  44. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  45. package/package.json +38 -37
  46. package/src/Chart/Chart.ts +1 -1
  47. package/src/Chart/api/chart.ts +5 -5
  48. package/src/Chart/api/data.ts +2 -1
  49. package/src/Chart/api/export.ts +1 -1
  50. package/src/Chart/api/flow.ts +1 -1
  51. package/src/Chart/api/load.ts +3 -3
  52. package/src/Chart/api/subchart.ts +3 -3
  53. package/src/Chart/api/tooltip.ts +1 -1
  54. package/src/Chart/api/zoom.ts +1 -1
  55. package/src/ChartInternal/Axis/Axis.ts +1 -1
  56. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  57. package/src/ChartInternal/ChartInternal.ts +3 -2
  58. package/src/ChartInternal/data/IData.ts +3 -0
  59. package/src/ChartInternal/data/convert.helper.ts +1 -1
  60. package/src/ChartInternal/data/convert.ts +9 -8
  61. package/src/ChartInternal/data/data.ts +135 -17
  62. package/src/ChartInternal/data/load.ts +8 -8
  63. package/src/ChartInternal/interactions/drag.ts +53 -42
  64. package/src/ChartInternal/interactions/eventrect.ts +15 -5
  65. package/src/ChartInternal/interactions/flow.ts +1 -1
  66. package/src/ChartInternal/interactions/interaction.ts +1 -1
  67. package/src/ChartInternal/interactions/zoom.ts +24 -20
  68. package/src/ChartInternal/internals/color.ts +27 -10
  69. package/src/ChartInternal/internals/domain.ts +22 -5
  70. package/src/ChartInternal/internals/format.ts +4 -4
  71. package/src/ChartInternal/internals/grid.ts +11 -11
  72. package/src/ChartInternal/internals/legend.ts +80 -19
  73. package/src/ChartInternal/internals/scale.ts +6 -6
  74. package/src/ChartInternal/internals/selection.ts +1 -1
  75. package/src/ChartInternal/internals/style.ts +3 -3
  76. package/src/ChartInternal/internals/text.arc.ts +304 -0
  77. package/src/ChartInternal/internals/text.ts +44 -14
  78. package/src/ChartInternal/internals/text.util.ts +19 -0
  79. package/src/ChartInternal/internals/title.ts +3 -3
  80. package/src/ChartInternal/internals/tooltip.ts +23 -15
  81. package/src/ChartInternal/shape/arc.ts +174 -71
  82. package/src/ChartInternal/shape/area.ts +2 -2
  83. package/src/ChartInternal/shape/bar.ts +7 -6
  84. package/src/ChartInternal/shape/candlestick.ts +3 -3
  85. package/src/ChartInternal/shape/funnel.ts +18 -18
  86. package/src/ChartInternal/shape/line.ts +9 -10
  87. package/src/ChartInternal/shape/point.common.ts +24 -6
  88. package/src/ChartInternal/shape/radar.ts +4 -4
  89. package/src/ChartInternal/shape/shape.ts +24 -6
  90. package/src/ChartInternal/shape/treemap.ts +19 -5
  91. package/src/Plugin/stanford/Options.ts +2 -2
  92. package/src/Plugin/tableview/Options.ts +1 -1
  93. package/src/config/Options/axis/axis.ts +7 -7
  94. package/src/config/Options/axis/x.ts +6 -6
  95. package/src/config/Options/axis/y.ts +4 -4
  96. package/src/config/Options/axis/y2.ts +16 -3
  97. package/src/config/Options/common/color.ts +2 -2
  98. package/src/config/Options/common/legend.ts +6 -5
  99. package/src/config/Options/common/main.ts +23 -23
  100. package/src/config/Options/common/point.ts +4 -3
  101. package/src/config/Options/common/tooltip.ts +14 -13
  102. package/src/config/Options/data/axis.ts +31 -6
  103. package/src/config/Options/data/data.ts +44 -44
  104. package/src/config/Options/data/selection.ts +4 -4
  105. package/src/config/Options/interaction/interaction.ts +2 -1
  106. package/src/config/Options/interaction/subchart.ts +2 -2
  107. package/src/config/Options/interaction/zoom.ts +4 -4
  108. package/src/config/Options/shape/arc.ts +4 -4
  109. package/src/config/Options/shape/area.ts +1 -1
  110. package/src/config/Options/shape/bar.ts +4 -4
  111. package/src/config/Options/shape/bubble.ts +2 -2
  112. package/src/config/Options/shape/candlestick.ts +1 -1
  113. package/src/config/Options/shape/donut.ts +34 -3
  114. package/src/config/Options/shape/gauge.ts +36 -4
  115. package/src/config/Options/shape/line.ts +1 -1
  116. package/src/config/Options/shape/pie.ts +34 -3
  117. package/src/config/Options/shape/polar.ts +35 -4
  118. package/src/config/Options/shape/radar.ts +1 -1
  119. package/src/config/Options/shape/scatter.ts +1 -1
  120. package/src/config/Options/shape/treemap.ts +31 -5
  121. package/src/config/Store/State.ts +11 -1
  122. package/src/config/classes.ts +1 -0
  123. package/src/core.ts +1 -1
  124. package/src/module/Cache.ts +29 -4
  125. package/src/module/generator.ts +1 -1
  126. package/src/module/util.ts +308 -117
  127. package/src/module/worker.ts +3 -3
  128. package/src/scss/billboard.scss +15 -0
  129. package/src/scss/theme/dark.scss +15 -0
  130. package/src/scss/theme/datalab.scss +15 -0
  131. package/src/scss/theme/graph.scss +15 -0
  132. package/src/scss/theme/insight.scss +15 -0
  133. package/src/scss/theme/modern.scss +15 -0
  134. package/types/axis.d.ts +3 -3
  135. package/types/chart.d.ts +4 -4
  136. package/types/options.d.ts +22 -9
  137. package/types/options.shape.d.ts +59 -2
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.17.4
8
+ * @version 3.18.0-next.2
9
9
  */
10
10
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
11
11
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
@@ -84,6 +84,7 @@ var $COMMON = {
84
84
  var $ARC = {
85
85
  arc: "bb-arc",
86
86
  arcLabelLine: "bb-arc-label-line",
87
+ arcLabelLineText: "bb-arc-label-line-text",
87
88
  arcRange: "bb-arc-range",
88
89
  arcs: "bb-arcs",
89
90
  chartArc: "bb-chart-arc",
@@ -289,9 +290,9 @@ var color$1 = {
289
290
  * @memberof Options
290
291
  * @type {object}
291
292
  * @property {object} color color object
292
- * @property {string|object|Function} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
293
+ * @property {string|object|((this: Chart, d: DataItem) => string)} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
293
294
  * @property {Array|null} [color.pattern=[]] Set custom color pattern. Passing `null` will not set a color for these elements, which requires the usage of custom CSS-based theming to work.
294
- * @property {Function} [color.tiles] if defined, allows use svg's patterns to fill data area. It should return an array of [SVGPatternElement](https://developer.mozilla.org/en-US/docs/Web/API/SVGPatternElement).
295
+ * @property {(this: Chart) => SVGPathElement[]} [color.tiles] if defined, allows use svg's patterns to fill data area. It should return an array of [SVGPatternElement](https://developer.mozilla.org/en-US/docs/Web/API/SVGPatternElement).
295
296
  * - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
296
297
  * ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
297
298
  * - `bb-colorize-pattern-red`
@@ -382,7 +383,7 @@ var legend$2 = {
382
383
  * If true given, all legend will be hidden. If string or array given, only the legend that has the id will be hidden.
383
384
  * @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
384
385
  * - **NOTE:** Should be used along with `legend.contents.template`.
385
- * @property {string|Function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
386
+ * @property {string|function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
386
387
  * - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
387
388
  * - {=COLOR}: data color value
388
389
  * - {=TITLE}: data title value
@@ -390,6 +391,7 @@ var legend$2 = {
390
391
  * - title {string}: data's id value
391
392
  * - color {string}: color string
392
393
  * - data {Array}: data array
394
+ * - **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.
393
395
  * @property {string} [legend.position=bottom] Change the position of legend.<br>
394
396
  * Available values are: `bottom`, `right` and `inset` are supported.
395
397
  * @property {object} [legend.inset={anchor: 'top-left',x: 10,y: 0,step: undefined}] Change inset legend attributes.<br>
@@ -416,13 +418,13 @@ var legend$2 = {
416
418
  * - To return initial state(which all dataseries are showing), double click current focused legend item again.
417
419
  * - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
418
420
  * - In this case, default `click` interaction will be disabled.
419
- * @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
421
+ * @property {function} [legend.item.onclick=undefined] Set click event handler to the legend item.
420
422
  * - **NOTE:**
421
423
  * - When set, default `click` interaction will be disabled.
422
424
  * - When `interaction.dblclick=true` is set, will be called on double click.
423
- * @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
425
+ * @property {function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
424
426
  * - **NOTE:** When set, default `mouseover` interaction will be disabled.
425
- * @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
427
+ * @property {function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
426
428
  * - **NOTE:** When set, default `mouseout` interaction will be disabled.
427
429
  * @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
428
430
  * @property {number} [legend.item.tile.height=10] Set height for 'rectangle' legend item tile element.
@@ -499,7 +501,7 @@ var legend$2 = {
499
501
  * width: 15,
500
502
  * height: 15
501
503
  *
502
- * // radis is only applicable for 'circle' legend type
504
+ * // radius is only applicable for 'circle' legend type
503
505
  * r: 10
504
506
  * }
505
507
  * },
@@ -547,14 +549,14 @@ var legend$2 = {
547
549
  var main = {
548
550
  /**
549
551
  * Specify the CSS selector or the element which the chart will be set to. D3 selection object can be specified also.<br>
550
- * If other chart is set already, it will be replaced with the new one (only one chart can be set in one element).
551
- * - **NOTE:** In case of element doesn't exist or not specified, will add a `<div>` element to the body.
552
+ * If another chart is already set, it will be replaced with the new one (only one chart can be set in one element).
553
+ * - **NOTE:** In case the element doesn't exist or not specified, will add a `<div>` element to the body.
552
554
  * @name bindto
553
555
  * @memberof Options
554
556
  * @property {string|HTMLElement|d3.selection|object} [bindto="#chart"] Specify the element where chart will be drawn.
555
557
  * @property {string|HTMLElement|d3.selection} bindto.element="#chart" Specify the element where chart will be drawn.
556
558
  * @property {string} [bindto.classname=bb] Specify the class name of bind element.<br>
557
- * **NOTE:** When class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
559
+ * **NOTE:** When the class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
558
560
  * @default #chart
559
561
  * @example
560
562
  * bindto: "#myContainer"
@@ -595,8 +597,8 @@ var main = {
595
597
  /**
596
598
  * Set 'clip-path' attribute for chart element
597
599
  * - **NOTE:**
598
- * > When is false, chart node element is positioned after the axis node in DOM tree hierarchy.
599
- * > Is to make chart element positioned over axis element.
600
+ * > When false, chart node element is positioned after the axis node in DOM tree hierarchy.
601
+ * > This is to make the chart element positioned over axis element.
600
602
  * @name clipPath
601
603
  * @memberof Options
602
604
  * @type {boolean}
@@ -622,7 +624,7 @@ var main = {
622
624
  svg_classname: undefined,
623
625
  /**
624
626
  * The desired size of the chart element.
625
- * If value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
627
+ * If the value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
626
628
  * @name size
627
629
  * @memberof Options
628
630
  * @type {object}
@@ -640,13 +642,13 @@ var main = {
640
642
  size_height: undefined,
641
643
  /**
642
644
  * The padding of the chart element.
643
- * - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)"" wiki documentaion.
645
+ * - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)" wiki documentation.
644
646
  * @name padding
645
647
  * @memberof Options
646
648
  * @type {object}
647
649
  * @property {object|boolean} [padding=true] Set padding of chart, and accepts object or boolean type.
648
650
  * - `Object`: Specify each side's padding.
649
- * - `false`: Remove padding completely and make shape to fully occupy the container element.
651
+ * - `false`: Remove padding completely and make the shape fully occupy the container element.
650
652
  * - In this case, axes and subchart will be hidden.
651
653
  * - To adjust some padding from this state, use `axis.[x|y].padding` option.
652
654
  * @property {string} [padding.mode] padding mode
@@ -733,7 +735,7 @@ var main = {
733
735
  * Set a callback to execute when the chart is clicked.
734
736
  * @name onclick
735
737
  * @memberof Options
736
- * @type {Function}
738
+ * @type {function}
737
739
  * @default undefined
738
740
  * @example
739
741
  * onclick: function(event) {
@@ -747,7 +749,7 @@ var main = {
747
749
  * Set a callback to execute when mouse/touch enters the chart.
748
750
  * @name onover
749
751
  * @memberof Options
750
- * @type {Function}
752
+ * @type {function}
751
753
  * @default undefined
752
754
  * @example
753
755
  * onover: function(event) {
@@ -761,7 +763,7 @@ var main = {
761
763
  * Set a callback to execute when mouse/touch leaves the chart.
762
764
  * @name onout
763
765
  * @memberof Options
764
- * @type {Function}
766
+ * @type {function}
765
767
  * @default undefined
766
768
  * @example
767
769
  * onout: function(event) {
@@ -775,7 +777,7 @@ var main = {
775
777
  * Set a callback to execute when user resizes the screen.
776
778
  * @name onresize
777
779
  * @memberof Options
778
- * @type {Function}
780
+ * @type {function}
779
781
  * @default undefined
780
782
  * @example
781
783
  * onresize: function() {
@@ -788,7 +790,7 @@ var main = {
788
790
  * Set a callback to execute when screen resize finished.
789
791
  * @name onresized
790
792
  * @memberof Options
791
- * @type {Function}
793
+ * @type {function}
792
794
  * @default undefined
793
795
  * @example
794
796
  * onresized: function() {
@@ -801,7 +803,7 @@ var main = {
801
803
  * Set a callback to execute before the chart is initialized
802
804
  * @name onbeforeinit
803
805
  * @memberof Options
804
- * @type {Function}
806
+ * @type {function}
805
807
  * @default undefined
806
808
  * @example
807
809
  * onbeforeinit: function() {
@@ -814,7 +816,7 @@ var main = {
814
816
  * Set a callback to execute when the chart is initialized.
815
817
  * @name oninit
816
818
  * @memberof Options
817
- * @type {Function}
819
+ * @type {function}
818
820
  * @default undefined
819
821
  * @example
820
822
  * oninit: function() {
@@ -827,7 +829,7 @@ var main = {
827
829
  * Set a callback to execute after the chart is initialized
828
830
  * @name onafterinit
829
831
  * @memberof Options
830
- * @type {Function}
832
+ * @type {function}
831
833
  * @default undefined
832
834
  * @example
833
835
  * onafterinit: function() {
@@ -837,10 +839,10 @@ var main = {
837
839
  */
838
840
  onafterinit: undefined,
839
841
  /**
840
- * Set a callback which is executed when the chart is rendered. Basically, this callback will be called in each time when the chart is redrawed.
842
+ * Set a callback which is executed when the chart is rendered. Basically, this callback will be called in each time when the chart is redrawn.
841
843
  * @name onrendered
842
844
  * @memberof Options
843
- * @type {Function}
845
+ * @type {function}
844
846
  * @default undefined
845
847
  * @example
846
848
  * onrendered: function() {
@@ -851,7 +853,7 @@ var main = {
851
853
  onrendered: undefined,
852
854
  /**
853
855
  * Set duration of transition (in milliseconds) for chart animation.<br><br>
854
- * - **NOTE:** If `0 `or `null` set, transition will be skipped. So, this makes initial rendering faster especially in case you have a lot of data.
856
+ * - **NOTE:** If `0` or `null` is set, transition will be skipped. So, this makes initial rendering faster especially in case you have a lot of data.
855
857
  * @name transition
856
858
  * @memberof Options
857
859
  * @type {object}
@@ -882,11 +884,11 @@ var main = {
882
884
  * @memberof Options
883
885
  * @type {object}
884
886
  * @property {object} [render] render object
885
- * @property {boolean} [render.lazy=true] Make to not render at initialization.
887
+ * @property {boolean} [render.lazy=true] Make it not render at initialization.
886
888
  * - **NOTE**:
887
889
  * - Enabled by default when bind element's visibility is hidden.
888
890
  * - When set to `false`, will initialize the chart regardless the bind element's visibility state, but in this case chart can't be guaranteed to be rendered properly.
889
- * @property {boolean} [render.observe=true] Observe bind element's visibility(`display` or `visiblity` inline css property or class value) & render when is visible automatically (for IEs, only works IE11+). When set to **false**, call [`.flush()`](./Chart.html#flush) to render.
891
+ * @property {boolean} [render.observe=true] Observe bind element's visibility(`display` or `visibility` inline css property or class value) & render when it is visible automatically (for IEs, only works IE11+). When set to **false**, call [`.flush()`](./Chart.html#flush) to render.
890
892
  * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
891
893
  * @example
892
894
  * render: {
@@ -908,7 +910,7 @@ var main = {
908
910
  * document.getElementById('chart').style.display = 'block'; // (b)
909
911
  *
910
912
  * @example
911
- * // chart won't be rendered and not observing bind element's visiblity changes
913
+ * // chart won't be rendered and not observing bind element's visibility changes
912
914
  * var chart = bb.generate({
913
915
  * render: {
914
916
  * lazy: true,
@@ -934,7 +936,7 @@ var main = {
934
936
  * - `[start] {number|Date|string}`: Start position of the region. If not set, the start will be the edge of the chart.
935
937
  * - `[end] {number|Date|string}`: End position of the region. If not set, the end will be the edge of the chart.
936
938
  * - `[class] {string}`: Class value to apply to the region.
937
- * - `[label] {object}` Lable text option.
939
+ * - `[label] {object}` Label text option.
938
940
  * - `text {string}`: Text value.
939
941
  * - `x {number}`: x Position.
940
942
  * - `y {number}`: y Position.
@@ -1036,17 +1038,17 @@ var tooltip$2 = {
1036
1038
  * - **NOTE:** The overlapped data points will be displayed as grouped even if set false.
1037
1039
  * @property {boolean} [tooltip.linked=false] Set if tooltips on all visible charts with like x points are shown together when one is shown.
1038
1040
  * @property {string} [tooltip.linked.name=""] Groping name for linked tooltip.<br>If specified, linked tooltip will be groped interacting to be worked only with the same name.
1039
- * @property {Function} [tooltip.format.title] Set format for the title of tooltip.<br>
1041
+ * @property {function} [tooltip.format.title] Set format for the title of tooltip.<br>
1040
1042
  * Specified function receives x of the data point to show.
1041
- * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
1043
+ * @property {function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
1042
1044
  * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
1043
- * @property {Function} [tooltip.format.value] Set format for the value of each data value in tooltip. If undefined returned, the row of that value will be skipped to be called.
1045
+ * @property {function} [tooltip.format.value] Set format for the value of each data value in tooltip. If undefined returned, the row of that value will be skipped to be called.
1044
1046
  * - Will pass following arguments to the given function:
1045
1047
  * - `value {string}`: Value of the data point. If data row contains multiple or ranged(ex. candlestick, area range, etc.) value, formatter will be called as value length.
1046
1048
  * - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
1047
1049
  * - `id {string}`: id of the data point
1048
1050
  * - `index {number}`: Index of the data point
1049
- * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
1051
+ * @property {function} [tooltip.position] Set custom position function for the tooltip.<br>
1050
1052
  * This option can be used to modify the tooltip position by returning object that has top and left.
1051
1053
  * - Will pass following arguments to the given function:
1052
1054
  * - `data {Array}`: Current selected data array object.
@@ -1054,7 +1056,7 @@ var tooltip$2 = {
1054
1056
  * - `height {number}`: Height of tooltip.
1055
1057
  * - `element {SVGElement}`: Tooltip event bound element
1056
1058
  * - `pos {object}`: Current position of the tooltip.
1057
- * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
1059
+ * @property {function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
1058
1060
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
1059
1061
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
1060
1062
  * - **Note:**
@@ -1076,6 +1078,7 @@ var tooltip$2 = {
1076
1078
  * - **{=COLOR}**: data color.
1077
1079
  * - **{=NAME}**: data id value.
1078
1080
  * - **{=VALUE}**: data value.
1081
+ * - **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.
1079
1082
  * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
1080
1083
  * - **NOTE:** It should contain `{ key: Array, ... }` value
1081
1084
  * - 'key' name is used as substitution within template as '{=KEY}'
@@ -1083,11 +1086,11 @@ var tooltip$2 = {
1083
1086
  * @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
1084
1087
  * @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
1085
1088
  * @property {object} [tooltip.init.position] Set the position of tooltip at the initialization.
1086
- * @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
1087
- * @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
1088
- * @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
1089
- * @property {Function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
1090
- * @property {string|Function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
1089
+ * @property {function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
1090
+ * @property {function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
1091
+ * @property {function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
1092
+ * @property {function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
1093
+ * @property {string|function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
1091
1094
  * **Available Values:**
1092
1095
  * - `desc`: In descending data value order
1093
1096
  * - `asc`: In ascending data value order
@@ -1126,7 +1129,7 @@ var tooltip$2 = {
1126
1129
  * // yAxis: Current y Axis position value or function(the value is given for axis based chart type only)
1127
1130
  * // }
1128
1131
  *
1129
- * // yAxis will work differently per data lenghts
1132
+ * // yAxis will work differently per data lengths
1130
1133
  * // - a) Single data: `yAxis` will return `number` value
1131
1134
  * // - b) Multiple data: `yAxis` will return a function with property value
1132
1135
  *
@@ -1137,8 +1140,8 @@ var tooltip$2 = {
1137
1140
  * // b) Multiple data:
1138
1141
  * // Get y coordinate of value 500, where 'data1' scales(y or y2).
1139
1142
  * // When 'data.axes' option is used, data can bound to different axes.
1140
- * // - when "data.axes={data1: 'y'}", wil return y value from y axis scale.
1141
- * // - when "data.axes={data1: 'y2'}", wil return y value from y2 axis scale.
1143
+ * // - when "data.axes={data1: 'y'}", will return y value from y axis scale.
1144
+ * // - when "data.axes={data1: 'y2'}", will return y value from y2 axis scale.
1142
1145
  * pos.yAxis(500, "data1"); // will return y coordinate value of data1
1143
1146
  *
1144
1147
  * pos.yAxis(500); // get y coordinate with value of 500, using y axis scale
@@ -1272,7 +1275,7 @@ var tooltip$2 = {
1272
1275
  var data$2 = {
1273
1276
  /**
1274
1277
  * Specify the key of x values in the data.<br><br>
1275
- * We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on category axis, the values of the data on the key will be used for category names.
1278
+ * We can show the data with non-index x values by this option. This option is required when the type of x axis is timeseries. If this option is set on a category axis, the values of the data on the key will be used for category names.
1276
1279
  * @name data․x
1277
1280
  * @memberof Options
1278
1281
  * @type {string}
@@ -1287,7 +1290,7 @@ var data$2 = {
1287
1290
  * Converts data id value
1288
1291
  * @name data․idConverter
1289
1292
  * @memberof Options
1290
- * @type {Function}
1293
+ * @type {function}
1291
1294
  * @default function(id) { return id; }
1292
1295
  * @example
1293
1296
  * data: {
@@ -1456,8 +1459,8 @@ var data$2 = {
1456
1459
  data_types: {},
1457
1460
  /**
1458
1461
  * This option changes the order of stacking data and pieces of pie/donut.
1459
- * - If `null` specified, it will be the order the data loaded.
1460
- * - If function specified, it will be used as [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)<br><br>
1462
+ * - If `null` specified, it will be the order in which the data is loaded.
1463
+ * - If a function is specified, it will be used as [Array.sort compareFunction](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#Parameters)<br><br>
1461
1464
  *
1462
1465
  * **Available Values:**
1463
1466
  * - `desc`: In descending order
@@ -1465,10 +1468,10 @@ var data$2 = {
1465
1468
  * - `null`: It keeps the data load order
1466
1469
  * - `function(data1, data2) { ... }`: Array.sort compareFunction
1467
1470
  *
1468
- * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
1471
+ * **NOTE**: order function only works for Axis based types & Arc types, except `Radar` type.
1469
1472
  * @name data․order
1470
1473
  * @memberof Options
1471
- * @type {string|Function|null}
1474
+ * @type {string|function|null}
1472
1475
  * @default desc
1473
1476
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
1474
1477
  * @example
@@ -1523,7 +1526,7 @@ var data$2 = {
1523
1526
  /**
1524
1527
  * Set how zero value will be treated on groups.<br>
1525
1528
  * Possible values:
1526
- * - `zero`: 0 will be positioned at absolute axis zero point.
1529
+ * - `zero`: 0 will be positioned at the absolute axis zero point.
1527
1530
  * - `positive`: 0 will be positioned at the top of a stack.
1528
1531
  * - `negative`: 0 will be positioned at the bottom of a stack.
1529
1532
  * @name data․groupsZeroAs
@@ -1539,10 +1542,10 @@ var data$2 = {
1539
1542
  data_groupsZeroAs: "positive",
1540
1543
  /**
1541
1544
  * Set color converter function.<br><br>
1542
- * This option should a function and the specified function receives color (e.g. '#ff0000') and d that has data parameters like id, value, index, etc. And it must return a string that represents color (e.g. '#00ff00').
1545
+ * This option should be a function and the specified function receives color (e.g. '#ff0000') and d that has data parameters like id, value, index, etc. And it must return a string that represents color (e.g. '#00ff00').
1543
1546
  * @name data․color
1544
1547
  * @memberof Options
1545
- * @type {Function}
1548
+ * @type {function}
1546
1549
  * @default undefined
1547
1550
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
1548
1551
  * @example
@@ -1575,41 +1578,41 @@ var data$2 = {
1575
1578
  * @memberof Options
1576
1579
  * @type {object}
1577
1580
  * @property {object} data Data object
1578
- * @property {boolean} [data.labels=false] Show or hide labels on each data points
1581
+ * @property {boolean} [data.labels=false] Show or hide labels on each data point
1579
1582
  * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
1580
- * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
1583
+ * @property {function} [data.labels.format] Set formatter function for data labels.<br>
1581
1584
  * The formatter function receives 4 arguments such as `v, id, i, texts` and it **must return a string** (`\n` character will be used as line break) that will be shown as the label.<br><br>
1582
1585
  * The arguments are:<br>
1583
1586
  * - `v` is the value of the data point where the label is shown.
1584
1587
  * - `id` is the id of the data where the label is shown.
1585
1588
  * - `i` is the index of the data series point where the label is shown.
1586
- * - `texts` is the array of whole corresponding data series' text labels.<br><br>
1589
+ * - `texts` is an array of whole corresponding data series' text labels.<br><br>
1587
1590
  * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
1588
- * @property {string|object|Function} [data.labels.backgroundColors] Set label text background colors.<br><br>
1589
- * - **NOTE**: When function is set, background colors can be specified one color per dataset.
1591
+ * @property {string|object|function} [data.labels.backgroundColors] Set label text background colors.<br><br>
1592
+ * - **NOTE**: When a function is set, background colors can be specified one color per dataset.
1590
1593
  * - Within the function, the last returned color for dataset will be used.
1591
1594
  * - Only can control set or unset background color for each values.
1592
- * @property {string|object|Function} [data.labels.colors] Set label text colors.
1593
- * @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
1594
- * When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
1595
+ * @property {string|object|function} [data.labels.colors] Set label text colors.
1596
+ * @property {object|function} [data.labels.position] Set each dataset position, relative to the original.<br><br>
1597
+ * When a function is specified, it will receive 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
1595
1598
  * The arguments are:<br>
1596
1599
  * - `type` coordinate type string, which will be 'x' or 'y'.
1597
1600
  * - `v` is the value of the data point where the label is shown.
1598
1601
  * - `id` is the id of the data where the label is shown.
1599
1602
  * - `i` is the index of the data series point where the label is shown.
1600
- * - `texts` is the array of whole corresponding data series' text labels.<br><br>
1601
- * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
1602
- * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
1603
+ * - `texts` is an array of whole corresponding data series' text labels.<br><br>
1604
+ * @property {number} [data.labels.position.x=0] x coordinate position, relative to the original.
1605
+ * @property {number} [data.labels.position.y=0] y coordinate position, relative to the original.
1603
1606
  * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
1604
- * - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
1605
- * @property {boolean|object} [data.labels.border=false] Add border to data label text. NOTE: When set as `true`, styling aren't applied. Hence, need to set using `.bb-text-border` class.
1607
+ * - **NOTE:** Depending on the rotate value, the text position needs to be adjusted manually(using `data.labels.position` option) to be shown nicely.
1608
+ * @property {boolean|object} [data.labels.border=false] Add border to data label text. NOTE: When set as `true`, styling isn't applied. Hence, you need to set it using `.bb-text-border` class.
1606
1609
  * @property {number|string|object} [data.labels.border.padding="3 5"] Border padding. Can be a single number, string or object with top, bottom, left, right properties.
1607
1610
  * @property {number} [data.labels.border.radius=10] Border radius value.
1608
1611
  * @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
1609
1612
  * @property {string} [data.labels.border.stroke="#000"] Border stroke color.
1610
1613
  * @property {string} [data.labels.border.fill="none"] Border fill color.
1611
- * @property {object|Function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
1612
- * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
1614
+ * @property {object|function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
1615
+ * When a function is specified, it will receive 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
1613
1616
  * The arguments are:<br>
1614
1617
  * - `v` is the value of the data point where the label is shown.
1615
1618
  * - `id` is the id of the data where the label is shown.
@@ -1618,8 +1621,8 @@ var data$2 = {
1618
1621
  * @property {number} data.labels.image.width Image width in pixels.
1619
1622
  * @property {number} data.labels.image.height Image height in pixels.
1620
1623
  * @property {object} [data.labels.image.pos] Image position relative to the label text.
1621
- * @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
1622
- * @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
1624
+ * @property {number} [data.labels.image.pos.x=0] x coordinate position, relative to the original.
1625
+ * @property {number} [data.labels.image.pos.y=0] y coordinate position, relative to the original.
1623
1626
  * @memberof Options
1624
1627
  * @type {object}
1625
1628
  * @default {}
@@ -1653,10 +1656,10 @@ var data$2 = {
1653
1656
  * // align text to center of the 'bar' shape (works only for 'bar' type)
1654
1657
  * centered: true,
1655
1658
  *
1656
- * // apply backgound color for label texts
1659
+ * // apply background color for label texts
1657
1660
  * backgroundColors: "red",
1658
1661
  *
1659
- * // set differenct backround colors per dataset
1662
+ * // set different background colors per dataset
1660
1663
  * backgroundColors: {
1661
1664
  * data1: "green",
1662
1665
  * data2: "yellow"
@@ -1767,7 +1770,7 @@ var data$2 = {
1767
1770
  * pos: { x: 0, y: 0 }
1768
1771
  * };
1769
1772
  * } else if(v < 5) {
1770
- * // Return falsy value in case of don't want to show image
1773
+ * // Return falsy value in case you don't want to show image
1771
1774
  * return null;
1772
1775
  * } else {
1773
1776
  * return {
@@ -1788,7 +1791,7 @@ var data$2 = {
1788
1791
  data_labels_imgUrl: undefined,
1789
1792
  /**
1790
1793
  * Hide each data when the chart appears.<br><br>
1791
- * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
1794
+ * If true is specified, all of data will be hidden. If multiple ids are specified as an array, those will be hidden.
1792
1795
  * @name data․hide
1793
1796
  * @memberof Options
1794
1797
  * @type {boolean|Array}
@@ -1809,7 +1812,7 @@ var data$2 = {
1809
1812
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
1810
1813
  * @name data․filter
1811
1814
  * @memberof Options
1812
- * @type {Function}
1815
+ * @type {function}
1813
1816
  * @default undefined
1814
1817
  * @example
1815
1818
  * data: {
@@ -1824,13 +1827,13 @@ var data$2 = {
1824
1827
  data_filter: undefined,
1825
1828
  /**
1826
1829
  * Set a callback for click event on each data point.<br><br>
1827
- * This callback will be called when each data point clicked and will receive `d` and element as the arguments.
1830
+ * This callback will be called when each data point is clicked and will receive `d` and element as the arguments.
1828
1831
  * - `d` is the data clicked and element is the element clicked.
1829
1832
  * - `element` is the current interacting svg element.
1830
1833
  * - In this callback, `this` will be the Chart object.
1831
1834
  * @name data․onclick
1832
1835
  * @memberof Options
1833
- * @type {Function}
1836
+ * @type {function}
1834
1837
  * @default function() {}
1835
1838
  * @example
1836
1839
  * data: {
@@ -1844,13 +1847,13 @@ var data$2 = {
1844
1847
  data_onclick: function () { },
1845
1848
  /**
1846
1849
  * Set a callback for mouse/touch over event on each data point.<br><br>
1847
- * This callback will be called when mouse cursor or via touch moves onto each data point and will receive `d` and `element` as the argument.
1850
+ * This callback will be called when the mouse cursor or touch moves onto each data point and will receive `d` and `element` as the argument.
1848
1851
  * - `d` is the data where mouse cursor moves onto.
1849
1852
  * - `element` is the current interacting svg element.
1850
1853
  * - In this callback, `this` will be the Chart object.
1851
1854
  * @name data․onover
1852
1855
  * @memberof Options
1853
- * @type {Function}
1856
+ * @type {function}
1854
1857
  * @default function() {}
1855
1858
  * @example
1856
1859
  * data: {
@@ -1864,13 +1867,13 @@ var data$2 = {
1864
1867
  data_onover: function () { },
1865
1868
  /**
1866
1869
  * Set a callback for mouse/touch out event on each data point.<br><br>
1867
- * This callback will be called when mouse cursor or via touch moves out each data point and will receive `d` as the argument.
1870
+ * This callback will be called when the mouse cursor or touch moves out each data point and will receive `d` as the argument.
1868
1871
  * - `d` is the data where mouse cursor moves out.
1869
1872
  * - `element` is the current interacting svg element.
1870
1873
  * - In this callback, `this` will be the Chart object.
1871
1874
  * @name data․onout
1872
1875
  * @memberof Options
1873
- * @type {Function}
1876
+ * @type {function}
1874
1877
  * @default function() {}
1875
1878
  * @example
1876
1879
  * data: {
@@ -1887,7 +1890,7 @@ var data$2 = {
1887
1890
  * The callback will receive shown data ids in array.
1888
1891
  * @name data․onshown
1889
1892
  * @memberof Options
1890
- * @type {Function}
1893
+ * @type {function}
1891
1894
  * @default undefined
1892
1895
  * @example
1893
1896
  * data: {
@@ -1903,7 +1906,7 @@ var data$2 = {
1903
1906
  * The callback will receive hidden data ids in array.
1904
1907
  * @name data․onhidden
1905
1908
  * @memberof Options
1906
- * @type {Function}
1909
+ * @type {function}
1907
1910
  * @default undefined
1908
1911
  * @example
1909
1912
  * data: {
@@ -1919,7 +1922,7 @@ var data$2 = {
1919
1922
  * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
1920
1923
  * @name data․onmin
1921
1924
  * @memberof Options
1922
- * @type {Function}
1925
+ * @type {function}
1923
1926
  * @default undefined
1924
1927
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
1925
1928
  * @example
@@ -1934,7 +1937,7 @@ var data$2 = {
1934
1937
  * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
1935
1938
  * @name data․onmax
1936
1939
  * @memberof Options
1937
- * @type {Function}
1940
+ * @type {function}
1938
1941
  * @default undefined
1939
1942
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
1940
1943
  * @example
@@ -1945,7 +1948,7 @@ var data$2 = {
1945
1948
  */
1946
1949
  data_onmax: undefined,
1947
1950
  /**
1948
- * Load a CSV or JSON file from a URL. NOTE that this will not work if loading via the "file://" protocol as the most browsers will block XMLHTTPRequests.
1951
+ * Load a CSV or JSON file from a URL. NOTE that this will not work if loading via the "file://" protocol as most browsers will block XMLHTTPRequests.
1949
1952
  * @name data․url
1950
1953
  * @memberof Options
1951
1954
  * @type {string}
@@ -2073,7 +2076,7 @@ var data$2 = {
2073
2076
  * }
2074
2077
  * }
2075
2078
  *
2076
- * // for 'canlestick' type, data should contain:
2079
+ * // for 'candlestick' type, data should contain:
2077
2080
  * // - an array of [open, high, low, close, volume(optional)] data following the order
2078
2081
  * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
2079
2082
  * data: {
@@ -2148,7 +2151,7 @@ var data$2 = {
2148
2151
  * type: "bubble"
2149
2152
  * }
2150
2153
  *
2151
- * // for 'canlestick' type, data should contain:
2154
+ * // for 'candlestick' type, data should contain:
2152
2155
  * // - an array of [open, high, low, close, volume(optional)] data following the order
2153
2156
  * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
2154
2157
  * data: {
@@ -2242,7 +2245,8 @@ var interaction$1 = {
2242
2245
  * @property {boolean} [interaction.brighten=true] Make brighter for the selected area (ex. 'pie' type data selected area)
2243
2246
  * @property {boolean} [interaction.inputType.mouse=true] enable or disable mouse interaction
2244
2247
  * @property {boolean} [interaction.inputType.touch=true] enable or disable touch interaction
2245
- * @property {boolean|number} [interaction.inputType.touch.preventDefault=false] enable or disable to call event.preventDefault on touchstart & touchmove event. It's usually used to prevent document scrolling.
2248
+ * @property {boolean|number} [interaction.inputType.touch.preventDefault=false] enable or disable to call event.preventDefault on touchstart & touchmove event. It's usually used to prevent document scrolling.<br>
2249
+ * - **NOTE**: When `true` is set, touch events are bound with [`{passive: false}`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#using_passive_listeners) option.
2246
2250
  * @property {boolean} [interaction.onout=true] Enable or disable "onout" event.<br>
2247
2251
  * When is disabled, defocus(hiding tooltip, focused gridline, etc.) event won't work.
2248
2252
  * @see [Demo: touch.preventDefault](https://naver.github.io/billboard.js/demo/#Interaction.PreventScrollOnTouch)
@@ -2320,6 +2324,123 @@ var win = getGlobal();
2320
2324
  var doc = win === null || win === void 0 ? void 0 : win.document;
2321
2325
  var _a = getFallback(win), requestAnimationFrame = _a[0], requestIdleCallback = _a[2];
2322
2326
 
2327
+ // ====================================
2328
+ // Internal Helper (Not Exported)
2329
+ // ====================================
2330
+ /**
2331
+ * Get boundingClientRect or BBox with caching.
2332
+ * Internal helper for getBoundingRect() and getBBox()
2333
+ * @param {boolean} relativeViewport Relative to viewport - true: will use .getBoundingClientRect(), false: will use .getBBox()
2334
+ * @param {SVGElement} node Target element
2335
+ * @param {boolean} forceEval Force evaluation
2336
+ * @returns {object}
2337
+ * @private
2338
+ */
2339
+ function _getRect(relativeViewport, node, forceEval) {
2340
+ if (forceEval === void 0) { forceEval = false; }
2341
+ var _ = function (n) { return n[relativeViewport ? "getBoundingClientRect" : "getBBox"](); };
2342
+ if (forceEval) {
2343
+ return _(node);
2344
+ }
2345
+ else {
2346
+ // will cache the value if the element is not a SVGElement or the width is not set
2347
+ var needEvaluate = !("rect" in node) || ("rect" in node && node.hasAttribute("width") &&
2348
+ node.rect.width !== +(node.getAttribute("width") || 0));
2349
+ return needEvaluate ? (node.rect = _(node)) : node.rect;
2350
+ }
2351
+ }
2352
+ /**
2353
+ * Internal helper to iterate over array items and invoke a callback for each valid item
2354
+ * @param {Array} items Array to iterate
2355
+ * @param {function} callback Callback function (item, index) => void
2356
+ * @private
2357
+ */
2358
+ function _forEachValidItem(items, callback) {
2359
+ for (var i = 0; i < items.length; i++) {
2360
+ var item = items[i];
2361
+ if (item) {
2362
+ callback(item, i);
2363
+ }
2364
+ }
2365
+ }
2366
+ /**
2367
+ * Private sanitization utilities
2368
+ * Encapsulates all XSS prevention patterns and helper functions
2369
+ * @private
2370
+ */
2371
+ var _sanitize = (function () {
2372
+ var DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
2373
+ // HTML entity character code map (for decoding)
2374
+ var ENTITY_MAP = {
2375
+ quot: 34,
2376
+ amp: 38,
2377
+ apos: 39,
2378
+ lt: 60,
2379
+ gt: 62,
2380
+ nbsp: 160,
2381
+ iexcl: 161,
2382
+ cent: 162,
2383
+ pound: 163,
2384
+ curren: 164,
2385
+ yen: 165
2386
+ };
2387
+ // Angle bracket codes (< and >) - never decode these to prevent tag bypass
2388
+ var LT_CODE = 60;
2389
+ var GT_CODE = 62;
2390
+ // Maximum sanitization iterations to prevent infinite loops
2391
+ var MAX_ITERATIONS = 10;
2392
+ // Regular expressions (compiled once for performance)
2393
+ var rx = {
2394
+ tags: new RegExp("<(".concat(DANGEROUS_TAGS, ")\\b[\\s\\S]*?>([\\s\\S]*?<\\/(").concat(DANGEROUS_TAGS, ")\\s*>)?"), "gi"),
2395
+ htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
2396
+ // eslint-disable-next-line no-control-regex
2397
+ controlChar: /[\x00-\x1F\x7F]/g,
2398
+ eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
2399
+ dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
2400
+ dangerousProtocol: /^(javascript|data|vbscript):/
2401
+ };
2402
+ return {
2403
+ ENTITY_MAP: ENTITY_MAP,
2404
+ LT_CODE: LT_CODE,
2405
+ GT_CODE: GT_CODE,
2406
+ MAX_ITERATIONS: MAX_ITERATIONS,
2407
+ rx: rx,
2408
+ /**
2409
+ * Decode HTML entities to prevent bypass attacks
2410
+ * @param {string} str String with potential HTML entities
2411
+ * @returns {string} Decoded string
2412
+ */
2413
+ decodeEntities: function (str) {
2414
+ return str.replace(rx.htmlEntity, function (match, hex, dec, named) {
2415
+ var code = hex ?
2416
+ parseInt(hex, 16) :
2417
+ dec ?
2418
+ parseInt(dec, 10) :
2419
+ named ?
2420
+ ENTITY_MAP[named.toLowerCase()] || 0 :
2421
+ 0;
2422
+ // Never decode angle brackets to prevent tag bypass
2423
+ return code && code !== LT_CODE && code !== GT_CODE ?
2424
+ String.fromCharCode(code) :
2425
+ match;
2426
+ });
2427
+ },
2428
+ /**
2429
+ * Remove dangerous URI protocols from attribute values
2430
+ * @param {string} str String to sanitize
2431
+ * @returns {string} Sanitized string
2432
+ */
2433
+ removeDangerousUris: function (str) {
2434
+ return str.replace(rx.dangerousUri, function (match, attr, quote, value) {
2435
+ var normalized = value.toLowerCase().replace(/\s/g, "");
2436
+ return rx.dangerousProtocol.test(normalized) ? "".concat(attr, "=").concat(quote).concat(quote) : match;
2437
+ });
2438
+ }
2439
+ };
2440
+ })();
2441
+ // ====================================
2442
+ // Exported
2443
+ // ====================================
2323
2444
  var isValue = function (v) { return v || v === 0; };
2324
2445
  var isFunction = function (v) { return typeof v === "function"; };
2325
2446
  var isString = function (v) { return typeof v === "string"; };
@@ -2361,8 +2482,8 @@ var isObject = function (obj) { return obj && !(obj === null || obj === void 0 ?
2361
2482
  * If default value is given, will return if given key value not found
2362
2483
  * @param {object} options Source object
2363
2484
  * @param {string} key Key value
2364
- * @param {*} defaultValue Default value
2365
- * @returns {*}
2485
+ * @param {string|number|boolean|object|Array|function|null|undefined} defaultValue Default value
2486
+ * @returns {string|number|boolean|object|Array|function|null|undefined} Option value or default value
2366
2487
  * @private
2367
2488
  */
2368
2489
  function getOption(options, key, defaultValue) {
@@ -2371,7 +2492,7 @@ function getOption(options, key, defaultValue) {
2371
2492
  /**
2372
2493
  * Check if value exist in the given object
2373
2494
  * @param {object} dict Target object to be checked
2374
- * @param {*} value Value to be checked
2495
+ * @param {string|number|boolean|object|Array|function|null|undefined} value Value to be checked
2375
2496
  * @returns {boolean}
2376
2497
  * @private
2377
2498
  */
@@ -2382,9 +2503,9 @@ function hasValue(dict, value) {
2382
2503
  }
2383
2504
  /**
2384
2505
  * Call function with arguments
2385
- * @param {Function} fn Function to be called
2386
- * @param {*} thisArg "this" value for fn
2387
- * @param {*} args Arguments for fn
2506
+ * @param {function} fn Function to be called
2507
+ * @param {object|null|undefined} thisArg "this" value for fn
2508
+ * @param {...(string|number|boolean|object|Array|function|null|undefined)} args Arguments for fn
2388
2509
  * @returns {boolean} true: fn is function, false: fn is not function
2389
2510
  * @private
2390
2511
  */
@@ -2423,40 +2544,43 @@ function endall(transition, cb) {
2423
2544
  transition.call(end);
2424
2545
  }
2425
2546
  }
2426
- // Sanitize patterns (blacklist approach with repeated application)
2427
- var DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
2428
- var sanitizeRx = {
2429
- tags: new RegExp("<(".concat(DANGEROUS_TAGS, ")\\b[\\s\\S]*?>([\\s\\S]*?<\\/(").concat(DANGEROUS_TAGS, ")\\s*>)?"), "gi"),
2430
- // Handles: whitespace, slash, quotes before event handlers (e.g., <img/onerror=...>, <img src="x"onerror=...>)
2431
- eventHandlers: /[\s/"']+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,
2432
- // Handles: javascript/data/vbscript URIs with optional whitespace/newlines between protocol and colon
2433
- dangerousURIs: /(href|src|action|xlink:href)\s*=\s*["']?\s*(javascript|data|vbscript)\s*:/gi
2434
- };
2435
2547
  /**
2436
2548
  * Sanitize HTML string to prevent XSS attacks
2437
2549
  * Uses blacklist approach with repeated application to prevent nested tag bypass
2550
+ * Handles encoded characters (HTML entities, Unicode escapes) to prevent bypass attacks
2438
2551
  * @param {string} str Target string value
2439
2552
  * @returns {string} Sanitized string with dangerous elements removed
2440
2553
  * @private
2441
2554
  */
2442
2555
  function sanitize(str) {
2556
+ // Early return for non-string, empty string, or string without HTML
2443
2557
  if (!isString(str) || !str || str.indexOf("<") === -1) {
2444
2558
  return str;
2445
2559
  }
2446
2560
  var result = str;
2447
2561
  var prev;
2562
+ var iterations = 0;
2448
2563
  // Repeat until no more changes (prevents nested tag attacks like <scri<script>pt>)
2449
2564
  do {
2450
2565
  prev = result;
2451
- result = result
2452
- .replace(sanitizeRx.tags, "")
2453
- .replace(sanitizeRx.eventHandlers, "")
2454
- .replace(sanitizeRx.dangerousURIs, "$1=\"\"");
2566
+ // 1. Decode HTML entities to prevent bypass (e.g., jav&#x0A;ascript:)
2567
+ // 2. Remove control characters (NULL, tab, newline, etc.)
2568
+ // 3. Remove dangerous tags (script, iframe, etc.)
2569
+ result = _sanitize.decodeEntities(result)
2570
+ .replace(_sanitize.rx.controlChar, "")
2571
+ .replace(_sanitize.rx.tags, "")
2572
+ .replace(_sanitize.rx.eventHandler, ""); // 4. Remove event handlers
2573
+ // 5. Remove dangerous URIs (javascript:, data:, vbscript:)
2574
+ result = _sanitize.removeDangerousUris(result);
2575
+ // Safety check to prevent infinite loops
2576
+ if (++iterations >= _sanitize.MAX_ITERATIONS) {
2577
+ break;
2578
+ }
2455
2579
  } while (result !== prev);
2456
2580
  return result;
2457
2581
  }
2458
2582
  /**
2459
- * Set text value. If there's multiline add nodes.
2583
+ * Set text value. If there're multiline add nodes.
2460
2584
  * @param {d3Selection} node Text node
2461
2585
  * @param {string} text Text value string
2462
2586
  * @param {Array} dy dy value for multilined text
@@ -2566,28 +2690,6 @@ function getBrushSelection(ctx) {
2566
2690
  }
2567
2691
  return selection;
2568
2692
  }
2569
- /**
2570
- * Get boundingClientRect.
2571
- * Cache the evaluated value once it was called.
2572
- * @param {boolean} relativeViewport Relative to viewport - true: will use .getBoundingClientRect(), false: will use .getBBox()
2573
- * @param {SVGElement} node Target element
2574
- * @param {boolean} forceEval Force evaluation
2575
- * @returns {object}
2576
- * @private
2577
- */
2578
- function getRect(relativeViewport, node, forceEval) {
2579
- if (forceEval === void 0) { forceEval = false; }
2580
- var _ = function (n) { return n[relativeViewport ? "getBoundingClientRect" : "getBBox"](); };
2581
- if (forceEval) {
2582
- return _(node);
2583
- }
2584
- else {
2585
- // will cache the value if the element is not a SVGElement or the width is not set
2586
- var needEvaluate = !("rect" in node) || ("rect" in node && node.hasAttribute("width") &&
2587
- node.rect.width !== +(node.getAttribute("width") || 0));
2588
- return needEvaluate ? (node.rect = _(node)) : node.rect;
2589
- }
2590
- }
2591
2693
  /**
2592
2694
  * Get boundingClientRect.
2593
2695
  * @param {SVGElement} node Target element
@@ -2597,7 +2699,7 @@ function getRect(relativeViewport, node, forceEval) {
2597
2699
  */
2598
2700
  function getBoundingRect(node, forceEval) {
2599
2701
  if (forceEval === void 0) { forceEval = false; }
2600
- return getRect(true, node, forceEval);
2702
+ return _getRect(true, node, forceEval);
2601
2703
  }
2602
2704
  /**
2603
2705
  * Get BBox.
@@ -2608,7 +2710,7 @@ function getBoundingRect(node, forceEval) {
2608
2710
  */
2609
2711
  function getBBox(node, forceEval) {
2610
2712
  if (forceEval === void 0) { forceEval = false; }
2611
- return getRect(false, node, forceEval);
2713
+ return _getRect(false, node, forceEval);
2612
2714
  }
2613
2715
  /**
2614
2716
  * Retrun random number
@@ -3117,8 +3219,8 @@ function convertInputType(mouse, touch) {
3117
3219
  }
3118
3220
  /**
3119
3221
  * Run function until given condition function return true
3120
- * @param {Function} fn Function to be executed when condition is true
3121
- * @param {Function} conditionFn Condition function to check if condition is true
3222
+ * @param {function} fn Function to be executed when condition is true
3223
+ * @param {function(): boolean} conditionFn Condition function to check if condition is true
3122
3224
  * @private
3123
3225
  */
3124
3226
  function runUntil(fn, conditionFn) {
@@ -3149,6 +3251,67 @@ function parseShorthand(value) {
3149
3251
  var a = values[0], _a = values[1], b = _a === void 0 ? a : _a, _b = values[2], c = _b === void 0 ? a : _b, _c = values[3], d = _c === void 0 ? b : _c;
3150
3252
  return { top: a, right: b, bottom: c, left: d };
3151
3253
  }
3254
+ /**
3255
+ * Schedule a RAF update to batch multiple redraw requests
3256
+ * Manages a RAF state object to intelligently batch rapid updates while ensuring
3257
+ * immediate execution for the first call (for test compatibility)
3258
+ * @param {object} rafState RAF state object with pendingRaf property
3259
+ * @param {number|null} rafState.pendingRaf ID of pending RAF or null
3260
+ * @param {function} callback Function to execute in RAF
3261
+ * @returns {void}
3262
+ * @private
3263
+ */
3264
+ function scheduleRAFUpdate(rafState, callback) {
3265
+ // If there's already a pending RAF, we're in a rapid update scenario
3266
+ // Cancel it and schedule a new one to batch the updates
3267
+ if (rafState.pendingRaf !== null) {
3268
+ win.cancelAnimationFrame(rafState.pendingRaf);
3269
+ // Schedule new RAF
3270
+ rafState.pendingRaf = win.requestAnimationFrame(function () {
3271
+ rafState.pendingRaf = null;
3272
+ callback();
3273
+ });
3274
+ }
3275
+ else {
3276
+ // First call - execute immediately for test compatibility
3277
+ // But set pending RAF to detect rapid consecutive calls
3278
+ rafState.pendingRaf = win.requestAnimationFrame(function () {
3279
+ rafState.pendingRaf = null;
3280
+ });
3281
+ callback();
3282
+ }
3283
+ }
3284
+ /**
3285
+ * Convert an array to a Set by applying a key extractor
3286
+ * @param {Array} items Array of items to convert to Set
3287
+ * @param {function} keyFn Function to extract key from each item (item, index) => key. Defaults to identity function
3288
+ * @returns {Set} Set with extracted keys
3289
+ * @private
3290
+ */
3291
+ function toSet(items, keyFn) {
3292
+ if (keyFn === void 0) { keyFn = (function (item) { return item; }); }
3293
+ var set = new Set();
3294
+ _forEachValidItem(items, function (item, i) {
3295
+ set.add(keyFn(item, i));
3296
+ });
3297
+ return set;
3298
+ }
3299
+ /**
3300
+ * Convert an array to a Map by applying key and value extractors
3301
+ * @param {Array} items Array of items to convert to Map
3302
+ * @param {function} keyFn Function to extract key from each item (item, index) => key
3303
+ * @param {function} valueFn Function to extract value from each item (item, index) => value. Defaults to identity function
3304
+ * @returns {Map} Map with extracted keys and values
3305
+ * @private
3306
+ */
3307
+ function toMap(items, keyFn, valueFn) {
3308
+ if (valueFn === void 0) { valueFn = (function (item) { return item; }); }
3309
+ var map = new Map();
3310
+ _forEachValidItem(items, function (item, i) {
3311
+ map.set(keyFn(item, i), valueFn(item, i));
3312
+ });
3313
+ return map;
3314
+ }
3152
3315
 
3153
3316
  /**
3154
3317
  * Class to set options on generating chart.
@@ -3276,6 +3439,10 @@ var State = /** @class */ (function () {
3276
3439
  hasTreemap: false,
3277
3440
  // for data CSS rule index (used when boost.useCssRule is true)
3278
3441
  cssRule: {},
3442
+ // Data loading state (used in scale calculation)
3443
+ loading: undefined,
3444
+ // Zoom/subchart domain (different from current.domain which is for rendering)
3445
+ domain: undefined,
3279
3446
  current: {
3280
3447
  // current domain value. Assigned when is zoom is called
3281
3448
  domain: undefined,
@@ -3377,7 +3544,10 @@ var State = /** @class */ (function () {
3377
3544
  x2: null,
3378
3545
  y1: null,
3379
3546
  y2: null
3380
- }
3547
+ },
3548
+ // RAF batching for zoom/drag interactions
3549
+ pendingRaf: null,
3550
+ rafBatchQueue: []
3381
3551
  };
3382
3552
  }
3383
3553
  return State;
@@ -3422,12 +3592,16 @@ var KEY = {
3422
3592
  dataMinMax: "$dataMinMax",
3423
3593
  dataTotalSum: "$dataTotalSum",
3424
3594
  dataTotalPerIndex: "$totalPerIndex",
3595
+ filteredTargets: "$filteredTargets",
3596
+ visibilityChecksum: "visibilityChecksum",
3425
3597
  legendItemTextBox: "legendItemTextBox",
3598
+ legendItemMap: "$legendItemMap",
3426
3599
  radarPoints: "$radarPoints",
3427
3600
  radarTextWidth: "$radarTextWidth",
3428
3601
  setOverOut: "setOverOut",
3429
3602
  callOverOutForTouch: "callOverOutForTouch",
3430
- textRect: "textRect"
3603
+ textRect: "textRect",
3604
+ shapeOffset: "$shapeOffset"
3431
3605
  };
3432
3606
  var Cache = /** @class */ (function () {
3433
3607
  function Cache() {
@@ -3436,9 +3610,9 @@ var Cache = /** @class */ (function () {
3436
3610
  /**
3437
3611
  * Add cache
3438
3612
  * @param {string} key Cache key
3439
- * @param {*} value Value to be stored
3613
+ * @param {string|number|boolean|object|Array|function|null|undefined} value Value to be stored
3440
3614
  * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
3441
- * @returns {*} Added data value
3615
+ * @returns {string|number|boolean|object|Array|function|null|undefined} Added data value
3442
3616
  * @private
3443
3617
  */
3444
3618
  Cache.prototype.add = function (key, value, isDataType) {
@@ -3460,7 +3634,7 @@ var Cache = /** @class */ (function () {
3460
3634
  * Get cahce
3461
3635
  * @param {string|Array} key Cache key
3462
3636
  * @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
3463
- * @returns {*}
3637
+ * @returns {string|number|boolean|object|Array|function|null} Cached value
3464
3638
  * @private
3465
3639
  */
3466
3640
  Cache.prototype.get = function (key, isDataType) {
@@ -3480,6 +3654,23 @@ var Cache = /** @class */ (function () {
3480
3654
  return isValue(value) ? value : null;
3481
3655
  }
3482
3656
  };
3657
+ /**
3658
+ * Check if cache key exists
3659
+ * @param {string} key Cache key
3660
+ * @returns {boolean} True if key exists in cache
3661
+ * @private
3662
+ */
3663
+ Cache.prototype.has = function (key) {
3664
+ return key in this.cache && this.cache[key] !== null;
3665
+ };
3666
+ /**
3667
+ * Get all cache keys
3668
+ * @returns {string[]} Array of cache keys
3669
+ * @private
3670
+ */
3671
+ Cache.prototype.getKeys = function () {
3672
+ return Object.keys(this.cache);
3673
+ };
3483
3674
  /**
3484
3675
  * Reset cached data
3485
3676
  * @param {boolean} all true: reset all data, false: reset only '$' prefixed key data
@@ -3693,7 +3884,7 @@ function generateResize(option) {
3693
3884
  }
3694
3885
  /**
3695
3886
  * Generate transition queue function
3696
- * @returns {Function}
3887
+ * @returns {function}
3697
3888
  * @private
3698
3889
  */
3699
3890
  function generateWait() {
@@ -3745,7 +3936,7 @@ function generateWait() {
3745
3936
  var blob = {};
3746
3937
  /**
3747
3938
  * Get Object URL
3748
- * @param {Function} fn Function to be executed in worker
3939
+ * @param {function} fn Function to be executed in worker
3749
3940
  * @param {Array} depsFn Dependency functions to run given function(fn).
3750
3941
  * @returns {string}
3751
3942
  * @private
@@ -3782,8 +3973,8 @@ function getWorker(src) {
3782
3973
  /**
3783
3974
  * Create and run on Web Worker
3784
3975
  * @param {boolean} useWorker Use Web Worker
3785
- * @param {Function} fn Function to be executed in worker
3786
- * @param {Function} callback Callback function to receive result from worker
3976
+ * @param {function} fn Function to be executed in worker
3977
+ * @param {function} callback Callback function to receive result from worker
3787
3978
  * @param {Array} depsFn Dependency functions to run given function(fn).
3788
3979
  * @returns {object}
3789
3980
  * @example
@@ -3955,7 +4146,7 @@ function json(json, keysParam) {
3955
4146
  * @param {string} mimeType MIME type string: json | csv | tsv
3956
4147
  * @param {object} headers Header object
3957
4148
  * @param {object} keys Key object
3958
- * @param {Function} done Callback function
4149
+ * @param {function} done Callback function
3959
4150
  * @private
3960
4151
  */
3961
4152
  function url(url, mimeType, headers, keys, done) {
@@ -4026,7 +4217,7 @@ function tsv(tsv) {
4026
4217
  * @returns {string} Data key
4027
4218
  * @private
4028
4219
  */
4029
- function getDataKeyForJson(keysParam, config) {
4220
+ function _getDataKeyForJson(keysParam, config) {
4030
4221
  var keys = keysParam || (config === null || config === void 0 ? void 0 : config.data_keys);
4031
4222
  if (keys === null || keys === void 0 ? void 0 : keys.x) {
4032
4223
  config.data_x = keys.x;
@@ -4045,7 +4236,7 @@ function getDataKeyForJson(keysParam, config) {
4045
4236
  * @param {boolean} params.customX Whether the x is custom
4046
4237
  * @private
4047
4238
  */
4048
- function setXS(ids, data, params) {
4239
+ function _setXS(ids, data, params) {
4049
4240
  var _this = this;
4050
4241
  var $$ = this;
4051
4242
  var config = $$.config;
@@ -4091,7 +4282,7 @@ var dataConvert = {
4091
4282
  /**
4092
4283
  * Convert data according its type
4093
4284
  * @param {object} args data object
4094
- * @param {Function} [callback] callback for url(XHR) type loading
4285
+ * @param {function} [callback] callback for url(XHR) type loading
4095
4286
  * @private
4096
4287
  */
4097
4288
  convertData: function (args, callback) {
@@ -4109,10 +4300,10 @@ var dataConvert = {
4109
4300
  });
4110
4301
  }
4111
4302
  if (data.url && callback) {
4112
- url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config), callback);
4303
+ url(data.url, data.mimeType, data.headers, _getDataKeyForJson(data.keys, config), callback);
4113
4304
  }
4114
4305
  else if (data.json) {
4115
- runWorker(useWorker(data.json), json, callback, [columns, rows])(data.json, getDataKeyForJson(data.keys, config));
4306
+ runWorker(useWorker(data.json), json, callback, [columns, rows])(data.json, _getDataKeyForJson(data.keys, config));
4116
4307
  }
4117
4308
  else if (data.rows) {
4118
4309
  runWorker(useWorker(data.rows), rows, callback)(data.rows);
@@ -4157,14 +4348,14 @@ var dataConvert = {
4157
4348
  customX: axis === null || axis === void 0 ? void 0 : axis.isCustomX()
4158
4349
  };
4159
4350
  // save x for update data by load when custom x and bb.x API
4160
- setXS.bind($$)(ids, data, params);
4351
+ _setXS.bind($$)(ids, data, params);
4161
4352
  // convert to target
4162
4353
  var targets = ids.map(function (id, index) {
4163
4354
  var convertedId = config.data_idConverter.bind($$.api)(id);
4164
4355
  var xKey = $$.getXKey(id);
4165
4356
  var isCategory = params.customX && params.categorized;
4166
4357
  var hasCategory = isCategory && (function () {
4167
- var categorySet = new Set(config.axis_x_categories);
4358
+ var categorySet = toSet(config.axis_x_categories);
4168
4359
  return data.every(function (v) { return categorySet.has(v.x); });
4169
4360
  })();
4170
4361
  // when .load() with 'append' option is used for indexed axis
@@ -4254,7 +4445,21 @@ var data$1 = {
4254
4445
  },
4255
4446
  isStackNormalized: function () {
4256
4447
  var config = this.config;
4257
- return !!(config.data_stack_normalize && config.data_groups.length);
4448
+ return !!((config.data_stack_normalize === true ||
4449
+ isObjectType(config.data_stack_normalize)) &&
4450
+ config.data_groups.length);
4451
+ },
4452
+ /**
4453
+ * Check if stack normalization should be applied per group
4454
+ * @returns {boolean}
4455
+ * @private
4456
+ */
4457
+ isStackNormalizedPerGroup: function () {
4458
+ var _a;
4459
+ var config = this.config;
4460
+ return !!(isObjectType(config.data_stack_normalize) &&
4461
+ ((_a = config.data_stack_normalize) === null || _a === void 0 ? void 0 : _a.perGroup) &&
4462
+ config.data_groups.length);
4258
4463
  },
4259
4464
  /**
4260
4465
  * Check if given id is grouped data or has grouped data
@@ -4266,6 +4471,23 @@ var data$1 = {
4266
4471
  var groups = this.config.data_groups;
4267
4472
  return id ? groups.some(function (v) { return v.indexOf(id) >= 0 && v.length > 1; }) : groups.length > 0;
4268
4473
  },
4474
+ /**
4475
+ * Check if the given axis has any grouped data
4476
+ * @param {string} axisId Axis ID (e.g., "y", "y2")
4477
+ * @returns {boolean} true if axis has grouped data
4478
+ * @private
4479
+ */
4480
+ hasAxisGroupedData: function (axisId) {
4481
+ var $$ = this;
4482
+ var axis = $$.axis;
4483
+ var targets = $$.data.targets;
4484
+ // Get all data IDs that belong to this axis
4485
+ var axisDataIds = targets
4486
+ .filter(function (t) { return axis.getId(t.id) === axisId; })
4487
+ .map(function (t) { return t.id; });
4488
+ // Check if any of the axis data IDs are in groups
4489
+ return axisDataIds.some(function (id) { return $$.isGrouped(id); });
4490
+ },
4269
4491
  getXKey: function (id) {
4270
4492
  var $$ = this;
4271
4493
  var config = $$.config;
@@ -4476,16 +4698,33 @@ var data$1 = {
4476
4698
  },
4477
4699
  /**
4478
4700
  * Get sum of data per index
4701
+ * @param {string} targetId Target ID to get total for (only for normalized stack per group)
4479
4702
  * @private
4480
4703
  * @returns {Array}
4481
4704
  */
4482
- getTotalPerIndex: function () {
4705
+ getTotalPerIndex: function (targetId) {
4483
4706
  var $$ = this;
4484
- var cacheKey = KEY.dataTotalPerIndex;
4707
+ var config = $$.config;
4708
+ var cacheKey = targetId ? "".concat(KEY.dataTotalPerIndex, "-").concat(targetId) : KEY.dataTotalPerIndex;
4485
4709
  var sum = $$.cache.get(cacheKey);
4486
4710
  if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
4487
4711
  sum = [];
4488
- $$.data.targets.forEach(function (row) {
4712
+ // When normalize per group is enabled and targetId is provided,
4713
+ // only sum data within the same group
4714
+ var targets = $$.data.targets;
4715
+ if ($$.isStackNormalizedPerGroup() && targetId) {
4716
+ // Find which group the target belongs to
4717
+ var group_1 = config.data_groups.find(function (g) { return g.indexOf(targetId) >= 0; });
4718
+ if (group_1) {
4719
+ // Only sum targets in the same group
4720
+ targets = targets.filter(function (t) { return group_1.indexOf(t.id) >= 0; });
4721
+ }
4722
+ else {
4723
+ // If target is not in any group, return null to indicate no normalization
4724
+ return null;
4725
+ }
4726
+ }
4727
+ targets.forEach(function (row) {
4489
4728
  row.values.forEach(function (v, i) {
4490
4729
  if (!sum[i]) {
4491
4730
  sum[i] = 0;
@@ -4493,6 +4732,7 @@ var data$1 = {
4493
4732
  sum[i] += ~~v.value;
4494
4733
  });
4495
4734
  });
4735
+ $$.cache.add(cacheKey, sum);
4496
4736
  }
4497
4737
  return sum;
4498
4738
  },
@@ -4508,7 +4748,7 @@ var data$1 = {
4508
4748
  var total = $$.cache.get(cacheKey);
4509
4749
  if (!isNumber(total)) {
4510
4750
  total = $$.data.targets.reduce(function (acc, t) {
4511
- return acc + t.values.reduce(function (sum, v) { return sum + ~~v.value; }, 0);
4751
+ return acc + t.values.reduce(function (sum, v) { var _a; return sum + ((_a = v.value) !== null && _a !== void 0 ? _a : 0); }, 0);
4512
4752
  }, 0);
4513
4753
  $$.cache.add(cacheKey, total);
4514
4754
  }
@@ -4594,7 +4834,28 @@ var data$1 = {
4594
4834
  },
4595
4835
  filterTargetsToShow: function (targets) {
4596
4836
  var $$ = this;
4597
- return (targets || $$.data.targets).filter(function (t) { return $$.isTargetToShow(t.id); });
4837
+ // When called without arguments, use caching
4838
+ if (!targets) {
4839
+ var cache = $$.cache, data = $$.data, state = $$.state;
4840
+ var cacheKey = KEY.filteredTargets;
4841
+ var visibilityChecksum = state.hiddenTargetIds.join(",");
4842
+ var storedChecksum = cache.get(KEY.visibilityChecksum);
4843
+ // Invalidate cache if visibility changed
4844
+ if (visibilityChecksum !== storedChecksum) {
4845
+ cache.remove(cacheKey);
4846
+ cache.add(KEY.visibilityChecksum, visibilityChecksum);
4847
+ }
4848
+ // Return cached result if available
4849
+ if (cache.has(cacheKey)) {
4850
+ return cache.get(cacheKey);
4851
+ }
4852
+ // Compute and cache result (store the filtered array)
4853
+ var filtered = data.targets.filter(function (t) { return $$.isTargetToShow(t.id); });
4854
+ cache.add(cacheKey, filtered);
4855
+ return filtered;
4856
+ }
4857
+ // When called with custom targets, don't cache
4858
+ return targets.filter(function (t) { return $$.isTargetToShow(t.id); });
4598
4859
  },
4599
4860
  mapTargetsToUniqueXs: function (targets) {
4600
4861
  var $$ = this;
@@ -4607,7 +4868,7 @@ var data$1 = {
4607
4868
  return sortValue(xs);
4608
4869
  },
4609
4870
  /**
4610
- * Add to the state target Ids
4871
+ * Add to thetarget Ids
4611
4872
  * @param {string} type State's prop name
4612
4873
  * @param {Array|string} targetIds Target ids array
4613
4874
  * @private
@@ -4655,6 +4916,8 @@ var data$1 = {
4655
4916
  $$.mapTargetsToUniqueXs(targets)
4656
4917
  .map(function (v) { return (isString(v) ? v : +v); }) :
4657
4918
  null;
4919
+ // Create xIndexMap for O(1) lookup instead of O(n) indexOf in getIndexByX
4920
+ var xIndexMap = xs ? new Map(xs.map(function (x, i) { return [x, i]; })) : null;
4658
4921
  targets.forEach(function (t) {
4659
4922
  var data = [];
4660
4923
  t.values
@@ -4680,8 +4943,13 @@ var data$1 = {
4680
4943
  data.push(hasAxis && $$.getBubbleZData(value, "y"));
4681
4944
  }
4682
4945
  else {
4683
- if (isMultipleX) {
4684
- data[$$.getIndexByX(v.x, xs)] = value;
4946
+ if (isMultipleX && xIndexMap) {
4947
+ // Use Map for O(1) lookup instead of getIndexByX which uses indexOf
4948
+ var xKey = isString(v.x) ? v.x : +v.x;
4949
+ var index = xIndexMap.get(xKey);
4950
+ if (index !== undefined) {
4951
+ data[index] = value;
4952
+ }
4685
4953
  }
4686
4954
  else {
4687
4955
  data.push(value);
@@ -4722,7 +4990,7 @@ var data$1 = {
4722
4990
  /**
4723
4991
  * Get data.order compare function
4724
4992
  * @param {boolean} isReversed for Arc & Treemap type sort order needs to be reversed
4725
- * @returns {Function} compare function
4993
+ * @returns {function} compare function
4726
4994
  * @private
4727
4995
  */
4728
4996
  getSortCompareFn: function (isReversed) {
@@ -5037,13 +5305,30 @@ var data$1 = {
5037
5305
  }
5038
5306
  else if (type === "index") {
5039
5307
  var dataValues = api.data.values.bind(api);
5040
- var total = this.getTotalPerIndex();
5041
- if (state.hiddenTargetIds.length) {
5042
- var hiddenSum_1 = dataValues(state.hiddenTargetIds, false);
5043
- if (hiddenSum_1.length) {
5044
- hiddenSum_1 = hiddenSum_1
5045
- .reduce(function (acc, curr) { return acc.map(function (v, i) { return ~~v + curr[i]; }); });
5046
- total = total.map(function (v, i) { return v - hiddenSum_1[i]; });
5308
+ var hiddenTargetIds = state.hiddenTargetIds;
5309
+ // For normalized stack per group, get total per group
5310
+ var total = this.getTotalPerIndex($$.isStackNormalizedPerGroup() ? d.id : undefined);
5311
+ // If total is null, the data is not in any group - don't normalize
5312
+ if (total === null) {
5313
+ return ratio;
5314
+ }
5315
+ if (hiddenTargetIds.length) {
5316
+ // When normalized per group, only subtract hidden data from the same group
5317
+ var hiddenIds = hiddenTargetIds;
5318
+ if ($$.isStackNormalizedPerGroup() && d.id) {
5319
+ var group_2 = config.data_groups.find(function (g) { return g.indexOf(d.id) >= 0; });
5320
+ if (group_2) {
5321
+ // Only consider hidden IDs in the same group
5322
+ hiddenIds = hiddenIds.filter(function (id) { return group_2.indexOf(id) >= 0; });
5323
+ }
5324
+ }
5325
+ if (hiddenIds.length) {
5326
+ var hiddenSum_1 = dataValues(hiddenIds, false);
5327
+ if (hiddenSum_1.length) {
5328
+ hiddenSum_1 = hiddenSum_1
5329
+ .reduce(function (acc, curr) { return acc.map(function (v, i) { return ~~v + curr[i]; }); });
5330
+ total = total.map(function (v, i) { return v - hiddenSum_1[i]; });
5331
+ }
5047
5332
  }
5048
5333
  }
5049
5334
  var divisor = total[d.index];
@@ -5128,7 +5413,7 @@ var data$1 = {
5128
5413
  */
5129
5414
  /**
5130
5415
  * Call done callback with resize after transition
5131
- * @param {Function} fn Callback function
5416
+ * @param {function} fn Callback function
5132
5417
  * @param {boolean} resizeAfter Weather to resize chart after the load
5133
5418
  * @private
5134
5419
  */
@@ -5250,11 +5535,6 @@ var dataLoad = {
5250
5535
  done();
5251
5536
  return;
5252
5537
  }
5253
- var targets = $el.svg.selectAll(targetIds.map(function (id) { return $$.selectorTarget(id); }));
5254
- $T(targets)
5255
- .style("opacity", "0")
5256
- .remove()
5257
- .call(endall, done);
5258
5538
  targetIds.forEach(function (id) {
5259
5539
  var _a;
5260
5540
  var suffixId = $$.getTargetSelectorSuffix(id);
@@ -5275,6 +5555,11 @@ var dataLoad = {
5275
5555
  state.hasTreemap && $$.updateTargetsForTreemap($$.data.targets);
5276
5556
  // Update current state chart type and elements list after redraw
5277
5557
  $$.updateTypesElements();
5558
+ var targets = $el.svg.selectAll(targetIds.map(function (id) { return $$.selectorTarget(id); }));
5559
+ $T(targets)
5560
+ .style("opacity", "0")
5561
+ .remove()
5562
+ .call(endall, done);
5278
5563
  }
5279
5564
  };
5280
5565
 
@@ -5394,7 +5679,7 @@ var interaction = {
5394
5679
  },
5395
5680
  /**
5396
5681
  * Return draggable selection function
5397
- * @returns {Function}
5682
+ * @returns {function}
5398
5683
  * @private
5399
5684
  */
5400
5685
  getDraggableSelection: function () {
@@ -5649,7 +5934,7 @@ var classModule = {
5649
5934
  * @returns {{id: string, node: SVGPatternElement}}
5650
5935
  * @private
5651
5936
  */
5652
- var colorizePattern = function (pattern, color, id) {
5937
+ var _colorizePattern = function (pattern, color, id) {
5653
5938
  var node = select(pattern.cloneNode(true));
5654
5939
  node
5655
5940
  .attr("id", id)
@@ -5669,7 +5954,7 @@ var colorizePattern = function (pattern, color, id) {
5669
5954
  * @returns {Array}
5670
5955
  * @private
5671
5956
  */
5672
- function getColorFromCss(element) {
5957
+ function _getColorFromCss(element) {
5673
5958
  var cacheKey = KEY.colorPattern;
5674
5959
  var body = doc.body;
5675
5960
  var pattern = body[cacheKey];
@@ -5709,9 +5994,11 @@ var color = {
5709
5994
  var $$ = this;
5710
5995
  var $el = $$.$el, config = $$.config;
5711
5996
  var ids = [];
5997
+ var hasGradient = config.area_linearGradient || config.bar_linearGradient ||
5998
+ config.point_radialGradient;
5712
5999
  var pattern = notEmpty(config.color_pattern) ?
5713
6000
  config.color_pattern :
5714
- scaleOrdinal(getColorFromCss($el.chart) || schemeCategory10).range();
6001
+ scaleOrdinal(_getColorFromCss($el.chart) || schemeCategory10).range();
5715
6002
  var originalColorPattern = pattern;
5716
6003
  if (isFunction(config.color_tiles)) {
5717
6004
  var tiles_1 = config.color_tiles.bind($$.api)();
@@ -5719,7 +6006,7 @@ var color = {
5719
6006
  var colorizedPatterns = pattern.map(function (p, index) {
5720
6007
  var color = p.replace(/[#\(\)\s,]/g, "");
5721
6008
  var id = "".concat($$.state.datetimeId, "-pattern-").concat(color, "-").concat(index);
5722
- return colorizePattern(tiles_1[index % tiles_1.length], p, id);
6009
+ return _colorizePattern(tiles_1[index % tiles_1.length], p, id);
5723
6010
  });
5724
6011
  pattern = colorizedPatterns.map(function (p) { return "url(#".concat(p.id, ")"); });
5725
6012
  $$.patterns = colorizedPatterns;
@@ -5736,13 +6023,13 @@ var color = {
5736
6023
  // if callback function is provided
5737
6024
  if (isFunction(colors[id])) {
5738
6025
  color = colors[id].bind($$.api)(d);
5739
- // if specified, choose that color
5740
6026
  }
5741
6027
  else if (colors[id]) {
6028
+ // if specified, choose that color
5742
6029
  color = colors[id];
5743
- // if not specified, choose from pattern
5744
6030
  }
5745
6031
  else {
6032
+ // if not specified, choose from pattern
5746
6033
  if (ids.indexOf(id) < 0) {
5747
6034
  ids.push(id);
5748
6035
  }
@@ -5751,7 +6038,18 @@ var color = {
5751
6038
  pattern[ids.indexOf(id) % pattern.length];
5752
6039
  colors[id] = color;
5753
6040
  }
5754
- return isFunction(callback) ? callback.bind($$.api)(color, d) : color;
6041
+ color = isFunction(callback) ? callback.call($$.api, color, d) : color;
6042
+ if (hasGradient) {
6043
+ var stop_1 = $$.$el.defs.selectAll("[id$='-gradient".concat($$.getTargetSelectorSuffix(id), "'] stop"));
6044
+ var hasSameColor_1;
6045
+ stop_1.each(function (d, i) {
6046
+ hasSameColor_1 = i === 0 ?
6047
+ this.style.stopColor :
6048
+ this.style.stopColor === hasSameColor_1;
6049
+ });
6050
+ hasSameColor_1 === true && stop_1.attr("stop-color", color);
6051
+ }
6052
+ return color;
5755
6053
  };
5756
6054
  },
5757
6055
  generateLevelColor: function () {
@@ -5781,7 +6079,7 @@ var color = {
5781
6079
  },
5782
6080
  /**
5783
6081
  * Append data backgound color filter definition
5784
- * @param {string|object|Function} color Color string, object, or function
6082
+ * @param {string|object|function} color Color string, object, or function
5785
6083
  * @param {object} attr filter attribute
5786
6084
  * @private
5787
6085
  */
@@ -5920,16 +6218,19 @@ var domain = {
5920
6218
  var isMin = type === "min";
5921
6219
  var dataGroups = config.data_groups;
5922
6220
  var ids = $$.mapToIds(targets);
6221
+ var idsSet = toSet(ids); // O(1) lookup instead of O(n) indexOf
5923
6222
  var ys = $$.getValuesAsIdKeyed(targets);
5924
6223
  if (dataGroups.length > 0) {
5925
6224
  var hasValue_1 = $$["has".concat(isMin ? "Negative" : "Positive", "ValueInTargets")](targets);
6225
+ // Pre-compute axis IDs for O(1) lookup instead of repeated axis.getId() calls
6226
+ var axisIdMap_1 = new Map(ids.map(function (id) { return [id, axis.getId(id)]; }));
5926
6227
  dataGroups.forEach(function (groupIds) {
5927
6228
  // Determine baseId
5928
6229
  var idsInGroup = groupIds
5929
- .filter(function (v) { return ids.indexOf(v) >= 0; });
6230
+ .filter(function (v) { return idsSet.has(v); });
5930
6231
  if (idsInGroup.length) {
5931
6232
  var baseId_1 = idsInGroup[0];
5932
- var baseAxisId_1 = axis.getId(baseId_1);
6233
+ var baseAxisId_1 = axisIdMap_1.get(baseId_1);
5933
6234
  // Initialize base value. Set to 0 if not match with the condition
5934
6235
  if (hasValue_1 && ys[baseId_1]) {
5935
6236
  ys[baseId_1] = ys[baseId_1]
@@ -5939,7 +6240,7 @@ var domain = {
5939
6240
  .filter(function (v, i) { return i > 0; })
5940
6241
  .forEach(function (id) {
5941
6242
  if (ys[id]) {
5942
- var axisId_1 = axis.getId(id);
6243
+ var axisId_1 = axisIdMap_1.get(id);
5943
6244
  ys[id].forEach(function (v, i) {
5944
6245
  var val = +v;
5945
6246
  var meetCondition = isMin ? val > 0 : val < 0;
@@ -5969,8 +6270,18 @@ var domain = {
5969
6270
  var $$ = this;
5970
6271
  var axis = $$.axis, config = $$.config, scale = $$.scale;
5971
6272
  var pfx = "axis_".concat(axisId);
6273
+ // Check if stack normalization should be applied for this axis
5972
6274
  if ($$.isStackNormalized()) {
5973
- return [0, 100];
6275
+ // Get all data IDs that belong to this axis
6276
+ var axisDataIds = targets
6277
+ .filter(function (t) { return axis.getId(t.id) === axisId; })
6278
+ .map(function (t) { return t.id; });
6279
+ // Check if any of the axis data IDs are in groups
6280
+ var hasGroupedData = axisDataIds.some(function (id) { return $$.isGrouped(id); });
6281
+ // Apply normalization only if this axis has grouped data
6282
+ if (hasGroupedData) {
6283
+ return [0, 100];
6284
+ }
5974
6285
  }
5975
6286
  var isLog = (scale === null || scale === void 0 ? void 0 : scale[axisId]) && scale[axisId].type === "log";
5976
6287
  var targetsByAxisId = targets.filter(function (t) { return axis.getId(t.id) === axisId; });
@@ -6316,7 +6627,7 @@ var domain = {
6316
6627
  * @returns {number | string}
6317
6628
  * @private
6318
6629
  */
6319
- function getFormat($$, typeValue, v) {
6630
+ function _getFormat($$, typeValue, v) {
6320
6631
  var config = $$.config;
6321
6632
  var type = "axis_".concat(typeValue, "_tick_format");
6322
6633
  var format = config[type] ? config[type] : $$.defaultValueFormat;
@@ -6324,14 +6635,14 @@ function getFormat($$, typeValue, v) {
6324
6635
  }
6325
6636
  var format = {
6326
6637
  yFormat: function (v) {
6327
- return getFormat(this, "y", v);
6638
+ return _getFormat(this, "y", v);
6328
6639
  },
6329
6640
  y2Format: function (v) {
6330
- return getFormat(this, "y2", v);
6641
+ return _getFormat(this, "y2", v);
6331
6642
  },
6332
6643
  /**
6333
6644
  * Get default value format function
6334
- * @returns {Function} formatter function
6645
+ * @returns {function} formatter function
6335
6646
  * @private
6336
6647
  */
6337
6648
  getDefaultValueFormat: function () {
@@ -6391,11 +6702,12 @@ var format = {
6391
6702
  */
6392
6703
  /**
6393
6704
  * Get color string for given data id
6705
+ * Internal helper used only within this file
6394
6706
  * @param {string} id Data id
6395
6707
  * @returns {string} Color string
6396
6708
  * @private
6397
6709
  */
6398
- function getLegendColor(id) {
6710
+ function _getLegendColor(id) {
6399
6711
  var $$ = this;
6400
6712
  var data = $$.getDataById(id);
6401
6713
  var color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
@@ -6403,11 +6715,13 @@ function getLegendColor(id) {
6403
6715
  }
6404
6716
  /**
6405
6717
  * Get formatted text value
6718
+ * Internal helper used only within this file
6406
6719
  * @param {string} id Legend text id
6407
6720
  * @param {boolean} formatted Whether or not to format the text
6408
6721
  * @returns {string} Formatted legend text
6722
+ * @private
6409
6723
  */
6410
- function getFormattedText(id, formatted) {
6724
+ function _getFormattedText(id, formatted) {
6411
6725
  var _a;
6412
6726
  if (formatted === void 0) { formatted = true; }
6413
6727
  var config = this.config;
@@ -6417,6 +6731,27 @@ function getFormattedText(id, formatted) {
6417
6731
  }
6418
6732
  return text;
6419
6733
  }
6734
+ /**
6735
+ * Build a Map of legend items for fast O(1) lookup by ID
6736
+ * Internal helper used only within this file
6737
+ * @param {object} $$ ChartInternal context
6738
+ * @param {d3.selection} legendItems D3 selection of legend items
6739
+ * @private
6740
+ */
6741
+ function _buildLegendItemMap($$, legendItems) {
6742
+ if (!legendItems || legendItems.empty()) {
6743
+ return;
6744
+ }
6745
+ // Convert D3 selection to array of [id, node] pairs
6746
+ var items = [];
6747
+ legendItems.each(function (id) {
6748
+ items.push({ id: id, node: this });
6749
+ });
6750
+ // Create Map for O(1) lookups using toMap utility
6751
+ var itemMap = toMap(items, function (item) { return item.id; }, function (item) { return item.node; });
6752
+ // Cache the map
6753
+ $$.cache.add(KEY.legendItemMap, itemMap);
6754
+ }
6420
6755
  var legend$1 = {
6421
6756
  /**
6422
6757
  * Initialize the legend.
@@ -6590,10 +6925,15 @@ var legend$1 = {
6590
6925
  * @private
6591
6926
  */
6592
6927
  updateLegendItemColor: function (id, color) {
6593
- var legend = this.$el.legend;
6928
+ var $$ = this;
6929
+ var legend = $$.$el.legend;
6594
6930
  if (legend) {
6595
- legend.select(".".concat($LEGEND.legendItem, "-").concat(id, " line"))
6596
- .style("stroke", color);
6931
+ // Use cached Map lookup for O(1) performance
6932
+ var legendItem = $$.getLegendItemById(id);
6933
+ if (legendItem) {
6934
+ select(legendItem).select("line")
6935
+ .style("stroke", color);
6936
+ }
6597
6937
  }
6598
6938
  },
6599
6939
  /**
@@ -6803,6 +7143,26 @@ var legend$1 = {
6803
7143
  !item.empty() && item.on("click mouseout mouseover") &&
6804
7144
  item.style("cursor", $$.getStylePropValue("pointer"));
6805
7145
  }
7146
+ // Build legend item map for O(1) lookup
7147
+ _buildLegendItemMap($$, item);
7148
+ },
7149
+ /**
7150
+ * Get legend item node by ID using cached Map for O(1) lookup
7151
+ * Falls back to D3 selection if map is not available
7152
+ * @param {string} id Data ID
7153
+ * @returns {HTMLElement | null} Legend item node
7154
+ * @private
7155
+ */
7156
+ getLegendItemById: function (id) {
7157
+ var _a;
7158
+ var $$ = this;
7159
+ var itemMap = $$.cache.get(KEY.legendItemMap);
7160
+ if (itemMap && itemMap instanceof Map) {
7161
+ return itemMap.get(id) || null;
7162
+ }
7163
+ // Fallback to D3 selection (slower)
7164
+ var item = (_a = $$.$el.legend) === null || _a === void 0 ? void 0 : _a.selectAll(".".concat($LEGEND.legendItem)).filter(function (d) { return d === id; });
7165
+ return (item === null || item === void 0 ? void 0 : item.node()) || null;
6806
7166
  },
6807
7167
  /**
6808
7168
  * Update the legend
@@ -6885,11 +7245,11 @@ var legend$1 = {
6885
7245
  if (config.legend_tooltip) {
6886
7246
  legend.selectAll("title")
6887
7247
  .data(targetIdz)
6888
- .text(function (id) { return getFormattedText.bind($$)(id, false); });
7248
+ .text(function (id) { return _getFormattedText.bind($$)(id, false); });
6889
7249
  }
6890
7250
  var texts = legend.selectAll("text")
6891
7251
  .data(targetIdz)
6892
- .text(function (id) { return getFormattedText.bind($$)(id); }) // MEMO: needed for update
7252
+ .text(function (id) { return _getFormattedText.bind($$)(id); }) // MEMO: needed for update
6893
7253
  .each(function (id, i) {
6894
7254
  updatePositions(this, id, i);
6895
7255
  });
@@ -6920,7 +7280,7 @@ var legend$1 = {
6920
7280
  * @param {Array} targetIdz Data ids
6921
7281
  * @param {object} dimension Dimension object
6922
7282
  * @param {object} sizes Size object
6923
- * @returns {Function} Update position function
7283
+ * @returns {function} Update position function
6924
7284
  * @private
6925
7285
  */
6926
7286
  getUpdateLegendPositions: function (targetIdz, dimension, sizes) {
@@ -6997,7 +7357,7 @@ var legend$1 = {
6997
7357
  * Generate legend item elements
6998
7358
  * @param {Array} targetIdz Data ids
6999
7359
  * @param {object} itemTileSize Item tile size {width, height}
7000
- * @param {Function} updatePositions Update position function
7360
+ * @param {function} updatePositions Update position function
7001
7361
  * @param {object} posFn Position functions
7002
7362
  * @private
7003
7363
  */
@@ -7020,7 +7380,7 @@ var legend$1 = {
7020
7380
  l.append("title").text(function (id) { return id; });
7021
7381
  }
7022
7382
  l.append("text")
7023
- .text(function (id) { return getFormattedText.bind($$)(id); })
7383
+ .text(function (id) { return _getFormattedText.bind($$)(id); })
7024
7384
  .each(function (id, i) {
7025
7385
  updatePositions(this, id, i);
7026
7386
  })
@@ -7034,19 +7394,17 @@ var legend$1 = {
7034
7394
  .attr("y", isLegendRightOrInset ? pos : posFn.yRect);
7035
7395
  if (usePoint) {
7036
7396
  var ids_2 = [];
7397
+ var pattern_1 = $$.getValidPointPattern();
7037
7398
  l.append(function (d) {
7038
- var pattern = notEmpty(config.point_pattern) ?
7039
- config.point_pattern :
7040
- [config.point_type];
7041
7399
  ids_2.indexOf(d) === -1 && ids_2.push(d);
7042
- var point = pattern[ids_2.indexOf(d) % pattern.length];
7400
+ var point = pattern_1[ids_2.indexOf(d) % pattern_1.length];
7043
7401
  if (point === "rectangle") {
7044
7402
  point = "rect";
7045
7403
  }
7046
7404
  return doc.createElementNS(namespaces.svg, ("hasValidPointType" in $$) && $$.hasValidPointType(point) ? point : "use");
7047
7405
  })
7048
7406
  .attr("class", $LEGEND.legendItemPoint)
7049
- .style("fill", getLegendColor.bind($$))
7407
+ .style("fill", _getLegendColor.bind($$))
7050
7408
  .style("pointer-events", $$.getStylePropValue("none"))
7051
7409
  .attr("href", function (data, idx, selection) {
7052
7410
  var node = selection[idx];
@@ -7058,13 +7416,13 @@ var legend$1 = {
7058
7416
  else {
7059
7417
  l.append(isRectangle ? "line" : legendType)
7060
7418
  .attr("class", $LEGEND.legendItemTile)
7061
- .style("stroke", getLegendColor.bind($$))
7419
+ .style("stroke", _getLegendColor.bind($$))
7062
7420
  .style("pointer-events", $$.getStylePropValue("none"))
7063
7421
  .call(function (selection) {
7064
7422
  if (legendType === "circle") {
7065
7423
  selection
7066
7424
  .attr("r", legendItemR)
7067
- .style("fill", getLegendColor.bind($$))
7425
+ .style("fill", _getLegendColor.bind($$))
7068
7426
  .attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos)
7069
7427
  .attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
7070
7428
  }
@@ -7132,7 +7490,7 @@ var legend$1 = {
7132
7490
  var tiles = legend.selectAll(".".concat($LEGEND.legendItemTile))
7133
7491
  .data(targetIdz);
7134
7492
  $T(tiles, withTransition)
7135
- .style("stroke", getLegendColor.bind($$))
7493
+ .style("stroke", _getLegendColor.bind($$))
7136
7494
  .call(function (selection) {
7137
7495
  if (legendType === "circle") {
7138
7496
  selection
@@ -7392,8 +7750,8 @@ var scale = {
7392
7750
  * @param {number} min Min range value
7393
7751
  * @param {number} max Max range value
7394
7752
  * @param {Array} domain Domain value
7395
- * @param {Function} offset The offset getter to be sum
7396
- * @returns {Function} scale
7753
+ * @param {function} offset The offset getter to be sum
7754
+ * @returns {function} scale
7397
7755
  * @private
7398
7756
  */
7399
7757
  getXScale: function (min, max, domain, offset) {
@@ -7408,7 +7766,7 @@ var scale = {
7408
7766
  * @param {number} min Min value
7409
7767
  * @param {number} max Max value
7410
7768
  * @param {Array} domain Domain value
7411
- * @returns {Function} Scale function
7769
+ * @returns {function} Scale function
7412
7770
  * @private
7413
7771
  */
7414
7772
  getYScale: function (id, min, max, domain) {
@@ -7421,7 +7779,7 @@ var scale = {
7421
7779
  * Get y Axis scale
7422
7780
  * @param {string} id Axis id
7423
7781
  * @param {boolean} isSub Weather is sub Axis
7424
- * @returns {Function} Scale function
7782
+ * @returns {function} Scale function
7425
7783
  * @private
7426
7784
  */
7427
7785
  getYScaleById: function (id, isSub) {
@@ -7434,8 +7792,8 @@ var scale = {
7434
7792
  /**
7435
7793
  * Get customized x axis scale
7436
7794
  * @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
7437
- * @param {Function} offsetValue Offset getter to be sum
7438
- * @returns {Function} Scale function
7795
+ * @param {function} offsetValue Offset getter to be sum
7796
+ * @returns {function} Scale function
7439
7797
  * @private
7440
7798
  */
7441
7799
  getCustomizedXScale: function (scaleValue, offsetValue) {
@@ -7952,8 +8310,8 @@ var style = {
7952
8310
  * @param {boolean} withShape Set shpes' prefix class
7953
8311
  * @param {string} selector CSS selector
7954
8312
  * @param {Array} props CSS props list
7955
- * @param {Function} propsFn Function to retrieve value or determine for props
7956
- * @returns {Function}
8313
+ * @param {function} propsFn Function to retrieve value or determine for props
8314
+ * @returns {function}
7957
8315
  * @private
7958
8316
  */
7959
8317
  setCssRule: function (withShape, selector, props, propsFn) {
@@ -7972,7 +8330,7 @@ var style = {
7972
8330
  },
7973
8331
  /**
7974
8332
  * Get style prop value
7975
- * @param {Function|string} v Value
8333
+ * @param {function|string} v Value
7976
8334
  * @returns {string|null}
7977
8335
  * @private
7978
8336
  */
@@ -8228,6 +8586,18 @@ function updateTextImagePos(textNode, pos) {
8228
8586
  .attr("y", y);
8229
8587
  }
8230
8588
  }
8589
+ /**
8590
+ * Batch getBBox() calls to avoid layout thrashing
8591
+ * Collects all bbox calculations in a single read phase
8592
+ * @param {SVGTextElement[]} elements Array of text elements
8593
+ * @returns {Map<SVGTextElement, DOMRect>} Map of element to bbox
8594
+ * @private
8595
+ */
8596
+ function batchGetBBox(elements) {
8597
+ // Single read phase - batch all getBBox calls together
8598
+ // This prevents layout thrashing by avoiding interleaved reads/writes
8599
+ return toMap(elements, function (element) { return element; }, function (element) { return getBBox(element); });
8600
+ }
8231
8601
 
8232
8602
  /**
8233
8603
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -8325,7 +8695,7 @@ var text = {
8325
8695
  this.textContent = value;
8326
8696
  }
8327
8697
  else {
8328
- setTextValue(node, value);
8698
+ setTextValue(node, value, undefined, true);
8329
8699
  }
8330
8700
  });
8331
8701
  // Add images if imgUrl is specified
@@ -8361,7 +8731,7 @@ var text = {
8361
8731
  /**
8362
8732
  * Update data label text background color
8363
8733
  * @param {object} d Data object
8364
- * @param {object|string|Function} option option object
8734
+ * @param {object|string|function} option option object
8365
8735
  * @returns {string|null}
8366
8736
  * @private
8367
8737
  */
@@ -8394,8 +8764,8 @@ var text = {
8394
8764
  },
8395
8765
  /**
8396
8766
  * Redraw chartText
8397
- * @param {Function} getX Positioning function for x
8398
- * @param {Function} getY Positioning function for y
8767
+ * @param {function} getX Positioning function for x
8768
+ * @param {function} getY Positioning function for y
8399
8769
  * @param {boolean} forFlow Weather is flow
8400
8770
  * @param {boolean} withTransition transition is enabled
8401
8771
  * @returns {Array}
@@ -8409,18 +8779,37 @@ var text = {
8409
8779
  var angle = config.data_labels.rotate;
8410
8780
  var anchorString = getRotateAnchor(angle);
8411
8781
  var rotateString = angle ? "rotate(".concat(angle, ")") : "";
8782
+ // Phase 1: Batch getBBox() calls to avoid layout thrashing
8783
+ // Pre-compute all text bounding boxes in a single read phase
8784
+ var bboxCache = new Map();
8785
+ if (config.data_labels.centered) {
8786
+ // Collect all elements that need bbox measurement
8787
+ var elementsToMeasure_1 = [];
8788
+ $$.$el.text.each(function (d) {
8789
+ if (($$.isBarType(d) || $$.isTreemapType(d))) {
8790
+ elementsToMeasure_1.push(this);
8791
+ }
8792
+ });
8793
+ // Batch all getBBox() calls together in a single read phase
8794
+ if (elementsToMeasure_1.length > 0) {
8795
+ bboxCache = batchGetBBox(elementsToMeasure_1);
8796
+ }
8797
+ }
8798
+ // Phase 2: Apply cached bbox values during position calculation
8412
8799
  $$.$el.text
8413
8800
  .style("fill", $$.getStylePropValue($$.updateTextColor))
8414
8801
  .attr("filter", function (d) { return $$.updateTextBGColor.bind($$)(d, config.data_labels_backgroundColors); })
8415
8802
  .style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$))
8416
8803
  .each(function (d, i) {
8804
+ // Get cached bbox for this element (undefined if not cached)
8805
+ var cachedBbox = bboxCache.get(this);
8417
8806
  // do not apply transition for newly added text elements
8418
8807
  var node = $T(hasTreemap && this.childElementCount ? this.parentNode : this, !!(withTransition &&
8419
8808
  (this.getAttribute("x") || this.getAttribute("transform"))), t);
8420
8809
  var isInverted = config["axis_".concat(axis === null || axis === void 0 ? void 0 : axis.getId(d.id), "_inverted")];
8421
8810
  var pos = {
8422
- x: getX.bind(this)(d, i),
8423
- y: getY.bind(this)(d, i)
8811
+ x: getX.bind(this)(d, i, cachedBbox),
8812
+ y: getY.bind(this)(d, i, cachedBbox)
8424
8813
  };
8425
8814
  if (angle) {
8426
8815
  pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
@@ -8519,17 +8908,19 @@ var text = {
8519
8908
  * @param {Array} points Data points position
8520
8909
  * @param {HTMLElement} textElement Data label text element
8521
8910
  * @param {string} type 'x' or 'y'
8911
+ * @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
8522
8912
  * @returns {number} Position value
8523
8913
  * @private
8524
8914
  */
8525
- getCenteredTextPos: function (d, points, textElement, type) {
8915
+ getCenteredTextPos: function (d, points, textElement, type, cachedBbox) {
8526
8916
  var $$ = this;
8527
8917
  var config = $$.config;
8528
8918
  var isRotated = config.axis_rotated;
8529
8919
  var isBarType = $$.isBarType(d);
8530
8920
  var isTreemapType = $$.isTreemapType(d);
8531
8921
  if (config.data_labels.centered && (isBarType || isTreemapType)) {
8532
- var rect = getBoundingRect(textElement);
8922
+ // Use cached bbox from parameter to avoid layout thrashing, fallback to getBBox if not provided
8923
+ var rect = cachedBbox || getBBox(textElement);
8533
8924
  if (isBarType) {
8534
8925
  var isPositive = $$.getRangedData(d, null, "bar") >= 0;
8535
8926
  if (isRotated) {
@@ -8547,8 +8938,8 @@ var text = {
8547
8938
  }
8548
8939
  else if (isTreemapType) {
8549
8940
  return type === "x" ?
8550
- (points[1][0] - points[0][0]) / 2 :
8551
- (points[1][1] - points[0][1]) / 2 + (rect.height / 2);
8941
+ (points[1][0] - points[0][0]) / 2 : // X: Move to horizontal center of rect
8942
+ (points[1][1] - points[0][1]) / 2 - rect.y - rect.height / 2; // Y: Calculate true vertical center
8552
8943
  }
8553
8944
  }
8554
8945
  return 0;
@@ -8558,10 +8949,11 @@ var text = {
8558
8949
  * @param {object} points Data points position
8559
8950
  * @param {object} d Data object
8560
8951
  * @param {HTMLElement} textElement Data label text element
8952
+ * @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
8561
8953
  * @returns {number} x coordinate
8562
8954
  * @private
8563
8955
  */
8564
- getXForText: function (points, d, textElement) {
8956
+ getXForText: function (points, d, textElement, cachedBbox) {
8565
8957
  var _a;
8566
8958
  var $$ = this;
8567
8959
  var config = $$.config;
@@ -8601,7 +8993,7 @@ var text = {
8601
8993
  }
8602
8994
  }
8603
8995
  if (isRotated || isTreemapType) {
8604
- xPos += $$.getCenteredTextPos(d, points, textElement, "x");
8996
+ xPos += $$.getCenteredTextPos(d, points, textElement, "x", cachedBbox);
8605
8997
  }
8606
8998
  return xPos + getTextPos.call(this, d, "x");
8607
8999
  },
@@ -8610,10 +9002,11 @@ var text = {
8610
9002
  * @param {object} points Data points position
8611
9003
  * @param {object} d Data object
8612
9004
  * @param {HTMLElement} textElement Data label text element
9005
+ * @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
8613
9006
  * @returns {number} y coordinate
8614
9007
  * @private
8615
9008
  */
8616
- getYForText: function (points, d, textElement) {
9009
+ getYForText: function (points, d, textElement, cachedBbox) {
8617
9010
  var $$ = this;
8618
9011
  var axis = $$.axis, config = $$.config, state = $$.state;
8619
9012
  var isRotated = config.axis_rotated;
@@ -8675,7 +9068,7 @@ var text = {
8675
9068
  }
8676
9069
  }
8677
9070
  if (!isRotated || isTreemapType) {
8678
- yPos += $$.getCenteredTextPos(d, points, textElement, "y");
9071
+ yPos += $$.getCenteredTextPos(d, points, textElement, "y", cachedBbox);
8679
9072
  }
8680
9073
  return yPos + getTextPos.call(this, d, "y");
8681
9074
  },
@@ -8734,7 +9127,7 @@ var text = {
8734
9127
  * @returns {string|number} text-anchor value or position in pixel
8735
9128
  * @private
8736
9129
  */
8737
- function getTextXPos(pos, width) {
9130
+ function _getTextXPos(pos, width) {
8738
9131
  if (pos === void 0) { pos = "left"; }
8739
9132
  var isNum = isNumber(width);
8740
9133
  var position;
@@ -8761,7 +9154,7 @@ var title = {
8761
9154
  $el.title = $el.svg.append("g");
8762
9155
  var text = $el.title
8763
9156
  .append("text")
8764
- .style("text-anchor", getTextXPos(config.title_position))
9157
+ .style("text-anchor", _getTextXPos(config.title_position))
8765
9158
  .attr("class", $TEXT.title);
8766
9159
  setTextValue(text, config.title_text, [0.3, 1.5]);
8767
9160
  }
@@ -8774,7 +9167,7 @@ var title = {
8774
9167
  var $$ = this;
8775
9168
  var config = $$.config, current = $$.state.current, title = $$.$el.title;
8776
9169
  if (title) {
8777
- var x = getTextXPos(config.title_position, current.width);
9170
+ var x = _getTextXPos(config.title_position, current.width);
8778
9171
  var y = (config.title_padding.top || 0) +
8779
9172
  $$.getTextRect($$.$el.title, $TEXT.title).height;
8780
9173
  title.attr("transform", "translate(".concat(x, ", ").concat(y, ")"));
@@ -8861,9 +9254,9 @@ var tooltip$1 = {
8861
9254
  /**
8862
9255
  * Returns the tooltip content(HTML string)
8863
9256
  * @param {object} d data
8864
- * @param {Function} defaultTitleFormat Default title format
8865
- * @param {Function} defaultValueFormat Default format for each data value in the tooltip.
8866
- * @param {Function} color Color function
9257
+ * @param {function} defaultTitleFormat Default title format
9258
+ * @param {function} defaultValueFormat Default format for each data value in the tooltip.
9259
+ * @param {function} color Color function
8867
9260
  * @returns {string} html
8868
9261
  * @private
8869
9262
  */
@@ -8891,15 +9284,20 @@ var tooltip$1 = {
8891
9284
  }
8892
9285
  return sanitize((nameFn || (function (name) { return name; })).apply(void 0, arg));
8893
9286
  };
8894
- var valueFormat = function () {
8895
- var arg = [];
8896
- for (var _i = 0; _i < arguments.length; _i++) {
8897
- arg[_i] = arguments[_i];
9287
+ var valueFormat = function (v, ratio, id, index) {
9288
+ var fn = valueFn;
9289
+ if (!fn) {
9290
+ // For normalize per group, only show percentage for data in groups
9291
+ if (state.hasTreemap ||
9292
+ ($$.isStackNormalized() &&
9293
+ (!$$.isStackNormalizedPerGroup() || $$.isGrouped(id)))) {
9294
+ fn = function (v, ratio) { return "".concat((ratio * 100).toFixed(2), "%"); };
9295
+ }
9296
+ else {
9297
+ fn = defaultValueFormat;
9298
+ }
8898
9299
  }
8899
- var fn = valueFn || (state.hasTreemap || $$.isStackNormalized() ?
8900
- function (v, ratio) { return "".concat((ratio * 100).toFixed(2), "%"); } :
8901
- defaultValueFormat);
8902
- return sanitize(fn.apply(void 0, arg));
9300
+ return sanitize(fn(v, ratio, id, index));
8903
9301
  };
8904
9302
  var order = config.tooltip_order;
8905
9303
  var getRowValue = function (row) { return ($$.axis && $$.isBubbleZType(row) ?
@@ -9270,7 +9668,6 @@ var tooltip$1 = {
9270
9668
  // hide tooltip
9271
9669
  tooltip
9272
9670
  .style("display", "none")
9273
- .style("visibility", "hidden") // for IE9
9274
9671
  .datum(null);
9275
9672
  callFn(config.tooltip_onhidden, api, selectedData);
9276
9673
  }
@@ -9712,10 +10109,10 @@ var typeInternals = {
9712
10109
  * Get grouped data point function for y coordinate
9713
10110
  * - Note: Grouped(stacking) works only for line and bar types
9714
10111
  * @param {object} d data vlaue
9715
- * @returns {Function|undefined}
10112
+ * @returns {function|undefined}
9716
10113
  * @private
9717
10114
  */
9718
- function getGroupedDataPointsFn(d) {
10115
+ function _getGroupedDataPointsFn(d) {
9719
10116
  var $$ = this;
9720
10117
  var fn;
9721
10118
  if ($$.isLineType(d)) {
@@ -9774,7 +10171,7 @@ var shape = {
9774
10171
  * data2 data4 data2 data4
9775
10172
  * -------------------------
9776
10173
  * 0 1
9777
- * @param {Function} typeFilter Chart type filter function
10174
+ * @param {function} typeFilter Chart type filter function
9778
10175
  * @returns {object} Indices object with its position
9779
10176
  */
9780
10177
  getShapeIndices: function (typeFilter) {
@@ -9938,13 +10335,21 @@ var shape = {
9938
10335
  },
9939
10336
  /**
9940
10337
  * Get Shape's offset data
9941
- * @param {Function} typeFilter Type filter function
10338
+ * @param {function} typeFilter Type filter function
9942
10339
  * @returns {object}
9943
10340
  * @private
9944
10341
  */
9945
10342
  getShapeOffsetData: function (typeFilter) {
9946
10343
  var $$ = this;
9947
10344
  var targets = $$.orderTargets($$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$)));
10345
+ // Create cache key based on target IDs
10346
+ var targetIds = targets.map(function (t) { return t.id; }).join("_");
10347
+ var cacheKey = "".concat(KEY.shapeOffset, "_").concat(targetIds);
10348
+ // Check if result is already cached
10349
+ var cachedData = $$.cache.get(cacheKey);
10350
+ if (cachedData) {
10351
+ return cachedData;
10352
+ }
9948
10353
  var isStackNormalized = $$.isStackNormalized();
9949
10354
  var shapeOffsetTargets = targets.map(function (target) {
9950
10355
  var rowValues = target.values;
@@ -9970,7 +10375,10 @@ var shape = {
9970
10375
  out[id] = index;
9971
10376
  return out;
9972
10377
  }, {});
9973
- return { indexMapByTargetId: indexMapByTargetId, shapeOffsetTargets: shapeOffsetTargets };
10378
+ var result = { indexMapByTargetId: indexMapByTargetId, shapeOffsetTargets: shapeOffsetTargets };
10379
+ // Cache the result
10380
+ $$.cache.add(cacheKey, result);
10381
+ return result;
9974
10382
  },
9975
10383
  getShapeOffset: function (typeFilter, indices, isSub) {
9976
10384
  var $$ = this;
@@ -10026,7 +10434,7 @@ var shape = {
10026
10434
  var id = d.id;
10027
10435
  var points;
10028
10436
  if ($$.isGrouped(id)) {
10029
- points = getGroupedDataPointsFn.bind($$)(d);
10437
+ points = _getGroupedDataPointsFn.bind($$)(d);
10030
10438
  }
10031
10439
  return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
10032
10440
  },
@@ -10447,7 +10855,7 @@ var ChartInternal = /** @class */ (function () {
10447
10855
  var onclick_1 = config.onclick, onover = config.onover, onout = config.onout;
10448
10856
  $el.svg
10449
10857
  .on("click", (onclick_1 === null || onclick_1 === void 0 ? void 0 : onclick_1.bind($$.api)) || null)
10450
- .on(isTouch ? "touchstart" : "mouseenter", (onover === null || onover === void 0 ? void 0 : onover.bind($$.api)) || null)
10858
+ .on(isTouch ? "touchstart" : "mouseenter", (onover === null || onover === void 0 ? void 0 : onover.bind($$.api)) || null, isTouch ? { passive: true } : undefined)
10451
10859
  .on(isTouch ? "touchend" : "mouseleave", (onout === null || onout === void 0 ? void 0 : onout.bind($$.api)) || null);
10452
10860
  }
10453
10861
  config.svg_classname && $el.svg.attr("class", config.svg_classname);
@@ -10457,7 +10865,7 @@ var ChartInternal = /** @class */ (function () {
10457
10865
  labelsBGColor || ((_a = $$.hasLegendDefsPoint) === null || _a === void 0 ? void 0 : _a.call($$))) {
10458
10866
  $el.defs = $el.svg.append("defs");
10459
10867
  if (hasAxis) {
10460
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
10868
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(function (v) {
10461
10869
  $$.appendClip($el.defs, state.clip[v]);
10462
10870
  });
10463
10871
  }
@@ -10878,7 +11286,7 @@ var apiChart = {
10878
11286
  },
10879
11287
  /**
10880
11288
  * Force to redraw.
10881
- * - **NOTE:** When zoom/subchart is used, the zoomed state will be resetted.
11289
+ * - **NOTE:** When zoom/subchart is used, the zoomed state will be reset.
10882
11290
  * @function flush
10883
11291
  * @instance
10884
11292
  * @memberof Chart
@@ -10986,15 +11394,15 @@ var apiChart = {
10986
11394
  * Get or set config option value.
10987
11395
  * - **NOTE**
10988
11396
  * - The option key name must be specified as the last level.
10989
- * - when no argument is given, will return all specified generation options object only. (will exclude any other options not specified at the initialization)
11397
+ * - When no argument is given, it will return all specified generation options object only. (will exclude any other options not specified at the initialization)
10990
11398
  * @function config
10991
11399
  * @instance
10992
11400
  * @memberof Chart
10993
11401
  * @param {string} name The option key name.
10994
- * @param {*} [value] The value accepted for indicated option.
11402
+ * @param {string|number|boolean|object|Array} [value] The value accepted for indicated option.
10995
11403
  * @param {boolean} [redraw] Set to redraw with the new option changes.
10996
- * - **NOTE:** Doesn't guarantee work in all circumstances. It can be applied for limited options only.
10997
- * @returns {*}
11404
+ * - **NOTE:** Doesn't guarantee to work in all circumstances. It can be applied for limited options only.
11405
+ * @returns {string|number|boolean|object|Array} The option value or all options object
10998
11406
  * @example
10999
11407
  *
11000
11408
  * // Getter
@@ -11112,7 +11520,7 @@ extend(data, {
11112
11520
  * @function data․values
11113
11521
  * @instance
11114
11522
  * @memberof Chart
11115
- * @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be retruned
11523
+ * @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be returned
11116
11524
  * @param {boolean} [flat=true] Get flatten values
11117
11525
  * @returns {Array} Data values
11118
11526
  * @example
@@ -11159,6 +11567,7 @@ extend(data, {
11159
11567
  },
11160
11568
  /**
11161
11569
  * Get and set colors of the data loaded in the chart.
11570
+ * - **NOTE:** If gradient option is set, the color update will affect only gradient stops have the same color.
11162
11571
  * @function data․colors
11163
11572
  * @instance
11164
11573
  * @memberof Chart
@@ -11403,7 +11812,7 @@ var apiExport = {
11403
11812
  * - Text element's position(especially "transformed") can't be preserved correctly according the page's layout condition.
11404
11813
  * - If need to preserve accurate text position, embed the web font data within to the page and set `preserveFontStyle=false`.
11405
11814
  * - Checkout the embed example: <a href="https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html">https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html</a>
11406
- * @param {Function} [callback] The callback to be invoked when export is ready.
11815
+ * @param {function(string): void} [callback] The callback to be invoked when export is ready.
11407
11816
  * @returns {string} dataURI
11408
11817
  * @example
11409
11818
  * chart.export();
@@ -11667,7 +12076,7 @@ var apiLoad = {
11667
12076
  * | categories | Array | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
11668
12077
  * | classes | Object | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
11669
12078
  * | colors | Object | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
11670
- * | data | Obejct | Data objects to be loaded. Checkout the example. |
12079
+ * | data | Object | Data objects to be loaded. Checkout the example. |
11671
12080
  * | done | Function | The specified function will be called after data loaded.|
11672
12081
  * | headers | string | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
11673
12082
  * | keys | Object | Choose which JSON objects keys correspond to desired data.<br>**NOTE:** Only for JSON object given as array.<br>@see [data․keys](Options.html#.data%25E2%2580%25A4keys) |
@@ -11726,7 +12135,7 @@ var apiLoad = {
11726
12135
  *
11727
12136
  * chart.load({
11728
12137
  * columns: [
11729
- * // when existing chart has `x` value, should provide correponding 'x' value.
12138
+ * // when existing chart has `x` value, should provide corresponding 'x' value.
11730
12139
  * // with 'append' option, the 'data1' will have `[36,30,24,37]`.
11731
12140
  * ["x", "2021-02-01T08:00:00"],
11732
12141
  * ["data1", 37]
@@ -11827,7 +12236,7 @@ var apiLoad = {
11827
12236
  * | key | Type | Description |
11828
12237
  * | --- | --- | --- |
11829
12238
  * | ids | String &vert; Array | Target id data to be unloaded. If not given, all data will be unloaded. |
11830
- * | done | Fuction | Callback after data is unloaded. |
12239
+ * | done | Function | Callback after data is unloaded. |
11831
12240
  * | resizeAfter | boolean | Resize after the unload. Default value is `false`.<br>- This option won't call `onresize` neither `onresized`.<br>- When set to 'true', will call `.flush(true)` at the end of unload. |
11832
12241
  * @example
11833
12242
  * // Unload data2 and data3
@@ -12014,7 +12423,7 @@ var tooltip = {
12014
12423
  *
12015
12424
  * @example
12016
12425
  * // show the 2nd x Axis coordinate tooltip
12017
- * // for Arc(gauge, donut & pie) and radar type, approch showing tooltip by using "index" number.
12426
+ * // for Arc(gauge, donut & pie) and radar type, approach showing tooltip by using "index" number.
12018
12427
  * chart.tooltip.show({
12019
12428
  * index: 1
12020
12429
  * });
@@ -12158,7 +12567,7 @@ var apiTooltip = { tooltip: tooltip };
12158
12567
  * @property {d3.selection} $.needle Needle element
12159
12568
  * - **NOTE:**
12160
12569
  * - The element will have `bb-needle` as class name.
12161
- * - Will provide speical helper `.updateHelper(value: number, updateConfig: boolean)` method to facilitate needle position update.
12570
+ * - Will provide special helper `.updateHelper(value: number, updateConfig: boolean)` method to facilitate needle position update.
12162
12571
  * @property {d3.selection} $.tooltip Tooltip element
12163
12572
  * @property {d3.selection} $.legend Legend element
12164
12573
  * @property {d3.selection} $.title Title element
@@ -12587,7 +12996,7 @@ var apiFlow = {
12587
12996
  * - If json specified, keys is required as well as data.json.
12588
12997
  * - If tab isn't visible(by evaluating `document.hidden`), will not be executed to prevent unnecessary work.
12589
12998
  * @example
12590
- * // 2 data points will be apprended to the tail and popped from the head.
12999
+ * // 2 data points will be appended to the tail and popped from the head.
12591
13000
  * // After that, 4 data points will be appended and no data points will be poppoed.
12592
13001
  * chart.flow({
12593
13002
  * columns: [
@@ -13225,7 +13634,7 @@ var AxisRendererHelper = /** @class */ (function () {
13225
13634
  /**
13226
13635
  * Get tick transform setter function
13227
13636
  * @param {string} id Axis id
13228
- * @returns {Function} transfrom setter function
13637
+ * @returns {(selection: d3Selection, scale) => void} transfrom setter function
13229
13638
  * @private
13230
13639
  */
13231
13640
  AxisRendererHelper.prototype.getTickTransformSetter = function (id) {
@@ -14067,7 +14476,7 @@ var Axis = /** @class */ (function () {
14067
14476
  }
14068
14477
  tickValues && axis.tickValues(tickValues);
14069
14478
  // Set tick
14070
- axis.tickFormat(tickFormat || (!isX && ($$.isStackNormalized() && (function (x) { return "".concat(x, "%"); }))));
14479
+ axis.tickFormat(tickFormat || (!isX && ($$.isStackNormalized() && $$.hasAxisGroupedData(id) && (function (x) { return "".concat(x, "%"); }))));
14071
14480
  if (isCategory) {
14072
14481
  axis.tickCentered(config.axis_x_tick_centered);
14073
14482
  if (isEmpty(config.axis_x_tick_culling)) {
@@ -14761,6 +15170,9 @@ var eventrect = {
14761
15170
  var isPrevented = (isBoolean(preventDefault) && preventDefault) || false;
14762
15171
  var preventThreshold = (!isNaN(preventDefault) && preventDefault) || null;
14763
15172
  var startPx;
15173
+ // Determine passive option based on preventDefault setting
15174
+ // If preventDefault is needed, passive must be false
15175
+ var passiveOption = !isPrevented && preventThreshold === null;
14764
15176
  var preventEvent = function (event) {
14765
15177
  var eventType = event.type;
14766
15178
  var touch = event.changedTouches[0];
@@ -14788,7 +15200,7 @@ var eventrect = {
14788
15200
  .on("touchstart", function (event) {
14789
15201
  state.event = event;
14790
15202
  $$.updateEventRect();
14791
- })
15203
+ }, { passive: passiveOption })
14792
15204
  .on("touchstart.eventRect touchmove.eventRect", function (event) {
14793
15205
  state.event = event;
14794
15206
  if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
@@ -14803,7 +15215,7 @@ var eventrect = {
14803
15215
  else {
14804
15216
  unselectRect();
14805
15217
  }
14806
- }, true)
15218
+ }, { passive: passiveOption })
14807
15219
  .on("touchend.eventRect", function (event) {
14808
15220
  state.event = event;
14809
15221
  if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
@@ -14811,14 +15223,14 @@ var eventrect = {
14811
15223
  state.cancelClick && (state.cancelClick = false);
14812
15224
  }
14813
15225
  }
14814
- }, true);
15226
+ }, { passive: passiveOption });
14815
15227
  svg.on("touchstart", function (event) {
14816
15228
  state.event = event;
14817
15229
  var target = event.target;
14818
15230
  if (target && target !== eventRect.node()) {
14819
15231
  unselectRect();
14820
15232
  }
14821
- });
15233
+ }, { passive: passiveOption });
14822
15234
  },
14823
15235
  /**
14824
15236
  * Update event rect size
@@ -15056,7 +15468,9 @@ var eventrect = {
15056
15468
  // Show cursor as pointer if point is close to mouse position
15057
15469
  if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
15058
15470
  $$.$el.svg.select(".".concat($EVENT.eventRect)).style("cursor", "pointer");
15059
- if (triggerEvent && !state.mouseover) {
15471
+ if (triggerEvent && (!state.mouseover ||
15472
+ state.mouseover.x !== closest.x ||
15473
+ state.mouseover.id !== closest.id)) {
15060
15474
  config.data_onover.call($$.api, closest);
15061
15475
  state.mouseover = closest;
15062
15476
  }
@@ -15248,7 +15662,7 @@ var flow = {
15248
15662
  /**
15249
15663
  * Generate flow
15250
15664
  * @param {object} args option object
15251
- * @returns {Function}
15665
+ * @returns {function}
15252
15666
  * @private
15253
15667
  */
15254
15668
  generateFlow: function (args) {
@@ -15573,17 +15987,17 @@ var clip = {
15573
15987
  * billboard.js project is licensed under the MIT license
15574
15988
  */
15575
15989
  // Grid position and text anchor helpers
15576
- var getGridTextAnchor = function (d) { return isValue(d.position) || "end"; };
15577
- var getGridTextDx = function (d) { return (d.position === "start" ? 4 : (d.position === "middle" ? 0 : -4)); };
15990
+ var _getGridTextAnchor = function (d) { return isValue(d.position) || "end"; };
15991
+ var _getGridTextDx = function (d) { return (d.position === "start" ? 4 : (d.position === "middle" ? 0 : -4)); };
15578
15992
  /**
15579
15993
  * Get grid text x value getter function
15580
15994
  * @param {boolean} isX Is x Axis
15581
15995
  * @param {number} width Width value
15582
15996
  * @param {number} height Height value
15583
- * @returns {Function}
15997
+ * @returns {function}
15584
15998
  * @private
15585
15999
  */
15586
- function getGridTextX(isX, width, height) {
16000
+ function _getGridTextX(isX, width, height) {
15587
16001
  return function (d) {
15588
16002
  var x = isX ? 0 : width;
15589
16003
  if (d.position === "start") {
@@ -15601,7 +16015,7 @@ function getGridTextX(isX, width, height) {
15601
16015
  * @param {string} type Type
15602
16016
  * @private
15603
16017
  */
15604
- function smoothLines(el, type) {
16018
+ function _smoothLines(el, type) {
15605
16019
  {
15606
16020
  el.each(function () {
15607
16021
  var g = select(this);
@@ -15695,7 +16109,7 @@ var grid = {
15695
16109
  .attr("x2", isRotated ? pos : state.width)
15696
16110
  .attr("y1", isRotated ? 0 : pos)
15697
16111
  .attr("y2", isRotated ? state.height : pos);
15698
- smoothLines(grid.y);
16112
+ _smoothLines(grid.y);
15699
16113
  },
15700
16114
  updateGrid: function () {
15701
16115
  var $$ = this;
@@ -15740,11 +16154,11 @@ var grid = {
15740
16154
  $T(lines
15741
16155
  .attr("class", function (d) { return "".concat($GRID["".concat(type, "gridLine")], " ").concat(d.class || "").trim(); })
15742
16156
  .select("text")
15743
- .attr("text-anchor", getGridTextAnchor)
16157
+ .attr("text-anchor", _getGridTextAnchor)
15744
16158
  .attr("transform", function () { return (isX ?
15745
16159
  (isRotated ? null : "rotate(-90)") :
15746
16160
  (isRotated ? "rotate(-90)" : null)); })
15747
- .attr("dx", getGridTextDx)
16161
+ .attr("dx", _getGridTextDx)
15748
16162
  .attr("dy", -5))
15749
16163
  .text(function (d) {
15750
16164
  var _a;
@@ -15767,7 +16181,7 @@ var grid = {
15767
16181
  .attr("y1", isRotated ? xv : 0)
15768
16182
  .attr("y2", isRotated ? xv : height);
15769
16183
  xTexts = $T(xTexts, withTransition)
15770
- .attr("x", getGridTextX(!isRotated, width, height))
16184
+ .attr("x", _getGridTextX(!isRotated, width, height))
15771
16185
  .attr("y", xv);
15772
16186
  yLines = $T(yLines, withTransition)
15773
16187
  .attr("x1", isRotated ? yv : 0)
@@ -15775,7 +16189,7 @@ var grid = {
15775
16189
  .attr("y1", isRotated ? 0 : yv)
15776
16190
  .attr("y2", isRotated ? height : yv);
15777
16191
  yTexts = $T(yTexts, withTransition)
15778
- .attr("x", getGridTextX(isRotated, width, height))
16192
+ .attr("x", _getGridTextX(isRotated, width, height))
15779
16193
  .attr("y", yv);
15780
16194
  return [
15781
16195
  xLines.style("opacity", null),
@@ -15927,7 +16341,7 @@ var grid = {
15927
16341
  ["x1", "y1", "x2", "y2"]
15928
16342
  .forEach(function (v, i) { return el.attr(v, xy[i]); });
15929
16343
  });
15930
- smoothLines(focusEl);
16344
+ _smoothLines(focusEl);
15931
16345
  (_a = $$.showCircleFocus) === null || _a === void 0 ? void 0 : _a.call($$, data);
15932
16346
  },
15933
16347
  hideGridFocus: function () {
@@ -16454,7 +16868,7 @@ var x = {
16454
16868
  * A function to format tick value. Format string is also available for timeseries data.
16455
16869
  * @name axis․x․tick․format
16456
16870
  * @memberof Options
16457
- * @type {Function|string}
16871
+ * @type {function|string}
16458
16872
  * @default undefined
16459
16873
  * @see [D3's time specifier](https://d3js.org/d3-time-format#locale_format)
16460
16874
  * @example
@@ -16483,7 +16897,7 @@ var x = {
16483
16897
  * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
16484
16898
  * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.x.tick.culling.lines=false`.
16485
16899
  * - `false`: all of ticks will be shown.<br><br>
16486
- * The number of ticks to be shown can be chaned by `axis.x.tick.culling.max`.
16900
+ * The number of ticks to be shown can be changed by `axis.x.tick.culling.max`.
16487
16901
  * @name axis․x․tick․culling
16488
16902
  * @memberof Options
16489
16903
  * @type {boolean}
@@ -16694,10 +17108,10 @@ var x = {
16694
17108
  /**
16695
17109
  * Set the x values of ticks manually.<br><br>
16696
17110
  * If this option is provided, the position of the ticks will be determined based on those values.<br>
16697
- * This option works with `timeseries` data and the x values will be parsed accoding to the type of the value and data.xFormat option.
17111
+ * This option works with `timeseries` data and the x values will be parsed according to the type of the value and data.xFormat option.
16698
17112
  * @name axis․x․tick․values
16699
17113
  * @memberof Options
16700
- * @type {Array|Function}
17114
+ * @type {Array|function}
16701
17115
  * @default null
16702
17116
  * @example
16703
17117
  * axis: {
@@ -16918,7 +17332,7 @@ var x = {
16918
17332
  * - **timeseries:** Numeric time value
16919
17333
  * ex. the given value `1000*60*60*24`, which is numeric time equivalent of a day, is same as the width of 1 tick width
16920
17334
  * - If want values to be treated as pixels, specify `unit:"px"`.
16921
- * - The pixel value will be convered based on the scale values. Hence can not reflect accurate padding result.
17335
+ * - The pixel value will be converted based on the scale values. Hence can not reflect accurate padding result.
16922
17336
  * @name axis․x․padding
16923
17337
  * @memberof Options
16924
17338
  * @type {object|number}
@@ -16969,7 +17383,7 @@ var x = {
16969
17383
  * - **NOTE:** Specifying value, will limit the zoom scope selection within.
16970
17384
  * @name axis․x․extent
16971
17385
  * @memberof Options
16972
- * @type {Array|Function}
17386
+ * @type {Array|function}
16973
17387
  * @default undefined
16974
17388
  * @example
16975
17389
  * axis: {
@@ -17241,7 +17655,7 @@ var y = {
17241
17655
  * This option accepts d3.format object as well as a function you define.
17242
17656
  * @name axis․y․tick․format
17243
17657
  * @memberof Options
17244
- * @type {Function}
17658
+ * @type {function}
17245
17659
  * @default undefined
17246
17660
  * @example
17247
17661
  * axis: {
@@ -17260,7 +17674,7 @@ var y = {
17260
17674
  * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
17261
17675
  * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y.tick.culling.lines=false`.
17262
17676
  * - `false`: all of ticks will be shown.<br><br>
17263
- * The number of ticks to be shown can be chaned by `axis.y.tick.culling.max`.
17677
+ * The number of ticks to be shown can be changed by `axis.y.tick.culling.max`.
17264
17678
  * @name axis․y․tick․culling
17265
17679
  * @memberof Options
17266
17680
  * @type {boolean}
@@ -17366,7 +17780,7 @@ var y = {
17366
17780
  * Set y axis tick values manually.
17367
17781
  * @name axis․y․tick․values
17368
17782
  * @memberof Options
17369
- * @type {Array|Function}
17783
+ * @type {Array|function}
17370
17784
  * @default null
17371
17785
  * @example
17372
17786
  * axis: {
@@ -17502,7 +17916,7 @@ var y = {
17502
17916
  * @private
17503
17917
  * @type {object}
17504
17918
  * @property {object} time time object
17505
- * @property {Function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
17919
+ * @property {function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
17506
17920
  * @example
17507
17921
  * axis: {
17508
17922
  * y: {
@@ -17607,6 +18021,18 @@ var y = {
17607
18021
  * y2 Axis config options
17608
18022
  */
17609
18023
  var y2 = {
18024
+ /**
18025
+ * Set clip-path attribute for y2 axis element
18026
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
18027
+ * @name axis․y2․clipPath
18028
+ * @memberof Options
18029
+ * @type {boolean}
18030
+ * @default true
18031
+ * @example
18032
+ * // don't set 'clip-path' attribute
18033
+ * clipPath: false
18034
+ */
18035
+ axis_y2_clipPath: true,
17610
18036
  /**
17611
18037
  * Show or hide y2 axis.
17612
18038
  * - **NOTE**:
@@ -17752,7 +18178,7 @@ var y2 = {
17752
18178
  * This option works in the same way as axis.y.format.
17753
18179
  * @name axis․y2․tick․format
17754
18180
  * @memberof Options
17755
- * @type {Function}
18181
+ * @type {function}
17756
18182
  * @default undefined
17757
18183
  * @example
17758
18184
  * axis: {
@@ -17770,7 +18196,7 @@ var y2 = {
17770
18196
  * - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
17771
18197
  * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y2.tick.culling.lines=false`.
17772
18198
  * - `false`: all of ticks will be shown.<br><br>
17773
- * The number of ticks to be shown can be chaned by `axis.y2.tick.culling.max`.
18199
+ * The number of ticks to be shown can be changed by `axis.y2.tick.culling.max`.
17774
18200
  * @name axis․y2․tick․culling
17775
18201
  * @memberof Options
17776
18202
  * @type {boolean}
@@ -17877,7 +18303,7 @@ var y2 = {
17877
18303
  * Set y2 axis tick values manually.
17878
18304
  * @name axis․y2․tick․values
17879
18305
  * @memberof Options
17880
- * @type {Array|Function}
18306
+ * @type {Array|function}
17881
18307
  * @default null
17882
18308
  * @example
17883
18309
  * axis: {
@@ -18092,16 +18518,16 @@ var optAxis = __assign(__assign(__assign({
18092
18518
  /**
18093
18519
  * Setup the way to evaluate tick text size.
18094
18520
  * - **NOTE:**
18095
- * - Setting `false` or custom evaluator, highly recommended to memoize evaluated text dimension value to not degrade performance.
18521
+ * - When setting `false` or a custom evaluator, it is highly recommended to memoize evaluated text dimension value to not degrade performance.
18096
18522
  * @name axis․evalTextSize
18097
18523
  * @memberof Options
18098
- * @type {boolean|Function}
18524
+ * @type {boolean|function}
18099
18525
  * @default true
18100
18526
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.AxisEvalTextSize)
18101
18527
  * @example
18102
18528
  * axis: {
18103
18529
  * // will evaluate getting text size every time.
18104
- * evalTextSize: false.
18530
+ * evalTextSize: false,
18105
18531
  *
18106
18532
  * // set a custom evaluator
18107
18533
  * evalTextSize: function(textElement, axisId) {
@@ -18145,8 +18571,8 @@ var optAxis = __assign(__assign(__assign({
18145
18571
  * Set axis tooltip.
18146
18572
  * - **NOTE:**
18147
18573
  * - When enabled, will disable default focus grid line.
18148
- * - For `timeseries` x Axis, tootlip will be formatted using x Axis' tick format.
18149
- * - For `category` x Axis, tootlip will be displaying scales' value text.
18574
+ * - For `timeseries` x Axis, tooltip will be formatted using x Axis' tick format.
18575
+ * - For `category` x Axis, tooltip will be displaying scales' value text.
18150
18576
  * @name axis․tooltip
18151
18577
  * @memberof Options
18152
18578
  * @type {boolean}
@@ -18159,11 +18585,11 @@ var optAxis = __assign(__assign(__assign({
18159
18585
  * axis: {
18160
18586
  * tooltip: true, // default background color is
18161
18587
  *
18162
- * // set backgound color for axis tooltip texts
18588
+ * // set background color for axis tooltip texts
18163
18589
  * tooltip: {
18164
18590
  * backgroundColor: "red",
18165
18591
  *
18166
- * // set differenct backround colors per axes
18592
+ * // set different background colors per axes
18167
18593
  * // NOTE: In this case, only specified axes tooltip will appear.
18168
18594
  * backgroundColor: {
18169
18595
  * x: "green",
@@ -18268,7 +18694,7 @@ var optDataAxis = {
18268
18694
  */
18269
18695
  data_xs: {},
18270
18696
  /**
18271
- * Set a format specifier to parse string specifed as x.
18697
+ * Set a format specifier to parse string specified as x.
18272
18698
  * @name data․xFormat
18273
18699
  * @memberof Options
18274
18700
  * @type {string}
@@ -18317,7 +18743,7 @@ var optDataAxis = {
18317
18743
  * x: "x",
18318
18744
  * columns: [
18319
18745
  * // The line graph will start to be drawn following the x axis sequence
18320
- * // Below data, wil start drawing x=1: 200, x=2: 300, x=3: 100
18746
+ * // Below data, will start drawing x=1: 200, x=2: 300, x=3: 100
18321
18747
  * ["x", 3, 1, 2],
18322
18748
  * ["data1", 100, 200, 300]
18323
18749
  * ]
@@ -18378,16 +18804,41 @@ var optDataAxis = {
18378
18804
  * - **NOTE:**
18379
18805
  * - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
18380
18806
  * - y Axis will be set in percentage value (0 ~ 100%)
18381
- * - Must have postive values
18807
+ * - Must have positive values
18808
+ * - Data not in any group will not be normalized when using perGroup option
18382
18809
  * @name data․stack․normalize
18383
18810
  * @memberof Options
18384
- * @type {boolean}
18811
+ * @type {boolean|object}
18385
18812
  * @default false
18386
- * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
18813
+ * @see [Demo: Data Stack Normalized](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
18814
+ * @see [Demo: Data Stack Normalized per Group](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalizedGroup)
18387
18815
  * @example
18388
18816
  * data: {
18389
18817
  * stack: {
18818
+ * // Normalize all grouped data together (all groups combined to 0-100%)
18390
18819
  * normalize: true
18820
+ *
18821
+ * // Normalize per group (each group independently becomes 0-100%)
18822
+ * // Data not in any group will display with their original values.
18823
+ * // If non-grouped data shares the same axis (e.g., y), it will be
18824
+ * // displayed on the 0-100 absolute scale. To display original values,
18825
+ * // assign them to a separate axis (e.g., y2).
18826
+ * normalize: {
18827
+ * perGroup: true
18828
+ * }
18829
+ * },
18830
+ * groups: [
18831
+ * ["data1", "data2"] // This group will be normalized to 0-100%
18832
+ * ],
18833
+ * // data3 is not in any group, so it displays original values
18834
+ * // Assign it to y2 axis to use a separate scale
18835
+ * axes: {
18836
+ * data3: "y2"
18837
+ * }
18838
+ * },
18839
+ * axis: {
18840
+ * y2: {
18841
+ * show: true
18391
18842
  * }
18392
18843
  * }
18393
18844
  */
@@ -18426,6 +18877,331 @@ var options = {
18426
18877
  optGrid: optGrid
18427
18878
  };
18428
18879
 
18880
+ /**
18881
+ * Copyright (c) 2017 ~ present NAVER Corp.
18882
+ * billboard.js project is licensed under the MIT license
18883
+ */
18884
+ // Arc label line positioning constants (used in multiple places or non-obvious values)
18885
+ var BREAK_POINT_OFFSET = 15; // Offset from arc edge to break point
18886
+ var DEFAULT_LINE_DISTANCE = 20; // Default horizontal line distance
18887
+ var TEXT_VERTICAL_OFFSET = 0.35; // Text vertical alignment offset (shared with arc.ts)
18888
+ /**
18889
+ * Get the first matching arc chart type
18890
+ * @this {object} ChartInternal context
18891
+ * @param {boolean} excludeMultiGauge Whether to exclude multi gauge type
18892
+ * @returns {string|undefined} Chart type or undefined
18893
+ * @private
18894
+ */
18895
+ function getArcType(excludeMultiGauge) {
18896
+ if (excludeMultiGauge === void 0) { excludeMultiGauge = false; }
18897
+ var $$ = this;
18898
+ return ["donut", "pie", "polar", "gauge"].find(function (type) {
18899
+ return $$.hasType(type) && !(type === "gauge" && excludeMultiGauge && $$.hasMultiArcGauge());
18900
+ });
18901
+ }
18902
+ /**
18903
+ * Get label line configuration (line and text)
18904
+ * @this {object} ChartInternal context
18905
+ * @returns {LabelLineConfig} Configuration with chartType, line (show, distance) and text (formatter)
18906
+ * @private
18907
+ */
18908
+ function getConfig() {
18909
+ var $$ = this;
18910
+ var config = $$.config;
18911
+ var chartType = getArcType.call($$, true);
18912
+ var lineConfig = chartType && config["".concat(chartType, "_label_line")];
18913
+ var isValidConfig = isObjectType(lineConfig);
18914
+ // Default formatter: returns id
18915
+ var defaultFormatter = function (value, ratio, id) { return id; };
18916
+ // Line configuration
18917
+ var line = {
18918
+ show: lineConfig === true || (isValidConfig && (lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.show) !== false),
18919
+ distance: (isValidConfig && (lineConfig === null || lineConfig === void 0 ? void 0 : lineConfig.distance)) || DEFAULT_LINE_DISTANCE
18920
+ };
18921
+ // When lineConfig is boolean true, use all defaults
18922
+ if (lineConfig === true) {
18923
+ return {
18924
+ chartType: chartType,
18925
+ line: line,
18926
+ text: { formatter: defaultFormatter }
18927
+ };
18928
+ }
18929
+ // When no valid config, return default with show: false
18930
+ if (!isValidConfig) {
18931
+ return {
18932
+ chartType: chartType,
18933
+ line: { show: false, distance: DEFAULT_LINE_DISTANCE },
18934
+ text: { formatter: null }
18935
+ };
18936
+ }
18937
+ // Determine formatter based on text option
18938
+ // - text is function: use custom formatter
18939
+ // - text is true or undefined (not set): use default formatter (show id)
18940
+ // - text is false: use label.format by returning null
18941
+ var formatter = defaultFormatter;
18942
+ if (isFunction(lineConfig.text)) {
18943
+ formatter = lineConfig.text;
18944
+ }
18945
+ else if (lineConfig.text === false) {
18946
+ formatter = null;
18947
+ }
18948
+ return {
18949
+ chartType: chartType,
18950
+ line: line,
18951
+ text: { formatter: formatter }
18952
+ };
18953
+ }
18954
+ /**
18955
+ * Calculate label with line positions for arc data
18956
+ * @this {object} ChartInternal context
18957
+ * @param {object} d Data object
18958
+ * @param {number} lineDistance Horizontal line distance (from getConfig)
18959
+ * @returns {object|null} Object containing startPoint, breakPoint, endPoint, isRight, and midAngle
18960
+ * @private
18961
+ */
18962
+ function getLinePosition(d, lineDistance) {
18963
+ var $$ = this;
18964
+ var state = $$.state;
18965
+ var updated = $$.updateAngle(d);
18966
+ if (!updated) {
18967
+ return null;
18968
+ }
18969
+ var outerRadius = $$.getRadius(d).outerRadius;
18970
+ var arcOuterRadius = outerRadius;
18971
+ if ($$.hasType("polar")) {
18972
+ // For polar, arc radius is proportional to data value
18973
+ arcOuterRadius = $$.getPolarOuterRadius(d, outerRadius);
18974
+ // But labels should be positioned outside the full chart radius (levels)
18975
+ outerRadius = state.radius;
18976
+ }
18977
+ var midAngle = (updated.startAngle + updated.endAngle) / 2;
18978
+ // Check if this is a single data item (full circle arc)
18979
+ // When arc spans the entire circle, position label on the right side to avoid legend overlap
18980
+ var isFullCircleArc = Math.abs((updated.endAngle - updated.startAngle) - (2 * Math.PI)) < 0.01;
18981
+ if (isFullCircleArc) {
18982
+ // Position at 3 o'clock (π/2 from top) for single data item
18983
+ midAngle = Math.PI / 2;
18984
+ }
18985
+ // Pre-calculate trigonometric values
18986
+ var sinAngle = Math.sin(midAngle);
18987
+ var cosAngle = -Math.cos(midAngle);
18988
+ // Start point: at the arc edge (for polar, this is the data-proportional radius)
18989
+ var startPoint = {
18990
+ x: sinAngle * arcOuterRadius,
18991
+ y: cosAngle * arcOuterRadius
18992
+ };
18993
+ // Break point: extends outward from the full chart radius (outside levels for polar)
18994
+ var breakRadius = outerRadius + BREAK_POINT_OFFSET;
18995
+ var breakPoint = {
18996
+ x: sinAngle * breakRadius,
18997
+ y: cosAngle * breakRadius
18998
+ };
18999
+ // Determine if label is on the right side of the chart
19000
+ // Use pre-calculated sinAngle to account for startingAngle offset
19001
+ var isRight = sinAngle >= 0;
19002
+ // End point: extends horizontally from break point
19003
+ var endPoint = {
19004
+ x: breakPoint.x + (lineDistance * (isRight ? 1 : -1)),
19005
+ y: breakPoint.y
19006
+ };
19007
+ return { startPoint: startPoint, breakPoint: breakPoint, endPoint: endPoint, isRight: isRight, midAngle: midAngle };
19008
+ }
19009
+ /**
19010
+ * Check if label with line type is enabled for arc charts
19011
+ * @this {object} ChartInternal context
19012
+ * @returns {boolean} Whether label with lines are enabled
19013
+ * @private
19014
+ */
19015
+ function isLabelWithLine() {
19016
+ return getConfig.call(this).line.show;
19017
+ }
19018
+ /**
19019
+ * Render connector lines and text for label with lines
19020
+ * @this {object} ChartInternal context
19021
+ * @param {number} duration Transition duration
19022
+ * @private
19023
+ */
19024
+ function redrawArcLabelLines(duration) {
19025
+ var $$ = this;
19026
+ var arcs = $$.$el.arcs, $T = $$.$T;
19027
+ // Get config once and reuse (avoid N+1 calls)
19028
+ var _a = getConfig.call($$), lineConfig = _a.line, textConfig = _a.text;
19029
+ var lineDistance = lineConfig.distance;
19030
+ // Cache fontSize from first text element to avoid repeated getComputedStyle calls
19031
+ var cachedFontSize = null;
19032
+ arcs.selectAll(".".concat($ARC.chartArc)).each(function (d) {
19033
+ var _a, _b, _c;
19034
+ var g = select(this);
19035
+ var linePos = getLinePosition.call($$, d, lineDistance);
19036
+ // Use cached values from textForArcLabel if available, otherwise calculate
19037
+ var _d = (_a = d._cache) !== null && _a !== void 0 ? _a : {}, ratio = _d.ratio, meetsThreshold = _d.meetsThreshold, updated = _d.updated;
19038
+ // Handle invalid data
19039
+ if (!updated || !linePos) {
19040
+ return;
19041
+ }
19042
+ var isVisible = $$.isTargetToShow(d.data.id) && meetsThreshold;
19043
+ // --- Render connector line (polyline) ---
19044
+ var startPoint = linePos.startPoint, breakPoint = linePos.breakPoint, endPoint = linePos.endPoint, isRight = linePos.isRight;
19045
+ var points = "".concat(startPoint.x, ",").concat(startPoint.y, " ").concat(breakPoint.x, ",").concat(breakPoint.y, " ").concat(endPoint.x, ",").concat(endPoint.y);
19046
+ if (lineConfig.show) {
19047
+ var line = g.select(".".concat($ARC.arcLabelLine));
19048
+ if (line.empty()) {
19049
+ line = g.append("polyline")
19050
+ .attr("class", $ARC.arcLabelLine);
19051
+ }
19052
+ $T(line, duration)
19053
+ .attr("points", points)
19054
+ .style("stroke", $$.color(d.data))
19055
+ .style("opacity", isVisible ? null : "0");
19056
+ }
19057
+ // --- Render text ---
19058
+ var labelLineText = g.select(".".concat($ARC.arcLabelLineText));
19059
+ if (labelLineText.empty()) {
19060
+ labelLineText = g.append("text")
19061
+ .attr("class", $ARC.arcLabelLineText)
19062
+ .style("pointer-events", "none");
19063
+ }
19064
+ if (isVisible) {
19065
+ var value = updated.value;
19066
+ var id = d.data.id;
19067
+ // Get formatted text
19068
+ var text = ((_c = (_b = textConfig.formatter) !== null && _b !== void 0 ? _b : $$.getArcLabelConfig("format")) !== null && _c !== void 0 ? _c : $$.defaultArcValueFormat)(value, ratio, id).toString();
19069
+ setTextValue(labelLineText, text, [-1, 1], false);
19070
+ // Position the text at the end of the connector line (outside)
19071
+ var pos = {
19072
+ x: endPoint.x + (5 * (isRight ? 1 : -1)), // 5: label offset from endpoint
19073
+ y: endPoint.y
19074
+ };
19075
+ // Configure text alignment based on position
19076
+ labelLineText.style("text-anchor", isRight ? "start" : "end");
19077
+ // Handle text vertical alignment by adjusting translate y position
19078
+ var textNode = labelLineText.node();
19079
+ var tspanNodes = textNode === null || textNode === void 0 ? void 0 : textNode.querySelectorAll("tspan");
19080
+ // Cache fontSize on first access to avoid repeated getComputedStyle calls
19081
+ if (cachedFontSize === null) {
19082
+ cachedFontSize = parseFloat(win.getComputedStyle(textNode).fontSize) || 12;
19083
+ }
19084
+ if (tspanNodes && tspanNodes.length > 1) {
19085
+ // Multiline: adjust for vertical centering
19086
+ // With setTextValue(text, [-1, 1], false):
19087
+ // - 1st line at -1em, 2nd at 0em, 3rd at 1em, 4th at 2em, ...
19088
+ // - Center of text block = (-1 + (lineCount - 2)) / 2 = (lineCount - 3) / 2
19089
+ // - To center at y=0, shift by negative of center
19090
+ var lineCount = tspanNodes.length;
19091
+ var centerOffset = (lineCount - 3) / 2;
19092
+ pos.y += (-centerOffset + TEXT_VERTICAL_OFFSET) * cachedFontSize;
19093
+ }
19094
+ else {
19095
+ // Single line: apply base vertical offset
19096
+ pos.y += TEXT_VERTICAL_OFFSET * cachedFontSize;
19097
+ }
19098
+ $T(labelLineText, duration)
19099
+ .attr("transform", "translate(".concat(pos.x, ",").concat(pos.y, ")"))
19100
+ .style("opacity", null)
19101
+ .style("fill", $$.updateTextColor.bind($$)(d));
19102
+ }
19103
+ else {
19104
+ $T(labelLineText, duration)
19105
+ .style("opacity", "0");
19106
+ }
19107
+ });
19108
+ }
19109
+
19110
+ /**
19111
+ * Get the first matching arc chart type
19112
+ * @param {ChartInternalThis} $$ ChartInternal context
19113
+ * @returns {string|undefined} Chart type or undefined
19114
+ * @private
19115
+ */
19116
+ function _getArcType($$) {
19117
+ return ["donut", "pie", "polar", "gauge"].find(function (type) { return $$.hasType(type); });
19118
+ }
19119
+ /**
19120
+ * Calculate position for range text or multi-arc gauge labels
19121
+ * @param {ChartInternalThis} $$ ChartInternal context
19122
+ * @param {IArcData} d Data object
19123
+ * @param {IArcData} updated Updated angle data
19124
+ * @param {boolean} forRange Whether is for ranged text option
19125
+ * @returns {object} Position object {x, y}
19126
+ * @private
19127
+ */
19128
+ function _calculateRangeOrGaugePosition($$, d, updated, forRange) {
19129
+ var _a, _b;
19130
+ var config = $$.config, radiusExpanded = $$.state.radiusExpanded;
19131
+ var angle = updated.endAngle - Math.PI / 2;
19132
+ var sinAngle = Math.sin(angle);
19133
+ var pos = {
19134
+ x: Math.cos(angle) * (radiusExpanded + (forRange ? 5 : 25)), // 5: range offset, 25: gauge offset
19135
+ y: sinAngle * (radiusExpanded + 15 - Math.abs(sinAngle * 10)) + 3 // 10: y factor, 3: y offset
19136
+ };
19137
+ if (forRange) {
19138
+ var rangeTextPosition = config.arc_rangeText_position;
19139
+ if (rangeTextPosition) {
19140
+ var rangeValues = config.arc_rangeText_values;
19141
+ var position = isFunction(rangeTextPosition) ?
19142
+ rangeTextPosition(rangeValues[d.index]) :
19143
+ rangeTextPosition;
19144
+ pos.x += (_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : 0;
19145
+ pos.y += (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : 0;
19146
+ }
19147
+ }
19148
+ return pos;
19149
+ }
19150
+ /**
19151
+ * Calculate label ratio for standard arc types
19152
+ * @param {ChartInternalThis} $$ ChartInternal context
19153
+ * @param {IArcData} d Data object
19154
+ * @param {number} outerRadius Outer radius value
19155
+ * @param {number} distance Distance from center
19156
+ * @returns {number} Calculated ratio
19157
+ * @private
19158
+ */
19159
+ function _calculateLabelRatio($$, d, outerRadius, distance) {
19160
+ var config = $$.config;
19161
+ var chartType = _getArcType($$);
19162
+ var ratio = chartType ? config["".concat(chartType, "_label_ratio")] : undefined;
19163
+ if (ratio) {
19164
+ ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, distance) : ratio;
19165
+ }
19166
+ else {
19167
+ // Label positioning constants
19168
+ var LABEL_MIN_SIZE = 36; // Minimum space needed for label text (pixels)
19169
+ var LABEL_RATIO_THRESHOLD = 0.375; // Threshold ratio (3/8) to determine "small chart"
19170
+ var LABEL_RATIO_BASE = 1.175; // Base ratio for dynamic positioning on small charts
19171
+ var LABEL_RATIO_LARGE = 0.8; // Fixed ratio for large charts (80% position)
19172
+ // Calculate ratio based on chart size
19173
+ // For small charts (label space > 37.5% of radius), position labels closer to center
19174
+ // For large charts, use fixed 80% position
19175
+ var labelSpaceRatio = LABEL_MIN_SIZE / outerRadius;
19176
+ var isSmallChart = labelSpaceRatio > LABEL_RATIO_THRESHOLD;
19177
+ ratio = outerRadius && distance ?
19178
+ (isSmallChart ? LABEL_RATIO_BASE - labelSpaceRatio : LABEL_RATIO_LARGE) * outerRadius /
19179
+ distance :
19180
+ 0;
19181
+ }
19182
+ return ratio;
19183
+ }
19184
+ /**
19185
+ * Calculate position for standard arc label (donut, pie, polar)
19186
+ * @param {ChartInternalThis} $$ ChartInternal context
19187
+ * @param {IArcData} d Data object
19188
+ * @param {IArcData} updated Updated angle data
19189
+ * @returns {object} Object with pos {x, y} and ratio
19190
+ * @private
19191
+ */
19192
+ function _calculateStandardArcPosition($$, d, updated) {
19193
+ var outerRadius = $$.getRadius(d).outerRadius;
19194
+ if ($$.hasType("polar")) {
19195
+ outerRadius = $$.getPolarOuterRadius(d, outerRadius);
19196
+ }
19197
+ var _a = $$.svgArc.centroid(updated).map(function (v) { return (isNaN(v) ? 0 : v); }), x = _a[0], y = _a[1];
19198
+ var distance = Math.sqrt(x * x + y * y);
19199
+ var ratio = _calculateLabelRatio($$, d, outerRadius, distance);
19200
+ return {
19201
+ pos: { x: x, y: y },
19202
+ ratio: ratio
19203
+ };
19204
+ }
18429
19205
  /**
18430
19206
  * Get radius functions
18431
19207
  * @param {number} expandRate Expand rate number.
@@ -18434,7 +19210,7 @@ var options = {
18434
19210
  * @returns {object} radius functions
18435
19211
  * @private
18436
19212
  */
18437
- function getRadiusFn(expandRate) {
19213
+ function _getRadiusFn(expandRate) {
18438
19214
  if (expandRate === void 0) { expandRate = 0; }
18439
19215
  var $$ = this;
18440
19216
  var config = $$.config, state = $$.state;
@@ -18508,11 +19284,11 @@ function getRadiusFn(expandRate) {
18508
19284
  }
18509
19285
  /**
18510
19286
  * Get attrTween function to get interpolated value on transition
18511
- * @param {Function} fn Arc function to execute
18512
- * @returns {Function} attrTween function
19287
+ * @param {function} fn Arc function to execute
19288
+ * @returns {function} attrTween function
18513
19289
  * @private
18514
19290
  */
18515
- function getAttrTweenFn(fn) {
19291
+ function _getAttrTweenFn(fn) {
18516
19292
  return function (d) {
18517
19293
  var getAngleKeyValue = function (_a) {
18518
19294
  var _b = _a.startAngle, startAngle = _b === void 0 ? 0 : _b, _c = _a.endAngle, endAngle = _c === void 0 ? 0 : _c, _d = _a.padAngle, padAngle = _d === void 0 ? 0 : _d;
@@ -18557,8 +19333,14 @@ var shapeArc = {
18557
19333
  var w = config.gauge_width || config.donut_width;
18558
19334
  var gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length *
18559
19335
  config.gauge_arcs_minWidth;
19336
+ // Radius reduction ratio when labels are present
19337
+ var LABEL_RADIUS_RATIO = 0.85;
19338
+ // Reduce radius for label with lines to make room for external labels
19339
+ var labelWithLineRatio = isLabelWithLine.call($$) ? LABEL_RADIUS_RATIO : 1;
18560
19340
  // determine radius
18561
- state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() && config.gauge_label_show ? 0.85 : 1);
19341
+ state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() && config.gauge_label_show ?
19342
+ LABEL_RADIUS_RATIO :
19343
+ labelWithLineRatio);
18562
19344
  state.radius = state.radiusExpanded * 0.95;
18563
19345
  state.innerRadiusRatio = w ? (state.radius - w) / state.radius : 0.6;
18564
19346
  state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ?
@@ -18695,7 +19477,7 @@ var shapeArc = {
18695
19477
  },
18696
19478
  getSvgArc: function () {
18697
19479
  var $$ = this;
18698
- var _a = getRadiusFn.call($$), inner = _a.inner, outer = _a.outer, corner = _a.corner;
19480
+ var _a = _getRadiusFn.call($$), inner = _a.inner, outer = _a.outer, corner = _a.corner;
18699
19481
  var arc$1 = arc()
18700
19482
  .innerRadius(inner)
18701
19483
  .outerRadius(outer);
@@ -18717,13 +19499,13 @@ var shapeArc = {
18717
19499
  /**
18718
19500
  * Get expanded arc path function
18719
19501
  * @param {number} rate Expand rate
18720
- * @returns {Function} Expanded arc path getter function
19502
+ * @returns {function} Expanded arc path getter function
18721
19503
  * @private
18722
19504
  */
18723
19505
  getSvgArcExpanded: function (rate) {
18724
19506
  if (rate === void 0) { rate = 1; }
18725
19507
  var $$ = this;
18726
- var _a = getRadiusFn.call($$, rate), inner = _a.inner, outer = _a.outer, corner = _a.corner;
19508
+ var _a = _getRadiusFn.call($$, rate), inner = _a.inner, outer = _a.outer, corner = _a.corner;
18727
19509
  var arc$1 = arc()
18728
19510
  .innerRadius(inner)
18729
19511
  .outerRadius(outer);
@@ -18788,58 +19570,28 @@ var shapeArc = {
18788
19570
  * @private
18789
19571
  */
18790
19572
  transformForArcLabel: function (textNode, d, forRange) {
18791
- var _a, _b, _c;
18792
19573
  if (forRange === void 0) { forRange = false; }
18793
19574
  var $$ = this;
18794
- var config = $$.config, radiusExpanded = $$.state.radiusExpanded;
18795
19575
  var updated = $$.updateAngle(d, forRange);
18796
- var pos = { x: 0, y: 0 };
18797
- var translate = "";
19576
+ if (!updated) {
19577
+ return "";
19578
+ }
19579
+ var pos;
18798
19580
  var ratio = 1;
18799
- if (updated) {
18800
- if (forRange || $$.hasMultiArcGauge()) {
18801
- var y1 = Math.sin(updated.endAngle - Math.PI / 2);
18802
- var rangeTextPosition = config.arc_rangeText_position;
18803
- pos.x = Math.cos(updated.endAngle - Math.PI / 2) *
18804
- (radiusExpanded + (forRange ? 5 : 25));
18805
- pos.y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
18806
- if (forRange && rangeTextPosition) {
18807
- var rangeValues = config.arc_rangeText_values;
18808
- var position = isFunction(rangeTextPosition) ?
18809
- rangeTextPosition(rangeValues[d.index]) :
18810
- rangeTextPosition;
18811
- pos.x += (_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : 0;
18812
- pos.y += (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : 0;
18813
- }
18814
- // translate = `translate(${x},${y})`;
18815
- }
18816
- else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
18817
- var outerRadius = $$.getRadius(d).outerRadius;
18818
- if ($$.hasType("polar")) {
18819
- outerRadius = $$.getPolarOuterRadius(d, outerRadius);
18820
- }
18821
- var c = this.svgArc.centroid(updated);
18822
- var _d = c.map(function (v) { return (isNaN(v) ? 0 : v); }), x = _d[0], y = _d[1];
18823
- var h = Math.sqrt(x * x + y * y);
18824
- pos.x = x;
18825
- pos.y = y;
18826
- ratio = (_c = ["donut", "gauge", "pie", "polar"]
18827
- .filter($$.hasType.bind($$))
18828
- .map(function (v) { return config["".concat(v, "_label_ratio")]; })) === null || _c === void 0 ? void 0 : _c[0];
18829
- if (ratio) {
18830
- ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
18831
- }
18832
- else {
18833
- ratio = outerRadius && (h ?
18834
- (36 / outerRadius > 0.375 ? 1.175 - 36 / outerRadius : 0.8) *
18835
- outerRadius / h :
18836
- 0);
18837
- }
18838
- }
18839
- updateTextImagePos.call($$, textNode, pos);
18840
- translate = "translate(".concat(pos.x * ratio, ",").concat(pos.y * ratio, ")");
19581
+ // Handle range text or multi-arc gauge labels
19582
+ if (forRange || $$.hasMultiArcGauge()) {
19583
+ pos = _calculateRangeOrGaugePosition($$, d, updated, forRange);
19584
+ } // Handle standard arc types (donut, pie, polar)
19585
+ else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
19586
+ var result = _calculateStandardArcPosition($$, d, updated);
19587
+ pos = result.pos;
19588
+ ratio = result.ratio;
19589
+ }
19590
+ else {
19591
+ return "";
18841
19592
  }
18842
- return translate;
19593
+ updateTextImagePos.call($$, textNode, pos);
19594
+ return "translate(".concat(pos.x * ratio, ",").concat(pos.y * ratio, ")");
18843
19595
  },
18844
19596
  convertToArcData: function (d) {
18845
19597
  return this.addName({
@@ -18850,8 +19602,10 @@ var shapeArc = {
18850
19602
  });
18851
19603
  },
18852
19604
  textForArcLabel: function (selection) {
19605
+ var _a;
18853
19606
  var $$ = this;
18854
19607
  var hasGauge = $$.hasType("gauge");
19608
+ var chartType = (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) === null || _a === void 0 ? void 0 : _a[0];
18855
19609
  if ($$.shouldShowArcLabel()) {
18856
19610
  selection
18857
19611
  .style("fill", $$.updateTextColor.bind($$))
@@ -18859,12 +19613,13 @@ var shapeArc = {
18859
19613
  return $$.updateTextBGColor.bind($$)(d, $$.config.data_labels_backgroundColors);
18860
19614
  })
18861
19615
  .each(function (d) {
18862
- var _a;
18863
19616
  var node = select(this);
18864
19617
  var updated = $$.updateAngle(d);
18865
19618
  var ratio = $$.getRatio("arc", updated);
18866
- var isUnderThreshold = meetsLabelThreshold.call($$, ratio, (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) === null || _a === void 0 ? void 0 : _a[0]);
18867
- if (isUnderThreshold) {
19619
+ var meetsThreshold = meetsLabelThreshold.call($$, ratio, chartType);
19620
+ // Cache calculated values for reuse in redrawArcLabelLines
19621
+ d._cache = { updated: updated, ratio: ratio, meetsThreshold: meetsThreshold };
19622
+ if (meetsThreshold) {
18868
19623
  var value = (updated || d).value;
18869
19624
  var text = ($$.getArcLabelConfig("format") || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
18870
19625
  setTextValue(node, text, [-1, 1], hasGauge);
@@ -18901,10 +19656,10 @@ var shapeArc = {
18901
19656
  // @ts-ignore
18902
19657
  .transition()
18903
19658
  .duration(expandDuration)
18904
- .attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$)))
19659
+ .attrTween("d", _getAttrTweenFn($$.svgArcExpanded.bind($$)))
18905
19660
  .transition()
18906
19661
  .duration(expandDuration * 2)
18907
- .attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
19662
+ .attrTween("d", _getAttrTweenFn(svgArcExpandedSub.bind($$)));
18908
19663
  });
18909
19664
  },
18910
19665
  unexpandArc: function (targetIds) {
@@ -18918,7 +19673,7 @@ var shapeArc = {
18918
19673
  .selectAll("path")
18919
19674
  .transition()
18920
19675
  .duration(function (d) { return $$.getExpandConfig(d.data.id, "duration"); })
18921
- .attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
19676
+ .attrTween("d", _getAttrTweenFn($$.svgArc.bind($$)));
18922
19677
  svg.selectAll("".concat($ARC.arc))
18923
19678
  .style("opacity", null);
18924
19679
  },
@@ -19000,7 +19755,7 @@ var shapeArc = {
19000
19755
  .attr("class", classArcs)
19001
19756
  .merge(mainPieUpdate);
19002
19757
  mainPieEnter.append("text")
19003
- .attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : ".35em")
19758
+ .attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : null)
19004
19759
  .style("opacity", "0")
19005
19760
  .style("text-anchor", $$.getStylePropValue("middle"))
19006
19761
  .style("pointer-events", $$.getStylePropValue("none"));
@@ -19384,7 +20139,7 @@ var shapeArc = {
19384
20139
  var id = (arcData === null || arcData === void 0 ? void 0 : arcData.id) || undefined;
19385
20140
  $$.callOverOutForTouch(arcData);
19386
20141
  isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
19387
- });
20142
+ }, { passive: true });
19388
20143
  }
19389
20144
  },
19390
20145
  redrawArcText: function (duration) {
@@ -19436,6 +20191,8 @@ var shapeArc = {
19436
20191
  .text($$.textForGaugeMinMax(config.gauge_max, true));
19437
20192
  }
19438
20193
  }
20194
+ // Render connector lines for label with lines
20195
+ isLabelWithLine.call($$) && redrawArcLabelLines.call($$, duration);
19439
20196
  },
19440
20197
  /**
19441
20198
  * Get Arc element by id or index
@@ -19505,7 +20262,7 @@ var shapeArea = {
19505
20262
  },
19506
20263
  /**
19507
20264
  * Redraw function
19508
- * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
20265
+ * @param {function} drawFn Retuned functino from .generateDrawCandlestick()
19509
20266
  * @param {boolean} withTransition With or without transition
19510
20267
  * @param {boolean} isSub Subchart draw
19511
20268
  * @returns {Array}
@@ -19526,7 +20283,7 @@ var shapeArea = {
19526
20283
  * Generate area path data
19527
20284
  * @param {object} areaIndices Indices
19528
20285
  * @param {boolean} isSub Weather is sub axis
19529
- * @returns {Function}
20286
+ * @returns {function}
19530
20287
  * @private
19531
20288
  */
19532
20289
  generateDrawArea: function (areaIndices, isSub) {
@@ -19608,8 +20365,9 @@ var shapeArea = {
19608
20365
  * Get the type of connect line for bar chart
19609
20366
  * @param {string} id Data id
19610
20367
  * @returns {string|null} Connect line type or null if not applicable
20368
+ * @private
19611
20369
  */
19612
- function getConnectLineType(id) {
20370
+ function _getConnectLineType(id) {
19613
20371
  var connectLine = this.config.bar_connectLine;
19614
20372
  var type = (connectLine === null || connectLine === void 0 ? void 0 : connectLine[id]) || connectLine;
19615
20373
  return (/^(start|end)\-(start|end)$/.test(type)) ? type : null;
@@ -19654,7 +20412,7 @@ var shapeBar = {
19654
20412
  $$.setCssRule(true, " .".concat($BAR.bar), ["fill"], $$.color)(selection);
19655
20413
  // add bar connect line
19656
20414
  selection.each(function (d) {
19657
- if (getConnectLineType.call($$, d.id)) {
20415
+ if (_getConnectLineType.call($$, d.id)) {
19658
20416
  select(this).append("path")
19659
20417
  .attr("class", $BAR.barConnectLine);
19660
20418
  }
@@ -19702,7 +20460,7 @@ var shapeBar = {
19702
20460
  },
19703
20461
  /**
19704
20462
  * Redraw function
19705
- * @param {Function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
20463
+ * @param {function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
19706
20464
  * @param {boolean} withTransition With or without transition
19707
20465
  * @param {boolean} isSub Subchart draw
19708
20466
  * @returns {Array}
@@ -19717,7 +20475,7 @@ var shapeBar = {
19717
20475
  $$.$T(bar, withTransition, getRandom())
19718
20476
  .attr("d", function (d, i, arr) {
19719
20477
  var path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
19720
- var connectLineType = getConnectLineType.call($$, d.id);
20478
+ var connectLineType = _getConnectLineType.call($$, d.id);
19721
20479
  // for bar.coonectLine option
19722
20480
  if (path.length > 1) {
19723
20481
  barPath.push(path[1]);
@@ -19751,7 +20509,7 @@ var shapeBar = {
19751
20509
  * -------------------------
19752
20510
  * 0 1
19753
20511
  * @param {boolean} isSub If is for subchart
19754
- * @returns {Function}
20512
+ * @returns {function}
19755
20513
  * @private
19756
20514
  */
19757
20515
  generateDrawBar: function (barIndices, isSub) {
@@ -19824,7 +20582,7 @@ var shapeBar = {
19824
20582
  "H".concat(pos, " ").concat(pathRadius[0], "V").concat(points[2][indexY] - radius, " ").concat(pathRadius[1], "H").concat(points[3][indexX]) :
19825
20583
  "V".concat(pos, " ").concat(pathRadius[0], "H").concat(points[2][indexX] - radius, " ").concat(pathRadius[1], "V").concat(points[3][indexY]);
19826
20584
  var coords = ["M".concat(points[0][indexX], ",").concat(points[0][indexY]).concat(path, "z")];
19827
- if (getConnectLineType.call($$, d.id)) {
20585
+ if (_getConnectLineType.call($$, d.id)) {
19828
20586
  coords.push(isRotated ?
19829
20587
  {
19830
20588
  x: points[0][indexX],
@@ -20072,7 +20830,7 @@ var shapeCandlestick = {
20072
20830
  * Get draw function
20073
20831
  * @param {object} indices Indice data
20074
20832
  * @param {boolean} isSub Subchart draw
20075
- * @returns {Function}
20833
+ * @returns {function}
20076
20834
  * @private
20077
20835
  */
20078
20836
  generateDrawCandlestick: function (indices, isSub) {
@@ -20124,7 +20882,7 @@ var shapeCandlestick = {
20124
20882
  * Generate shape drawing points
20125
20883
  * @param {object} indices Indice data
20126
20884
  * @param {boolean} isSub Subchart draw
20127
- * @returns {Function}
20885
+ * @returns {function}
20128
20886
  */
20129
20887
  generateGetCandlestickPoints: function (indices, isSub) {
20130
20888
  if (isSub === void 0) { isSub = false; }
@@ -20172,7 +20930,7 @@ var shapeCandlestick = {
20172
20930
  },
20173
20931
  /**
20174
20932
  * Redraw function
20175
- * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
20933
+ * @param {function} drawFn Retuned functino from .generateDrawCandlestick()
20176
20934
  * @param {boolean} withTransition With or without transition
20177
20935
  * @param {boolean} isSub Subchart draw
20178
20936
  * @returns {Array}
@@ -20225,7 +20983,7 @@ var shapeCandlestick = {
20225
20983
  * @returns {object} size object
20226
20984
  * @private
20227
20985
  */
20228
- function getSize(checkNeck) {
20986
+ function _getSize(checkNeck) {
20229
20987
  if (checkNeck === void 0) { checkNeck = false; }
20230
20988
  var $$ = this;
20231
20989
  var config = $$.config, _a = $$.state.current, width = _a.width, height = _a.height;
@@ -20234,7 +20992,7 @@ function getSize(checkNeck) {
20234
20992
  (padding.top + padding.bottom) }, padding);
20235
20993
  // determine if container width to not be less than neck width
20236
20994
  if (checkNeck) {
20237
- var _b = getNecklSize.call($$, {
20995
+ var _b = _getNeckSize.call($$, {
20238
20996
  width: size.width,
20239
20997
  height: size.height
20240
20998
  }), neckWidth = _b.width, neckHeight = _b.height;
@@ -20254,7 +21012,7 @@ function getSize(checkNeck) {
20254
21012
  * @returns {object} size object
20255
21013
  * @private
20256
21014
  */
20257
- function getNecklSize(current) {
21015
+ function _getNeckSize(current) {
20258
21016
  var _a;
20259
21017
  var $$ = this;
20260
21018
  var config = $$.config;
@@ -20278,9 +21036,9 @@ function getNecklSize(current) {
20278
21036
  * @returns {Array} Coordinate points
20279
21037
  * @private
20280
21038
  */
20281
- function getCoord(d) {
21039
+ function _getCoord(d) {
20282
21040
  var $$ = this;
20283
- var _a = getSize.call($$, true), top = _a.top, left = _a.left, width = _a.width;
21041
+ var _a = _getSize.call($$, true), top = _a.top, left = _a.left, width = _a.width;
20284
21042
  var coords = [];
20285
21043
  d.forEach(function (d, i) {
20286
21044
  var ratio = d.ratio;
@@ -20306,11 +21064,11 @@ function getCoord(d) {
20306
21064
  * @returns {string} path
20307
21065
  * @private
20308
21066
  */
20309
- function getClipPath(forBackground) {
21067
+ function _getClipPath(forBackground) {
20310
21068
  if (forBackground === void 0) { forBackground = false; }
20311
21069
  var $$ = this;
20312
- var _a = getSize.call($$, true), width = _a.width, height = _a.height, top = _a.top, left = _a.left;
20313
- var neck = getNecklSize.call($$, { width: width, height: height });
21070
+ var _a = _getSize.call($$, true), width = _a.width, height = _a.height, top = _a.top, left = _a.left;
21071
+ var neck = _getNeckSize.call($$, { width: width, height: height });
20314
21072
  var leftX = (width - neck.width) / 2;
20315
21073
  var rightX = (width + neck.width) / 2;
20316
21074
  var bodyHeigth = height - neck.height;
@@ -20337,7 +21095,7 @@ function getClipPath(forBackground) {
20337
21095
  * @returns {Array}
20338
21096
  * @private
20339
21097
  */
20340
- function getFunnelData(d) {
21098
+ function _getFunnelData(d) {
20341
21099
  var $$ = this;
20342
21100
  var config = $$.config;
20343
21101
  var data = d.map(function (d) { return ({
@@ -20347,7 +21105,7 @@ function getFunnelData(d) {
20347
21105
  if (config.data_order) {
20348
21106
  data.sort($$.getSortCompareFn.bind($$)(true));
20349
21107
  }
20350
- return updateRatio.call($$, data);
21108
+ return _updateRatio.call($$, data);
20351
21109
  }
20352
21110
  /**
20353
21111
  * Update ratio value
@@ -20355,9 +21113,9 @@ function getFunnelData(d) {
20355
21113
  * @returns {Array} Updated data object
20356
21114
  * @private
20357
21115
  */
20358
- function updateRatio(data) {
21116
+ function _updateRatio(data) {
20359
21117
  var $$ = this;
20360
- var height = getSize.call($$).height;
21118
+ var height = _getSize.call($$).height;
20361
21119
  var total = $$.getTotalDataSum(true);
20362
21120
  data.forEach(function (d) {
20363
21121
  // ratio = shape's height
@@ -20407,7 +21165,7 @@ var shapeFunnel = {
20407
21165
  $$.showTooltip([data], event.target);
20408
21166
  /^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
20409
21167
  }
20410
- })
21168
+ }, isTouch ? { passive: true } : undefined)
20411
21169
  .on(isTouch ? "touchend" : "mouseout", function (event) {
20412
21170
  var data = getTarget(event);
20413
21171
  if (config.interaction_onout) {
@@ -20430,7 +21188,7 @@ var shapeFunnel = {
20430
21188
  if (!funnel) {
20431
21189
  $$.initFunnel();
20432
21190
  }
20433
- var targets = getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
21191
+ var targets = _getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
20434
21192
  var mainFunnelUpdate = funnel
20435
21193
  .selectAll(".".concat($FUNNEL.chartFunnel))
20436
21194
  .data($$.filterNullish(targets));
@@ -20471,7 +21229,7 @@ var shapeFunnel = {
20471
21229
  var $$ = this;
20472
21230
  var funnel = $$.$el.funnel;
20473
21231
  var targets = $$.filterTargetsToShow(funnel.path);
20474
- var _a = getSize.call($$), top = _a.top, left = _a.left, right = _a.right;
21232
+ var _a = _getSize.call($$), top = _a.top, left = _a.left, right = _a.right;
20475
21233
  var center = (left - right) / 2;
20476
21234
  var points = {};
20477
21235
  var accumulatedHeight = top !== null && top !== void 0 ? top : 0;
@@ -20492,10 +21250,10 @@ var shapeFunnel = {
20492
21250
  var $$ = this;
20493
21251
  var $T = $$.$T, funnel = $$.$el.funnel;
20494
21252
  var targets = $$.filterTargetsToShow(funnel.path);
20495
- var coords = getCoord.call($$, updateRatio.call($$, targets.data()));
21253
+ var coords = _getCoord.call($$, _updateRatio.call($$, targets.data()));
20496
21254
  // set neck path
20497
- funnel.attr("clip-path", "path('".concat(getClipPath.bind($$)(), "')"));
20498
- funnel.background.attr("d", getClipPath.call($$, true));
21255
+ funnel.attr("clip-path", "path('".concat(_getClipPath.bind($$)(), "')"));
21256
+ funnel.background.attr("d", _getClipPath.call($$, true));
20499
21257
  $T(targets)
20500
21258
  .attr("d", function (d, i) { return "M".concat(coords[i].join("L"), "z"); })
20501
21259
  .style("opacity", "1");
@@ -20614,7 +21372,7 @@ var shapeGauge = {
20614
21372
  * @returns {object} Stroke dasharray style value and its length
20615
21373
  * @private
20616
21374
  */
20617
- function getStrokeDashArray(start, end, pattern, isLastX) {
21375
+ function _getStrokeDashArray(start, end, pattern, isLastX) {
20618
21376
  if (isLastX === void 0) { isLastX = false; }
20619
21377
  var dash = start ? [start, 0] : pattern;
20620
21378
  var _loop_1 = function (i) {
@@ -20646,7 +21404,7 @@ function getStrokeDashArray(start, end, pattern, isLastX) {
20646
21404
  * @returns {object} Regions data
20647
21405
  * @private
20648
21406
  */
20649
- function getRegions(d, _regions, isTimeSeries) {
21407
+ function _getRegions(d, _regions, isTimeSeries) {
20650
21408
  var $$ = this;
20651
21409
  var regions = [];
20652
21410
  var dasharray = "2 2"; // default value
@@ -20708,8 +21466,7 @@ var shapeLine = {
20708
21466
  var $$ = this;
20709
21467
  var extraLineClasses = $$.format.extraLineClasses, $el = $$.$el, $T = $$.$T;
20710
21468
  var $root = isSub ? $el.subchart : $el;
20711
- var line = $root.main
20712
- .selectAll(".".concat($LINE.lines))
21469
+ var line = $root.main.selectAll(".".concat($LINE.lines))
20713
21470
  .selectAll(".".concat($LINE.line))
20714
21471
  .data($$.lineData.bind($$));
20715
21472
  $T(line.exit(), withTransition)
@@ -20725,7 +21482,7 @@ var shapeLine = {
20725
21482
  },
20726
21483
  /**
20727
21484
  * Redraw function
20728
- * @param {Function} drawFn Retuned functino from .generateDrawCandlestick()
21485
+ * @param {function} drawFn Retuned functino from .generateDrawCandlestick()
20729
21486
  * @param {boolean} withTransition With or without transition
20730
21487
  * @param {boolean} isSub Subchart draw
20731
21488
  * @returns {Array}
@@ -20746,7 +21503,7 @@ var shapeLine = {
20746
21503
  /**
20747
21504
  * Get the curve interpolate
20748
21505
  * @param {Array} d Data object
20749
- * @returns {Function}
21506
+ * @returns {function}
20750
21507
  * @private
20751
21508
  */
20752
21509
  getCurve: function (d) {
@@ -20824,8 +21581,8 @@ var shapeLine = {
20824
21581
  /**
20825
21582
  * Set regions dasharray and get path
20826
21583
  * @param {Array} d Data object
20827
- * @param {Function} x x scale function
20828
- * @param {Function} y y scale function
21584
+ * @param {function} x x scale function
21585
+ * @param {function} y y scale function
20829
21586
  * @param {object} _regions regions to be set
20830
21587
  * @returns {stirng} Path string
20831
21588
  * @private
@@ -20836,7 +21593,7 @@ var shapeLine = {
20836
21593
  var isRotated = config.axis_rotated;
20837
21594
  var isTimeSeries = $$.axis.isTimeSeries();
20838
21595
  var dasharray = "2 2"; // default value
20839
- var regions = getRegions.bind($$)(d, _regions, isTimeSeries);
21596
+ var regions = _getRegions.bind($$)(d, _regions, isTimeSeries);
20840
21597
  // when contains null data, can't apply style dashed
20841
21598
  var hasNullDataValue = $$.hasNullDataValue(d);
20842
21599
  var xp;
@@ -20951,7 +21708,7 @@ var shapeLine = {
20951
21708
  isRotated && points.forEach(function (v) { return v.reverse(); });
20952
21709
  var startLength = getLength(tempNode, path);
20953
21710
  var endLength = getLength(tempNode, path += "L".concat(points[1].join(",")));
20954
- var strokeDashArray = getStrokeDashArray(startLength - dashArray.lastLength, endLength - dashArray.lastLength, style, isLastX);
21711
+ var strokeDashArray = _getStrokeDashArray(startLength - dashArray.lastLength, endLength - dashArray.lastLength, style, isLastX);
20955
21712
  dashArray.lastLength += strokeDashArray.length;
20956
21713
  dashArray.dash.push(strokeDashArray.dash);
20957
21714
  }
@@ -21443,7 +22200,7 @@ var shapePoint = {
21443
22200
  * @returns {boolean}
21444
22201
  * @private
21445
22202
  */
21446
- function hasValidPointDrawMethods(point) {
22203
+ function _hasValidPointDrawMethods(point) {
21447
22204
  return isObjectType(point) &&
21448
22205
  isFunction(point.create) && isFunction(point.update);
21449
22206
  }
@@ -21453,7 +22210,7 @@ function hasValidPointDrawMethods(point) {
21453
22210
  * @param {string} id Point id
21454
22211
  * @private
21455
22212
  */
21456
- function insertPointInfoDefs(point, id) {
22213
+ function _insertPointInfoDefs(point, id) {
21457
22214
  var _a;
21458
22215
  var $$ = this;
21459
22216
  var copyAttr = function (from, target) {
@@ -21491,6 +22248,8 @@ var shapePointCommon = {
21491
22248
  * @private
21492
22249
  */
21493
22250
  hasValidPointType: function (type) {
22251
+ // For point.pattern, allow additional SVG shape tags (polygon, ellipse, use)
22252
+ // These will be sanitized before use
21494
22253
  return /^(circle|rect(angle)?|polygon|ellipse|use)$/i.test(type || this.config.point_type);
21495
22254
  },
21496
22255
  /**
@@ -21507,16 +22266,29 @@ var shapePointCommon = {
21507
22266
  var datetimeId = this.state.datetimeId;
21508
22267
  return "".concat(datetimeId, "-point").concat(id);
21509
22268
  },
22269
+ /**
22270
+ * Get validated point pattern array
22271
+ * @returns {Array} Array of point types
22272
+ * @private
22273
+ */
22274
+ getValidPointPattern: function () {
22275
+ var config = this.config;
22276
+ // Ensure point_type is restricted to 'circle' or 'rectangle' only
22277
+ var validPointType = /^(circle|rect(angle)?)$/i.test(config.point_type) ?
22278
+ config.point_type :
22279
+ "circle";
22280
+ return notEmpty(config.point_pattern) ? config.point_pattern : [validPointType];
22281
+ },
21510
22282
  /**
21511
22283
  * Get generate point function
21512
- * @returns {Function}
22284
+ * @returns {function}
21513
22285
  * @private
21514
22286
  */
21515
22287
  generatePoint: function () {
21516
22288
  var $$ = this;
21517
22289
  var $el = $$.$el, config = $$.config;
21518
22290
  var ids = [];
21519
- var pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
22291
+ var pattern = $$.getValidPointPattern();
21520
22292
  return function (method, context) {
21521
22293
  var args = [];
21522
22294
  for (var _i = 2; _i < arguments.length; _i++) {
@@ -21531,11 +22303,11 @@ var shapePointCommon = {
21531
22303
  if ($$.hasValidPointType(point)) {
21532
22304
  point = $$[point];
21533
22305
  }
21534
- else if (!hasValidPointDrawMethods(point || config.point_type)) {
22306
+ else if (!_hasValidPointDrawMethods(point || config.point_type)) {
21535
22307
  var pointId = $$.getDefsPointId(id);
21536
22308
  var defsPoint = $el.defs.select("#".concat(pointId));
21537
22309
  if (defsPoint.size() < 1) {
21538
- insertPointInfoDefs.call($$, point, pointId);
22310
+ _insertPointInfoDefs.call($$, point, pointId);
21539
22311
  }
21540
22312
  if (method === "create") {
21541
22313
  return (_b = $$.custom) === null || _b === void 0 ? void 0 : _b.create.bind(context).apply(void 0, __spreadArray([element, pointId], args, false));
@@ -21675,7 +22447,7 @@ var shapePolar = {
21675
22447
  * @returns {number}
21676
22448
  * @private
21677
22449
  */
21678
- function getPosition(isClockwise, type, edge, pos, range, ratio) {
22450
+ function _getPosition(isClockwise, type, edge, pos, range, ratio) {
21679
22451
  var index = isClockwise && pos > 0 ? edge - pos : pos;
21680
22452
  var r = 2 * Math.PI;
21681
22453
  var func = type === "x" ? Math.sin : Math.cos;
@@ -21733,7 +22505,7 @@ var shapeRadar = {
21733
22505
  var edge = config.axis_x_categories.length;
21734
22506
  var isClockwise = config.radar_direction_clockwise;
21735
22507
  var pos = toArray(type).map(function (v) {
21736
- return getPosition(isClockwise, v, edge, index, isDefined(range) ? range : (type === "x" ? width : height), isNumber(ratio) ? ratio : config.radar_size_ratio);
22508
+ return _getPosition(isClockwise, v, edge, index, isDefined(range) ? range : (type === "x" ? width : height), isNumber(ratio) ? ratio : config.radar_size_ratio);
21737
22509
  });
21738
22510
  return pos.length === 1 ? pos[0] : pos;
21739
22511
  },
@@ -21939,10 +22711,10 @@ var shapeRadar = {
21939
22711
  var index = $$.getDataIndexFromEvent(event);
21940
22712
  $$.selectRectForSingle(svg.node(), index);
21941
22713
  isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
21942
- })
22714
+ }, isMouse ? undefined : { passive: true })
21943
22715
  .on("mouseout", isMouse ? hide : null);
21944
22716
  if (!isMouse) {
21945
- svg.on("touchstart", hide);
22717
+ svg.on("touchstart", hide, { passive: true });
21946
22718
  }
21947
22719
  },
21948
22720
  updateRadarShape: function () {
@@ -22081,7 +22853,7 @@ var shapeTreemap = {
22081
22853
  $$.showTooltip([data], event.currentTarget);
22082
22854
  /^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
22083
22855
  }
22084
- })
22856
+ }, isTouch ? { passive: true } : undefined)
22085
22857
  .on(isTouch ? "touchend" : "mouseout", function (event) {
22086
22858
  var data = getTarget(event);
22087
22859
  if (config.interaction_onout) {
@@ -22093,7 +22865,7 @@ var shapeTreemap = {
22093
22865
  },
22094
22866
  /**
22095
22867
  * Get tiling function
22096
- * @returns {Function}
22868
+ * @returns {function}
22097
22869
  * @private
22098
22870
  */
22099
22871
  getTreemapTile: function () {
@@ -22208,12 +22980,12 @@ var shapeTreemap = {
22208
22980
  /**
22209
22981
  * Get treemap data label format function
22210
22982
  * @param {object} d Data object
22211
- * @returns {Function}
22983
+ * @returns {function} Label formatter function
22212
22984
  * @private
22213
22985
  */
22214
22986
  treemapDataLabelFormat: function (d) {
22215
22987
  var $$ = this;
22216
- var config = $$.config;
22988
+ var treemap = $$.$el.treemap, config = $$.config, _a = $$.scale, x = _a.x, y = _a.y;
22217
22989
  var id = d.id, value = d.value;
22218
22990
  var format = config.treemap_label_format;
22219
22991
  var ratio = $$.getRatio("treemap", d);
@@ -22221,10 +22993,21 @@ var shapeTreemap = {
22221
22993
  var meetLabelThreshold = config.treemap_label_show && meetsLabelThreshold.call($$, ratio, "treemap") ?
22222
22994
  null :
22223
22995
  "0";
22996
+ // Get treemap dimensions for the specific data
22997
+ var treemapNode = treemap.selectAll("g")
22998
+ .filter(function (node) { return node.data.id === id; })
22999
+ .datum();
23000
+ var width = 0;
23001
+ var height = 0;
23002
+ if (treemapNode) {
23003
+ var x0 = treemapNode.x0, x1 = treemapNode.x1, y0 = treemapNode.y0, y1 = treemapNode.y1;
23004
+ width = x(x1) - x(x0);
23005
+ height = y(y1) - y(y0);
23006
+ }
22224
23007
  return function (node) {
22225
23008
  node.style("opacity", meetLabelThreshold);
22226
23009
  return isFunction(format) ?
22227
- format.bind($$.api)(value, ratio, id) :
23010
+ format.bind($$.api)(value, ratio, id, { width: width, height: height }) :
22228
23011
  "".concat(id, "\n").concat(percentValue, "%");
22229
23012
  };
22230
23013
  }
@@ -22241,7 +23024,7 @@ var optPoint = {
22241
23024
  * @type {object}
22242
23025
  * @property {object} point Point object
22243
23026
  * @property {boolean} [point.show=true] Whether to show each point in line.
22244
- * @property {number|Function} [point.r=2.5] The radius size of each point.
23027
+ * @property {number|function} [point.r=2.5] The radius size of each point.
22245
23028
  * - **NOTE:** Disabled for 'bubble' type
22246
23029
  * @property {boolean|object} [point.radialGradient=false] Set the radial gradient on point.<br><br>
22247
23030
  * Or customize by giving below object value:
@@ -22258,7 +23041,7 @@ var optPoint = {
22258
23041
  * - **NOTE:**
22259
23042
  * - `null` will make to not set inline 'opacity' css prop.
22260
23043
  * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
22261
- * @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
23044
+ * @property {number|string|function} [point.sensitivity=10] The sensitivity value for interaction boundary.
22262
23045
  * - **Available Values:**
22263
23046
  * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
22264
23047
  * - "radius": sensitivity based on point's radius
@@ -22285,6 +23068,7 @@ var optPoint = {
22285
23068
  * - This is an `experimental` feature and can have some unexpected behaviors.
22286
23069
  * - If chart has 'bubble' type, only circle can be used.
22287
23070
  * - For IE, non circle point expansions are not supported due to lack of transform support.
23071
+ * - 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.
22288
23072
  * - **Available Values:**
22289
23073
  * - circle
22290
23074
  * - rectangle
@@ -22305,7 +23089,7 @@ var optPoint = {
22305
23089
  * return r;
22306
23090
  * },
22307
23091
  *
22308
- * // will generate follwing radialGradient:
23092
+ * // will generate following radialGradient:
22309
23093
  * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient
22310
23094
  * // <radualGradient cx="0.3" cy="0.3" r="0.7">
22311
23095
  * // <stop offset="0.1" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
@@ -22427,7 +23211,7 @@ var optArea = {
22427
23211
  * // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
22428
23212
  * front: false,
22429
23213
  *
22430
- * // will generate follwing linearGradient:
23214
+ * // will generate following linearGradient:
22431
23215
  * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
22432
23216
  * // <linearGradient x1="0" x2="0" y1="0" y2="1">
22433
23217
  * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
@@ -22487,8 +23271,8 @@ var optBar = {
22487
23271
  * @property {number} [bar.padding=0] The padding pixel value between each bar.
22488
23272
  * @property {number} [bar.radius] Set the radius of bar edge in pixel.
22489
23273
  * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
22490
- * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
22491
- * @property {number|Function|object} [bar.width] Change the width of bar chart.
23274
+ * @property {number} [bar.sensitivity=2] The sensitivity offset value for interaction boundary.
23275
+ * @property {number|function|object} [bar.width] Change the width of bar chart.
22492
23276
  * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
22493
23277
  * - **NOTE:** Criteria for ratio.
22494
23278
  * - When x ticks count is same with the data count, the baseline for ratio is the minimum interval value of x ticks.
@@ -22515,12 +23299,12 @@ var optBar = {
22515
23299
  * // make bar shape to be positioned over the other shape elements
22516
23300
  * front: true,
22517
23301
  *
22518
- * // remove nullish data on bar indices postions
23302
+ * // remove nullish data on bar indices positions
22519
23303
  * indices: {
22520
23304
  * removeNull: true
22521
23305
  * },
22522
23306
  *
22523
- * // will generate follwing linearGradient:
23307
+ * // will generate following linearGradient:
22524
23308
  * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
22525
23309
  * // <linearGradient x1="0" x2="0" y1="0" y2="1">
22526
23310
  * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
@@ -22624,12 +23408,12 @@ var optBubble = {
22624
23408
  * @memberof Options
22625
23409
  * @type {object}
22626
23410
  * @property {object} bubble bubble object
22627
- * @property {number|Function} [bubble.maxR=35] Set the max bubble radius value
23411
+ * @property {number|function} [bubble.maxR=35] Set the max bubble radius value
22628
23412
  * @property {boolean} [bubble.zerobased=false] Set if min or max value will be 0 on bubble chart.
22629
23413
  * @example
22630
23414
  * bubble: {
22631
23415
  * // ex) If 100 is the highest value among data bound, the representation bubble of 100 will have radius of 50.
22632
- * // And the lesser will have radius relatively from tha max value.
23416
+ * // And the lesser will have radius relatively from the max value.
22633
23417
  * maxR: 50,
22634
23418
  *
22635
23419
  * // or set radius callback
@@ -22689,7 +23473,7 @@ var optCandlestick = {
22689
23473
  * }
22690
23474
  * },
22691
23475
  * color: {
22692
- * // spcify bearish color
23476
+ * // specify bearish color
22693
23477
  * down: "red",
22694
23478
  *
22695
23479
  * // or specify color per dataset
@@ -22748,7 +23532,7 @@ var optLine = {
22748
23532
  * // hide all data points ('point.show=false' also has similar effect)
22749
23533
  * point: false,
22750
23534
  *
22751
- * // show data points for only indicated datas
23535
+ * // show data points for only indicated data
22752
23536
  * point: [
22753
23537
  * "data1", "data3"
22754
23538
  * ],
@@ -22789,7 +23573,7 @@ var optScatter = {
22789
23573
  * // hide all data points ('point.show=false' also has similar effect)
22790
23574
  * point: false,
22791
23575
  *
22792
- * // show data points for only indicated datas
23576
+ * // show data points for only indicated data
22793
23577
  * point: [
22794
23578
  * "data1", "data3"
22795
23579
  * ],
@@ -22860,14 +23644,14 @@ var optArc = {
22860
23644
  * @memberof Options
22861
23645
  * @type {object}
22862
23646
  * @property {object} arc Arc object
22863
- * @property {number|Function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
23647
+ * @property {number|function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
22864
23648
  * - **NOTE:**
22865
23649
  * - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
22866
23650
  * @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
22867
23651
  * @property {object} [arc.needle] Set needle options.
22868
23652
  * @property {boolean} [arc.needle.show=false] Show or hide needle.
22869
23653
  * @property {string} [arc.needle.color] Set needle filled color.
22870
- * @property {Function} [arc.needle.path] Set custom needle path function.
23654
+ * @property {function} [arc.needle.path] Set custom needle path function.
22871
23655
  * - **NOTE:**
22872
23656
  * - The path should be starting from 0,0 (which is center) to top center coordinate.
22873
23657
  * - The function will receive, `length`{number} parameter which indicating the needle length in pixel relative to radius.
@@ -22891,8 +23675,8 @@ var optArc = {
22891
23675
  * @property {string} [arc.rangeText.unit="absolute"] Specify the range text unit.
22892
23676
  * - "absolute": Show absolute value
22893
23677
  * - "%": Show percentage value
22894
- * @property {boolean} [arc.rangeText.fiexed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
22895
- * @property {Function} [arc.rangeText.format] Set format function for the range text.
23678
+ * @property {boolean} [arc.rangeText.fixed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
23679
+ * @property {function} [arc.rangeText.format] Set format function for the range text.
22896
23680
  * @property {number} [arc.rangeText.position] Set position function or object for the range text.
22897
23681
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
22898
23682
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
@@ -23011,10 +23795,21 @@ var optDonut = {
23011
23795
  * @type {object}
23012
23796
  * @property {object} donut Donut object
23013
23797
  * @property {boolean} [donut.label.show=true] Show or hide label on each donut piece.
23014
- * @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
23798
+ * @property {function} [donut.label.format] Set formatter for the label on each donut piece.
23015
23799
  * @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
23016
- * @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
23017
- * @property {object|Function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
23800
+ * @property {number|function} [donut.label.ratio=undefined] Set ratio of labels position.
23801
+ * @property {boolean|object} [donut.label.line=false] Enable label with lines (displayed outside with connector lines).
23802
+ * - `true`: Enable label with lines with default settings
23803
+ * - `false`: Labels are displayed inside the donut slices (default behavior).
23804
+ * - `{show: boolean, distance: number, text: boolean}`: Enable label with lines with custom settings. When object member is not provided, it will be set to default values.
23805
+ * @property {boolean} [donut.label.line.show=true] Show or hide connector lines.
23806
+ * @property {number} [donut.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
23807
+ * @property {boolean|function} [donut.label.line.text=true] Show text at the end of the connector line (outside the shape).
23808
+ * - `true`: show data "id" text
23809
+ * - `false`: use default formatter(label.format) to show text
23810
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
23811
+ * - **NOTE:** When the viewport size decreases, the size is adjusted based on the shape, so text may appear clipped. In this case, consider setting `overflow: visible` on the SVG node.
23812
+ * @property {object|function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
23018
23813
  * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
23019
23814
  * The arguments are:<br>
23020
23815
  * - `v` is the value of the data point where the label is shown.
@@ -23039,6 +23834,7 @@ var optDonut = {
23039
23834
  * @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
23040
23835
  * @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
23041
23836
  * @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
23837
+ * @see [Demo: Label Line](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelLine)
23042
23838
  * @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
23043
23839
  * @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
23044
23840
  * @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
@@ -23068,6 +23864,20 @@ var optDonut = {
23068
23864
  * // or set ratio number
23069
23865
  * ratio: 0.5,
23070
23866
  *
23867
+ * // Enable label with lines (displayed outside with connector lines)
23868
+ * line: false, // default - labels inside
23869
+ * line: true, // enable label with lines with default settings
23870
+ * line: { // enable label with lines with custom settings
23871
+ * show: true,
23872
+ * distance: 20, // horizontal line distance in pixels
23873
+ *
23874
+ * // show text at the end of connector line (outside the shape)
23875
+ * text: true, // use default formatter
23876
+ * text: function(value, ratio, id) { // custom formatter
23877
+ * return d3.format(".1%")(ratio);
23878
+ * }
23879
+ * },
23880
+ *
23071
23881
  * // set image to be displayed next to the label text
23072
23882
  * image: {
23073
23883
  * url: "./sample.svg",
@@ -23139,6 +23949,7 @@ var optDonut = {
23139
23949
  donut_label_show: true,
23140
23950
  donut_label_format: undefined,
23141
23951
  donut_label_threshold: 0.05,
23952
+ donut_label_line: false,
23142
23953
  donut_label_image: undefined,
23143
23954
  donut_label_ratio: undefined,
23144
23955
  donut_width: undefined,
@@ -23206,15 +24017,27 @@ var optGauge = {
23206
24017
  * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
23207
24018
  * @property {boolean} [gauge.fullCircle=false] Show full circle as donut. When set to 'true', the max label will not be showed due to start and end points are same location.
23208
24019
  * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
23209
- * @property {Function} [gauge.label.extents] Set customized min/max label text.
23210
- * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
24020
+ * @property {function} [gauge.label.extents] Set customized min/max label text.
24021
+ * @property {function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
23211
24022
  * Will pass following arguments to the given function:
23212
24023
  * - value {number}: absolute value
23213
24024
  * - ratio {number}: value's ratio
23214
24025
  * - id {string}: data's id value
23215
- * @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
24026
+ * @property {number|function} [gauge.label.ratio=undefined] Set ratio of labels position.
23216
24027
  * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
23217
- * @property {object|Function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
24028
+ * @property {boolean|object} [gauge.label.line=false] Enable label with lines (displayed outside with connector lines).
24029
+ * - **NOTE:** Only applicable for single gauge (not for `gauge.type="multi"`).
24030
+ * - `true`: Enable label with lines with default settings
24031
+ * - `false`: Labels are displayed inside the gauge (default behavior).
24032
+ * - `{show: boolean, distance: number, text: boolean}`: Enable label with lines with custom settings. When object member is not provided, it will be set to default values.
24033
+ * @property {boolean} [gauge.label.line.show=true] Show or hide connector lines.
24034
+ * @property {number} [gauge.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
24035
+ * @property {boolean|function} [gauge.label.line.text=true] Show text at the end of the connector line (outside the shape).
24036
+ * - `true`: show data "id" text
24037
+ * - `false`: use default formatter(label.format) to show text
24038
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
24039
+ * - **NOTE:** When the viewport size decreases, the size is adjusted based on the shape, so text may appear clipped. In this case, consider setting `overflow: visible` on the SVG node.
24040
+ * @property {object|function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
23218
24041
  * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
23219
24042
  * The arguments are:<br>
23220
24043
  * - `v` is the value of the data point where the label is shown.
@@ -23267,6 +24090,7 @@ var optGauge = {
23267
24090
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
23268
24091
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
23269
24092
  * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
24093
+ * @see [Demo: label line](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelLine)
23270
24094
  * @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
23271
24095
  * @example
23272
24096
  * gauge: {
@@ -23289,6 +24113,20 @@ var optGauge = {
23289
24113
  * // if data value is below than 0.1, text label will be hidden.
23290
24114
  * threshold: 0.1,
23291
24115
  *
24116
+ * // Enable label with lines (displayed outside with connector lines)
24117
+ * // NOTE: Only works with single gauge (not gauge.type="multi")
24118
+ * line: true, // enable label with lines with default settings
24119
+ * line: { // enable label with lines with custom settings
24120
+ * show: true, // enable lines (default: true when line is enabled)
24121
+ * distance: 30, // distance of horizontal line in pixels (default: 20)
24122
+ *
24123
+ * // show text at the end of connector line (outside the shape)
24124
+ * text: true, // use default formatter
24125
+ * text: function(value, ratio, id) { // custom formatter
24126
+ * return d3.format(".1%")(ratio);
24127
+ * }
24128
+ * },
24129
+ *
23292
24130
  * // set ratio callback. Should return ratio value
23293
24131
  * ratio: function(d, radius, h) {
23294
24132
  * ...
@@ -23382,6 +24220,7 @@ var optGauge = {
23382
24220
  gauge_label_format: undefined,
23383
24221
  gauge_label_ratio: undefined,
23384
24222
  gauge_label_threshold: 0,
24223
+ gauge_label_line: false,
23385
24224
  gauge_label_image: undefined,
23386
24225
  gauge_enforceMinMax: false,
23387
24226
  gauge_min: 0,
@@ -23413,10 +24252,21 @@ var optPie = {
23413
24252
  * @type {object}
23414
24253
  * @property {object} pie Pie object
23415
24254
  * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
23416
- * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
23417
- * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
24255
+ * @property {function} [pie.label.format] Set formatter for the label on each pie piece.
24256
+ * @property {number|function} [pie.label.ratio=undefined] Set ratio of labels position.
23418
24257
  * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
23419
- * @property {object|Function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
24258
+ * @property {boolean|object} [pie.label.line=false] Enable label with lines (displayed outside with connector lines).
24259
+ * - `true`: Enable label with lines with default settings
24260
+ * - `false`: Labels are displayed inside the pie slices (default behavior).
24261
+ * - `{show: boolean, distance: number, text: boolean}`: Enable label with lines with custom settings. When object member is not provided, it will be set to default values.
24262
+ * @property {boolean} [pie.label.line.show=true] Show or hide connector lines.
24263
+ * @property {number} [pie.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
24264
+ * @property {boolean|function} [pie.label.line.text=true] Show text at the end of the connector line (outside the shape).
24265
+ * - `true`: show data "id" text
24266
+ * - `false`: use default formatter(label.format) to show text
24267
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
24268
+ * - **NOTE:** When the viewport size decreases, the size is adjusted based on the shape, so text may appear clipped. In this case, consider setting `overflow: visible` on the SVG node.
24269
+ * @property {object|function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
23420
24270
  * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
23421
24271
  * The arguments are:<br>
23422
24272
  * - `v` is the value of the data point where the label is shown.
@@ -23441,6 +24291,7 @@ var optPie = {
23441
24291
  * @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
23442
24292
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
23443
24293
  * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
24294
+ * @see [Demo: label line](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelLine)
23444
24295
  * @example
23445
24296
  * pie: {
23446
24297
  * label: {
@@ -23464,6 +24315,20 @@ var optPie = {
23464
24315
  * // or set ratio number
23465
24316
  * ratio: 0.5,
23466
24317
  *
24318
+ * // Enable label with lines (displayed outside with connector lines)
24319
+ * line: false, // default - labels inside
24320
+ * line: true, // enable label with lines with default settings
24321
+ * line: { // enable label with lines with custom settings
24322
+ * show: true,
24323
+ * distance: 20, // horizontal line distance in pixels
24324
+ *
24325
+ * // show text at the end of connector line (outside the shape)
24326
+ * text: true, // use default formatter
24327
+ * text: function(value, ratio, id) { // custom formatter
24328
+ * return d3.format(".1%")(ratio);
24329
+ * }
24330
+ * },
24331
+ *
23467
24332
  * // set image to be displayed next to the label text
23468
24333
  * image: {
23469
24334
  * url: "./sample.svg",
@@ -23545,6 +24410,7 @@ var optPie = {
23545
24410
  pie_label_format: undefined,
23546
24411
  pie_label_ratio: undefined,
23547
24412
  pie_label_threshold: 0.05,
24413
+ pie_label_line: false,
23548
24414
  pie_label_image: undefined,
23549
24415
  pie_expand: {},
23550
24416
  pie_expand_rate: 0.98,
@@ -23571,10 +24437,21 @@ var optPolar = {
23571
24437
  * @type {object}
23572
24438
  * @property {object} polar Polar object
23573
24439
  * @property {boolean} [polar.label.show=true] Show or hide label on each polar piece.
23574
- * @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
24440
+ * @property {function} [polar.label.format] Set formatter for the label on each polar piece.
23575
24441
  * @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
23576
- * @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
23577
- * @property {object|Function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
24442
+ * @property {number|function} [polar.label.ratio=undefined] Set ratio of labels position.
24443
+ * @property {boolean|object} [polar.label.line=false] Enable label with lines (displayed outside with connector lines).
24444
+ * - `true`: Enable label with lines with default settings
24445
+ * - `false`: Labels are displayed inside the polar slices (default behavior).
24446
+ * - `{show: boolean, distance: number, text: boolean}`: Enable label with lines with custom settings. When object member is not provided, it will be set to default values.
24447
+ * @property {boolean} [polar.label.line.show=true] Show or hide connector lines.
24448
+ * @property {number} [polar.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
24449
+ * @property {boolean|function} [polar.label.line.text=true] Show text at the end of the connector line (outside the shape).
24450
+ * - `true`: show data "id" text
24451
+ * - `false`: use default formatter(label.format) to show text
24452
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
24453
+ * - **NOTE:** When the viewport size decreases, the size is adjusted based on the shape, so text may appear clipped. In this case, consider setting `overflow: visible` on the SVG node.
24454
+ * @property {object|function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
23578
24455
  * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
23579
24456
  * The arguments are:<br>
23580
24457
  * - `v` is the value of the data point where the label is shown.
@@ -23589,13 +24466,14 @@ var optPolar = {
23589
24466
  * @property {number} [polar.level.depth=3] Set the level depth.
23590
24467
  * @property {boolean} [polar.level.show=true] Show or hide level.
23591
24468
  * @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
23592
- * @property {Function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
24469
+ * @property {function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
23593
24470
  * @property {boolean} [polar.level.text.show=true] Show or hide level text.
23594
24471
  * @property {number} [polar.padAngle=0] Set padding between data.
23595
24472
  * @property {number} [polar.padding=0] Sets the gap between pie arcs.
23596
24473
  * @property {number} [polar.startingAngle=0] Set starting angle where data draws.
23597
24474
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
23598
24475
  * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
24476
+ * @see [Demo: label line](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelLine)
23599
24477
  * @example
23600
24478
  * polar: {
23601
24479
  * label: {
@@ -23619,6 +24497,20 @@ var optPolar = {
23619
24497
  * // or set ratio number
23620
24498
  * ratio: 0.5,
23621
24499
  *
24500
+ * // Enable label with lines (displayed outside with connector lines)
24501
+ * line: false, // default - labels inside
24502
+ * line: true, // enable label with lines with default settings
24503
+ * line: { // enable label with lines with custom settings
24504
+ * show: true,
24505
+ * distance: 20, // horizontal line distance in pixels
24506
+ *
24507
+ * // show text at the end of connector line (outside the shape)
24508
+ * text: true, // use default formatter
24509
+ * text: function(value, ratio, id) { // custom formatter
24510
+ * return d3.format(".1%")(ratio);
24511
+ * }
24512
+ * },
24513
+ *
23622
24514
  * // set image to be displayed next to the label text
23623
24515
  * image: {
23624
24516
  * url: "./sample.svg",
@@ -23683,6 +24575,7 @@ var optPolar = {
23683
24575
  polar_label_show: true,
23684
24576
  polar_label_format: undefined,
23685
24577
  polar_label_threshold: 0.05,
24578
+ polar_label_line: false,
23686
24579
  polar_label_image: undefined,
23687
24580
  polar_label_ratio: undefined,
23688
24581
  polar_level_depth: 3,
@@ -23720,7 +24613,7 @@ var optRadar = {
23720
24613
  * @property {boolean} [radar.direction.clockwise=false] Set the direction to be drawn.
23721
24614
  * @property {number} [radar.level.depth=3] Set the level depth.
23722
24615
  * @property {boolean} [radar.level.show=true] Show or hide level.
23723
- * @property {Function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
24616
+ * @property {function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
23724
24617
  * @property {boolean} [radar.level.text.show=true] Show or hide level text.
23725
24618
  * @property {number} [radar.size.ratio=0.87] Set size ratio.
23726
24619
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.RadarChart)
@@ -23794,7 +24687,12 @@ var optTreemap = {
23794
24687
  * - sliceDice ([d3.treemapSliceDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSliceDice))
23795
24688
  * - squrify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
23796
24689
  * - resquarify ([d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapResquarify))
23797
- * @property {Function} [treemap.label.format] Set formatter for the label text.
24690
+ * @property {function} [treemap.label.format] Set formatter for the label text.<br>
24691
+ * - **Arguments:**
24692
+ * - `value {number}`: Data value
24693
+ * - `ratio {number}`: The `ratio` of how much space this tile occupies relative to the total area (0~1)
24694
+ * - `id {string}`: Data id
24695
+ * - `size {object}`: Tile size `{width, height}` in pixels
23798
24696
  * @property {number} [treemap.label.threshold=0.05] Set threshold ratio to show/hide labels text.
23799
24697
  * @property {number} [treemap.label.show=true] Show or hide label text.
23800
24698
  * @see [Demo: treemap](https://naver.github.io/billboard.js/demo/#Chart.TreemapChart)
@@ -23807,12 +24705,33 @@ var optTreemap = {
23807
24705
  * // show or hide label text
23808
24706
  * show: false,
23809
24707
  *
23810
- * // set label text formatter
23811
- * format: function(value, ratio, id) {
24708
+ * // Example 1: Format with currency
24709
+ * format: function(value, ratio, id, size) {
24710
+ * // size: {width, height} - tile size in pixels
23812
24711
  * return d3.format("$")(value);
24712
+ * },
23813
24713
  *
23814
- * // to multiline, return with '\n' character
23815
- * // return value +"%\nLine1\n2Line2";
24714
+ * // Example 2: Show different content based on tile size
24715
+ * format: function(value, ratio, id, size) {
24716
+ * if (size.width > 100 && size.height > 50) {
24717
+ * return `${id}\n${d3.format("$")(value)}\n(${(ratio * 100).toFixed(1)}%)`;
24718
+ * } else if (size.width > 50) {
24719
+ * return `${id}\n${d3.format("$")(value)}`;
24720
+ * } else {
24721
+ * return d3.format("$")(value);
24722
+ * }
24723
+ * },
24724
+ *
24725
+ * // Example 3: Include tile dimensions in label
24726
+ * format: function(value, ratio, id, size) {
24727
+ * return `${id}\n${value}\n${size.width.toFixed(0)}x${size.height.toFixed(0)}px`;
24728
+ * },
24729
+ *
24730
+ * // Example 4: Conditional formatting based on ratio
24731
+ * format: function(value, ratio, id, size) {
24732
+ * return ratio > 0.1 ?
24733
+ * `${id}\n${value} (${(ratio * 100).toFixed(1)}%)` :
24734
+ * value;
23816
24735
  * },
23817
24736
  *
23818
24737
  * // set ratio number
@@ -24022,7 +24941,7 @@ var apiSelection = {
24022
24941
  * @function subchart
24023
24942
  * @instance
24024
24943
  * @memberof Chart
24025
- * @param {Array} domainValue If domain range is given, the subchart will be seleted to the given domain. If no argument is given, the current subchart selection domain will be returned.
24944
+ * @param {Array} domainValue If domain range is given, the subchart will be selected to the given domain. If no argument is given, the current subchart selection domain will be returned.
24026
24945
  * @returns {Array} domain value in array
24027
24946
  * @example
24028
24947
  * // Specify domain for subchart selection
@@ -24032,7 +24951,7 @@ var apiSelection = {
24032
24951
  * // Domain value may not be exact returning approximately values.
24033
24952
  * chart.subchart();
24034
24953
  */
24035
- // NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
24954
+ // NOTE: declared function assigning to variable to prevent duplicated method generation in JSDoc.
24036
24955
  var subchart$1 = function (domainValue) {
24037
24956
  var _a;
24038
24957
  var $$ = this.internal;
@@ -24121,7 +25040,7 @@ extend(subchart$1, {
24121
25040
  }
24122
25041
  },
24123
25042
  /**
24124
- * Toggle the visiblity of subchart
25043
+ * Toggle the visibility of subchart
24125
25044
  * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
24126
25045
  * @function subchart․toggle
24127
25046
  * @instance
@@ -24185,7 +25104,7 @@ var apiSubchart = {
24185
25104
  * // Domain value may not be exact returning approximately values.
24186
25105
  * chart.zoom();
24187
25106
  */
24188
- // NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
25107
+ // NOTE: declared function assigning to variable to prevent duplicated method generation in JSDoc.
24189
25108
  var zoom$1 = function (domainValue) {
24190
25109
  var _a;
24191
25110
  var $$ = this.internal;
@@ -24751,9 +25670,6 @@ var zoom = {
24751
25670
  var tY = isRotated ? t : transform.y;
24752
25671
  $$.$el.eventRect.property("__zoom", zoomIdentity.translate(tX, tY).scale(transform.k));
24753
25672
  }
24754
- if (!$$.state.xTickOffset) {
24755
- $$.state.xTickOffset = $$.axis.x.tickOffset();
24756
- }
24757
25673
  scale.zoom = $$.getCustomizedXScale(newScale);
24758
25674
  $$.axis.x.scale(scale.zoom);
24759
25675
  if (rescale) {
@@ -24802,7 +25718,6 @@ var zoom = {
24802
25718
  * @private
24803
25719
  */
24804
25720
  onZoom: function (event) {
24805
- var _a;
24806
25721
  var $$ = this;
24807
25722
  var config = $$.config, scale = $$.scale, state = $$.state, org = $$.org;
24808
25723
  var sourceEvent = event.sourceEvent;
@@ -24829,16 +25744,23 @@ var zoom = {
24829
25744
  // - when .unzoom() is called (event.transform === d3ZoomIdentity)
24830
25745
  var doTransition = config.transition_duration > 0 &&
24831
25746
  !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
24832
- $$.redraw({
24833
- withTransition: doTransition,
24834
- withY: config.zoom_rescale,
24835
- withSubchart: false,
24836
- withEventRect: false,
24837
- withDimension: false
24838
- });
24839
- $$.state.cancelClick = isMousemove;
24840
- // do not call event cb when is .unzoom() is called
24841
- !isUnZoom && callFn(config.zoom_onzoom, $$.api, (_a = $$.state.domain) !== null && _a !== void 0 ? _a : $$.zoom.getDomain());
25747
+ // Use RAF batching for continuous drag zoom events only
25748
+ // Wheel zoom and API calls need synchronous execution for correct behavior and tests
25749
+ var useRAF = sourceEvent && isMousemove && config.zoom_type !== "wheel";
25750
+ var executeRedraw = function () {
25751
+ var _a;
25752
+ $$.redraw({
25753
+ withTransition: doTransition,
25754
+ withY: config.zoom_rescale,
25755
+ withSubchart: false,
25756
+ withEventRect: false,
25757
+ withDimension: false
25758
+ });
25759
+ $$.state.cancelClick = isMousemove;
25760
+ // do not call event cb when is .unzoom() is called
25761
+ !isUnZoom && callFn(config.zoom_onzoom, $$.api, (_a = $$.state.domain) !== null && _a !== void 0 ? _a : $$.zoom.getDomain());
25762
+ };
25763
+ useRAF ? scheduleRAFUpdate($$.state, executeRedraw) : executeRedraw();
24842
25764
  },
24843
25765
  /**
24844
25766
  * 'end' event listener
@@ -24891,7 +25813,7 @@ var zoom = {
24891
25813
  },
24892
25814
  /**
24893
25815
  * Set zoom transform to event rect
24894
- * @param {Function} x x Axis scale function
25816
+ * @param {function} x x Axis scale function
24895
25817
  * @param {Array} domain Domain value to be set
24896
25818
  * @private
24897
25819
  */
@@ -25068,44 +25990,53 @@ var drag = {
25068
25990
  var maxX = Math.max(sx, mx);
25069
25991
  var minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my);
25070
25992
  var maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
25071
- main.select(".".concat($DRAG.dragarea))
25072
- .attr("x", minX)
25073
- .attr("y", minY)
25074
- .attr("width", maxX - minX)
25075
- .attr("height", maxY - minY);
25076
- // TODO: binary search when multiple xs
25077
- main.selectAll(".".concat($SHAPE.shapes))
25078
- .selectAll(".".concat($SHAPE.shape))
25079
- .filter(function (d) { return isSelectable === null || isSelectable === void 0 ? void 0 : isSelectable.bind($$.api)(d); })
25080
- .each(function (d, i) {
25081
- var shape = select(this);
25082
- var isSelected = shape.classed($SELECT.SELECTED);
25083
- var isIncluded = shape.classed($DRAG.INCLUDED);
25084
- var isWithin = false;
25085
- var toggle;
25086
- if (shape.classed($CIRCLE.circle)) {
25087
- var x = +shape.attr("cx") * 1;
25088
- var y = +shape.attr("cy") * 1;
25089
- toggle = $$.togglePoint;
25090
- isWithin = minX < x && x < maxX && minY < y && y < maxY;
25091
- }
25092
- else if (shape.classed($BAR.bar)) {
25093
- var _a = getPathBox(this), x = _a.x, y = _a.y, width = _a.width, height = _a.height;
25094
- toggle = $$.togglePath;
25095
- isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
25096
- }
25097
- else {
25098
- // line/area selection not supported yet
25993
+ // Use RAF batching to smooth out rapid drag events
25994
+ var executeDrag = function () {
25995
+ // Check if chart still exists before executing
25996
+ if (!$$ || !$$.$el || !$$.$el.main) {
25099
25997
  return;
25100
25998
  }
25101
- // @ts-ignore
25102
- if (isWithin ^ isIncluded) {
25103
- shape.classed($DRAG.INCLUDED, !isIncluded);
25104
- // TODO: included/unincluded callback here
25105
- shape.classed($SELECT.SELECTED, !isSelected);
25106
- toggle.call($$, !isSelected, shape, d, i);
25107
- }
25108
- });
25999
+ main.select(".".concat($DRAG.dragarea))
26000
+ .attr("x", minX)
26001
+ .attr("y", minY)
26002
+ .attr("width", maxX - minX)
26003
+ .attr("height", maxY - minY);
26004
+ // TODO: binary search when multiple xs
26005
+ main.selectAll(".".concat($SHAPE.shapes))
26006
+ .selectAll(".".concat($SHAPE.shape))
26007
+ .filter(function (d) { return isSelectable === null || isSelectable === void 0 ? void 0 : isSelectable.bind($$.api)(d); })
26008
+ .each(function (d, i) {
26009
+ var shape = select(this);
26010
+ var isSelected = shape.classed($SELECT.SELECTED);
26011
+ var isIncluded = shape.classed($DRAG.INCLUDED);
26012
+ var isWithin = false;
26013
+ var toggle;
26014
+ if (shape.classed($CIRCLE.circle)) {
26015
+ var x = +shape.attr("cx") * 1;
26016
+ var y = +shape.attr("cy") * 1;
26017
+ toggle = $$.togglePoint;
26018
+ isWithin = minX < x && x < maxX && minY < y && y < maxY;
26019
+ }
26020
+ else if (shape.classed($BAR.bar)) {
26021
+ var _a = getPathBox(this), x = _a.x, y = _a.y, width = _a.width, height = _a.height;
26022
+ toggle = $$.togglePath;
26023
+ isWithin = !(maxX < x || x + width < minX) &&
26024
+ !(maxY < y || y + height < minY);
26025
+ }
26026
+ else {
26027
+ // line/area selection not supported yet
26028
+ return;
26029
+ }
26030
+ // @ts-ignore
26031
+ if (isWithin ^ isIncluded) {
26032
+ shape.classed($DRAG.INCLUDED, !isIncluded);
26033
+ // TODO: included/unincluded callback here
26034
+ shape.classed($SELECT.SELECTED, !isSelected);
26035
+ toggle.call($$, !isSelected, shape, d, i);
26036
+ }
26037
+ });
26038
+ };
26039
+ scheduleRAFUpdate($$.state, executeDrag);
25109
26040
  },
25110
26041
  /**
25111
26042
  * Called when the drag starts.
@@ -25246,7 +26177,7 @@ var selection = __assign(__assign({}, drag), {
25246
26177
  * Returns the toggle method of the target
25247
26178
  * @param {object} that shape
25248
26179
  * @param {object} d Data object
25249
- * @returns {Function} toggle method
26180
+ * @returns {function} toggle method
25250
26181
  * @private
25251
26182
  */
25252
26183
  getToggle: function (that, d) {
@@ -25351,7 +26282,7 @@ var optDataSelection = {
25351
26282
  * The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
25352
26283
  * @name data․selection․isselectable
25353
26284
  * @memberof Options
25354
- * @type {Function}
26285
+ * @type {function}
25355
26286
  * @default function() { return true; }
25356
26287
  * @example
25357
26288
  * data: {
@@ -25363,7 +26294,7 @@ var optDataSelection = {
25363
26294
  data_selection_isselectable: function () { return true; },
25364
26295
  /**
25365
26296
  * Set multiple data points selection enabled.<br><br>
25366
- * If this option set true, multile data points can have the selected state at the same time. If false set, only one data point can have the selected state and the others will be unselected when the new data point is selected.
26297
+ * If this option set true, multiple data points can have the selected state at the same time. If false set, only one data point can have the selected state and the others will be unselected when the new data point is selected.
25367
26298
  * @name data․selection․multiple
25368
26299
  * @memberof Options
25369
26300
  * @type {boolean}
@@ -25396,7 +26327,7 @@ var optDataSelection = {
25396
26327
  * Set a callback for on data selection.
25397
26328
  * @name data․onselected
25398
26329
  * @memberof Options
25399
- * @type {Function}
26330
+ * @type {function}
25400
26331
  * @default function() {}
25401
26332
  * @example
25402
26333
  * data: {
@@ -25412,7 +26343,7 @@ var optDataSelection = {
25412
26343
  * Set a callback for on data un-selection.
25413
26344
  * @name data․onunselected
25414
26345
  * @memberof Options
25415
- * @type {Function}
26346
+ * @type {function}
25416
26347
  * @default function() {}
25417
26348
  * @example
25418
26349
  * data: {
@@ -25447,11 +26378,11 @@ var optSubchart = {
25447
26378
  * @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
25448
26379
  * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
25449
26380
  * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
25450
- * @property {Function|string} [subchart.axis.x.tick.format] Use custom format for x axis ticks - see [axis.x.tick.format](#.axis․x․tick․format) for details.
26381
+ * @property {function|string} [subchart.axis.x.tick.format] Use custom format for x axis ticks - see [axis.x.tick.format](#.axis․x․tick․format) for details.
25451
26382
  * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
25452
26383
  * @property {Array} [subchart.init.range] Set initial selection domain range.
25453
26384
  * @property {number} [subchart.size.height] Change the height of the subchart.
25454
- * @property {Function} [subchart.onbrush] Set callback for brush event.<br>
26385
+ * @property {function} [subchart.onbrush] Set callback for brush event.<br>
25455
26386
  * Specified function receives the current zoomed x domain.
25456
26387
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Interaction.SubChart)
25457
26388
  * @example
@@ -25525,14 +26456,14 @@ var optZoom = {
25525
26456
  * @property {Array} [zoom.extent=[1, 10]] Change zoom extent.
25526
26457
  * @property {number|Date} [zoom.x.min] Set x Axis minimum zoom range
25527
26458
  * @property {number|Date} [zoom.x.max] Set x Axis maximum zoom range
25528
- * @property {Function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
26459
+ * @property {function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
25529
26460
  * Specified function receives the zoom event.
25530
- * @property {Function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
26461
+ * @property {function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
25531
26462
  * Specified function receives the zoomed domain.
25532
- * @property {Function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
26463
+ * @property {function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
25533
26464
  * Specified function receives the zoomed domain.
25534
26465
  * @property {boolean|object} [zoom.resetButton=true] Set to display zoom reset button for 'drag' type zoom
25535
- * @property {Function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
26466
+ * @property {function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
25536
26467
  * @property {string} [zoom.resetButton.text='Reset Zoom'] Text value for zoom reset button.
25537
26468
  * @see [Demo:zoom](https://naver.github.io/billboard.js/demo/#Interaction.Zoom)
25538
26469
  * @see [Demo:drag zoom](https://naver.github.io/billboard.js/demo/#Interaction.DragZoom)
@@ -25616,7 +26547,7 @@ var zoomModule = function () {
25616
26547
  var defaults = Object.create(null);
25617
26548
  /**
25618
26549
  * @namespace bb
25619
- * @version 3.17.4
26550
+ * @version 3.18.0-next.2
25620
26551
  */
25621
26552
  var bb = {
25622
26553
  /**
@@ -25626,10 +26557,10 @@ var bb = {
25626
26557
  * bb.version; // "1.0.0"
25627
26558
  * @memberof bb
25628
26559
  */
25629
- version: "3.17.4",
26560
+ version: "3.18.0-next.2",
25630
26561
  /**
25631
26562
  * Generate chart
25632
- * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
26563
+ * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when:
25633
26564
  * - Unused option value is given.
25634
26565
  * - ex) For `data.type="pie"` option, setting 'axis' option can cause unexpected generation error.
25635
26566
  * - Insufficient value is given for certain option used.