billboard.js 3.9.2 → 3.10.0-next.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.
- package/README.md +2 -2
- package/dist/billboard.css +2 -2
- package/dist/billboard.js +2705 -2529
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +3516 -3329
- package/dist/billboard.pkgd.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +15 -15
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +215 -196
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +244 -239
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +184 -164
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +170 -151
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/{billboardjs-plugin-bubblecompare.js → billboardjs-plugin-bubblecompare.pkgd.js} +667 -642
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-sparkline.js → billboardjs-plugin-sparkline.pkgd.js} +864 -820
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-stanford.js → billboardjs-plugin-stanford.pkgd.js} +929 -900
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-tableview.js → billboardjs-plugin-tableview.pkgd.js} +833 -788
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +12 -0
- package/dist/plugin/pkgd/{billboardjs-plugin-textoverlap.js → billboardjs-plugin-textoverlap.pkgd.js} +932 -897
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +12 -0
- package/dist/theme/dark.css +5 -4
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +5 -4
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +5 -4
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +5 -4
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +605 -468
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +13 -7
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +21 -28
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +17 -11
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +13 -7
- package/package.json +31 -31
- package/src/Chart/api/axis.ts +4 -0
- package/src/Chart/api/category.ts +8 -4
- package/src/Chart/api/export.ts +1 -2
- package/src/Chart/api/subchart.ts +162 -89
- package/src/Chart/api/zoom.ts +69 -79
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +0 -8
- package/src/ChartInternal/data/IData.ts +4 -1
- package/src/ChartInternal/data/convert.helper.ts +1 -15
- package/src/ChartInternal/data/data.ts +8 -2
- package/src/ChartInternal/interactions/eventrect.ts +0 -1
- package/src/ChartInternal/interactions/flow.ts +1 -7
- package/src/ChartInternal/interactions/interaction.ts +10 -4
- package/src/ChartInternal/interactions/subchart.ts +36 -30
- package/src/ChartInternal/interactions/zoom.ts +13 -3
- package/src/ChartInternal/internals/category.ts +2 -2
- package/src/ChartInternal/internals/clip.ts +4 -4
- package/src/ChartInternal/internals/domain.ts +46 -10
- package/src/ChartInternal/internals/grid.ts +57 -86
- package/src/ChartInternal/internals/redraw.ts +0 -5
- package/src/ChartInternal/internals/region.ts +35 -12
- package/src/ChartInternal/internals/text.ts +1 -26
- package/src/ChartInternal/internals/title.ts +10 -48
- package/src/ChartInternal/internals/tooltip.ts +47 -51
- package/src/ChartInternal/shape/arc.ts +16 -6
- package/src/ChartInternal/shape/candlestick.ts +2 -17
- package/src/ChartInternal/shape/shape.ts +50 -4
- package/src/ChartInternal/shape/treemap.ts +2 -2
- package/src/Plugin/bubblecompare/index.ts +1 -1
- package/src/Plugin/stanford/Elements.ts +10 -2
- package/src/Plugin/stanford/index.ts +1 -24
- package/src/Plugin/tableview/index.ts +2 -2
- package/src/config/Options/axis/x.ts +1 -0
- package/src/config/Options/common/main.ts +12 -2
- package/src/config/Options/common/tooltip.ts +10 -10
- package/src/config/Options/data/axis.ts +3 -1
- package/src/config/Options/data/data.ts +10 -2
- package/src/config/Store/State.ts +3 -0
- package/src/module/Cache.ts +7 -5
- package/src/module/browser.ts +34 -14
- package/src/module/util.ts +8 -4
- package/src/module/worker.ts +24 -13
- package/src/scss/billboard.scss +4 -2
- package/src/scss/theme/dark.scss +4 -2
- package/src/scss/theme/datalab.scss +4 -2
- package/src/scss/theme/graph.scss +4 -2
- package/src/scss/theme/insight.scss +4 -2
- package/types/chart.d.ts +11 -0
- package/types/options.d.ts +3 -3
- package/types/types.d.ts +15 -1
|
@@ -655,7 +655,11 @@ export default {
|
|
|
655
655
|
* {name: "www.site4.com", upload: 400, download: 100, total: 500}
|
|
656
656
|
* ],
|
|
657
657
|
* keys: {
|
|
658
|
-
* //
|
|
658
|
+
* // case 1: specify 'x' key for category axis
|
|
659
|
+
* x: "name", // 'name' key will be used as category x axis values
|
|
660
|
+
* value: ["upload", "download"]
|
|
661
|
+
*
|
|
662
|
+
* // case 2: without 'x' key for non-category axis
|
|
659
663
|
* value: ["upload", "download"]
|
|
660
664
|
* }
|
|
661
665
|
* }
|
|
@@ -857,7 +861,11 @@ export default {
|
|
|
857
861
|
* {name: "www.site4.com", upload: 400, download: 100, total: 500}
|
|
858
862
|
* ],
|
|
859
863
|
* keys: {
|
|
860
|
-
* //
|
|
864
|
+
* // case 1: specify 'x' key for category axis
|
|
865
|
+
* x: "name", // 'name' key will be used as category x axis values
|
|
866
|
+
* value: ["upload", "download"]
|
|
867
|
+
*
|
|
868
|
+
* // case 2: without 'x' key for non-category axis
|
|
861
869
|
* value: ["upload", "download"]
|
|
862
870
|
* }
|
|
863
871
|
* }
|
package/src/module/Cache.ts
CHANGED
|
@@ -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 {
|
|
5
|
+
import {isString, isValue} from "./util";
|
|
6
6
|
import type {DataRow} from "../../types/types";
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -45,7 +45,8 @@ export default class Cache {
|
|
|
45
45
|
* @private
|
|
46
46
|
*/
|
|
47
47
|
remove(key: string | string[]) {
|
|
48
|
-
|
|
48
|
+
(isString(key) ? [key] : key)
|
|
49
|
+
.forEach(v => delete this.cache[v]);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -55,8 +56,9 @@ export default class Cache {
|
|
|
55
56
|
* @returns {*}
|
|
56
57
|
* @private
|
|
57
58
|
*/
|
|
58
|
-
get(key: string, isDataType = false): any | null {
|
|
59
|
-
|
|
59
|
+
get(key: string|string[], isDataType = false): any | null {
|
|
60
|
+
// when is isDataType, key should be string array
|
|
61
|
+
if (isDataType && Array.isArray(key)) {
|
|
60
62
|
const targets: any[] = [];
|
|
61
63
|
|
|
62
64
|
for (let i = 0, id; (id = key[i]); i++) {
|
|
@@ -67,7 +69,7 @@ export default class Cache {
|
|
|
67
69
|
|
|
68
70
|
return targets;
|
|
69
71
|
} else {
|
|
70
|
-
const value = this.cache[key];
|
|
72
|
+
const value = this.cache[key as string];
|
|
71
73
|
|
|
72
74
|
return isValue(value) ? value : null;
|
|
73
75
|
}
|
package/src/module/browser.ts
CHANGED
|
@@ -14,22 +14,42 @@ export {
|
|
|
14
14
|
requestIdleCallback, cancelIdleCallback
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Get global object
|
|
19
|
+
* @returns {object} window object
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
function getGlobal() {
|
|
23
|
+
return (typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis) ||
|
|
19
24
|
(typeof global === "object" && global !== null && global.Object === Object && global) ||
|
|
20
|
-
(typeof self === "object" && self !== null && self.Object === Object && self)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
})();
|
|
24
|
-
/* eslint-enable no-new-func, no-undef */
|
|
25
|
+
(typeof self === "object" && self !== null && self.Object === Object && self) ||
|
|
26
|
+
Function("return this")();
|
|
27
|
+
}
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Get fallback object
|
|
31
|
+
* @param {object} w global object
|
|
32
|
+
* @returns {Array} fallback object array
|
|
33
|
+
* @private
|
|
34
|
+
*/
|
|
35
|
+
function getFallback(w) {
|
|
36
|
+
const hasRAF = typeof w?.requestAnimationFrame === "function";
|
|
37
|
+
const hasRIC = typeof w?.requestIdleCallback === "function";
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
return [
|
|
40
|
+
hasRAF ? w.requestAnimationFrame : (cb => setTimeout(cb, 1)),
|
|
41
|
+
hasRAF ? w.cancelAnimationFrame : (id => clearTimeout(id)),
|
|
42
|
+
hasRIC ? w.requestIdleCallback : requestAnimationFrame,
|
|
43
|
+
hasRIC ? w.cancelIdleCallback : cancelAnimationFrame
|
|
44
|
+
];
|
|
45
|
+
}
|
|
34
46
|
|
|
47
|
+
const win = getGlobal();
|
|
35
48
|
const doc = win?.document;
|
|
49
|
+
|
|
50
|
+
const [
|
|
51
|
+
requestAnimationFrame,
|
|
52
|
+
cancelAnimationFrame,
|
|
53
|
+
requestIdleCallback,
|
|
54
|
+
cancelIdleCallback
|
|
55
|
+
] = getFallback(win);
|
package/src/module/util.ts
CHANGED
|
@@ -53,7 +53,7 @@ export {
|
|
|
53
53
|
notEmpty,
|
|
54
54
|
parseDate,
|
|
55
55
|
runUntil,
|
|
56
|
-
|
|
56
|
+
sanitize,
|
|
57
57
|
setTextValue,
|
|
58
58
|
sortValue,
|
|
59
59
|
toArray,
|
|
@@ -168,9 +168,9 @@ function endall(transition, cb: Function): void {
|
|
|
168
168
|
* @returns {string}
|
|
169
169
|
* @private
|
|
170
170
|
*/
|
|
171
|
-
function
|
|
171
|
+
function sanitize(str: string): string {
|
|
172
172
|
return isString(str) ?
|
|
173
|
-
str.replace(
|
|
173
|
+
str.replace(/<(script|img)?/ig, "<").replace(/(script)?>/ig, ">") : str;
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
/**
|
|
@@ -266,7 +266,11 @@ function getPathBox(
|
|
|
266
266
|
*/
|
|
267
267
|
function getPointer(event, element?: Element): number[] {
|
|
268
268
|
const touches = event && (event.touches || (event.sourceEvent && event.sourceEvent.touches))?.[0];
|
|
269
|
-
|
|
269
|
+
let pointer = [0, 0];
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
pointer = d3Pointer(touches || event, element);
|
|
273
|
+
} catch (e) {}
|
|
270
274
|
|
|
271
275
|
return pointer.map(v => (isNaN(v) ? 0 : v));
|
|
272
276
|
}
|
package/src/module/worker.ts
CHANGED
|
@@ -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 =
|
|
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;
|
package/src/scss/billboard.scss
CHANGED
package/src/scss/theme/dark.scss
CHANGED
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: {
|
package/types/options.d.ts
CHANGED
|
@@ -646,14 +646,14 @@ export interface TooltipOptions {
|
|
|
646
646
|
/**
|
|
647
647
|
* Set x Axis index to be shown at the initialization.
|
|
648
648
|
*/
|
|
649
|
-
x?: number;
|
|
649
|
+
x?: number | string;
|
|
650
650
|
|
|
651
651
|
/**
|
|
652
652
|
* Set the position of tooltip at the initialization.
|
|
653
653
|
*/
|
|
654
654
|
position?: {
|
|
655
|
-
top?: string;
|
|
656
|
-
left?: string;
|
|
655
|
+
top?: number | string;
|
|
656
|
+
left?: number | string;
|
|
657
657
|
}
|
|
658
658
|
};
|
|
659
659
|
|
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
|
|
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
|
+
}
|