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
package/dist-esm/billboard.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 3.
|
|
8
|
+
* @version 3.10.0-next.1
|
|
9
9
|
*/
|
|
10
10
|
import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
|
|
11
11
|
import { pointer, select, namespaces, selectAll } from 'd3-selection';
|
|
@@ -30,21 +30,36 @@ import { zoomIdentity, zoomTransform, zoom as zoom$2 } from 'd3-zoom';
|
|
|
30
30
|
* @private
|
|
31
31
|
*/
|
|
32
32
|
/* eslint-disable no-new-func, no-undef */
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Get global object
|
|
35
|
+
* @returns {object} window object
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
function getGlobal() {
|
|
39
|
+
return (typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis) ||
|
|
35
40
|
(typeof global === "object" && global !== null && global.Object === Object && global) ||
|
|
36
|
-
(typeof self === "object" && self !== null && self.Object === Object && self)
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
(typeof self === "object" && self !== null && self.Object === Object && self) ||
|
|
42
|
+
Function("return this")();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get fallback object
|
|
46
|
+
* @param {object} w global object
|
|
47
|
+
* @returns {Array} fallback object array
|
|
48
|
+
* @private
|
|
49
|
+
*/
|
|
50
|
+
function getFallback(w) {
|
|
51
|
+
var hasRAF = typeof (w === null || w === void 0 ? void 0 : w.requestAnimationFrame) === "function";
|
|
52
|
+
var hasRIC = typeof (w === null || w === void 0 ? void 0 : w.requestIdleCallback) === "function";
|
|
53
|
+
return [
|
|
54
|
+
hasRAF ? w.requestAnimationFrame : (function (cb) { return setTimeout(cb, 1); }),
|
|
55
|
+
hasRAF ? w.cancelAnimationFrame : (function (id) { return clearTimeout(id); }),
|
|
56
|
+
hasRIC ? w.requestIdleCallback : requestAnimationFrame,
|
|
57
|
+
hasRIC ? w.cancelIdleCallback : cancelAnimationFrame
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
var win = getGlobal();
|
|
47
61
|
var doc = win === null || win === void 0 ? void 0 : win.document;
|
|
62
|
+
var _a = getFallback(win), requestAnimationFrame = _a[0], cancelAnimationFrame = _a[1], requestIdleCallback = _a[2];
|
|
48
63
|
|
|
49
64
|
/**
|
|
50
65
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
@@ -285,9 +300,9 @@ function endall(transition, cb) {
|
|
|
285
300
|
* @returns {string}
|
|
286
301
|
* @private
|
|
287
302
|
*/
|
|
288
|
-
function
|
|
303
|
+
function sanitize(str) {
|
|
289
304
|
return isString(str) ?
|
|
290
|
-
str.replace(
|
|
305
|
+
str.replace(/<(script|img)?/ig, "<").replace(/(script)?>/ig, ">") : str;
|
|
291
306
|
}
|
|
292
307
|
/**
|
|
293
308
|
* Set text value. If there's multiline add nodes.
|
|
@@ -372,7 +387,11 @@ function getPathBox(path) {
|
|
|
372
387
|
function getPointer(event, element) {
|
|
373
388
|
var _a;
|
|
374
389
|
var touches = event && ((_a = (event.touches || (event.sourceEvent && event.sourceEvent.touches))) === null || _a === void 0 ? void 0 : _a[0]);
|
|
375
|
-
var pointer$1 =
|
|
390
|
+
var pointer$1 = [0, 0];
|
|
391
|
+
try {
|
|
392
|
+
pointer$1 = pointer(touches || event, element);
|
|
393
|
+
}
|
|
394
|
+
catch (e) { }
|
|
376
395
|
return pointer$1.map(function (v) { return (isNaN(v) ? 0 : v); });
|
|
377
396
|
}
|
|
378
397
|
/**
|
|
@@ -1161,6 +1180,8 @@ var State = /** @class */ (function () {
|
|
|
1161
1180
|
// for data CSS rule index (used when boost.useCssRule is true)
|
|
1162
1181
|
cssRule: {},
|
|
1163
1182
|
current: {
|
|
1183
|
+
// current domain value. Assigned when is zoom is called
|
|
1184
|
+
domain: undefined,
|
|
1164
1185
|
// chart whole dimension
|
|
1165
1186
|
width: 0,
|
|
1166
1187
|
height: 0,
|
|
@@ -1286,10 +1307,6 @@ var Store = /** @class */ (function () {
|
|
|
1286
1307
|
return Store;
|
|
1287
1308
|
}());
|
|
1288
1309
|
|
|
1289
|
-
/**
|
|
1290
|
-
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
1291
|
-
* billboard.js project is licensed under the MIT license
|
|
1292
|
-
*/
|
|
1293
1310
|
/**
|
|
1294
1311
|
* main config options
|
|
1295
1312
|
*/
|
|
@@ -1664,13 +1681,21 @@ var main = {
|
|
|
1664
1681
|
* @memberof Options
|
|
1665
1682
|
* @type {Array}
|
|
1666
1683
|
* @default []
|
|
1684
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Region.RegionLabel)
|
|
1667
1685
|
* @example
|
|
1668
1686
|
* regions: [
|
|
1669
1687
|
* {
|
|
1670
1688
|
* axis: "x",
|
|
1671
1689
|
* start: 1,
|
|
1672
1690
|
* end: 4,
|
|
1673
|
-
* class: "region-1-4"
|
|
1691
|
+
* class: "region-1-4",
|
|
1692
|
+
* label: {
|
|
1693
|
+
* text: "Region Text",
|
|
1694
|
+
* x: 5, // position relative of the initial x coordinate
|
|
1695
|
+
* y: 5, // position relative of the initial y coordinate
|
|
1696
|
+
* color: "red", // color string
|
|
1697
|
+
* rotated: true // make text to show in vertical or horizontal
|
|
1698
|
+
* }
|
|
1674
1699
|
* }
|
|
1675
1700
|
* ]
|
|
1676
1701
|
*/
|
|
@@ -2328,7 +2353,11 @@ var data$2 = {
|
|
|
2328
2353
|
* {name: "www.site4.com", upload: 400, download: 100, total: 500}
|
|
2329
2354
|
* ],
|
|
2330
2355
|
* keys: {
|
|
2331
|
-
* //
|
|
2356
|
+
* // case 1: specify 'x' key for category axis
|
|
2357
|
+
* x: "name", // 'name' key will be used as category x axis values
|
|
2358
|
+
* value: ["upload", "download"]
|
|
2359
|
+
*
|
|
2360
|
+
* // case 2: without 'x' key for non-category axis
|
|
2332
2361
|
* value: ["upload", "download"]
|
|
2333
2362
|
* }
|
|
2334
2363
|
* }
|
|
@@ -2526,7 +2555,11 @@ var data$2 = {
|
|
|
2526
2555
|
* {name: "www.site4.com", upload: 400, download: 100, total: 500}
|
|
2527
2556
|
* ],
|
|
2528
2557
|
* keys: {
|
|
2529
|
-
* //
|
|
2558
|
+
* // case 1: specify 'x' key for category axis
|
|
2559
|
+
* x: "name", // 'name' key will be used as category x axis values
|
|
2560
|
+
* value: ["upload", "download"]
|
|
2561
|
+
*
|
|
2562
|
+
* // case 2: without 'x' key for non-category axis
|
|
2530
2563
|
* value: ["upload", "download"]
|
|
2531
2564
|
* }
|
|
2532
2565
|
* }
|
|
@@ -2913,9 +2946,9 @@ var tooltip$2 = {
|
|
|
2913
2946
|
* Specified function receives x of the data point to show.
|
|
2914
2947
|
* @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
|
|
2915
2948
|
* Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
|
|
2916
|
-
* @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip. If undefined returned, the row of that value will be skipped to be called.
|
|
2949
|
+
* @property {Function} [tooltip.format.value] Set format for the value of each data value in tooltip. If undefined returned, the row of that value will be skipped to be called.
|
|
2917
2950
|
* - Will pass following arguments to the given function:
|
|
2918
|
-
* - `value {string}`: Value of the data point
|
|
2951
|
+
* - `value {string}`: Value of the data point. If data row contains multiple or ranged(ex. candlestick, area range, etc.) value, formatter will be called as value length.
|
|
2919
2952
|
* - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
|
|
2920
2953
|
* - `id {string}`: id of the data point
|
|
2921
2954
|
* - `index {number}`: Index of the data point
|
|
@@ -2954,7 +2987,7 @@ var tooltip$2 = {
|
|
|
2954
2987
|
* - The value array length should match with the data length
|
|
2955
2988
|
* @property {boolean} [tooltip.init.show=false] Show tooltip at the initialization.
|
|
2956
2989
|
* @property {number} [tooltip.init.x=0] Set x Axis index(or index for Arc(donut, gauge, pie) types) to be shown at the initialization.
|
|
2957
|
-
* @property {object} [tooltip.init.position
|
|
2990
|
+
* @property {object} [tooltip.init.position] Set the position of tooltip at the initialization.
|
|
2958
2991
|
* @property {Function} [tooltip.onshow] Set a callback that will be invoked before the tooltip is shown.
|
|
2959
2992
|
* @property {Function} [tooltip.onhide] Set a callback that will be invoked before the tooltip is hidden.
|
|
2960
2993
|
* @property {Function} [tooltip.onshown] Set a callback that will be invoked after the tooltip is shown
|
|
@@ -2980,6 +3013,9 @@ var tooltip$2 = {
|
|
|
2980
3013
|
* format: {
|
|
2981
3014
|
* title: function(x) { return "Data " + x; },
|
|
2982
3015
|
* name: function(name, ratio, id, index) { return name; },
|
|
3016
|
+
*
|
|
3017
|
+
* // If data row contains multiple or ranged(ex. candlestick, area range, etc.) value,
|
|
3018
|
+
* // formatter will be called as value length times.
|
|
2983
3019
|
* value: function(value, ratio, id, index) { return ratio; }
|
|
2984
3020
|
* },
|
|
2985
3021
|
* position: function(data, width, height, element, pos) {
|
|
@@ -3046,10 +3082,10 @@ var tooltip$2 = {
|
|
|
3046
3082
|
* // show at the initialization
|
|
3047
3083
|
* init: {
|
|
3048
3084
|
* show: true,
|
|
3049
|
-
* x: 2, // x Axis index(or index for Arc(donut, gauge, pie) types)
|
|
3085
|
+
* x: 2, // x Axis index (or index for Arc(donut, gauge, pie) types)
|
|
3050
3086
|
* position: {
|
|
3051
|
-
* top: "150px",
|
|
3052
|
-
* left:
|
|
3087
|
+
* top: "150px", // specify as number or as string with 'px' unit string
|
|
3088
|
+
* left: 250 // specify as number or as string with 'px' unit string
|
|
3053
3089
|
* }
|
|
3054
3090
|
* },
|
|
3055
3091
|
*
|
|
@@ -3101,10 +3137,7 @@ var tooltip$2 = {
|
|
|
3101
3137
|
tooltip_contents: {},
|
|
3102
3138
|
tooltip_init_show: false,
|
|
3103
3139
|
tooltip_init_x: 0,
|
|
3104
|
-
tooltip_init_position:
|
|
3105
|
-
top: "0px",
|
|
3106
|
-
left: "50px"
|
|
3107
|
-
},
|
|
3140
|
+
tooltip_init_position: undefined,
|
|
3108
3141
|
tooltip_linked: false,
|
|
3109
3142
|
tooltip_linked_name: "",
|
|
3110
3143
|
tooltip_onshow: function () { },
|
|
@@ -3177,7 +3210,8 @@ var Cache = /** @class */ (function () {
|
|
|
3177
3210
|
*/
|
|
3178
3211
|
Cache.prototype.remove = function (key) {
|
|
3179
3212
|
var _this = this;
|
|
3180
|
-
|
|
3213
|
+
(isString(key) ? [key] : key)
|
|
3214
|
+
.forEach(function (v) { return delete _this.cache[v]; });
|
|
3181
3215
|
};
|
|
3182
3216
|
/**
|
|
3183
3217
|
* Get cahce
|
|
@@ -3188,7 +3222,8 @@ var Cache = /** @class */ (function () {
|
|
|
3188
3222
|
*/
|
|
3189
3223
|
Cache.prototype.get = function (key, isDataType) {
|
|
3190
3224
|
if (isDataType === void 0) { isDataType = false; }
|
|
3191
|
-
|
|
3225
|
+
// when is isDataType, key should be string array
|
|
3226
|
+
if (isDataType && Array.isArray(key)) {
|
|
3192
3227
|
var targets = [];
|
|
3193
3228
|
for (var i = 0, id = void 0; (id = key[i]); i++) {
|
|
3194
3229
|
if (id in this.cache) {
|
|
@@ -3342,6 +3377,21 @@ function getObjectURL(fn, depsFn) {
|
|
|
3342
3377
|
}
|
|
3343
3378
|
return win.URL.createObjectURL(blob[key]);
|
|
3344
3379
|
}
|
|
3380
|
+
/**
|
|
3381
|
+
* Get WebWorker instance
|
|
3382
|
+
* @param {string} src URL object as string
|
|
3383
|
+
* @returns {object} WebWorker instance
|
|
3384
|
+
* @private
|
|
3385
|
+
*/
|
|
3386
|
+
function getWorker(src) {
|
|
3387
|
+
var worker = new win.Worker(src);
|
|
3388
|
+
// handle error
|
|
3389
|
+
worker.onerror = function (e) {
|
|
3390
|
+
// eslint-disable-next-line no-console
|
|
3391
|
+
console.error ? console.error(e) : console.log(e);
|
|
3392
|
+
};
|
|
3393
|
+
return worker;
|
|
3394
|
+
}
|
|
3345
3395
|
/**
|
|
3346
3396
|
* Create and run on Web Worker
|
|
3347
3397
|
* @param {boolean} useWorker Use Web Worker
|
|
@@ -3367,10 +3417,17 @@ function getObjectURL(fn, depsFn) {
|
|
|
3367
3417
|
*/
|
|
3368
3418
|
function runWorker(useWorker, fn, callback, depsFn) {
|
|
3369
3419
|
if (useWorker === void 0) { useWorker = true; }
|
|
3370
|
-
var runFn
|
|
3420
|
+
var runFn = function () {
|
|
3421
|
+
var args = [];
|
|
3422
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3423
|
+
args[_i] = arguments[_i];
|
|
3424
|
+
}
|
|
3425
|
+
var res = fn.apply(void 0, args);
|
|
3426
|
+
callback(res);
|
|
3427
|
+
};
|
|
3371
3428
|
if (win.Worker && useWorker) {
|
|
3372
3429
|
var src_1 = getObjectURL(fn, depsFn);
|
|
3373
|
-
var worker_1 =
|
|
3430
|
+
var worker_1 = getWorker(src_1);
|
|
3374
3431
|
runFn = function () {
|
|
3375
3432
|
var args = [];
|
|
3376
3433
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -3384,26 +3441,12 @@ function runWorker(useWorker, fn, callback, depsFn) {
|
|
|
3384
3441
|
win.URL.revokeObjectURL(src_1);
|
|
3385
3442
|
return callback(e.data);
|
|
3386
3443
|
};
|
|
3387
|
-
// handle error
|
|
3388
|
-
worker_1.onerror = function (e) {
|
|
3389
|
-
console.error(e);
|
|
3390
|
-
};
|
|
3391
3444
|
// return new Promise((resolve, reject) => {
|
|
3392
3445
|
// worker.onmessage = ({data}) => resolve(data);
|
|
3393
3446
|
// worker.onerror = reject;
|
|
3394
3447
|
// });
|
|
3395
3448
|
};
|
|
3396
3449
|
}
|
|
3397
|
-
else {
|
|
3398
|
-
runFn = function () {
|
|
3399
|
-
var args = [];
|
|
3400
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
3401
|
-
args[_i] = arguments[_i];
|
|
3402
|
-
}
|
|
3403
|
-
var res = fn.apply(void 0, args);
|
|
3404
|
-
callback(res);
|
|
3405
|
-
};
|
|
3406
|
-
}
|
|
3407
3450
|
return runFn;
|
|
3408
3451
|
}
|
|
3409
3452
|
|
|
@@ -3789,6 +3832,12 @@ var data$1 = {
|
|
|
3789
3832
|
var config = this.config;
|
|
3790
3833
|
return !!(config.data_stack_normalize && config.data_groups.length);
|
|
3791
3834
|
},
|
|
3835
|
+
/**
|
|
3836
|
+
* Check if given id is grouped data or has grouped data
|
|
3837
|
+
* @param {string} id Data id value
|
|
3838
|
+
* @returns {boolean} is grouped data or has grouped data
|
|
3839
|
+
* @private
|
|
3840
|
+
*/
|
|
3792
3841
|
isGrouped: function (id) {
|
|
3793
3842
|
var groups = this.config.data_groups;
|
|
3794
3843
|
return id ?
|
|
@@ -4068,7 +4117,7 @@ var data$1 = {
|
|
|
4068
4117
|
* @private
|
|
4069
4118
|
*/
|
|
4070
4119
|
getMaxDataCount: function () {
|
|
4071
|
-
return Math.max.apply(Math, this.data.targets.map(function (t) { return t.values.length; }));
|
|
4120
|
+
return Math.max.apply(Math, __spreadArray(__spreadArray([], this.data.targets.map(function (t) { return t.values.length; }), false), [0], false));
|
|
4072
4121
|
},
|
|
4073
4122
|
getMaxDataCountTarget: function () {
|
|
4074
4123
|
var target = this.filterTargetsToShow() || [];
|
|
@@ -4880,9 +4929,16 @@ var interaction = {
|
|
|
4880
4929
|
var _e = element.getBoundingClientRect(), width = _e.width, left = _e.left, top_1 = _e.top;
|
|
4881
4930
|
if (hasAxis && !hasRadar && !isMultipleX) {
|
|
4882
4931
|
var coords = eventReceiver.coords[index];
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4932
|
+
if (coords) {
|
|
4933
|
+
width = coords.w;
|
|
4934
|
+
left += coords.x;
|
|
4935
|
+
top_1 += coords.y;
|
|
4936
|
+
}
|
|
4937
|
+
else {
|
|
4938
|
+
width = 0;
|
|
4939
|
+
left = 0;
|
|
4940
|
+
top_1 = 0;
|
|
4941
|
+
}
|
|
4886
4942
|
}
|
|
4887
4943
|
var x = left + (mouse ? mouse[0] : 0) + (isMultipleX || config.axis_rotated ? 0 : (width / 2));
|
|
4888
4944
|
var y = top_1 + (mouse ? mouse[1] : 0);
|
|
@@ -5049,8 +5105,9 @@ var category = {
|
|
|
5049
5105
|
* @private
|
|
5050
5106
|
*/
|
|
5051
5107
|
categoryName: function (i) {
|
|
5052
|
-
var
|
|
5053
|
-
|
|
5108
|
+
var _a;
|
|
5109
|
+
var axis_x_categories = this.config.axis_x_categories;
|
|
5110
|
+
return (_a = axis_x_categories === null || axis_x_categories === void 0 ? void 0 : axis_x_categories[i]) !== null && _a !== void 0 ? _a : i;
|
|
5054
5111
|
},
|
|
5055
5112
|
};
|
|
5056
5113
|
|
|
@@ -5568,19 +5625,25 @@ var domain = {
|
|
|
5568
5625
|
return domain;
|
|
5569
5626
|
},
|
|
5570
5627
|
/**
|
|
5571
|
-
* Get zoom domain
|
|
5628
|
+
* Get subchart/zoom domain
|
|
5629
|
+
* @param {string} type "subX" or "zoom"
|
|
5630
|
+
* @param {boolean} getCurrent Get current domain if true
|
|
5572
5631
|
* @returns {Array} zoom domain
|
|
5573
5632
|
* @private
|
|
5574
5633
|
*/
|
|
5575
|
-
getZoomDomain: function () {
|
|
5634
|
+
getZoomDomain: function (type, getCurrent) {
|
|
5635
|
+
if (type === void 0) { type = "zoom"; }
|
|
5636
|
+
if (getCurrent === void 0) { getCurrent = false; }
|
|
5576
5637
|
var $$ = this;
|
|
5577
|
-
var config = $$.config, org = $$.org;
|
|
5578
|
-
var _a = org.xDomain, min = _a[0], max = _a[1];
|
|
5579
|
-
if (
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5638
|
+
var config = $$.config, scale = $$.scale, org = $$.org;
|
|
5639
|
+
var _a = getCurrent && scale[type] ? scale[type].domain() : org.xDomain, min = _a[0], max = _a[1];
|
|
5640
|
+
if (type === "zoom") {
|
|
5641
|
+
if (isDefined(config.zoom_x_min)) {
|
|
5642
|
+
min = getMinMax$1("min", [min, config.zoom_x_min]);
|
|
5643
|
+
}
|
|
5644
|
+
if (isDefined(config.zoom_x_max)) {
|
|
5645
|
+
max = getMinMax$1("max", [max, config.zoom_x_max]);
|
|
5646
|
+
}
|
|
5584
5647
|
}
|
|
5585
5648
|
return [min, max];
|
|
5586
5649
|
},
|
|
@@ -5604,6 +5667,27 @@ var domain = {
|
|
|
5604
5667
|
length = isRotated ? "width" : "height";
|
|
5605
5668
|
}
|
|
5606
5669
|
return domainLength * (pixels / state[length]);
|
|
5670
|
+
},
|
|
5671
|
+
/**
|
|
5672
|
+
* Check if the given domain is within subchart/zoom range
|
|
5673
|
+
* @param {Array} domain Target domain value
|
|
5674
|
+
* @param {Array} current Current subchart/zoom domain value
|
|
5675
|
+
* @param {Array} range subchart/zoom range value
|
|
5676
|
+
* @returns {boolean}
|
|
5677
|
+
* @private
|
|
5678
|
+
*/
|
|
5679
|
+
withinRange: function (domain, current, range) {
|
|
5680
|
+
var $$ = this;
|
|
5681
|
+
var isInverted = $$.config.axis_x_inverted;
|
|
5682
|
+
var _a = range, min = _a[0], max = _a[1];
|
|
5683
|
+
if (Array.isArray(domain)) {
|
|
5684
|
+
var target = __spreadArray([], domain, true);
|
|
5685
|
+
isInverted && target.reverse();
|
|
5686
|
+
if (target[0] < target[1]) {
|
|
5687
|
+
return domain.every(function (v, i) { return (i === 0 ? (isInverted ? +v <= min : +v >= min) : (isInverted ? +v >= max : +v <= max)) && !(domain.every(function (v, i) { return v === current[i]; })); });
|
|
5688
|
+
}
|
|
5689
|
+
}
|
|
5690
|
+
return false;
|
|
5607
5691
|
}
|
|
5608
5692
|
};
|
|
5609
5693
|
|
|
@@ -6440,10 +6524,6 @@ var redraw = {
|
|
|
6440
6524
|
// no need to update axis in it because they will be updated in redraw()
|
|
6441
6525
|
$$.updateDimension(true);
|
|
6442
6526
|
}
|
|
6443
|
-
// update circleY based on updated parameters
|
|
6444
|
-
if (!treemap && (!$$.hasArcType() || state.hasRadar)) {
|
|
6445
|
-
$$.updateCircleY && ($$.circleY = $$.updateCircleY());
|
|
6446
|
-
}
|
|
6447
6527
|
// Data empty label positioning and text.
|
|
6448
6528
|
config.data_empty_label_text && main.select("text.".concat($TEXT.text, ".").concat($COMMON.empty))
|
|
6449
6529
|
.attr("x", state.width / 2)
|
|
@@ -6828,6 +6908,24 @@ var scale = {
|
|
|
6828
6908
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
6829
6909
|
* billboard.js project is licensed under the MIT license
|
|
6830
6910
|
*/
|
|
6911
|
+
/**
|
|
6912
|
+
* Get grouped data point function for y coordinate
|
|
6913
|
+
* - Note: Grouped(stacking) works only for line and bar types
|
|
6914
|
+
* @param {object} d data vlaue
|
|
6915
|
+
* @returns {Function|undefined}
|
|
6916
|
+
* @private
|
|
6917
|
+
*/
|
|
6918
|
+
function getGroupedDataPointsFn(d) {
|
|
6919
|
+
var $$ = this;
|
|
6920
|
+
var fn;
|
|
6921
|
+
if ($$.isLineType(d)) {
|
|
6922
|
+
fn = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType));
|
|
6923
|
+
}
|
|
6924
|
+
else if ($$.isBarType(d)) {
|
|
6925
|
+
fn = $$.generateGetBarPoints($$.getShapeIndices($$.isBarType));
|
|
6926
|
+
}
|
|
6927
|
+
return fn;
|
|
6928
|
+
}
|
|
6831
6929
|
var shape = {
|
|
6832
6930
|
/**
|
|
6833
6931
|
* Get the shape draw function
|
|
@@ -6866,7 +6964,7 @@ var shape = {
|
|
|
6866
6964
|
return shape;
|
|
6867
6965
|
},
|
|
6868
6966
|
/**
|
|
6869
|
-
* Get shape's indices according it's position
|
|
6967
|
+
* Get shape's indices according it's position within each axis tick.
|
|
6870
6968
|
*
|
|
6871
6969
|
* From the below example, indices will be:
|
|
6872
6970
|
* ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
|
|
@@ -6894,17 +6992,22 @@ var shape = {
|
|
|
6894
6992
|
}
|
|
6895
6993
|
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
|
|
6896
6994
|
.forEach(function (d) {
|
|
6995
|
+
var _a;
|
|
6897
6996
|
var xKey = d.id in xs ? xs[d.id] : "";
|
|
6898
6997
|
var ind = xKey ? indices[xKey] : indices;
|
|
6899
6998
|
for (var j = 0, groups = void 0; (groups = config.data_groups[j]); j++) {
|
|
6900
6999
|
if (groups.indexOf(d.id) < 0) {
|
|
6901
7000
|
continue;
|
|
6902
7001
|
}
|
|
6903
|
-
for (var k = 0,
|
|
6904
|
-
if (
|
|
6905
|
-
ind[d.id] = ind[
|
|
7002
|
+
for (var k = 0, key = void 0; (key = groups[k]); k++) {
|
|
7003
|
+
if (key in ind) {
|
|
7004
|
+
ind[d.id] = ind[key];
|
|
6906
7005
|
break;
|
|
6907
7006
|
}
|
|
7007
|
+
// for same grouped data, add other data to same indices
|
|
7008
|
+
if (d.id !== key && xKey) {
|
|
7009
|
+
ind[key] = (_a = ind[d.id]) !== null && _a !== void 0 ? _a : i[xKey];
|
|
7010
|
+
}
|
|
6908
7011
|
}
|
|
6909
7012
|
}
|
|
6910
7013
|
if (isUndefined(ind[d.id])) {
|
|
@@ -7104,6 +7207,24 @@ var shape = {
|
|
|
7104
7207
|
return offset;
|
|
7105
7208
|
};
|
|
7106
7209
|
},
|
|
7210
|
+
/**
|
|
7211
|
+
* Get data's y coordinate
|
|
7212
|
+
* @param {object} d Target data
|
|
7213
|
+
* @param {number} i Index number
|
|
7214
|
+
* @returns {number} y coordinate
|
|
7215
|
+
* @private
|
|
7216
|
+
*/
|
|
7217
|
+
circleY: function (d, i) {
|
|
7218
|
+
var $$ = this;
|
|
7219
|
+
var id = d.id;
|
|
7220
|
+
var points;
|
|
7221
|
+
if ($$.isGrouped(id)) {
|
|
7222
|
+
points = getGroupedDataPointsFn.bind($$)(d);
|
|
7223
|
+
}
|
|
7224
|
+
return points ?
|
|
7225
|
+
points(d, i)[0][1] :
|
|
7226
|
+
$$.getYScaleById(id)($$.getBaseValue(d));
|
|
7227
|
+
},
|
|
7107
7228
|
getBarW: function (type, axis, targetsNum) {
|
|
7108
7229
|
var $$ = this;
|
|
7109
7230
|
var config = $$.config, org = $$.org, scale = $$.scale;
|
|
@@ -7685,7 +7806,7 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
|
|
|
7685
7806
|
* @returns {number} Position value
|
|
7686
7807
|
* @private
|
|
7687
7808
|
*/
|
|
7688
|
-
function getTextPos
|
|
7809
|
+
function getTextPos(d, type) {
|
|
7689
7810
|
var _a;
|
|
7690
7811
|
var position = this.config.data_labels_position;
|
|
7691
7812
|
var id = d.id, index = d.index, value = d.value;
|
|
@@ -7848,7 +7969,6 @@ var text = {
|
|
|
7848
7969
|
var angle = config.data_labels.rotate;
|
|
7849
7970
|
var anchorString = getRotateAnchor(angle);
|
|
7850
7971
|
var rotateString = angle ? "rotate(".concat(angle, ")") : "";
|
|
7851
|
-
// $$.meetsLabelThreshold(ratio,
|
|
7852
7972
|
$$.$el.text
|
|
7853
7973
|
.style("fill", $$.getStylePropValue($$.updateTextColor))
|
|
7854
7974
|
.attr("filter", $$.updateTextBacgroundColor.bind($$))
|
|
@@ -7985,7 +8105,7 @@ var text = {
|
|
|
7985
8105
|
getXForText: function (points, d, textElement) {
|
|
7986
8106
|
var _a;
|
|
7987
8107
|
var $$ = this;
|
|
7988
|
-
var config = $$.config
|
|
8108
|
+
var config = $$.config;
|
|
7989
8109
|
var isRotated = config.axis_rotated;
|
|
7990
8110
|
var isTreemapType = $$.isTreemapType(d);
|
|
7991
8111
|
var xPos = points[0][0];
|
|
@@ -8018,20 +8138,10 @@ var text = {
|
|
|
8018
8138
|
xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
|
|
8019
8139
|
}
|
|
8020
8140
|
}
|
|
8021
|
-
// show labels regardless of the domain if value is null
|
|
8022
|
-
if (d.value === null) {
|
|
8023
|
-
if (xPos > state.width) {
|
|
8024
|
-
var width = getBoundingRect(textElement).width;
|
|
8025
|
-
xPos = state.width - width;
|
|
8026
|
-
}
|
|
8027
|
-
else if (xPos < 0) {
|
|
8028
|
-
xPos = 4;
|
|
8029
|
-
}
|
|
8030
|
-
}
|
|
8031
8141
|
if (isRotated || isTreemapType) {
|
|
8032
8142
|
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
|
8033
8143
|
}
|
|
8034
|
-
return xPos + getTextPos
|
|
8144
|
+
return xPos + getTextPos.call(this, d, "x");
|
|
8035
8145
|
},
|
|
8036
8146
|
/**
|
|
8037
8147
|
* Gets the y coordinate of the text
|
|
@@ -8098,20 +8208,10 @@ var text = {
|
|
|
8098
8208
|
}
|
|
8099
8209
|
}
|
|
8100
8210
|
}
|
|
8101
|
-
// show labels regardless of the domain if value is null
|
|
8102
|
-
if (d.value === null && !isRotated) {
|
|
8103
|
-
var boxHeight = rect.height;
|
|
8104
|
-
if (yPos < boxHeight) {
|
|
8105
|
-
yPos = boxHeight;
|
|
8106
|
-
}
|
|
8107
|
-
else if (yPos > state.height) {
|
|
8108
|
-
yPos = state.height - 4;
|
|
8109
|
-
}
|
|
8110
|
-
}
|
|
8111
8211
|
if (!isRotated || isTreemapType) {
|
|
8112
8212
|
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
|
8113
8213
|
}
|
|
8114
|
-
return yPos + getTextPos
|
|
8214
|
+
return yPos + getTextPos.call(this, d, "y");
|
|
8115
8215
|
},
|
|
8116
8216
|
/**
|
|
8117
8217
|
* Calculate if two or more text nodes are overlapping
|
|
@@ -8181,7 +8281,7 @@ var text = {
|
|
|
8181
8281
|
* @returns {string|number} text-anchor value or position in pixel
|
|
8182
8282
|
* @private
|
|
8183
8283
|
*/
|
|
8184
|
-
function
|
|
8284
|
+
function getTextXPos(pos, width) {
|
|
8185
8285
|
if (pos === void 0) { pos = "left"; }
|
|
8186
8286
|
var isNum = isNumber(width);
|
|
8187
8287
|
var position;
|
|
@@ -8208,7 +8308,7 @@ var title = {
|
|
|
8208
8308
|
$el.title = $el.svg.append("g");
|
|
8209
8309
|
var text = $el.title
|
|
8210
8310
|
.append("text")
|
|
8211
|
-
.style("text-anchor",
|
|
8311
|
+
.style("text-anchor", getTextXPos(config.title_position))
|
|
8212
8312
|
.attr("class", $TEXT.title);
|
|
8213
8313
|
setTextValue(text, config.title_text, [0.3, 1.5]);
|
|
8214
8314
|
}
|
|
@@ -8221,49 +8321,11 @@ var title = {
|
|
|
8221
8321
|
var $$ = this;
|
|
8222
8322
|
var config = $$.config, current = $$.state.current, title = $$.$el.title;
|
|
8223
8323
|
if (title) {
|
|
8224
|
-
var
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
else {
|
|
8229
|
-
title.attr("x", $$.xForTitle.call($$)).attr("y", y);
|
|
8230
|
-
}
|
|
8231
|
-
}
|
|
8232
|
-
},
|
|
8233
|
-
/**
|
|
8234
|
-
* Returns the x attribute value of the title
|
|
8235
|
-
* @returns {number} x attribute value
|
|
8236
|
-
* @private
|
|
8237
|
-
*/
|
|
8238
|
-
xForTitle: function () {
|
|
8239
|
-
var $$ = this;
|
|
8240
|
-
var config = $$.config, current = $$.state.current;
|
|
8241
|
-
var position = config.title_position || "left";
|
|
8242
|
-
var textRectWidth = $$.getTextRect($$.$el.title, $TEXT.title).width;
|
|
8243
|
-
var x;
|
|
8244
|
-
if (/(right|center)/.test(position)) {
|
|
8245
|
-
x = current.width - textRectWidth;
|
|
8246
|
-
if (position.indexOf("right") >= 0) {
|
|
8247
|
-
x = current.width - textRectWidth - config.title_padding.right;
|
|
8248
|
-
}
|
|
8249
|
-
else if (position.indexOf("center") >= 0) {
|
|
8250
|
-
x = (current.width - textRectWidth) / 2;
|
|
8251
|
-
}
|
|
8252
|
-
}
|
|
8253
|
-
else { // left
|
|
8254
|
-
x = (config.title_padding.left || 0);
|
|
8324
|
+
var x = getTextXPos(config.title_position, current.width);
|
|
8325
|
+
var y = (config.title_padding.top || 0) +
|
|
8326
|
+
$$.getTextRect($$.$el.title, $TEXT.title).height;
|
|
8327
|
+
title.attr("transform", "translate(".concat(x, ", ").concat(y, ")"));
|
|
8255
8328
|
}
|
|
8256
|
-
return x;
|
|
8257
|
-
},
|
|
8258
|
-
/**
|
|
8259
|
-
* Returns the y attribute value of the title
|
|
8260
|
-
* @returns {number} y attribute value
|
|
8261
|
-
* @private
|
|
8262
|
-
*/
|
|
8263
|
-
yForTitle: function () {
|
|
8264
|
-
var $$ = this;
|
|
8265
|
-
return ($$.config.title_padding.top || 0) +
|
|
8266
|
-
$$.getTextRect($$.$el.title, $TEXT.title).height;
|
|
8267
8329
|
},
|
|
8268
8330
|
/**
|
|
8269
8331
|
* Get title padding
|
|
@@ -8272,7 +8334,10 @@ var title = {
|
|
|
8272
8334
|
*/
|
|
8273
8335
|
getTitlePadding: function () {
|
|
8274
8336
|
var $$ = this;
|
|
8275
|
-
|
|
8337
|
+
var $el = $$.$el, config = $$.config;
|
|
8338
|
+
return (config.title_padding.top || 0) +
|
|
8339
|
+
$$.getTextRect($el.title, $TEXT.title).height +
|
|
8340
|
+
(config.title_padding.bottom || 0);
|
|
8276
8341
|
},
|
|
8277
8342
|
};
|
|
8278
8343
|
|
|
@@ -8295,36 +8360,32 @@ var tooltip$1 = {
|
|
|
8295
8360
|
}
|
|
8296
8361
|
$$.bindTooltipResizePos();
|
|
8297
8362
|
},
|
|
8363
|
+
/**
|
|
8364
|
+
* Show tooltip at initialization.
|
|
8365
|
+
* Is called only when tooltip.init.show=true option is set
|
|
8366
|
+
* @private
|
|
8367
|
+
*/
|
|
8298
8368
|
initShowTooltip: function () {
|
|
8299
|
-
var _a
|
|
8369
|
+
var _a;
|
|
8370
|
+
var _b;
|
|
8300
8371
|
var $$ = this;
|
|
8301
8372
|
var config = $$.config, $el = $$.$el, _c = $$.state, hasAxis = _c.hasAxis, hasRadar = _c.hasRadar;
|
|
8302
8373
|
// Show tooltip if needed
|
|
8303
8374
|
if (config.tooltip_init_show) {
|
|
8304
|
-
var
|
|
8305
|
-
if (((
|
|
8306
|
-
var targets = $$.data.targets[0];
|
|
8307
|
-
var i = void 0;
|
|
8308
|
-
var val = void 0;
|
|
8375
|
+
var isArc = !(hasAxis || hasRadar);
|
|
8376
|
+
if (((_b = $$.axis) === null || _b === void 0 ? void 0 : _b.isTimeSeries()) && isString(config.tooltip_init_x)) {
|
|
8309
8377
|
config.tooltip_init_x = parseDate.call($$, config.tooltip_init_x);
|
|
8310
|
-
for (i = 0; (val = targets.values[i]); i++) {
|
|
8311
|
-
if ((val.x - config.tooltip_init_x) === 0) {
|
|
8312
|
-
break;
|
|
8313
|
-
}
|
|
8314
|
-
}
|
|
8315
|
-
config.tooltip_init_x = i;
|
|
8316
8378
|
}
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8379
|
+
$$.api.tooltip.show({
|
|
8380
|
+
data: (_a = {},
|
|
8381
|
+
_a[isArc ? "index" : "x"] = config.tooltip_init_x,
|
|
8382
|
+
_a)
|
|
8320
8383
|
});
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
$el.tooltip.style("top", config.tooltip_init_position.top)
|
|
8327
|
-
.style("left", config.tooltip_init_position.left)
|
|
8384
|
+
var position = config.tooltip_init_position;
|
|
8385
|
+
if (!config.tooltip_contents.bindto && !isEmpty(position)) {
|
|
8386
|
+
var _d = position.top, top_1 = _d === void 0 ? 0 : _d, _e = position.left, left = _e === void 0 ? 50 : _e;
|
|
8387
|
+
$el.tooltip.style("top", isString(top_1) ? top_1 : "".concat(top_1, "px"))
|
|
8388
|
+
.style("left", isString(left) ? left : "".concat(left, "px"))
|
|
8328
8389
|
.style("display", null);
|
|
8329
8390
|
}
|
|
8330
8391
|
}
|
|
@@ -8356,13 +8417,34 @@ var tooltip$1 = {
|
|
|
8356
8417
|
getTooltipContent: function (d, defaultTitleFormat, defaultValueFormat, color) {
|
|
8357
8418
|
var $$ = this;
|
|
8358
8419
|
var api = $$.api, config = $$.config, state = $$.state, $el = $$.$el;
|
|
8420
|
+
// get formatter function
|
|
8359
8421
|
var _a = ["title", "name", "value"].map(function (v) {
|
|
8360
8422
|
var fn = config["tooltip_format_".concat(v)];
|
|
8361
8423
|
return isFunction(fn) ? fn.bind(api) : fn;
|
|
8362
|
-
}),
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8424
|
+
}), titleFn = _a[0], nameFn = _a[1], valueFn = _a[2];
|
|
8425
|
+
// determine fotmatter function with sanitization
|
|
8426
|
+
var titleFormat = function () {
|
|
8427
|
+
var arg = [];
|
|
8428
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8429
|
+
arg[_i] = arguments[_i];
|
|
8430
|
+
}
|
|
8431
|
+
return sanitize((titleFn || defaultTitleFormat).apply(void 0, arg));
|
|
8432
|
+
};
|
|
8433
|
+
var nameFormat = function () {
|
|
8434
|
+
var arg = [];
|
|
8435
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8436
|
+
arg[_i] = arguments[_i];
|
|
8437
|
+
}
|
|
8438
|
+
return sanitize((nameFn || (function (name) { return name; })).apply(void 0, arg));
|
|
8439
|
+
};
|
|
8440
|
+
var valueFormat = function () {
|
|
8441
|
+
var arg = [];
|
|
8442
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8443
|
+
arg[_i] = arguments[_i];
|
|
8444
|
+
}
|
|
8445
|
+
var fn = valueFn || (state.hasTreemap || $$.isStackNormalized() ? function (v, ratio) { return "".concat((ratio * 100).toFixed(2), "%"); } : defaultValueFormat);
|
|
8446
|
+
return sanitize(fn.apply(void 0, arg));
|
|
8447
|
+
};
|
|
8366
8448
|
var order = config.tooltip_order;
|
|
8367
8449
|
var getRowValue = function (row) { return ($$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row)); };
|
|
8368
8450
|
var getBgColor = $$.levelColor ? function (row) { return $$.levelColor(row.value); } : function (row) { return color(row); };
|
|
@@ -8408,8 +8490,7 @@ var tooltip$1 = {
|
|
|
8408
8490
|
return "continue";
|
|
8409
8491
|
}
|
|
8410
8492
|
if (isUndefined(text)) {
|
|
8411
|
-
var title = (state.hasAxis || state.hasRadar) &&
|
|
8412
|
-
sanitise(titleFormat ? titleFormat(row.x) : row.x);
|
|
8493
|
+
var title = (state.hasAxis || state.hasRadar) && titleFormat(row.x);
|
|
8413
8494
|
text = tplProcess(tpl[0], {
|
|
8414
8495
|
CLASS_TOOLTIP: $TOOLTIP.tooltip,
|
|
8415
8496
|
TITLE: isValue(title) ? (tplStr ? title : "<tr><th colspan=\"2\">".concat(title, "</th></tr>")) : ""
|
|
@@ -8419,26 +8500,33 @@ var tooltip$1 = {
|
|
|
8419
8500
|
param = ["arc", $$.$el.arcs.select("path.".concat($ARC.arc, "-").concat(row.id)).data()[0]];
|
|
8420
8501
|
row.ratio = $$.getRatio.apply($$, param);
|
|
8421
8502
|
}
|
|
8422
|
-
param
|
|
8423
|
-
|
|
8503
|
+
// arrange param to be passed to formatter
|
|
8504
|
+
param = [row.ratio, row.id, row.index];
|
|
8424
8505
|
if ($$.isAreaRangeType(row)) {
|
|
8425
|
-
var _b = ["high", "low"].map(function (v) { return
|
|
8426
|
-
|
|
8506
|
+
var _b = ["high", "low"].map(function (v) { return valueFormat.apply(void 0, __spreadArray([$$.getRangedData(row, v)], param, false)); }), high = _b[0], low = _b[1];
|
|
8507
|
+
var mid = valueFormat.apply(void 0, __spreadArray([getRowValue(row)], param, false));
|
|
8508
|
+
value = "<b>Mid:</b> ".concat(mid, " <b>High:</b> ").concat(high, " <b>Low:</b> ").concat(low);
|
|
8427
8509
|
}
|
|
8428
8510
|
else if ($$.isCandlestickType(row)) {
|
|
8429
|
-
var _c = ["open", "high", "low", "close", "volume"].map(function (v) {
|
|
8511
|
+
var _c = ["open", "high", "low", "close", "volume"].map(function (v) {
|
|
8512
|
+
var value = $$.getRangedData(row, v, "candlestick");
|
|
8513
|
+
return value ? valueFormat.apply(void 0, __spreadArray([$$.getRangedData(row, v, "candlestick")], param, false)) : undefined;
|
|
8514
|
+
}), open_1 = _c[0], high = _c[1], low = _c[2], close_1 = _c[3], volume = _c[4];
|
|
8430
8515
|
value = "<b>Open:</b> ".concat(open_1, " <b>High:</b> ").concat(high, " <b>Low:</b> ").concat(low, " <b>Close:</b> ").concat(close_1).concat(volume ? " <b>Volume:</b> ".concat(volume) : "");
|
|
8431
8516
|
}
|
|
8432
8517
|
else if ($$.isBarRangeType(row)) {
|
|
8433
|
-
var _d = row.value, start = _d[0], end = _d[1];
|
|
8434
|
-
value = "".concat(valueFormat(start), " ~ ").concat(valueFormat(end));
|
|
8518
|
+
var _d = row.value, start = _d[0], end = _d[1], id = row.id, index = row.index;
|
|
8519
|
+
value = "".concat(valueFormat(start, undefined, id, index), " ~ ").concat(valueFormat(end, undefined, id, index));
|
|
8520
|
+
}
|
|
8521
|
+
else {
|
|
8522
|
+
value = valueFormat.apply(void 0, __spreadArray([getRowValue(row)], param, false));
|
|
8435
8523
|
}
|
|
8436
8524
|
if (value !== undefined) {
|
|
8437
8525
|
// Skip elements when their name is set to null
|
|
8438
8526
|
if (row.name === null) {
|
|
8439
8527
|
return "continue";
|
|
8440
8528
|
}
|
|
8441
|
-
var name_1 =
|
|
8529
|
+
var name_1 = nameFormat.apply(void 0, __spreadArray([row.name], param, false));
|
|
8442
8530
|
var color_1 = getBgColor(row);
|
|
8443
8531
|
var contentValue_1 = {
|
|
8444
8532
|
CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
|
|
@@ -10138,8 +10226,7 @@ function nodeToSvgDataUrl(node, option, orgSize) {
|
|
|
10138
10226
|
var styleXml = serializer.serializeToString(style);
|
|
10139
10227
|
// foreignObject not supported in IE11 and below
|
|
10140
10228
|
// https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
|
|
10141
|
-
var dataStr = "<svg xmlns=\"".concat(namespaces.svg, "\" width=\"").concat(width, "\" height=\"").concat(height, "\" \n\t\tviewBox=\"0 0 ").concat(orgSize.width, " ").concat(orgSize.height, "\" \n\t\tpreserveAspectRatio=\"").concat((option === null || option === void 0 ? void 0 : option.preserveAspectRatio) === false ? "none" : "xMinYMid meet", "\">\n\t\t\t<foreignObject width=\"100%\" height=\"100%\">\n\t\t\t\t").concat(styleXml, "\n\t\t\t\t").concat(nodeXml.replace(/(url\()[^#]+/g, "$1"), "\n\t\t\t</foreignObject></svg>")
|
|
10142
|
-
.replace("/\n/g", "%0A");
|
|
10229
|
+
var dataStr = "<svg xmlns=\"".concat(namespaces.svg, "\" width=\"").concat(width, "\" height=\"").concat(height, "\" \n\t\tviewBox=\"0 0 ").concat(orgSize.width, " ").concat(orgSize.height, "\" \n\t\tpreserveAspectRatio=\"").concat((option === null || option === void 0 ? void 0 : option.preserveAspectRatio) === false ? "none" : "xMinYMid meet", "\">\n\t\t\t<foreignObject width=\"100%\" height=\"100%\">\n\t\t\t\t").concat(styleXml, "\n\t\t\t\t").concat(nodeXml.replace(/(url\()[^#]+/g, "$1"), "\n\t\t\t</foreignObject></svg>");
|
|
10143
10230
|
return "data:image/svg+xml;base64,".concat(b64EncodeUnicode(dataStr));
|
|
10144
10231
|
}
|
|
10145
10232
|
/**
|
|
@@ -11182,6 +11269,7 @@ function getMinMax($$, type) {
|
|
|
11182
11269
|
var axis$1 = {
|
|
11183
11270
|
/**
|
|
11184
11271
|
* Get and set axis labels.
|
|
11272
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11185
11273
|
* @function axis․labels
|
|
11186
11274
|
* @instance
|
|
11187
11275
|
* @memberof Chart
|
|
@@ -11225,6 +11313,7 @@ var axis$1 = {
|
|
|
11225
11313
|
},
|
|
11226
11314
|
/**
|
|
11227
11315
|
* Get and set axis min value.
|
|
11316
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11228
11317
|
* @function axis․min
|
|
11229
11318
|
* @instance
|
|
11230
11319
|
* @memberof Chart
|
|
@@ -11260,6 +11349,7 @@ var axis$1 = {
|
|
|
11260
11349
|
},
|
|
11261
11350
|
/**
|
|
11262
11351
|
* Get and set axis max value.
|
|
11352
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11263
11353
|
* @function axis․max
|
|
11264
11354
|
* @instance
|
|
11265
11355
|
* @memberof Chart
|
|
@@ -11295,6 +11385,7 @@ var axis$1 = {
|
|
|
11295
11385
|
},
|
|
11296
11386
|
/**
|
|
11297
11387
|
* Get and set axis min and max value.
|
|
11388
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11298
11389
|
* @function axis․range
|
|
11299
11390
|
* @instance
|
|
11300
11391
|
* @memberof Chart
|
|
@@ -11379,7 +11470,7 @@ var apiCategory = {
|
|
|
11379
11470
|
return config.axis_x_categories[i];
|
|
11380
11471
|
},
|
|
11381
11472
|
/**
|
|
11382
|
-
* Set category names on category axis.
|
|
11473
|
+
* Set or get category names on category axis.
|
|
11383
11474
|
* @function categories
|
|
11384
11475
|
* @instance
|
|
11385
11476
|
* @memberof Chart
|
|
@@ -11393,8 +11484,9 @@ var apiCategory = {
|
|
|
11393
11484
|
categories: function (categories) {
|
|
11394
11485
|
var $$ = this.internal;
|
|
11395
11486
|
var config = $$.config;
|
|
11396
|
-
if (!
|
|
11397
|
-
|
|
11487
|
+
if (!categories || !Array.isArray(categories)) {
|
|
11488
|
+
var cat = config.axis_x_categories;
|
|
11489
|
+
return isEmpty(cat) ? Object.values($$.data.xs)[0] : cat;
|
|
11398
11490
|
}
|
|
11399
11491
|
config.axis_x_categories = categories;
|
|
11400
11492
|
$$.redraw();
|
|
@@ -12101,14 +12193,6 @@ var AxisRendererHelper = /** @class */ (function () {
|
|
|
12101
12193
|
return r;
|
|
12102
12194
|
});
|
|
12103
12195
|
}
|
|
12104
|
-
else {
|
|
12105
|
-
for (var i = Math.ceil(start); i < end; i++) {
|
|
12106
|
-
ticks.push(i);
|
|
12107
|
-
}
|
|
12108
|
-
if (ticks.length > 0 && ticks[0] > 0) {
|
|
12109
|
-
ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
|
|
12110
|
-
}
|
|
12111
|
-
}
|
|
12112
12196
|
return ticks;
|
|
12113
12197
|
};
|
|
12114
12198
|
AxisRendererHelper.prototype.copyScale = function () {
|
|
@@ -14011,10 +14095,6 @@ var flow = {
|
|
|
14011
14095
|
else if (v === "gridLines.x") {
|
|
14012
14096
|
n.attr("x1", isRotated ? 0 : xv)
|
|
14013
14097
|
.attr("x2", isRotated ? state.width : xv);
|
|
14014
|
-
}
|
|
14015
|
-
else if (v === "gridLines.x") {
|
|
14016
|
-
n.select("line").attr("x1", isRotated ? 0 : xv)
|
|
14017
|
-
.attr("x2", isRotated ? state.width : xv);
|
|
14018
14098
|
n.select("text")
|
|
14019
14099
|
.attr("x", isRotated ? state.width : 0)
|
|
14020
14100
|
.attr("y", xv);
|
|
@@ -14034,10 +14114,7 @@ var flow = {
|
|
|
14034
14114
|
else {
|
|
14035
14115
|
var xFunc = function (d) { return cx(d) - config.point_r; };
|
|
14036
14116
|
var yFunc = function (d) { return cy(d) - config.point_r; };
|
|
14037
|
-
n.attr("x", xFunc)
|
|
14038
|
-
.attr("y", yFunc)
|
|
14039
|
-
.attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
|
|
14040
|
-
.attr("cy", cy);
|
|
14117
|
+
n.attr("x", xFunc).attr("y", yFunc);
|
|
14041
14118
|
}
|
|
14042
14119
|
}
|
|
14043
14120
|
else if (v === "region.list") {
|
|
@@ -14146,11 +14223,11 @@ var clip = {
|
|
|
14146
14223
|
var config = $$.config, _a = $$.state, margin = _a.margin, width = _a.width, height = _a.height;
|
|
14147
14224
|
var isRotated = config.axis_rotated;
|
|
14148
14225
|
var left = Math.max(30, margin.left) - (isRotated ? 0 : 20);
|
|
14149
|
-
var x = isRotated ? -(1 + left) : -(left - 1);
|
|
14150
|
-
var y = -Math.max(15, margin.top);
|
|
14151
|
-
var w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
14152
14226
|
// less than 20 is not enough to show the axis label 'outer' without legend
|
|
14153
14227
|
var h = (isRotated ? (margin.top + height) + 10 : margin.bottom) + 20;
|
|
14228
|
+
var x = isRotated ? -(1 + left) : -(left - 1);
|
|
14229
|
+
var y = -Math.max(15, margin.bottom);
|
|
14230
|
+
var w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
14154
14231
|
node
|
|
14155
14232
|
.attr("x", x)
|
|
14156
14233
|
.attr("y", y)
|
|
@@ -14351,105 +14428,84 @@ var grid = {
|
|
|
14351
14428
|
// hide if arc type
|
|
14352
14429
|
grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
|
14353
14430
|
$$.hideGridFocus();
|
|
14354
|
-
$$.
|
|
14355
|
-
$$.
|
|
14431
|
+
$$.updateGridLines("x");
|
|
14432
|
+
$$.updateGridLines("y");
|
|
14356
14433
|
},
|
|
14357
14434
|
/**
|
|
14358
|
-
* Update
|
|
14435
|
+
* Update Grid lines
|
|
14436
|
+
* @param {string} type x | y
|
|
14359
14437
|
* @private
|
|
14360
14438
|
*/
|
|
14361
|
-
|
|
14439
|
+
updateGridLines: function (type) {
|
|
14362
14440
|
var $$ = this;
|
|
14363
14441
|
var config = $$.config, _a = $$.$el, gridLines = _a.gridLines, main = _a.main, $T = $$.$T;
|
|
14364
14442
|
var isRotated = config.axis_rotated;
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
.
|
|
14443
|
+
var isX = type === "x";
|
|
14444
|
+
config["grid_".concat(type, "_show")] && $$["update".concat(type.toUpperCase(), "Grid")]();
|
|
14445
|
+
var lines = main.select(".".concat($GRID["".concat(type, "gridLines")]))
|
|
14446
|
+
.selectAll(".".concat($GRID["".concat(type, "gridLine")]))
|
|
14447
|
+
.data(config["grid_".concat(type, "_lines")]);
|
|
14369
14448
|
// exit
|
|
14370
|
-
$T(
|
|
14449
|
+
$T(lines.exit())
|
|
14371
14450
|
.style("opacity", "0")
|
|
14372
14451
|
.remove();
|
|
14373
14452
|
// enter
|
|
14374
|
-
var
|
|
14375
|
-
|
|
14453
|
+
var gridLine = lines.enter().append("g");
|
|
14454
|
+
gridLine.append("line")
|
|
14376
14455
|
.style("opacity", "0");
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
.
|
|
14381
|
-
|
|
14382
|
-
|
|
14383
|
-
|
|
14456
|
+
lines = gridLine.merge(lines);
|
|
14457
|
+
lines.each(function (d) {
|
|
14458
|
+
var g = select(this);
|
|
14459
|
+
if (g.select("text").empty() && d.text) {
|
|
14460
|
+
g.append("text")
|
|
14461
|
+
.style("opacity", "0");
|
|
14462
|
+
}
|
|
14463
|
+
});
|
|
14464
|
+
$T(lines
|
|
14465
|
+
.attr("class", function (d) { return "".concat($GRID["".concat(type, "gridLine")], " ").concat(d.class || "").trim(); })
|
|
14384
14466
|
.select("text")
|
|
14385
14467
|
.attr("text-anchor", getGridTextAnchor)
|
|
14386
|
-
.attr("
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
var $$ = this;
|
|
14397
|
-
var config = $$.config, _a = $$.state, width = _a.width, height = _a.height, $el = $$.$el, $T = $$.$T;
|
|
14398
|
-
var isRotated = config.axis_rotated;
|
|
14399
|
-
config.grid_y_show && $$.updateYGrid();
|
|
14400
|
-
var ygridLines = $el.main.select(".".concat($GRID.ygridLines))
|
|
14401
|
-
.selectAll(".".concat($GRID.ygridLine))
|
|
14402
|
-
.data(config.grid_y_lines);
|
|
14403
|
-
// exit
|
|
14404
|
-
$T(ygridLines.exit())
|
|
14405
|
-
.style("opacity", "0")
|
|
14406
|
-
.remove();
|
|
14407
|
-
// enter
|
|
14408
|
-
var ygridLine = ygridLines.enter().append("g");
|
|
14409
|
-
ygridLine.append("line")
|
|
14410
|
-
.style("opacity", "0");
|
|
14411
|
-
ygridLine.append("text")
|
|
14412
|
-
.attr("transform", isRotated ? "rotate(-90)" : "")
|
|
14413
|
-
.style("opacity", "0");
|
|
14414
|
-
ygridLines = ygridLine.merge(ygridLines);
|
|
14415
|
-
// update
|
|
14416
|
-
var yv = $$.yv.bind($$);
|
|
14417
|
-
$T(ygridLines
|
|
14418
|
-
.attr("class", function (d) { return "".concat($GRID.ygridLine, " ").concat(d.class || "").trim(); })
|
|
14419
|
-
.select("line"))
|
|
14420
|
-
.attr("x1", isRotated ? yv : 0)
|
|
14421
|
-
.attr("x2", isRotated ? yv : width)
|
|
14422
|
-
.attr("y1", isRotated ? 0 : yv)
|
|
14423
|
-
.attr("y2", isRotated ? height : yv)
|
|
14424
|
-
.style("opacity", null);
|
|
14425
|
-
$T(ygridLines.select("text")
|
|
14426
|
-
.attr("text-anchor", getGridTextAnchor)
|
|
14427
|
-
.attr("dx", getGridTextDx))
|
|
14428
|
-
.attr("dy", -5)
|
|
14429
|
-
.attr("x", getGridTextX(isRotated, width, height))
|
|
14430
|
-
.attr("y", yv)
|
|
14431
|
-
.text(function (d) { return d.text; })
|
|
14432
|
-
.style("opacity", null);
|
|
14433
|
-
$el.gridLines.y = ygridLines;
|
|
14468
|
+
.attr("transform", function () { return (isX ?
|
|
14469
|
+
(isRotated ? null : "rotate(-90)") :
|
|
14470
|
+
(isRotated ? "rotate(-90)" : null)); })
|
|
14471
|
+
.attr("dx", getGridTextDx)
|
|
14472
|
+
.attr("dy", -5))
|
|
14473
|
+
.text(function (d) {
|
|
14474
|
+
var _a;
|
|
14475
|
+
return (_a = d.text) !== null && _a !== void 0 ? _a : this.remove();
|
|
14476
|
+
});
|
|
14477
|
+
gridLines[type] = lines;
|
|
14434
14478
|
},
|
|
14435
14479
|
redrawGrid: function (withTransition) {
|
|
14436
14480
|
var $$ = this;
|
|
14437
14481
|
var isRotated = $$.config.axis_rotated, _a = $$.state, width = _a.width, height = _a.height, gridLines = $$.$el.gridLines, $T = $$.$T;
|
|
14438
14482
|
var xv = $$.xv.bind($$);
|
|
14439
|
-
var
|
|
14440
|
-
var
|
|
14441
|
-
|
|
14483
|
+
var yv = $$.yv.bind($$);
|
|
14484
|
+
var xLines = gridLines.x.select("line");
|
|
14485
|
+
var xTexts = gridLines.x.select("text");
|
|
14486
|
+
var yLines = gridLines.y.select("line");
|
|
14487
|
+
var yTexts = gridLines.y.select("text");
|
|
14488
|
+
xLines = $T(xLines, withTransition)
|
|
14442
14489
|
.attr("x1", isRotated ? 0 : xv)
|
|
14443
14490
|
.attr("x2", isRotated ? width : xv)
|
|
14444
14491
|
.attr("y1", isRotated ? xv : 0)
|
|
14445
14492
|
.attr("y2", isRotated ? xv : height);
|
|
14446
|
-
|
|
14493
|
+
xTexts = $T(xTexts, withTransition)
|
|
14447
14494
|
.attr("x", getGridTextX(!isRotated, width, height))
|
|
14448
|
-
.attr("y", xv)
|
|
14449
|
-
|
|
14495
|
+
.attr("y", xv);
|
|
14496
|
+
yLines = $T(yLines, withTransition)
|
|
14497
|
+
.attr("x1", isRotated ? yv : 0)
|
|
14498
|
+
.attr("x2", isRotated ? yv : width)
|
|
14499
|
+
.attr("y1", isRotated ? 0 : yv)
|
|
14500
|
+
.attr("y2", isRotated ? height : yv);
|
|
14501
|
+
yTexts = $T(yTexts, withTransition)
|
|
14502
|
+
.attr("x", getGridTextX(isRotated, width, height))
|
|
14503
|
+
.attr("y", yv);
|
|
14450
14504
|
return [
|
|
14451
|
-
|
|
14452
|
-
|
|
14505
|
+
xLines.style("opacity", null),
|
|
14506
|
+
xTexts.style("opacity", null),
|
|
14507
|
+
yLines.style("opacity", null),
|
|
14508
|
+
yTexts.style("opacity", null)
|
|
14453
14509
|
];
|
|
14454
14510
|
},
|
|
14455
14511
|
initFocusGrid: function () {
|
|
@@ -14624,7 +14680,7 @@ var grid = {
|
|
|
14624
14680
|
.remove();
|
|
14625
14681
|
var gridLines = "grid_".concat(forX ? "x" : "y", "_lines");
|
|
14626
14682
|
config[gridLines] = config[gridLines].filter(toShow);
|
|
14627
|
-
}
|
|
14683
|
+
}
|
|
14628
14684
|
};
|
|
14629
14685
|
|
|
14630
14686
|
/**
|
|
@@ -14655,7 +14711,8 @@ var region = {
|
|
|
14655
14711
|
$T(regions.exit())
|
|
14656
14712
|
.style("opacity", "0")
|
|
14657
14713
|
.remove();
|
|
14658
|
-
var regionsEnter = regions
|
|
14714
|
+
var regionsEnter = regions
|
|
14715
|
+
.enter()
|
|
14659
14716
|
.append("g");
|
|
14660
14717
|
regionsEnter
|
|
14661
14718
|
.append("rect")
|
|
@@ -14663,16 +14720,35 @@ var region = {
|
|
|
14663
14720
|
region.list = regionsEnter
|
|
14664
14721
|
.merge(regions)
|
|
14665
14722
|
.attr("class", $$.classRegion.bind($$));
|
|
14723
|
+
region.list.each(function (d) {
|
|
14724
|
+
var _a;
|
|
14725
|
+
var g = select(this);
|
|
14726
|
+
if (g.select("text").empty() && ((_a = d.label) === null || _a === void 0 ? void 0 : _a.text)) {
|
|
14727
|
+
select(this).append("text")
|
|
14728
|
+
.style("opacity", "0");
|
|
14729
|
+
}
|
|
14730
|
+
});
|
|
14666
14731
|
},
|
|
14667
14732
|
redrawRegion: function (withTransition) {
|
|
14668
14733
|
var $$ = this;
|
|
14669
14734
|
var region = $$.$el.region, $T = $$.$T;
|
|
14670
14735
|
var regions = region.list.select("rect");
|
|
14736
|
+
var label = region.list.selectAll("text");
|
|
14671
14737
|
regions = $T(regions, withTransition)
|
|
14672
14738
|
.attr("x", $$.regionX.bind($$))
|
|
14673
14739
|
.attr("y", $$.regionY.bind($$))
|
|
14674
14740
|
.attr("width", $$.regionWidth.bind($$))
|
|
14675
14741
|
.attr("height", $$.regionHeight.bind($$));
|
|
14742
|
+
label = $T(label, withTransition)
|
|
14743
|
+
.attr("transform", function (d) {
|
|
14744
|
+
var _a;
|
|
14745
|
+
var _b = (_a = d.label) !== null && _a !== void 0 ? _a : {}, _c = _b.x, x = _c === void 0 ? 0 : _c, _d = _b.y, y = _d === void 0 ? 0 : _d, _e = _b.rotated, rotated = _e === void 0 ? false : _e;
|
|
14746
|
+
return "translate(".concat($$.regionX.bind($$)(d) + x, ", ").concat($$.regionY.bind($$)(d) + y, ")").concat(rotated ? " rotate(-90)" : "");
|
|
14747
|
+
})
|
|
14748
|
+
.attr("text-anchor", function (d) { var _a; return (((_a = d.label) === null || _a === void 0 ? void 0 : _a.rotated) ? "end" : null); })
|
|
14749
|
+
.attr("dy", "1em")
|
|
14750
|
+
.style("fill", function (d) { var _a, _b; return (_b = (_a = d.label) === null || _a === void 0 ? void 0 : _a.color) !== null && _b !== void 0 ? _b : null; })
|
|
14751
|
+
.text(function (d) { var _a; return (_a = d.label) === null || _a === void 0 ? void 0 : _a.text; });
|
|
14676
14752
|
return [
|
|
14677
14753
|
regions
|
|
14678
14754
|
.style("fill-opacity", function (d) { return (isValue(d.opacity) ? d.opacity : null); })
|
|
@@ -14681,7 +14757,8 @@ var region = {
|
|
|
14681
14757
|
select(this.parentNode)
|
|
14682
14758
|
.selectAll("rect:not([x])")
|
|
14683
14759
|
.remove();
|
|
14684
|
-
})
|
|
14760
|
+
}),
|
|
14761
|
+
label.style("opacity", null)
|
|
14685
14762
|
];
|
|
14686
14763
|
},
|
|
14687
14764
|
getRegionXY: function (type, d) {
|
|
@@ -14885,10 +14962,6 @@ var sizeAxis = {
|
|
|
14885
14962
|
}
|
|
14886
14963
|
};
|
|
14887
14964
|
|
|
14888
|
-
/**
|
|
14889
|
-
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
14890
|
-
* billboard.js project is licensed under the MIT license
|
|
14891
|
-
*/
|
|
14892
14965
|
/**
|
|
14893
14966
|
* Axis based chart data config options
|
|
14894
14967
|
*/
|
|
@@ -15078,6 +15151,7 @@ var x = {
|
|
|
15078
15151
|
* - **log** type:
|
|
15079
15152
|
* - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
|
|
15080
15153
|
* - x axis min value should be >= 0.
|
|
15154
|
+
* - for 'category' type, `data.xs` option isn't supported.
|
|
15081
15155
|
*
|
|
15082
15156
|
* @name axis․x․type
|
|
15083
15157
|
* @memberof Options
|
|
@@ -16763,10 +16837,6 @@ var options = [
|
|
|
16763
16837
|
optGrid,
|
|
16764
16838
|
];
|
|
16765
16839
|
|
|
16766
|
-
/**
|
|
16767
|
-
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
16768
|
-
* billboard.js project is licensed under the MIT license
|
|
16769
|
-
*/
|
|
16770
16840
|
/**
|
|
16771
16841
|
* Get radius functions
|
|
16772
16842
|
* @param {number} expandRate Expand rate number.
|
|
@@ -16852,11 +16922,23 @@ function getRadiusFn(expandRate) {
|
|
|
16852
16922
|
*/
|
|
16853
16923
|
function getAttrTweenFn(fn) {
|
|
16854
16924
|
return function (d) {
|
|
16855
|
-
var
|
|
16925
|
+
var getAngleKeyValue = function (_a) {
|
|
16926
|
+
var _b = _a.startAngle, startAngle = _b === void 0 ? 0 : _b, _c = _a.endAngle, endAngle = _c === void 0 ? 0 : _c, _d = _a.padAngle, padAngle = _d === void 0 ? 0 : _d;
|
|
16927
|
+
return ({
|
|
16928
|
+
startAngle: startAngle,
|
|
16929
|
+
endAngle: endAngle,
|
|
16930
|
+
padAngle: padAngle
|
|
16931
|
+
});
|
|
16932
|
+
};
|
|
16933
|
+
// d3.interpolate interpolates id value, if id is given as color string(ex. gold, silver, etc)
|
|
16934
|
+
// to avoid unexpected behavior, interpolate only angle values
|
|
16935
|
+
// https://github.com/naver/billboard.js/issues/3321
|
|
16936
|
+
var interpolate$1 = interpolate(getAngleKeyValue(this._current), getAngleKeyValue(d));
|
|
16856
16937
|
this._current = d;
|
|
16857
16938
|
return function (t) {
|
|
16858
16939
|
var interpolated = interpolate$1(t);
|
|
16859
|
-
|
|
16940
|
+
var data = d.data, index = d.index, value = d.value;
|
|
16941
|
+
return fn(_assign(_assign({}, interpolated), { data: data, index: index, value: value }));
|
|
16860
16942
|
};
|
|
16861
16943
|
};
|
|
16862
16944
|
}
|
|
@@ -17599,8 +17681,9 @@ var shapeArc = {
|
|
|
17599
17681
|
// touch events
|
|
17600
17682
|
if (isTouch && $$.hasArcType() && !$$.radars) {
|
|
17601
17683
|
var getEventArc_1 = function (event) {
|
|
17602
|
-
var
|
|
17603
|
-
var
|
|
17684
|
+
var _a, _b;
|
|
17685
|
+
var _c = (_b = (_a = event.changedTouches) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : { clientX: 0, clientY: 0 }, clientX = _c.clientX, clientY = _c.clientY;
|
|
17686
|
+
var eventArc = select(doc.elementFromPoint(clientX, clientY));
|
|
17604
17687
|
return eventArc;
|
|
17605
17688
|
};
|
|
17606
17689
|
$$.$el.svg
|
|
@@ -18084,14 +18167,12 @@ var shapeCandlestick = {
|
|
|
18084
18167
|
var $$ = this;
|
|
18085
18168
|
var $el = $$.$el;
|
|
18086
18169
|
var classChart = $$.getChartClass("Candlestick");
|
|
18087
|
-
var classFocus = $$.classFocus.bind($$);
|
|
18088
18170
|
if (!$el.candlestick) {
|
|
18089
18171
|
$$.initCandlestick();
|
|
18090
18172
|
}
|
|
18091
18173
|
var mainUpdate = $$.$el.main.select(".".concat($CANDLESTICK.chartCandlesticks))
|
|
18092
18174
|
.selectAll(".".concat($CANDLESTICK.chartCandlestick))
|
|
18093
|
-
.data(targets)
|
|
18094
|
-
.attr("class", function (d) { return classChart(d) + classFocus(d); });
|
|
18175
|
+
.data(targets);
|
|
18095
18176
|
mainUpdate.enter().append("g")
|
|
18096
18177
|
.attr("class", classChart)
|
|
18097
18178
|
.style("pointer-events", "none");
|
|
@@ -18121,9 +18202,6 @@ var shapeCandlestick = {
|
|
|
18121
18202
|
.attr("class", classSetter);
|
|
18122
18203
|
candlestickEnter.append("line");
|
|
18123
18204
|
candlestickEnter.append("path");
|
|
18124
|
-
if (!$root.candlestick) {
|
|
18125
|
-
$root.candlestick = {};
|
|
18126
|
-
}
|
|
18127
18205
|
$root.candlestick = candlestick.merge(candlestickEnter)
|
|
18128
18206
|
.style("opacity", initialOpacity);
|
|
18129
18207
|
},
|
|
@@ -18186,7 +18264,6 @@ var shapeCandlestick = {
|
|
|
18186
18264
|
generateGetCandlestickPoints: function (indices, isSub) {
|
|
18187
18265
|
if (isSub === void 0) { isSub = false; }
|
|
18188
18266
|
var $$ = this;
|
|
18189
|
-
var config = $$.config;
|
|
18190
18267
|
var axis = isSub ? $$.axis.subX : $$.axis.x;
|
|
18191
18268
|
var targetsNum = $$.getIndicesMax(indices) + 1;
|
|
18192
18269
|
var barW = $$.getBarW("candlestick", axis, targetsNum);
|
|
@@ -18200,7 +18277,7 @@ var shapeCandlestick = {
|
|
|
18200
18277
|
var width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
|
|
18201
18278
|
var value = $$.getCandlestickData(d);
|
|
18202
18279
|
var points;
|
|
18203
|
-
if (value) {
|
|
18280
|
+
if (value && isNumber(value.open) && isNumber(value.close)) {
|
|
18204
18281
|
var posX = {
|
|
18205
18282
|
start: x(d),
|
|
18206
18283
|
end: 0
|
|
@@ -18215,10 +18292,6 @@ var shapeCandlestick = {
|
|
|
18215
18292
|
high: y(value.high),
|
|
18216
18293
|
low: y(value.low)
|
|
18217
18294
|
};
|
|
18218
|
-
// fix posY not to overflow opposite quadrant
|
|
18219
|
-
if (config.axis_rotated && ((d.value > 0 && posY.start < y0) || (d.value < 0 && y0 < posY.start))) {
|
|
18220
|
-
posY.start = y0;
|
|
18221
|
-
}
|
|
18222
18295
|
posY.start -= (y0 - offset);
|
|
18223
18296
|
points = [
|
|
18224
18297
|
[posX.start, posY.start],
|
|
@@ -19688,11 +19761,11 @@ var shapeTreemap = {
|
|
|
19688
19761
|
if (config.interaction_enabled) {
|
|
19689
19762
|
var isTouch = state.inputType === "touch";
|
|
19690
19763
|
$el.treemap
|
|
19691
|
-
.on(isTouch ? "touchstart" : "mousemove", function (event) {
|
|
19764
|
+
.on(isTouch ? "touchstart" : "mouseover mousemove", function (event) {
|
|
19692
19765
|
var data = getTarget(event);
|
|
19693
19766
|
if (data) {
|
|
19694
19767
|
$$.showTooltip([data], event.currentTarget);
|
|
19695
|
-
event.type
|
|
19768
|
+
/^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
|
|
19696
19769
|
}
|
|
19697
19770
|
})
|
|
19698
19771
|
.on(isTouch ? "touchend" : "mouseout", function (event) {
|
|
@@ -21236,113 +21309,157 @@ var apiSelection = {
|
|
|
21236
21309
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
21237
21310
|
* billboard.js project is licensed under the MIT license
|
|
21238
21311
|
*/
|
|
21239
|
-
|
|
21240
|
-
|
|
21241
|
-
|
|
21242
|
-
|
|
21243
|
-
|
|
21244
|
-
|
|
21245
|
-
|
|
21246
|
-
|
|
21247
|
-
|
|
21248
|
-
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
|
|
21252
|
-
|
|
21253
|
-
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
|
|
21259
|
-
|
|
21260
|
-
|
|
21261
|
-
|
|
21262
|
-
|
|
21263
|
-
|
|
21264
|
-
|
|
21265
|
-
|
|
21266
|
-
|
|
21267
|
-
var subchart = $$.$el.subchart, config = $$.config;
|
|
21268
|
-
var show = config.subchart_show;
|
|
21269
|
-
if (!show) {
|
|
21270
|
-
// unbind zoom event bound to chart rect area
|
|
21271
|
-
$$.unbindZoomEvent();
|
|
21272
|
-
config.subchart_show = !show;
|
|
21273
|
-
!subchart.main && $$.initSubchart();
|
|
21274
|
-
var $target = subchart.main.selectAll(".".concat($COMMON.target));
|
|
21275
|
-
// need to cover when new data has been loaded
|
|
21276
|
-
if ($$.data.targets.length !== $target.size()) {
|
|
21277
|
-
$$.updateSizes();
|
|
21278
|
-
$$.updateTargetsForSubchart($$.data.targets);
|
|
21279
|
-
$target = (_a = subchart.main) === null || _a === void 0 ? void 0 : _a.selectAll(".".concat($COMMON.target));
|
|
21280
|
-
}
|
|
21281
|
-
$target === null || $target === void 0 ? void 0 : $target.style("opacity", null);
|
|
21282
|
-
(_b = subchart.main) === null || _b === void 0 ? void 0 : _b.style("display", null);
|
|
21283
|
-
this.resize();
|
|
21312
|
+
/**
|
|
21313
|
+
* Select subchart by giving x domain range.
|
|
21314
|
+
* - **ℹ️ NOTE:**
|
|
21315
|
+
* - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
|
|
21316
|
+
* @function subchart
|
|
21317
|
+
* @instance
|
|
21318
|
+
* @memberof Chart
|
|
21319
|
+
* @param {Array} domainValue 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.
|
|
21320
|
+
* @returns {Array} domain value in array
|
|
21321
|
+
* @example
|
|
21322
|
+
* // Specify domain for subchart selection
|
|
21323
|
+
* chart.subchart([1, 2]);
|
|
21324
|
+
*
|
|
21325
|
+
* // Get the current subchart selection domain range
|
|
21326
|
+
* // Domain value may not be exact returning approximately values.
|
|
21327
|
+
* chart.subchart();
|
|
21328
|
+
*/
|
|
21329
|
+
// NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
|
|
21330
|
+
var subchart$1 = function (domainValue) {
|
|
21331
|
+
var _a;
|
|
21332
|
+
var $$ = this.internal;
|
|
21333
|
+
var axis = $$.axis, brush = $$.brush, config = $$.config, _b = $$.scale, x = _b.x, subX = _b.subX, state = $$.state;
|
|
21334
|
+
var domain;
|
|
21335
|
+
if (config.subchart_show) {
|
|
21336
|
+
domain = domainValue;
|
|
21337
|
+
if (Array.isArray(domain)) {
|
|
21338
|
+
if (axis.isTimeSeries()) {
|
|
21339
|
+
domain = domain.map(function (x) { return parseDate.bind($$)(x); });
|
|
21284
21340
|
}
|
|
21285
|
-
|
|
21286
|
-
|
|
21287
|
-
|
|
21288
|
-
|
|
21289
|
-
* @function subchart․hide
|
|
21290
|
-
* @instance
|
|
21291
|
-
* @memberof Chart
|
|
21292
|
-
* @example
|
|
21293
|
-
* chart.subchart.hide();
|
|
21294
|
-
*/
|
|
21295
|
-
hide: function () {
|
|
21296
|
-
var $$ = this.internal;
|
|
21297
|
-
var main = $$.$el.subchart.main, config = $$.config;
|
|
21298
|
-
if (config.subchart_show && (main === null || main === void 0 ? void 0 : main.style("display")) !== "none") {
|
|
21299
|
-
config.subchart_show = false;
|
|
21300
|
-
main.style("display", "none");
|
|
21301
|
-
this.resize();
|
|
21341
|
+
var isWithinRange = $$.withinRange(domain, $$.getZoomDomain("subX", true), $$.getZoomDomain("subX"));
|
|
21342
|
+
if (isWithinRange) {
|
|
21343
|
+
state.domain = domain;
|
|
21344
|
+
brush.move(brush.getSelection(), domain.map(subX));
|
|
21302
21345
|
}
|
|
21303
|
-
},
|
|
21304
|
-
/**
|
|
21305
|
-
* Toggle the visiblity of subchart
|
|
21306
|
-
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21307
|
-
* @function subchart․toggle
|
|
21308
|
-
* @instance
|
|
21309
|
-
* @memberof Chart
|
|
21310
|
-
* @example
|
|
21311
|
-
* // When subchart is hidden, will be shown
|
|
21312
|
-
* // When subchart is shown, will be hidden
|
|
21313
|
-
* chart.subchart.toggle();
|
|
21314
|
-
*/
|
|
21315
|
-
toggle: function () {
|
|
21316
|
-
var $$ = this.internal;
|
|
21317
|
-
var config = $$.config;
|
|
21318
|
-
this.subchart[config.subchart_show ? "hide" : "show"]();
|
|
21319
21346
|
}
|
|
21347
|
+
else {
|
|
21348
|
+
domain = (_a = state.domain) !== null && _a !== void 0 ? _a : x.orgDomain();
|
|
21349
|
+
}
|
|
21350
|
+
}
|
|
21351
|
+
return domain;
|
|
21352
|
+
};
|
|
21353
|
+
extend(subchart$1, {
|
|
21354
|
+
/**
|
|
21355
|
+
* Show subchart
|
|
21356
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21357
|
+
* @function subchart․show
|
|
21358
|
+
* @instance
|
|
21359
|
+
* @memberof Chart
|
|
21360
|
+
* @example
|
|
21361
|
+
* // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
|
|
21362
|
+
* import {subchart} from "billboard.js";
|
|
21363
|
+
*
|
|
21364
|
+
* const chart = bb.generate({
|
|
21365
|
+
* ...
|
|
21366
|
+
* subchart: {
|
|
21367
|
+
* // need to be instantiated by calling 'subchart()'
|
|
21368
|
+
* enabled: subchart()
|
|
21369
|
+
*
|
|
21370
|
+
* // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
|
|
21371
|
+
* enabled: !subchart()
|
|
21372
|
+
* }
|
|
21373
|
+
* });
|
|
21374
|
+
*
|
|
21375
|
+
* chart.subchart.show();
|
|
21376
|
+
*/
|
|
21377
|
+
show: function () {
|
|
21378
|
+
var _a, _b;
|
|
21379
|
+
var $$ = this.internal;
|
|
21380
|
+
var subchart = $$.$el.subchart, config = $$.config;
|
|
21381
|
+
var show = config.subchart_show;
|
|
21382
|
+
if (!show) {
|
|
21383
|
+
// unbind zoom event bound to chart rect area
|
|
21384
|
+
$$.unbindZoomEvent();
|
|
21385
|
+
config.subchart_show = !show;
|
|
21386
|
+
!subchart.main && $$.initSubchart();
|
|
21387
|
+
var $target = subchart.main.selectAll(".".concat($COMMON.target));
|
|
21388
|
+
// need to cover when new data has been loaded
|
|
21389
|
+
if ($$.data.targets.length !== $target.size()) {
|
|
21390
|
+
$$.updateSizes();
|
|
21391
|
+
$$.updateTargetsForSubchart($$.data.targets);
|
|
21392
|
+
$target = (_a = subchart.main) === null || _a === void 0 ? void 0 : _a.selectAll(".".concat($COMMON.target));
|
|
21393
|
+
}
|
|
21394
|
+
$target === null || $target === void 0 ? void 0 : $target.style("opacity", null);
|
|
21395
|
+
(_b = subchart.main) === null || _b === void 0 ? void 0 : _b.style("display", null);
|
|
21396
|
+
this.resize();
|
|
21397
|
+
}
|
|
21398
|
+
},
|
|
21399
|
+
/**
|
|
21400
|
+
* Hide generated subchart
|
|
21401
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21402
|
+
* @function subchart․hide
|
|
21403
|
+
* @instance
|
|
21404
|
+
* @memberof Chart
|
|
21405
|
+
* @example
|
|
21406
|
+
* chart.subchart.hide();
|
|
21407
|
+
*/
|
|
21408
|
+
hide: function () {
|
|
21409
|
+
var $$ = this.internal;
|
|
21410
|
+
var main = $$.$el.subchart.main, config = $$.config;
|
|
21411
|
+
if (config.subchart_show && (main === null || main === void 0 ? void 0 : main.style("display")) !== "none") {
|
|
21412
|
+
config.subchart_show = false;
|
|
21413
|
+
main.style("display", "none");
|
|
21414
|
+
this.resize();
|
|
21415
|
+
}
|
|
21416
|
+
},
|
|
21417
|
+
/**
|
|
21418
|
+
* Toggle the visiblity of subchart
|
|
21419
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21420
|
+
* @function subchart․toggle
|
|
21421
|
+
* @instance
|
|
21422
|
+
* @memberof Chart
|
|
21423
|
+
* @example
|
|
21424
|
+
* // When subchart is hidden, will be shown
|
|
21425
|
+
* // When subchart is shown, will be hidden
|
|
21426
|
+
* chart.subchart.toggle();
|
|
21427
|
+
*/
|
|
21428
|
+
toggle: function () {
|
|
21429
|
+
var $$ = this.internal;
|
|
21430
|
+
var config = $$.config;
|
|
21431
|
+
this.subchart[config.subchart_show ? "hide" : "show"]();
|
|
21432
|
+
},
|
|
21433
|
+
/**
|
|
21434
|
+
* Reset subchart selection
|
|
21435
|
+
* @function subchart․reset
|
|
21436
|
+
* @instance
|
|
21437
|
+
* @memberof Chart
|
|
21438
|
+
* @example
|
|
21439
|
+
* // Reset subchart selection
|
|
21440
|
+
* chart.subchart.reset();
|
|
21441
|
+
*/
|
|
21442
|
+
reset: function () {
|
|
21443
|
+
var $$ = this.internal;
|
|
21444
|
+
var brush = $$.brush;
|
|
21445
|
+
brush.clear(brush.getSelection());
|
|
21320
21446
|
}
|
|
21447
|
+
});
|
|
21448
|
+
var apiSubchart = {
|
|
21449
|
+
subchart: subchart$1
|
|
21321
21450
|
};
|
|
21322
21451
|
|
|
21323
21452
|
/**
|
|
21324
21453
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
21325
21454
|
* billboard.js project is licensed under the MIT license
|
|
21326
21455
|
*/
|
|
21327
|
-
/**
|
|
21328
|
-
* Check if the given domain is within zoom range
|
|
21329
|
-
* @param {Array} domain Target domain value
|
|
21330
|
-
* @param {Array} current Current zoom domain value
|
|
21331
|
-
* @param {Array} range Zoom range value
|
|
21332
|
-
* @param {boolean} isInverted Whether the axis is inverted or not
|
|
21333
|
-
* @returns {boolean}
|
|
21334
|
-
* @private
|
|
21335
|
-
*/
|
|
21336
|
-
function withinRange(domain, current, range, isInverted) {
|
|
21337
|
-
if (isInverted === void 0) { isInverted = false; }
|
|
21338
|
-
var min = range[0], max = range[1];
|
|
21339
|
-
return domain.every(function (v, i) { return (i === 0 ? (isInverted ? +v <= min : +v >= min) : (isInverted ? +v >= max : +v <= max)) && !(domain.every(function (v, i) { return v === current[i]; })); });
|
|
21340
|
-
}
|
|
21341
21456
|
/**
|
|
21342
21457
|
* Zoom by giving x domain range.
|
|
21343
|
-
* -
|
|
21458
|
+
* - **ℹ️ NOTE:**
|
|
21344
21459
|
* - For `wheel` type zoom, the minimum zoom range will be set as the given domain range. To get the initial state, [.unzoom()](#unzoom) should be called.
|
|
21345
21460
|
* - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
|
|
21461
|
+
* - When x axis type is `category`, domain range should be specified as index numbers.
|
|
21462
|
+
* - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
|
|
21346
21463
|
* @function zoom
|
|
21347
21464
|
* @instance
|
|
21348
21465
|
* @memberof Chart
|
|
@@ -21352,56 +21469,64 @@ function withinRange(domain, current, range, isInverted) {
|
|
|
21352
21469
|
* // Zoom to specified domain range
|
|
21353
21470
|
* chart.zoom([10, 20]);
|
|
21354
21471
|
*
|
|
21355
|
-
* // For timeseries, the domain value can be string, but the format should match with the 'data.xFormat' option.
|
|
21472
|
+
* // For timeseries x axis, the domain value can be string, but the format should match with the 'data.xFormat' option.
|
|
21356
21473
|
* chart.zoom(["2021-02-03", "2021-02-08"]);
|
|
21357
21474
|
*
|
|
21475
|
+
* // For category x axis, the domain value should be index number.
|
|
21476
|
+
* chart.zoom([0, 3]);
|
|
21477
|
+
*
|
|
21358
21478
|
* // Get the current zoomed domain range
|
|
21479
|
+
* // Domain value may not be exact returning approximately values.
|
|
21359
21480
|
* chart.zoom();
|
|
21360
21481
|
*/
|
|
21482
|
+
// NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
|
|
21361
21483
|
var zoom$1 = function (domainValue) {
|
|
21362
21484
|
var _a;
|
|
21485
|
+
var _b;
|
|
21363
21486
|
var $$ = this.internal;
|
|
21364
|
-
var $el = $$.$el, axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale;
|
|
21487
|
+
var $el = $$.$el, axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale, state = $$.state;
|
|
21365
21488
|
var isRotated = config.axis_rotated;
|
|
21366
|
-
var isInverted = config.axis_x_inverted;
|
|
21367
21489
|
var isCategorized = axis.isCategorized();
|
|
21368
|
-
var domain
|
|
21369
|
-
if (config.zoom_enabled
|
|
21370
|
-
|
|
21371
|
-
|
|
21372
|
-
|
|
21373
|
-
|
|
21374
|
-
|
|
21375
|
-
|
|
21376
|
-
|
|
21377
|
-
|
|
21378
|
-
|
|
21379
|
-
|
|
21380
|
-
|
|
21381
|
-
|
|
21382
|
-
$$.
|
|
21383
|
-
|
|
21490
|
+
var domain;
|
|
21491
|
+
if (config.zoom_enabled) {
|
|
21492
|
+
domain = domainValue;
|
|
21493
|
+
if (Array.isArray(domain)) {
|
|
21494
|
+
if (axis.isTimeSeries()) {
|
|
21495
|
+
domain = domain.map(function (x) { return parseDate.bind($$)(x); });
|
|
21496
|
+
}
|
|
21497
|
+
var isWithinRange = $$.withinRange(domain, $$.getZoomDomain("zoom", true), $$.getZoomDomain("zoom"));
|
|
21498
|
+
if (isWithinRange) {
|
|
21499
|
+
state.domain = domain;
|
|
21500
|
+
if (isCategorized) {
|
|
21501
|
+
domain = domain.map(function (v, i) { return Number(v) + (i === 0 ? 0 : 1); });
|
|
21502
|
+
}
|
|
21503
|
+
// hide any possible tooltip show before the zoom
|
|
21504
|
+
$$.api.tooltip.hide();
|
|
21505
|
+
if (config.subchart_show) {
|
|
21506
|
+
var x = scale.zoom || scale.x;
|
|
21507
|
+
$$.brush.getSelection().call($$.brush.move, domain.map(x));
|
|
21508
|
+
// resultDomain = domain;
|
|
21509
|
+
}
|
|
21510
|
+
else {
|
|
21511
|
+
// in case of 'config.zoom_rescale=true', use org.xScale
|
|
21512
|
+
var x = isCategorized ? scale.x.orgScale() : (org.xScale || scale.x);
|
|
21513
|
+
// Get transform from given domain value
|
|
21514
|
+
// https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
|
|
21515
|
+
var translate = [-x(domain[0]), 0];
|
|
21516
|
+
var transform = (_a = zoomIdentity
|
|
21517
|
+
.scale(x.range()[1] / (x(domain[1]) - x(domain[0]))))
|
|
21518
|
+
.translate.apply(_a, (isRotated ? translate.reverse() : translate));
|
|
21519
|
+
$el.eventRect
|
|
21520
|
+
.call($$.zoom.transform, transform);
|
|
21521
|
+
}
|
|
21522
|
+
$$.setZoomResetButton();
|
|
21384
21523
|
}
|
|
21385
|
-
|
|
21386
|
-
|
|
21387
|
-
|
|
21388
|
-
// Get transform from given domain value
|
|
21389
|
-
// https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
|
|
21390
|
-
var translate = [-x(domain[0]), 0];
|
|
21391
|
-
var transform = (_a = zoomIdentity
|
|
21392
|
-
.scale(x.range()[1] / (x(domain[1]) - x(domain[0]))))
|
|
21393
|
-
.translate.apply(_a, (isRotated ? translate.reverse() : translate));
|
|
21394
|
-
$el.eventRect
|
|
21395
|
-
.call($$.zoom.transform, transform);
|
|
21396
|
-
}
|
|
21397
|
-
$$.setZoomResetButton();
|
|
21524
|
+
}
|
|
21525
|
+
else {
|
|
21526
|
+
domain = $$.zoom.getDomain();
|
|
21398
21527
|
}
|
|
21399
21528
|
}
|
|
21400
|
-
|
|
21401
|
-
domain = scale.zoom ?
|
|
21402
|
-
scale.zoom.domain() : scale.x.orgDomain();
|
|
21403
|
-
}
|
|
21404
|
-
return domain;
|
|
21529
|
+
return (_b = state.domain) !== null && _b !== void 0 ? _b : domain;
|
|
21405
21530
|
};
|
|
21406
21531
|
extend(zoom$1, {
|
|
21407
21532
|
/**
|
|
@@ -21519,7 +21644,7 @@ var apiZoom = {
|
|
|
21519
21644
|
*/
|
|
21520
21645
|
unzoom: function () {
|
|
21521
21646
|
var $$ = this.internal;
|
|
21522
|
-
var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, zoomResetBtn = _a.zoomResetBtn;
|
|
21647
|
+
var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, zoomResetBtn = _a.zoomResetBtn, state = $$.state;
|
|
21523
21648
|
if ($$.scale.zoom) {
|
|
21524
21649
|
config.subchart_show ?
|
|
21525
21650
|
$$.brush.getSelection().call($$.brush.move, null) :
|
|
@@ -21530,6 +21655,7 @@ var apiZoom = {
|
|
|
21530
21655
|
if (zoomTransform(eventRect.node()) !== zoomIdentity) {
|
|
21531
21656
|
$$.zoom.transform(eventRect, zoomIdentity);
|
|
21532
21657
|
}
|
|
21658
|
+
state.domain = undefined;
|
|
21533
21659
|
}
|
|
21534
21660
|
}
|
|
21535
21661
|
};
|
|
@@ -21802,29 +21928,32 @@ var subchart = {
|
|
|
21802
21928
|
*/
|
|
21803
21929
|
initBrush: function () {
|
|
21804
21930
|
var $$ = this;
|
|
21805
|
-
var config = $$.config, scale = $$.scale, subchart = $$.$el.subchart;
|
|
21931
|
+
var config = $$.config, scale = $$.scale, subchart = $$.$el.subchart, state = $$.state;
|
|
21806
21932
|
var isRotated = config.axis_rotated;
|
|
21933
|
+
var height = config.subchart_size_height;
|
|
21807
21934
|
var lastDomain;
|
|
21935
|
+
var lastSelection;
|
|
21808
21936
|
var timeout;
|
|
21809
21937
|
// set the brush
|
|
21810
21938
|
$$.brush = (isRotated ? brushY() : brushX()).handleSize(5);
|
|
21811
|
-
var getBrushSize = function () {
|
|
21812
|
-
var brush = $$.$el.svg.select(".".concat(CLASS.brush, " .overlay"));
|
|
21813
|
-
var brushSize = { width: 0, height: 0 };
|
|
21814
|
-
if (brush.size()) {
|
|
21815
|
-
brushSize.width = +brush.attr("width");
|
|
21816
|
-
brushSize.height = +brush.attr("height");
|
|
21817
|
-
}
|
|
21818
|
-
return brushSize[isRotated ? "width" : "height"];
|
|
21819
|
-
};
|
|
21820
21939
|
// bind brush event
|
|
21821
21940
|
$$.brush.on("start brush end", function (event) {
|
|
21822
|
-
var selection = event.selection, target = event.target, type = event.type;
|
|
21941
|
+
var selection = event.selection, sourceEvent = event.sourceEvent, target = event.target, type = event.type;
|
|
21823
21942
|
if (type === "start") {
|
|
21824
21943
|
$$.state.inputType === "touch" && $$.hideTooltip();
|
|
21944
|
+
lastSelection = sourceEvent ? selection : null;
|
|
21945
|
+
// sourceEvent && (state.domain = null);
|
|
21825
21946
|
}
|
|
21947
|
+
// if (type === "brush") {
|
|
21826
21948
|
if (/(start|brush)/.test(type)) {
|
|
21827
|
-
|
|
21949
|
+
// when brush selection updates happens on one edge, update only chainging edge and
|
|
21950
|
+
// is only for adjustment of given domain range to be used to return current domain range.
|
|
21951
|
+
type === "brush" && sourceEvent && state.domain && (lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.forEach(function (v, i) {
|
|
21952
|
+
if (v !== selection[i]) {
|
|
21953
|
+
state.domain[i] = scale.x.orgDomain()[i];
|
|
21954
|
+
}
|
|
21955
|
+
}));
|
|
21956
|
+
$$.redrawForBrush(type !== "start");
|
|
21828
21957
|
}
|
|
21829
21958
|
if (type === "end") {
|
|
21830
21959
|
lastDomain = scale.x.orgDomain();
|
|
@@ -21837,9 +21966,8 @@ var subchart = {
|
|
|
21837
21966
|
else {
|
|
21838
21967
|
$$.brush.handle.attr("display", null)
|
|
21839
21968
|
.attr("transform", function (d, i) {
|
|
21840
|
-
var pos =
|
|
21841
|
-
|
|
21842
|
-
return "translate(".concat(pos, ")");
|
|
21969
|
+
var pos = [selection[i], height / 2];
|
|
21970
|
+
return "translate(".concat(isRotated ? pos.reverse() : pos, ")");
|
|
21843
21971
|
});
|
|
21844
21972
|
}
|
|
21845
21973
|
}
|
|
@@ -21863,7 +21991,7 @@ var subchart = {
|
|
|
21863
21991
|
};
|
|
21864
21992
|
// set the brush extent
|
|
21865
21993
|
$$.brush.scale = function (scale) {
|
|
21866
|
-
var h = config.subchart_size_height
|
|
21994
|
+
var h = config.subchart_size_height;
|
|
21867
21995
|
var extent = $$.getExtent();
|
|
21868
21996
|
if (!extent && scale.range) {
|
|
21869
21997
|
extent = [[0, 0], [scale.range()[1], h]];
|
|
@@ -21948,11 +22076,11 @@ var subchart = {
|
|
|
21948
22076
|
var customHandleClass = "handle--custom";
|
|
21949
22077
|
// brush handle shape's path
|
|
21950
22078
|
var path = isRotated ? [
|
|
21951
|
-
"
|
|
21952
|
-
"
|
|
22079
|
+
"M8.5 0 a6 6 0 0 0 -6 -6.5 H-2.5 a 6 6 0 0 0 -6 6.5 z m-5 -2 H-3.5 m7 -2 H-3.5z",
|
|
22080
|
+
"M8.5 0 a6 -6 0 0 1 -6 6.5 H-2.5 a 6 -6 0 0 1 -6 -6.5z m-5 2 H-3.5 m7 2 H-3.5z"
|
|
21953
22081
|
] : [
|
|
21954
|
-
"
|
|
21955
|
-
"
|
|
22082
|
+
"M0 -8.5 A6 6 0 0 0 -6.5 -3.5 V2.5 A6 6 0 0 0 0 8.5 Z M-2 -3.5 V3.5 M-4 -3.5 V3.5z",
|
|
22083
|
+
"M0 -8.5 A6 6 0 0 1 6.5 -3.5 V2.5 A6 6 0 0 1 0 8.5 Z M2 -3.5 V3.5 M4 -3.5 V3.5z"
|
|
21956
22084
|
];
|
|
21957
22085
|
$$.brush.handle = brush.selectAll(".".concat(customHandleClass))
|
|
21958
22086
|
.data(isRotated ?
|
|
@@ -22050,17 +22178,23 @@ var subchart = {
|
|
|
22050
22178
|
$$.updateCircle(true);
|
|
22051
22179
|
$$.redrawCircle(cx, cy, withTransition, undefined, true);
|
|
22052
22180
|
}
|
|
22053
|
-
!state.rendered && initRange
|
|
22181
|
+
if (!state.rendered && initRange) {
|
|
22182
|
+
state.domain = initRange;
|
|
22183
|
+
$$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
|
|
22184
|
+
}
|
|
22054
22185
|
}
|
|
22055
22186
|
}
|
|
22056
22187
|
},
|
|
22057
22188
|
/**
|
|
22058
22189
|
* Redraw the brush.
|
|
22190
|
+
* @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
|
|
22059
22191
|
* @private
|
|
22060
22192
|
*/
|
|
22061
|
-
redrawForBrush: function () {
|
|
22193
|
+
redrawForBrush: function (callCallbck) {
|
|
22194
|
+
var _a;
|
|
22195
|
+
if (callCallbck === void 0) { callCallbck = true; }
|
|
22062
22196
|
var $$ = this;
|
|
22063
|
-
var
|
|
22197
|
+
var _b = $$.config, onBrush = _b.subchart_onbrush, withY = _b.zoom_rescale, scale = $$.scale, state = $$.state;
|
|
22064
22198
|
$$.redraw({
|
|
22065
22199
|
withTransition: false,
|
|
22066
22200
|
withY: withY,
|
|
@@ -22068,7 +22202,8 @@ var subchart = {
|
|
|
22068
22202
|
withUpdateXDomain: true,
|
|
22069
22203
|
withDimension: false
|
|
22070
22204
|
});
|
|
22071
|
-
|
|
22205
|
+
callCallbck && state.rendered &&
|
|
22206
|
+
onBrush.bind($$.api)((_a = state.domain) !== null && _a !== void 0 ? _a : scale.x.orgDomain());
|
|
22072
22207
|
},
|
|
22073
22208
|
/**
|
|
22074
22209
|
* Transform context
|
|
@@ -22238,6 +22373,7 @@ var zoom = {
|
|
|
22238
22373
|
* @private
|
|
22239
22374
|
*/
|
|
22240
22375
|
onZoom: function (event) {
|
|
22376
|
+
var _a;
|
|
22241
22377
|
var $$ = this;
|
|
22242
22378
|
var config = $$.config, scale = $$.scale, state = $$.state, org = $$.org;
|
|
22243
22379
|
var sourceEvent = event.sourceEvent;
|
|
@@ -22249,6 +22385,7 @@ var zoom = {
|
|
|
22249
22385
|
}
|
|
22250
22386
|
if (event.sourceEvent) {
|
|
22251
22387
|
state.zooming = true;
|
|
22388
|
+
state.domain = undefined;
|
|
22252
22389
|
}
|
|
22253
22390
|
var isMousemove = (sourceEvent === null || sourceEvent === void 0 ? void 0 : sourceEvent.type) === "mousemove";
|
|
22254
22391
|
var isZoomOut = (sourceEvent === null || sourceEvent === void 0 ? void 0 : sourceEvent.wheelDelta) < 0;
|
|
@@ -22271,7 +22408,7 @@ var zoom = {
|
|
|
22271
22408
|
});
|
|
22272
22409
|
$$.state.cancelClick = isMousemove;
|
|
22273
22410
|
// do not call event cb when is .unzoom() is called
|
|
22274
|
-
!isUnZoom && callFn(config.zoom_onzoom, $$.api, $$.zoom.getDomain());
|
|
22411
|
+
!isUnZoom && callFn(config.zoom_onzoom, $$.api, (_a = $$.state.domain) !== null && _a !== void 0 ? _a : $$.zoom.getDomain());
|
|
22275
22412
|
},
|
|
22276
22413
|
/**
|
|
22277
22414
|
* 'end' event listener
|
|
@@ -22279,7 +22416,7 @@ var zoom = {
|
|
|
22279
22416
|
* @private
|
|
22280
22417
|
*/
|
|
22281
22418
|
onZoomEnd: function (event) {
|
|
22282
|
-
var _a;
|
|
22419
|
+
var _a, _b;
|
|
22283
22420
|
var $$ = this;
|
|
22284
22421
|
var config = $$.config, state = $$.state;
|
|
22285
22422
|
var startEvent = $$.zoom.startEvent;
|
|
@@ -22297,7 +22434,7 @@ var zoom = {
|
|
|
22297
22434
|
$$.updateZoom();
|
|
22298
22435
|
state.zooming = false;
|
|
22299
22436
|
// do not call event cb when is .unzoom() is called
|
|
22300
|
-
!isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, $$.zoom.getDomain());
|
|
22437
|
+
!isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, (_b = $$.state.domain) !== null && _b !== void 0 ? _b : $$.zoom.getDomain());
|
|
22301
22438
|
},
|
|
22302
22439
|
/**
|
|
22303
22440
|
* Update zoom
|
|
@@ -22741,7 +22878,7 @@ var zoomModule = function () {
|
|
|
22741
22878
|
var defaults = {};
|
|
22742
22879
|
/**
|
|
22743
22880
|
* @namespace bb
|
|
22744
|
-
* @version 3.
|
|
22881
|
+
* @version 3.10.0-next.1
|
|
22745
22882
|
*/
|
|
22746
22883
|
var bb = {
|
|
22747
22884
|
/**
|
|
@@ -22751,7 +22888,7 @@ var bb = {
|
|
|
22751
22888
|
* bb.version; // "1.0.0"
|
|
22752
22889
|
* @memberof bb
|
|
22753
22890
|
*/
|
|
22754
|
-
version: "3.
|
|
22891
|
+
version: "3.10.0-next.1",
|
|
22755
22892
|
/**
|
|
22756
22893
|
* Generate chart
|
|
22757
22894
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|