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
@@ -399,6 +399,21 @@ text.bb-chart-arcs-gauge-title {
399
399
  font-size: 13px;
400
400
  font-weight: bold;
401
401
  }
402
+
403
+ /* Connector line base styles */
404
+ .bb-arc-label-line {
405
+ fill: none;
406
+ stroke-width: 1px;
407
+ pointer-events: none;
408
+ }
409
+
410
+ .bb-arc-label-line {
411
+ stroke: #7f7f7f;
412
+ }
413
+
414
+ > text.bb-arc-label-line-text {
415
+ fill: #000;
416
+ }
402
417
  }
403
418
 
404
419
  /*-- Radar --*/
@@ -377,6 +377,21 @@ text.bb-chart-arcs-gauge-title {
377
377
  fill: #fff;
378
378
  font-size: 13px;
379
379
  }
380
+
381
+ /* Connector line base styles */
382
+ .bb-arc-label-line {
383
+ fill: none;
384
+ stroke-width: 1px;
385
+ pointer-events: none;
386
+ }
387
+
388
+ .bb-arc-label-line {
389
+ stroke: #7f7f7f;
390
+ }
391
+
392
+ > text.bb-arc-label-line-text {
393
+ fill: #000;
394
+ }
380
395
  }
381
396
 
382
397
  /*-- Radar --*/
@@ -397,6 +397,21 @@ text.bb-chart-arcs-gauge-title {
397
397
  fill: #fff;
398
398
  font-size: 11px;
399
399
  }
400
+
401
+ /* Connector line base styles */
402
+ .bb-arc-label-line {
403
+ fill: none;
404
+ stroke-width: 1px;
405
+ pointer-events: none;
406
+ }
407
+
408
+ .bb-arc-label-line {
409
+ stroke: #7f7f7f;
410
+ }
411
+
412
+ > text.bb-arc-label-line-text {
413
+ fill: #000;
414
+ }
400
415
  }
401
416
 
402
417
  /*-- Radar --*/
package/types/axis.d.ts CHANGED
@@ -239,7 +239,7 @@ export interface XTickConfiguration {
239
239
  * - `true`: the ticks will be culled, then only limited tick text will be shown.
240
240
  * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.x.tick.culling.lines=false`.
241
241
  * - `false`: all of ticks will be shown.
242
- * The number of ticks to be shown can be chaned by `axis.x.tick.culling.max`.
242
+ * The number of ticks to be shown can be changed by `axis.x.tick.culling.max`.
243
243
  */
244
244
  culling?: boolean | {
245
245
  /**
@@ -276,7 +276,7 @@ export interface XTickConfiguration {
276
276
  /**
277
277
  * Set the x values of ticks manually.
278
278
  * If this option is provided, the position of the ticks will be determined based on those values.
279
- * This option works with timeseries data and the x values will be parsed accoding to the type of the value and data.xFormat option.
279
+ * This option works with timeseries data and the x values will be parsed according to the type of the value and data.xFormat option.
280
280
  */
281
281
  values?: Array<number|string> | ((this: Chart) => number[]);
282
282
 
@@ -403,7 +403,7 @@ export interface YTickConfiguration {
403
403
  * - `true`: the ticks will be culled, then only limited tick text will be shown.
404
404
  * This option does not hide the tick lines by default, if want to hide tick lines, set `axis.[y|y2].tick.culling.lines=false`.
405
405
  * - `false`: all of ticks will be shown.
406
- * The number of ticks to be shown can be chaned by `axis.[y|y2].tick.culling.max`.
406
+ * The number of ticks to be shown can be changed by `axis.[y|y2].tick.culling.max`.
407
407
  */
408
408
  culling?: boolean | {
409
409
  /**
package/types/chart.d.ts CHANGED
@@ -143,7 +143,7 @@ export interface Chart {
143
143
 
144
144
  /**
145
145
  * Get values of the data loaded in the chart.
146
- * @param targetIds This API returns the values of specified target. If this argument is not given, null will be retruned.
146
+ * @param targetIds This API returns the values of specified target. If this argument is not given, null will be returned.
147
147
  */
148
148
  values(targetIds?: ArrayOrString): number[];
149
149
 
@@ -263,7 +263,7 @@ export interface Chart {
263
263
  subchart: {
264
264
  /**
265
265
  * Select subchart by giving x domain range.
266
- * @param domain If domain range is given, the subchart will be seleted to the given domain. If no argument is given, the current subchart selection domain will be returned.
266
+ * @param domain If domain range is given, the subchart will be selected to the given domain. If no argument is given, the current subchart selection domain will be returned.
267
267
  */
268
268
  (domain?: Array<Date|number|string>): Array<Date|number>;
269
269
 
@@ -394,7 +394,7 @@ export interface Chart {
394
394
  * - If no argument is given, all of targets will be toggles.
395
395
  * - If ids given, the data that has specified target id will be unloaded. ids should be String or Array.
396
396
  * - If ids is not specified, all data will be unloaded.
397
- * - If done given, the specified function will be called after data loded.
397
+ * - If done given, the specified function will be called after data loaded.
398
398
  *
399
399
  * - NOTE:
400
400
  * - If you call load API soon after/before unload, unload param of load should be used. Otherwise chart will not be rendered properly because of cancel of animation.
@@ -510,7 +510,7 @@ export interface Chart {
510
510
 
511
511
  /**
512
512
  * Force to redraw.
513
- * - **NOTE:** When zoom/subchart is used, the zoomed state will be resetted.
513
+ * - **NOTE:** When zoom/subchart is used, the zoomed state will be reset.
514
514
  * @param soft For soft redraw.
515
515
  */
516
516
  flush(soft?: boolean): void;
@@ -374,7 +374,7 @@ export interface ChartOptions {
374
374
  lazy?: boolean;
375
375
 
376
376
  /**
377
- * Observe bind element's visibility(`display` or `visiblity` inline css property or class value) & render when is visible automatically (for IEs, only works IE11+).
377
+ * Observe bind element's visibility(`display` or `visibility` inline css property or class value) & render when is visible automatically (for IEs, only works IE11+).
378
378
  * When set to **false**, call [`.flush()`](./Chart.html#flush) to render.
379
379
  */
380
380
  observe?: boolean;
@@ -911,7 +911,7 @@ export interface PointOptions {
911
911
  };
912
912
 
913
913
  /**
914
- * The senstivity value for interaction boundary.
914
+ * The sensitivity value for interaction boundary.
915
915
  *
916
916
  * - **Available Values:**
917
917
  * - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
@@ -1085,7 +1085,7 @@ export interface Data {
1085
1085
  xs?: { [key: string]: string };
1086
1086
 
1087
1087
  /**
1088
- * Set a format to parse string specifed as x.
1088
+ * Set a format to parse string specified as x.
1089
1089
  * Default is %Y-%m-%d
1090
1090
  */
1091
1091
  xFormat?: string;
@@ -1159,7 +1159,7 @@ export interface Data {
1159
1159
 
1160
1160
  /**
1161
1161
  * Set label text background colors.
1162
- * - **NOTE**: When function is set, background colors can be sepcified one color per dataset.
1162
+ * - **NOTE**: When function is set, background colors can be specified one color per dataset.
1163
1163
  * - Within the function, the last returned color for dataset will be used.
1164
1164
  * - Only can control set or unset background color for each values.
1165
1165
  */
@@ -1361,7 +1361,7 @@ export interface Data {
1361
1361
  /**
1362
1362
  * Define the order of the data.
1363
1363
  * This option changes the order of stacking the data and pieces of pie/donut. If null specified, it will be the order the data loaded.
1364
- * If function specified, it will be used to sort the data and it will recieve the data as argument.
1364
+ * If function specified, it will be used to sort the data and it will receive the data as argument.
1365
1365
  *
1366
1366
  * - Available Values: desc, asc, function (data1, data2) { ... }, null
1367
1367
  * **NOTE**: order function, only works for Axis based types & Arc types, except `Radar` type.
@@ -1419,7 +1419,7 @@ export interface Data {
1419
1419
 
1420
1420
  /**
1421
1421
  * Set multiple data points selection enabled.
1422
- * If this option set true, multile data points can have the selected state at the same time.
1422
+ * If this option set true, multiple data points can have the selected state at the same time.
1423
1423
  * 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.
1424
1424
  */
1425
1425
  multiple?: boolean;
@@ -1455,9 +1455,22 @@ export interface Data {
1455
1455
  * Set the stacking to be normalized
1456
1456
  * - NOTE: For stacking, 'data.groups' option should be set
1457
1457
  * - y Axis will be set in percentage value (0 ~ 100%)
1458
- * - Must have postive values
1459
- */
1460
- normalize?: boolean;
1458
+ * - Must have positive values
1459
+ * - Data not in any group will not be normalized when using perGroup option
1460
+ *
1461
+ * When boolean:
1462
+ * - true: Normalize all grouped data together (all groups combined to 0-100%)
1463
+ *
1464
+ * When object with perGroup:
1465
+ * - perGroup: true - Normalize each group independently (each group becomes 0-100%)
1466
+ * Data not in any group will display with their original values.
1467
+ * If non-grouped data shares the same axis (e.g., y), it will be
1468
+ * displayed on the 0-100 absolute scale. To display original values,
1469
+ * assign them to a separate axis (e.g., y2).
1470
+ */
1471
+ normalize?: boolean | {
1472
+ perGroup?: boolean;
1473
+ };
1461
1474
  };
1462
1475
 
1463
1476
  /**
@@ -5,6 +5,30 @@
5
5
  import {DataItem, GaugeTypes} from "./types";
6
6
  import {Chart} from "./chart";
7
7
 
8
+ /**
9
+ * Label line configuration for arc chart types (donut, pie, polar, gauge).
10
+ * Enable labels to be displayed outside the shape with connector lines.
11
+ */
12
+ export interface LabelLineOptions {
13
+ /**
14
+ * Show or hide connector lines.
15
+ */
16
+ show?: boolean;
17
+
18
+ /**
19
+ * Set the distance of the horizontal part of the connector line in pixels.
20
+ */
21
+ distance?: number;
22
+
23
+ /**
24
+ * Show text at the end of the connector line (outside the shape).
25
+ * - `true`: show data "id" text
26
+ * - `false`: use default formatter (label.format) to show text
27
+ * - `function(value, ratio, id)`: Custom formatter function for the text.
28
+ */
29
+ text?: boolean | ((this: Chart, value: number, ratio: number, id: string) => string);
30
+ }
31
+
8
32
  export interface ArcOptions {
9
33
  /**
10
34
  * Set corner radius of Arc(donut/gauge/pie/polar) shape.
@@ -216,7 +240,7 @@ export interface BarOptions {
216
240
  };
217
241
 
218
242
  /**
219
- * The senstivity offset value for interaction boundary.
243
+ * The sensitivity offset value for interaction boundary.
220
244
  */
221
245
  sensitivity?: number;
222
246
 
@@ -329,6 +353,14 @@ export interface DonutOptions {
329
353
  */
330
354
  threshold?: number;
331
355
 
356
+ /**
357
+ * Enable label with lines (displayed outside with connector lines).
358
+ * - `true`: Enable label with lines with default settings
359
+ * - `false`: Labels are displayed inside the donut slices (default behavior)
360
+ * - `LabelLineOptions`: Enable with custom settings
361
+ */
362
+ line?: boolean | LabelLineOptions;
363
+
332
364
  /**
333
365
  * Set image to be displayed next to the label text.
334
366
  * @example
@@ -498,6 +530,15 @@ export interface GaugeOptions {
498
530
  */
499
531
  threshold?: number;
500
532
 
533
+ /**
534
+ * Enable label with lines (displayed outside with connector lines).
535
+ * - `true`: Enable label with lines with default settings
536
+ * - `false`: Labels are displayed inside the gauge (default behavior)
537
+ * - `LabelLineOptions`: Enable with custom settings
538
+ * - **NOTE:** Not available for multi gauge type.
539
+ */
540
+ line?: boolean | LabelLineOptions;
541
+
501
542
  /**
502
543
  * Set image to be displayed next to the label text.
503
544
  * @example
@@ -700,6 +741,14 @@ export interface PieOptions {
700
741
  */
701
742
  ratio?: ((this: Chart, d: DataItem, radius: number, h: number) => void) | number;
702
743
 
744
+ /**
745
+ * Enable label with lines (displayed outside with connector lines).
746
+ * - `true`: Enable label with lines with default settings
747
+ * - `false`: Labels are displayed inside the pie slices (default behavior)
748
+ * - `LabelLineOptions`: Enable with custom settings
749
+ */
750
+ line?: boolean | LabelLineOptions;
751
+
703
752
  /**
704
753
  * Set image to be displayed next to the label text.
705
754
  * @example
@@ -843,6 +892,14 @@ export interface PolarOptions {
843
892
  */
844
893
  ratio?: ((this: Chart, d: DataItem, radius: number, h: number) => void) | number;
845
894
 
895
+ /**
896
+ * Enable label with lines (displayed outside with connector lines).
897
+ * - `true`: Enable label with lines with default settings
898
+ * - `false`: Labels are displayed inside the polar slices (default behavior)
899
+ * - `LabelLineOptions`: Enable with custom settings
900
+ */
901
+ line?: boolean | LabelLineOptions;
902
+
846
903
  /**
847
904
  * Set image to be displayed next to the label text.
848
905
  * @example
@@ -1142,7 +1199,7 @@ export interface TreemapOptions {
1142
1199
  /**
1143
1200
  * Set formatter for the label.
1144
1201
  */
1145
- format?: (this: Chart, value: number, ratio: number, id: string) => string;
1202
+ format?: (this: Chart, value: number, ratio: number, id: string, size: {width: number, height: number}) => string;
1146
1203
 
1147
1204
  /**
1148
1205
  * Set threshold ratio to show/hide labels.