billboard.js 3.12.4 → 3.13.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 (68) hide show
  1. package/README.md +10 -3
  2. package/dist/billboard.css +167 -118
  3. package/dist/billboard.js +213 -90
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +10 -10
  6. package/dist/billboard.pkgd.js +1212 -1504
  7. package/dist/billboard.pkgd.min.js +15 -15
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +5 -12
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +7 -13
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +9 -21
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +7 -13
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +7 -13
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +597 -628
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +5 -5
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +759 -953
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +6 -6
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +840 -1105
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -12
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +759 -953
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +7 -7
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +832 -1092
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -7
  28. package/dist/theme/dark.css +220 -154
  29. package/dist/theme/dark.min.css +1 -1
  30. package/dist/theme/datalab.css +221 -157
  31. package/dist/theme/datalab.min.css +1 -1
  32. package/dist/theme/graph.css +223 -158
  33. package/dist/theme/graph.min.css +1 -1
  34. package/dist/theme/insight.css +212 -149
  35. package/dist/theme/insight.min.css +1 -1
  36. package/dist/theme/modern.css +223 -159
  37. package/dist/theme/modern.min.css +1 -1
  38. package/dist-esm/billboard.js +249 -73
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  44. package/package.json +28 -42
  45. package/src/Chart/api/show.ts +1 -1
  46. package/src/ChartInternal/ChartInternal.ts +1 -1
  47. package/src/ChartInternal/data/data.ts +11 -0
  48. package/src/ChartInternal/interactions/zoom.ts +12 -1
  49. package/src/ChartInternal/internals/legend.ts +1 -1
  50. package/src/ChartInternal/internals/scale.ts +13 -5
  51. package/src/ChartInternal/shape/line.ts +170 -41
  52. package/src/ChartInternal/shape/shape.ts +8 -5
  53. package/src/config/Options/axis/y2.ts +13 -0
  54. package/src/config/Options/common/legend.ts +3 -2
  55. package/src/config/Options/data/axis.ts +6 -2
  56. package/src/config/Options/data/data.ts +7 -4
  57. package/src/config/Options/shape/bar.ts +22 -6
  58. package/src/config/const.ts +10 -4
  59. package/src/config/resolver/shape.ts +4 -0
  60. package/src/index.esm.ts +1 -0
  61. package/src/module/browser.ts +1 -1
  62. package/src/module/util.ts +2 -2
  63. package/src/module/worker.ts +1 -1
  64. package/types/bb.d.ts +1 -0
  65. package/types/index.d.ts +1 -0
  66. package/types/options.d.ts +6 -6
  67. package/types/options.shape.d.ts +10 -1
  68. package/types/types.d.ts +1 -0
@@ -87,6 +87,7 @@ export default {
87
87
  * - area-spline
88
88
  * - area-spline-range
89
89
  * - area-step
90
+ * - area-step-range
90
91
  * - bar
91
92
  * - bubble
92
93
  * - candlestick
@@ -118,6 +119,7 @@ export default {
118
119
  * areaSpline,
119
120
  * areaSplineRange,
120
121
  * areaStep,
122
+ * areaStepRange,
121
123
  * bar,
122
124
  * bubble,
123
125
  * candlestick,
@@ -167,6 +169,7 @@ export default {
167
169
  * areaSpline,
168
170
  * areaSplineRange,
169
171
  * areaStep,
172
+ * areaStepRange,
170
173
  * bar,
171
174
  * bubble,
172
175
  * candlestick,
@@ -578,7 +581,7 @@ export default {
578
581
 
579
582
  /**
580
583
  * Set a callback for minimum data
581
- * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
584
+ * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
582
585
  * @name data․onmin
583
586
  * @memberof Options
584
587
  * @type {Function}
@@ -594,7 +597,7 @@ export default {
594
597
 
595
598
  /**
596
599
  * Set a callback for maximum data
597
- * - **NOTE:** For 'area-line-range' and 'area-spline-range', `mid` data will be taken for the comparison
600
+ * - **NOTE:** For 'area-line-range', 'area-step-range' and 'area-spline-range', `mid` data will be taken for the comparison
598
601
  * @name data․onmax
599
602
  * @memberof Options
600
603
  * @type {Function}
@@ -701,7 +704,7 @@ export default {
701
704
  * type: "bar"
702
705
  * }
703
706
  *
704
- * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
707
+ * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
705
708
  * // - an array of [high, mid, low] data following the order
706
709
  * // - or an object with 'high', 'mid' and 'low' key value
707
710
  * data: {
@@ -787,7 +790,7 @@ export default {
787
790
  * type: "bar"
788
791
  * }
789
792
  *
790
- * // for 'range' types('area-line-range' or 'area-spline-range'), data should contain:
793
+ * // for 'range' types('area-line-range' or 'area-step-range' or 'area-spline-range'), data should contain:
791
794
  * // - an array of [high, mid, low] data following the order
792
795
  * // - or an object with 'high', 'mid' and 'low' key value
793
796
  * data: {
@@ -26,14 +26,19 @@ export default {
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
28
  * @property {number} [bar.sensitivity=2] The senstivity offset value for interaction boundary.
29
- * @property {number} [bar.width] Change the width of bar chart.
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
+ * - **NOTE:** Criteria for ratio.
32
+ * - When x ticks count is same with the data count, the baseline for ratio is the minimum interval value of x ticks.
33
+ * - ex. when timeseries x values are: [2024-01-01, 2024-02-01, 2024-03-01], the minimum interval will be `2024-02-01 ~ 2024-03-01`
34
+ * - if the minimum interval is 30px, then ratio=1 means 30px.
35
+ * - When x ticks count is lower than the data count, the baseline will be calculated as `chart width / data count`.
36
+ * - ex. when chart width is 500, data count is 5, then ratio=1 means 100px.
31
37
  * @property {number} [bar.width.max] The maximum width value for ratio.
32
38
  * @property {number} [bar.width.dataname] Change the width of bar for indicated dataset only.
33
- * - **NOTE:**
34
- * - Works only for non-stacked bar
35
- * - Bars are centered accoding its total width value
36
39
  * @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
40
+ * - **NOTE:**
41
+ * - Works only for non-stacked bar
37
42
  * @property {number} [bar.width.dataname.max] The maximum width value for ratio.
38
43
  * @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
39
44
  * @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
@@ -101,7 +106,15 @@ export default {
101
106
  *
102
107
  * width: 10,
103
108
  *
104
- * // or
109
+ * // or specify width callback. The callback will receive width, targetsNum, maxDataCount as arguments.
110
+ * // - width: chart area width
111
+ * // - targetsNum: number of targets
112
+ * // - maxDataCount: maximum data count among targets
113
+ * width: function(width, targetsNum, maxDataCount) {
114
+ * return width / (targetsNum * maxDataCount);
115
+ * }
116
+ *
117
+ * // or specify ratio & max
105
118
  * width: {
106
119
  * ratio: 0.2,
107
120
  * max: 20
@@ -132,7 +145,10 @@ export default {
132
145
  bar_radius: <number | {ratio: number} | undefined>undefined,
133
146
  bar_radius_ratio: <number | undefined>undefined,
134
147
  bar_sensitivity: 2,
135
- bar_width: <number | {ratio?: number, max?: number} | undefined>undefined,
148
+ bar_width: <number | ((width: number, targetsNum: number, maxDataCount: number) => number) | {
149
+ ratio?: number,
150
+ max?: number
151
+ } | undefined>undefined,
136
152
  bar_width_ratio: 0.6,
137
153
  bar_width_max: undefined,
138
154
  bar_zerobased: true
@@ -12,6 +12,7 @@ export const TYPE = {
12
12
  AREA_SPLINE: "area-spline",
13
13
  AREA_SPLINE_RANGE: "area-spline-range",
14
14
  AREA_STEP: "area-step",
15
+ AREA_STEP_RANGE: "area-step-range",
15
16
  BAR: "bar",
16
17
  BUBBLE: "bubble",
17
18
  CANDLESTICK: "candlestick",
@@ -38,6 +39,7 @@ export const TYPE_METHOD_NEEDED = {
38
39
  AREA_SPLINE: "initArea",
39
40
  AREA_SPLINE_RANGE: "initArea",
40
41
  AREA_STEP: "initArea",
42
+ AREA_STEP_RANGE: "initArea",
41
43
  BAR: "initBar",
42
44
  BUBBLE: "initCircle",
43
45
  CANDLESTICK: "initCandlestick",
@@ -64,11 +66,13 @@ export const TYPE_BY_CATEGORY = {
64
66
  TYPE.AREA_SPLINE,
65
67
  TYPE.AREA_SPLINE_RANGE,
66
68
  TYPE.AREA_LINE_RANGE,
67
- TYPE.AREA_STEP
69
+ TYPE.AREA_STEP,
70
+ TYPE.AREA_STEP_RANGE
68
71
  ],
69
72
  AreaRange: [
70
73
  TYPE.AREA_SPLINE_RANGE,
71
- TYPE.AREA_LINE_RANGE
74
+ TYPE.AREA_LINE_RANGE,
75
+ TYPE.AREA_STEP_RANGE
72
76
  ],
73
77
  Arc: [
74
78
  TYPE.PIE,
@@ -85,11 +89,13 @@ export const TYPE_BY_CATEGORY = {
85
89
  TYPE.AREA_SPLINE_RANGE,
86
90
  TYPE.AREA_LINE_RANGE,
87
91
  TYPE.STEP,
88
- TYPE.AREA_STEP
92
+ TYPE.AREA_STEP,
93
+ TYPE.AREA_STEP_RANGE
89
94
  ],
90
95
  Step: [
91
96
  TYPE.STEP,
92
- TYPE.AREA_STEP
97
+ TYPE.AREA_STEP,
98
+ TYPE.AREA_STEP_RANGE
93
99
  ],
94
100
  Spline: [
95
101
  TYPE.SPLINE,
@@ -52,6 +52,7 @@ export {
52
52
  areaSpline,
53
53
  areaSplineRange,
54
54
  areaStep,
55
+ areaStepRange,
55
56
  bar,
56
57
  bubble,
57
58
  candlestick,
@@ -109,6 +110,9 @@ let area = (): string => (
109
110
  let areaLineRange = (): string => (
110
111
  extendLine(shapeArea, [optArea]), (areaLineRange = () => TYPE.AREA_LINE_RANGE)()
111
112
  );
113
+ let areaStepRange = (): string => (
114
+ extendLine(shapeArea, [optArea]), (areaStepRange = () => TYPE.AREA_STEP_RANGE)()
115
+ );
112
116
  let areaSpline = () => (
113
117
  extendLine(shapeArea, [optArea, optSpline]), (areaSpline = () => TYPE.AREA_SPLINE)()
114
118
  );
package/src/index.esm.ts CHANGED
@@ -9,6 +9,7 @@ export {
9
9
  areaSpline,
10
10
  areaSplineRange,
11
11
  areaStep,
12
+ areaStepRange,
12
13
  bar,
13
14
  bubble,
14
15
  candlestick,
@@ -26,7 +26,7 @@ function getGlobal() {
26
26
  * @returns {Array} fallback object array
27
27
  * @private
28
28
  */
29
- function getFallback(w) {
29
+ export function getFallback(w?) {
30
30
  const hasRAF = typeof w?.requestAnimationFrame === "function" &&
31
31
  typeof w?.cancelAnimationFrame === "function";
32
32
  const hasRIC = typeof w?.requestIdleCallback === "function" &&
@@ -532,8 +532,8 @@ function getCssRules(styleSheets: any[]) {
532
532
  */
533
533
  function getScrollPosition(node: HTMLElement) {
534
534
  return {
535
- x: (window.pageXOffset ?? window.scrollX ?? 0) + node.scrollLeft ?? 0,
536
- y: (window.pageYOffset ?? window.scrollY ?? 0) + node.scrollTop ?? 0
535
+ x: (window.pageXOffset ?? window.scrollX ?? 0) + (node.scrollLeft ?? 0),
536
+ y: (window.pageYOffset ?? window.scrollY ?? 0) + (node.scrollTop ?? 0)
537
537
  };
538
538
  }
539
539
 
@@ -41,7 +41,7 @@ function getObjectURL(fn: Function, depsFn?: Function[]): string {
41
41
  * @returns {object} WebWorker instance
42
42
  * @private
43
43
  */
44
- function getWorker(src) {
44
+ export function getWorker(src) {
45
45
  const worker = new window.Worker(src);
46
46
 
47
47
  // handle error
package/types/bb.d.ts CHANGED
@@ -38,6 +38,7 @@ export function areaLineRange(): "area-line-range";
38
38
  export function areaSpline(): "area-spline";
39
39
  export function areaSplineRange(): "area-spline-range";
40
40
  export function areaStep(): "area-step";
41
+ export function areaStepRange(): "area-step-range";
41
42
  export function bar(): "bar";
42
43
  export function bubble(): "bubble";
43
44
  export function candlestick(): "candlestick";
package/types/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export {
15
15
  areaSpline,
16
16
  areaSplineRange,
17
17
  areaStep,
18
+ areaStepRange,
18
19
  bar,
19
20
  bubble,
20
21
  candlestick,
@@ -440,7 +440,7 @@ export interface LegendOptions {
440
440
  * Change the position of legend.
441
441
  * Currently bottom, right and inset are supported.
442
442
  */
443
- position?: string;
443
+ position?: "bottom" | "right" | "inset";
444
444
 
445
445
  /**
446
446
  * Change inset legend attributes.
@@ -450,7 +450,7 @@ export interface LegendOptions {
450
450
  * - step: defines the max step the lagend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
451
451
  */
452
452
  inset?: {
453
- anchor?: string;
453
+ anchor?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
454
454
  x?: number;
455
455
  y?: number;
456
456
  step?: number;
@@ -552,7 +552,7 @@ export interface LegendOptions {
552
552
  /**
553
553
  * Set formatter function for legend text.
554
554
  */
555
- format?: (id: string) => string;
555
+ format?: (id: string, dataId?: string) => string;
556
556
 
557
557
  /**
558
558
  * Show full legend text value using system tooltip(via 'title' element).
@@ -1120,7 +1120,7 @@ export interface Data {
1120
1120
  /**
1121
1121
  * Set chart type at once.
1122
1122
  * If this option is specified, the type will be applied to every data. This setting can be overwritten by data.types.
1123
- * - Available Values: area, area-line-range, area-spline, area-spline-range, area-step, bar, bubble, candlestick, donut, gauge, line, pie, radar, scatter, spline, step
1123
+ * - Available Values: area, area-line-range, area-spline, area-spline-range, area-step, area-step-range, bar, bubble, candlestick, donut, gauge, line, pie, radar, scatter, spline, step
1124
1124
  */
1125
1125
  type?: ChartTypes;
1126
1126
 
@@ -1344,13 +1344,13 @@ export interface Data {
1344
1344
 
1345
1345
  /**
1346
1346
  * Set a callback for minimum data
1347
- * - NOTE: For 'area-line-range' and 'area-spline-range', mid data will be taken for the comparison
1347
+ * - NOTE: For 'area-line-range', 'area-step-range' and 'area-spline-range', mid data will be taken for the comparison
1348
1348
  */
1349
1349
  onmin?(this: Chart, d: DataItem[]): void;
1350
1350
 
1351
1351
  /**
1352
1352
  * Set a callback for maximum data
1353
- * - NOTE: For 'area-line-range' and 'area-spline-range', mid data will be taken for the comparison
1353
+ * - NOTE: For 'area-line-range', 'area-step-range' and 'area-spline-range', mid data will be taken for the comparison
1354
1354
  */
1355
1355
  onmax?(this: Chart, d: DataItem[]): void;
1356
1356
 
@@ -217,7 +217,16 @@ export interface BarOptions {
217
217
  /**
218
218
  * Change the width of bar chart. If ratio is specified, change the width of bar chart by ratio.
219
219
  */
220
- width?: number | {
220
+ width?: number | (
221
+ /**
222
+ * Specify width callback
223
+ * The callback will receive width, targetsNum, maxDataCount as arguments.
224
+ * - width: chart area width
225
+ * - targetsNum: number of targets
226
+ * - maxDataCount: maximum data count among targets
227
+ */
228
+ (width: number, targetsNum: number, maxDataCount: number) => number
229
+ ) | {
221
230
  /**
222
231
  * Set the width of each bar by ratio
223
232
  */
package/types/types.d.ts CHANGED
@@ -17,6 +17,7 @@ export type ChartTypes = "area"
17
17
  | "area-spline"
18
18
  | "area-spline-range"
19
19
  | "area-step"
20
+ | "area-step-range"
20
21
  | "bar"
21
22
  | "bubble"
22
23
  | "candlestick"