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
@@ -10,14 +10,14 @@ import type {RegionOptions} from "../../../../types/options";
10
10
  export default {
11
11
  /**
12
12
  * Specify the CSS selector or the element which the chart will be set to. D3 selection object can be specified also.<br>
13
- * If other chart is set already, it will be replaced with the new one (only one chart can be set in one element).
14
- * - **NOTE:** In case of element doesn't exist or not specified, will add a `<div>` element to the body.
13
+ * If another chart is already set, it will be replaced with the new one (only one chart can be set in one element).
14
+ * - **NOTE:** In case the element doesn't exist or not specified, will add a `<div>` element to the body.
15
15
  * @name bindto
16
16
  * @memberof Options
17
17
  * @property {string|HTMLElement|d3.selection|object} [bindto="#chart"] Specify the element where chart will be drawn.
18
18
  * @property {string|HTMLElement|d3.selection} bindto.element="#chart" Specify the element where chart will be drawn.
19
19
  * @property {string} [bindto.classname=bb] Specify the class name of bind element.<br>
20
- * **NOTE:** When class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
20
+ * **NOTE:** When the class name isn't `bb`, then you also need to update the default CSS to be rendered correctly.
21
21
  * @default #chart
22
22
  * @example
23
23
  * bindto: "#myContainer"
@@ -60,8 +60,8 @@ export default {
60
60
  /**
61
61
  * Set 'clip-path' attribute for chart element
62
62
  * - **NOTE:**
63
- * > When is false, chart node element is positioned after the axis node in DOM tree hierarchy.
64
- * > Is to make chart element positioned over axis element.
63
+ * > When false, chart node element is positioned after the axis node in DOM tree hierarchy.
64
+ * > This is to make the chart element positioned over axis element.
65
65
  * @name clipPath
66
66
  * @memberof Options
67
67
  * @type {boolean}
@@ -89,7 +89,7 @@ export default {
89
89
 
90
90
  /**
91
91
  * The desired size of the chart element.
92
- * If value is not specified, the width of the chart will be calculated by the size of the parent element it's appended to.
92
+ * 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.
93
93
  * @name size
94
94
  * @memberof Options
95
95
  * @type {object}
@@ -108,13 +108,13 @@ export default {
108
108
 
109
109
  /**
110
110
  * The padding of the chart element.
111
- * - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)"" wiki documentaion.
111
+ * - **NOTE:** for more information, see the "[`Understanding padding`](https://github.com/naver/billboard.js/wiki/Understanding-padding)" wiki documentation.
112
112
  * @name padding
113
113
  * @memberof Options
114
114
  * @type {object}
115
115
  * @property {object|boolean} [padding=true] Set padding of chart, and accepts object or boolean type.
116
116
  * - `Object`: Specify each side's padding.
117
- * - `false`: Remove padding completely and make shape to fully occupy the container element.
117
+ * - `false`: Remove padding completely and make the shape fully occupy the container element.
118
118
  * - In this case, axes and subchart will be hidden.
119
119
  * - To adjust some padding from this state, use `axis.[x|y].padding` option.
120
120
  * @property {string} [padding.mode] padding mode
@@ -203,7 +203,7 @@ export default {
203
203
  * Set a callback to execute when the chart is clicked.
204
204
  * @name onclick
205
205
  * @memberof Options
206
- * @type {Function}
206
+ * @type {function}
207
207
  * @default undefined
208
208
  * @example
209
209
  * onclick: function(event) {
@@ -218,7 +218,7 @@ export default {
218
218
  * Set a callback to execute when mouse/touch enters the chart.
219
219
  * @name onover
220
220
  * @memberof Options
221
- * @type {Function}
221
+ * @type {function}
222
222
  * @default undefined
223
223
  * @example
224
224
  * onover: function(event) {
@@ -233,7 +233,7 @@ export default {
233
233
  * Set a callback to execute when mouse/touch leaves the chart.
234
234
  * @name onout
235
235
  * @memberof Options
236
- * @type {Function}
236
+ * @type {function}
237
237
  * @default undefined
238
238
  * @example
239
239
  * onout: function(event) {
@@ -248,7 +248,7 @@ export default {
248
248
  * Set a callback to execute when user resizes the screen.
249
249
  * @name onresize
250
250
  * @memberof Options
251
- * @type {Function}
251
+ * @type {function}
252
252
  * @default undefined
253
253
  * @example
254
254
  * onresize: function() {
@@ -262,7 +262,7 @@ export default {
262
262
  * Set a callback to execute when screen resize finished.
263
263
  * @name onresized
264
264
  * @memberof Options
265
- * @type {Function}
265
+ * @type {function}
266
266
  * @default undefined
267
267
  * @example
268
268
  * onresized: function() {
@@ -276,7 +276,7 @@ export default {
276
276
  * Set a callback to execute before the chart is initialized
277
277
  * @name onbeforeinit
278
278
  * @memberof Options
279
- * @type {Function}
279
+ * @type {function}
280
280
  * @default undefined
281
281
  * @example
282
282
  * onbeforeinit: function() {
@@ -290,7 +290,7 @@ export default {
290
290
  * Set a callback to execute when the chart is initialized.
291
291
  * @name oninit
292
292
  * @memberof Options
293
- * @type {Function}
293
+ * @type {function}
294
294
  * @default undefined
295
295
  * @example
296
296
  * oninit: function() {
@@ -304,7 +304,7 @@ export default {
304
304
  * Set a callback to execute after the chart is initialized
305
305
  * @name onafterinit
306
306
  * @memberof Options
307
- * @type {Function}
307
+ * @type {function}
308
308
  * @default undefined
309
309
  * @example
310
310
  * onafterinit: function() {
@@ -315,10 +315,10 @@ export default {
315
315
  onafterinit: <(() => void) | undefined>undefined,
316
316
 
317
317
  /**
318
- * Set a callback which is executed when the chart is rendered. Basically, this callback will be called in each time when the chart is redrawed.
318
+ * 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.
319
319
  * @name onrendered
320
320
  * @memberof Options
321
- * @type {Function}
321
+ * @type {function}
322
322
  * @default undefined
323
323
  * @example
324
324
  * onrendered: function() {
@@ -330,7 +330,7 @@ export default {
330
330
 
331
331
  /**
332
332
  * Set duration of transition (in milliseconds) for chart animation.<br><br>
333
- * - **NOTE:** If `0 `or `null` set, transition will be skipped. So, this makes initial rendering faster especially in case you have a lot of data.
333
+ * - **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.
334
334
  * @name transition
335
335
  * @memberof Options
336
336
  * @type {object}
@@ -363,11 +363,11 @@ export default {
363
363
  * @memberof Options
364
364
  * @type {object}
365
365
  * @property {object} [render] render object
366
- * @property {boolean} [render.lazy=true] Make to not render at initialization.
366
+ * @property {boolean} [render.lazy=true] Make it not render at initialization.
367
367
  * - **NOTE**:
368
368
  * - Enabled by default when bind element's visibility is hidden.
369
369
  * - 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.
370
- * @property {boolean} [render.observe=true] Observe bind element's visibility(`display` or `visiblity` inline css property or class value) & render when is visible automatically (for IEs, only works IE11+). When set to **false**, call [`.flush()`](./Chart.html#flush) to render.
370
+ * @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.
371
371
  * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.LazyRender)
372
372
  * @example
373
373
  * render: {
@@ -389,7 +389,7 @@ export default {
389
389
  * document.getElementById('chart').style.display = 'block'; // (b)
390
390
  *
391
391
  * @example
392
- * // chart won't be rendered and not observing bind element's visiblity changes
392
+ * // chart won't be rendered and not observing bind element's visibility changes
393
393
  * var chart = bb.generate({
394
394
  * render: {
395
395
  * lazy: true,
@@ -416,7 +416,7 @@ export default {
416
416
  * - `[start] {number|Date|string}`: Start position of the region. If not set, the start will be the edge of the chart.
417
417
  * - `[end] {number|Date|string}`: End position of the region. If not set, the end will be the edge of the chart.
418
418
  * - `[class] {string}`: Class value to apply to the region.
419
- * - `[label] {object}` Lable text option.
419
+ * - `[label] {object}` Label text option.
420
420
  * - `text {string}`: Text value.
421
421
  * - `x {number}`: x Position.
422
422
  * - `y {number}`: y Position.
@@ -15,7 +15,7 @@ export default {
15
15
  * @type {object}
16
16
  * @property {object} point Point object
17
17
  * @property {boolean} [point.show=true] Whether to show each point in line.
18
- * @property {number|Function} [point.r=2.5] The radius size of each point.
18
+ * @property {number|function} [point.r=2.5] The radius size of each point.
19
19
  * - **NOTE:** Disabled for 'bubble' type
20
20
  * @property {boolean|object} [point.radialGradient=false] Set the radial gradient on point.<br><br>
21
21
  * Or customize by giving below object value:
@@ -32,7 +32,7 @@ export default {
32
32
  * - **NOTE:**
33
33
  * - `null` will make to not set inline 'opacity' css prop.
34
34
  * - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
35
- * @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
35
+ * @property {number|string|function} [point.sensitivity=10] The sensitivity value for interaction boundary.
36
36
  * - **Available Values:**
37
37
  * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
38
38
  * - "radius": sensitivity based on point's radius
@@ -59,6 +59,7 @@ export default {
59
59
  * - This is an `experimental` feature and can have some unexpected behaviors.
60
60
  * - If chart has 'bubble' type, only circle can be used.
61
61
  * - For IE, non circle point expansions are not supported due to lack of transform support.
62
+ * - 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.
62
63
  * - **Available Values:**
63
64
  * - circle
64
65
  * - rectangle
@@ -79,7 +80,7 @@ export default {
79
80
  * return r;
80
81
  * },
81
82
  *
82
- * // will generate follwing radialGradient:
83
+ * // will generate following radialGradient:
83
84
  * // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient
84
85
  * // <radualGradient cx="0.3" cy="0.3" r="0.7">
85
86
  * // <stop offset="0.1" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
@@ -18,17 +18,17 @@ export default {
18
18
  * - **NOTE:** The overlapped data points will be displayed as grouped even if set false.
19
19
  * @property {boolean} [tooltip.linked=false] Set if tooltips on all visible charts with like x points are shown together when one is shown.
20
20
  * @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.
21
- * @property {Function} [tooltip.format.title] Set format for the title of tooltip.<br>
21
+ * @property {function} [tooltip.format.title] Set format for the title of tooltip.<br>
22
22
  * Specified function receives x of the data point to show.
23
- * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
23
+ * @property {function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
24
24
  * 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.
25
- * @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.
25
+ * @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.
26
26
  * - Will pass following arguments to the given function:
27
27
  * - `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.
28
28
  * - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
29
29
  * - `id {string}`: id of the data point
30
30
  * - `index {number}`: Index of the data point
31
- * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
31
+ * @property {function} [tooltip.position] Set custom position function for the tooltip.<br>
32
32
  * This option can be used to modify the tooltip position by returning object that has top and left.
33
33
  * - Will pass following arguments to the given function:
34
34
  * - `data {Array}`: Current selected data array object.
@@ -36,7 +36,7 @@ export default {
36
36
  * - `height {number}`: Height of tooltip.
37
37
  * - `element {SVGElement}`: Tooltip event bound element
38
38
  * - `pos {object}`: Current position of the tooltip.
39
- * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
39
+ * @property {function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
40
40
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
41
41
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
42
42
  * - **Note:**
@@ -58,6 +58,7 @@ export default {
58
58
  * - **{=COLOR}**: data color.
59
59
  * - **{=NAME}**: data id value.
60
60
  * - **{=VALUE}**: data value.
61
+ * - **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.
61
62
  * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
62
63
  * - **NOTE:** It should contain `{ key: Array, ... }` value
63
64
  * - 'key' name is used as substitution within template as '{=KEY}'
@@ -65,11 +66,11 @@ export default {
65
66
  * @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
66
67
  * @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
67
68
  * @property {object} [tooltip.init.position] Set the position of tooltip at the initialization.
68
- * @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
69
- * @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
70
- * @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
71
- * @property {Function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
72
- * @property {string|Function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
69
+ * @property {function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
70
+ * @property {function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
71
+ * @property {function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
72
+ * @property {function} [tooltip.onhidden] Set a callback that will be invoked after the tooltip is hidden.
73
+ * @property {string|function|null} [tooltip.order=null] Set tooltip data display order.<br><br>
73
74
  * **Available Values:**
74
75
  * - `desc`: In descending data value order
75
76
  * - `asc`: In ascending data value order
@@ -108,7 +109,7 @@ export default {
108
109
  * // yAxis: Current y Axis position value or function(the value is given for axis based chart type only)
109
110
  * // }
110
111
  *
111
- * // yAxis will work differently per data lenghts
112
+ * // yAxis will work differently per data lengths
112
113
  * // - a) Single data: `yAxis` will return `number` value
113
114
  * // - b) Multiple data: `yAxis` will return a function with property value
114
115
  *
@@ -119,8 +120,8 @@ export default {
119
120
  * // b) Multiple data:
120
121
  * // Get y coordinate of value 500, where 'data1' scales(y or y2).
121
122
  * // When 'data.axes' option is used, data can bound to different axes.
122
- * // - when "data.axes={data1: 'y'}", wil return y value from y axis scale.
123
- * // - when "data.axes={data1: 'y2'}", wil return y value from y2 axis scale.
123
+ * // - when "data.axes={data1: 'y'}", will return y value from y axis scale.
124
+ * // - when "data.axes={data1: 'y2'}", will return y value from y2 axis scale.
124
125
  * pos.yAxis(500, "data1"); // will return y coordinate value of data1
125
126
  *
126
127
  * pos.yAxis(500); // get y coordinate with value of 500, using y axis scale
@@ -26,7 +26,7 @@ export default {
26
26
  data_xs: {},
27
27
 
28
28
  /**
29
- * Set a format specifier to parse string specifed as x.
29
+ * Set a format specifier to parse string specified as x.
30
30
  * @name data․xFormat
31
31
  * @memberof Options
32
32
  * @type {string}
@@ -77,7 +77,7 @@ export default {
77
77
  * x: "x",
78
78
  * columns: [
79
79
  * // The line graph will start to be drawn following the x axis sequence
80
- * // Below data, wil start drawing x=1: 200, x=2: 300, x=3: 100
80
+ * // Below data, will start drawing x=1: 200, x=2: 300, x=3: 100
81
81
  * ["x", 3, 1, 2],
82
82
  * ["data1", 100, 200, 300]
83
83
  * ]
@@ -141,18 +141,43 @@ export default {
141
141
  * - **NOTE:**
142
142
  * - For stacking, '[data.groups](#.data%25E2%2580%25A4groups)' option should be set
143
143
  * - y Axis will be set in percentage value (0 ~ 100%)
144
- * - Must have postive values
144
+ * - Must have positive values
145
+ * - Data not in any group will not be normalized when using perGroup option
145
146
  * @name data․stack․normalize
146
147
  * @memberof Options
147
- * @type {boolean}
148
+ * @type {boolean|object}
148
149
  * @default false
149
- * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
150
+ * @see [Demo: Data Stack Normalized](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalized)
151
+ * @see [Demo: Data Stack Normalized per Group](https://naver.github.io/billboard.js/demo/#Data.DataStackNormalizedGroup)
150
152
  * @example
151
153
  * data: {
152
154
  * stack: {
155
+ * // Normalize all grouped data together (all groups combined to 0-100%)
153
156
  * normalize: true
157
+ *
158
+ * // Normalize per group (each group independently becomes 0-100%)
159
+ * // Data not in any group will display with their original values.
160
+ * // If non-grouped data shares the same axis (e.g., y), it will be
161
+ * // displayed on the 0-100 absolute scale. To display original values,
162
+ * // assign them to a separate axis (e.g., y2).
163
+ * normalize: {
164
+ * perGroup: true
165
+ * }
166
+ * },
167
+ * groups: [
168
+ * ["data1", "data2"] // This group will be normalized to 0-100%
169
+ * ],
170
+ * // data3 is not in any group, so it displays original values
171
+ * // Assign it to y2 axis to use a separate scale
172
+ * axes: {
173
+ * data3: "y2"
174
+ * }
175
+ * },
176
+ * axis: {
177
+ * y2: {
178
+ * show: true
154
179
  * }
155
180
  * }
156
181
  */
157
- data_stack_normalize: false
182
+ data_stack_normalize: <boolean | {perGroup?: boolean}>false
158
183
  };
@@ -10,7 +10,7 @@ import type {ChartTypes, d3Selection} from "../../../../types/types";
10
10
  export default {
11
11
  /**
12
12
  * Specify the key of x values in the data.<br><br>
13
- * 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.
13
+ * 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.
14
14
  * @name data․x
15
15
  * @memberof Options
16
16
  * @type {string}
@@ -26,7 +26,7 @@ export default {
26
26
  * Converts data id value
27
27
  * @name data․idConverter
28
28
  * @memberof Options
29
- * @type {Function}
29
+ * @type {function}
30
30
  * @default function(id) { return id; }
31
31
  * @example
32
32
  * data: {
@@ -200,8 +200,8 @@ export default {
200
200
 
201
201
  /**
202
202
  * This option changes the order of stacking data and pieces of pie/donut.
203
- * - If `null` specified, it will be the order the data loaded.
204
- * - 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>
203
+ * - If `null` specified, it will be the order in which the data is loaded.
204
+ * - 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>
205
205
  *
206
206
  * **Available Values:**
207
207
  * - `desc`: In descending order
@@ -209,10 +209,10 @@ export default {
209
209
  * - `null`: It keeps the data load order
210
210
  * - `function(data1, data2) { ... }`: Array.sort compareFunction
211
211
  *
212
- * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
212
+ * **NOTE**: order function only works for Axis based types & Arc types, except `Radar` type.
213
213
  * @name data․order
214
214
  * @memberof Options
215
- * @type {string|Function|null}
215
+ * @type {string|function|null}
216
216
  * @default desc
217
217
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataOrder)
218
218
  * @example
@@ -269,7 +269,7 @@ export default {
269
269
  /**
270
270
  * Set how zero value will be treated on groups.<br>
271
271
  * Possible values:
272
- * - `zero`: 0 will be positioned at absolute axis zero point.
272
+ * - `zero`: 0 will be positioned at the absolute axis zero point.
273
273
  * - `positive`: 0 will be positioned at the top of a stack.
274
274
  * - `negative`: 0 will be positioned at the bottom of a stack.
275
275
  * @name data․groupsZeroAs
@@ -286,10 +286,10 @@ export default {
286
286
 
287
287
  /**
288
288
  * Set color converter function.<br><br>
289
- * 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').
289
+ * 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').
290
290
  * @name data․color
291
291
  * @memberof Options
292
- * @type {Function}
292
+ * @type {function}
293
293
  * @default undefined
294
294
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataColor)
295
295
  * @example
@@ -324,41 +324,41 @@ export default {
324
324
  * @memberof Options
325
325
  * @type {object}
326
326
  * @property {object} data Data object
327
- * @property {boolean} [data.labels=false] Show or hide labels on each data points
327
+ * @property {boolean} [data.labels=false] Show or hide labels on each data point
328
328
  * @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
329
- * @property {Function} [data.labels.format] Set formatter function for data labels.<br>
329
+ * @property {function} [data.labels.format] Set formatter function for data labels.<br>
330
330
  * 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>
331
331
  * The arguments are:<br>
332
332
  * - `v` is the value of the data point where the label is shown.
333
333
  * - `id` is the id of the data where the label is shown.
334
334
  * - `i` is the index of the data series point where the label is shown.
335
- * - `texts` is the array of whole corresponding data series' text labels.<br><br>
335
+ * - `texts` is an array of whole corresponding data series' text labels.<br><br>
336
336
  * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
337
- * @property {string|object|Function} [data.labels.backgroundColors] Set label text background colors.<br><br>
338
- * - **NOTE**: When function is set, background colors can be specified one color per dataset.
337
+ * @property {string|object|function} [data.labels.backgroundColors] Set label text background colors.<br><br>
338
+ * - **NOTE**: When a function is set, background colors can be specified one color per dataset.
339
339
  * - Within the function, the last returned color for dataset will be used.
340
340
  * - Only can control set or unset background color for each values.
341
- * @property {string|object|Function} [data.labels.colors] Set label text colors.
342
- * @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
343
- * When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
341
+ * @property {string|object|function} [data.labels.colors] Set label text colors.
342
+ * @property {object|function} [data.labels.position] Set each dataset position, relative to the original.<br><br>
343
+ * 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>
344
344
  * The arguments are:<br>
345
345
  * - `type` coordinate type string, which will be 'x' or 'y'.
346
346
  * - `v` is the value of the data point where the label is shown.
347
347
  * - `id` is the id of the data where the label is shown.
348
348
  * - `i` is the index of the data series point where the label is shown.
349
- * - `texts` is the array of whole corresponding data series' text labels.<br><br>
350
- * @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
351
- * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
349
+ * - `texts` is an array of whole corresponding data series' text labels.<br><br>
350
+ * @property {number} [data.labels.position.x=0] x coordinate position, relative to the original.
351
+ * @property {number} [data.labels.position.y=0] y coordinate position, relative to the original.
352
352
  * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
353
- * - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
354
- * @property {boolean|object} [data.labels.border=false] Add border to data label text. NOTE: When set as `true`, styling aren't applied. Hence, need to set using `.bb-text-border` class.
353
+ * - **NOTE:** Depending on the rotate value, the text position needs to be adjusted manually(using `data.labels.position` option) to be shown nicely.
354
+ * @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.
355
355
  * @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.
356
356
  * @property {number} [data.labels.border.radius=10] Border radius value.
357
357
  * @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
358
358
  * @property {string} [data.labels.border.stroke="#000"] Border stroke color.
359
359
  * @property {string} [data.labels.border.fill="none"] Border fill color.
360
- * @property {object|Function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
361
- * 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>
360
+ * @property {object|function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
361
+ * 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>
362
362
  * The arguments are:<br>
363
363
  * - `v` is the value of the data point where the label is shown.
364
364
  * - `id` is the id of the data where the label is shown.
@@ -367,8 +367,8 @@ export default {
367
367
  * @property {number} data.labels.image.width Image width in pixels.
368
368
  * @property {number} data.labels.image.height Image height in pixels.
369
369
  * @property {object} [data.labels.image.pos] Image position relative to the label text.
370
- * @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
371
- * @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
370
+ * @property {number} [data.labels.image.pos.x=0] x coordinate position, relative to the original.
371
+ * @property {number} [data.labels.image.pos.y=0] y coordinate position, relative to the original.
372
372
  * @memberof Options
373
373
  * @type {object}
374
374
  * @default {}
@@ -402,10 +402,10 @@ export default {
402
402
  * // align text to center of the 'bar' shape (works only for 'bar' type)
403
403
  * centered: true,
404
404
  *
405
- * // apply backgound color for label texts
405
+ * // apply background color for label texts
406
406
  * backgroundColors: "red",
407
407
  *
408
- * // set differenct backround colors per dataset
408
+ * // set different background colors per dataset
409
409
  * backgroundColors: {
410
410
  * data1: "green",
411
411
  * data2: "yellow"
@@ -516,7 +516,7 @@ export default {
516
516
  * pos: { x: 0, y: 0 }
517
517
  * };
518
518
  * } else if(v < 5) {
519
- * // Return falsy value in case of don't want to show image
519
+ * // Return falsy value in case you don't want to show image
520
520
  * return null;
521
521
  * } else {
522
522
  * return {
@@ -567,7 +567,7 @@ export default {
567
567
 
568
568
  /**
569
569
  * Hide each data when the chart appears.<br><br>
570
- * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
570
+ * If true is specified, all of data will be hidden. If multiple ids are specified as an array, those will be hidden.
571
571
  * @name data․hide
572
572
  * @memberof Options
573
573
  * @type {boolean|Array}
@@ -589,7 +589,7 @@ export default {
589
589
  * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter
590
590
  * @name data․filter
591
591
  * @memberof Options
592
- * @type {Function}
592
+ * @type {function}
593
593
  * @default undefined
594
594
  * @example
595
595
  * data: {
@@ -605,13 +605,13 @@ export default {
605
605
 
606
606
  /**
607
607
  * Set a callback for click event on each data point.<br><br>
608
- * This callback will be called when each data point clicked and will receive `d` and element as the arguments.
608
+ * This callback will be called when each data point is clicked and will receive `d` and element as the arguments.
609
609
  * - `d` is the data clicked and element is the element clicked.
610
610
  * - `element` is the current interacting svg element.
611
611
  * - In this callback, `this` will be the Chart object.
612
612
  * @name data․onclick
613
613
  * @memberof Options
614
- * @type {Function}
614
+ * @type {function}
615
615
  * @default function() {}
616
616
  * @example
617
617
  * data: {
@@ -626,13 +626,13 @@ export default {
626
626
 
627
627
  /**
628
628
  * Set a callback for mouse/touch over event on each data point.<br><br>
629
- * This callback will be called when mouse cursor or via touch moves onto each data point and will receive `d` and `element` as the argument.
629
+ * 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.
630
630
  * - `d` is the data where mouse cursor moves onto.
631
631
  * - `element` is the current interacting svg element.
632
632
  * - In this callback, `this` will be the Chart object.
633
633
  * @name data․onover
634
634
  * @memberof Options
635
- * @type {Function}
635
+ * @type {function}
636
636
  * @default function() {}
637
637
  * @example
638
638
  * data: {
@@ -647,13 +647,13 @@ export default {
647
647
 
648
648
  /**
649
649
  * Set a callback for mouse/touch out event on each data point.<br><br>
650
- * This callback will be called when mouse cursor or via touch moves out each data point and will receive `d` as the argument.
650
+ * This callback will be called when the mouse cursor or touch moves out each data point and will receive `d` as the argument.
651
651
  * - `d` is the data where mouse cursor moves out.
652
652
  * - `element` is the current interacting svg element.
653
653
  * - In this callback, `this` will be the Chart object.
654
654
  * @name data․onout
655
655
  * @memberof Options
656
- * @type {Function}
656
+ * @type {function}
657
657
  * @default function() {}
658
658
  * @example
659
659
  * data: {
@@ -671,7 +671,7 @@ export default {
671
671
  * The callback will receive shown data ids in array.
672
672
  * @name data․onshown
673
673
  * @memberof Options
674
- * @type {Function}
674
+ * @type {function}
675
675
  * @default undefined
676
676
  * @example
677
677
  * data: {
@@ -688,7 +688,7 @@ export default {
688
688
  * The callback will receive hidden data ids in array.
689
689
  * @name data․onhidden
690
690
  * @memberof Options
691
- * @type {Function}
691
+ * @type {function}
692
692
  * @default undefined
693
693
  * @example
694
694
  * data: {
@@ -705,7 +705,7 @@ export default {
705
705
  * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
706
706
  * @name data․onmin
707
707
  * @memberof Options
708
- * @type {Function}
708
+ * @type {function}
709
709
  * @default undefined
710
710
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
711
711
  * @example
@@ -721,7 +721,7 @@ export default {
721
721
  * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
722
722
  * @name data․onmax
723
723
  * @memberof Options
724
- * @type {Function}
724
+ * @type {function}
725
725
  * @default undefined
726
726
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.OnMinMaxCallback)
727
727
  * @example
@@ -733,7 +733,7 @@ export default {
733
733
  data_onmax: <Function | undefined>undefined,
734
734
 
735
735
  /**
736
- * Load a CSV or JSON file from a URL. NOTE that this will not work if loading via the "file://" protocol as the most browsers will block XMLHTTPRequests.
736
+ * 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.
737
737
  * @name data․url
738
738
  * @memberof Options
739
739
  * @type {string}
@@ -864,7 +864,7 @@ export default {
864
864
  * }
865
865
  * }
866
866
  *
867
- * // for 'canlestick' type, data should contain:
867
+ * // for 'candlestick' type, data should contain:
868
868
  * // - an array of [open, high, low, close, volume(optional)] data following the order
869
869
  * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
870
870
  * data: {
@@ -940,7 +940,7 @@ export default {
940
940
  * type: "bubble"
941
941
  * }
942
942
  *
943
- * // for 'canlestick' type, data should contain:
943
+ * // for 'candlestick' type, data should contain:
944
944
  * // - an array of [open, high, low, close, volume(optional)] data following the order
945
945
  * // - or an object with 'open', 'high', 'low', 'close' and 'value'(optional) key value
946
946
  * data: {