billboard.js 3.9.4 → 3.10.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 (100) hide show
  1. package/README.md +2 -2
  2. package/dist/billboard.css +2 -2
  3. package/dist/billboard.js +2742 -2516
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +2936 -2704
  7. package/dist/billboard.pkgd.min.js +4 -4
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +15 -15
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +205 -186
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +231 -226
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +172 -152
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +161 -142
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/{billboardjs-plugin-bubblecompare.js → billboardjs-plugin-bubblecompare.pkgd.js} +52 -32
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +12 -0
  20. package/dist/plugin/pkgd/{billboardjs-plugin-sparkline.js → billboardjs-plugin-sparkline.pkgd.js} +239 -200
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +12 -0
  22. package/dist/plugin/pkgd/{billboardjs-plugin-stanford.js → billboardjs-plugin-stanford.pkgd.js} +301 -277
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -0
  24. package/dist/plugin/pkgd/{billboardjs-plugin-tableview.js → billboardjs-plugin-tableview.pkgd.js} +206 -166
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -0
  26. package/dist/plugin/pkgd/{billboardjs-plugin-textoverlap.js → billboardjs-plugin-textoverlap.pkgd.js} +308 -278
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +12 -0
  28. package/dist/theme/dark.css +5 -4
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +5 -4
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +5 -4
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +5 -4
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist-esm/billboard.js +718 -509
  37. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
  38. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +15 -9
  39. package/dist-esm/plugin/billboardjs-plugin-stanford.js +21 -28
  40. package/dist-esm/plugin/billboardjs-plugin-tableview.js +17 -11
  41. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +13 -7
  42. package/package.json +32 -32
  43. package/src/Chart/api/axis.ts +4 -0
  44. package/src/Chart/api/category.ts +8 -4
  45. package/src/Chart/api/export.ts +1 -2
  46. package/src/Chart/api/subchart.ts +162 -89
  47. package/src/Chart/api/zoom.ts +69 -79
  48. package/src/ChartInternal/Axis/AxisRendererHelper.ts +0 -8
  49. package/src/ChartInternal/data/IData.ts +4 -1
  50. package/src/ChartInternal/data/convert.helper.ts +1 -15
  51. package/src/ChartInternal/data/data.ts +8 -2
  52. package/src/ChartInternal/interactions/eventrect.ts +3 -4
  53. package/src/ChartInternal/interactions/flow.ts +1 -7
  54. package/src/ChartInternal/interactions/interaction.ts +11 -5
  55. package/src/ChartInternal/interactions/subchart.ts +36 -30
  56. package/src/ChartInternal/interactions/zoom.ts +13 -3
  57. package/src/ChartInternal/internals/category.ts +2 -2
  58. package/src/ChartInternal/internals/clip.ts +4 -5
  59. package/src/ChartInternal/internals/color.ts +49 -23
  60. package/src/ChartInternal/internals/domain.ts +46 -10
  61. package/src/ChartInternal/internals/grid.ts +57 -86
  62. package/src/ChartInternal/internals/redraw.ts +1 -6
  63. package/src/ChartInternal/internals/region.ts +35 -12
  64. package/src/ChartInternal/internals/selection.ts +1 -1
  65. package/src/ChartInternal/internals/text.ts +1 -26
  66. package/src/ChartInternal/internals/title.ts +10 -48
  67. package/src/ChartInternal/internals/tooltip.ts +50 -54
  68. package/src/ChartInternal/shape/arc.ts +2 -2
  69. package/src/ChartInternal/shape/candlestick.ts +2 -17
  70. package/src/ChartInternal/shape/point.ts +36 -8
  71. package/src/ChartInternal/shape/radar.ts +1 -1
  72. package/src/ChartInternal/shape/shape.ts +50 -4
  73. package/src/ChartInternal/shape/treemap.ts +2 -2
  74. package/src/Plugin/bubblecompare/index.ts +1 -1
  75. package/src/Plugin/sparkline/index.ts +2 -2
  76. package/src/Plugin/stanford/Elements.ts +10 -2
  77. package/src/Plugin/stanford/index.ts +1 -24
  78. package/src/Plugin/tableview/index.ts +2 -2
  79. package/src/config/Options/axis/x.ts +1 -0
  80. package/src/config/Options/common/main.ts +12 -2
  81. package/src/config/Options/common/point.ts +41 -0
  82. package/src/config/Options/common/tooltip.ts +10 -10
  83. package/src/config/Options/data/axis.ts +3 -1
  84. package/src/config/Options/data/data.ts +10 -2
  85. package/src/config/Options/shape/area.ts +10 -4
  86. package/src/config/Options/shape/bar.ts +10 -4
  87. package/src/config/Store/State.ts +3 -0
  88. package/src/module/Cache.ts +7 -5
  89. package/src/module/browser.ts +34 -14
  90. package/src/module/util.ts +8 -4
  91. package/src/module/worker.ts +24 -13
  92. package/src/scss/billboard.scss +4 -2
  93. package/src/scss/theme/dark.scss +4 -2
  94. package/src/scss/theme/datalab.scss +4 -2
  95. package/src/scss/theme/graph.scss +4 -2
  96. package/src/scss/theme/insight.scss +4 -2
  97. package/types/chart.d.ts +11 -0
  98. package/types/options.d.ts +9 -3
  99. package/types/options.shape.d.ts +26 -0
  100. package/types/types.d.ts +15 -1
@@ -35,6 +35,24 @@ function getObjectURL(fn: Function, depsFn?: Function[]): string {
35
35
  return window.URL.createObjectURL(blob[key]);
36
36
  }
37
37
 
38
+ /**
39
+ * Get WebWorker instance
40
+ * @param {string} src URL object as string
41
+ * @returns {object} WebWorker instance
42
+ * @private
43
+ */
44
+ function getWorker(src) {
45
+ const worker = new window.Worker(src);
46
+
47
+ // handle error
48
+ worker.onerror = function(e) {
49
+ // eslint-disable-next-line no-console
50
+ console.error ? console.error(e) : console.log(e);
51
+ };
52
+
53
+ return worker;
54
+ }
55
+
38
56
  /**
39
57
  * Create and run on Web Worker
40
58
  * @param {boolean} useWorker Use Web Worker
@@ -61,11 +79,15 @@ function getObjectURL(fn: Function, depsFn?: Function[]): string {
61
79
  export function runWorker(
62
80
  useWorker = true, fn: Function, callback: Function, depsFn?: Function[]
63
81
  ): Function {
64
- let runFn;
82
+ let runFn = function(...args) {
83
+ const res = fn(...args);
84
+
85
+ callback(res);
86
+ };
65
87
 
66
88
  if (window.Worker && useWorker) {
67
89
  const src = getObjectURL(fn, depsFn);
68
- const worker = new window.Worker(src);
90
+ const worker = getWorker(src);
69
91
 
70
92
  runFn = function(...args) {
71
93
  // trigger worker
@@ -79,22 +101,11 @@ export function runWorker(
79
101
  return callback(e.data);
80
102
  };
81
103
 
82
- // handle error
83
- worker.onerror = function(e) {
84
- console.error(e);
85
- };
86
-
87
104
  // return new Promise((resolve, reject) => {
88
105
  // worker.onmessage = ({data}) => resolve(data);
89
106
  // worker.onerror = reject;
90
107
  // });
91
108
  };
92
- } else {
93
- runFn = function(...args) {
94
- const res = fn(...args);
95
-
96
- callback(res);
97
- };
98
109
  }
99
110
 
100
111
  return runFn;
@@ -136,8 +136,10 @@
136
136
  }
137
137
  /*-- Region --*/
138
138
  .bb-region {
139
- fill: steelblue;
140
- fill-opacity: .1;
139
+ rect {
140
+ fill: steelblue;
141
+ fill-opacity: .1;
142
+ }
141
143
  }
142
144
 
143
145
  /*-- Zoom region --*/
@@ -162,8 +162,10 @@ rect.bb-circle, use.bb-circle {
162
162
 
163
163
  /*-- Region --*/
164
164
  .bb-region {
165
- fill: steelblue;
166
- fill-opacity: 0.5;
165
+ rect {
166
+ fill: steelblue;
167
+ fill-opacity: 0.5;
168
+ }
167
169
 
168
170
  &.selected rect {
169
171
  fill: rgb(39, 201, 3);
@@ -147,8 +147,10 @@ $text-font-size: 11px;
147
147
 
148
148
  /*-- Region --*/
149
149
  .bb-region {
150
- fill: steelblue;
151
- fill-opacity: 0.1;
150
+ rect {
151
+ fill: steelblue;
152
+ fill-opacity: 0.1;
153
+ }
152
154
 
153
155
  &.selected rect {
154
156
  fill: rgb(39, 201, 3);
@@ -158,8 +158,10 @@ rect.bb-circle, use.bb-circle {
158
158
 
159
159
  /*-- Region --*/
160
160
  .bb-region {
161
- fill: steelblue;
162
- fill-opacity: 0.1;
161
+ rect {
162
+ fill: steelblue;
163
+ fill-opacity: 0.1;
164
+ }
163
165
 
164
166
  &.selected rect {
165
167
  fill: rgb(39, 201, 3);
@@ -154,8 +154,10 @@ rect.bb-circle, use.bb-circle {
154
154
 
155
155
  /*-- Region --*/
156
156
  .bb-region {
157
- fill: steelblue;
158
- fill-opacity: 0.1;
157
+ rect {
158
+ fill: steelblue;
159
+ fill-opacity: 0.1;
160
+ }
159
161
 
160
162
  &.selected rect {
161
163
  fill: rgb(39, 201, 3);
package/types/chart.d.ts CHANGED
@@ -251,6 +251,12 @@ export interface Chart {
251
251
  };
252
252
 
253
253
  subchart: {
254
+ /**
255
+ * Select subchart by giving x domain range.
256
+ * @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.
257
+ */
258
+ (domain?: Array<Date|number|string>): Array<Date|number>;
259
+
254
260
  /**
255
261
  * Hide generated subchart
256
262
  * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
@@ -268,6 +274,11 @@ export interface Chart {
268
274
  * - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
269
275
  */
270
276
  toggle(): void;
277
+
278
+ /**
279
+ * Reset subchart selection
280
+ */
281
+ reset(): void;
271
282
  };
272
283
 
273
284
  tooltip: {
@@ -18,6 +18,7 @@ import {
18
18
  PieOptions,
19
19
  PolarOptions,
20
20
  RadarOptions,
21
+ RadialGradientOptions,
21
22
  ScatterOptions,
22
23
  SplineOptions,
23
24
  TreemapOptions
@@ -646,14 +647,14 @@ export interface TooltipOptions {
646
647
  /**
647
648
  * Set x Axis index to be shown at the initialization.
648
649
  */
649
- x?: number;
650
+ x?: number | string;
650
651
 
651
652
  /**
652
653
  * Set the position of tooltip at the initialization.
653
654
  */
654
655
  position?: {
655
- top?: string;
656
- left?: string;
656
+ top?: number | string;
657
+ left?: number | string;
657
658
  }
658
659
  };
659
660
 
@@ -851,6 +852,11 @@ export interface PointOptions {
851
852
  */
852
853
  opacity?: number | null;
853
854
 
855
+ /**
856
+ * Set the radial gradient on point.
857
+ */
858
+ radialGradient?: RadialGradientOptions;
859
+
854
860
  select?: {
855
861
  /**
856
862
  * The radius size of each point on selected.
@@ -709,6 +709,32 @@ export interface LinearGradientOptions {
709
709
  stops?: Array<[number, string | null | ((this: Chart, id: string) => string), number]>;
710
710
  }
711
711
 
712
+ export interface RadialGradientOptions {
713
+ /**
714
+ * cx attribute
715
+ */
716
+ cx?: number;
717
+
718
+ /**
719
+ * cy attribute
720
+ */
721
+ cy?: number;
722
+
723
+ /**
724
+ * r attribute
725
+ */
726
+ r?: number;
727
+
728
+ /**
729
+ * The ramp of colors to use on a gradient
730
+ *
731
+ * offset, stop-color, stop-opacity
732
+ * - setting 'null' for stop-color, will set its original data color
733
+ * - setting 'function' for stop-color, will pass data id as argument. It should return color string or null value
734
+ */
735
+ stops?: Array<[number, string | null | ((this: Chart, id: string) => string), number]>;
736
+ }
737
+
712
738
  export interface TreemapOptions {
713
739
  /**
714
740
  * Treemap tile type
package/types/types.d.ts CHANGED
@@ -54,7 +54,7 @@ export interface DataItem<T=number> {
54
54
 
55
55
  export type DataArray = DataRow[];
56
56
 
57
- export interface RegionsType {
57
+ export interface DataRegionsType {
58
58
  [key: string]: {
59
59
  start?: number;
60
60
  end?: number;
@@ -63,3 +63,17 @@ export interface RegionsType {
63
63
  }
64
64
  };
65
65
  }
66
+
67
+ export interface RegionsType {
68
+ axis?: "x" | "y" | "y2";
69
+ start?: number;
70
+ end?: number;
71
+ class?: string;
72
+ label?: {
73
+ text: string;
74
+ x?: number;
75
+ y?: number;
76
+ color?: string;
77
+ rotated?: boolean;
78
+ };
79
+ }