billboard.js 3.17.4 → 3.18.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/CONTRIBUTING.md +12 -12
  2. package/README.md +12 -12
  3. package/dist/billboard.css +15 -1
  4. package/dist/billboard.js +1146 -463
  5. package/dist/billboard.min.css +2 -2
  6. package/dist/billboard.min.js +10 -10
  7. package/dist/billboard.pkgd.js +1147 -464
  8. package/dist/billboard.pkgd.min.js +21 -21
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-sparkline.js +117 -26
  12. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  13. package/dist/plugin/billboardjs-plugin-stanford.js +119 -28
  14. package/dist/plugin/billboardjs-plugin-stanford.min.js +10 -10
  15. package/dist/plugin/billboardjs-plugin-tableview.js +117 -27
  16. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  17. package/dist/plugin/billboardjs-plugin-textoverlap.js +116 -26
  18. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +117 -26
  22. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +120 -29
  24. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +14 -14
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +117 -27
  26. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -12
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +116 -26
  28. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +10 -10
  29. package/dist/theme/dark.css +15 -1
  30. package/dist/theme/dark.min.css +2 -2
  31. package/dist/theme/datalab.css +15 -1
  32. package/dist/theme/datalab.min.css +2 -2
  33. package/dist/theme/graph.css +15 -1
  34. package/dist/theme/graph.min.css +2 -2
  35. package/dist/theme/insight.css +15 -1
  36. package/dist/theme/insight.min.css +2 -2
  37. package/dist/theme/modern.css +15 -1
  38. package/dist/theme/modern.min.css +2 -2
  39. package/dist-esm/billboard.js +1467 -536
  40. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -2
  42. package/dist-esm/plugin/billboardjs-plugin-stanford.js +5 -4
  43. package/dist-esm/plugin/billboardjs-plugin-tableview.js +94 -16
  44. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  45. package/package.json +38 -37
  46. package/src/Chart/Chart.ts +1 -1
  47. package/src/Chart/api/chart.ts +5 -5
  48. package/src/Chart/api/data.ts +2 -1
  49. package/src/Chart/api/export.ts +1 -1
  50. package/src/Chart/api/flow.ts +1 -1
  51. package/src/Chart/api/load.ts +3 -3
  52. package/src/Chart/api/subchart.ts +3 -3
  53. package/src/Chart/api/tooltip.ts +1 -1
  54. package/src/Chart/api/zoom.ts +1 -1
  55. package/src/ChartInternal/Axis/Axis.ts +1 -1
  56. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  57. package/src/ChartInternal/ChartInternal.ts +3 -2
  58. package/src/ChartInternal/data/IData.ts +3 -0
  59. package/src/ChartInternal/data/convert.helper.ts +1 -1
  60. package/src/ChartInternal/data/convert.ts +9 -8
  61. package/src/ChartInternal/data/data.ts +135 -17
  62. package/src/ChartInternal/data/load.ts +8 -8
  63. package/src/ChartInternal/interactions/drag.ts +53 -42
  64. package/src/ChartInternal/interactions/eventrect.ts +15 -5
  65. package/src/ChartInternal/interactions/flow.ts +1 -1
  66. package/src/ChartInternal/interactions/interaction.ts +1 -1
  67. package/src/ChartInternal/interactions/zoom.ts +24 -20
  68. package/src/ChartInternal/internals/color.ts +27 -10
  69. package/src/ChartInternal/internals/domain.ts +22 -5
  70. package/src/ChartInternal/internals/format.ts +4 -4
  71. package/src/ChartInternal/internals/grid.ts +11 -11
  72. package/src/ChartInternal/internals/legend.ts +80 -19
  73. package/src/ChartInternal/internals/scale.ts +6 -6
  74. package/src/ChartInternal/internals/selection.ts +1 -1
  75. package/src/ChartInternal/internals/style.ts +3 -3
  76. package/src/ChartInternal/internals/text.arc.ts +304 -0
  77. package/src/ChartInternal/internals/text.ts +44 -14
  78. package/src/ChartInternal/internals/text.util.ts +19 -0
  79. package/src/ChartInternal/internals/title.ts +3 -3
  80. package/src/ChartInternal/internals/tooltip.ts +23 -15
  81. package/src/ChartInternal/shape/arc.ts +174 -71
  82. package/src/ChartInternal/shape/area.ts +2 -2
  83. package/src/ChartInternal/shape/bar.ts +7 -6
  84. package/src/ChartInternal/shape/candlestick.ts +3 -3
  85. package/src/ChartInternal/shape/funnel.ts +18 -18
  86. package/src/ChartInternal/shape/line.ts +9 -10
  87. package/src/ChartInternal/shape/point.common.ts +24 -6
  88. package/src/ChartInternal/shape/radar.ts +4 -4
  89. package/src/ChartInternal/shape/shape.ts +24 -6
  90. package/src/ChartInternal/shape/treemap.ts +19 -5
  91. package/src/Plugin/stanford/Options.ts +2 -2
  92. package/src/Plugin/tableview/Options.ts +1 -1
  93. package/src/config/Options/axis/axis.ts +7 -7
  94. package/src/config/Options/axis/x.ts +6 -6
  95. package/src/config/Options/axis/y.ts +4 -4
  96. package/src/config/Options/axis/y2.ts +16 -3
  97. package/src/config/Options/common/color.ts +2 -2
  98. package/src/config/Options/common/legend.ts +6 -5
  99. package/src/config/Options/common/main.ts +23 -23
  100. package/src/config/Options/common/point.ts +4 -3
  101. package/src/config/Options/common/tooltip.ts +14 -13
  102. package/src/config/Options/data/axis.ts +31 -6
  103. package/src/config/Options/data/data.ts +44 -44
  104. package/src/config/Options/data/selection.ts +4 -4
  105. package/src/config/Options/interaction/interaction.ts +2 -1
  106. package/src/config/Options/interaction/subchart.ts +2 -2
  107. package/src/config/Options/interaction/zoom.ts +4 -4
  108. package/src/config/Options/shape/arc.ts +4 -4
  109. package/src/config/Options/shape/area.ts +1 -1
  110. package/src/config/Options/shape/bar.ts +4 -4
  111. package/src/config/Options/shape/bubble.ts +2 -2
  112. package/src/config/Options/shape/candlestick.ts +1 -1
  113. package/src/config/Options/shape/donut.ts +34 -3
  114. package/src/config/Options/shape/gauge.ts +36 -4
  115. package/src/config/Options/shape/line.ts +1 -1
  116. package/src/config/Options/shape/pie.ts +34 -3
  117. package/src/config/Options/shape/polar.ts +35 -4
  118. package/src/config/Options/shape/radar.ts +1 -1
  119. package/src/config/Options/shape/scatter.ts +1 -1
  120. package/src/config/Options/shape/treemap.ts +31 -5
  121. package/src/config/Store/State.ts +11 -1
  122. package/src/config/classes.ts +1 -0
  123. package/src/core.ts +1 -1
  124. package/src/module/Cache.ts +29 -4
  125. package/src/module/generator.ts +1 -1
  126. package/src/module/util.ts +308 -117
  127. package/src/module/worker.ts +3 -3
  128. package/src/scss/billboard.scss +15 -0
  129. package/src/scss/theme/dark.scss +15 -0
  130. package/src/scss/theme/datalab.scss +15 -0
  131. package/src/scss/theme/graph.scss +15 -0
  132. package/src/scss/theme/insight.scss +15 -0
  133. package/src/scss/theme/modern.scss +15 -0
  134. package/types/axis.d.ts +3 -3
  135. package/types/chart.d.ts +4 -4
  136. package/types/options.d.ts +22 -9
  137. package/types/options.shape.d.ts +59 -2
@@ -56,7 +56,7 @@ export default {
56
56
  * The callback will receive d as an argument and it has some parameters like id, value, index. This callback should return boolean.
57
57
  * @name data․selection․isselectable
58
58
  * @memberof Options
59
- * @type {Function}
59
+ * @type {function}
60
60
  * @default function() { return true; }
61
61
  * @example
62
62
  * data: {
@@ -69,7 +69,7 @@ export default {
69
69
 
70
70
  /**
71
71
  * Set multiple data points selection enabled.<br><br>
72
- * If this option set true, multile data points can have the selected state at the same time. If false set, only one data point can have the selected state and the others will be unselected when the new data point is selected.
72
+ * 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.
73
73
  * @name data․selection․multiple
74
74
  * @memberof Options
75
75
  * @type {boolean}
@@ -104,7 +104,7 @@ export default {
104
104
  * Set a callback for on data selection.
105
105
  * @name data․onselected
106
106
  * @memberof Options
107
- * @type {Function}
107
+ * @type {function}
108
108
  * @default function() {}
109
109
  * @example
110
110
  * data: {
@@ -121,7 +121,7 @@ export default {
121
121
  * Set a callback for on data un-selection.
122
122
  * @name data․onunselected
123
123
  * @memberof Options
124
- * @type {Function}
124
+ * @type {function}
125
125
  * @default function() {}
126
126
  * @example
127
127
  * data: {
@@ -17,7 +17,8 @@ export default {
17
17
  * @property {boolean} [interaction.brighten=true] Make brighter for the selected area (ex. 'pie' type data selected area)
18
18
  * @property {boolean} [interaction.inputType.mouse=true] enable or disable mouse interaction
19
19
  * @property {boolean} [interaction.inputType.touch=true] enable or disable touch interaction
20
- * @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.
20
+ * @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>
21
+ * - **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.
21
22
  * @property {boolean} [interaction.onout=true] Enable or disable "onout" event.<br>
22
23
  * When is disabled, defocus(hiding tooltip, focused gridline, etc.) event won't work.
23
24
  * @see [Demo: touch.preventDefault](https://naver.github.io/billboard.js/demo/#Interaction.PreventScrollOnTouch)
@@ -19,11 +19,11 @@ export default {
19
19
  * @property {boolean} [subchart.showHandle=false] Show sub chart's handle.
20
20
  * @property {boolean} [subchart.axis.x.show=true] Show or hide x axis.
21
21
  * @property {boolean} [subchart.axis.x.tick.show=true] Show or hide x axis tick line.
22
- * @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.
22
+ * @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.
23
23
  * @property {boolean} [subchart.axis.x.tick.text.show=true] Show or hide x axis tick text.
24
24
  * @property {Array} [subchart.init.range] Set initial selection domain range.
25
25
  * @property {number} [subchart.size.height] Change the height of the subchart.
26
- * @property {Function} [subchart.onbrush] Set callback for brush event.<br>
26
+ * @property {function} [subchart.onbrush] Set callback for brush event.<br>
27
27
  * Specified function receives the current zoomed x domain.
28
28
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Interaction.SubChart)
29
29
  * @example
@@ -24,14 +24,14 @@ export default {
24
24
  * @property {Array} [zoom.extent=[1, 10]] Change zoom extent.
25
25
  * @property {number|Date} [zoom.x.min] Set x Axis minimum zoom range
26
26
  * @property {number|Date} [zoom.x.max] Set x Axis maximum zoom range
27
- * @property {Function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
27
+ * @property {function} [zoom.onzoomstart=undefined] Set callback that is called when zooming starts.<br>
28
28
  * Specified function receives the zoom event.
29
- * @property {Function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
29
+ * @property {function} [zoom.onzoom=undefined] Set callback that is called when the chart is zooming.<br>
30
30
  * Specified function receives the zoomed domain.
31
- * @property {Function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
31
+ * @property {function} [zoom.onzoomend=undefined] Set callback that is called when zooming ends.<br>
32
32
  * Specified function receives the zoomed domain.
33
33
  * @property {boolean|object} [zoom.resetButton=true] Set to display zoom reset button for 'drag' type zoom
34
- * @property {Function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
34
+ * @property {function} [zoom.resetButton.onclick] Set callback when clicks the reset button. The callback will receive reset button element reference as argument.
35
35
  * @property {string} [zoom.resetButton.text='Reset Zoom'] Text value for zoom reset button.
36
36
  * @see [Demo:zoom](https://naver.github.io/billboard.js/demo/#Interaction.Zoom)
37
37
  * @see [Demo:drag zoom](https://naver.github.io/billboard.js/demo/#Interaction.DragZoom)
@@ -12,14 +12,14 @@ export default {
12
12
  * @memberof Options
13
13
  * @type {object}
14
14
  * @property {object} arc Arc object
15
- * @property {number|Function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
15
+ * @property {number|function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
16
16
  * - **NOTE:**
17
17
  * - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
18
18
  * @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
19
19
  * @property {object} [arc.needle] Set needle options.
20
20
  * @property {boolean} [arc.needle.show=false] Show or hide needle.
21
21
  * @property {string} [arc.needle.color] Set needle filled color.
22
- * @property {Function} [arc.needle.path] Set custom needle path function.
22
+ * @property {function} [arc.needle.path] Set custom needle path function.
23
23
  * - **NOTE:**
24
24
  * - The path should be starting from 0,0 (which is center) to top center coordinate.
25
25
  * - The function will receive, `length`{number} parameter which indicating the needle length in pixel relative to radius.
@@ -43,8 +43,8 @@ export default {
43
43
  * @property {string} [arc.rangeText.unit="absolute"] Specify the range text unit.
44
44
  * - "absolute": Show absolute value
45
45
  * - "%": Show percentage value
46
- * @property {boolean} [arc.rangeText.fiexed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
47
- * @property {Function} [arc.rangeText.format] Set format function for the range text.
46
+ * @property {boolean} [arc.rangeText.fixed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
47
+ * @property {function} [arc.rangeText.format] Set format function for the range text.
48
48
  * @property {number} [arc.rangeText.position] Set position function or object for the range text.
49
49
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
50
50
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
@@ -37,7 +37,7 @@ export default {
37
37
  * // <g class='bb-areas'> will be positioned behind the line <g class='bb-lines'> in stacking order
38
38
  * front: false,
39
39
  *
40
- * // will generate follwing linearGradient:
40
+ * // will generate following linearGradient:
41
41
  * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
42
42
  * // <linearGradient x1="0" x2="0" y1="0" y2="1">
43
43
  * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
@@ -25,8 +25,8 @@ export default {
25
25
  * @property {number} [bar.padding=0] The padding pixel value between each bar.
26
26
  * @property {number} [bar.radius] Set the radius of bar edge in pixel.
27
27
  * @property {number} [bar.radius.ratio] Set the radius ratio of bar edge in relative the bar's width.
28
- * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
29
- * @property {number|Function|object} [bar.width] Change the width of bar chart.
28
+ * @property {number} [bar.sensitivity=2] The sensitivity offset value for interaction boundary.
29
+ * @property {number|function|object} [bar.width] Change the width of bar chart.
30
30
  * @property {number} [bar.width.ratio=0.6] Change the width of bar chart by ratio.
31
31
  * - **NOTE:** Criteria for ratio.
32
32
  * - When x ticks count is same with the data count, the baseline for ratio is the minimum interval value of x ticks.
@@ -53,12 +53,12 @@ export default {
53
53
  * // make bar shape to be positioned over the other shape elements
54
54
  * front: true,
55
55
  *
56
- * // remove nullish data on bar indices postions
56
+ * // remove nullish data on bar indices positions
57
57
  * indices: {
58
58
  * removeNull: true
59
59
  * },
60
60
  *
61
- * // will generate follwing linearGradient:
61
+ * // will generate following linearGradient:
62
62
  * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
63
63
  * // <linearGradient x1="0" x2="0" y1="0" y2="1">
64
64
  * // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
@@ -12,12 +12,12 @@ export default {
12
12
  * @memberof Options
13
13
  * @type {object}
14
14
  * @property {object} bubble bubble object
15
- * @property {number|Function} [bubble.maxR=35] Set the max bubble radius value
15
+ * @property {number|function} [bubble.maxR=35] Set the max bubble radius value
16
16
  * @property {boolean} [bubble.zerobased=false] Set if min or max value will be 0 on bubble chart.
17
17
  * @example
18
18
  * bubble: {
19
19
  * // ex) If 100 is the highest value among data bound, the representation bubble of 100 will have radius of 50.
20
- * // And the lesser will have radius relatively from tha max value.
20
+ * // And the lesser will have radius relatively from the max value.
21
21
  * maxR: 50,
22
22
  *
23
23
  * // or set radius callback
@@ -42,7 +42,7 @@ export default {
42
42
  * }
43
43
  * },
44
44
  * color: {
45
- * // spcify bearish color
45
+ * // specify bearish color
46
46
  * down: "red",
47
47
  *
48
48
  * // or specify color per dataset
@@ -13,10 +13,21 @@ export default {
13
13
  * @type {object}
14
14
  * @property {object} donut Donut object
15
15
  * @property {boolean} [donut.label.show=true] Show or hide label on each donut piece.
16
- * @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
16
+ * @property {function} [donut.label.format] Set formatter for the label on each donut piece.
17
17
  * @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
18
- * @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
19
- * @property {object|Function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
18
+ * @property {number|function} [donut.label.ratio=undefined] Set ratio of labels position.
19
+ * @property {boolean|object} [donut.label.line=false] Enable label with lines (displayed outside with connector lines).
20
+ * - `true`: Enable label with lines with default settings
21
+ * - `false`: Labels are displayed inside the donut slices (default behavior).
22
+ * - `{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.
23
+ * @property {boolean} [donut.label.line.show=true] Show or hide connector lines.
24
+ * @property {number} [donut.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
25
+ * @property {boolean|function} [donut.label.line.text=true] Show text at the end of the connector line (outside the shape).
26
+ * - `true`: show data "id" text
27
+ * - `false`: use default formatter(label.format) to show text
28
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
29
+ * - **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.
30
+ * @property {object|function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
20
31
  * 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>
21
32
  * The arguments are:<br>
22
33
  * - `v` is the value of the data point where the label is shown.
@@ -41,6 +52,7 @@ export default {
41
52
  * @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
42
53
  * @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
43
54
  * @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
55
+ * @see [Demo: Label Line](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelLine)
44
56
  * @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
45
57
  * @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
46
58
  * @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
@@ -70,6 +82,20 @@ export default {
70
82
  * // or set ratio number
71
83
  * ratio: 0.5,
72
84
  *
85
+ * // Enable label with lines (displayed outside with connector lines)
86
+ * line: false, // default - labels inside
87
+ * line: true, // enable label with lines with default settings
88
+ * line: { // enable label with lines with custom settings
89
+ * show: true,
90
+ * distance: 20, // horizontal line distance in pixels
91
+ *
92
+ * // show text at the end of connector line (outside the shape)
93
+ * text: true, // use default formatter
94
+ * text: function(value, ratio, id) { // custom formatter
95
+ * return d3.format(".1%")(ratio);
96
+ * }
97
+ * },
98
+ *
73
99
  * // set image to be displayed next to the label text
74
100
  * image: {
75
101
  * url: "./sample.svg",
@@ -141,6 +167,11 @@ export default {
141
167
  donut_label_show: true,
142
168
  donut_label_format: <(() => number | string) | undefined>undefined,
143
169
  donut_label_threshold: 0.05,
170
+ donut_label_line: <boolean | {
171
+ show?: boolean,
172
+ distance?: number,
173
+ text?: boolean | ((value: number, ratio: number, id: string) => string)
174
+ }>false,
144
175
  donut_label_image: <
145
176
  | {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
146
177
  | ((v: number, id: string, i: number) => {
@@ -15,15 +15,27 @@ export default {
15
15
  * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
16
16
  * @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.
17
17
  * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
18
- * @property {Function} [gauge.label.extents] Set customized min/max label text.
19
- * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
18
+ * @property {function} [gauge.label.extents] Set customized min/max label text.
19
+ * @property {function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
20
20
  * Will pass following arguments to the given function:
21
21
  * - value {number}: absolute value
22
22
  * - ratio {number}: value's ratio
23
23
  * - id {string}: data's id value
24
- * @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
24
+ * @property {number|function} [gauge.label.ratio=undefined] Set ratio of labels position.
25
25
  * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
26
- * @property {object|Function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
26
+ * @property {boolean|object} [gauge.label.line=false] Enable label with lines (displayed outside with connector lines).
27
+ * - **NOTE:** Only applicable for single gauge (not for `gauge.type="multi"`).
28
+ * - `true`: Enable label with lines with default settings
29
+ * - `false`: Labels are displayed inside the gauge (default behavior).
30
+ * - `{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.
31
+ * @property {boolean} [gauge.label.line.show=true] Show or hide connector lines.
32
+ * @property {number} [gauge.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
33
+ * @property {boolean|function} [gauge.label.line.text=true] Show text at the end of the connector line (outside the shape).
34
+ * - `true`: show data "id" text
35
+ * - `false`: use default formatter(label.format) to show text
36
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
37
+ * - **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.
38
+ * @property {object|function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
27
39
  * 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>
28
40
  * The arguments are:<br>
29
41
  * - `v` is the value of the data point where the label is shown.
@@ -76,6 +88,7 @@ export default {
76
88
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
77
89
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
78
90
  * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
91
+ * @see [Demo: label line](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelLine)
79
92
  * @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
80
93
  * @example
81
94
  * gauge: {
@@ -98,6 +111,20 @@ export default {
98
111
  * // if data value is below than 0.1, text label will be hidden.
99
112
  * threshold: 0.1,
100
113
  *
114
+ * // Enable label with lines (displayed outside with connector lines)
115
+ * // NOTE: Only works with single gauge (not gauge.type="multi")
116
+ * line: true, // enable label with lines with default settings
117
+ * line: { // enable label with lines with custom settings
118
+ * show: true, // enable lines (default: true when line is enabled)
119
+ * distance: 30, // distance of horizontal line in pixels (default: 20)
120
+ *
121
+ * // show text at the end of connector line (outside the shape)
122
+ * text: true, // use default formatter
123
+ * text: function(value, ratio, id) { // custom formatter
124
+ * return d3.format(".1%")(ratio);
125
+ * }
126
+ * },
127
+ *
101
128
  * // set ratio callback. Should return ratio value
102
129
  * ratio: function(d, radius, h) {
103
130
  * ...
@@ -191,6 +218,11 @@ export default {
191
218
  gauge_label_format: <(() => string) | undefined>undefined,
192
219
  gauge_label_ratio: <(() => number) | undefined>undefined,
193
220
  gauge_label_threshold: 0,
221
+ gauge_label_line: <boolean | {
222
+ show?: boolean,
223
+ distance?: number,
224
+ text?: boolean | ((value: number, ratio: number, id: string) => string)
225
+ }>false,
194
226
  gauge_label_image: <
195
227
  | {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
196
228
  | ((v: number, id: string, i: number) => {
@@ -40,7 +40,7 @@ export default {
40
40
  * // hide all data points ('point.show=false' also has similar effect)
41
41
  * point: false,
42
42
  *
43
- * // show data points for only indicated datas
43
+ * // show data points for only indicated data
44
44
  * point: [
45
45
  * "data1", "data3"
46
46
  * ],
@@ -13,10 +13,21 @@ export default {
13
13
  * @type {object}
14
14
  * @property {object} pie Pie object
15
15
  * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
16
- * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
17
- * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
16
+ * @property {function} [pie.label.format] Set formatter for the label on each pie piece.
17
+ * @property {number|function} [pie.label.ratio=undefined] Set ratio of labels position.
18
18
  * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
19
- * @property {object|Function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
19
+ * @property {boolean|object} [pie.label.line=false] Enable label with lines (displayed outside with connector lines).
20
+ * - `true`: Enable label with lines with default settings
21
+ * - `false`: Labels are displayed inside the pie slices (default behavior).
22
+ * - `{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.
23
+ * @property {boolean} [pie.label.line.show=true] Show or hide connector lines.
24
+ * @property {number} [pie.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
25
+ * @property {boolean|function} [pie.label.line.text=true] Show text at the end of the connector line (outside the shape).
26
+ * - `true`: show data "id" text
27
+ * - `false`: use default formatter(label.format) to show text
28
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
29
+ * - **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.
30
+ * @property {object|function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
20
31
  * 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>
21
32
  * The arguments are:<br>
22
33
  * - `v` is the value of the data point where the label is shown.
@@ -41,6 +52,7 @@ export default {
41
52
  * @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
42
53
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
43
54
  * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
55
+ * @see [Demo: label line](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelLine)
44
56
  * @example
45
57
  * pie: {
46
58
  * label: {
@@ -64,6 +76,20 @@ export default {
64
76
  * // or set ratio number
65
77
  * ratio: 0.5,
66
78
  *
79
+ * // Enable label with lines (displayed outside with connector lines)
80
+ * line: false, // default - labels inside
81
+ * line: true, // enable label with lines with default settings
82
+ * line: { // enable label with lines with custom settings
83
+ * show: true,
84
+ * distance: 20, // horizontal line distance in pixels
85
+ *
86
+ * // show text at the end of connector line (outside the shape)
87
+ * text: true, // use default formatter
88
+ * text: function(value, ratio, id) { // custom formatter
89
+ * return d3.format(".1%")(ratio);
90
+ * }
91
+ * },
92
+ *
67
93
  * // set image to be displayed next to the label text
68
94
  * image: {
69
95
  * url: "./sample.svg",
@@ -145,6 +171,11 @@ export default {
145
171
  pie_label_format: <(() => number | string) | undefined>undefined,
146
172
  pie_label_ratio: <(() => number) | undefined>undefined,
147
173
  pie_label_threshold: 0.05,
174
+ pie_label_line: <boolean | {
175
+ show?: boolean,
176
+ distance?: number,
177
+ text?: boolean | ((value: number, ratio: number, id: string) => string)
178
+ }>false,
148
179
  pie_label_image: <
149
180
  | {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
150
181
  | ((v: number, id: string, i: number) => {
@@ -13,10 +13,21 @@ export default {
13
13
  * @type {object}
14
14
  * @property {object} polar Polar object
15
15
  * @property {boolean} [polar.label.show=true] Show or hide label on each polar piece.
16
- * @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
16
+ * @property {function} [polar.label.format] Set formatter for the label on each polar piece.
17
17
  * @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
18
- * @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
19
- * @property {object|Function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
18
+ * @property {number|function} [polar.label.ratio=undefined] Set ratio of labels position.
19
+ * @property {boolean|object} [polar.label.line=false] Enable label with lines (displayed outside with connector lines).
20
+ * - `true`: Enable label with lines with default settings
21
+ * - `false`: Labels are displayed inside the polar slices (default behavior).
22
+ * - `{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.
23
+ * @property {boolean} [polar.label.line.show=true] Show or hide connector lines.
24
+ * @property {number} [polar.label.line.distance=20] Set the distance of the horizontal part of the connector line in pixels.
25
+ * @property {boolean|function} [polar.label.line.text=true] Show text at the end of the connector line (outside the shape).
26
+ * - `true`: show data "id" text
27
+ * - `false`: use default formatter(label.format) to show text
28
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
29
+ * - **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.
30
+ * @property {object|function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
20
31
  * 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>
21
32
  * The arguments are:<br>
22
33
  * - `v` is the value of the data point where the label is shown.
@@ -31,13 +42,14 @@ export default {
31
42
  * @property {number} [polar.level.depth=3] Set the level depth.
32
43
  * @property {boolean} [polar.level.show=true] Show or hide level.
33
44
  * @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
34
- * @property {Function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
45
+ * @property {function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
35
46
  * @property {boolean} [polar.level.text.show=true] Show or hide level text.
36
47
  * @property {number} [polar.padAngle=0] Set padding between data.
37
48
  * @property {number} [polar.padding=0] Sets the gap between pie arcs.
38
49
  * @property {number} [polar.startingAngle=0] Set starting angle where data draws.
39
50
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
40
51
  * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
52
+ * @see [Demo: label line](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelLine)
41
53
  * @example
42
54
  * polar: {
43
55
  * label: {
@@ -61,6 +73,20 @@ export default {
61
73
  * // or set ratio number
62
74
  * ratio: 0.5,
63
75
  *
76
+ * // Enable label with lines (displayed outside with connector lines)
77
+ * line: false, // default - labels inside
78
+ * line: true, // enable label with lines with default settings
79
+ * line: { // enable label with lines with custom settings
80
+ * show: true,
81
+ * distance: 20, // horizontal line distance in pixels
82
+ *
83
+ * // show text at the end of connector line (outside the shape)
84
+ * text: true, // use default formatter
85
+ * text: function(value, ratio, id) { // custom formatter
86
+ * return d3.format(".1%")(ratio);
87
+ * }
88
+ * },
89
+ *
64
90
  * // set image to be displayed next to the label text
65
91
  * image: {
66
92
  * url: "./sample.svg",
@@ -125,6 +151,11 @@ export default {
125
151
  polar_label_show: true,
126
152
  polar_label_format: <(() => number | string) | undefined>undefined,
127
153
  polar_label_threshold: 0.05,
154
+ polar_label_line: <boolean | {
155
+ show?: boolean,
156
+ distance?: number,
157
+ text?: boolean | ((value: number, ratio: number, id: string) => string)
158
+ }>false,
128
159
  polar_label_image: <
129
160
  | {url: string, width: number, height: number, pos?: {x?: number, y?: number}}
130
161
  | ((v: number, id: string, i: number) => {
@@ -22,7 +22,7 @@ export default {
22
22
  * @property {boolean} [radar.direction.clockwise=false] Set the direction to be drawn.
23
23
  * @property {number} [radar.level.depth=3] Set the level depth.
24
24
  * @property {boolean} [radar.level.show=true] Show or hide level.
25
- * @property {Function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
25
+ * @property {function} [radar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
26
26
  * @property {boolean} [radar.level.text.show=true] Show or hide level text.
27
27
  * @property {number} [radar.size.ratio=0.87] Set size ratio.
28
28
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.RadarChart)
@@ -23,7 +23,7 @@ export default {
23
23
  * // hide all data points ('point.show=false' also has similar effect)
24
24
  * point: false,
25
25
  *
26
- * // show data points for only indicated datas
26
+ * // show data points for only indicated data
27
27
  * point: [
28
28
  * "data1", "data3"
29
29
  * ],
@@ -20,7 +20,12 @@ export default {
20
20
  * - sliceDice ([d3.treemapSliceDice](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSliceDice))
21
21
  * - squrify ([d3.treemapSquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapSquarify))
22
22
  * - resquarify ([d3.treemapResquarify](https://github.com/d3/d3-hierarchy/blob/main/README.md#treemapResquarify))
23
- * @property {Function} [treemap.label.format] Set formatter for the label text.
23
+ * @property {function} [treemap.label.format] Set formatter for the label text.<br>
24
+ * - **Arguments:**
25
+ * - `value {number}`: Data value
26
+ * - `ratio {number}`: The `ratio` of how much space this tile occupies relative to the total area (0~1)
27
+ * - `id {string}`: Data id
28
+ * - `size {object}`: Tile size `{width, height}` in pixels
24
29
  * @property {number} [treemap.label.threshold=0.05] Set threshold ratio to show/hide labels text.
25
30
  * @property {number} [treemap.label.show=true] Show or hide label text.
26
31
  * @see [Demo: treemap](https://naver.github.io/billboard.js/demo/#Chart.TreemapChart)
@@ -33,12 +38,33 @@ export default {
33
38
  * // show or hide label text
34
39
  * show: false,
35
40
  *
36
- * // set label text formatter
37
- * format: function(value, ratio, id) {
41
+ * // Example 1: Format with currency
42
+ * format: function(value, ratio, id, size) {
43
+ * // size: {width, height} - tile size in pixels
38
44
  * return d3.format("$")(value);
45
+ * },
46
+ *
47
+ * // Example 2: Show different content based on tile size
48
+ * format: function(value, ratio, id, size) {
49
+ * if (size.width > 100 && size.height > 50) {
50
+ * return `${id}\n${d3.format("$")(value)}\n(${(ratio * 100).toFixed(1)}%)`;
51
+ * } else if (size.width > 50) {
52
+ * return `${id}\n${d3.format("$")(value)}`;
53
+ * } else {
54
+ * return d3.format("$")(value);
55
+ * }
56
+ * },
57
+ *
58
+ * // Example 3: Include tile dimensions in label
59
+ * format: function(value, ratio, id, size) {
60
+ * return `${id}\n${value}\n${size.width.toFixed(0)}x${size.height.toFixed(0)}px`;
61
+ * },
39
62
  *
40
- * // to multiline, return with '\n' character
41
- * // return value +"%\nLine1\n2Line2";
63
+ * // Example 4: Conditional formatting based on ratio
64
+ * format: function(value, ratio, id, size) {
65
+ * return ratio > 0.1 ?
66
+ * `${id}\n${value} (${(ratio * 100).toFixed(1)}%)` :
67
+ * value;
42
68
  * },
43
69
  *
44
70
  * // set ratio number
@@ -46,6 +46,12 @@ export default class State {
46
46
  // for data CSS rule index (used when boost.useCssRule is true)
47
47
  cssRule: {},
48
48
 
49
+ // Data loading state (used in scale calculation)
50
+ loading: <"append" | "load" | undefined>undefined,
51
+
52
+ // Zoom/subchart domain (different from current.domain which is for rendering)
53
+ domain: <number[] | undefined>undefined,
54
+
49
55
  current: {
50
56
  // current domain value. Assigned when is zoom is called
51
57
  domain: undefined,
@@ -162,7 +168,11 @@ export default class State {
162
168
  x2: <number | null>null,
163
169
  y1: <number | null>null,
164
170
  y2: <number | null>null
165
- }
171
+ },
172
+
173
+ // RAF batching for zoom/drag interactions
174
+ pendingRaf: <number | null>null,
175
+ rafBatchQueue: <Array<() => void>>[]
166
176
  };
167
177
  }
168
178
  }
@@ -19,6 +19,7 @@ export const $COMMON = {
19
19
  export const $ARC = {
20
20
  arc: "bb-arc",
21
21
  arcLabelLine: "bb-arc-label-line",
22
+ arcLabelLineText: "bb-arc-label-line-text",
22
23
  arcRange: "bb-arc-range",
23
24
  arcs: "bb-arcs",
24
25
  chartArc: "bb-chart-arc",
package/src/core.ts CHANGED
@@ -23,7 +23,7 @@ const bb = {
23
23
 
24
24
  /**
25
25
  * Generate chart
26
- * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
26
+ * - **NOTE:** Bear in mind for the possibility of ***throwing an error***, during the generation when:
27
27
  * - Unused option value is given.
28
28
  * - ex) For `data.type="pie"` option, setting 'axis' option can cause unexpected generation error.
29
29
  * - Insufficient value is given for certain option used.