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.
- package/CONTRIBUTING.md +12 -12
- package/README.md +12 -12
- package/dist/billboard.css +15 -1
- package/dist/billboard.js +1146 -463
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +10 -10
- package/dist/billboard.pkgd.js +1147 -464
- package/dist/billboard.pkgd.min.js +21 -21
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +117 -26
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-stanford.js +119 -28
- package/dist/plugin/billboardjs-plugin-stanford.min.js +10 -10
- package/dist/plugin/billboardjs-plugin-tableview.js +117 -27
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +116 -26
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +117 -26
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +120 -29
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +117 -27
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -12
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +116 -26
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
- package/dist/theme/dark.css +15 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +15 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +15 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +15 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +15 -1
- package/dist/theme/modern.min.css +2 -2
- package/dist-esm/billboard.js +1467 -536
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +5 -4
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +94 -16
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +38 -37
- package/src/Chart/Chart.ts +1 -1
- package/src/Chart/api/chart.ts +5 -5
- package/src/Chart/api/data.ts +2 -1
- package/src/Chart/api/export.ts +1 -1
- package/src/Chart/api/flow.ts +1 -1
- package/src/Chart/api/load.ts +3 -3
- package/src/Chart/api/subchart.ts +3 -3
- package/src/Chart/api/tooltip.ts +1 -1
- package/src/Chart/api/zoom.ts +1 -1
- package/src/ChartInternal/Axis/Axis.ts +1 -1
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
- package/src/ChartInternal/ChartInternal.ts +3 -2
- package/src/ChartInternal/data/IData.ts +3 -0
- package/src/ChartInternal/data/convert.helper.ts +1 -1
- package/src/ChartInternal/data/convert.ts +9 -8
- package/src/ChartInternal/data/data.ts +135 -17
- package/src/ChartInternal/data/load.ts +8 -8
- package/src/ChartInternal/interactions/drag.ts +53 -42
- package/src/ChartInternal/interactions/eventrect.ts +15 -5
- package/src/ChartInternal/interactions/flow.ts +1 -1
- package/src/ChartInternal/interactions/interaction.ts +1 -1
- package/src/ChartInternal/interactions/zoom.ts +24 -20
- package/src/ChartInternal/internals/color.ts +27 -10
- package/src/ChartInternal/internals/domain.ts +22 -5
- package/src/ChartInternal/internals/format.ts +4 -4
- package/src/ChartInternal/internals/grid.ts +11 -11
- package/src/ChartInternal/internals/legend.ts +80 -19
- package/src/ChartInternal/internals/scale.ts +6 -6
- package/src/ChartInternal/internals/selection.ts +1 -1
- package/src/ChartInternal/internals/style.ts +3 -3
- package/src/ChartInternal/internals/text.arc.ts +304 -0
- package/src/ChartInternal/internals/text.ts +44 -14
- package/src/ChartInternal/internals/text.util.ts +19 -0
- package/src/ChartInternal/internals/title.ts +3 -3
- package/src/ChartInternal/internals/tooltip.ts +23 -15
- package/src/ChartInternal/shape/arc.ts +174 -71
- package/src/ChartInternal/shape/area.ts +2 -2
- package/src/ChartInternal/shape/bar.ts +7 -6
- package/src/ChartInternal/shape/candlestick.ts +3 -3
- package/src/ChartInternal/shape/funnel.ts +18 -18
- package/src/ChartInternal/shape/line.ts +9 -10
- package/src/ChartInternal/shape/point.common.ts +24 -6
- package/src/ChartInternal/shape/radar.ts +4 -4
- package/src/ChartInternal/shape/shape.ts +24 -6
- package/src/ChartInternal/shape/treemap.ts +19 -5
- package/src/Plugin/stanford/Options.ts +2 -2
- package/src/Plugin/tableview/Options.ts +1 -1
- package/src/config/Options/axis/axis.ts +7 -7
- package/src/config/Options/axis/x.ts +6 -6
- package/src/config/Options/axis/y.ts +4 -4
- package/src/config/Options/axis/y2.ts +16 -3
- package/src/config/Options/common/color.ts +2 -2
- package/src/config/Options/common/legend.ts +6 -5
- package/src/config/Options/common/main.ts +23 -23
- package/src/config/Options/common/point.ts +4 -3
- package/src/config/Options/common/tooltip.ts +14 -13
- package/src/config/Options/data/axis.ts +31 -6
- package/src/config/Options/data/data.ts +44 -44
- package/src/config/Options/data/selection.ts +4 -4
- package/src/config/Options/interaction/interaction.ts +2 -1
- package/src/config/Options/interaction/subchart.ts +2 -2
- package/src/config/Options/interaction/zoom.ts +4 -4
- package/src/config/Options/shape/arc.ts +4 -4
- package/src/config/Options/shape/area.ts +1 -1
- package/src/config/Options/shape/bar.ts +4 -4
- package/src/config/Options/shape/bubble.ts +2 -2
- package/src/config/Options/shape/candlestick.ts +1 -1
- package/src/config/Options/shape/donut.ts +34 -3
- package/src/config/Options/shape/gauge.ts +36 -4
- package/src/config/Options/shape/line.ts +1 -1
- package/src/config/Options/shape/pie.ts +34 -3
- package/src/config/Options/shape/polar.ts +35 -4
- package/src/config/Options/shape/radar.ts +1 -1
- package/src/config/Options/shape/scatter.ts +1 -1
- package/src/config/Options/shape/treemap.ts +31 -5
- package/src/config/Store/State.ts +11 -1
- package/src/config/classes.ts +1 -0
- package/src/core.ts +1 -1
- package/src/module/Cache.ts +29 -4
- package/src/module/generator.ts +1 -1
- package/src/module/util.ts +308 -117
- package/src/module/worker.ts +3 -3
- package/src/scss/billboard.scss +15 -0
- package/src/scss/theme/dark.scss +15 -0
- package/src/scss/theme/datalab.scss +15 -0
- package/src/scss/theme/graph.scss +15 -0
- package/src/scss/theme/insight.scss +15 -0
- package/src/scss/theme/modern.scss +15 -0
- package/types/axis.d.ts +3 -3
- package/types/chart.d.ts +4 -4
- package/types/options.d.ts +22 -9
- package/types/options.shape.d.ts +59 -2
package/dist/billboard.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.18.0-next.2
|
|
9
9
|
*/
|
|
10
10
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
11
11
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -241,6 +241,7 @@ const $COMMON = {
|
|
|
241
241
|
const $ARC = {
|
|
242
242
|
arc: "bb-arc",
|
|
243
243
|
arcLabelLine: "bb-arc-label-line",
|
|
244
|
+
arcLabelLineText: "bb-arc-label-line-text",
|
|
244
245
|
arcRange: "bb-arc-range",
|
|
245
246
|
arcs: "bb-arcs",
|
|
246
247
|
chartArc: "bb-chart-arc",
|
|
@@ -434,9 +435,9 @@ const $ZOOM = {
|
|
|
434
435
|
* @memberof Options
|
|
435
436
|
* @type {object}
|
|
436
437
|
* @property {object} color color object
|
|
437
|
-
* @property {string|object|
|
|
438
|
+
* @property {string|object|((this: Chart, d: DataItem) => string)} [color.onover] Set the color value for each data point when mouse/touch onover event occurs.
|
|
438
439
|
* @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.
|
|
439
|
-
* @property {
|
|
440
|
+
* @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).
|
|
440
441
|
* - **NOTE:** The pattern element's id will be defined as `bb-colorize-pattern-$COLOR-VALUE`.<br>
|
|
441
442
|
* ex. When color pattern value is `['red', '#fff']` and defined 2 patterns,then ids for pattern elements are:<br>
|
|
442
443
|
* - `bb-colorize-pattern-red`
|
|
@@ -521,7 +522,7 @@ const $ZOOM = {
|
|
|
521
522
|
* If true given, all legend will be hidden. If string or array given, only the legend that has the id will be hidden.
|
|
522
523
|
* @property {string|HTMLElement} [legend.contents.bindto=undefined] Set CSS selector or element reference to bind legend items.
|
|
523
524
|
* - **NOTE:** Should be used along with `legend.contents.template`.
|
|
524
|
-
* @property {string|
|
|
525
|
+
* @property {string|function} [legend.contents.template="<span style='color:#fff;padding:5px;background-color:{=COLOR}'>{=TITLE}</span>"] Set item's template.<br>
|
|
525
526
|
* - If set `string` value, within template the 'color' and 'title' can be replaced using template-like syntax string:
|
|
526
527
|
* - {=COLOR}: data color value
|
|
527
528
|
* - {=TITLE}: data title value
|
|
@@ -529,6 +530,7 @@ const $ZOOM = {
|
|
|
529
530
|
* - title {string}: data's id value
|
|
530
531
|
* - color {string}: color string
|
|
531
532
|
* - data {Array}: data array
|
|
533
|
+
* - **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.
|
|
532
534
|
* @property {string} [legend.position=bottom] Change the position of legend.<br>
|
|
533
535
|
* Available values are: `bottom`, `right` and `inset` are supported.
|
|
534
536
|
* @property {object} [legend.inset={anchor: 'top-left',x: 10,y: 0,step: undefined}] Change inset legend attributes.<br>
|
|
@@ -555,13 +557,13 @@ const $ZOOM = {
|
|
|
555
557
|
* - To return initial state(which all dataseries are showing), double click current focused legend item again.
|
|
556
558
|
* - for single click case, `click + altKey(Win)/optionKey(Mac OS)` to have same effect.
|
|
557
559
|
* - In this case, default `click` interaction will be disabled.
|
|
558
|
-
* @property {
|
|
560
|
+
* @property {function} [legend.item.onclick=undefined] Set click event handler to the legend item.
|
|
559
561
|
* - **NOTE:**
|
|
560
562
|
* - When set, default `click` interaction will be disabled.
|
|
561
563
|
* - When `interaction.dblclick=true` is set, will be called on double click.
|
|
562
|
-
* @property {
|
|
564
|
+
* @property {function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
|
|
563
565
|
* - **NOTE:** When set, default `mouseover` interaction will be disabled.
|
|
564
|
-
* @property {
|
|
566
|
+
* @property {function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
|
|
565
567
|
* - **NOTE:** When set, default `mouseout` interaction will be disabled.
|
|
566
568
|
* @property {number} [legend.item.tile.width=10] Set width for 'rectangle' legend item tile element.
|
|
567
569
|
* @property {number} [legend.item.tile.height=10] Set height for 'rectangle' legend item tile element.
|
|
@@ -638,7 +640,7 @@ const $ZOOM = {
|
|
|
638
640
|
* width: 15,
|
|
639
641
|
* height: 15
|
|
640
642
|
*
|
|
641
|
-
* //
|
|
643
|
+
* // radius is only applicable for 'circle' legend type
|
|
642
644
|
* r: 10
|
|
643
645
|
* }
|
|
644
646
|
* },
|
|
@@ -684,14 +686,14 @@ const $ZOOM = {
|
|
|
684
686
|
/* harmony default export */ var main = ({
|
|
685
687
|
/**
|
|
686
688
|
* Specify the CSS selector or the element which the chart will be set to. D3 selection object can be specified also.<br>
|
|
687
|
-
* If
|
|
688
|
-
* - **NOTE:** In case
|
|
689
|
+
* If another chart is already set, it will be replaced with the new one (only one chart can be set in one element).
|
|
690
|
+
* - **NOTE:** In case the element doesn't exist or not specified, will add a `<div>` element to the body.
|
|
689
691
|
* @name bindto
|
|
690
692
|
* @memberof Options
|
|
691
693
|
* @property {string|HTMLElement|d3.selection|object} [bindto="#chart"] Specify the element where chart will be drawn.
|
|
692
694
|
* @property {string|HTMLElement|d3.selection} bindto.element="#chart" Specify the element where chart will be drawn.
|
|
693
695
|
* @property {string} [bindto.classname=bb] Specify the class name of bind element.<br>
|
|
694
|
-
* **NOTE:** When class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
|
|
696
|
+
* **NOTE:** When the class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
|
|
695
697
|
* @default #chart
|
|
696
698
|
* @example
|
|
697
699
|
* bindto: "#myContainer"
|
|
@@ -732,8 +734,8 @@ const $ZOOM = {
|
|
|
732
734
|
/**
|
|
733
735
|
* Set 'clip-path' attribute for chart element
|
|
734
736
|
* - **NOTE:**
|
|
735
|
-
* > When
|
|
736
|
-
* >
|
|
737
|
+
* > When false, chart node element is positioned after the axis node in DOM tree hierarchy.
|
|
738
|
+
* > This is to make the chart element positioned over axis element.
|
|
737
739
|
* @name clipPath
|
|
738
740
|
* @memberof Options
|
|
739
741
|
* @type {boolean}
|
|
@@ -759,7 +761,7 @@ const $ZOOM = {
|
|
|
759
761
|
svg_classname: void 0,
|
|
760
762
|
/**
|
|
761
763
|
* The desired size of the chart element.
|
|
762
|
-
* If value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
|
|
764
|
+
* 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.
|
|
763
765
|
* @name size
|
|
764
766
|
* @memberof Options
|
|
765
767
|
* @type {object}
|
|
@@ -777,13 +779,13 @@ const $ZOOM = {
|
|
|
777
779
|
size_height: void 0,
|
|
778
780
|
/**
|
|
779
781
|
* The padding of the chart element.
|
|
780
|
-
* - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)"
|
|
782
|
+
* - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)" wiki documentation.
|
|
781
783
|
* @name padding
|
|
782
784
|
* @memberof Options
|
|
783
785
|
* @type {object}
|
|
784
786
|
* @property {object|boolean} [padding=true] Set padding of chart, and accepts object or boolean type.
|
|
785
787
|
* - `Object`: Specify each side's padding.
|
|
786
|
-
* - `false`: Remove padding completely and make shape
|
|
788
|
+
* - `false`: Remove padding completely and make the shape fully occupy the container element.
|
|
787
789
|
* - In this case, axes and subchart will be hidden.
|
|
788
790
|
* - To adjust some padding from this state, use `axis.[x|y].padding` option.
|
|
789
791
|
* @property {string} [padding.mode] padding mode
|
|
@@ -870,7 +872,7 @@ const $ZOOM = {
|
|
|
870
872
|
* Set a callback to execute when the chart is clicked.
|
|
871
873
|
* @name onclick
|
|
872
874
|
* @memberof Options
|
|
873
|
-
* @type {
|
|
875
|
+
* @type {function}
|
|
874
876
|
* @default undefined
|
|
875
877
|
* @example
|
|
876
878
|
* onclick: function(event) {
|
|
@@ -884,7 +886,7 @@ const $ZOOM = {
|
|
|
884
886
|
* Set a callback to execute when mouse/touch enters the chart.
|
|
885
887
|
* @name onover
|
|
886
888
|
* @memberof Options
|
|
887
|
-
* @type {
|
|
889
|
+
* @type {function}
|
|
888
890
|
* @default undefined
|
|
889
891
|
* @example
|
|
890
892
|
* onover: function(event) {
|
|
@@ -898,7 +900,7 @@ const $ZOOM = {
|
|
|
898
900
|
* Set a callback to execute when mouse/touch leaves the chart.
|
|
899
901
|
* @name onout
|
|
900
902
|
* @memberof Options
|
|
901
|
-
* @type {
|
|
903
|
+
* @type {function}
|
|
902
904
|
* @default undefined
|
|
903
905
|
* @example
|
|
904
906
|
* onout: function(event) {
|
|
@@ -912,7 +914,7 @@ const $ZOOM = {
|
|
|
912
914
|
* Set a callback to execute when user resizes the screen.
|
|
913
915
|
* @name onresize
|
|
914
916
|
* @memberof Options
|
|
915
|
-
* @type {
|
|
917
|
+
* @type {function}
|
|
916
918
|
* @default undefined
|
|
917
919
|
* @example
|
|
918
920
|
* onresize: function() {
|
|
@@ -925,7 +927,7 @@ const $ZOOM = {
|
|
|
925
927
|
* Set a callback to execute when screen resize finished.
|
|
926
928
|
* @name onresized
|
|
927
929
|
* @memberof Options
|
|
928
|
-
* @type {
|
|
930
|
+
* @type {function}
|
|
929
931
|
* @default undefined
|
|
930
932
|
* @example
|
|
931
933
|
* onresized: function() {
|
|
@@ -938,7 +940,7 @@ const $ZOOM = {
|
|
|
938
940
|
* Set a callback to execute before the chart is initialized
|
|
939
941
|
* @name onbeforeinit
|
|
940
942
|
* @memberof Options
|
|
941
|
-
* @type {
|
|
943
|
+
* @type {function}
|
|
942
944
|
* @default undefined
|
|
943
945
|
* @example
|
|
944
946
|
* onbeforeinit: function() {
|
|
@@ -951,7 +953,7 @@ const $ZOOM = {
|
|
|
951
953
|
* Set a callback to execute when the chart is initialized.
|
|
952
954
|
* @name oninit
|
|
953
955
|
* @memberof Options
|
|
954
|
-
* @type {
|
|
956
|
+
* @type {function}
|
|
955
957
|
* @default undefined
|
|
956
958
|
* @example
|
|
957
959
|
* oninit: function() {
|
|
@@ -964,7 +966,7 @@ const $ZOOM = {
|
|
|
964
966
|
* Set a callback to execute after the chart is initialized
|
|
965
967
|
* @name onafterinit
|
|
966
968
|
* @memberof Options
|
|
967
|
-
* @type {
|
|
969
|
+
* @type {function}
|
|
968
970
|
* @default undefined
|
|
969
971
|
* @example
|
|
970
972
|
* onafterinit: function() {
|
|
@@ -974,10 +976,10 @@ const $ZOOM = {
|
|
|
974
976
|
*/
|
|
975
977
|
onafterinit: void 0,
|
|
976
978
|
/**
|
|
977
|
-
* Set a callback which is executed when the chart is rendered. Basically, this callback will be called in each time when the chart is
|
|
979
|
+
* 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.
|
|
978
980
|
* @name onrendered
|
|
979
981
|
* @memberof Options
|
|
980
|
-
* @type {
|
|
982
|
+
* @type {function}
|
|
981
983
|
* @default undefined
|
|
982
984
|
* @example
|
|
983
985
|
* onrendered: function() {
|
|
@@ -988,7 +990,7 @@ const $ZOOM = {
|
|
|
988
990
|
onrendered: void 0,
|
|
989
991
|
/**
|
|
990
992
|
* Set duration of transition (in milliseconds) for chart animation.<br><br>
|
|
991
|
-
* - **NOTE:** If `0
|
|
993
|
+
* - **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.
|
|
992
994
|
* @name transition
|
|
993
995
|
* @memberof Options
|
|
994
996
|
* @type {object}
|
|
@@ -1019,11 +1021,11 @@ const $ZOOM = {
|
|
|
1019
1021
|
* @memberof Options
|
|
1020
1022
|
* @type {object}
|
|
1021
1023
|
* @property {object} [render] render object
|
|
1022
|
-
* @property {boolean} [render.lazy=true] Make
|
|
1024
|
+
* @property {boolean} [render.lazy=true] Make it not render at initialization.
|
|
1023
1025
|
* - **NOTE**:
|
|
1024
1026
|
* - Enabled by default when bind element's visibility is hidden.
|
|
1025
1027
|
* - 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.
|
|
1026
|
-
* @property {boolean} [render.observe=true] Observe bind element's visibility(`display` or `
|
|
1028
|
+
* @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.
|
|
1027
1029
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
|
|
1028
1030
|
* @example
|
|
1029
1031
|
* render: {
|
|
@@ -1045,7 +1047,7 @@ const $ZOOM = {
|
|
|
1045
1047
|
* document.getElementById('chart').style.display = 'block'; // (b)
|
|
1046
1048
|
*
|
|
1047
1049
|
* @example
|
|
1048
|
-
* // chart won't be rendered and not observing bind element's
|
|
1050
|
+
* // chart won't be rendered and not observing bind element's visibility changes
|
|
1049
1051
|
* var chart = bb.generate({
|
|
1050
1052
|
* render: {
|
|
1051
1053
|
* lazy: true,
|
|
@@ -1071,7 +1073,7 @@ const $ZOOM = {
|
|
|
1071
1073
|
* - `[start] {number|Date|string}`: Start position of the region. If not set, the start will be the edge of the chart.
|
|
1072
1074
|
* - `[end] {number|Date|string}`: End position of the region. If not set, the end will be the edge of the chart.
|
|
1073
1075
|
* - `[class] {string}`: Class value to apply to the region.
|
|
1074
|
-
* - `[label] {object}`
|
|
1076
|
+
* - `[label] {object}` Label text option.
|
|
1075
1077
|
* - `text {string}`: Text value.
|
|
1076
1078
|
* - `x {number}`: x Position.
|
|
1077
1079
|
* - `y {number}`: y Position.
|
|
@@ -1161,17 +1163,17 @@ const $ZOOM = {
|
|
|
1161
1163
|
* - **NOTE:** The overlapped data points will be displayed as grouped even if set false.
|
|
1162
1164
|
* @property {boolean} [tooltip.linked=false] Set if tooltips on all visible charts with like x points are shown together when one is shown.
|
|
1163
1165
|
* @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.
|
|
1164
|
-
* @property {
|
|
1166
|
+
* @property {function} [tooltip.format.title] Set format for the title of tooltip.<br>
|
|
1165
1167
|
* Specified function receives x of the data point to show.
|
|
1166
|
-
* @property {
|
|
1168
|
+
* @property {function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
|
|
1167
1169
|
* 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.
|
|
1168
|
-
* @property {
|
|
1170
|
+
* @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.
|
|
1169
1171
|
* - Will pass following arguments to the given function:
|
|
1170
1172
|
* - `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.
|
|
1171
1173
|
* - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
|
|
1172
1174
|
* - `id {string}`: id of the data point
|
|
1173
1175
|
* - `index {number}`: Index of the data point
|
|
1174
|
-
* @property {
|
|
1176
|
+
* @property {function} [tooltip.position] Set custom position function for the tooltip.<br>
|
|
1175
1177
|
* This option can be used to modify the tooltip position by returning object that has top and left.
|
|
1176
1178
|
* - Will pass following arguments to the given function:
|
|
1177
1179
|
* - `data {Array}`: Current selected data array object.
|
|
@@ -1179,7 +1181,7 @@ const $ZOOM = {
|
|
|
1179
1181
|
* - `height {number}`: Height of tooltip.
|
|
1180
1182
|
* - `element {SVGElement}`: Tooltip event bound element
|
|
1181
1183
|
* - `pos {object}`: Current position of the tooltip.
|
|
1182
|
-
* @property {
|
|
1184
|
+
* @property {function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
|
|
1183
1185
|
* If tooltip.grouped is true, data includes multiple data points.<br><br>
|
|
1184
1186
|
* Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
|
|
1185
1187
|
* - **Note:**
|
|
@@ -1201,6 +1203,7 @@ const $ZOOM = {
|
|
|
1201
1203
|
* - **{=COLOR}**: data color.
|
|
1202
1204
|
* - **{=NAME}**: data id value.
|
|
1203
1205
|
* - **{=VALUE}**: data value.
|
|
1206
|
+
* - **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.
|
|
1204
1207
|
* @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
|
|
1205
1208
|
* - **NOTE:** It should contain `{ key: Array, ... }` value
|
|
1206
1209
|
* - 'key' name is used as substitution within template as '{=KEY}'
|
|
@@ -1208,11 +1211,11 @@ const $ZOOM = {
|
|
|
1208
1211
|
* @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
|
|
1209
1212
|
* @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
|
|
1210
1213
|
* @property {object} [tooltip.init.position] Set the position of tooltip at the initialization.
|
|
1211
|
-
* @property {
|
|
1212
|
-
* @property {
|
|
1213
|
-
* @property {
|
|
1214
|
-
* @property {
|
|
1215
|
-
* @property {string|
|
|
1214
|
+
* @property {function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
|
|
1215
|
+
* @property {function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
|
|
1216
|
+
* @property {function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
|
|
1217
|
+
* @property {function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
|
|
1218
|
+
* @property {string|function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
|
|
1216
1219
|
* **Available Values:**
|
|
1217
1220
|
* - `desc`: In descending data value order
|
|
1218
1221
|
* - `asc`: In ascending data value order
|
|
@@ -1251,7 +1254,7 @@ const $ZOOM = {
|
|
|
1251
1254
|
* // yAxis: Current y Axis position value or function(the value is given for axis based chart type only)
|
|
1252
1255
|
* // }
|
|
1253
1256
|
*
|
|
1254
|
-
* // yAxis will work differently per data
|
|
1257
|
+
* // yAxis will work differently per data lengths
|
|
1255
1258
|
* // - a) Single data: `yAxis` will return `number` value
|
|
1256
1259
|
* // - b) Multiple data: `yAxis` will return a function with property value
|
|
1257
1260
|
*
|
|
@@ -1262,8 +1265,8 @@ const $ZOOM = {
|
|
|
1262
1265
|
* // b) Multiple data:
|
|
1263
1266
|
* // Get y coordinate of value 500, where 'data1' scales(y or y2).
|
|
1264
1267
|
* // When 'data.axes' option is used, data can bound to different axes.
|
|
1265
|
-
* // - when "data.axes={data1: 'y'}",
|
|
1266
|
-
* // - when "data.axes={data1: 'y2'}",
|
|
1268
|
+
* // - when "data.axes={data1: 'y'}", will return y value from y axis scale.
|
|
1269
|
+
* // - when "data.axes={data1: 'y2'}", will return y value from y2 axis scale.
|
|
1267
1270
|
* pos.yAxis(500, "data1"); // will return y coordinate value of data1
|
|
1268
1271
|
*
|
|
1269
1272
|
* pos.yAxis(500); // get y coordinate with value of 500, using y axis scale
|
|
@@ -1399,7 +1402,7 @@ const $ZOOM = {
|
|
|
1399
1402
|
/* harmony default export */ var data = ({
|
|
1400
1403
|
/**
|
|
1401
1404
|
* Specify the key of x values in the data.<br><br>
|
|
1402
|
-
* 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.
|
|
1405
|
+
* 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.
|
|
1403
1406
|
* @name data․x
|
|
1404
1407
|
* @memberof Options
|
|
1405
1408
|
* @type {string}
|
|
@@ -1414,7 +1417,7 @@ const $ZOOM = {
|
|
|
1414
1417
|
* Converts data id value
|
|
1415
1418
|
* @name data․idConverter
|
|
1416
1419
|
* @memberof Options
|
|
1417
|
-
* @type {
|
|
1420
|
+
* @type {function}
|
|
1418
1421
|
* @default function(id) { return id; }
|
|
1419
1422
|
* @example
|
|
1420
1423
|
* data: {
|
|
@@ -1583,8 +1586,8 @@ const $ZOOM = {
|
|
|
1583
1586
|
data_types: {},
|
|
1584
1587
|
/**
|
|
1585
1588
|
* This option changes the order of stacking data and pieces of pie/donut.
|
|
1586
|
-
* - If `null` specified, it will be the order the data loaded.
|
|
1587
|
-
* - 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>
|
|
1589
|
+
* - If `null` specified, it will be the order in which the data is loaded.
|
|
1590
|
+
* - 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>
|
|
1588
1591
|
*
|
|
1589
1592
|
* **Available Values:**
|
|
1590
1593
|
* - `desc`: In descending order
|
|
@@ -1592,10 +1595,10 @@ const $ZOOM = {
|
|
|
1592
1595
|
* - `null`: It keeps the data load order
|
|
1593
1596
|
* - `function(data1, data2) { ... }`: Array.sort compareFunction
|
|
1594
1597
|
*
|
|
1595
|
-
* **NOTE**: order function
|
|
1598
|
+
* **NOTE**: order function only works for Axis based types & Arc types, except `Radar` type.
|
|
1596
1599
|
* @name data․order
|
|
1597
1600
|
* @memberof Options
|
|
1598
|
-
* @type {string|
|
|
1601
|
+
* @type {string|function|null}
|
|
1599
1602
|
* @default desc
|
|
1600
1603
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
|
|
1601
1604
|
* @example
|
|
@@ -1650,7 +1653,7 @@ const $ZOOM = {
|
|
|
1650
1653
|
/**
|
|
1651
1654
|
* Set how zero value will be treated on groups.<br>
|
|
1652
1655
|
* Possible values:
|
|
1653
|
-
* - `zero`: 0 will be positioned at absolute axis zero point.
|
|
1656
|
+
* - `zero`: 0 will be positioned at the absolute axis zero point.
|
|
1654
1657
|
* - `positive`: 0 will be positioned at the top of a stack.
|
|
1655
1658
|
* - `negative`: 0 will be positioned at the bottom of a stack.
|
|
1656
1659
|
* @name data․groupsZeroAs
|
|
@@ -1666,10 +1669,10 @@ const $ZOOM = {
|
|
|
1666
1669
|
data_groupsZeroAs: "positive",
|
|
1667
1670
|
/**
|
|
1668
1671
|
* Set color converter function.<br><br>
|
|
1669
|
-
* 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').
|
|
1672
|
+
* 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').
|
|
1670
1673
|
* @name data․color
|
|
1671
1674
|
* @memberof Options
|
|
1672
|
-
* @type {
|
|
1675
|
+
* @type {function}
|
|
1673
1676
|
* @default undefined
|
|
1674
1677
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
|
|
1675
1678
|
* @example
|
|
@@ -1702,41 +1705,41 @@ const $ZOOM = {
|
|
|
1702
1705
|
* @memberof Options
|
|
1703
1706
|
* @type {object}
|
|
1704
1707
|
* @property {object} data Data object
|
|
1705
|
-
* @property {boolean} [data.labels=false] Show or hide labels on each data
|
|
1708
|
+
* @property {boolean} [data.labels=false] Show or hide labels on each data point
|
|
1706
1709
|
* @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
|
|
1707
|
-
* @property {
|
|
1710
|
+
* @property {function} [data.labels.format] Set formatter function for data labels.<br>
|
|
1708
1711
|
* 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>
|
|
1709
1712
|
* The arguments are:<br>
|
|
1710
1713
|
* - `v` is the value of the data point where the label is shown.
|
|
1711
1714
|
* - `id` is the id of the data where the label is shown.
|
|
1712
1715
|
* - `i` is the index of the data series point where the label is shown.
|
|
1713
|
-
* - `texts` is
|
|
1716
|
+
* - `texts` is an array of whole corresponding data series' text labels.<br><br>
|
|
1714
1717
|
* Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
|
|
1715
|
-
* @property {string|object|
|
|
1716
|
-
* - **NOTE**: When function is set, background colors can be specified one color per dataset.
|
|
1718
|
+
* @property {string|object|function} [data.labels.backgroundColors] Set label text background colors.<br><br>
|
|
1719
|
+
* - **NOTE**: When a function is set, background colors can be specified one color per dataset.
|
|
1717
1720
|
* - Within the function, the last returned color for dataset will be used.
|
|
1718
1721
|
* - Only can control set or unset background color for each values.
|
|
1719
|
-
* @property {string|object|
|
|
1720
|
-
* @property {object|
|
|
1721
|
-
* When function is specified, will
|
|
1722
|
+
* @property {string|object|function} [data.labels.colors] Set label text colors.
|
|
1723
|
+
* @property {object|function} [data.labels.position] Set each dataset position, relative to the original.<br><br>
|
|
1724
|
+
* 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>
|
|
1722
1725
|
* The arguments are:<br>
|
|
1723
1726
|
* - `type` coordinate type string, which will be 'x' or 'y'.
|
|
1724
1727
|
* - `v` is the value of the data point where the label is shown.
|
|
1725
1728
|
* - `id` is the id of the data where the label is shown.
|
|
1726
1729
|
* - `i` is the index of the data series point where the label is shown.
|
|
1727
|
-
* - `texts` is
|
|
1728
|
-
* @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
|
|
1729
|
-
* @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
|
|
1730
|
+
* - `texts` is an array of whole corresponding data series' text labels.<br><br>
|
|
1731
|
+
* @property {number} [data.labels.position.x=0] x coordinate position, relative to the original.
|
|
1732
|
+
* @property {number} [data.labels.position.y=0] y coordinate position, relative to the original.
|
|
1730
1733
|
* @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
|
|
1731
|
-
* - **NOTE:**
|
|
1732
|
-
* @property {boolean|object} [data.labels.border=false] Add border to data label text. NOTE: When set as `true`, styling
|
|
1734
|
+
* - **NOTE:** Depending on the rotate value, the text position needs to be adjusted manually(using `data.labels.position` option) to be shown nicely.
|
|
1735
|
+
* @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.
|
|
1733
1736
|
* @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.
|
|
1734
1737
|
* @property {number} [data.labels.border.radius=10] Border radius value.
|
|
1735
1738
|
* @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
|
|
1736
1739
|
* @property {string} [data.labels.border.stroke="#000"] Border stroke color.
|
|
1737
1740
|
* @property {string} [data.labels.border.fill="none"] Border fill color.
|
|
1738
|
-
* @property {object|
|
|
1739
|
-
* When function is specified, will
|
|
1741
|
+
* @property {object|function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
|
|
1742
|
+
* 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>
|
|
1740
1743
|
* The arguments are:<br>
|
|
1741
1744
|
* - `v` is the value of the data point where the label is shown.
|
|
1742
1745
|
* - `id` is the id of the data where the label is shown.
|
|
@@ -1745,8 +1748,8 @@ const $ZOOM = {
|
|
|
1745
1748
|
* @property {number} data.labels.image.width Image width in pixels.
|
|
1746
1749
|
* @property {number} data.labels.image.height Image height in pixels.
|
|
1747
1750
|
* @property {object} [data.labels.image.pos] Image position relative to the label text.
|
|
1748
|
-
* @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
|
|
1749
|
-
* @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
|
|
1751
|
+
* @property {number} [data.labels.image.pos.x=0] x coordinate position, relative to the original.
|
|
1752
|
+
* @property {number} [data.labels.image.pos.y=0] y coordinate position, relative to the original.
|
|
1750
1753
|
* @memberof Options
|
|
1751
1754
|
* @type {object}
|
|
1752
1755
|
* @default {}
|
|
@@ -1780,10 +1783,10 @@ const $ZOOM = {
|
|
|
1780
1783
|
* // align text to center of the 'bar' shape (works only for 'bar' type)
|
|
1781
1784
|
* centered: true,
|
|
1782
1785
|
*
|
|
1783
|
-
* // apply
|
|
1786
|
+
* // apply background color for label texts
|
|
1784
1787
|
* backgroundColors: "red",
|
|
1785
1788
|
*
|
|
1786
|
-
* // set
|
|
1789
|
+
* // set different background colors per dataset
|
|
1787
1790
|
* backgroundColors: {
|
|
1788
1791
|
* data1: "green",
|
|
1789
1792
|
* data2: "yellow"
|
|
@@ -1894,7 +1897,7 @@ const $ZOOM = {
|
|
|
1894
1897
|
* pos: { x: 0, y: 0 }
|
|
1895
1898
|
* };
|
|
1896
1899
|
* } else if(v < 5) {
|
|
1897
|
-
* // Return falsy value in case
|
|
1900
|
+
* // Return falsy value in case you don't want to show image
|
|
1898
1901
|
* return null;
|
|
1899
1902
|
* } else {
|
|
1900
1903
|
* return {
|
|
@@ -1915,7 +1918,7 @@ const $ZOOM = {
|
|
|
1915
1918
|
data_labels_imgUrl: void 0,
|
|
1916
1919
|
/**
|
|
1917
1920
|
* Hide each data when the chart appears.<br><br>
|
|
1918
|
-
* If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
|
|
1921
|
+
* If true is specified, all of data will be hidden. If multiple ids are specified as an array, those will be hidden.
|
|
1919
1922
|
* @name data․hide
|
|
1920
1923
|
* @memberof Options
|
|
1921
1924
|
* @type {boolean|Array}
|
|
@@ -1936,7 +1939,7 @@ const $ZOOM = {
|
|
|
1936
1939
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
|
|
1937
1940
|
* @name data․filter
|
|
1938
1941
|
* @memberof Options
|
|
1939
|
-
* @type {
|
|
1942
|
+
* @type {function}
|
|
1940
1943
|
* @default undefined
|
|
1941
1944
|
* @example
|
|
1942
1945
|
* data: {
|
|
@@ -1951,13 +1954,13 @@ const $ZOOM = {
|
|
|
1951
1954
|
data_filter: void 0,
|
|
1952
1955
|
/**
|
|
1953
1956
|
* Set a callback for click event on each data point.<br><br>
|
|
1954
|
-
* This callback will be called when each data point clicked and will receive `d` and element as the arguments.
|
|
1957
|
+
* This callback will be called when each data point is clicked and will receive `d` and element as the arguments.
|
|
1955
1958
|
* - `d` is the data clicked and element is the element clicked.
|
|
1956
1959
|
* - `element` is the current interacting svg element.
|
|
1957
1960
|
* - In this callback, `this` will be the Chart object.
|
|
1958
1961
|
* @name data․onclick
|
|
1959
1962
|
* @memberof Options
|
|
1960
|
-
* @type {
|
|
1963
|
+
* @type {function}
|
|
1961
1964
|
* @default function() {}
|
|
1962
1965
|
* @example
|
|
1963
1966
|
* data: {
|
|
@@ -1972,13 +1975,13 @@ const $ZOOM = {
|
|
|
1972
1975
|
},
|
|
1973
1976
|
/**
|
|
1974
1977
|
* Set a callback for mouse/touch over event on each data point.<br><br>
|
|
1975
|
-
* This callback will be called when mouse cursor or
|
|
1978
|
+
* 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.
|
|
1976
1979
|
* - `d` is the data where mouse cursor moves onto.
|
|
1977
1980
|
* - `element` is the current interacting svg element.
|
|
1978
1981
|
* - In this callback, `this` will be the Chart object.
|
|
1979
1982
|
* @name data․onover
|
|
1980
1983
|
* @memberof Options
|
|
1981
|
-
* @type {
|
|
1984
|
+
* @type {function}
|
|
1982
1985
|
* @default function() {}
|
|
1983
1986
|
* @example
|
|
1984
1987
|
* data: {
|
|
@@ -1993,13 +1996,13 @@ const $ZOOM = {
|
|
|
1993
1996
|
},
|
|
1994
1997
|
/**
|
|
1995
1998
|
* Set a callback for mouse/touch out event on each data point.<br><br>
|
|
1996
|
-
* This callback will be called when mouse cursor or
|
|
1999
|
+
* This callback will be called when the mouse cursor or touch moves out each data point and will receive `d` as the argument.
|
|
1997
2000
|
* - `d` is the data where mouse cursor moves out.
|
|
1998
2001
|
* - `element` is the current interacting svg element.
|
|
1999
2002
|
* - In this callback, `this` will be the Chart object.
|
|
2000
2003
|
* @name data․onout
|
|
2001
2004
|
* @memberof Options
|
|
2002
|
-
* @type {
|
|
2005
|
+
* @type {function}
|
|
2003
2006
|
* @default function() {}
|
|
2004
2007
|
* @example
|
|
2005
2008
|
* data: {
|
|
@@ -2017,7 +2020,7 @@ const $ZOOM = {
|
|
|
2017
2020
|
* The callback will receive shown data ids in array.
|
|
2018
2021
|
* @name data․onshown
|
|
2019
2022
|
* @memberof Options
|
|
2020
|
-
* @type {
|
|
2023
|
+
* @type {function}
|
|
2021
2024
|
* @default undefined
|
|
2022
2025
|
* @example
|
|
2023
2026
|
* data: {
|
|
@@ -2033,7 +2036,7 @@ const $ZOOM = {
|
|
|
2033
2036
|
* The callback will receive hidden data ids in array.
|
|
2034
2037
|
* @name data․onhidden
|
|
2035
2038
|
* @memberof Options
|
|
2036
|
-
* @type {
|
|
2039
|
+
* @type {function}
|
|
2037
2040
|
* @default undefined
|
|
2038
2041
|
* @example
|
|
2039
2042
|
* data: {
|
|
@@ -2049,7 +2052,7 @@ const $ZOOM = {
|
|
|
2049
2052
|
* - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
|
|
2050
2053
|
* @name data․onmin
|
|
2051
2054
|
* @memberof Options
|
|
2052
|
-
* @type {
|
|
2055
|
+
* @type {function}
|
|
2053
2056
|
* @default undefined
|
|
2054
2057
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
|
|
2055
2058
|
* @example
|
|
@@ -2064,7 +2067,7 @@ const $ZOOM = {
|
|
|
2064
2067
|
* - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
|
|
2065
2068
|
* @name data․onmax
|
|
2066
2069
|
* @memberof Options
|
|
2067
|
-
* @type {
|
|
2070
|
+
* @type {function}
|
|
2068
2071
|
* @default undefined
|
|
2069
2072
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
|
|
2070
2073
|
* @example
|
|
@@ -2075,7 +2078,7 @@ const $ZOOM = {
|
|
|
2075
2078
|
*/
|
|
2076
2079
|
data_onmax: void 0,
|
|
2077
2080
|
/**
|
|
2078
|
-
* Load a CSV or JSON file from a URL. NOTE that this will not work if loading via the "file://" protocol as
|
|
2081
|
+
* 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.
|
|
2079
2082
|
* @name data․url
|
|
2080
2083
|
* @memberof Options
|
|
2081
2084
|
* @type {string}
|
|
@@ -2203,7 +2206,7 @@ const $ZOOM = {
|
|
|
2203
2206
|
* }
|
|
2204
2207
|
* }
|
|
2205
2208
|
*
|
|
2206
|
-
* // for '
|
|
2209
|
+
* // for 'candlestick' type, data should contain:
|
|
2207
2210
|
* // - an array of [open, high, low, close, volume(optional)] data following the order
|
|
2208
2211
|
* // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
|
|
2209
2212
|
* data: {
|
|
@@ -2278,7 +2281,7 @@ const $ZOOM = {
|
|
|
2278
2281
|
* type: "bubble"
|
|
2279
2282
|
* }
|
|
2280
2283
|
*
|
|
2281
|
-
* // for '
|
|
2284
|
+
* // for 'candlestick' type, data should contain:
|
|
2282
2285
|
* // - an array of [open, high, low, close, volume(optional)] data following the order
|
|
2283
2286
|
* // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
|
|
2284
2287
|
* data: {
|
|
@@ -2366,7 +2369,8 @@ const $ZOOM = {
|
|
|
2366
2369
|
* @property {boolean} [interaction.brighten=true] Make brighter for the selected area (ex. 'pie' type data selected area)
|
|
2367
2370
|
* @property {boolean} [interaction.inputType.mouse=true] enable or disable mouse interaction
|
|
2368
2371
|
* @property {boolean} [interaction.inputType.touch=true] enable or disable touch interaction
|
|
2369
|
-
* @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
|
|
2372
|
+
* @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>
|
|
2373
|
+
* - **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.
|
|
2370
2374
|
* @property {boolean} [interaction.onout=true] Enable or disable "onout" event.<br>
|
|
2371
2375
|
* When is disabled, defocus(hiding tooltip, focused gridline, etc.) event won't work.
|
|
2372
2376
|
* @see [Demo: touch.preventDefault](https://naver.github.io/billboard.js/demo/#Interaction.PreventScrollOnTouch)
|
|
@@ -2447,7 +2451,83 @@ var util_spreadValues = (a, b) => {
|
|
|
2447
2451
|
|
|
2448
2452
|
|
|
2449
2453
|
|
|
2450
|
-
|
|
2454
|
+
function _getRect(relativeViewport, node, forceEval = false) {
|
|
2455
|
+
const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
|
|
2456
|
+
if (forceEval) {
|
|
2457
|
+
return _(node);
|
|
2458
|
+
} else {
|
|
2459
|
+
const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
|
|
2460
|
+
return needEvaluate ? node.rect = _(node) : node.rect;
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
function _forEachValidItem(items, callback) {
|
|
2464
|
+
for (let i = 0; i < items.length; i++) {
|
|
2465
|
+
const item = items[i];
|
|
2466
|
+
if (item) {
|
|
2467
|
+
callback(item, i);
|
|
2468
|
+
}
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
const _sanitize = (() => {
|
|
2472
|
+
const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
|
|
2473
|
+
const ENTITY_MAP = {
|
|
2474
|
+
quot: 34,
|
|
2475
|
+
amp: 38,
|
|
2476
|
+
apos: 39,
|
|
2477
|
+
lt: 60,
|
|
2478
|
+
gt: 62,
|
|
2479
|
+
nbsp: 160,
|
|
2480
|
+
iexcl: 161,
|
|
2481
|
+
cent: 162,
|
|
2482
|
+
pound: 163,
|
|
2483
|
+
curren: 164,
|
|
2484
|
+
yen: 165
|
|
2485
|
+
};
|
|
2486
|
+
const LT_CODE = 60;
|
|
2487
|
+
const GT_CODE = 62;
|
|
2488
|
+
const MAX_ITERATIONS = 10;
|
|
2489
|
+
const rx = {
|
|
2490
|
+
tags: new RegExp(
|
|
2491
|
+
`<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
|
|
2492
|
+
"gi"
|
|
2493
|
+
),
|
|
2494
|
+
htmlEntity: /&#x([0-9a-f]+);?|&#([0-9]+);?|&([a-z]+);/gi,
|
|
2495
|
+
// eslint-disable-next-line no-control-regex
|
|
2496
|
+
controlChar: /[\x00-\x1F\x7F]/g,
|
|
2497
|
+
eventHandler: /\s+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)|on\w+\s*=\s*(?:"[^"]*"|'[^']*'|`[^`]*`|[^\s>]*)/gi,
|
|
2498
|
+
dangerousUri: /(href|src|action|xlink:href)\s*=\s*(['"`]?)([^'"`>\s]*)\2/gi,
|
|
2499
|
+
dangerousProtocol: /^(javascript|data|vbscript):/
|
|
2500
|
+
};
|
|
2501
|
+
return {
|
|
2502
|
+
ENTITY_MAP,
|
|
2503
|
+
LT_CODE,
|
|
2504
|
+
GT_CODE,
|
|
2505
|
+
MAX_ITERATIONS,
|
|
2506
|
+
rx,
|
|
2507
|
+
/**
|
|
2508
|
+
* Decode HTML entities to prevent bypass attacks
|
|
2509
|
+
* @param {string} str String with potential HTML entities
|
|
2510
|
+
* @returns {string} Decoded string
|
|
2511
|
+
*/
|
|
2512
|
+
decodeEntities(str) {
|
|
2513
|
+
return str.replace(rx.htmlEntity, (match, hex, dec, named) => {
|
|
2514
|
+
const code = hex ? parseInt(hex, 16) : dec ? parseInt(dec, 10) : named ? ENTITY_MAP[named.toLowerCase()] || 0 : 0;
|
|
2515
|
+
return code && code !== LT_CODE && code !== GT_CODE ? String.fromCharCode(code) : match;
|
|
2516
|
+
});
|
|
2517
|
+
},
|
|
2518
|
+
/**
|
|
2519
|
+
* Remove dangerous URI protocols from attribute values
|
|
2520
|
+
* @param {string} str String to sanitize
|
|
2521
|
+
* @returns {string} Sanitized string
|
|
2522
|
+
*/
|
|
2523
|
+
removeDangerousUris(str) {
|
|
2524
|
+
return str.replace(rx.dangerousUri, (match, attr, quote, value) => {
|
|
2525
|
+
const normalized = value.toLowerCase().replace(/\s/g, "");
|
|
2526
|
+
return rx.dangerousProtocol.test(normalized) ? `${attr}=${quote}${quote}` : match;
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
})();
|
|
2451
2531
|
const isValue = (v) => v || v === 0;
|
|
2452
2532
|
const isFunction = (v) => typeof v === "function";
|
|
2453
2533
|
const isString = (v) => typeof v === "string";
|
|
@@ -2494,26 +2574,20 @@ function endall(transition, cb) {
|
|
|
2494
2574
|
transition.call(end);
|
|
2495
2575
|
}
|
|
2496
2576
|
}
|
|
2497
|
-
const DANGEROUS_TAGS = "script|iframe|object|embed|form|input|button|textarea|select|style|link|meta|base|math|isindex";
|
|
2498
|
-
const sanitizeRx = {
|
|
2499
|
-
tags: new RegExp(
|
|
2500
|
-
`<(${DANGEROUS_TAGS})\\b[\\s\\S]*?>([\\s\\S]*?<\\/(${DANGEROUS_TAGS})\\s*>)?`,
|
|
2501
|
-
"gi"
|
|
2502
|
-
),
|
|
2503
|
-
// Handles: whitespace, slash, quotes before event handlers (e.g., <img/onerror=...>, <img src="x"onerror=...>)
|
|
2504
|
-
eventHandlers: /[\s/"']+on\w+\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+)/gi,
|
|
2505
|
-
// Handles: javascript/data/vbscript URIs with optional whitespace/newlines between protocol and colon
|
|
2506
|
-
dangerousURIs: /(href|src|action|xlink:href)\s*=\s*["']?\s*(javascript|data|vbscript)\s*:/gi
|
|
2507
|
-
};
|
|
2508
2577
|
function sanitize(str) {
|
|
2509
2578
|
if (!isString(str) || !str || str.indexOf("<") === -1) {
|
|
2510
2579
|
return str;
|
|
2511
2580
|
}
|
|
2512
2581
|
let result = str;
|
|
2513
2582
|
let prev;
|
|
2583
|
+
let iterations = 0;
|
|
2514
2584
|
do {
|
|
2515
2585
|
prev = result;
|
|
2516
|
-
result = result.replace(
|
|
2586
|
+
result = _sanitize.decodeEntities(result).replace(_sanitize.rx.controlChar, "").replace(_sanitize.rx.tags, "").replace(_sanitize.rx.eventHandler, "");
|
|
2587
|
+
result = _sanitize.removeDangerousUris(result);
|
|
2588
|
+
if (++iterations >= _sanitize.MAX_ITERATIONS) {
|
|
2589
|
+
break;
|
|
2590
|
+
}
|
|
2517
2591
|
} while (result !== prev);
|
|
2518
2592
|
return result;
|
|
2519
2593
|
}
|
|
@@ -2581,20 +2655,11 @@ function getBrushSelection(ctx) {
|
|
|
2581
2655
|
}
|
|
2582
2656
|
return selection;
|
|
2583
2657
|
}
|
|
2584
|
-
function getRect(relativeViewport, node, forceEval = false) {
|
|
2585
|
-
const _ = (n) => n[relativeViewport ? "getBoundingClientRect" : "getBBox"]();
|
|
2586
|
-
if (forceEval) {
|
|
2587
|
-
return _(node);
|
|
2588
|
-
} else {
|
|
2589
|
-
const needEvaluate = !("rect" in node) || "rect" in node && node.hasAttribute("width") && node.rect.width !== +(node.getAttribute("width") || 0);
|
|
2590
|
-
return needEvaluate ? node.rect = _(node) : node.rect;
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
2658
|
function getBoundingRect(node, forceEval = false) {
|
|
2594
|
-
return
|
|
2659
|
+
return _getRect(true, node, forceEval);
|
|
2595
2660
|
}
|
|
2596
2661
|
function getBBox(node, forceEval = false) {
|
|
2597
|
-
return
|
|
2662
|
+
return _getRect(false, node, forceEval);
|
|
2598
2663
|
}
|
|
2599
2664
|
function getRandom(asStr = true, min = 0, max = 1e4) {
|
|
2600
2665
|
const crpt = win.crypto || win.msCrypto;
|
|
@@ -2906,6 +2971,35 @@ function parseShorthand(value) {
|
|
|
2906
2971
|
const [a, b = a, c = a, d = b] = values;
|
|
2907
2972
|
return { top: a, right: b, bottom: c, left: d };
|
|
2908
2973
|
}
|
|
2974
|
+
function scheduleRAFUpdate(rafState, callback) {
|
|
2975
|
+
if (rafState.pendingRaf !== null) {
|
|
2976
|
+
win.cancelAnimationFrame(rafState.pendingRaf);
|
|
2977
|
+
rafState.pendingRaf = win.requestAnimationFrame(() => {
|
|
2978
|
+
rafState.pendingRaf = null;
|
|
2979
|
+
callback();
|
|
2980
|
+
});
|
|
2981
|
+
} else {
|
|
2982
|
+
rafState.pendingRaf = win.requestAnimationFrame(() => {
|
|
2983
|
+
rafState.pendingRaf = null;
|
|
2984
|
+
});
|
|
2985
|
+
callback();
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
function toSet(items, keyFn = ((item) => item)) {
|
|
2989
|
+
const set = /* @__PURE__ */ new Set();
|
|
2990
|
+
_forEachValidItem(items, (item, i) => {
|
|
2991
|
+
set.add(keyFn(item, i));
|
|
2992
|
+
});
|
|
2993
|
+
return set;
|
|
2994
|
+
}
|
|
2995
|
+
function toMap(items, keyFn, valueFn = ((item) => item)) {
|
|
2996
|
+
const map = /* @__PURE__ */ new Map();
|
|
2997
|
+
_forEachValidItem(items, (item, i) => {
|
|
2998
|
+
map.set(keyFn(item, i), valueFn(item, i));
|
|
2999
|
+
});
|
|
3000
|
+
return map;
|
|
3001
|
+
}
|
|
3002
|
+
|
|
2909
3003
|
|
|
2910
3004
|
;// ./src/config/Options/Options.ts
|
|
2911
3005
|
var Options_defProp = Object.defineProperty;
|
|
@@ -3068,6 +3162,10 @@ class State {
|
|
|
3068
3162
|
hasTreemap: false,
|
|
3069
3163
|
// for data CSS rule index (used when boost.useCssRule is true)
|
|
3070
3164
|
cssRule: {},
|
|
3165
|
+
// Data loading state (used in scale calculation)
|
|
3166
|
+
loading: void 0,
|
|
3167
|
+
// Zoom/subchart domain (different from current.domain which is for rendering)
|
|
3168
|
+
domain: void 0,
|
|
3071
3169
|
current: {
|
|
3072
3170
|
// current domain value. Assigned when is zoom is called
|
|
3073
3171
|
domain: void 0,
|
|
@@ -3181,7 +3279,10 @@ class State {
|
|
|
3181
3279
|
x2: null,
|
|
3182
3280
|
y1: null,
|
|
3183
3281
|
y2: null
|
|
3184
|
-
}
|
|
3282
|
+
},
|
|
3283
|
+
// RAF batching for zoom/drag interactions
|
|
3284
|
+
pendingRaf: null,
|
|
3285
|
+
rafBatchQueue: []
|
|
3185
3286
|
};
|
|
3186
3287
|
}
|
|
3187
3288
|
}
|
|
@@ -3215,12 +3316,18 @@ const KEY = {
|
|
|
3215
3316
|
dataMinMax: "$dataMinMax",
|
|
3216
3317
|
dataTotalSum: "$dataTotalSum",
|
|
3217
3318
|
dataTotalPerIndex: "$totalPerIndex",
|
|
3319
|
+
domainMinMax: "$domainMinMax",
|
|
3320
|
+
filteredTargets: "$filteredTargets",
|
|
3321
|
+
filteredNullish: "$filteredNullish",
|
|
3322
|
+
visibilityChecksum: "visibilityChecksum",
|
|
3218
3323
|
legendItemTextBox: "legendItemTextBox",
|
|
3324
|
+
legendItemMap: "$legendItemMap",
|
|
3219
3325
|
radarPoints: "$radarPoints",
|
|
3220
3326
|
radarTextWidth: "$radarTextWidth",
|
|
3221
3327
|
setOverOut: "setOverOut",
|
|
3222
3328
|
callOverOutForTouch: "callOverOutForTouch",
|
|
3223
|
-
textRect: "textRect"
|
|
3329
|
+
textRect: "textRect",
|
|
3330
|
+
shapeOffset: "$shapeOffset"
|
|
3224
3331
|
};
|
|
3225
3332
|
class Cache {
|
|
3226
3333
|
constructor() {
|
|
@@ -3229,9 +3336,9 @@ class Cache {
|
|
|
3229
3336
|
/**
|
|
3230
3337
|
* Add cache
|
|
3231
3338
|
* @param {string} key Cache key
|
|
3232
|
-
* @param {
|
|
3339
|
+
* @param {string|number|boolean|object|Array|function|null|undefined} value Value to be stored
|
|
3233
3340
|
* @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
|
|
3234
|
-
* @returns {
|
|
3341
|
+
* @returns {string|number|boolean|object|Array|function|null|undefined} Added data value
|
|
3235
3342
|
* @private
|
|
3236
3343
|
*/
|
|
3237
3344
|
add(key, value, isDataType = false) {
|
|
@@ -3250,7 +3357,7 @@ class Cache {
|
|
|
3250
3357
|
* Get cahce
|
|
3251
3358
|
* @param {string|Array} key Cache key
|
|
3252
3359
|
* @param {boolean} isDataType Weather the cache is data typed '{id:'data', id_org: 'data', values: [{x:0, index:0,...}, ...]}'
|
|
3253
|
-
* @returns {
|
|
3360
|
+
* @returns {string|number|boolean|object|Array|function|null} Cached value
|
|
3254
3361
|
* @private
|
|
3255
3362
|
*/
|
|
3256
3363
|
get(key, isDataType = false) {
|
|
@@ -3267,6 +3374,23 @@ class Cache {
|
|
|
3267
3374
|
return isValue(value) ? value : null;
|
|
3268
3375
|
}
|
|
3269
3376
|
}
|
|
3377
|
+
/**
|
|
3378
|
+
* Check if cache key exists
|
|
3379
|
+
* @param {string} key Cache key
|
|
3380
|
+
* @returns {boolean} True if key exists in cache
|
|
3381
|
+
* @private
|
|
3382
|
+
*/
|
|
3383
|
+
has(key) {
|
|
3384
|
+
return key in this.cache && this.cache[key] !== null;
|
|
3385
|
+
}
|
|
3386
|
+
/**
|
|
3387
|
+
* Get all cache keys
|
|
3388
|
+
* @returns {string[]} Array of cache keys
|
|
3389
|
+
* @private
|
|
3390
|
+
*/
|
|
3391
|
+
getKeys() {
|
|
3392
|
+
return Object.keys(this.cache);
|
|
3393
|
+
}
|
|
3270
3394
|
/**
|
|
3271
3395
|
* Reset cached data
|
|
3272
3396
|
* @param {boolean} all true: reset all data, false: reset only '$' prefixed key data
|
|
@@ -3674,14 +3798,14 @@ function tsv(tsv2) {
|
|
|
3674
3798
|
|
|
3675
3799
|
|
|
3676
3800
|
|
|
3677
|
-
function
|
|
3801
|
+
function _getDataKeyForJson(keysParam, config) {
|
|
3678
3802
|
const keys = keysParam || (config == null ? void 0 : config.data_keys);
|
|
3679
3803
|
if (keys == null ? void 0 : keys.x) {
|
|
3680
3804
|
config.data_x = keys.x;
|
|
3681
3805
|
}
|
|
3682
3806
|
return keys;
|
|
3683
3807
|
}
|
|
3684
|
-
function
|
|
3808
|
+
function _setXS(ids, data, params) {
|
|
3685
3809
|
const $$ = this;
|
|
3686
3810
|
const { config } = $$;
|
|
3687
3811
|
let xsData;
|
|
@@ -3714,7 +3838,7 @@ function setXS(ids, data, params) {
|
|
|
3714
3838
|
/**
|
|
3715
3839
|
* Convert data according its type
|
|
3716
3840
|
* @param {object} args data object
|
|
3717
|
-
* @param {
|
|
3841
|
+
* @param {function} [callback] callback for url(XHR) type loading
|
|
3718
3842
|
* @private
|
|
3719
3843
|
*/
|
|
3720
3844
|
convertData(args, callback) {
|
|
@@ -3735,13 +3859,13 @@ function setXS(ids, data, params) {
|
|
|
3735
3859
|
data.url,
|
|
3736
3860
|
data.mimeType,
|
|
3737
3861
|
data.headers,
|
|
3738
|
-
|
|
3862
|
+
_getDataKeyForJson(data.keys, config),
|
|
3739
3863
|
callback
|
|
3740
3864
|
);
|
|
3741
3865
|
} else if (data.json) {
|
|
3742
3866
|
runWorker(useWorker(data.json), json, callback, [columns, rows])(
|
|
3743
3867
|
data.json,
|
|
3744
|
-
|
|
3868
|
+
_getDataKeyForJson(data.keys, config)
|
|
3745
3869
|
);
|
|
3746
3870
|
} else if (data.rows) {
|
|
3747
3871
|
runWorker(useWorker(data.rows), rows, callback)(data.rows);
|
|
@@ -3779,13 +3903,13 @@ function setXS(ids, data, params) {
|
|
|
3779
3903
|
timeSeries: axis == null ? void 0 : axis.isTimeSeries(),
|
|
3780
3904
|
customX: axis == null ? void 0 : axis.isCustomX()
|
|
3781
3905
|
};
|
|
3782
|
-
|
|
3906
|
+
_setXS.bind($$)(ids, data, params);
|
|
3783
3907
|
const targets = ids.map((id, index) => {
|
|
3784
3908
|
const convertedId = config.data_idConverter.bind($$.api)(id);
|
|
3785
3909
|
const xKey = $$.getXKey(id);
|
|
3786
3910
|
const isCategory = params.customX && params.categorized;
|
|
3787
3911
|
const hasCategory = isCategory && (() => {
|
|
3788
|
-
const categorySet =
|
|
3912
|
+
const categorySet = toSet(config.axis_x_categories);
|
|
3789
3913
|
return data.every((v) => categorySet.has(v.x));
|
|
3790
3914
|
})();
|
|
3791
3915
|
const isDataAppend = data.__append__;
|
|
@@ -3865,7 +3989,17 @@ function setXS(ids, data, params) {
|
|
|
3865
3989
|
},
|
|
3866
3990
|
isStackNormalized() {
|
|
3867
3991
|
const { config } = this;
|
|
3868
|
-
return !!(config.data_stack_normalize && config.data_groups.length);
|
|
3992
|
+
return !!((config.data_stack_normalize === true || isObjectType(config.data_stack_normalize)) && config.data_groups.length);
|
|
3993
|
+
},
|
|
3994
|
+
/**
|
|
3995
|
+
* Check if stack normalization should be applied per group
|
|
3996
|
+
* @returns {boolean}
|
|
3997
|
+
* @private
|
|
3998
|
+
*/
|
|
3999
|
+
isStackNormalizedPerGroup() {
|
|
4000
|
+
var _a;
|
|
4001
|
+
const { config } = this;
|
|
4002
|
+
return !!(isObjectType(config.data_stack_normalize) && ((_a = config.data_stack_normalize) == null ? void 0 : _a.perGroup) && config.data_groups.length);
|
|
3869
4003
|
},
|
|
3870
4004
|
/**
|
|
3871
4005
|
* Check if given id is grouped data or has grouped data
|
|
@@ -3877,6 +4011,19 @@ function setXS(ids, data, params) {
|
|
|
3877
4011
|
const groups = this.config.data_groups;
|
|
3878
4012
|
return id ? groups.some((v) => v.indexOf(id) >= 0 && v.length > 1) : groups.length > 0;
|
|
3879
4013
|
},
|
|
4014
|
+
/**
|
|
4015
|
+
* Check if the given axis has any grouped data
|
|
4016
|
+
* @param {string} axisId Axis ID (e.g., "y", "y2")
|
|
4017
|
+
* @returns {boolean} true if axis has grouped data
|
|
4018
|
+
* @private
|
|
4019
|
+
*/
|
|
4020
|
+
hasAxisGroupedData(axisId) {
|
|
4021
|
+
const $$ = this;
|
|
4022
|
+
const { axis } = $$;
|
|
4023
|
+
const targets = $$.data.targets;
|
|
4024
|
+
const axisDataIds = targets.filter((t) => axis.getId(t.id) === axisId).map((t) => t.id);
|
|
4025
|
+
return axisDataIds.some((id) => $$.isGrouped(id));
|
|
4026
|
+
},
|
|
3880
4027
|
getXKey(id) {
|
|
3881
4028
|
const $$ = this;
|
|
3882
4029
|
const { config } = $$;
|
|
@@ -4068,16 +4215,27 @@ function setXS(ids, data, params) {
|
|
|
4068
4215
|
},
|
|
4069
4216
|
/**
|
|
4070
4217
|
* Get sum of data per index
|
|
4218
|
+
* @param {string} targetId Target ID to get total for (only for normalized stack per group)
|
|
4071
4219
|
* @private
|
|
4072
4220
|
* @returns {Array}
|
|
4073
4221
|
*/
|
|
4074
|
-
getTotalPerIndex() {
|
|
4222
|
+
getTotalPerIndex(targetId) {
|
|
4075
4223
|
const $$ = this;
|
|
4076
|
-
const
|
|
4224
|
+
const { config } = $$;
|
|
4225
|
+
const cacheKey = targetId ? `${KEY.dataTotalPerIndex}-${targetId}` : KEY.dataTotalPerIndex;
|
|
4077
4226
|
let sum = $$.cache.get(cacheKey);
|
|
4078
4227
|
if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
|
|
4079
4228
|
sum = [];
|
|
4080
|
-
|
|
4229
|
+
let { targets } = $$.data;
|
|
4230
|
+
if ($$.isStackNormalizedPerGroup() && targetId) {
|
|
4231
|
+
const group = config.data_groups.find((g) => g.indexOf(targetId) >= 0);
|
|
4232
|
+
if (group) {
|
|
4233
|
+
targets = targets.filter((t) => group.indexOf(t.id) >= 0);
|
|
4234
|
+
} else {
|
|
4235
|
+
return null;
|
|
4236
|
+
}
|
|
4237
|
+
}
|
|
4238
|
+
targets.forEach((row) => {
|
|
4081
4239
|
row.values.forEach((v, i) => {
|
|
4082
4240
|
if (!sum[i]) {
|
|
4083
4241
|
sum[i] = 0;
|
|
@@ -4085,6 +4243,7 @@ function setXS(ids, data, params) {
|
|
|
4085
4243
|
sum[i] += ~~v.value;
|
|
4086
4244
|
});
|
|
4087
4245
|
});
|
|
4246
|
+
$$.cache.add(cacheKey, sum);
|
|
4088
4247
|
}
|
|
4089
4248
|
return sum;
|
|
4090
4249
|
},
|
|
@@ -4100,7 +4259,10 @@ function setXS(ids, data, params) {
|
|
|
4100
4259
|
let total = $$.cache.get(cacheKey);
|
|
4101
4260
|
if (!isNumber(total)) {
|
|
4102
4261
|
total = $$.data.targets.reduce((acc, t) => {
|
|
4103
|
-
return acc + t.values.reduce((sum, v) =>
|
|
4262
|
+
return acc + t.values.reduce((sum, v) => {
|
|
4263
|
+
var _a;
|
|
4264
|
+
return sum + ((_a = v.value) != null ? _a : 0);
|
|
4265
|
+
}, 0);
|
|
4104
4266
|
}, 0);
|
|
4105
4267
|
$$.cache.add(cacheKey, total);
|
|
4106
4268
|
}
|
|
@@ -4180,7 +4342,23 @@ function setXS(ids, data, params) {
|
|
|
4180
4342
|
},
|
|
4181
4343
|
filterTargetsToShow(targets) {
|
|
4182
4344
|
const $$ = this;
|
|
4183
|
-
|
|
4345
|
+
if (!targets) {
|
|
4346
|
+
const { cache, data, state } = $$;
|
|
4347
|
+
const cacheKey = KEY.filteredTargets;
|
|
4348
|
+
const visibilityChecksum = state.hiddenTargetIds.join(",");
|
|
4349
|
+
const storedChecksum = cache.get(KEY.visibilityChecksum);
|
|
4350
|
+
if (visibilityChecksum !== storedChecksum) {
|
|
4351
|
+
cache.remove(cacheKey);
|
|
4352
|
+
cache.add(KEY.visibilityChecksum, visibilityChecksum);
|
|
4353
|
+
}
|
|
4354
|
+
if (cache.has(cacheKey)) {
|
|
4355
|
+
return cache.get(cacheKey);
|
|
4356
|
+
}
|
|
4357
|
+
const filtered = data.targets.filter((t) => $$.isTargetToShow(t.id));
|
|
4358
|
+
cache.add(cacheKey, filtered);
|
|
4359
|
+
return filtered;
|
|
4360
|
+
}
|
|
4361
|
+
return targets.filter((t) => $$.isTargetToShow(t.id));
|
|
4184
4362
|
},
|
|
4185
4363
|
mapTargetsToUniqueXs(targets) {
|
|
4186
4364
|
const $$ = this;
|
|
@@ -4195,7 +4373,7 @@ function setXS(ids, data, params) {
|
|
|
4195
4373
|
return sortValue(xs);
|
|
4196
4374
|
},
|
|
4197
4375
|
/**
|
|
4198
|
-
* Add to
|
|
4376
|
+
* Add to thetarget Ids
|
|
4199
4377
|
* @param {string} type State's prop name
|
|
4200
4378
|
* @param {Array|string} targetIds Target ids array
|
|
4201
4379
|
* @private
|
|
@@ -4239,6 +4417,7 @@ function setXS(ids, data, params) {
|
|
|
4239
4417
|
const ys = {};
|
|
4240
4418
|
const isMultipleX = $$.isMultipleX();
|
|
4241
4419
|
const xs = isMultipleX ? $$.mapTargetsToUniqueXs(targets).map((v) => isString(v) ? v : +v) : null;
|
|
4420
|
+
const xIndexMap = xs ? new Map(xs.map((x, i) => [x, i])) : null;
|
|
4242
4421
|
targets.forEach((t) => {
|
|
4243
4422
|
const data = [];
|
|
4244
4423
|
t.values.filter(({ value }) => isValue(value) || value === null).forEach((v) => {
|
|
@@ -4253,8 +4432,12 @@ function setXS(ids, data, params) {
|
|
|
4253
4432
|
} else if ($$.isBubbleZType(v)) {
|
|
4254
4433
|
data.push(hasAxis && $$.getBubbleZData(value, "y"));
|
|
4255
4434
|
} else {
|
|
4256
|
-
if (isMultipleX) {
|
|
4257
|
-
|
|
4435
|
+
if (isMultipleX && xIndexMap) {
|
|
4436
|
+
const xKey = isString(v.x) ? v.x : +v.x;
|
|
4437
|
+
const index = xIndexMap.get(xKey);
|
|
4438
|
+
if (index !== void 0) {
|
|
4439
|
+
data[index] = value;
|
|
4440
|
+
}
|
|
4258
4441
|
} else {
|
|
4259
4442
|
data.push(value);
|
|
4260
4443
|
}
|
|
@@ -4293,7 +4476,7 @@ function setXS(ids, data, params) {
|
|
|
4293
4476
|
/**
|
|
4294
4477
|
* Get data.order compare function
|
|
4295
4478
|
* @param {boolean} isReversed for Arc & Treemap type sort order needs to be reversed
|
|
4296
|
-
* @returns {
|
|
4479
|
+
* @returns {function} compare function
|
|
4297
4480
|
* @private
|
|
4298
4481
|
*/
|
|
4299
4482
|
getSortCompareFn(isReversed = false) {
|
|
@@ -4575,12 +4758,27 @@ function setXS(ids, data, params) {
|
|
|
4575
4758
|
}
|
|
4576
4759
|
} else if (type === "index") {
|
|
4577
4760
|
const dataValues = api.data.values.bind(api);
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4761
|
+
const { hiddenTargetIds } = state;
|
|
4762
|
+
let total = this.getTotalPerIndex(
|
|
4763
|
+
$$.isStackNormalizedPerGroup() ? d.id : void 0
|
|
4764
|
+
);
|
|
4765
|
+
if (total === null) {
|
|
4766
|
+
return ratio;
|
|
4767
|
+
}
|
|
4768
|
+
if (hiddenTargetIds.length) {
|
|
4769
|
+
let hiddenIds = hiddenTargetIds;
|
|
4770
|
+
if ($$.isStackNormalizedPerGroup() && d.id) {
|
|
4771
|
+
const group = config.data_groups.find((g) => g.indexOf(d.id) >= 0);
|
|
4772
|
+
if (group) {
|
|
4773
|
+
hiddenIds = hiddenIds.filter((id) => group.indexOf(id) >= 0);
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
if (hiddenIds.length) {
|
|
4777
|
+
let hiddenSum = dataValues(hiddenIds, false);
|
|
4778
|
+
if (hiddenSum.length) {
|
|
4779
|
+
hiddenSum = hiddenSum.reduce((acc, curr) => acc.map((v, i) => ~~v + curr[i]));
|
|
4780
|
+
total = total.map((v, i) => v - hiddenSum[i]);
|
|
4781
|
+
}
|
|
4584
4782
|
}
|
|
4585
4783
|
}
|
|
4586
4784
|
const divisor = total[d.index];
|
|
@@ -4758,8 +4956,6 @@ function callDone(fn, resizeAfter = false) {
|
|
|
4758
4956
|
done();
|
|
4759
4957
|
return;
|
|
4760
4958
|
}
|
|
4761
|
-
const targets = $el.svg.selectAll(targetIds.map((id) => $$.selectorTarget(id)));
|
|
4762
|
-
$T(targets).style("opacity", "0").remove().call(endall, done);
|
|
4763
4959
|
targetIds.forEach((id) => {
|
|
4764
4960
|
var _a2;
|
|
4765
4961
|
const suffixId = $$.getTargetSelectorSuffix(id);
|
|
@@ -4773,6 +4969,8 @@ function callDone(fn, resizeAfter = false) {
|
|
|
4773
4969
|
state.hasFunnel && $$.updateFunnel($$.data.targets);
|
|
4774
4970
|
state.hasTreemap && $$.updateTargetsForTreemap($$.data.targets);
|
|
4775
4971
|
$$.updateTypesElements();
|
|
4972
|
+
const targets = $el.svg.selectAll(targetIds.map((id) => $$.selectorTarget(id)));
|
|
4973
|
+
$T(targets).style("opacity", "0").remove().call(endall, done);
|
|
4776
4974
|
}
|
|
4777
4975
|
});
|
|
4778
4976
|
|
|
@@ -4877,7 +5075,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
|
|
|
4877
5075
|
},
|
|
4878
5076
|
/**
|
|
4879
5077
|
* Return draggable selection function
|
|
4880
|
-
* @returns {
|
|
5078
|
+
* @returns {function}
|
|
4881
5079
|
* @private
|
|
4882
5080
|
*/
|
|
4883
5081
|
getDraggableSelection() {
|
|
@@ -5119,7 +5317,7 @@ var external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_ = __webp
|
|
|
5119
5317
|
|
|
5120
5318
|
|
|
5121
5319
|
|
|
5122
|
-
const
|
|
5320
|
+
const _colorizePattern = (pattern, color, id) => {
|
|
5123
5321
|
const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(pattern.cloneNode(true));
|
|
5124
5322
|
node.attr("id", id).insert("rect", ":first-child").attr("width", node.attr("width")).attr("height", node.attr("height")).style("fill", color);
|
|
5125
5323
|
return {
|
|
@@ -5127,7 +5325,7 @@ const colorizePattern = (pattern, color, id) => {
|
|
|
5127
5325
|
node: node.node()
|
|
5128
5326
|
};
|
|
5129
5327
|
};
|
|
5130
|
-
function
|
|
5328
|
+
function _getColorFromCss(element) {
|
|
5131
5329
|
const cacheKey = KEY.colorPattern;
|
|
5132
5330
|
const { body } = browser_doc;
|
|
5133
5331
|
let pattern = body[cacheKey];
|
|
@@ -5159,14 +5357,15 @@ const schemeCategory10 = [
|
|
|
5159
5357
|
const $$ = this;
|
|
5160
5358
|
const { $el, config } = $$;
|
|
5161
5359
|
const ids = [];
|
|
5162
|
-
|
|
5360
|
+
const hasGradient = config.area_linearGradient || config.bar_linearGradient || config.point_radialGradient;
|
|
5361
|
+
let pattern = notEmpty(config.color_pattern) ? config.color_pattern : (0,external_commonjs_d3_scale_commonjs2_d3_scale_amd_d3_scale_root_d3_.scaleOrdinal)(_getColorFromCss($el.chart) || schemeCategory10).range();
|
|
5163
5362
|
const originalColorPattern = pattern;
|
|
5164
5363
|
if (isFunction(config.color_tiles)) {
|
|
5165
5364
|
const tiles = config.color_tiles.bind($$.api)();
|
|
5166
5365
|
const colorizedPatterns = pattern.map((p, index) => {
|
|
5167
5366
|
const color = p.replace(/[#\(\)\s,]/g, "");
|
|
5168
5367
|
const id = `${$$.state.datetimeId}-pattern-${color}-${index}`;
|
|
5169
|
-
return
|
|
5368
|
+
return _colorizePattern(tiles[index % tiles.length], p, id);
|
|
5170
5369
|
});
|
|
5171
5370
|
pattern = colorizedPatterns.map((p) => `url(#${p.id})`);
|
|
5172
5371
|
$$.patterns = colorizedPatterns;
|
|
@@ -5189,7 +5388,18 @@ const schemeCategory10 = [
|
|
|
5189
5388
|
color = isLine ? originalColorPattern[ids.indexOf(id) % originalColorPattern.length] : pattern[ids.indexOf(id) % pattern.length];
|
|
5190
5389
|
colors[id] = color;
|
|
5191
5390
|
}
|
|
5192
|
-
|
|
5391
|
+
color = isFunction(callback) ? callback.call($$.api, color, d) : color;
|
|
5392
|
+
if (hasGradient) {
|
|
5393
|
+
const stop = $$.$el.defs.selectAll(
|
|
5394
|
+
`[id$='-gradient${$$.getTargetSelectorSuffix(id)}'] stop`
|
|
5395
|
+
);
|
|
5396
|
+
let hasSameColor;
|
|
5397
|
+
stop.each(function(d2, i) {
|
|
5398
|
+
hasSameColor = i === 0 ? this.style.stopColor : this.style.stopColor === hasSameColor;
|
|
5399
|
+
});
|
|
5400
|
+
hasSameColor === true && stop.attr("stop-color", color);
|
|
5401
|
+
}
|
|
5402
|
+
return color;
|
|
5193
5403
|
};
|
|
5194
5404
|
},
|
|
5195
5405
|
generateLevelColor() {
|
|
@@ -5214,7 +5424,7 @@ const schemeCategory10 = [
|
|
|
5214
5424
|
},
|
|
5215
5425
|
/**
|
|
5216
5426
|
* Append data backgound color filter definition
|
|
5217
|
-
* @param {string|object|
|
|
5427
|
+
* @param {string|object|function} color Color string, object, or function
|
|
5218
5428
|
* @param {object} attr filter attribute
|
|
5219
5429
|
* @private
|
|
5220
5430
|
*/
|
|
@@ -5338,20 +5548,22 @@ const schemeCategory10 = [
|
|
|
5338
5548
|
const isMin = type === "min";
|
|
5339
5549
|
const dataGroups = config.data_groups;
|
|
5340
5550
|
const ids = $$.mapToIds(targets);
|
|
5551
|
+
const idsSet = toSet(ids);
|
|
5341
5552
|
const ys = $$.getValuesAsIdKeyed(targets);
|
|
5342
5553
|
if (dataGroups.length > 0) {
|
|
5343
5554
|
const hasValue = $$[`has${isMin ? "Negative" : "Positive"}ValueInTargets`](targets);
|
|
5555
|
+
const axisIdMap = new Map(ids.map((id) => [id, axis.getId(id)]));
|
|
5344
5556
|
dataGroups.forEach((groupIds) => {
|
|
5345
|
-
const idsInGroup = groupIds.filter((v) =>
|
|
5557
|
+
const idsInGroup = groupIds.filter((v) => idsSet.has(v));
|
|
5346
5558
|
if (idsInGroup.length) {
|
|
5347
5559
|
const baseId = idsInGroup[0];
|
|
5348
|
-
const baseAxisId =
|
|
5560
|
+
const baseAxisId = axisIdMap.get(baseId);
|
|
5349
5561
|
if (hasValue && ys[baseId]) {
|
|
5350
5562
|
ys[baseId] = ys[baseId].map((v) => (isMin ? v < 0 : v > 0) ? v : 0);
|
|
5351
5563
|
}
|
|
5352
5564
|
idsInGroup.filter((v, i) => i > 0).forEach((id) => {
|
|
5353
5565
|
if (ys[id]) {
|
|
5354
|
-
const axisId =
|
|
5566
|
+
const axisId = axisIdMap.get(id);
|
|
5355
5567
|
ys[id].forEach((v, i) => {
|
|
5356
5568
|
const val = +v;
|
|
5357
5569
|
const meetCondition = isMin ? val > 0 : val < 0;
|
|
@@ -5381,7 +5593,11 @@ const schemeCategory10 = [
|
|
|
5381
5593
|
const { axis, config, scale } = $$;
|
|
5382
5594
|
const pfx = `axis_${axisId}`;
|
|
5383
5595
|
if ($$.isStackNormalized()) {
|
|
5384
|
-
|
|
5596
|
+
const axisDataIds = targets.filter((t) => axis.getId(t.id) === axisId).map((t) => t.id);
|
|
5597
|
+
const hasGroupedData = axisDataIds.some((id) => $$.isGrouped(id));
|
|
5598
|
+
if (hasGroupedData) {
|
|
5599
|
+
return [0, 100];
|
|
5600
|
+
}
|
|
5385
5601
|
}
|
|
5386
5602
|
const isLog = (scale == null ? void 0 : scale[axisId]) && scale[axisId].type === "log";
|
|
5387
5603
|
const targetsByAxisId = targets.filter((t) => axis.getId(t.id) === axisId);
|
|
@@ -5684,7 +5900,7 @@ const schemeCategory10 = [
|
|
|
5684
5900
|
|
|
5685
5901
|
;// ./src/ChartInternal/internals/format.ts
|
|
5686
5902
|
|
|
5687
|
-
function
|
|
5903
|
+
function _getFormat($$, typeValue, v) {
|
|
5688
5904
|
const { config } = $$;
|
|
5689
5905
|
const type = `axis_${typeValue}_tick_format`;
|
|
5690
5906
|
const format = config[type] ? config[type] : $$.defaultValueFormat;
|
|
@@ -5692,14 +5908,14 @@ function getFormat($$, typeValue, v) {
|
|
|
5692
5908
|
}
|
|
5693
5909
|
/* harmony default export */ var format = ({
|
|
5694
5910
|
yFormat(v) {
|
|
5695
|
-
return
|
|
5911
|
+
return _getFormat(this, "y", v);
|
|
5696
5912
|
},
|
|
5697
5913
|
y2Format(v) {
|
|
5698
|
-
return
|
|
5914
|
+
return _getFormat(this, "y2", v);
|
|
5699
5915
|
},
|
|
5700
5916
|
/**
|
|
5701
5917
|
* Get default value format function
|
|
5702
|
-
* @returns {
|
|
5918
|
+
* @returns {function} formatter function
|
|
5703
5919
|
* @private
|
|
5704
5920
|
*/
|
|
5705
5921
|
getDefaultValueFormat() {
|
|
@@ -5753,13 +5969,13 @@ function getFormat($$, typeValue, v) {
|
|
|
5753
5969
|
|
|
5754
5970
|
|
|
5755
5971
|
|
|
5756
|
-
function
|
|
5972
|
+
function _getLegendColor(id) {
|
|
5757
5973
|
const $$ = this;
|
|
5758
5974
|
const data = $$.getDataById(id);
|
|
5759
5975
|
const color = $$.levelColor ? $$.levelColor(data.values[0].value) : $$.color(data);
|
|
5760
5976
|
return color;
|
|
5761
5977
|
}
|
|
5762
|
-
function
|
|
5978
|
+
function _getFormattedText(id, formatted = true) {
|
|
5763
5979
|
var _a;
|
|
5764
5980
|
const { config } = this;
|
|
5765
5981
|
let text = (_a = config.data_names[id]) != null ? _a : id;
|
|
@@ -5768,6 +5984,21 @@ function getFormattedText(id, formatted = true) {
|
|
|
5768
5984
|
}
|
|
5769
5985
|
return text;
|
|
5770
5986
|
}
|
|
5987
|
+
function _buildLegendItemMap($$, legendItems) {
|
|
5988
|
+
if (!legendItems || legendItems.empty()) {
|
|
5989
|
+
return;
|
|
5990
|
+
}
|
|
5991
|
+
const items = [];
|
|
5992
|
+
legendItems.each(function(id) {
|
|
5993
|
+
items.push({ id, node: this });
|
|
5994
|
+
});
|
|
5995
|
+
const itemMap = toMap(
|
|
5996
|
+
items,
|
|
5997
|
+
(item) => item.id,
|
|
5998
|
+
(item) => item.node
|
|
5999
|
+
);
|
|
6000
|
+
$$.cache.add(KEY.legendItemMap, itemMap);
|
|
6001
|
+
}
|
|
5771
6002
|
/* harmony default export */ var internals_legend = ({
|
|
5772
6003
|
/**
|
|
5773
6004
|
* Initialize the legend.
|
|
@@ -5926,9 +6157,13 @@ function getFormattedText(id, formatted = true) {
|
|
|
5926
6157
|
* @private
|
|
5927
6158
|
*/
|
|
5928
6159
|
updateLegendItemColor(id, color) {
|
|
5929
|
-
const
|
|
6160
|
+
const $$ = this;
|
|
6161
|
+
const { legend } = $$.$el;
|
|
5930
6162
|
if (legend) {
|
|
5931
|
-
|
|
6163
|
+
const legendItem = $$.getLegendItemById(id);
|
|
6164
|
+
if (legendItem) {
|
|
6165
|
+
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(legendItem).select("line").style("stroke", color);
|
|
6166
|
+
}
|
|
5932
6167
|
}
|
|
5933
6168
|
},
|
|
5934
6169
|
/**
|
|
@@ -6129,6 +6364,24 @@ function getFormattedText(id, formatted = true) {
|
|
|
6129
6364
|
} : null);
|
|
6130
6365
|
!item.empty() && item.on("click mouseout mouseover") && item.style("cursor", $$.getStylePropValue("pointer"));
|
|
6131
6366
|
}
|
|
6367
|
+
_buildLegendItemMap($$, item);
|
|
6368
|
+
},
|
|
6369
|
+
/**
|
|
6370
|
+
* Get legend item node by ID using cached Map for O(1) lookup
|
|
6371
|
+
* Falls back to D3 selection if map is not available
|
|
6372
|
+
* @param {string} id Data ID
|
|
6373
|
+
* @returns {HTMLElement | null} Legend item node
|
|
6374
|
+
* @private
|
|
6375
|
+
*/
|
|
6376
|
+
getLegendItemById(id) {
|
|
6377
|
+
var _a;
|
|
6378
|
+
const $$ = this;
|
|
6379
|
+
const itemMap = $$.cache.get(KEY.legendItemMap);
|
|
6380
|
+
if (itemMap && itemMap instanceof Map) {
|
|
6381
|
+
return itemMap.get(id) || null;
|
|
6382
|
+
}
|
|
6383
|
+
const item = (_a = $$.$el.legend) == null ? void 0 : _a.selectAll(`.${$LEGEND.legendItem}`).filter((d) => d === id);
|
|
6384
|
+
return (item == null ? void 0 : item.node()) || null;
|
|
6132
6385
|
},
|
|
6133
6386
|
/**
|
|
6134
6387
|
* Update the legend
|
|
@@ -6202,9 +6455,9 @@ function getFormattedText(id, formatted = true) {
|
|
|
6202
6455
|
background = legend.insert("g", `.${$LEGEND.legendItem}`).attr("class", $LEGEND.legendBackground).append("rect");
|
|
6203
6456
|
}
|
|
6204
6457
|
if (config.legend_tooltip) {
|
|
6205
|
-
legend.selectAll("title").data(targetIdz).text((id) =>
|
|
6458
|
+
legend.selectAll("title").data(targetIdz).text((id) => _getFormattedText.bind($$)(id, false));
|
|
6206
6459
|
}
|
|
6207
|
-
const texts = legend.selectAll("text").data(targetIdz).text((id) =>
|
|
6460
|
+
const texts = legend.selectAll("text").data(targetIdz).text((id) => _getFormattedText.bind($$)(id)).each(function(id, i) {
|
|
6208
6461
|
updatePositions(this, id, i);
|
|
6209
6462
|
});
|
|
6210
6463
|
$T(texts, withTransition).attr("x", posFn.xText).attr("y", posFn.yText);
|
|
@@ -6223,7 +6476,7 @@ function getFormattedText(id, formatted = true) {
|
|
|
6223
6476
|
* @param {Array} targetIdz Data ids
|
|
6224
6477
|
* @param {object} dimension Dimension object
|
|
6225
6478
|
* @param {object} sizes Size object
|
|
6226
|
-
* @returns {
|
|
6479
|
+
* @returns {function} Update position function
|
|
6227
6480
|
* @private
|
|
6228
6481
|
*/
|
|
6229
6482
|
getUpdateLegendPositions(targetIdz, dimension, sizes) {
|
|
@@ -6297,7 +6550,7 @@ function getFormattedText(id, formatted = true) {
|
|
|
6297
6550
|
* Generate legend item elements
|
|
6298
6551
|
* @param {Array} targetIdz Data ids
|
|
6299
6552
|
* @param {object} itemTileSize Item tile size {width, height}
|
|
6300
|
-
* @param {
|
|
6553
|
+
* @param {function} updatePositions Update position function
|
|
6301
6554
|
* @param {object} posFn Position functions
|
|
6302
6555
|
* @private
|
|
6303
6556
|
*/
|
|
@@ -6315,14 +6568,14 @@ function getFormattedText(id, formatted = true) {
|
|
|
6315
6568
|
if (config.legend_tooltip) {
|
|
6316
6569
|
l.append("title").text((id) => id);
|
|
6317
6570
|
}
|
|
6318
|
-
l.append("text").text((id) =>
|
|
6571
|
+
l.append("text").text((id) => _getFormattedText.bind($$)(id)).each(function(id, i) {
|
|
6319
6572
|
updatePositions(this, id, i);
|
|
6320
6573
|
}).style("pointer-events", $$.getStylePropValue("none")).attr("x", isLegendRightOrInset ? posFn.xText : pos).attr("y", isLegendRightOrInset ? pos : posFn.yText);
|
|
6321
6574
|
l.append("rect").attr("class", $LEGEND.legendItemEvent).style("fill-opacity", $$.getStylePropValue("0")).attr("x", isLegendRightOrInset ? posFn.xRect : pos).attr("y", isLegendRightOrInset ? pos : posFn.yRect);
|
|
6322
6575
|
if (usePoint) {
|
|
6323
6576
|
const ids = [];
|
|
6577
|
+
const pattern = $$.getValidPointPattern();
|
|
6324
6578
|
l.append((d) => {
|
|
6325
|
-
const pattern = notEmpty(config.point_pattern) ? config.point_pattern : [config.point_type];
|
|
6326
6579
|
ids.indexOf(d) === -1 && ids.push(d);
|
|
6327
6580
|
let point = pattern[ids.indexOf(d) % pattern.length];
|
|
6328
6581
|
if (point === "rectangle") {
|
|
@@ -6332,16 +6585,16 @@ function getFormattedText(id, formatted = true) {
|
|
|
6332
6585
|
external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.svg,
|
|
6333
6586
|
"hasValidPointType" in $$ && $$.hasValidPointType(point) ? point : "use"
|
|
6334
6587
|
);
|
|
6335
|
-
}).attr("class", $LEGEND.legendItemPoint).style("fill",
|
|
6588
|
+
}).attr("class", $LEGEND.legendItemPoint).style("fill", _getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).attr("href", (data, idx, selection) => {
|
|
6336
6589
|
const node = selection[idx];
|
|
6337
6590
|
const nodeName = node.nodeName.toLowerCase();
|
|
6338
6591
|
const id = $$.getTargetSelectorSuffix(data);
|
|
6339
6592
|
return nodeName === "use" ? `#${state.datetimeId}-point${id}` : void 0;
|
|
6340
6593
|
});
|
|
6341
6594
|
} else {
|
|
6342
|
-
l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke",
|
|
6595
|
+
l.append(isRectangle ? "line" : legendType).attr("class", $LEGEND.legendItemTile).style("stroke", _getLegendColor.bind($$)).style("pointer-events", $$.getStylePropValue("none")).call((selection) => {
|
|
6343
6596
|
if (legendType === "circle") {
|
|
6344
|
-
selection.attr("r", legendItemR).style("fill",
|
|
6597
|
+
selection.attr("r", legendItemR).style("fill", _getLegendColor.bind($$)).attr("cx", isLegendRightOrInset ? posFn.x2Tile : pos).attr("cy", isLegendRightOrInset ? pos : posFn.yTile);
|
|
6345
6598
|
} else if (isRectangle) {
|
|
6346
6599
|
selection.attr("stroke-width", itemTileSize.height).attr("x1", isLegendRightOrInset ? posFn.x1Tile : pos).attr("y1", isLegendRightOrInset ? pos : posFn.yTile).attr("x2", isLegendRightOrInset ? posFn.x2Tile : pos).attr("y2", isLegendRightOrInset ? pos : posFn.yTile);
|
|
6347
6600
|
}
|
|
@@ -6390,7 +6643,7 @@ function getFormattedText(id, formatted = true) {
|
|
|
6390
6643
|
});
|
|
6391
6644
|
} else {
|
|
6392
6645
|
const tiles = legend.selectAll(`.${$LEGEND.legendItemTile}`).data(targetIdz);
|
|
6393
|
-
$T(tiles, withTransition).style("stroke",
|
|
6646
|
+
$T(tiles, withTransition).style("stroke", _getLegendColor.bind($$)).call((selection) => {
|
|
6394
6647
|
if (legendType === "circle") {
|
|
6395
6648
|
selection.attr("cx", (d) => {
|
|
6396
6649
|
const x2 = posFn.x2Tile(d);
|
|
@@ -6592,8 +6845,8 @@ function getScale(type = "linear", min, max) {
|
|
|
6592
6845
|
* @param {number} min Min range value
|
|
6593
6846
|
* @param {number} max Max range value
|
|
6594
6847
|
* @param {Array} domain Domain value
|
|
6595
|
-
* @param {
|
|
6596
|
-
* @returns {
|
|
6848
|
+
* @param {function} offset The offset getter to be sum
|
|
6849
|
+
* @returns {function} scale
|
|
6597
6850
|
* @private
|
|
6598
6851
|
*/
|
|
6599
6852
|
getXScale(min, max, domain, offset) {
|
|
@@ -6610,7 +6863,7 @@ function getScale(type = "linear", min, max) {
|
|
|
6610
6863
|
* @param {number} min Min value
|
|
6611
6864
|
* @param {number} max Max value
|
|
6612
6865
|
* @param {Array} domain Domain value
|
|
6613
|
-
* @returns {
|
|
6866
|
+
* @returns {function} Scale function
|
|
6614
6867
|
* @private
|
|
6615
6868
|
*/
|
|
6616
6869
|
getYScale(id, min, max, domain) {
|
|
@@ -6623,7 +6876,7 @@ function getScale(type = "linear", min, max) {
|
|
|
6623
6876
|
* Get y Axis scale
|
|
6624
6877
|
* @param {string} id Axis id
|
|
6625
6878
|
* @param {boolean} isSub Weather is sub Axis
|
|
6626
|
-
* @returns {
|
|
6879
|
+
* @returns {function} Scale function
|
|
6627
6880
|
* @private
|
|
6628
6881
|
*/
|
|
6629
6882
|
getYScaleById(id, isSub = false) {
|
|
@@ -6635,8 +6888,8 @@ function getScale(type = "linear", min, max) {
|
|
|
6635
6888
|
/**
|
|
6636
6889
|
* Get customized x axis scale
|
|
6637
6890
|
* @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
|
|
6638
|
-
* @param {
|
|
6639
|
-
* @returns {
|
|
6891
|
+
* @param {function} offsetValue Offset getter to be sum
|
|
6892
|
+
* @returns {function} Scale function
|
|
6640
6893
|
* @private
|
|
6641
6894
|
*/
|
|
6642
6895
|
getCustomizedXScale(scaleValue, offsetValue) {
|
|
@@ -7086,8 +7339,8 @@ function getScale(type = "linear", min, max) {
|
|
|
7086
7339
|
* @param {boolean} withShape Set shpes' prefix class
|
|
7087
7340
|
* @param {string} selector CSS selector
|
|
7088
7341
|
* @param {Array} props CSS props list
|
|
7089
|
-
* @param {
|
|
7090
|
-
* @returns {
|
|
7342
|
+
* @param {function} propsFn Function to retrieve value or determine for props
|
|
7343
|
+
* @returns {function}
|
|
7091
7344
|
* @private
|
|
7092
7345
|
*/
|
|
7093
7346
|
setCssRule(withShape, selector, props, propsFn) {
|
|
@@ -7109,7 +7362,7 @@ function getScale(type = "linear", min, max) {
|
|
|
7109
7362
|
},
|
|
7110
7363
|
/**
|
|
7111
7364
|
* Get style prop value
|
|
7112
|
-
* @param {
|
|
7365
|
+
* @param {function|string} v Value
|
|
7113
7366
|
* @returns {string|null}
|
|
7114
7367
|
* @private
|
|
7115
7368
|
*/
|
|
@@ -7295,6 +7548,13 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7295
7548
|
$$.$T(image).style("opacity", isShown(textNode) ? null : "0").attr("x", x).attr("y", y);
|
|
7296
7549
|
}
|
|
7297
7550
|
}
|
|
7551
|
+
function batchGetBBox(elements) {
|
|
7552
|
+
return toMap(
|
|
7553
|
+
elements,
|
|
7554
|
+
(element) => element,
|
|
7555
|
+
(element) => getBBox(element)
|
|
7556
|
+
);
|
|
7557
|
+
}
|
|
7298
7558
|
|
|
7299
7559
|
|
|
7300
7560
|
;// ./src/ChartInternal/internals/text.ts
|
|
@@ -7373,7 +7633,7 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7373
7633
|
if (isNumber(value)) {
|
|
7374
7634
|
this.textContent = value;
|
|
7375
7635
|
} else {
|
|
7376
|
-
setTextValue(node, value);
|
|
7636
|
+
setTextValue(node, value, void 0, true);
|
|
7377
7637
|
}
|
|
7378
7638
|
});
|
|
7379
7639
|
updateTextImage.call($$);
|
|
@@ -7404,7 +7664,7 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7404
7664
|
/**
|
|
7405
7665
|
* Update data label text background color
|
|
7406
7666
|
* @param {object} d Data object
|
|
7407
|
-
* @param {object|string|
|
|
7667
|
+
* @param {object|string|function} option option object
|
|
7408
7668
|
* @returns {string|null}
|
|
7409
7669
|
* @private
|
|
7410
7670
|
*/
|
|
@@ -7433,8 +7693,8 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7433
7693
|
},
|
|
7434
7694
|
/**
|
|
7435
7695
|
* Redraw chartText
|
|
7436
|
-
* @param {
|
|
7437
|
-
* @param {
|
|
7696
|
+
* @param {function} getX Positioning function for x
|
|
7697
|
+
* @param {function} getY Positioning function for y
|
|
7438
7698
|
* @param {boolean} forFlow Weather is flow
|
|
7439
7699
|
* @param {boolean} withTransition transition is enabled
|
|
7440
7700
|
* @returns {Array}
|
|
@@ -7448,10 +7708,23 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7448
7708
|
const angle = config.data_labels.rotate;
|
|
7449
7709
|
const anchorString = getRotateAnchor(angle);
|
|
7450
7710
|
const rotateString = angle ? `rotate(${angle})` : "";
|
|
7711
|
+
let bboxCache = /* @__PURE__ */ new Map();
|
|
7712
|
+
if (config.data_labels.centered) {
|
|
7713
|
+
const elementsToMeasure = [];
|
|
7714
|
+
$$.$el.text.each(function(d) {
|
|
7715
|
+
if ($$.isBarType(d) || $$.isTreemapType(d)) {
|
|
7716
|
+
elementsToMeasure.push(this);
|
|
7717
|
+
}
|
|
7718
|
+
});
|
|
7719
|
+
if (elementsToMeasure.length > 0) {
|
|
7720
|
+
bboxCache = batchGetBBox(elementsToMeasure);
|
|
7721
|
+
}
|
|
7722
|
+
}
|
|
7451
7723
|
$$.$el.text.style("fill", $$.getStylePropValue($$.updateTextColor)).attr(
|
|
7452
7724
|
"filter",
|
|
7453
7725
|
(d) => $$.updateTextBGColor.bind($$)(d, config.data_labels_backgroundColors)
|
|
7454
7726
|
).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function(d, i) {
|
|
7727
|
+
const cachedBbox = bboxCache.get(this);
|
|
7455
7728
|
const node = $T(
|
|
7456
7729
|
hasTreemap && this.childElementCount ? this.parentNode : this,
|
|
7457
7730
|
!!(withTransition && (this.getAttribute("x") || this.getAttribute("transform"))),
|
|
@@ -7459,8 +7732,8 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7459
7732
|
);
|
|
7460
7733
|
const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
|
|
7461
7734
|
let pos = {
|
|
7462
|
-
x: getX.bind(this)(d, i),
|
|
7463
|
-
y: getY.bind(this)(d, i)
|
|
7735
|
+
x: getX.bind(this)(d, i, cachedBbox),
|
|
7736
|
+
y: getY.bind(this)(d, i, cachedBbox)
|
|
7464
7737
|
};
|
|
7465
7738
|
if (angle) {
|
|
7466
7739
|
pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
|
|
@@ -7538,17 +7811,18 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7538
7811
|
* @param {Array} points Data points position
|
|
7539
7812
|
* @param {HTMLElement} textElement Data label text element
|
|
7540
7813
|
* @param {string} type 'x' or 'y'
|
|
7814
|
+
* @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
|
|
7541
7815
|
* @returns {number} Position value
|
|
7542
7816
|
* @private
|
|
7543
7817
|
*/
|
|
7544
|
-
getCenteredTextPos(d, points, textElement, type) {
|
|
7818
|
+
getCenteredTextPos(d, points, textElement, type, cachedBbox) {
|
|
7545
7819
|
const $$ = this;
|
|
7546
7820
|
const { config } = $$;
|
|
7547
7821
|
const isRotated = config.axis_rotated;
|
|
7548
7822
|
const isBarType = $$.isBarType(d);
|
|
7549
7823
|
const isTreemapType = $$.isTreemapType(d);
|
|
7550
7824
|
if (config.data_labels.centered && (isBarType || isTreemapType)) {
|
|
7551
|
-
const rect =
|
|
7825
|
+
const rect = cachedBbox || getBBox(textElement);
|
|
7552
7826
|
if (isBarType) {
|
|
7553
7827
|
const isPositive = $$.getRangedData(d, null, "bar") >= 0;
|
|
7554
7828
|
if (isRotated) {
|
|
@@ -7559,7 +7833,10 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7559
7833
|
return isPositive ? h : -h - 2;
|
|
7560
7834
|
}
|
|
7561
7835
|
} else if (isTreemapType) {
|
|
7562
|
-
return type === "x" ? (points[1][0] - points[0][0]) / 2 : (
|
|
7836
|
+
return type === "x" ? (points[1][0] - points[0][0]) / 2 : (
|
|
7837
|
+
// X: Move to horizontal center of rect
|
|
7838
|
+
(points[1][1] - points[0][1]) / 2 - rect.y - rect.height / 2
|
|
7839
|
+
);
|
|
7563
7840
|
}
|
|
7564
7841
|
}
|
|
7565
7842
|
return 0;
|
|
@@ -7569,10 +7846,11 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7569
7846
|
* @param {object} points Data points position
|
|
7570
7847
|
* @param {object} d Data object
|
|
7571
7848
|
* @param {HTMLElement} textElement Data label text element
|
|
7849
|
+
* @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
|
|
7572
7850
|
* @returns {number} x coordinate
|
|
7573
7851
|
* @private
|
|
7574
7852
|
*/
|
|
7575
|
-
getXForText(points, d, textElement) {
|
|
7853
|
+
getXForText(points, d, textElement, cachedBbox) {
|
|
7576
7854
|
var _a;
|
|
7577
7855
|
const $$ = this;
|
|
7578
7856
|
const { config } = $$;
|
|
@@ -7606,7 +7884,7 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7606
7884
|
}
|
|
7607
7885
|
}
|
|
7608
7886
|
if (isRotated || isTreemapType) {
|
|
7609
|
-
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
|
7887
|
+
xPos += $$.getCenteredTextPos(d, points, textElement, "x", cachedBbox);
|
|
7610
7888
|
}
|
|
7611
7889
|
return xPos + getTextPos.call(this, d, "x");
|
|
7612
7890
|
},
|
|
@@ -7615,10 +7893,11 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7615
7893
|
* @param {object} points Data points position
|
|
7616
7894
|
* @param {object} d Data object
|
|
7617
7895
|
* @param {HTMLElement} textElement Data label text element
|
|
7896
|
+
* @param {DOMRect} cachedBbox Optional cached bounding box (from getBBox batching)
|
|
7618
7897
|
* @returns {number} y coordinate
|
|
7619
7898
|
* @private
|
|
7620
7899
|
*/
|
|
7621
|
-
getYForText(points, d, textElement) {
|
|
7900
|
+
getYForText(points, d, textElement, cachedBbox) {
|
|
7622
7901
|
const $$ = this;
|
|
7623
7902
|
const { axis, config, state } = $$;
|
|
7624
7903
|
const isRotated = config.axis_rotated;
|
|
@@ -7671,7 +7950,7 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7671
7950
|
}
|
|
7672
7951
|
}
|
|
7673
7952
|
if (!isRotated || isTreemapType) {
|
|
7674
|
-
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
|
7953
|
+
yPos += $$.getCenteredTextPos(d, points, textElement, "y", cachedBbox);
|
|
7675
7954
|
}
|
|
7676
7955
|
return yPos + getTextPos.call(this, d, "y");
|
|
7677
7956
|
},
|
|
@@ -7715,7 +7994,7 @@ function updateTextImagePos(textNode, pos) {
|
|
|
7715
7994
|
;// ./src/ChartInternal/internals/title.ts
|
|
7716
7995
|
|
|
7717
7996
|
|
|
7718
|
-
function
|
|
7997
|
+
function _getTextXPos(pos = "left", width) {
|
|
7719
7998
|
const isNum = isNumber(width);
|
|
7720
7999
|
let position;
|
|
7721
8000
|
if (pos.indexOf("center") > -1) {
|
|
@@ -7737,7 +8016,7 @@ function getTextXPos(pos = "left", width) {
|
|
|
7737
8016
|
const { config, $el } = $$;
|
|
7738
8017
|
if (config.title_text) {
|
|
7739
8018
|
$el.title = $el.svg.append("g");
|
|
7740
|
-
const text = $el.title.append("text").style("text-anchor",
|
|
8019
|
+
const text = $el.title.append("text").style("text-anchor", _getTextXPos(config.title_position)).attr("class", $TEXT.title);
|
|
7741
8020
|
setTextValue(text, config.title_text, [0.3, 1.5]);
|
|
7742
8021
|
}
|
|
7743
8022
|
},
|
|
@@ -7749,7 +8028,7 @@ function getTextXPos(pos = "left", width) {
|
|
|
7749
8028
|
const $$ = this;
|
|
7750
8029
|
const { config, state: { current }, $el: { title } } = $$;
|
|
7751
8030
|
if (title) {
|
|
7752
|
-
const x =
|
|
8031
|
+
const x = _getTextXPos(config.title_position, current.width);
|
|
7753
8032
|
const y = (config.title_padding.top || 0) + $$.getTextRect($$.$el.title, $TEXT.title).height;
|
|
7754
8033
|
title.attr("transform", `translate(${x}, ${y})`);
|
|
7755
8034
|
}
|
|
@@ -7825,9 +8104,9 @@ function getTextXPos(pos = "left", width) {
|
|
|
7825
8104
|
/**
|
|
7826
8105
|
* Returns the tooltip content(HTML string)
|
|
7827
8106
|
* @param {object} d data
|
|
7828
|
-
* @param {
|
|
7829
|
-
* @param {
|
|
7830
|
-
* @param {
|
|
8107
|
+
* @param {function} defaultTitleFormat Default title format
|
|
8108
|
+
* @param {function} defaultValueFormat Default format for each data value in the tooltip.
|
|
8109
|
+
* @param {function} color Color function
|
|
7831
8110
|
* @returns {string} html
|
|
7832
8111
|
* @private
|
|
7833
8112
|
*/
|
|
@@ -7841,9 +8120,16 @@ function getTextXPos(pos = "left", width) {
|
|
|
7841
8120
|
});
|
|
7842
8121
|
const titleFormat = (...arg) => sanitize((titleFn || defaultTitleFormat)(...arg));
|
|
7843
8122
|
const nameFormat = (...arg) => sanitize((nameFn || ((name) => name))(...arg));
|
|
7844
|
-
const valueFormat = (
|
|
7845
|
-
|
|
7846
|
-
|
|
8123
|
+
const valueFormat = (v, ratio, id, index) => {
|
|
8124
|
+
let fn = valueFn;
|
|
8125
|
+
if (!fn) {
|
|
8126
|
+
if (state.hasTreemap || $$.isStackNormalized() && (!$$.isStackNormalizedPerGroup() || $$.isGrouped(id))) {
|
|
8127
|
+
fn = (v2, ratio2) => `${(ratio2 * 100).toFixed(2)}%`;
|
|
8128
|
+
} else {
|
|
8129
|
+
fn = defaultValueFormat;
|
|
8130
|
+
}
|
|
8131
|
+
}
|
|
8132
|
+
return sanitize(fn(v, ratio, id, index));
|
|
7847
8133
|
};
|
|
7848
8134
|
const order = config.tooltip_order;
|
|
7849
8135
|
const getRowValue = (row2) => $$.axis && $$.isBubbleZType(row2) ? $$.getBubbleZData(row2.value, "z") : $$.getBaseValue(row2);
|
|
@@ -8182,7 +8468,7 @@ function getTextXPos(pos = "left", width) {
|
|
|
8182
8468
|
if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
|
|
8183
8469
|
const selectedData = JSON.parse((_a = tooltip.datum().current) != null ? _a : {});
|
|
8184
8470
|
callFn(config.tooltip_onhide, api, selectedData);
|
|
8185
|
-
tooltip.style("display", "none").
|
|
8471
|
+
tooltip.style("display", "none").datum(null);
|
|
8186
8472
|
callFn(config.tooltip_onhidden, api, selectedData);
|
|
8187
8473
|
}
|
|
8188
8474
|
},
|
|
@@ -8566,7 +8852,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
|
|
|
8566
8852
|
|
|
8567
8853
|
|
|
8568
8854
|
|
|
8569
|
-
|
|
8855
|
+
|
|
8856
|
+
function _getGroupedDataPointsFn(d) {
|
|
8570
8857
|
const $$ = this;
|
|
8571
8858
|
let fn;
|
|
8572
8859
|
if ($$.isLineType(d)) {
|
|
@@ -8624,7 +8911,7 @@ function getGroupedDataPointsFn(d) {
|
|
|
8624
8911
|
* data2 data4 data2 data4
|
|
8625
8912
|
* -------------------------
|
|
8626
8913
|
* 0 1
|
|
8627
|
-
* @param {
|
|
8914
|
+
* @param {function} typeFilter Chart type filter function
|
|
8628
8915
|
* @returns {object} Indices object with its position
|
|
8629
8916
|
*/
|
|
8630
8917
|
getShapeIndices(typeFilter) {
|
|
@@ -8769,7 +9056,7 @@ function getGroupedDataPointsFn(d) {
|
|
|
8769
9056
|
},
|
|
8770
9057
|
/**
|
|
8771
9058
|
* Get Shape's offset data
|
|
8772
|
-
* @param {
|
|
9059
|
+
* @param {function} typeFilter Type filter function
|
|
8773
9060
|
* @returns {object}
|
|
8774
9061
|
* @private
|
|
8775
9062
|
*/
|
|
@@ -8778,6 +9065,12 @@ function getGroupedDataPointsFn(d) {
|
|
|
8778
9065
|
const targets = $$.orderTargets(
|
|
8779
9066
|
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
|
|
8780
9067
|
);
|
|
9068
|
+
const targetIds = targets.map((t) => t.id).join("_");
|
|
9069
|
+
const cacheKey = `${KEY.shapeOffset}_${targetIds}`;
|
|
9070
|
+
const cachedData = $$.cache.get(cacheKey);
|
|
9071
|
+
if (cachedData) {
|
|
9072
|
+
return cachedData;
|
|
9073
|
+
}
|
|
8781
9074
|
const isStackNormalized = $$.isStackNormalized();
|
|
8782
9075
|
const shapeOffsetTargets = targets.map((target) => {
|
|
8783
9076
|
let rowValues = target.values;
|
|
@@ -8802,7 +9095,9 @@ function getGroupedDataPointsFn(d) {
|
|
|
8802
9095
|
out[id] = index;
|
|
8803
9096
|
return out;
|
|
8804
9097
|
}, {});
|
|
8805
|
-
|
|
9098
|
+
const result = { indexMapByTargetId, shapeOffsetTargets };
|
|
9099
|
+
$$.cache.add(cacheKey, result);
|
|
9100
|
+
return result;
|
|
8806
9101
|
},
|
|
8807
9102
|
getShapeOffset(typeFilter, indices, isSub) {
|
|
8808
9103
|
const $$ = this;
|
|
@@ -8856,7 +9151,7 @@ function getGroupedDataPointsFn(d) {
|
|
|
8856
9151
|
const id = d.id;
|
|
8857
9152
|
let points;
|
|
8858
9153
|
if ($$.isGrouped(id)) {
|
|
8859
|
-
points =
|
|
9154
|
+
points = _getGroupedDataPointsFn.bind($$)(d);
|
|
8860
9155
|
}
|
|
8861
9156
|
return points ? points(d, i)[0][1] : $$.getYScaleById(id)($$.getBaseValue(d));
|
|
8862
9157
|
},
|
|
@@ -9270,14 +9565,18 @@ class ChartInternal {
|
|
|
9270
9565
|
if (hasInteraction && state.inputType) {
|
|
9271
9566
|
const isTouch = state.inputType === "touch";
|
|
9272
9567
|
const { onclick, onover, onout } = config;
|
|
9273
|
-
$el.svg.on("click", (onclick == null ? void 0 : onclick.bind($$.api)) || null).on(
|
|
9568
|
+
$el.svg.on("click", (onclick == null ? void 0 : onclick.bind($$.api)) || null).on(
|
|
9569
|
+
isTouch ? "touchstart" : "mouseenter",
|
|
9570
|
+
(onover == null ? void 0 : onover.bind($$.api)) || null,
|
|
9571
|
+
isTouch ? { passive: true } : void 0
|
|
9572
|
+
).on(isTouch ? "touchend" : "mouseleave", (onout == null ? void 0 : onout.bind($$.api)) || null);
|
|
9274
9573
|
}
|
|
9275
9574
|
config.svg_classname && $el.svg.attr("class", config.svg_classname);
|
|
9276
9575
|
const hasColorPatterns = isFunction(config.color_tiles) && $$.patterns;
|
|
9277
9576
|
if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
|
|
9278
9577
|
$el.defs = $el.svg.append("defs");
|
|
9279
9578
|
if (hasAxis) {
|
|
9280
|
-
["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
|
|
9579
|
+
["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
|
|
9281
9580
|
$$.appendClip($el.defs, state.clip[v]);
|
|
9282
9581
|
});
|
|
9283
9582
|
}
|
|
@@ -9647,7 +9946,7 @@ function loadConfig(config) {
|
|
|
9647
9946
|
},
|
|
9648
9947
|
/**
|
|
9649
9948
|
* Force to redraw.
|
|
9650
|
-
* - **NOTE:** When zoom/subchart is used, the zoomed state will be
|
|
9949
|
+
* - **NOTE:** When zoom/subchart is used, the zoomed state will be reset.
|
|
9651
9950
|
* @function flush
|
|
9652
9951
|
* @instance
|
|
9653
9952
|
* @memberof Chart
|
|
@@ -9736,15 +10035,15 @@ function loadConfig(config) {
|
|
|
9736
10035
|
* Get or set config option value.
|
|
9737
10036
|
* - **NOTE**
|
|
9738
10037
|
* - The option key name must be specified as the last level.
|
|
9739
|
-
* -
|
|
10038
|
+
* - When no argument is given, it will return all specified generation options object only. (will exclude any other options not specified at the initialization)
|
|
9740
10039
|
* @function config
|
|
9741
10040
|
* @instance
|
|
9742
10041
|
* @memberof Chart
|
|
9743
10042
|
* @param {string} name The option key name.
|
|
9744
|
-
* @param {
|
|
10043
|
+
* @param {string|number|boolean|object|Array} [value] The value accepted for indicated option.
|
|
9745
10044
|
* @param {boolean} [redraw] Set to redraw with the new option changes.
|
|
9746
|
-
* - **NOTE:** Doesn't guarantee work in all circumstances. It can be applied for limited options only.
|
|
9747
|
-
* @returns {
|
|
10045
|
+
* - **NOTE:** Doesn't guarantee to work in all circumstances. It can be applied for limited options only.
|
|
10046
|
+
* @returns {string|number|boolean|object|Array} The option value or all options object
|
|
9748
10047
|
* @example
|
|
9749
10048
|
*
|
|
9750
10049
|
* // Getter
|
|
@@ -9841,7 +10140,7 @@ extend(api_data_data, {
|
|
|
9841
10140
|
* @function data․values
|
|
9842
10141
|
* @instance
|
|
9843
10142
|
* @memberof Chart
|
|
9844
|
-
* @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be
|
|
10143
|
+
* @param {string|Array|null} targetIds This API returns the values of specified target. If this argument is not given, null will be returned
|
|
9845
10144
|
* @param {boolean} [flat=true] Get flatten values
|
|
9846
10145
|
* @returns {Array} Data values
|
|
9847
10146
|
* @example
|
|
@@ -9887,6 +10186,7 @@ extend(api_data_data, {
|
|
|
9887
10186
|
},
|
|
9888
10187
|
/**
|
|
9889
10188
|
* Get and set colors of the data loaded in the chart.
|
|
10189
|
+
* - **NOTE:** If gradient option is set, the color update will affect only gradient stops have the same color.
|
|
9890
10190
|
* @function data․colors
|
|
9891
10191
|
* @instance
|
|
9892
10192
|
* @memberof Chart
|
|
@@ -10092,7 +10392,7 @@ function renderText(ctx, glyph) {
|
|
|
10092
10392
|
* - Text element's position(especially "transformed") can't be preserved correctly according the page's layout condition.
|
|
10093
10393
|
* - If need to preserve accurate text position, embed the web font data within to the page and set `preserveFontStyle=false`.
|
|
10094
10394
|
* - 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>
|
|
10095
|
-
* @param {
|
|
10395
|
+
* @param {function(string): void} [callback] The callback to be invoked when export is ready.
|
|
10096
10396
|
* @returns {string} dataURI
|
|
10097
10397
|
* @example
|
|
10098
10398
|
* chart.export();
|
|
@@ -10346,7 +10646,7 @@ const legend_legend = {
|
|
|
10346
10646
|
* | categories | Array | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
|
|
10347
10647
|
* | classes | Object | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
|
|
10348
10648
|
* | colors | Object | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
|
|
10349
|
-
* | data |
|
|
10649
|
+
* | data | Object | Data objects to be loaded. Checkout the example. |
|
|
10350
10650
|
* | done | Function | The specified function will be called after data loaded.|
|
|
10351
10651
|
* | headers | string | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
|
|
10352
10652
|
* | 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) |
|
|
@@ -10405,7 +10705,7 @@ const legend_legend = {
|
|
|
10405
10705
|
*
|
|
10406
10706
|
* chart.load({
|
|
10407
10707
|
* columns: [
|
|
10408
|
-
* // when existing chart has `x` value, should provide
|
|
10708
|
+
* // when existing chart has `x` value, should provide corresponding 'x' value.
|
|
10409
10709
|
* // with 'append' option, the 'data1' will have `[36,30,24,37]`.
|
|
10410
10710
|
* ["x", "2021-02-01T08:00:00"],
|
|
10411
10711
|
* ["data1", 37]
|
|
@@ -10495,7 +10795,7 @@ const legend_legend = {
|
|
|
10495
10795
|
* | key | Type | Description |
|
|
10496
10796
|
* | --- | --- | --- |
|
|
10497
10797
|
* | ids | String | Array | Target id data to be unloaded. If not given, all data will be unloaded. |
|
|
10498
|
-
* | done |
|
|
10798
|
+
* | done | Function | Callback after data is unloaded. |
|
|
10499
10799
|
* | 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. |
|
|
10500
10800
|
* @example
|
|
10501
10801
|
* // Unload data2 and data3
|
|
@@ -10652,7 +10952,7 @@ const tooltip_tooltip = {
|
|
|
10652
10952
|
*
|
|
10653
10953
|
* @example
|
|
10654
10954
|
* // show the 2nd x Axis coordinate tooltip
|
|
10655
|
-
* // for Arc(gauge, donut & pie) and radar type,
|
|
10955
|
+
* // for Arc(gauge, donut & pie) and radar type, approach showing tooltip by using "index" number.
|
|
10656
10956
|
* chart.tooltip.show({
|
|
10657
10957
|
* index: 1
|
|
10658
10958
|
* });
|
|
@@ -11016,7 +11316,7 @@ extend(subchart, {
|
|
|
11016
11316
|
}
|
|
11017
11317
|
},
|
|
11018
11318
|
/**
|
|
11019
|
-
* Toggle the
|
|
11319
|
+
* Toggle the visibility of subchart
|
|
11020
11320
|
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
11021
11321
|
* @function subchart․toggle
|
|
11022
11322
|
* @instance
|
|
@@ -11538,9 +11838,6 @@ extend(zoom, {
|
|
|
11538
11838
|
external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.translate(tX, tY).scale(transform.k)
|
|
11539
11839
|
);
|
|
11540
11840
|
}
|
|
11541
|
-
if (!$$.state.xTickOffset) {
|
|
11542
|
-
$$.state.xTickOffset = $$.axis.x.tickOffset();
|
|
11543
|
-
}
|
|
11544
11841
|
scale.zoom = $$.getCustomizedXScale(newScale);
|
|
11545
11842
|
$$.axis.x.scale(scale.zoom);
|
|
11546
11843
|
if (rescale) {
|
|
@@ -11581,7 +11878,6 @@ extend(zoom, {
|
|
|
11581
11878
|
* @private
|
|
11582
11879
|
*/
|
|
11583
11880
|
onZoom(event) {
|
|
11584
|
-
var _a;
|
|
11585
11881
|
const $$ = this;
|
|
11586
11882
|
const { config, scale, state, org } = $$;
|
|
11587
11883
|
const { sourceEvent } = event;
|
|
@@ -11601,19 +11897,24 @@ extend(zoom, {
|
|
|
11601
11897
|
}
|
|
11602
11898
|
$$.zoom.updateTransformScale(transform, config.zoom_type === "wheel" && sourceEvent);
|
|
11603
11899
|
const doTransition = config.transition_duration > 0 && !config.subchart_show && (state.dragging || isUnZoom || !event.sourceEvent);
|
|
11604
|
-
|
|
11605
|
-
|
|
11606
|
-
|
|
11607
|
-
|
|
11608
|
-
|
|
11609
|
-
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
$$.
|
|
11615
|
-
|
|
11616
|
-
|
|
11900
|
+
const useRAF = sourceEvent && isMousemove && config.zoom_type !== "wheel";
|
|
11901
|
+
const executeRedraw = () => {
|
|
11902
|
+
var _a;
|
|
11903
|
+
$$.redraw({
|
|
11904
|
+
withTransition: doTransition,
|
|
11905
|
+
withY: config.zoom_rescale,
|
|
11906
|
+
withSubchart: false,
|
|
11907
|
+
withEventRect: false,
|
|
11908
|
+
withDimension: false
|
|
11909
|
+
});
|
|
11910
|
+
$$.state.cancelClick = isMousemove;
|
|
11911
|
+
!isUnZoom && callFn(
|
|
11912
|
+
config.zoom_onzoom,
|
|
11913
|
+
$$.api,
|
|
11914
|
+
(_a = $$.state.domain) != null ? _a : $$.zoom.getDomain()
|
|
11915
|
+
);
|
|
11916
|
+
};
|
|
11917
|
+
useRAF ? scheduleRAFUpdate($$.state, executeRedraw) : executeRedraw();
|
|
11617
11918
|
},
|
|
11618
11919
|
/**
|
|
11619
11920
|
* 'end' event listener
|
|
@@ -11665,7 +11966,7 @@ extend(zoom, {
|
|
|
11665
11966
|
},
|
|
11666
11967
|
/**
|
|
11667
11968
|
* Set zoom transform to event rect
|
|
11668
|
-
* @param {
|
|
11969
|
+
* @param {function} x x Axis scale function
|
|
11669
11970
|
* @param {Array} domain Domain value to be set
|
|
11670
11971
|
* @private
|
|
11671
11972
|
*/
|
|
@@ -11806,31 +12107,37 @@ extend(zoom, {
|
|
|
11806
12107
|
const maxX = Math.max(sx, mx);
|
|
11807
12108
|
const minY = isSelectionGrouped ? state.margin.top : Math.min(sy, my);
|
|
11808
12109
|
const maxY = isSelectionGrouped ? state.height : Math.max(sy, my);
|
|
11809
|
-
|
|
11810
|
-
|
|
11811
|
-
const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
|
11812
|
-
const isSelected = shape.classed($SELECT.SELECTED);
|
|
11813
|
-
const isIncluded = shape.classed($DRAG.INCLUDED);
|
|
11814
|
-
let isWithin = false;
|
|
11815
|
-
let toggle;
|
|
11816
|
-
if (shape.classed($CIRCLE.circle)) {
|
|
11817
|
-
const x = +shape.attr("cx") * 1;
|
|
11818
|
-
const y = +shape.attr("cy") * 1;
|
|
11819
|
-
toggle = $$.togglePoint;
|
|
11820
|
-
isWithin = minX < x && x < maxX && minY < y && y < maxY;
|
|
11821
|
-
} else if (shape.classed($BAR.bar)) {
|
|
11822
|
-
const { x, y, width, height } = getPathBox(this);
|
|
11823
|
-
toggle = $$.togglePath;
|
|
11824
|
-
isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
|
|
11825
|
-
} else {
|
|
12110
|
+
const executeDrag = () => {
|
|
12111
|
+
if (!$$ || !$$.$el || !$$.$el.main) {
|
|
11826
12112
|
return;
|
|
11827
12113
|
}
|
|
11828
|
-
|
|
11829
|
-
|
|
11830
|
-
shape
|
|
11831
|
-
|
|
11832
|
-
|
|
11833
|
-
|
|
12114
|
+
main.select(`.${$DRAG.dragarea}`).attr("x", minX).attr("y", minY).attr("width", maxX - minX).attr("height", maxY - minY);
|
|
12115
|
+
main.selectAll(`.${$SHAPE.shapes}`).selectAll(`.${$SHAPE.shape}`).filter((d) => isSelectable == null ? void 0 : isSelectable.bind($$.api)(d)).each(function(d, i) {
|
|
12116
|
+
const shape = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
|
12117
|
+
const isSelected = shape.classed($SELECT.SELECTED);
|
|
12118
|
+
const isIncluded = shape.classed($DRAG.INCLUDED);
|
|
12119
|
+
let isWithin = false;
|
|
12120
|
+
let toggle;
|
|
12121
|
+
if (shape.classed($CIRCLE.circle)) {
|
|
12122
|
+
const x = +shape.attr("cx") * 1;
|
|
12123
|
+
const y = +shape.attr("cy") * 1;
|
|
12124
|
+
toggle = $$.togglePoint;
|
|
12125
|
+
isWithin = minX < x && x < maxX && minY < y && y < maxY;
|
|
12126
|
+
} else if (shape.classed($BAR.bar)) {
|
|
12127
|
+
const { x, y, width, height } = getPathBox(this);
|
|
12128
|
+
toggle = $$.togglePath;
|
|
12129
|
+
isWithin = !(maxX < x || x + width < minX) && !(maxY < y || y + height < minY);
|
|
12130
|
+
} else {
|
|
12131
|
+
return;
|
|
12132
|
+
}
|
|
12133
|
+
if (isWithin ^ isIncluded) {
|
|
12134
|
+
shape.classed($DRAG.INCLUDED, !isIncluded);
|
|
12135
|
+
shape.classed($SELECT.SELECTED, !isSelected);
|
|
12136
|
+
toggle.call($$, !isSelected, shape, d, i);
|
|
12137
|
+
}
|
|
12138
|
+
});
|
|
12139
|
+
};
|
|
12140
|
+
scheduleRAFUpdate($$.state, executeDrag);
|
|
11834
12141
|
},
|
|
11835
12142
|
/**
|
|
11836
12143
|
* Called when the drag starts.
|
|
@@ -11975,7 +12282,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11975
12282
|
* Returns the toggle method of the target
|
|
11976
12283
|
* @param {object} that shape
|
|
11977
12284
|
* @param {object} d Data object
|
|
11978
|
-
* @returns {
|
|
12285
|
+
* @returns {function} toggle method
|
|
11979
12286
|
* @private
|
|
11980
12287
|
*/
|
|
11981
12288
|
getToggle(that, d) {
|
|
@@ -12074,7 +12381,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12074
12381
|
* The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
|
|
12075
12382
|
* @name data․selection․isselectable
|
|
12076
12383
|
* @memberof Options
|
|
12077
|
-
* @type {
|
|
12384
|
+
* @type {function}
|
|
12078
12385
|
* @default function() { return true; }
|
|
12079
12386
|
* @example
|
|
12080
12387
|
* data: {
|
|
@@ -12086,7 +12393,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12086
12393
|
data_selection_isselectable: () => true,
|
|
12087
12394
|
/**
|
|
12088
12395
|
* Set multiple data points selection enabled.<br><br>
|
|
12089
|
-
* If this option set true,
|
|
12396
|
+
* 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.
|
|
12090
12397
|
* @name data․selection․multiple
|
|
12091
12398
|
* @memberof Options
|
|
12092
12399
|
* @type {boolean}
|
|
@@ -12119,7 +12426,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12119
12426
|
* Set a callback for on data selection.
|
|
12120
12427
|
* @name data․onselected
|
|
12121
12428
|
* @memberof Options
|
|
12122
|
-
* @type {
|
|
12429
|
+
* @type {function}
|
|
12123
12430
|
* @default function() {}
|
|
12124
12431
|
* @example
|
|
12125
12432
|
* data: {
|
|
@@ -12136,7 +12443,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12136
12443
|
* Set a callback for on data un-selection.
|
|
12137
12444
|
* @name data․onunselected
|
|
12138
12445
|
* @memberof Options
|
|
12139
|
-
* @type {
|
|
12446
|
+
* @type {function}
|
|
12140
12447
|
* @default function() {}
|
|
12141
12448
|
* @example
|
|
12142
12449
|
* data: {
|
|
@@ -12166,11 +12473,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12166
12473
|
* @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
|
|
12167
12474
|
* @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
|
|
12168
12475
|
* @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
|
|
12169
|
-
* @property {
|
|
12476
|
+
* @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.
|
|
12170
12477
|
* @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
|
|
12171
12478
|
* @property {Array} [subchart.init.range] Set initial selection domain range.
|
|
12172
12479
|
* @property {number} [subchart.size.height] Change the height of the subchart.
|
|
12173
|
-
* @property {
|
|
12480
|
+
* @property {function} [subchart.onbrush] Set callback for brush event.<br>
|
|
12174
12481
|
* Specified function receives the current zoomed x domain.
|
|
12175
12482
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Interaction.SubChart)
|
|
12176
12483
|
* @example
|
|
@@ -12239,14 +12546,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12239
12546
|
* @property {Array} [zoom.extent=[1, 10]] Change zoom extent.
|
|
12240
12547
|
* @property {number|Date} [zoom.x.min] Set x Axis minimum zoom range
|
|
12241
12548
|
* @property {number|Date} [zoom.x.max] Set x Axis maximum zoom range
|
|
12242
|
-
* @property {
|
|
12549
|
+
* @property {function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
|
|
12243
12550
|
* Specified function receives the zoom event.
|
|
12244
|
-
* @property {
|
|
12551
|
+
* @property {function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
|
|
12245
12552
|
* Specified function receives the zoomed domain.
|
|
12246
|
-
* @property {
|
|
12553
|
+
* @property {function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
|
|
12247
12554
|
* Specified function receives the zoomed domain.
|
|
12248
12555
|
* @property {boolean|object} [zoom.resetButton=true] Set to display zoom reset button for 'drag' type zoom
|
|
12249
|
-
* @property {
|
|
12556
|
+
* @property {function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
|
|
12250
12557
|
* @property {string} [zoom.resetButton.text='Reset Zoom'] Text value for zoom reset button.
|
|
12251
12558
|
* @see [Demo:zoom](https://naver.github.io/billboard.js/demo/#Interaction.Zoom)
|
|
12252
12559
|
* @see [Demo:drag zoom](https://naver.github.io/billboard.js/demo/#Interaction.DragZoom)
|
|
@@ -12617,7 +12924,7 @@ const axis = {
|
|
|
12617
12924
|
* - If json specified, keys is required as well as data.json.
|
|
12618
12925
|
* - If tab isn't visible(by evaluating `document.hidden`), will not be executed to prevent unnecessary work.
|
|
12619
12926
|
* @example
|
|
12620
|
-
* // 2 data points will be
|
|
12927
|
+
* // 2 data points will be appended to the tail and popped from the head.
|
|
12621
12928
|
* // After that, 4 data points will be appended and no data points will be poppoed.
|
|
12622
12929
|
* chart.flow({
|
|
12623
12930
|
* columns: [
|
|
@@ -13150,7 +13457,7 @@ class AxisRendererHelper {
|
|
|
13150
13457
|
/**
|
|
13151
13458
|
* Get tick transform setter function
|
|
13152
13459
|
* @param {string} id Axis id
|
|
13153
|
-
* @returns {
|
|
13460
|
+
* @returns {(selection: d3Selection, scale) => void} transfrom setter function
|
|
13154
13461
|
* @private
|
|
13155
13462
|
*/
|
|
13156
13463
|
getTickTransformSetter(id) {
|
|
@@ -13871,7 +14178,7 @@ class Axis_Axis {
|
|
|
13871
14178
|
}
|
|
13872
14179
|
tickValues && axis.tickValues(tickValues);
|
|
13873
14180
|
axis.tickFormat(
|
|
13874
|
-
tickFormat || !isX && ($$.isStackNormalized() && ((x) => `${x}%`))
|
|
14181
|
+
tickFormat || !isX && ($$.isStackNormalized() && $$.hasAxisGroupedData(id) && ((x) => `${x}%`))
|
|
13875
14182
|
);
|
|
13876
14183
|
if (isCategory) {
|
|
13877
14184
|
axis.tickCentered(config.axis_x_tick_centered);
|
|
@@ -14499,6 +14806,7 @@ class Axis_Axis {
|
|
|
14499
14806
|
const isPrevented = isBoolean(preventDefault) && preventDefault || false;
|
|
14500
14807
|
const preventThreshold = !isNaN(preventDefault) && preventDefault || null;
|
|
14501
14808
|
let startPx;
|
|
14809
|
+
const passiveOption = !isPrevented && preventThreshold === null;
|
|
14502
14810
|
const preventEvent = (event) => {
|
|
14503
14811
|
const eventType = event.type;
|
|
14504
14812
|
const touch = event.changedTouches[0];
|
|
@@ -14519,7 +14827,7 @@ class Axis_Axis {
|
|
|
14519
14827
|
eventRect.on("touchstart", (event) => {
|
|
14520
14828
|
state.event = event;
|
|
14521
14829
|
$$.updateEventRect();
|
|
14522
|
-
}).on("touchstart.eventRect touchmove.eventRect", (event) => {
|
|
14830
|
+
}, { passive: passiveOption }).on("touchstart.eventRect touchmove.eventRect", (event) => {
|
|
14523
14831
|
state.event = event;
|
|
14524
14832
|
if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
|
14525
14833
|
if (state.dragging || state.flowing || $$.hasArcType() || event.touches.length > 1) {
|
|
@@ -14530,21 +14838,21 @@ class Axis_Axis {
|
|
|
14530
14838
|
} else {
|
|
14531
14839
|
unselectRect();
|
|
14532
14840
|
}
|
|
14533
|
-
},
|
|
14841
|
+
}, { passive: passiveOption }).on("touchend.eventRect", (event) => {
|
|
14534
14842
|
state.event = event;
|
|
14535
14843
|
if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
|
|
14536
14844
|
if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
|
|
14537
14845
|
state.cancelClick && (state.cancelClick = false);
|
|
14538
14846
|
}
|
|
14539
14847
|
}
|
|
14540
|
-
},
|
|
14848
|
+
}, { passive: passiveOption });
|
|
14541
14849
|
svg.on("touchstart", (event) => {
|
|
14542
14850
|
state.event = event;
|
|
14543
14851
|
const { target } = event;
|
|
14544
14852
|
if (target && target !== eventRect.node()) {
|
|
14545
14853
|
unselectRect();
|
|
14546
14854
|
}
|
|
14547
|
-
});
|
|
14855
|
+
}, { passive: passiveOption });
|
|
14548
14856
|
},
|
|
14549
14857
|
/**
|
|
14550
14858
|
* Update event rect size
|
|
@@ -14746,7 +15054,7 @@ class Axis_Axis {
|
|
|
14746
15054
|
const dist = $$.dist(closest, mouse);
|
|
14747
15055
|
if ($$.isBarType(closest.id) || dist < $$.getPointSensitivity(closest)) {
|
|
14748
15056
|
$$.$el.svg.select(`.${$EVENT.eventRect}`).style("cursor", "pointer");
|
|
14749
|
-
if (triggerEvent && !state.mouseover) {
|
|
15057
|
+
if (triggerEvent && (!state.mouseover || state.mouseover.x !== closest.x || state.mouseover.id !== closest.id)) {
|
|
14750
15058
|
config.data_onover.call($$.api, closest);
|
|
14751
15059
|
state.mouseover = closest;
|
|
14752
15060
|
}
|
|
@@ -14918,7 +15226,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
|
|
|
14918
15226
|
/**
|
|
14919
15227
|
* Generate flow
|
|
14920
15228
|
* @param {object} args option object
|
|
14921
|
-
* @returns {
|
|
15229
|
+
* @returns {function}
|
|
14922
15230
|
* @private
|
|
14923
15231
|
*/
|
|
14924
15232
|
generateFlow(args) {
|
|
@@ -15188,9 +15496,9 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
|
|
|
15188
15496
|
|
|
15189
15497
|
|
|
15190
15498
|
|
|
15191
|
-
const
|
|
15192
|
-
const
|
|
15193
|
-
function
|
|
15499
|
+
const _getGridTextAnchor = (d) => isValue(d.position) || "end";
|
|
15500
|
+
const _getGridTextDx = (d) => d.position === "start" ? 4 : d.position === "middle" ? 0 : -4;
|
|
15501
|
+
function _getGridTextX(isX, width, height) {
|
|
15194
15502
|
return (d) => {
|
|
15195
15503
|
let x = isX ? 0 : width;
|
|
15196
15504
|
if (d.position === "start") {
|
|
@@ -15201,7 +15509,7 @@ function getGridTextX(isX, width, height) {
|
|
|
15201
15509
|
return x;
|
|
15202
15510
|
};
|
|
15203
15511
|
}
|
|
15204
|
-
function
|
|
15512
|
+
function _smoothLines(el, type) {
|
|
15205
15513
|
if (type === "grid") {
|
|
15206
15514
|
el.each(function() {
|
|
15207
15515
|
const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
|
@@ -15272,7 +15580,7 @@ function smoothLines(el, type) {
|
|
|
15272
15580
|
grid.y.exit().remove();
|
|
15273
15581
|
grid.y = grid.y.enter().append("line").attr("class", $GRID.ygrid).merge(grid.y);
|
|
15274
15582
|
grid.y.attr("x1", isRotated ? pos : 0).attr("x2", isRotated ? pos : state.width).attr("y1", isRotated ? 0 : pos).attr("y2", isRotated ? state.height : pos);
|
|
15275
|
-
|
|
15583
|
+
_smoothLines(grid.y, "grid");
|
|
15276
15584
|
},
|
|
15277
15585
|
updateGrid() {
|
|
15278
15586
|
const $$ = this;
|
|
@@ -15305,10 +15613,10 @@ function smoothLines(el, type) {
|
|
|
15305
15613
|
g.append("text").style("opacity", "0");
|
|
15306
15614
|
}
|
|
15307
15615
|
});
|
|
15308
|
-
$T(lines.attr("class", (d) => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim()).select("text").attr("text-anchor",
|
|
15616
|
+
$T(lines.attr("class", (d) => `${$GRID[`${type}gridLine`]} ${d.class || ""}`.trim()).select("text").attr("text-anchor", _getGridTextAnchor).attr(
|
|
15309
15617
|
"transform",
|
|
15310
15618
|
() => isX ? isRotated ? null : "rotate(-90)" : isRotated ? "rotate(-90)" : null
|
|
15311
|
-
).attr("dx",
|
|
15619
|
+
).attr("dx", _getGridTextDx).attr("dy", -5)).text(function(d) {
|
|
15312
15620
|
var _a;
|
|
15313
15621
|
return (_a = d.text) != null ? _a : this.remove();
|
|
15314
15622
|
});
|
|
@@ -15329,9 +15637,9 @@ function smoothLines(el, type) {
|
|
|
15329
15637
|
let yLines = gridLines.y.select("line");
|
|
15330
15638
|
let yTexts = gridLines.y.select("text");
|
|
15331
15639
|
xLines = $T(xLines, withTransition).attr("x1", isRotated ? 0 : xv).attr("x2", isRotated ? width : xv).attr("y1", isRotated ? xv : 0).attr("y2", isRotated ? xv : height);
|
|
15332
|
-
xTexts = $T(xTexts, withTransition).attr("x",
|
|
15640
|
+
xTexts = $T(xTexts, withTransition).attr("x", _getGridTextX(!isRotated, width, height)).attr("y", xv);
|
|
15333
15641
|
yLines = $T(yLines, withTransition).attr("x1", isRotated ? yv : 0).attr("x2", isRotated ? yv : width).attr("y1", isRotated ? 0 : yv).attr("y2", isRotated ? height : yv);
|
|
15334
|
-
yTexts = $T(yTexts, withTransition).attr("x",
|
|
15642
|
+
yTexts = $T(yTexts, withTransition).attr("x", _getGridTextX(isRotated, width, height)).attr("y", yv);
|
|
15335
15643
|
return [
|
|
15336
15644
|
xLines.style("opacity", null),
|
|
15337
15645
|
xTexts.style("opacity", null),
|
|
@@ -15458,7 +15766,7 @@ function smoothLines(el, type) {
|
|
|
15458
15766
|
}
|
|
15459
15767
|
["x1", "y1", "x2", "y2"].forEach((v, i) => el.attr(v, xy[i]));
|
|
15460
15768
|
});
|
|
15461
|
-
|
|
15769
|
+
_smoothLines(focusEl, "grid");
|
|
15462
15770
|
(_a = $$.showCircleFocus) == null ? void 0 : _a.call($$, data);
|
|
15463
15771
|
},
|
|
15464
15772
|
hideGridFocus() {
|
|
@@ -15898,7 +16206,7 @@ function smoothLines(el, type) {
|
|
|
15898
16206
|
* A function to format tick value. Format string is also available for timeseries data.
|
|
15899
16207
|
* @name axis․x․tick․format
|
|
15900
16208
|
* @memberof Options
|
|
15901
|
-
* @type {
|
|
16209
|
+
* @type {function|string}
|
|
15902
16210
|
* @default undefined
|
|
15903
16211
|
* @see [D3's time specifier](https://d3js.org/d3-time-format#locale_format)
|
|
15904
16212
|
* @example
|
|
@@ -15927,7 +16235,7 @@ function smoothLines(el, type) {
|
|
|
15927
16235
|
* - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
|
|
15928
16236
|
* This option does not hide the tick lines by default, if want to hide tick lines, set `axis.x.tick.culling.lines=false`.
|
|
15929
16237
|
* - `false`: all of ticks will be shown.<br><br>
|
|
15930
|
-
* The number of ticks to be shown can be
|
|
16238
|
+
* The number of ticks to be shown can be changed by `axis.x.tick.culling.max`.
|
|
15931
16239
|
* @name axis․x․tick․culling
|
|
15932
16240
|
* @memberof Options
|
|
15933
16241
|
* @type {boolean}
|
|
@@ -16138,10 +16446,10 @@ function smoothLines(el, type) {
|
|
|
16138
16446
|
/**
|
|
16139
16447
|
* Set the x values of ticks manually.<br><br>
|
|
16140
16448
|
* If this option is provided, the position of the ticks will be determined based on those values.<br>
|
|
16141
|
-
* This option works with `timeseries` data and the x values will be parsed
|
|
16449
|
+
* This option works with `timeseries` data and the x values will be parsed according to the type of the value and data.xFormat option.
|
|
16142
16450
|
* @name axis․x․tick․values
|
|
16143
16451
|
* @memberof Options
|
|
16144
|
-
* @type {Array|
|
|
16452
|
+
* @type {Array|function}
|
|
16145
16453
|
* @default null
|
|
16146
16454
|
* @example
|
|
16147
16455
|
* axis: {
|
|
@@ -16362,7 +16670,7 @@ function smoothLines(el, type) {
|
|
|
16362
16670
|
* - **timeseries:** Numeric time value
|
|
16363
16671
|
* 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
|
|
16364
16672
|
* - If want values to be treated as pixels, specify `unit:"px"`.
|
|
16365
|
-
* - The pixel value will be
|
|
16673
|
+
* - The pixel value will be converted based on the scale values. Hence can not reflect accurate padding result.
|
|
16366
16674
|
* @name axis․x․padding
|
|
16367
16675
|
* @memberof Options
|
|
16368
16676
|
* @type {object|number}
|
|
@@ -16413,7 +16721,7 @@ function smoothLines(el, type) {
|
|
|
16413
16721
|
* - **NOTE:** Specifying value, will limit the zoom scope selection within.
|
|
16414
16722
|
* @name axis․x․extent
|
|
16415
16723
|
* @memberof Options
|
|
16416
|
-
* @type {Array|
|
|
16724
|
+
* @type {Array|function}
|
|
16417
16725
|
* @default undefined
|
|
16418
16726
|
* @example
|
|
16419
16727
|
* axis: {
|
|
@@ -16679,7 +16987,7 @@ function smoothLines(el, type) {
|
|
|
16679
16987
|
* This option accepts d3.format object as well as a function you define.
|
|
16680
16988
|
* @name axis․y․tick․format
|
|
16681
16989
|
* @memberof Options
|
|
16682
|
-
* @type {
|
|
16990
|
+
* @type {function}
|
|
16683
16991
|
* @default undefined
|
|
16684
16992
|
* @example
|
|
16685
16993
|
* axis: {
|
|
@@ -16698,7 +17006,7 @@ function smoothLines(el, type) {
|
|
|
16698
17006
|
* - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
|
|
16699
17007
|
* This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y.tick.culling.lines=false`.
|
|
16700
17008
|
* - `false`: all of ticks will be shown.<br><br>
|
|
16701
|
-
* The number of ticks to be shown can be
|
|
17009
|
+
* The number of ticks to be shown can be changed by `axis.y.tick.culling.max`.
|
|
16702
17010
|
* @name axis․y․tick․culling
|
|
16703
17011
|
* @memberof Options
|
|
16704
17012
|
* @type {boolean}
|
|
@@ -16804,7 +17112,7 @@ function smoothLines(el, type) {
|
|
|
16804
17112
|
* Set y axis tick values manually.
|
|
16805
17113
|
* @name axis․y․tick․values
|
|
16806
17114
|
* @memberof Options
|
|
16807
|
-
* @type {Array|
|
|
17115
|
+
* @type {Array|function}
|
|
16808
17116
|
* @default null
|
|
16809
17117
|
* @example
|
|
16810
17118
|
* axis: {
|
|
@@ -16940,7 +17248,7 @@ function smoothLines(el, type) {
|
|
|
16940
17248
|
* @private
|
|
16941
17249
|
* @type {object}
|
|
16942
17250
|
* @property {object} time time object
|
|
16943
|
-
* @property {
|
|
17251
|
+
* @property {function} [time.value] D3's time interval function (https://github.com/d3/d3-time#intervals)
|
|
16944
17252
|
* @example
|
|
16945
17253
|
* axis: {
|
|
16946
17254
|
* y: {
|
|
@@ -17039,6 +17347,18 @@ function smoothLines(el, type) {
|
|
|
17039
17347
|
|
|
17040
17348
|
;// ./src/config/Options/axis/y2.ts
|
|
17041
17349
|
/* harmony default export */ var y2 = ({
|
|
17350
|
+
/**
|
|
17351
|
+
* Set clip-path attribute for y2 axis element
|
|
17352
|
+
* - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
|
|
17353
|
+
* @name axis․y2․clipPath
|
|
17354
|
+
* @memberof Options
|
|
17355
|
+
* @type {boolean}
|
|
17356
|
+
* @default true
|
|
17357
|
+
* @example
|
|
17358
|
+
* // don't set 'clip-path' attribute
|
|
17359
|
+
* clipPath: false
|
|
17360
|
+
*/
|
|
17361
|
+
axis_y2_clipPath: true,
|
|
17042
17362
|
/**
|
|
17043
17363
|
* Show or hide y2 axis.
|
|
17044
17364
|
* - **NOTE**:
|
|
@@ -17184,7 +17504,7 @@ function smoothLines(el, type) {
|
|
|
17184
17504
|
* This option works in the same way as axis.y.format.
|
|
17185
17505
|
* @name axis․y2․tick․format
|
|
17186
17506
|
* @memberof Options
|
|
17187
|
-
* @type {
|
|
17507
|
+
* @type {function}
|
|
17188
17508
|
* @default undefined
|
|
17189
17509
|
* @example
|
|
17190
17510
|
* axis: {
|
|
@@ -17202,7 +17522,7 @@ function smoothLines(el, type) {
|
|
|
17202
17522
|
* - `true`: the ticks will be culled, then only limited tick text will be shown.<br>
|
|
17203
17523
|
* This option does not hide the tick lines by default, if want to hide tick lines, set `axis.y2.tick.culling.lines=false`.
|
|
17204
17524
|
* - `false`: all of ticks will be shown.<br><br>
|
|
17205
|
-
* The number of ticks to be shown can be
|
|
17525
|
+
* The number of ticks to be shown can be changed by `axis.y2.tick.culling.max`.
|
|
17206
17526
|
* @name axis․y2․tick․culling
|
|
17207
17527
|
* @memberof Options
|
|
17208
17528
|
* @type {boolean}
|
|
@@ -17309,7 +17629,7 @@ function smoothLines(el, type) {
|
|
|
17309
17629
|
* Set y2 axis tick values manually.
|
|
17310
17630
|
* @name axis․y2․tick․values
|
|
17311
17631
|
* @memberof Options
|
|
17312
|
-
* @type {Array|
|
|
17632
|
+
* @type {Array|function}
|
|
17313
17633
|
* @default null
|
|
17314
17634
|
* @example
|
|
17315
17635
|
* axis: {
|
|
@@ -17541,16 +17861,16 @@ var axis_spreadValues = (a, b) => {
|
|
|
17541
17861
|
/**
|
|
17542
17862
|
* Setup the way to evaluate tick text size.
|
|
17543
17863
|
* - **NOTE:**
|
|
17544
|
-
* -
|
|
17864
|
+
* - When setting `false` or a custom evaluator, it is highly recommended to memoize evaluated text dimension value to not degrade performance.
|
|
17545
17865
|
* @name axis․evalTextSize
|
|
17546
17866
|
* @memberof Options
|
|
17547
|
-
* @type {boolean|
|
|
17867
|
+
* @type {boolean|function}
|
|
17548
17868
|
* @default true
|
|
17549
17869
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.AxisEvalTextSize)
|
|
17550
17870
|
* @example
|
|
17551
17871
|
* axis: {
|
|
17552
17872
|
* // will evaluate getting text size every time.
|
|
17553
|
-
* evalTextSize: false
|
|
17873
|
+
* evalTextSize: false,
|
|
17554
17874
|
*
|
|
17555
17875
|
* // set a custom evaluator
|
|
17556
17876
|
* evalTextSize: function(textElement, axisId) {
|
|
@@ -17594,8 +17914,8 @@ var axis_spreadValues = (a, b) => {
|
|
|
17594
17914
|
* Set axis tooltip.
|
|
17595
17915
|
* - **NOTE:**
|
|
17596
17916
|
* - When enabled, will disable default focus grid line.
|
|
17597
|
-
* - For `timeseries` x Axis,
|
|
17598
|
-
* - For `category` x Axis,
|
|
17917
|
+
* - For `timeseries` x Axis, tooltip will be formatted using x Axis' tick format.
|
|
17918
|
+
* - For `category` x Axis, tooltip will be displaying scales' value text.
|
|
17599
17919
|
* @name axis․tooltip
|
|
17600
17920
|
* @memberof Options
|
|
17601
17921
|
* @type {boolean}
|
|
@@ -17608,11 +17928,11 @@ var axis_spreadValues = (a, b) => {
|
|
|
17608
17928
|
* axis: {
|
|
17609
17929
|
* tooltip: true, // default background color is
|
|
17610
17930
|
*
|
|
17611
|
-
* // set
|
|
17931
|
+
* // set background color for axis tooltip texts
|
|
17612
17932
|
* tooltip: {
|
|
17613
17933
|
* backgroundColor: "red",
|
|
17614
17934
|
*
|
|
17615
|
-
* // set
|
|
17935
|
+
* // set different background colors per axes
|
|
17616
17936
|
* // NOTE: In this case, only specified axes tooltip will appear.
|
|
17617
17937
|
* backgroundColor: {
|
|
17618
17938
|
* x: "green",
|
|
@@ -17717,7 +18037,7 @@ var axis_spreadValues = (a, b) => {
|
|
|
17717
18037
|
*/
|
|
17718
18038
|
data_xs: {},
|
|
17719
18039
|
/**
|
|
17720
|
-
* Set a format specifier to parse string
|
|
18040
|
+
* Set a format specifier to parse string specified as x.
|
|
17721
18041
|
* @name data․xFormat
|
|
17722
18042
|
* @memberof Options
|
|
17723
18043
|
* @type {string}
|
|
@@ -17766,7 +18086,7 @@ var axis_spreadValues = (a, b) => {
|
|
|
17766
18086
|
* x: "x",
|
|
17767
18087
|
* columns: [
|
|
17768
18088
|
* // The line graph will start to be drawn following the x axis sequence
|
|
17769
|
-
* // Below data,
|
|
18089
|
+
* // Below data, will start drawing x=1: 200, x=2: 300, x=3: 100
|
|
17770
18090
|
* ["x", 3, 1, 2],
|
|
17771
18091
|
* ["data1", 100, 200, 300]
|
|
17772
18092
|
* ]
|
|
@@ -17827,16 +18147,41 @@ var axis_spreadValues = (a, b) => {
|
|
|
17827
18147
|
* - **NOTE:**
|
|
17828
18148
|
* - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
|
|
17829
18149
|
* - y Axis will be set in percentage value (0 ~ 100%)
|
|
17830
|
-
* - Must have
|
|
18150
|
+
* - Must have positive values
|
|
18151
|
+
* - Data not in any group will not be normalized when using perGroup option
|
|
17831
18152
|
* @name data․stack․normalize
|
|
17832
18153
|
* @memberof Options
|
|
17833
|
-
* @type {boolean}
|
|
18154
|
+
* @type {boolean|object}
|
|
17834
18155
|
* @default false
|
|
17835
|
-
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
|
|
18156
|
+
* @see [Demo: Data Stack Normalized](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
|
|
18157
|
+
* @see [Demo: Data Stack Normalized per Group](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalizedGroup)
|
|
17836
18158
|
* @example
|
|
17837
18159
|
* data: {
|
|
17838
18160
|
* stack: {
|
|
18161
|
+
* // Normalize all grouped data together (all groups combined to 0-100%)
|
|
17839
18162
|
* normalize: true
|
|
18163
|
+
*
|
|
18164
|
+
* // Normalize per group (each group independently becomes 0-100%)
|
|
18165
|
+
* // Data not in any group will display with their original values.
|
|
18166
|
+
* // If non-grouped data shares the same axis (e.g., y), it will be
|
|
18167
|
+
* // displayed on the 0-100 absolute scale. To display original values,
|
|
18168
|
+
* // assign them to a separate axis (e.g., y2).
|
|
18169
|
+
* normalize: {
|
|
18170
|
+
* perGroup: true
|
|
18171
|
+
* }
|
|
18172
|
+
* },
|
|
18173
|
+
* groups: [
|
|
18174
|
+
* ["data1", "data2"] // This group will be normalized to 0-100%
|
|
18175
|
+
* ],
|
|
18176
|
+
* // data3 is not in any group, so it displays original values
|
|
18177
|
+
* // Assign it to y2 axis to use a separate scale
|
|
18178
|
+
* axes: {
|
|
18179
|
+
* data3: "y2"
|
|
18180
|
+
* }
|
|
18181
|
+
* },
|
|
18182
|
+
* axis: {
|
|
18183
|
+
* y2: {
|
|
18184
|
+
* show: true
|
|
17840
18185
|
* }
|
|
17841
18186
|
* }
|
|
17842
18187
|
*/
|
|
@@ -17887,6 +18232,155 @@ const options = {
|
|
|
17887
18232
|
|
|
17888
18233
|
// EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
|
|
17889
18234
|
var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(13);
|
|
18235
|
+
;// ./src/ChartInternal/internals/text.arc.ts
|
|
18236
|
+
|
|
18237
|
+
|
|
18238
|
+
|
|
18239
|
+
|
|
18240
|
+
const BREAK_POINT_OFFSET = 15;
|
|
18241
|
+
const DEFAULT_LINE_DISTANCE = 20;
|
|
18242
|
+
const TEXT_VERTICAL_OFFSET = 0.35;
|
|
18243
|
+
function getArcType(excludeMultiGauge = false) {
|
|
18244
|
+
const $$ = this;
|
|
18245
|
+
return ["donut", "pie", "polar", "gauge"].find(
|
|
18246
|
+
(type) => $$.hasType(type) && !(type === "gauge" && excludeMultiGauge && $$.hasMultiArcGauge())
|
|
18247
|
+
);
|
|
18248
|
+
}
|
|
18249
|
+
function getConfig() {
|
|
18250
|
+
const $$ = this;
|
|
18251
|
+
const { config } = $$;
|
|
18252
|
+
const chartType = getArcType.call($$, true);
|
|
18253
|
+
const lineConfig = chartType && config[`${chartType}_label_line`];
|
|
18254
|
+
const isValidConfig = isObjectType(lineConfig);
|
|
18255
|
+
const defaultFormatter = (value, ratio, id) => id;
|
|
18256
|
+
const line = {
|
|
18257
|
+
show: lineConfig === true || isValidConfig && (lineConfig == null ? void 0 : lineConfig.show) !== false,
|
|
18258
|
+
distance: isValidConfig && (lineConfig == null ? void 0 : lineConfig.distance) || DEFAULT_LINE_DISTANCE
|
|
18259
|
+
};
|
|
18260
|
+
if (lineConfig === true) {
|
|
18261
|
+
return {
|
|
18262
|
+
chartType,
|
|
18263
|
+
line,
|
|
18264
|
+
text: { formatter: defaultFormatter }
|
|
18265
|
+
};
|
|
18266
|
+
}
|
|
18267
|
+
if (!isValidConfig) {
|
|
18268
|
+
return {
|
|
18269
|
+
chartType,
|
|
18270
|
+
line: { show: false, distance: DEFAULT_LINE_DISTANCE },
|
|
18271
|
+
text: { formatter: null }
|
|
18272
|
+
};
|
|
18273
|
+
}
|
|
18274
|
+
let formatter = defaultFormatter;
|
|
18275
|
+
if (isFunction(lineConfig.text)) {
|
|
18276
|
+
formatter = lineConfig.text;
|
|
18277
|
+
} else if (lineConfig.text === false) {
|
|
18278
|
+
formatter = null;
|
|
18279
|
+
}
|
|
18280
|
+
return {
|
|
18281
|
+
chartType,
|
|
18282
|
+
line,
|
|
18283
|
+
text: { formatter }
|
|
18284
|
+
};
|
|
18285
|
+
}
|
|
18286
|
+
function getLinePosition(d, lineDistance) {
|
|
18287
|
+
const $$ = this;
|
|
18288
|
+
const { state } = $$;
|
|
18289
|
+
const updated = $$.updateAngle(d);
|
|
18290
|
+
if (!updated) {
|
|
18291
|
+
return null;
|
|
18292
|
+
}
|
|
18293
|
+
let { outerRadius } = $$.getRadius(d);
|
|
18294
|
+
let arcOuterRadius = outerRadius;
|
|
18295
|
+
if ($$.hasType("polar")) {
|
|
18296
|
+
arcOuterRadius = $$.getPolarOuterRadius(d, outerRadius);
|
|
18297
|
+
outerRadius = state.radius;
|
|
18298
|
+
}
|
|
18299
|
+
let midAngle = (updated.startAngle + updated.endAngle) / 2;
|
|
18300
|
+
const isFullCircleArc = Math.abs(updated.endAngle - updated.startAngle - 2 * Math.PI) < 0.01;
|
|
18301
|
+
if (isFullCircleArc) {
|
|
18302
|
+
midAngle = Math.PI / 2;
|
|
18303
|
+
}
|
|
18304
|
+
const sinAngle = Math.sin(midAngle);
|
|
18305
|
+
const cosAngle = -Math.cos(midAngle);
|
|
18306
|
+
const startPoint = {
|
|
18307
|
+
x: sinAngle * arcOuterRadius,
|
|
18308
|
+
y: cosAngle * arcOuterRadius
|
|
18309
|
+
};
|
|
18310
|
+
const breakRadius = outerRadius + BREAK_POINT_OFFSET;
|
|
18311
|
+
const breakPoint = {
|
|
18312
|
+
x: sinAngle * breakRadius,
|
|
18313
|
+
y: cosAngle * breakRadius
|
|
18314
|
+
};
|
|
18315
|
+
const isRight = sinAngle >= 0;
|
|
18316
|
+
const endPoint = {
|
|
18317
|
+
x: breakPoint.x + lineDistance * (isRight ? 1 : -1),
|
|
18318
|
+
y: breakPoint.y
|
|
18319
|
+
};
|
|
18320
|
+
return { startPoint, breakPoint, endPoint, isRight, midAngle };
|
|
18321
|
+
}
|
|
18322
|
+
function isLabelWithLine() {
|
|
18323
|
+
return getConfig.call(this).line.show;
|
|
18324
|
+
}
|
|
18325
|
+
function redrawArcLabelLines(duration) {
|
|
18326
|
+
const $$ = this;
|
|
18327
|
+
const { $el: { arcs }, $T } = $$;
|
|
18328
|
+
const { line: lineConfig, text: textConfig } = getConfig.call($$);
|
|
18329
|
+
const lineDistance = lineConfig.distance;
|
|
18330
|
+
let cachedFontSize = null;
|
|
18331
|
+
arcs.selectAll(`.${$ARC.chartArc}`).each(function(d) {
|
|
18332
|
+
var _a, _b, _c;
|
|
18333
|
+
const g = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
|
18334
|
+
const linePos = getLinePosition.call($$, d, lineDistance);
|
|
18335
|
+
const { ratio, meetsThreshold, updated } = (_a = d._cache) != null ? _a : {};
|
|
18336
|
+
if (!updated || !linePos) {
|
|
18337
|
+
return;
|
|
18338
|
+
}
|
|
18339
|
+
const isVisible = $$.isTargetToShow(d.data.id) && meetsThreshold;
|
|
18340
|
+
const { startPoint, breakPoint, endPoint, isRight } = linePos;
|
|
18341
|
+
const points = `${startPoint.x},${startPoint.y} ${breakPoint.x},${breakPoint.y} ${endPoint.x},${endPoint.y}`;
|
|
18342
|
+
if (lineConfig.show) {
|
|
18343
|
+
let line = g.select(`.${$ARC.arcLabelLine}`);
|
|
18344
|
+
if (line.empty()) {
|
|
18345
|
+
line = g.append("polyline").attr("class", $ARC.arcLabelLine);
|
|
18346
|
+
}
|
|
18347
|
+
$T(line, duration).attr("points", points).style("stroke", $$.color(d.data)).style("opacity", isVisible ? null : "0");
|
|
18348
|
+
}
|
|
18349
|
+
let labelLineText = g.select(`.${$ARC.arcLabelLineText}`);
|
|
18350
|
+
if (labelLineText.empty()) {
|
|
18351
|
+
labelLineText = g.append("text").attr("class", $ARC.arcLabelLineText).style("pointer-events", "none");
|
|
18352
|
+
}
|
|
18353
|
+
if (isVisible) {
|
|
18354
|
+
const { value } = updated;
|
|
18355
|
+
const { id } = d.data;
|
|
18356
|
+
const text = ((_c = (_b = textConfig.formatter) != null ? _b : $$.getArcLabelConfig("format")) != null ? _c : $$.defaultArcValueFormat)(value, ratio, id).toString();
|
|
18357
|
+
setTextValue(labelLineText, text, [-1, 1], false);
|
|
18358
|
+
const pos = {
|
|
18359
|
+
x: endPoint.x + 5 * (isRight ? 1 : -1),
|
|
18360
|
+
// 5: label offset from endpoint
|
|
18361
|
+
y: endPoint.y
|
|
18362
|
+
};
|
|
18363
|
+
labelLineText.style("text-anchor", isRight ? "start" : "end");
|
|
18364
|
+
const textNode = labelLineText.node();
|
|
18365
|
+
const tspanNodes = textNode == null ? void 0 : textNode.querySelectorAll("tspan");
|
|
18366
|
+
if (cachedFontSize === null) {
|
|
18367
|
+
cachedFontSize = parseFloat(win.getComputedStyle(textNode).fontSize) || 12;
|
|
18368
|
+
}
|
|
18369
|
+
if (tspanNodes && tspanNodes.length > 1) {
|
|
18370
|
+
const lineCount = tspanNodes.length;
|
|
18371
|
+
const centerOffset = (lineCount - 3) / 2;
|
|
18372
|
+
pos.y += (-centerOffset + TEXT_VERTICAL_OFFSET) * cachedFontSize;
|
|
18373
|
+
} else {
|
|
18374
|
+
pos.y += TEXT_VERTICAL_OFFSET * cachedFontSize;
|
|
18375
|
+
}
|
|
18376
|
+
$T(labelLineText, duration).attr("transform", `translate(${pos.x},${pos.y})`).style("opacity", null).style("fill", $$.updateTextColor.bind($$)(d));
|
|
18377
|
+
} else {
|
|
18378
|
+
$T(labelLineText, duration).style("opacity", "0");
|
|
18379
|
+
}
|
|
18380
|
+
});
|
|
18381
|
+
}
|
|
18382
|
+
|
|
18383
|
+
|
|
17890
18384
|
;// ./src/ChartInternal/shape/arc.ts
|
|
17891
18385
|
var arc_defProp = Object.defineProperty;
|
|
17892
18386
|
var arc_defProps = Object.defineProperties;
|
|
@@ -17914,7 +18408,63 @@ var arc_spreadProps = (a, b) => arc_defProps(a, arc_getOwnPropDescs(b));
|
|
|
17914
18408
|
|
|
17915
18409
|
|
|
17916
18410
|
|
|
17917
|
-
|
|
18411
|
+
|
|
18412
|
+
function _getArcType($$) {
|
|
18413
|
+
return ["donut", "pie", "polar", "gauge"].find((type) => $$.hasType(type));
|
|
18414
|
+
}
|
|
18415
|
+
function _calculateRangeOrGaugePosition($$, d, updated, forRange) {
|
|
18416
|
+
var _a, _b;
|
|
18417
|
+
const { config, state: { radiusExpanded } } = $$;
|
|
18418
|
+
const angle = updated.endAngle - Math.PI / 2;
|
|
18419
|
+
const sinAngle = Math.sin(angle);
|
|
18420
|
+
const pos = {
|
|
18421
|
+
x: Math.cos(angle) * (radiusExpanded + (forRange ? 5 : 25)),
|
|
18422
|
+
// 5: range offset, 25: gauge offset
|
|
18423
|
+
y: sinAngle * (radiusExpanded + 15 - Math.abs(sinAngle * 10)) + 3
|
|
18424
|
+
// 10: y factor, 3: y offset
|
|
18425
|
+
};
|
|
18426
|
+
if (forRange) {
|
|
18427
|
+
const rangeTextPosition = config.arc_rangeText_position;
|
|
18428
|
+
if (rangeTextPosition) {
|
|
18429
|
+
const rangeValues = config.arc_rangeText_values;
|
|
18430
|
+
const position = isFunction(rangeTextPosition) ? rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
|
|
18431
|
+
pos.x += (_a = position == null ? void 0 : position.x) != null ? _a : 0;
|
|
18432
|
+
pos.y += (_b = position == null ? void 0 : position.y) != null ? _b : 0;
|
|
18433
|
+
}
|
|
18434
|
+
}
|
|
18435
|
+
return pos;
|
|
18436
|
+
}
|
|
18437
|
+
function _calculateLabelRatio($$, d, outerRadius, distance) {
|
|
18438
|
+
const { config } = $$;
|
|
18439
|
+
const chartType = _getArcType($$);
|
|
18440
|
+
let ratio = chartType ? config[`${chartType}_label_ratio`] : void 0;
|
|
18441
|
+
if (ratio) {
|
|
18442
|
+
ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, distance) : ratio;
|
|
18443
|
+
} else {
|
|
18444
|
+
const LABEL_MIN_SIZE = 36;
|
|
18445
|
+
const LABEL_RATIO_THRESHOLD = 0.375;
|
|
18446
|
+
const LABEL_RATIO_BASE = 1.175;
|
|
18447
|
+
const LABEL_RATIO_LARGE = 0.8;
|
|
18448
|
+
const labelSpaceRatio = LABEL_MIN_SIZE / outerRadius;
|
|
18449
|
+
const isSmallChart = labelSpaceRatio > LABEL_RATIO_THRESHOLD;
|
|
18450
|
+
ratio = outerRadius && distance ? (isSmallChart ? LABEL_RATIO_BASE - labelSpaceRatio : LABEL_RATIO_LARGE) * outerRadius / distance : 0;
|
|
18451
|
+
}
|
|
18452
|
+
return ratio;
|
|
18453
|
+
}
|
|
18454
|
+
function _calculateStandardArcPosition($$, d, updated) {
|
|
18455
|
+
let { outerRadius } = $$.getRadius(d);
|
|
18456
|
+
if ($$.hasType("polar")) {
|
|
18457
|
+
outerRadius = $$.getPolarOuterRadius(d, outerRadius);
|
|
18458
|
+
}
|
|
18459
|
+
const [x, y] = $$.svgArc.centroid(updated).map((v) => isNaN(v) ? 0 : v);
|
|
18460
|
+
const distance = Math.sqrt(x * x + y * y);
|
|
18461
|
+
const ratio = _calculateLabelRatio($$, d, outerRadius, distance);
|
|
18462
|
+
return {
|
|
18463
|
+
pos: { x, y },
|
|
18464
|
+
ratio
|
|
18465
|
+
};
|
|
18466
|
+
}
|
|
18467
|
+
function _getRadiusFn(expandRate = 0) {
|
|
17918
18468
|
const $$ = this;
|
|
17919
18469
|
const { config, state } = $$;
|
|
17920
18470
|
const hasMultiArcGauge = $$.hasMultiArcGauge();
|
|
@@ -17982,7 +18532,7 @@ function getRadiusFn(expandRate = 0) {
|
|
|
17982
18532
|
}
|
|
17983
18533
|
};
|
|
17984
18534
|
}
|
|
17985
|
-
function
|
|
18535
|
+
function _getAttrTweenFn(fn) {
|
|
17986
18536
|
return function(d) {
|
|
17987
18537
|
const getAngleKeyValue = ({ startAngle = 0, endAngle = 0, padAngle = 0 }) => ({
|
|
17988
18538
|
startAngle,
|
|
@@ -18021,7 +18571,9 @@ function getAttrTweenFn(fn) {
|
|
|
18021
18571
|
const padding = config[`${dataType}_padding`];
|
|
18022
18572
|
const w = config.gauge_width || config.donut_width;
|
|
18023
18573
|
const gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length * config.gauge_arcs_minWidth;
|
|
18024
|
-
|
|
18574
|
+
const LABEL_RADIUS_RATIO = 0.85;
|
|
18575
|
+
const labelWithLineRatio = isLabelWithLine.call($$) ? LABEL_RADIUS_RATIO : 1;
|
|
18576
|
+
state.radiusExpanded = Math.min(state.arcWidth, state.arcHeight) / 2 * ($$.hasMultiArcGauge() && config.gauge_label_show ? LABEL_RADIUS_RATIO : labelWithLineRatio);
|
|
18025
18577
|
state.radius = state.radiusExpanded * 0.95;
|
|
18026
18578
|
state.innerRadiusRatio = w ? (state.radius - w) / state.radius : 0.6;
|
|
18027
18579
|
state.gaugeArcWidth = w || (gaugeArcWidth <= state.radius - state.innerRadius ? state.radius - state.innerRadius : gaugeArcWidth <= state.radius ? gaugeArcWidth : state.radius);
|
|
@@ -18139,7 +18691,7 @@ function getAttrTweenFn(fn) {
|
|
|
18139
18691
|
},
|
|
18140
18692
|
getSvgArc() {
|
|
18141
18693
|
const $$ = this;
|
|
18142
|
-
const { inner, outer, corner } =
|
|
18694
|
+
const { inner, outer, corner } = _getRadiusFn.call($$);
|
|
18143
18695
|
const arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
|
|
18144
18696
|
const newArc = function(d, withoutUpdate) {
|
|
18145
18697
|
var _a;
|
|
@@ -18160,12 +18712,12 @@ function getAttrTweenFn(fn) {
|
|
|
18160
18712
|
/**
|
|
18161
18713
|
* Get expanded arc path function
|
|
18162
18714
|
* @param {number} rate Expand rate
|
|
18163
|
-
* @returns {
|
|
18715
|
+
* @returns {function} Expanded arc path getter function
|
|
18164
18716
|
* @private
|
|
18165
18717
|
*/
|
|
18166
18718
|
getSvgArcExpanded(rate = 1) {
|
|
18167
18719
|
const $$ = this;
|
|
18168
|
-
const { inner, outer, corner } =
|
|
18720
|
+
const { inner, outer, corner } = _getRadiusFn.call($$, rate);
|
|
18169
18721
|
const arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
|
|
18170
18722
|
return (d) => {
|
|
18171
18723
|
const updated = $$.updateAngle(d);
|
|
@@ -18223,46 +18775,24 @@ function getAttrTweenFn(fn) {
|
|
|
18223
18775
|
* @private
|
|
18224
18776
|
*/
|
|
18225
18777
|
transformForArcLabel(textNode, d, forRange = false) {
|
|
18226
|
-
var _a, _b, _c;
|
|
18227
18778
|
const $$ = this;
|
|
18228
|
-
const { config, state: { radiusExpanded } } = $$;
|
|
18229
18779
|
const updated = $$.updateAngle(d, forRange);
|
|
18230
|
-
|
|
18231
|
-
|
|
18780
|
+
if (!updated) {
|
|
18781
|
+
return "";
|
|
18782
|
+
}
|
|
18783
|
+
let pos;
|
|
18232
18784
|
let ratio = 1;
|
|
18233
|
-
if (
|
|
18234
|
-
|
|
18235
|
-
|
|
18236
|
-
|
|
18237
|
-
|
|
18238
|
-
|
|
18239
|
-
|
|
18240
|
-
|
|
18241
|
-
const position = isFunction(rangeTextPosition) ? rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
|
|
18242
|
-
pos.x += (_a = position == null ? void 0 : position.x) != null ? _a : 0;
|
|
18243
|
-
pos.y += (_b = position == null ? void 0 : position.y) != null ? _b : 0;
|
|
18244
|
-
}
|
|
18245
|
-
} else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
|
|
18246
|
-
let { outerRadius } = $$.getRadius(d);
|
|
18247
|
-
if ($$.hasType("polar")) {
|
|
18248
|
-
outerRadius = $$.getPolarOuterRadius(d, outerRadius);
|
|
18249
|
-
}
|
|
18250
|
-
const c = this.svgArc.centroid(updated);
|
|
18251
|
-
const [x, y] = c.map((v) => isNaN(v) ? 0 : v);
|
|
18252
|
-
const h = Math.sqrt(x * x + y * y);
|
|
18253
|
-
pos.x = x;
|
|
18254
|
-
pos.y = y;
|
|
18255
|
-
ratio = (_c = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).map((v) => config[`${v}_label_ratio`])) == null ? void 0 : _c[0];
|
|
18256
|
-
if (ratio) {
|
|
18257
|
-
ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
|
|
18258
|
-
} else {
|
|
18259
|
-
ratio = outerRadius && (h ? (36 / outerRadius > 0.375 ? 1.175 - 36 / outerRadius : 0.8) * outerRadius / h : 0);
|
|
18260
|
-
}
|
|
18261
|
-
}
|
|
18262
|
-
updateTextImagePos.call($$, textNode, pos);
|
|
18263
|
-
translate = `translate(${pos.x * ratio},${pos.y * ratio})`;
|
|
18785
|
+
if (forRange || $$.hasMultiArcGauge()) {
|
|
18786
|
+
pos = _calculateRangeOrGaugePosition($$, d, updated, forRange);
|
|
18787
|
+
} else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
|
|
18788
|
+
const result = _calculateStandardArcPosition($$, d, updated);
|
|
18789
|
+
pos = result.pos;
|
|
18790
|
+
ratio = result.ratio;
|
|
18791
|
+
} else {
|
|
18792
|
+
return "";
|
|
18264
18793
|
}
|
|
18265
|
-
|
|
18794
|
+
updateTextImagePos.call($$, textNode, pos);
|
|
18795
|
+
return `translate(${pos.x * ratio},${pos.y * ratio})`;
|
|
18266
18796
|
},
|
|
18267
18797
|
convertToArcData(d) {
|
|
18268
18798
|
return this.addName({
|
|
@@ -18273,20 +18803,18 @@ function getAttrTweenFn(fn) {
|
|
|
18273
18803
|
});
|
|
18274
18804
|
},
|
|
18275
18805
|
textForArcLabel(selection) {
|
|
18806
|
+
var _a;
|
|
18276
18807
|
const $$ = this;
|
|
18277
18808
|
const hasGauge = $$.hasType("gauge");
|
|
18809
|
+
const chartType = (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _a[0];
|
|
18278
18810
|
if ($$.shouldShowArcLabel()) {
|
|
18279
18811
|
selection.style("fill", $$.updateTextColor.bind($$)).attr("filter", (d) => $$.updateTextBGColor.bind($$)(d, $$.config.data_labels_backgroundColors)).each(function(d) {
|
|
18280
|
-
var _a;
|
|
18281
18812
|
const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
|
18282
18813
|
const updated = $$.updateAngle(d);
|
|
18283
18814
|
const ratio = $$.getRatio("arc", updated);
|
|
18284
|
-
const
|
|
18285
|
-
|
|
18286
|
-
|
|
18287
|
-
(_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _a[0]
|
|
18288
|
-
);
|
|
18289
|
-
if (isUnderThreshold) {
|
|
18815
|
+
const meetsThreshold = meetsLabelThreshold.call($$, ratio, chartType);
|
|
18816
|
+
d._cache = { updated, ratio, meetsThreshold };
|
|
18817
|
+
if (meetsThreshold) {
|
|
18290
18818
|
const { value } = updated || d;
|
|
18291
18819
|
const text = ($$.getArcLabelConfig("format") || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
|
|
18292
18820
|
setTextValue(node, text, [-1, 1], hasGauge);
|
|
@@ -18317,7 +18845,7 @@ function getAttrTweenFn(fn) {
|
|
|
18317
18845
|
const svgArcExpandedSub = $$.getSvgArcExpanded(
|
|
18318
18846
|
$$.getExpandConfig(d.data.id, "rate")
|
|
18319
18847
|
);
|
|
18320
|
-
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d",
|
|
18848
|
+
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d", _getAttrTweenFn($$.svgArcExpanded.bind($$))).transition().duration(expandDuration * 2).attrTween("d", _getAttrTweenFn(svgArcExpandedSub.bind($$)));
|
|
18321
18849
|
});
|
|
18322
18850
|
},
|
|
18323
18851
|
unexpandArc(targetIds) {
|
|
@@ -18327,7 +18855,7 @@ function getAttrTweenFn(fn) {
|
|
|
18327
18855
|
return;
|
|
18328
18856
|
}
|
|
18329
18857
|
const newTargetIds = $$.mapToTargetIds(targetIds);
|
|
18330
|
-
svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`)).selectAll("path").transition().duration((d) => $$.getExpandConfig(d.data.id, "duration")).attrTween("d",
|
|
18858
|
+
svg.selectAll($$.selectorTargets(newTargetIds, `.${$ARC.chartArc}`)).selectAll("path").transition().duration((d) => $$.getExpandConfig(d.data.id, "duration")).attrTween("d", _getAttrTweenFn($$.svgArc.bind($$)));
|
|
18331
18859
|
svg.selectAll(`${$ARC.arc}`).style("opacity", null);
|
|
18332
18860
|
},
|
|
18333
18861
|
/**
|
|
@@ -18393,7 +18921,7 @@ function getAttrTweenFn(fn) {
|
|
|
18393
18921
|
])
|
|
18394
18922
|
);
|
|
18395
18923
|
mainPieEnter.append("g").attr("class", classArcs).merge(mainPieUpdate);
|
|
18396
|
-
mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" :
|
|
18924
|
+
mainPieEnter.append("text").attr("dy", hasGauge && !$$.hasMultiTargets() ? "-.1em" : null).style("opacity", "0").style("text-anchor", $$.getStylePropValue("middle")).style("pointer-events", $$.getStylePropValue("none"));
|
|
18397
18925
|
$el.text = chartArcs.selectAll(`.${$COMMON.target} text`);
|
|
18398
18926
|
},
|
|
18399
18927
|
initArc() {
|
|
@@ -18703,7 +19231,7 @@ function getAttrTweenFn(fn) {
|
|
|
18703
19231
|
const id = (arcData == null ? void 0 : arcData.id) || void 0;
|
|
18704
19232
|
$$.callOverOutForTouch(arcData);
|
|
18705
19233
|
isUndefined(id) ? unselectArc() : selectArc(this, arcData, id);
|
|
18706
|
-
});
|
|
19234
|
+
}, { passive: true });
|
|
18707
19235
|
}
|
|
18708
19236
|
},
|
|
18709
19237
|
redrawArcText(duration) {
|
|
@@ -18733,6 +19261,7 @@ function getAttrTweenFn(fn) {
|
|
|
18733
19261
|
!isFullCircle && arcs.select(`.${$GAUGE.chartArcsGaugeMax}`).attr("dx", `${state.innerRadius + (state.radius - state.innerRadius) / 2}px`).attr("dy", "1.2em").text($$.textForGaugeMinMax(config.gauge_max, true));
|
|
18734
19262
|
}
|
|
18735
19263
|
}
|
|
19264
|
+
isLabelWithLine.call($$) && redrawArcLabelLines.call($$, duration);
|
|
18736
19265
|
},
|
|
18737
19266
|
/**
|
|
18738
19267
|
* Get Arc element by id or index
|
|
@@ -18791,7 +19320,7 @@ function getAttrTweenFn(fn) {
|
|
|
18791
19320
|
},
|
|
18792
19321
|
/**
|
|
18793
19322
|
* Redraw function
|
|
18794
|
-
* @param {
|
|
19323
|
+
* @param {function} drawFn Retuned functino from .generateDrawCandlestick()
|
|
18795
19324
|
* @param {boolean} withTransition With or without transition
|
|
18796
19325
|
* @param {boolean} isSub Subchart draw
|
|
18797
19326
|
* @returns {Array}
|
|
@@ -18811,7 +19340,7 @@ function getAttrTweenFn(fn) {
|
|
|
18811
19340
|
* Generate area path data
|
|
18812
19341
|
* @param {object} areaIndices Indices
|
|
18813
19342
|
* @param {boolean} isSub Weather is sub axis
|
|
18814
|
-
* @returns {
|
|
19343
|
+
* @returns {function}
|
|
18815
19344
|
* @private
|
|
18816
19345
|
*/
|
|
18817
19346
|
generateDrawArea(areaIndices, isSub) {
|
|
@@ -18885,7 +19414,7 @@ function getAttrTweenFn(fn) {
|
|
|
18885
19414
|
|
|
18886
19415
|
|
|
18887
19416
|
|
|
18888
|
-
function
|
|
19417
|
+
function _getConnectLineType(id) {
|
|
18889
19418
|
const connectLine = this.config.bar_connectLine;
|
|
18890
19419
|
const type = (connectLine == null ? void 0 : connectLine[id]) || connectLine;
|
|
18891
19420
|
return /^(start|end)\-(start|end)$/.test(type) ? type : null;
|
|
@@ -18918,7 +19447,7 @@ function getConnectLineType(id) {
|
|
|
18918
19447
|
}).call((selection) => {
|
|
18919
19448
|
$$.setCssRule(true, ` .${$BAR.bar}`, ["fill"], $$.color)(selection);
|
|
18920
19449
|
selection.each(function(d) {
|
|
18921
|
-
if (
|
|
19450
|
+
if (_getConnectLineType.call($$, d.id)) {
|
|
18922
19451
|
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).append("path").attr("class", $BAR.barConnectLine);
|
|
18923
19452
|
}
|
|
18924
19453
|
});
|
|
@@ -18955,7 +19484,7 @@ function getConnectLineType(id) {
|
|
|
18955
19484
|
},
|
|
18956
19485
|
/**
|
|
18957
19486
|
* Redraw function
|
|
18958
|
-
* @param {
|
|
19487
|
+
* @param {function} drawFn Retuned function from .getDrawShape() => .generateDrawBar()
|
|
18959
19488
|
* @param {boolean} withTransition With or without transition
|
|
18960
19489
|
* @param {boolean} isSub Subchart draw
|
|
18961
19490
|
* @returns {Array}
|
|
@@ -18968,7 +19497,7 @@ function getConnectLineType(id) {
|
|
|
18968
19497
|
return [
|
|
18969
19498
|
$$.$T(bar, withTransition, getRandom()).attr("d", function(d, i, arr) {
|
|
18970
19499
|
const path = (isNumber(d.value) || $$.isBarRangeType(d)) && drawFn(d, i);
|
|
18971
|
-
const connectLineType =
|
|
19500
|
+
const connectLineType = _getConnectLineType.call($$, d.id);
|
|
18972
19501
|
if (path.length > 1) {
|
|
18973
19502
|
barPath.push(path[1]);
|
|
18974
19503
|
if (i === arr.length - 1) {
|
|
@@ -19002,7 +19531,7 @@ function getConnectLineType(id) {
|
|
|
19002
19531
|
* -------------------------
|
|
19003
19532
|
* 0 1
|
|
19004
19533
|
* @param {boolean} isSub If is for subchart
|
|
19005
|
-
* @returns {
|
|
19534
|
+
* @returns {function}
|
|
19006
19535
|
* @private
|
|
19007
19536
|
*/
|
|
19008
19537
|
generateDrawBar(barIndices, isSub) {
|
|
@@ -19060,7 +19589,7 @@ function getConnectLineType(id) {
|
|
|
19060
19589
|
}
|
|
19061
19590
|
const path = isRotated ? `H${pos} ${pathRadius[0]}V${points[2][indexY] - radius} ${pathRadius[1]}H${points[3][indexX]}` : `V${pos} ${pathRadius[0]}H${points[2][indexX] - radius} ${pathRadius[1]}V${points[3][indexY]}`;
|
|
19062
19591
|
const coords = [`M${points[0][indexX]},${points[0][indexY]}${path}z`];
|
|
19063
|
-
if (
|
|
19592
|
+
if (_getConnectLineType.call($$, d.id)) {
|
|
19064
19593
|
coords.push(isRotated ? {
|
|
19065
19594
|
x: points[0][indexX],
|
|
19066
19595
|
y: points[0][indexY],
|
|
@@ -19297,7 +19826,7 @@ var candlestick_spreadValues = (a, b) => {
|
|
|
19297
19826
|
* Get draw function
|
|
19298
19827
|
* @param {object} indices Indice data
|
|
19299
19828
|
* @param {boolean} isSub Subchart draw
|
|
19300
|
-
* @returns {
|
|
19829
|
+
* @returns {function}
|
|
19301
19830
|
* @private
|
|
19302
19831
|
*/
|
|
19303
19832
|
generateDrawCandlestick(indices, isSub) {
|
|
@@ -19341,7 +19870,7 @@ var candlestick_spreadValues = (a, b) => {
|
|
|
19341
19870
|
* Generate shape drawing points
|
|
19342
19871
|
* @param {object} indices Indice data
|
|
19343
19872
|
* @param {boolean} isSub Subchart draw
|
|
19344
|
-
* @returns {
|
|
19873
|
+
* @returns {function}
|
|
19345
19874
|
*/
|
|
19346
19875
|
generateGetCandlestickPoints(indices, isSub = false) {
|
|
19347
19876
|
const $$ = this;
|
|
@@ -19387,7 +19916,7 @@ var candlestick_spreadValues = (a, b) => {
|
|
|
19387
19916
|
},
|
|
19388
19917
|
/**
|
|
19389
19918
|
* Redraw function
|
|
19390
|
-
* @param {
|
|
19919
|
+
* @param {function} drawFn Retuned functino from .generateDrawCandlestick()
|
|
19391
19920
|
* @param {boolean} withTransition With or without transition
|
|
19392
19921
|
* @param {boolean} isSub Subchart draw
|
|
19393
19922
|
* @returns {Array}
|
|
@@ -19449,7 +19978,7 @@ var funnel_spreadValues = (a, b) => {
|
|
|
19449
19978
|
|
|
19450
19979
|
|
|
19451
19980
|
|
|
19452
|
-
function
|
|
19981
|
+
function _getSize(checkNeck = false) {
|
|
19453
19982
|
const $$ = this;
|
|
19454
19983
|
const { config, state: { current: { width, height } } } = $$;
|
|
19455
19984
|
const padding = $$.getCurrentPadding();
|
|
@@ -19458,7 +19987,7 @@ function getSize(checkNeck = false) {
|
|
|
19458
19987
|
height: height - (config.legend_show ? $$.getLegendHeight() + 10 : 0) - (padding.top + padding.bottom)
|
|
19459
19988
|
}, padding);
|
|
19460
19989
|
if (checkNeck) {
|
|
19461
|
-
const { width: neckWidth, height: neckHeight } =
|
|
19990
|
+
const { width: neckWidth, height: neckHeight } = _getNeckSize.call($$, {
|
|
19462
19991
|
width: size.width,
|
|
19463
19992
|
height: size.height
|
|
19464
19993
|
});
|
|
@@ -19471,7 +20000,7 @@ function getSize(checkNeck = false) {
|
|
|
19471
20000
|
}
|
|
19472
20001
|
return size;
|
|
19473
20002
|
}
|
|
19474
|
-
function
|
|
20003
|
+
function _getNeckSize(current) {
|
|
19475
20004
|
const $$ = this;
|
|
19476
20005
|
const { config } = $$;
|
|
19477
20006
|
let width = config.funnel_neck_width;
|
|
@@ -19488,9 +20017,9 @@ function getNecklSize(current) {
|
|
|
19488
20017
|
height
|
|
19489
20018
|
};
|
|
19490
20019
|
}
|
|
19491
|
-
function
|
|
20020
|
+
function _getCoord(d) {
|
|
19492
20021
|
const $$ = this;
|
|
19493
|
-
const { top, left, width } =
|
|
20022
|
+
const { top, left, width } = _getSize.call($$, true);
|
|
19494
20023
|
const coords = [];
|
|
19495
20024
|
d.forEach((d2, i) => {
|
|
19496
20025
|
const { ratio } = d2;
|
|
@@ -19510,10 +20039,10 @@ function getCoord(d) {
|
|
|
19510
20039
|
});
|
|
19511
20040
|
return coords;
|
|
19512
20041
|
}
|
|
19513
|
-
function
|
|
20042
|
+
function _getClipPath(forBackground = false) {
|
|
19514
20043
|
const $$ = this;
|
|
19515
|
-
const { width, height, top, left } =
|
|
19516
|
-
const neck =
|
|
20044
|
+
const { width, height, top, left } = _getSize.call($$, true);
|
|
20045
|
+
const neck = _getNeckSize.call($$, { width, height });
|
|
19517
20046
|
const leftX = (width - neck.width) / 2;
|
|
19518
20047
|
const rightX = (width + neck.width) / 2;
|
|
19519
20048
|
const bodyHeigth = height - neck.height;
|
|
@@ -19541,7 +20070,7 @@ function getClipPath(forBackground = false) {
|
|
|
19541
20070
|
}
|
|
19542
20071
|
return `M${coords.join("L")}z`;
|
|
19543
20072
|
}
|
|
19544
|
-
function
|
|
20073
|
+
function _getFunnelData(d) {
|
|
19545
20074
|
const $$ = this;
|
|
19546
20075
|
const { config } = $$;
|
|
19547
20076
|
const data = d.map((d2) => ({
|
|
@@ -19551,11 +20080,11 @@ function getFunnelData(d) {
|
|
|
19551
20080
|
if (config.data_order) {
|
|
19552
20081
|
data.sort($$.getSortCompareFn.bind($$)(true));
|
|
19553
20082
|
}
|
|
19554
|
-
return
|
|
20083
|
+
return _updateRatio.call($$, data);
|
|
19555
20084
|
}
|
|
19556
|
-
function
|
|
20085
|
+
function _updateRatio(data) {
|
|
19557
20086
|
const $$ = this;
|
|
19558
|
-
const { height } =
|
|
20087
|
+
const { height } = _getSize.call($$);
|
|
19559
20088
|
const total = $$.getTotalDataSum(true);
|
|
19560
20089
|
data.forEach((d) => {
|
|
19561
20090
|
d.ratio = d.value / total * height;
|
|
@@ -19599,7 +20128,7 @@ function updateRatio(data) {
|
|
|
19599
20128
|
$$.showTooltip([data], event.target);
|
|
19600
20129
|
/^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
|
|
19601
20130
|
}
|
|
19602
|
-
}).on(isTouch ? "touchend" : "mouseout", (event) => {
|
|
20131
|
+
}, isTouch ? { passive: true } : void 0).on(isTouch ? "touchend" : "mouseout", (event) => {
|
|
19603
20132
|
const data = getTarget(event);
|
|
19604
20133
|
if (config.interaction_onout) {
|
|
19605
20134
|
$$.hideTooltip();
|
|
@@ -19621,7 +20150,7 @@ function updateRatio(data) {
|
|
|
19621
20150
|
if (!funnel) {
|
|
19622
20151
|
$$.initFunnel();
|
|
19623
20152
|
}
|
|
19624
|
-
const targets =
|
|
20153
|
+
const targets = _getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
|
|
19625
20154
|
const mainFunnelUpdate = funnel.selectAll(`.${$FUNNEL.chartFunnel}`).data($$.filterNullish(targets));
|
|
19626
20155
|
mainFunnelUpdate.exit().remove();
|
|
19627
20156
|
const mainFunnelEnter = mainFunnelUpdate.enter().insert("g", `.${$FUNNEL.funnelBackground}`);
|
|
@@ -19648,7 +20177,7 @@ function updateRatio(data) {
|
|
|
19648
20177
|
const $$ = this;
|
|
19649
20178
|
const { $el: { funnel } } = $$;
|
|
19650
20179
|
const targets = $$.filterTargetsToShow(funnel.path);
|
|
19651
|
-
const { top, left, right } =
|
|
20180
|
+
const { top, left, right } = _getSize.call($$);
|
|
19652
20181
|
const center = (left - right) / 2;
|
|
19653
20182
|
const points = {};
|
|
19654
20183
|
let accumulatedHeight = top != null ? top : 0;
|
|
@@ -19669,9 +20198,9 @@ function updateRatio(data) {
|
|
|
19669
20198
|
const $$ = this;
|
|
19670
20199
|
const { $T, $el: { funnel } } = $$;
|
|
19671
20200
|
const targets = $$.filterTargetsToShow(funnel.path);
|
|
19672
|
-
const coords =
|
|
19673
|
-
funnel.attr("clip-path", `path('${
|
|
19674
|
-
funnel.background.attr("d",
|
|
20201
|
+
const coords = _getCoord.call($$, _updateRatio.call($$, targets.data()));
|
|
20202
|
+
funnel.attr("clip-path", `path('${_getClipPath.bind($$)()}')`);
|
|
20203
|
+
funnel.background.attr("d", _getClipPath.call($$, true));
|
|
19675
20204
|
$T(targets).attr("d", (d, i) => `M${coords[i].join("L")}z`).style("opacity", "1");
|
|
19676
20205
|
funnel.selectAll("g").style("opacity", null);
|
|
19677
20206
|
}
|
|
@@ -19779,7 +20308,7 @@ var line_spreadProps = (a, b) => line_defProps(a, line_getOwnPropDescs(b));
|
|
|
19779
20308
|
|
|
19780
20309
|
|
|
19781
20310
|
|
|
19782
|
-
function
|
|
20311
|
+
function _getStrokeDashArray(start, end, pattern, isLastX = false) {
|
|
19783
20312
|
const dash = start ? [start, 0] : pattern;
|
|
19784
20313
|
for (let i = start ? start : pattern.reduce((a, c) => a + c); i <= end; ) {
|
|
19785
20314
|
pattern.forEach((v) => {
|
|
@@ -19795,7 +20324,7 @@ function getStrokeDashArray(start, end, pattern, isLastX = false) {
|
|
|
19795
20324
|
length: dash.reduce((a, b) => a + b, 0)
|
|
19796
20325
|
};
|
|
19797
20326
|
}
|
|
19798
|
-
function
|
|
20327
|
+
function _getRegions(d, _regions, isTimeSeries) {
|
|
19799
20328
|
const $$ = this;
|
|
19800
20329
|
const regions = [];
|
|
19801
20330
|
const dasharray = "2 2";
|
|
@@ -19850,7 +20379,7 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
19850
20379
|
},
|
|
19851
20380
|
/**
|
|
19852
20381
|
* Redraw function
|
|
19853
|
-
* @param {
|
|
20382
|
+
* @param {function} drawFn Retuned functino from .generateDrawCandlestick()
|
|
19854
20383
|
* @param {boolean} withTransition With or without transition
|
|
19855
20384
|
* @param {boolean} isSub Subchart draw
|
|
19856
20385
|
* @returns {Array}
|
|
@@ -19867,7 +20396,7 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
19867
20396
|
/**
|
|
19868
20397
|
* Get the curve interpolate
|
|
19869
20398
|
* @param {Array} d Data object
|
|
19870
|
-
* @returns {
|
|
20399
|
+
* @returns {function}
|
|
19871
20400
|
* @private
|
|
19872
20401
|
*/
|
|
19873
20402
|
getCurve(d) {
|
|
@@ -19937,8 +20466,8 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
19937
20466
|
/**
|
|
19938
20467
|
* Set regions dasharray and get path
|
|
19939
20468
|
* @param {Array} d Data object
|
|
19940
|
-
* @param {
|
|
19941
|
-
* @param {
|
|
20469
|
+
* @param {function} x x scale function
|
|
20470
|
+
* @param {function} y y scale function
|
|
19942
20471
|
* @param {object} _regions regions to be set
|
|
19943
20472
|
* @returns {stirng} Path string
|
|
19944
20473
|
* @private
|
|
@@ -19949,7 +20478,7 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
19949
20478
|
const isRotated = config.axis_rotated;
|
|
19950
20479
|
const isTimeSeries = $$.axis.isTimeSeries();
|
|
19951
20480
|
const dasharray = "2 2";
|
|
19952
|
-
const regions =
|
|
20481
|
+
const regions = _getRegions.bind($$)(d, _regions, isTimeSeries);
|
|
19953
20482
|
const hasNullDataValue = $$.hasNullDataValue(d);
|
|
19954
20483
|
let xp;
|
|
19955
20484
|
let yp;
|
|
@@ -20045,7 +20574,7 @@ function getRegions(d, _regions, isTimeSeries) {
|
|
|
20045
20574
|
isRotated && points.forEach((v) => v.reverse());
|
|
20046
20575
|
const startLength = getLength(tempNode, path);
|
|
20047
20576
|
const endLength = getLength(tempNode, path += `L${points[1].join(",")}`);
|
|
20048
|
-
const strokeDashArray =
|
|
20577
|
+
const strokeDashArray = _getStrokeDashArray(
|
|
20049
20578
|
startLength - dashArray.lastLength,
|
|
20050
20579
|
endLength - dashArray.lastLength,
|
|
20051
20580
|
style,
|
|
@@ -20477,10 +21006,10 @@ const getTransitionName = () => getRandom();
|
|
|
20477
21006
|
|
|
20478
21007
|
|
|
20479
21008
|
|
|
20480
|
-
function
|
|
21009
|
+
function _hasValidPointDrawMethods(point) {
|
|
20481
21010
|
return isObjectType(point) && isFunction(point.create) && isFunction(point.update);
|
|
20482
21011
|
}
|
|
20483
|
-
function
|
|
21012
|
+
function _insertPointInfoDefs(point, id) {
|
|
20484
21013
|
var _a;
|
|
20485
21014
|
const $$ = this;
|
|
20486
21015
|
const copyAttr = (from, target) => {
|
|
@@ -20533,16 +21062,26 @@ function insertPointInfoDefs(point, id) {
|
|
|
20533
21062
|
const { state: { datetimeId } } = this;
|
|
20534
21063
|
return `${datetimeId}-point${id}`;
|
|
20535
21064
|
},
|
|
21065
|
+
/**
|
|
21066
|
+
* Get validated point pattern array
|
|
21067
|
+
* @returns {Array} Array of point types
|
|
21068
|
+
* @private
|
|
21069
|
+
*/
|
|
21070
|
+
getValidPointPattern() {
|
|
21071
|
+
const { config } = this;
|
|
21072
|
+
const validPointType = /^(circle|rect(angle)?)$/i.test(config.point_type) ? config.point_type : "circle";
|
|
21073
|
+
return notEmpty(config.point_pattern) ? config.point_pattern : [validPointType];
|
|
21074
|
+
},
|
|
20536
21075
|
/**
|
|
20537
21076
|
* Get generate point function
|
|
20538
|
-
* @returns {
|
|
21077
|
+
* @returns {function}
|
|
20539
21078
|
* @private
|
|
20540
21079
|
*/
|
|
20541
21080
|
generatePoint() {
|
|
20542
21081
|
const $$ = this;
|
|
20543
21082
|
const { $el, config } = $$;
|
|
20544
21083
|
const ids = [];
|
|
20545
|
-
const pattern =
|
|
21084
|
+
const pattern = $$.getValidPointPattern();
|
|
20546
21085
|
return function(method, context, ...args) {
|
|
20547
21086
|
return function(d) {
|
|
20548
21087
|
var _a, _b, _c, _d;
|
|
@@ -20552,11 +21091,11 @@ function insertPointInfoDefs(point, id) {
|
|
|
20552
21091
|
let point = pattern[ids.indexOf(id) % pattern.length];
|
|
20553
21092
|
if ($$.hasValidPointType(point)) {
|
|
20554
21093
|
point = $$[point];
|
|
20555
|
-
} else if (!
|
|
21094
|
+
} else if (!_hasValidPointDrawMethods(point || config.point_type)) {
|
|
20556
21095
|
const pointId = $$.getDefsPointId(id);
|
|
20557
21096
|
const defsPoint = $el.defs.select(`#${pointId}`);
|
|
20558
21097
|
if (defsPoint.size() < 1) {
|
|
20559
|
-
|
|
21098
|
+
_insertPointInfoDefs.call($$, point, pointId);
|
|
20560
21099
|
}
|
|
20561
21100
|
if (method === "create") {
|
|
20562
21101
|
return (_b = $$.custom) == null ? void 0 : _b.create.bind(context)(element, pointId, ...args);
|
|
@@ -20658,7 +21197,7 @@ function getDataMax($$) {
|
|
|
20658
21197
|
|
|
20659
21198
|
|
|
20660
21199
|
|
|
20661
|
-
function
|
|
21200
|
+
function _getPosition(isClockwise, type, edge, pos, range, ratio) {
|
|
20662
21201
|
const index = isClockwise && pos > 0 ? edge - pos : pos;
|
|
20663
21202
|
const r = 2 * Math.PI;
|
|
20664
21203
|
const func = type === "x" ? Math.sin : Math.cos;
|
|
@@ -20707,7 +21246,7 @@ const cacheKeyTextWidth = KEY.radarTextWidth;
|
|
|
20707
21246
|
const edge = config.axis_x_categories.length;
|
|
20708
21247
|
const isClockwise = config.radar_direction_clockwise;
|
|
20709
21248
|
const pos = toArray(type).map(
|
|
20710
|
-
(v) =>
|
|
21249
|
+
(v) => _getPosition(
|
|
20711
21250
|
isClockwise,
|
|
20712
21251
|
v,
|
|
20713
21252
|
edge,
|
|
@@ -20884,9 +21423,9 @@ const cacheKeyTextWidth = KEY.radarTextWidth;
|
|
|
20884
21423
|
const index = $$.getDataIndexFromEvent(event);
|
|
20885
21424
|
$$.selectRectForSingle(svg.node(), index);
|
|
20886
21425
|
isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
|
|
20887
|
-
}).on("mouseout", isMouse ? hide : null);
|
|
21426
|
+
}, isMouse ? void 0 : { passive: true }).on("mouseout", isMouse ? hide : null);
|
|
20888
21427
|
if (!isMouse) {
|
|
20889
|
-
svg.on("touchstart", hide);
|
|
21428
|
+
svg.on("touchstart", hide, { passive: true });
|
|
20890
21429
|
}
|
|
20891
21430
|
},
|
|
20892
21431
|
updateRadarShape() {
|
|
@@ -20998,7 +21537,7 @@ function getHierachyData(data) {
|
|
|
20998
21537
|
$$.showTooltip([data], event.currentTarget);
|
|
20999
21538
|
/^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
|
|
21000
21539
|
}
|
|
21001
|
-
}).on(isTouch ? "touchend" : "mouseout", (event) => {
|
|
21540
|
+
}, isTouch ? { passive: true } : void 0).on(isTouch ? "touchend" : "mouseout", (event) => {
|
|
21002
21541
|
const data = getTarget(event);
|
|
21003
21542
|
if (config.interaction_onout) {
|
|
21004
21543
|
$$.hideTooltip();
|
|
@@ -21009,7 +21548,7 @@ function getHierachyData(data) {
|
|
|
21009
21548
|
},
|
|
21010
21549
|
/**
|
|
21011
21550
|
* Get tiling function
|
|
21012
|
-
* @returns {
|
|
21551
|
+
* @returns {function}
|
|
21013
21552
|
* @private
|
|
21014
21553
|
*/
|
|
21015
21554
|
getTreemapTile() {
|
|
@@ -21110,20 +21649,28 @@ function getHierachyData(data) {
|
|
|
21110
21649
|
/**
|
|
21111
21650
|
* Get treemap data label format function
|
|
21112
21651
|
* @param {object} d Data object
|
|
21113
|
-
* @returns {
|
|
21652
|
+
* @returns {function} Label formatter function
|
|
21114
21653
|
* @private
|
|
21115
21654
|
*/
|
|
21116
21655
|
treemapDataLabelFormat(d) {
|
|
21117
21656
|
const $$ = this;
|
|
21118
|
-
const { config } = $$;
|
|
21657
|
+
const { $el: { treemap }, config, scale: { x, y } } = $$;
|
|
21119
21658
|
const { id, value } = d;
|
|
21120
21659
|
const format = config.treemap_label_format;
|
|
21121
21660
|
const ratio = $$.getRatio("treemap", d);
|
|
21122
21661
|
const percentValue = (ratio * 100).toFixed(2);
|
|
21123
21662
|
const meetLabelThreshold = config.treemap_label_show && meetsLabelThreshold.call($$, ratio, "treemap") ? null : "0";
|
|
21663
|
+
const treemapNode = treemap.selectAll("g").filter((node) => node.data.id === id).datum();
|
|
21664
|
+
let width = 0;
|
|
21665
|
+
let height = 0;
|
|
21666
|
+
if (treemapNode) {
|
|
21667
|
+
const { x0, x1, y0, y1 } = treemapNode;
|
|
21668
|
+
width = x(x1) - x(x0);
|
|
21669
|
+
height = y(y1) - y(y0);
|
|
21670
|
+
}
|
|
21124
21671
|
return function(node) {
|
|
21125
21672
|
node.style("opacity", meetLabelThreshold);
|
|
21126
|
-
return isFunction(format) ? format.bind($$.api)(value, ratio, id) : `${id}
|
|
21673
|
+
return isFunction(format) ? format.bind($$.api)(value, ratio, id, { width, height }) : `${id}
|
|
21127
21674
|
${percentValue}%`;
|
|
21128
21675
|
};
|
|
21129
21676
|
}
|
|
@@ -21138,7 +21685,7 @@ ${percentValue}%`;
|
|
|
21138
21685
|
* @type {object}
|
|
21139
21686
|
* @property {object} point Point object
|
|
21140
21687
|
* @property {boolean} [point.show=true] Whether to show each point in line.
|
|
21141
|
-
* @property {number|
|
|
21688
|
+
* @property {number|function} [point.r=2.5] The radius size of each point.
|
|
21142
21689
|
* - **NOTE:** Disabled for 'bubble' type
|
|
21143
21690
|
* @property {boolean|object} [point.radialGradient=false] Set the radial gradient on point.<br><br>
|
|
21144
21691
|
* Or customize by giving below object value:
|
|
@@ -21155,7 +21702,7 @@ ${percentValue}%`;
|
|
|
21155
21702
|
* - **NOTE:**
|
|
21156
21703
|
* - `null` will make to not set inline 'opacity' css prop.
|
|
21157
21704
|
* - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
|
|
21158
|
-
* @property {number|string|
|
|
21705
|
+
* @property {number|string|function} [point.sensitivity=10] The sensitivity value for interaction boundary.
|
|
21159
21706
|
* - **Available Values:**
|
|
21160
21707
|
* - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
|
|
21161
21708
|
* - "radius": sensitivity based on point's radius
|
|
@@ -21182,6 +21729,7 @@ ${percentValue}%`;
|
|
|
21182
21729
|
* - This is an `experimental` feature and can have some unexpected behaviors.
|
|
21183
21730
|
* - If chart has 'bubble' type, only circle can be used.
|
|
21184
21731
|
* - For IE, non circle point expansions are not supported due to lack of transform support.
|
|
21732
|
+
* - 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.
|
|
21185
21733
|
* - **Available Values:**
|
|
21186
21734
|
* - circle
|
|
21187
21735
|
* - rectangle
|
|
@@ -21202,7 +21750,7 @@ ${percentValue}%`;
|
|
|
21202
21750
|
* return r;
|
|
21203
21751
|
* },
|
|
21204
21752
|
*
|
|
21205
|
-
* // will generate
|
|
21753
|
+
* // will generate following radialGradient:
|
|
21206
21754
|
* // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient
|
|
21207
21755
|
* // <radualGradient cx="0.3" cy="0.3" r="0.7">
|
|
21208
21756
|
* // <stop offset="0.1" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
@@ -21318,7 +21866,7 @@ ${percentValue}%`;
|
|
|
21318
21866
|
* // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
|
|
21319
21867
|
* front: false,
|
|
21320
21868
|
*
|
|
21321
|
-
* // will generate
|
|
21869
|
+
* // will generate following linearGradient:
|
|
21322
21870
|
* // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
|
|
21323
21871
|
* // <linearGradient x1="0" x2="0" y1="0" y2="1">
|
|
21324
21872
|
* // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
@@ -21372,8 +21920,8 @@ ${percentValue}%`;
|
|
|
21372
21920
|
* @property {number} [bar.padding=0] The padding pixel value between each bar.
|
|
21373
21921
|
* @property {number} [bar.radius] Set the radius of bar edge in pixel.
|
|
21374
21922
|
* @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
|
|
21375
|
-
* @property {number} [bar.sensitivity=2] The
|
|
21376
|
-
* @property {number|
|
|
21923
|
+
* @property {number} [bar.sensitivity=2] The sensitivity offset value for interaction boundary.
|
|
21924
|
+
* @property {number|function|object} [bar.width] Change the width of bar chart.
|
|
21377
21925
|
* @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
|
|
21378
21926
|
* - **NOTE:** Criteria for ratio.
|
|
21379
21927
|
* - When x ticks count is same with the data count, the baseline for ratio is the minimum interval value of x ticks.
|
|
@@ -21400,12 +21948,12 @@ ${percentValue}%`;
|
|
|
21400
21948
|
* // make bar shape to be positioned over the other shape elements
|
|
21401
21949
|
* front: true,
|
|
21402
21950
|
*
|
|
21403
|
-
* // remove nullish data on bar indices
|
|
21951
|
+
* // remove nullish data on bar indices positions
|
|
21404
21952
|
* indices: {
|
|
21405
21953
|
* removeNull: true
|
|
21406
21954
|
* },
|
|
21407
21955
|
*
|
|
21408
|
-
* // will generate
|
|
21956
|
+
* // will generate following linearGradient:
|
|
21409
21957
|
* // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
|
|
21410
21958
|
* // <linearGradient x1="0" x2="0" y1="0" y2="1">
|
|
21411
21959
|
* // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
@@ -21503,12 +22051,12 @@ ${percentValue}%`;
|
|
|
21503
22051
|
* @memberof Options
|
|
21504
22052
|
* @type {object}
|
|
21505
22053
|
* @property {object} bubble bubble object
|
|
21506
|
-
* @property {number|
|
|
22054
|
+
* @property {number|function} [bubble.maxR=35] Set the max bubble radius value
|
|
21507
22055
|
* @property {boolean} [bubble.zerobased=false] Set if min or max value will be 0 on bubble chart.
|
|
21508
22056
|
* @example
|
|
21509
22057
|
* bubble: {
|
|
21510
22058
|
* // ex) If 100 is the highest value among data bound, the representation bubble of 100 will have radius of 50.
|
|
21511
|
-
* // And the lesser will have radius relatively from
|
|
22059
|
+
* // And the lesser will have radius relatively from the max value.
|
|
21512
22060
|
* maxR: 50,
|
|
21513
22061
|
*
|
|
21514
22062
|
* // or set radius callback
|
|
@@ -21562,7 +22110,7 @@ ${percentValue}%`;
|
|
|
21562
22110
|
* }
|
|
21563
22111
|
* },
|
|
21564
22112
|
* color: {
|
|
21565
|
-
* //
|
|
22113
|
+
* // specify bearish color
|
|
21566
22114
|
* down: "red",
|
|
21567
22115
|
*
|
|
21568
22116
|
* // or specify color per dataset
|
|
@@ -21615,7 +22163,7 @@ ${percentValue}%`;
|
|
|
21615
22163
|
* // hide all data points ('point.show=false' also has similar effect)
|
|
21616
22164
|
* point: false,
|
|
21617
22165
|
*
|
|
21618
|
-
* // show data points for only indicated
|
|
22166
|
+
* // show data points for only indicated data
|
|
21619
22167
|
* point: [
|
|
21620
22168
|
* "data1", "data3"
|
|
21621
22169
|
* ],
|
|
@@ -21650,7 +22198,7 @@ ${percentValue}%`;
|
|
|
21650
22198
|
* // hide all data points ('point.show=false' also has similar effect)
|
|
21651
22199
|
* point: false,
|
|
21652
22200
|
*
|
|
21653
|
-
* // show data points for only indicated
|
|
22201
|
+
* // show data points for only indicated data
|
|
21654
22202
|
* point: [
|
|
21655
22203
|
* "data1", "data3"
|
|
21656
22204
|
* ],
|
|
@@ -21709,14 +22257,14 @@ ${percentValue}%`;
|
|
|
21709
22257
|
* @memberof Options
|
|
21710
22258
|
* @type {object}
|
|
21711
22259
|
* @property {object} arc Arc object
|
|
21712
|
-
* @property {number|
|
|
22260
|
+
* @property {number|function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
|
|
21713
22261
|
* - **NOTE:**
|
|
21714
22262
|
* - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
|
|
21715
22263
|
* @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
|
|
21716
22264
|
* @property {object} [arc.needle] Set needle options.
|
|
21717
22265
|
* @property {boolean} [arc.needle.show=false] Show or hide needle.
|
|
21718
22266
|
* @property {string} [arc.needle.color] Set needle filled color.
|
|
21719
|
-
* @property {
|
|
22267
|
+
* @property {function} [arc.needle.path] Set custom needle path function.
|
|
21720
22268
|
* - **NOTE:**
|
|
21721
22269
|
* - The path should be starting from 0,0 (which is center) to top center coordinate.
|
|
21722
22270
|
* - The function will receive, `length`{number} parameter which indicating the needle length in pixel relative to radius.
|
|
@@ -21740,8 +22288,8 @@ ${percentValue}%`;
|
|
|
21740
22288
|
* @property {string} [arc.rangeText.unit="absolute"] Specify the range text unit.
|
|
21741
22289
|
* - "absolute": Show absolute value
|
|
21742
22290
|
* - "%": Show percentage value
|
|
21743
|
-
* @property {boolean} [arc.rangeText.
|
|
21744
|
-
* @property {
|
|
22291
|
+
* @property {boolean} [arc.rangeText.fixed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
|
|
22292
|
+
* @property {function} [arc.rangeText.format] Set format function for the range text.
|
|
21745
22293
|
* @property {number} [arc.rangeText.position] Set position function or object for the range text.
|
|
21746
22294
|
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
21747
22295
|
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
|
|
@@ -21854,10 +22402,21 @@ ${percentValue}%`;
|
|
|
21854
22402
|
* @type {object}
|
|
21855
22403
|
* @property {object} donut Donut object
|
|
21856
22404
|
* @property {boolean} [donut.label.show=true] Show or hide label on each donut piece.
|
|
21857
|
-
* @property {
|
|
22405
|
+
* @property {function} [donut.label.format] Set formatter for the label on each donut piece.
|
|
21858
22406
|
* @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
21859
|
-
* @property {number|
|
|
21860
|
-
* @property {object
|
|
22407
|
+
* @property {number|function} [donut.label.ratio=undefined] Set ratio of labels position.
|
|
22408
|
+
* @property {boolean|object} [donut.label.line=false] Enable label with lines (displayed outside with connector lines).
|
|
22409
|
+
* - `true`: Enable label with lines with default settings
|
|
22410
|
+
* - `false`: Labels are displayed inside the donut slices (default behavior).
|
|
22411
|
+
* - `{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.
|
|
22412
|
+
* @property {boolean} [donut.label.line.show=true] Show or hide connector lines.
|
|
22413
|
+
* @property {number} [donut.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
|
|
22414
|
+
* @property {boolean|function} [donut.label.line.text=true] Show text at the end of the connector line (outside the shape).
|
|
22415
|
+
* - `true`: show data "id" text
|
|
22416
|
+
* - `false`: use default formatter(label.format) to show text
|
|
22417
|
+
* - `function(value, ratio, id)`: Custom formatter function for the text.
|
|
22418
|
+
* - **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.
|
|
22419
|
+
* @property {object|function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
|
|
21861
22420
|
* 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>
|
|
21862
22421
|
* The arguments are:<br>
|
|
21863
22422
|
* - `v` is the value of the data point where the label is shown.
|
|
@@ -21882,6 +22441,7 @@ ${percentValue}%`;
|
|
|
21882
22441
|
* @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
|
|
21883
22442
|
* @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
|
|
21884
22443
|
* @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
|
|
22444
|
+
* @see [Demo: Label Line](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelLine)
|
|
21885
22445
|
* @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
|
|
21886
22446
|
* @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
|
|
21887
22447
|
* @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
|
|
@@ -21911,6 +22471,20 @@ ${percentValue}%`;
|
|
|
21911
22471
|
* // or set ratio number
|
|
21912
22472
|
* ratio: 0.5,
|
|
21913
22473
|
*
|
|
22474
|
+
* // Enable label with lines (displayed outside with connector lines)
|
|
22475
|
+
* line: false, // default - labels inside
|
|
22476
|
+
* line: true, // enable label with lines with default settings
|
|
22477
|
+
* line: { // enable label with lines with custom settings
|
|
22478
|
+
* show: true,
|
|
22479
|
+
* distance: 20, // horizontal line distance in pixels
|
|
22480
|
+
*
|
|
22481
|
+
* // show text at the end of connector line (outside the shape)
|
|
22482
|
+
* text: true, // use default formatter
|
|
22483
|
+
* text: function(value, ratio, id) { // custom formatter
|
|
22484
|
+
* return d3.format(".1%")(ratio);
|
|
22485
|
+
* }
|
|
22486
|
+
* },
|
|
22487
|
+
*
|
|
21914
22488
|
* // set image to be displayed next to the label text
|
|
21915
22489
|
* image: {
|
|
21916
22490
|
* url: "./sample.svg",
|
|
@@ -21982,6 +22556,7 @@ ${percentValue}%`;
|
|
|
21982
22556
|
donut_label_show: true,
|
|
21983
22557
|
donut_label_format: void 0,
|
|
21984
22558
|
donut_label_threshold: 0.05,
|
|
22559
|
+
donut_label_line: false,
|
|
21985
22560
|
donut_label_image: void 0,
|
|
21986
22561
|
donut_label_ratio: void 0,
|
|
21987
22562
|
donut_width: void 0,
|
|
@@ -22037,15 +22612,27 @@ ${percentValue}%`;
|
|
|
22037
22612
|
* @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
|
|
22038
22613
|
* @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.
|
|
22039
22614
|
* @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
|
|
22040
|
-
* @property {
|
|
22041
|
-
* @property {
|
|
22615
|
+
* @property {function} [gauge.label.extents] Set customized min/max label text.
|
|
22616
|
+
* @property {function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
|
|
22042
22617
|
* Will pass following arguments to the given function:
|
|
22043
22618
|
* - value {number}: absolute value
|
|
22044
22619
|
* - ratio {number}: value's ratio
|
|
22045
22620
|
* - id {string}: data's id value
|
|
22046
|
-
* @property {number|
|
|
22621
|
+
* @property {number|function} [gauge.label.ratio=undefined] Set ratio of labels position.
|
|
22047
22622
|
* @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
22048
|
-
* @property {object
|
|
22623
|
+
* @property {boolean|object} [gauge.label.line=false] Enable label with lines (displayed outside with connector lines).
|
|
22624
|
+
* - **NOTE:** Only applicable for single gauge (not for `gauge.type="multi"`).
|
|
22625
|
+
* - `true`: Enable label with lines with default settings
|
|
22626
|
+
* - `false`: Labels are displayed inside the gauge (default behavior).
|
|
22627
|
+
* - `{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.
|
|
22628
|
+
* @property {boolean} [gauge.label.line.show=true] Show or hide connector lines.
|
|
22629
|
+
* @property {number} [gauge.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
|
|
22630
|
+
* @property {boolean|function} [gauge.label.line.text=true] Show text at the end of the connector line (outside the shape).
|
|
22631
|
+
* - `true`: show data "id" text
|
|
22632
|
+
* - `false`: use default formatter(label.format) to show text
|
|
22633
|
+
* - `function(value, ratio, id)`: Custom formatter function for the text.
|
|
22634
|
+
* - **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.
|
|
22635
|
+
* @property {object|function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22049
22636
|
* 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>
|
|
22050
22637
|
* The arguments are:<br>
|
|
22051
22638
|
* - `v` is the value of the data point where the label is shown.
|
|
@@ -22098,6 +22685,7 @@ ${percentValue}%`;
|
|
|
22098
22685
|
* @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
|
|
22099
22686
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
|
|
22100
22687
|
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
|
|
22688
|
+
* @see [Demo: label line](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelLine)
|
|
22101
22689
|
* @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
|
|
22102
22690
|
* @example
|
|
22103
22691
|
* gauge: {
|
|
@@ -22120,6 +22708,20 @@ ${percentValue}%`;
|
|
|
22120
22708
|
* // if data value is below than 0.1, text label will be hidden.
|
|
22121
22709
|
* threshold: 0.1,
|
|
22122
22710
|
*
|
|
22711
|
+
* // Enable label with lines (displayed outside with connector lines)
|
|
22712
|
+
* // NOTE: Only works with single gauge (not gauge.type="multi")
|
|
22713
|
+
* line: true, // enable label with lines with default settings
|
|
22714
|
+
* line: { // enable label with lines with custom settings
|
|
22715
|
+
* show: true, // enable lines (default: true when line is enabled)
|
|
22716
|
+
* distance: 30, // distance of horizontal line in pixels (default: 20)
|
|
22717
|
+
*
|
|
22718
|
+
* // show text at the end of connector line (outside the shape)
|
|
22719
|
+
* text: true, // use default formatter
|
|
22720
|
+
* text: function(value, ratio, id) { // custom formatter
|
|
22721
|
+
* return d3.format(".1%")(ratio);
|
|
22722
|
+
* }
|
|
22723
|
+
* },
|
|
22724
|
+
*
|
|
22123
22725
|
* // set ratio callback. Should return ratio value
|
|
22124
22726
|
* ratio: function(d, radius, h) {
|
|
22125
22727
|
* ...
|
|
@@ -22213,6 +22815,7 @@ ${percentValue}%`;
|
|
|
22213
22815
|
gauge_label_format: void 0,
|
|
22214
22816
|
gauge_label_ratio: void 0,
|
|
22215
22817
|
gauge_label_threshold: 0,
|
|
22818
|
+
gauge_label_line: false,
|
|
22216
22819
|
gauge_label_image: void 0,
|
|
22217
22820
|
gauge_enforceMinMax: false,
|
|
22218
22821
|
gauge_min: 0,
|
|
@@ -22238,10 +22841,21 @@ ${percentValue}%`;
|
|
|
22238
22841
|
* @type {object}
|
|
22239
22842
|
* @property {object} pie Pie object
|
|
22240
22843
|
* @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
|
|
22241
|
-
* @property {
|
|
22242
|
-
* @property {number|
|
|
22844
|
+
* @property {function} [pie.label.format] Set formatter for the label on each pie piece.
|
|
22845
|
+
* @property {number|function} [pie.label.ratio=undefined] Set ratio of labels position.
|
|
22243
22846
|
* @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
22244
|
-
* @property {object
|
|
22847
|
+
* @property {boolean|object} [pie.label.line=false] Enable label with lines (displayed outside with connector lines).
|
|
22848
|
+
* - `true`: Enable label with lines with default settings
|
|
22849
|
+
* - `false`: Labels are displayed inside the pie slices (default behavior).
|
|
22850
|
+
* - `{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.
|
|
22851
|
+
* @property {boolean} [pie.label.line.show=true] Show or hide connector lines.
|
|
22852
|
+
* @property {number} [pie.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
|
|
22853
|
+
* @property {boolean|function} [pie.label.line.text=true] Show text at the end of the connector line (outside the shape).
|
|
22854
|
+
* - `true`: show data "id" text
|
|
22855
|
+
* - `false`: use default formatter(label.format) to show text
|
|
22856
|
+
* - `function(value, ratio, id)`: Custom formatter function for the text.
|
|
22857
|
+
* - **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.
|
|
22858
|
+
* @property {object|function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22245
22859
|
* 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>
|
|
22246
22860
|
* The arguments are:<br>
|
|
22247
22861
|
* - `v` is the value of the data point where the label is shown.
|
|
@@ -22266,6 +22880,7 @@ ${percentValue}%`;
|
|
|
22266
22880
|
* @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
|
|
22267
22881
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
|
|
22268
22882
|
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
|
|
22883
|
+
* @see [Demo: label line](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelLine)
|
|
22269
22884
|
* @example
|
|
22270
22885
|
* pie: {
|
|
22271
22886
|
* label: {
|
|
@@ -22289,6 +22904,20 @@ ${percentValue}%`;
|
|
|
22289
22904
|
* // or set ratio number
|
|
22290
22905
|
* ratio: 0.5,
|
|
22291
22906
|
*
|
|
22907
|
+
* // Enable label with lines (displayed outside with connector lines)
|
|
22908
|
+
* line: false, // default - labels inside
|
|
22909
|
+
* line: true, // enable label with lines with default settings
|
|
22910
|
+
* line: { // enable label with lines with custom settings
|
|
22911
|
+
* show: true,
|
|
22912
|
+
* distance: 20, // horizontal line distance in pixels
|
|
22913
|
+
*
|
|
22914
|
+
* // show text at the end of connector line (outside the shape)
|
|
22915
|
+
* text: true, // use default formatter
|
|
22916
|
+
* text: function(value, ratio, id) { // custom formatter
|
|
22917
|
+
* return d3.format(".1%")(ratio);
|
|
22918
|
+
* }
|
|
22919
|
+
* },
|
|
22920
|
+
*
|
|
22292
22921
|
* // set image to be displayed next to the label text
|
|
22293
22922
|
* image: {
|
|
22294
22923
|
* url: "./sample.svg",
|
|
@@ -22370,6 +22999,7 @@ ${percentValue}%`;
|
|
|
22370
22999
|
pie_label_format: void 0,
|
|
22371
23000
|
pie_label_ratio: void 0,
|
|
22372
23001
|
pie_label_threshold: 0.05,
|
|
23002
|
+
pie_label_line: false,
|
|
22373
23003
|
pie_label_image: void 0,
|
|
22374
23004
|
pie_expand: {},
|
|
22375
23005
|
pie_expand_rate: 0.98,
|
|
@@ -22390,10 +23020,21 @@ ${percentValue}%`;
|
|
|
22390
23020
|
* @type {object}
|
|
22391
23021
|
* @property {object} polar Polar object
|
|
22392
23022
|
* @property {boolean} [polar.label.show=true] Show or hide label on each polar piece.
|
|
22393
|
-
* @property {
|
|
23023
|
+
* @property {function} [polar.label.format] Set formatter for the label on each polar piece.
|
|
22394
23024
|
* @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
22395
|
-
* @property {number|
|
|
22396
|
-
* @property {object
|
|
23025
|
+
* @property {number|function} [polar.label.ratio=undefined] Set ratio of labels position.
|
|
23026
|
+
* @property {boolean|object} [polar.label.line=false] Enable label with lines (displayed outside with connector lines).
|
|
23027
|
+
* - `true`: Enable label with lines with default settings
|
|
23028
|
+
* - `false`: Labels are displayed inside the polar slices (default behavior).
|
|
23029
|
+
* - `{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.
|
|
23030
|
+
* @property {boolean} [polar.label.line.show=true] Show or hide connector lines.
|
|
23031
|
+
* @property {number} [polar.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
|
|
23032
|
+
* @property {boolean|function} [polar.label.line.text=true] Show text at the end of the connector line (outside the shape).
|
|
23033
|
+
* - `true`: show data "id" text
|
|
23034
|
+
* - `false`: use default formatter(label.format) to show text
|
|
23035
|
+
* - `function(value, ratio, id)`: Custom formatter function for the text.
|
|
23036
|
+
* - **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.
|
|
23037
|
+
* @property {object|function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22397
23038
|
* 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>
|
|
22398
23039
|
* The arguments are:<br>
|
|
22399
23040
|
* - `v` is the value of the data point where the label is shown.
|
|
@@ -22408,13 +23049,14 @@ ${percentValue}%`;
|
|
|
22408
23049
|
* @property {number} [polar.level.depth=3] Set the level depth.
|
|
22409
23050
|
* @property {boolean} [polar.level.show=true] Show or hide level.
|
|
22410
23051
|
* @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
|
|
22411
|
-
* @property {
|
|
23052
|
+
* @property {function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
|
|
22412
23053
|
* @property {boolean} [polar.level.text.show=true] Show or hide level text.
|
|
22413
23054
|
* @property {number} [polar.padAngle=0] Set padding between data.
|
|
22414
23055
|
* @property {number} [polar.padding=0] Sets the gap between pie arcs.
|
|
22415
23056
|
* @property {number} [polar.startingAngle=0] Set starting angle where data draws.
|
|
22416
23057
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
|
|
22417
23058
|
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
|
|
23059
|
+
* @see [Demo: label line](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelLine)
|
|
22418
23060
|
* @example
|
|
22419
23061
|
* polar: {
|
|
22420
23062
|
* label: {
|
|
@@ -22438,6 +23080,20 @@ ${percentValue}%`;
|
|
|
22438
23080
|
* // or set ratio number
|
|
22439
23081
|
* ratio: 0.5,
|
|
22440
23082
|
*
|
|
23083
|
+
* // Enable label with lines (displayed outside with connector lines)
|
|
23084
|
+
* line: false, // default - labels inside
|
|
23085
|
+
* line: true, // enable label with lines with default settings
|
|
23086
|
+
* line: { // enable label with lines with custom settings
|
|
23087
|
+
* show: true,
|
|
23088
|
+
* distance: 20, // horizontal line distance in pixels
|
|
23089
|
+
*
|
|
23090
|
+
* // show text at the end of connector line (outside the shape)
|
|
23091
|
+
* text: true, // use default formatter
|
|
23092
|
+
* text: function(value, ratio, id) { // custom formatter
|
|
23093
|
+
* return d3.format(".1%")(ratio);
|
|
23094
|
+
* }
|
|
23095
|
+
* },
|
|
23096
|
+
*
|
|
22441
23097
|
* // set image to be displayed next to the label text
|
|
22442
23098
|
* image: {
|
|
22443
23099
|
* url: "./sample.svg",
|
|
@@ -22502,6 +23158,7 @@ ${percentValue}%`;
|
|
|
22502
23158
|
polar_label_show: true,
|
|
22503
23159
|
polar_label_format: void 0,
|
|
22504
23160
|
polar_label_threshold: 0.05,
|
|
23161
|
+
polar_label_line: false,
|
|
22505
23162
|
polar_label_image: void 0,
|
|
22506
23163
|
polar_label_ratio: void 0,
|
|
22507
23164
|
polar_level_depth: 3,
|
|
@@ -22533,7 +23190,7 @@ ${percentValue}%`;
|
|
|
22533
23190
|
* @property {boolean} [radar.direction.clockwise=false] Set the direction to be drawn.
|
|
22534
23191
|
* @property {number} [radar.level.depth=3] Set the level depth.
|
|
22535
23192
|
* @property {boolean} [radar.level.show=true] Show or hide level.
|
|
22536
|
-
* @property {
|
|
23193
|
+
* @property {function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
|
|
22537
23194
|
* @property {boolean} [radar.level.text.show=true] Show or hide level text.
|
|
22538
23195
|
* @property {number} [radar.size.ratio=0.87] Set size ratio.
|
|
22539
23196
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.RadarChart)
|
|
@@ -22601,7 +23258,12 @@ ${percentValue}%`;
|
|
|
22601
23258
|
* - sliceDice ([d3.treemapSliceDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSliceDice))
|
|
22602
23259
|
* - squrify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
|
|
22603
23260
|
* - resquarify ([d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapResquarify))
|
|
22604
|
-
* @property {
|
|
23261
|
+
* @property {function} [treemap.label.format] Set formatter for the label text.<br>
|
|
23262
|
+
* - **Arguments:**
|
|
23263
|
+
* - `value {number}`: Data value
|
|
23264
|
+
* - `ratio {number}`: The `ratio` of how much space this tile occupies relative to the total area (0~1)
|
|
23265
|
+
* - `id {string}`: Data id
|
|
23266
|
+
* - `size {object}`: Tile size `{width, height}` in pixels
|
|
22605
23267
|
* @property {number} [treemap.label.threshold=0.05] Set threshold ratio to show/hide labels text.
|
|
22606
23268
|
* @property {number} [treemap.label.show=true] Show or hide label text.
|
|
22607
23269
|
* @see [Demo: treemap](https://naver.github.io/billboard.js/demo/#Chart.TreemapChart)
|
|
@@ -22614,12 +23276,33 @@ ${percentValue}%`;
|
|
|
22614
23276
|
* // show or hide label text
|
|
22615
23277
|
* show: false,
|
|
22616
23278
|
*
|
|
22617
|
-
* //
|
|
22618
|
-
* format: function(value, ratio, id) {
|
|
23279
|
+
* // Example 1: Format with currency
|
|
23280
|
+
* format: function(value, ratio, id, size) {
|
|
23281
|
+
* // size: {width, height} - tile size in pixels
|
|
22619
23282
|
* return d3.format("$")(value);
|
|
23283
|
+
* },
|
|
22620
23284
|
*
|
|
22621
|
-
*
|
|
22622
|
-
*
|
|
23285
|
+
* // Example 2: Show different content based on tile size
|
|
23286
|
+
* format: function(value, ratio, id, size) {
|
|
23287
|
+
* if (size.width > 100 && size.height > 50) {
|
|
23288
|
+
* return `${id}\n${d3.format("$")(value)}\n(${(ratio * 100).toFixed(1)}%)`;
|
|
23289
|
+
* } else if (size.width > 50) {
|
|
23290
|
+
* return `${id}\n${d3.format("$")(value)}`;
|
|
23291
|
+
* } else {
|
|
23292
|
+
* return d3.format("$")(value);
|
|
23293
|
+
* }
|
|
23294
|
+
* },
|
|
23295
|
+
*
|
|
23296
|
+
* // Example 3: Include tile dimensions in label
|
|
23297
|
+
* format: function(value, ratio, id, size) {
|
|
23298
|
+
* return `${id}\n${value}\n${size.width.toFixed(0)}x${size.height.toFixed(0)}px`;
|
|
23299
|
+
* },
|
|
23300
|
+
*
|
|
23301
|
+
* // Example 4: Conditional formatting based on ratio
|
|
23302
|
+
* format: function(value, ratio, id, size) {
|
|
23303
|
+
* return ratio > 0.1 ?
|
|
23304
|
+
* `${id}\n${value} (${(ratio * 100).toFixed(1)}%)` :
|
|
23305
|
+
* value;
|
|
22623
23306
|
* },
|
|
22624
23307
|
*
|
|
22625
23308
|
* // set ratio number
|
|
@@ -22728,10 +23411,10 @@ const bb = {
|
|
|
22728
23411
|
* bb.version; // "1.0.0"
|
|
22729
23412
|
* @memberof bb
|
|
22730
23413
|
*/
|
|
22731
|
-
version: "3.
|
|
23414
|
+
version: "3.18.0-next.2",
|
|
22732
23415
|
/**
|
|
22733
23416
|
* Generate chart
|
|
22734
|
-
* - **NOTE:** Bear in mind for the
|
|
23417
|
+
* - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when:
|
|
22735
23418
|
* - Unused option value is given.
|
|
22736
23419
|
* - ex) For `data.type="pie"` option, setting 'axis' option can cause unexpected generation error.
|
|
22737
23420
|
* - Insufficient value is given for certain option used.
|