billboard.js 3.5.0 → 3.5.1

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 (67) hide show
  1. package/README.md +1 -1
  2. package/dist/billboard.css +1 -1
  3. package/dist/billboard.js +105 -73
  4. package/dist/billboard.min.css +1 -1
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +134 -85
  7. package/dist/billboard.pkgd.min.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +2 -71
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +2 -71
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +2 -71
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -71
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +31 -14
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +31 -83
  20. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +31 -83
  21. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +31 -83
  22. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +31 -83
  23. package/dist/theme/datalab.css +1 -1
  24. package/dist/theme/datalab.min.css +1 -1
  25. package/dist/theme/graph.css +1 -1
  26. package/dist/theme/graph.min.css +1 -1
  27. package/dist/theme/insight.css +1 -1
  28. package/dist/theme/insight.min.css +1 -1
  29. package/dist-esm/billboard.js +97 -72
  30. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  34. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  35. package/package.json +10 -10
  36. package/src/Chart/api/data.ts +2 -2
  37. package/src/Chart/api/selection.ts +1 -1
  38. package/src/ChartInternal/Axis/AxisRenderer.ts +1 -1
  39. package/src/ChartInternal/Axis/AxisRendererHelper.ts +1 -1
  40. package/src/ChartInternal/ChartInternal.ts +1 -1
  41. package/src/ChartInternal/data/convert.ts +3 -2
  42. package/src/ChartInternal/data/data.ts +1 -1
  43. package/src/ChartInternal/interactions/drag.ts +1 -1
  44. package/src/ChartInternal/internals/color.ts +1 -1
  45. package/src/ChartInternal/internals/domain.ts +1 -1
  46. package/src/ChartInternal/internals/format.ts +1 -1
  47. package/src/ChartInternal/internals/region.ts +1 -1
  48. package/src/ChartInternal/internals/scale.ts +1 -1
  49. package/src/ChartInternal/internals/size.axis.ts +1 -1
  50. package/src/ChartInternal/internals/style.ts +2 -2
  51. package/src/ChartInternal/internals/text.ts +2 -2
  52. package/src/ChartInternal/internals/tooltip.ts +1 -1
  53. package/src/ChartInternal/shape/arc.ts +2 -2
  54. package/src/ChartInternal/shape/area.ts +3 -2
  55. package/src/ChartInternal/shape/bar.ts +2 -2
  56. package/src/ChartInternal/shape/point.ts +1 -1
  57. package/src/ChartInternal/shape/polar.ts +1 -1
  58. package/src/ChartInternal/shape/shape.ts +2 -2
  59. package/src/Plugin/sparkline/index.ts +1 -1
  60. package/src/Plugin/textoverlap/index.ts +1 -1
  61. package/src/config/Options/data/data.ts +1 -1
  62. package/src/config/Store/Element.ts +1 -1
  63. package/src/module/Cache.ts +1 -1
  64. package/src/module/generator.ts +1 -1
  65. package/src/module/util.ts +1 -74
  66. package/src/module/worker.ts +101 -0
  67. package/types/axis.d.ts +2 -2
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {d3Selection} from "billboard.js/types/types";
5
+ import type {d3Selection} from "billboard.js/types/types";
6
6
  import {Delaunay as d3Delaunay} from "d3-delaunay";
7
7
  import {
8
8
  polygonCentroid as d3PolygonCentroid,
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {ChartTypes} from "../../../../types/types";
5
+ import type {ChartTypes} from "../../../../types/types";
6
6
 
7
7
  /**
8
8
  * data config options
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {d3Selection} from "../../../types/types";
5
+ import type {d3Selection} from "../../../types/types";
6
6
 
7
7
  type T = d3Selection | null;
8
8
 
@@ -3,7 +3,7 @@
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
5
  import {isValue, toArray} from "./util";
6
- import {DataRow} from "../../types/types";
6
+ import type {DataRow} from "../../types/types";
7
7
 
8
8
  /**
9
9
  * Constant for cache key
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) 2017 ~ present NAVER Corp.
3
3
  * billboard.js project is licensed under the MIT license
4
4
  */
5
- import {d3Transition} from "../../types/types";
5
+ import type {d3Transition} from "../../types/types";
6
6
  import {window} from "./browser";
7
7
  import {isArray, isNumber, isTabVisible, runUntil} from "./util";
8
8
 
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import {pointer as d3Pointer} from "d3-selection";
7
7
  import {brushSelection as d3BrushSelection} from "d3-brush";
8
- import {d3Selection} from "../../types/types";
8
+ import type {d3Selection} from "../../types/types";
9
9
  import {document, window} from "./browser";
10
10
 
11
11
  export {
@@ -53,7 +53,6 @@ export {
53
53
  notEmpty,
54
54
  parseDate,
55
55
  runUntil,
56
- runWorker,
57
56
  sanitise,
58
57
  setTextValue,
59
58
  sortValue,
@@ -798,78 +797,6 @@ function convertInputType(mouse: boolean, touch: boolean): "mouse" | "touch" | n
798
797
  return (hasMouse && "mouse") || (hasTouch && "touch") || "mouse";
799
798
  }
800
799
 
801
- /**
802
- * Create and run on Web Worker
803
- * @param {boolean} useWorker Use Web Worker
804
- * @param {Function} fn Function to be executed in worker
805
- * @param {Function} callback Callback function to receive result from worker
806
- * @param {Array} depsFn Dependency functions to run given function(fn).
807
- * @returns {object}
808
- * @example
809
- * const worker = runWorker(function(arg) {
810
- * // do some tasks...
811
- * console.log("param:", A(arg));
812
- *
813
- * return 1234;
814
- * }, function(data) {
815
- * // callback after worker is done
816
- * console.log("result:", data);
817
- * },
818
- * [function A(){}]
819
- * );
820
- *
821
- * worker(11111);
822
- * @private
823
- */
824
- function runWorker(
825
- useWorker = true, fn: Function, callback: Function, depsFn?: Function[]
826
- ): Function {
827
- let runFn;
828
-
829
- if (window.Worker && useWorker) {
830
- // Web Worker body
831
- const blob = new Blob([
832
- `${depsFn?.map(String).join(";") ?? ""}
833
-
834
- self.onmessage=function({data}) {
835
- const result = (${fn.toString()}).apply(null, data);
836
- self.postMessage(result);
837
- };`
838
- ], {
839
- type: "text/javascript"
840
- });
841
- const worker = new Worker(URL.createObjectURL(blob));
842
-
843
- runFn = function(...args) {
844
- // trigger worker
845
- worker.postMessage(args);
846
-
847
- // listen worker
848
- worker.onmessage = function(e) {
849
- return callback(e.data);
850
- };
851
-
852
- // handle error
853
- worker.onerror = function(e) {
854
- console.error(e);
855
- };
856
-
857
- // return new Promise((resolve, reject) => {
858
- // worker.onmessage = ({data}) => resolve(data);
859
- // worker.onerror = reject;
860
- // });
861
- };
862
- } else {
863
- runFn = function(...args) {
864
- const res = fn(...args);
865
-
866
- callback(res);
867
- };
868
- }
869
-
870
- return runFn;
871
- }
872
-
873
800
  /**
874
801
  * Run function until given condition function return true
875
802
  * @param {Function} fn Function to be executed when condition is true
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Copyright (c) 2017 ~ present NAVER Corp.
3
+ * billboard.js project is licensed under the MIT license
4
+ */
5
+ import {window} from "./browser";
6
+
7
+ // Store blob in memory
8
+ const blob = {};
9
+
10
+ /**
11
+ * Get Object URL
12
+ * @param {Function} fn Function to be executed in worker
13
+ * @param {Array} depsFn Dependency functions to run given function(fn).
14
+ * @returns {string}
15
+ * @private
16
+ */
17
+ function getObjectURL(fn: Function, depsFn?: Function[]): string {
18
+ const fnString = fn.toString();
19
+ const key = fnString.replace(/(function|[\s\W\n])/g, "").substring(0, 15);
20
+
21
+ if (!(key in blob)) {
22
+ // Web Worker body
23
+ blob[key] = new window.Blob([
24
+ `${depsFn?.map(String).join(";") ?? ""}
25
+
26
+ self.onmessage=function({data}) {
27
+ const result = (${fnString}).apply(null, data);
28
+ self.postMessage(result);
29
+ };`
30
+ ], {
31
+ type: "text/javascript"
32
+ });
33
+ }
34
+
35
+ return window.URL.createObjectURL(blob[key]);
36
+ }
37
+
38
+ /**
39
+ * Create and run on Web Worker
40
+ * @param {boolean} useWorker Use Web Worker
41
+ * @param {Function} fn Function to be executed in worker
42
+ * @param {Function} callback Callback function to receive result from worker
43
+ * @param {Array} depsFn Dependency functions to run given function(fn).
44
+ * @returns {object}
45
+ * @example
46
+ * const worker = runWorker(function(arg) {
47
+ * // do some tasks...
48
+ * console.log("param:", A(arg));
49
+ *
50
+ * return 1234;
51
+ * }, function(data) {
52
+ * // callback after worker is done
53
+ * console.log("result:", data);
54
+ * },
55
+ * [function A(){}]
56
+ * );
57
+ *
58
+ * worker(11111);
59
+ * @private
60
+ */
61
+ export function runWorker(
62
+ useWorker = true, fn: Function, callback: Function, depsFn?: Function[]
63
+ ): Function {
64
+ let runFn;
65
+
66
+ if (window.Worker && useWorker) {
67
+ const src = getObjectURL(fn, depsFn);
68
+ const worker = new window.Worker(src);
69
+
70
+ runFn = function(...args) {
71
+ // trigger worker
72
+ worker.postMessage(args);
73
+
74
+ // listen worker
75
+ worker.onmessage = function(e) {
76
+ // release object URL from memory
77
+ window.URL.revokeObjectURL(src);
78
+
79
+ return callback(e.data);
80
+ };
81
+
82
+ // handle error
83
+ worker.onerror = function(e) {
84
+ console.error(e);
85
+ };
86
+
87
+ // return new Promise((resolve, reject) => {
88
+ // worker.onmessage = ({data}) => resolve(data);
89
+ // worker.onerror = reject;
90
+ // });
91
+ };
92
+ } else {
93
+ runFn = function(...args) {
94
+ const res = fn(...args);
95
+
96
+ callback(res);
97
+ };
98
+ }
99
+
100
+ return runFn;
101
+ }
package/types/axis.d.ts CHANGED
@@ -192,7 +192,7 @@ export interface XTickConfiguration {
192
192
  * A function to format tick value. Format string is also available for timeseries data.
193
193
  */
194
194
  format?: string
195
- | ((this: Chart, x: number | Date) => string | number)
195
+ | ((this: Chart, x: Date) => string | number)
196
196
  | ((this: Chart, index: number, categoryName: string) => string);
197
197
 
198
198
  /**
@@ -337,7 +337,7 @@ export interface YTickConfiguration {
337
337
  * Set formatter for y axis tick text.
338
338
  * This option accepts d3.format object as well as a function you define.
339
339
  */
340
- format?(this: Chart, x: number): string;
340
+ format?(this: Chart, x: number | Date): string | number;
341
341
 
342
342
  /**
343
343
  * Setting for culling ticks.