billboard.js 3.9.4 → 3.10.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/billboard.css +2 -2
- package/dist/billboard.js +2742 -2516
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +2936 -2704
- 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 +205 -186
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +231 -226
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +172 -152
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +161 -142
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/{billboardjs-plugin-bubblecompare.js → billboardjs-plugin-bubblecompare.pkgd.js} +52 -32
- 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} +239 -200
- 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} +301 -277
- 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} +206 -166
- 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} +308 -278
- 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 +718 -509
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +3 -3
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +15 -9
- 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 +32 -32
- 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 +3 -4
- package/src/ChartInternal/interactions/flow.ts +1 -7
- package/src/ChartInternal/interactions/interaction.ts +11 -5
- 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 -5
- package/src/ChartInternal/internals/color.ts +49 -23
- package/src/ChartInternal/internals/domain.ts +46 -10
- package/src/ChartInternal/internals/grid.ts +57 -86
- package/src/ChartInternal/internals/redraw.ts +1 -6
- package/src/ChartInternal/internals/region.ts +35 -12
- package/src/ChartInternal/internals/selection.ts +1 -1
- package/src/ChartInternal/internals/text.ts +1 -26
- package/src/ChartInternal/internals/title.ts +10 -48
- package/src/ChartInternal/internals/tooltip.ts +50 -54
- package/src/ChartInternal/shape/arc.ts +2 -2
- package/src/ChartInternal/shape/candlestick.ts +2 -17
- package/src/ChartInternal/shape/point.ts +36 -8
- package/src/ChartInternal/shape/radar.ts +1 -1
- 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/sparkline/index.ts +2 -2
- 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/point.ts +41 -0
- 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/Options/shape/area.ts +10 -4
- package/src/config/Options/shape/bar.ts +10 -4
- 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 +9 -3
- package/types/options.shape.d.ts +26 -0
- 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.2
|
|
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() || [];
|
|
@@ -4814,7 +4863,7 @@ var interaction = {
|
|
|
4814
4863
|
}
|
|
4815
4864
|
else {
|
|
4816
4865
|
if (isOver) {
|
|
4817
|
-
|
|
4866
|
+
$$.isPointFocusOnly() && hasRadar ?
|
|
4818
4867
|
$$.showCircleFocus($$.getAllValuesOnIndex(d, true)) :
|
|
4819
4868
|
$$.setExpand(d, null, true);
|
|
4820
4869
|
}
|
|
@@ -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
|
|
|
@@ -5220,7 +5277,9 @@ var color = {
|
|
|
5220
5277
|
return "url(#".concat(this.state.datetimeId, "-gradient").concat(this.getTargetSelectorSuffix(id), ")");
|
|
5221
5278
|
},
|
|
5222
5279
|
/**
|
|
5223
|
-
* Update linear gradient definition
|
|
5280
|
+
* Update linear/radial gradient definition
|
|
5281
|
+
* - linear: area & bar only
|
|
5282
|
+
* - radial: type which has data points only
|
|
5224
5283
|
* @private
|
|
5225
5284
|
*/
|
|
5226
5285
|
updateLinearGradient: function () {
|
|
@@ -5228,23 +5287,41 @@ var color = {
|
|
|
5228
5287
|
var config = $$.config, targets = $$.data.targets, datetimeId = $$.state.datetimeId, defs = $$.$el.defs;
|
|
5229
5288
|
targets.forEach(function (d) {
|
|
5230
5289
|
var id = "".concat(datetimeId, "-gradient").concat($$.getTargetSelectorSuffix(d.id));
|
|
5290
|
+
var radialGradient = $$.hasPointType() && config.point_radialGradient;
|
|
5231
5291
|
var supportedType = ($$.isAreaType(d) && "area") || ($$.isBarType(d) && "bar");
|
|
5232
|
-
|
|
5233
|
-
if (supportedType && defs.select("#".concat(id)).empty()) {
|
|
5292
|
+
if ((radialGradient || supportedType) && defs.select("#".concat(id)).empty()) {
|
|
5234
5293
|
var color_1 = $$.color(d);
|
|
5235
|
-
var
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
.
|
|
5241
|
-
.
|
|
5242
|
-
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
.attr("
|
|
5246
|
-
.attr("
|
|
5247
|
-
|
|
5294
|
+
var gradient_1 = {
|
|
5295
|
+
defs: null,
|
|
5296
|
+
stops: []
|
|
5297
|
+
};
|
|
5298
|
+
if (radialGradient) {
|
|
5299
|
+
var _a = radialGradient.cx, cx = _a === void 0 ? 0.3 : _a, _b = radialGradient.cy, cy = _b === void 0 ? 0.3 : _b, _c = radialGradient.r, r = _c === void 0 ? 0.7 : _c, _d = radialGradient.stops, stops = _d === void 0 ? [[0.1, color_1, 0], [0.9, color_1, 1]] : _d;
|
|
5300
|
+
gradient_1.stops = stops;
|
|
5301
|
+
gradient_1.defs = defs.append("radialGradient")
|
|
5302
|
+
.attr("id", "".concat(id))
|
|
5303
|
+
.attr("cx", cx)
|
|
5304
|
+
.attr("cy", cy)
|
|
5305
|
+
.attr("r", r);
|
|
5306
|
+
}
|
|
5307
|
+
else {
|
|
5308
|
+
var isRotated = config.axis_rotated;
|
|
5309
|
+
var _e = config["".concat(supportedType, "_linearGradient")], _f = _e.x, x = _f === void 0 ? isRotated ? [1, 0] : [0, 0] : _f, _g = _e.y, y = _g === void 0 ? isRotated ? [0, 0] : [0, 1] : _g, _h = _e.stops, stops = _h === void 0 ? [[0, color_1, 1], [1, color_1, 0]] : _h;
|
|
5310
|
+
gradient_1.stops = stops;
|
|
5311
|
+
gradient_1.defs = defs.append("linearGradient")
|
|
5312
|
+
.attr("id", "".concat(id))
|
|
5313
|
+
.attr("x1", x[0])
|
|
5314
|
+
.attr("x2", x[1])
|
|
5315
|
+
.attr("y1", y[0])
|
|
5316
|
+
.attr("y2", y[1]);
|
|
5317
|
+
}
|
|
5318
|
+
gradient_1.stops.forEach(function (v) {
|
|
5319
|
+
var offset = v[0], stopColor = v[1], stopOpacity = v[2];
|
|
5320
|
+
var colorValue = isFunction(stopColor) ? stopColor.bind($$.api)(d.id) : stopColor;
|
|
5321
|
+
gradient_1.defs && gradient_1.defs.append("stop")
|
|
5322
|
+
.attr("offset", offset)
|
|
5323
|
+
.attr("stop-color", colorValue || color_1)
|
|
5324
|
+
.attr("stop-opacity", stopOpacity);
|
|
5248
5325
|
});
|
|
5249
5326
|
}
|
|
5250
5327
|
});
|
|
@@ -5568,19 +5645,25 @@ var domain = {
|
|
|
5568
5645
|
return domain;
|
|
5569
5646
|
},
|
|
5570
5647
|
/**
|
|
5571
|
-
* Get zoom domain
|
|
5648
|
+
* Get subchart/zoom domain
|
|
5649
|
+
* @param {string} type "subX" or "zoom"
|
|
5650
|
+
* @param {boolean} getCurrent Get current domain if true
|
|
5572
5651
|
* @returns {Array} zoom domain
|
|
5573
5652
|
* @private
|
|
5574
5653
|
*/
|
|
5575
|
-
getZoomDomain: function () {
|
|
5654
|
+
getZoomDomain: function (type, getCurrent) {
|
|
5655
|
+
if (type === void 0) { type = "zoom"; }
|
|
5656
|
+
if (getCurrent === void 0) { getCurrent = false; }
|
|
5576
5657
|
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
|
-
|
|
5658
|
+
var config = $$.config, scale = $$.scale, org = $$.org;
|
|
5659
|
+
var _a = getCurrent && scale[type] ? scale[type].domain() : org.xDomain, min = _a[0], max = _a[1];
|
|
5660
|
+
if (type === "zoom") {
|
|
5661
|
+
if (isDefined(config.zoom_x_min)) {
|
|
5662
|
+
min = getMinMax$1("min", [min, config.zoom_x_min]);
|
|
5663
|
+
}
|
|
5664
|
+
if (isDefined(config.zoom_x_max)) {
|
|
5665
|
+
max = getMinMax$1("max", [max, config.zoom_x_max]);
|
|
5666
|
+
}
|
|
5584
5667
|
}
|
|
5585
5668
|
return [min, max];
|
|
5586
5669
|
},
|
|
@@ -5604,6 +5687,27 @@ var domain = {
|
|
|
5604
5687
|
length = isRotated ? "width" : "height";
|
|
5605
5688
|
}
|
|
5606
5689
|
return domainLength * (pixels / state[length]);
|
|
5690
|
+
},
|
|
5691
|
+
/**
|
|
5692
|
+
* Check if the given domain is within subchart/zoom range
|
|
5693
|
+
* @param {Array} domain Target domain value
|
|
5694
|
+
* @param {Array} current Current subchart/zoom domain value
|
|
5695
|
+
* @param {Array} range subchart/zoom range value
|
|
5696
|
+
* @returns {boolean}
|
|
5697
|
+
* @private
|
|
5698
|
+
*/
|
|
5699
|
+
withinRange: function (domain, current, range) {
|
|
5700
|
+
var $$ = this;
|
|
5701
|
+
var isInverted = $$.config.axis_x_inverted;
|
|
5702
|
+
var _a = range, min = _a[0], max = _a[1];
|
|
5703
|
+
if (Array.isArray(domain)) {
|
|
5704
|
+
var target = __spreadArray([], domain, true);
|
|
5705
|
+
isInverted && target.reverse();
|
|
5706
|
+
if (target[0] < target[1]) {
|
|
5707
|
+
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]; })); });
|
|
5708
|
+
}
|
|
5709
|
+
}
|
|
5710
|
+
return false;
|
|
5607
5711
|
}
|
|
5608
5712
|
};
|
|
5609
5713
|
|
|
@@ -6440,10 +6544,6 @@ var redraw = {
|
|
|
6440
6544
|
// no need to update axis in it because they will be updated in redraw()
|
|
6441
6545
|
$$.updateDimension(true);
|
|
6442
6546
|
}
|
|
6443
|
-
// update circleY based on updated parameters
|
|
6444
|
-
if (!treemap && (!$$.hasArcType() || state.hasRadar)) {
|
|
6445
|
-
$$.updateCircleY && ($$.circleY = $$.updateCircleY());
|
|
6446
|
-
}
|
|
6447
6547
|
// Data empty label positioning and text.
|
|
6448
6548
|
config.data_empty_label_text && main.select("text.".concat($TEXT.text, ".").concat($COMMON.empty))
|
|
6449
6549
|
.attr("x", state.width / 2)
|
|
@@ -6579,7 +6679,7 @@ var redraw = {
|
|
|
6579
6679
|
notEmpty(config.data_labels) && config.data_labels !== false &&
|
|
6580
6680
|
list.push($$.redrawText(xForText, yForText, flow, withTransition));
|
|
6581
6681
|
}
|
|
6582
|
-
if (($$.hasPointType() || hasRadar) &&
|
|
6682
|
+
if (($$.hasPointType() || hasRadar) && !$$.isPointFocusOnly()) {
|
|
6583
6683
|
$$.redrawCircle && list.push($$.redrawCircle(cx, cy, withTransition, flowFn));
|
|
6584
6684
|
}
|
|
6585
6685
|
if (hasTreemap) {
|
|
@@ -6828,6 +6928,24 @@ var scale = {
|
|
|
6828
6928
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
6829
6929
|
* billboard.js project is licensed under the MIT license
|
|
6830
6930
|
*/
|
|
6931
|
+
/**
|
|
6932
|
+
* Get grouped data point function for y coordinate
|
|
6933
|
+
* - Note: Grouped(stacking) works only for line and bar types
|
|
6934
|
+
* @param {object} d data vlaue
|
|
6935
|
+
* @returns {Function|undefined}
|
|
6936
|
+
* @private
|
|
6937
|
+
*/
|
|
6938
|
+
function getGroupedDataPointsFn(d) {
|
|
6939
|
+
var $$ = this;
|
|
6940
|
+
var fn;
|
|
6941
|
+
if ($$.isLineType(d)) {
|
|
6942
|
+
fn = $$.generateGetLinePoints($$.getShapeIndices($$.isLineType));
|
|
6943
|
+
}
|
|
6944
|
+
else if ($$.isBarType(d)) {
|
|
6945
|
+
fn = $$.generateGetBarPoints($$.getShapeIndices($$.isBarType));
|
|
6946
|
+
}
|
|
6947
|
+
return fn;
|
|
6948
|
+
}
|
|
6831
6949
|
var shape = {
|
|
6832
6950
|
/**
|
|
6833
6951
|
* Get the shape draw function
|
|
@@ -6866,7 +6984,7 @@ var shape = {
|
|
|
6866
6984
|
return shape;
|
|
6867
6985
|
},
|
|
6868
6986
|
/**
|
|
6869
|
-
* Get shape's indices according it's position
|
|
6987
|
+
* Get shape's indices according it's position within each axis tick.
|
|
6870
6988
|
*
|
|
6871
6989
|
* From the below example, indices will be:
|
|
6872
6990
|
* ==> {data1: 0, data2: 0, data3: 1, data4: 1, __max__: 1}
|
|
@@ -6894,17 +7012,22 @@ var shape = {
|
|
|
6894
7012
|
}
|
|
6895
7013
|
$$.filterTargetsToShow($$.data.targets.filter(typeFilter, $$))
|
|
6896
7014
|
.forEach(function (d) {
|
|
7015
|
+
var _a;
|
|
6897
7016
|
var xKey = d.id in xs ? xs[d.id] : "";
|
|
6898
7017
|
var ind = xKey ? indices[xKey] : indices;
|
|
6899
7018
|
for (var j = 0, groups = void 0; (groups = config.data_groups[j]); j++) {
|
|
6900
7019
|
if (groups.indexOf(d.id) < 0) {
|
|
6901
7020
|
continue;
|
|
6902
7021
|
}
|
|
6903
|
-
for (var k = 0,
|
|
6904
|
-
if (
|
|
6905
|
-
ind[d.id] = ind[
|
|
7022
|
+
for (var k = 0, key = void 0; (key = groups[k]); k++) {
|
|
7023
|
+
if (key in ind) {
|
|
7024
|
+
ind[d.id] = ind[key];
|
|
6906
7025
|
break;
|
|
6907
7026
|
}
|
|
7027
|
+
// for same grouped data, add other data to same indices
|
|
7028
|
+
if (d.id !== key && xKey) {
|
|
7029
|
+
ind[key] = (_a = ind[d.id]) !== null && _a !== void 0 ? _a : i[xKey];
|
|
7030
|
+
}
|
|
6908
7031
|
}
|
|
6909
7032
|
}
|
|
6910
7033
|
if (isUndefined(ind[d.id])) {
|
|
@@ -7104,6 +7227,24 @@ var shape = {
|
|
|
7104
7227
|
return offset;
|
|
7105
7228
|
};
|
|
7106
7229
|
},
|
|
7230
|
+
/**
|
|
7231
|
+
* Get data's y coordinate
|
|
7232
|
+
* @param {object} d Target data
|
|
7233
|
+
* @param {number} i Index number
|
|
7234
|
+
* @returns {number} y coordinate
|
|
7235
|
+
* @private
|
|
7236
|
+
*/
|
|
7237
|
+
circleY: function (d, i) {
|
|
7238
|
+
var $$ = this;
|
|
7239
|
+
var id = d.id;
|
|
7240
|
+
var points;
|
|
7241
|
+
if ($$.isGrouped(id)) {
|
|
7242
|
+
points = getGroupedDataPointsFn.bind($$)(d);
|
|
7243
|
+
}
|
|
7244
|
+
return points ?
|
|
7245
|
+
points(d, i)[0][1] :
|
|
7246
|
+
$$.getYScaleById(id)($$.getBaseValue(d));
|
|
7247
|
+
},
|
|
7107
7248
|
getBarW: function (type, axis, targetsNum) {
|
|
7108
7249
|
var $$ = this;
|
|
7109
7250
|
var config = $$.config, org = $$.org, scale = $$.scale;
|
|
@@ -7685,7 +7826,7 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
|
|
|
7685
7826
|
* @returns {number} Position value
|
|
7686
7827
|
* @private
|
|
7687
7828
|
*/
|
|
7688
|
-
function getTextPos
|
|
7829
|
+
function getTextPos(d, type) {
|
|
7689
7830
|
var _a;
|
|
7690
7831
|
var position = this.config.data_labels_position;
|
|
7691
7832
|
var id = d.id, index = d.index, value = d.value;
|
|
@@ -7848,7 +7989,6 @@ var text = {
|
|
|
7848
7989
|
var angle = config.data_labels.rotate;
|
|
7849
7990
|
var anchorString = getRotateAnchor(angle);
|
|
7850
7991
|
var rotateString = angle ? "rotate(".concat(angle, ")") : "";
|
|
7851
|
-
// $$.meetsLabelThreshold(ratio,
|
|
7852
7992
|
$$.$el.text
|
|
7853
7993
|
.style("fill", $$.getStylePropValue($$.updateTextColor))
|
|
7854
7994
|
.attr("filter", $$.updateTextBacgroundColor.bind($$))
|
|
@@ -7985,7 +8125,7 @@ var text = {
|
|
|
7985
8125
|
getXForText: function (points, d, textElement) {
|
|
7986
8126
|
var _a;
|
|
7987
8127
|
var $$ = this;
|
|
7988
|
-
var config = $$.config
|
|
8128
|
+
var config = $$.config;
|
|
7989
8129
|
var isRotated = config.axis_rotated;
|
|
7990
8130
|
var isTreemapType = $$.isTreemapType(d);
|
|
7991
8131
|
var xPos = points[0][0];
|
|
@@ -8018,20 +8158,10 @@ var text = {
|
|
|
8018
8158
|
xPos = $$.hasType("bar") ? (points[2][0] + points[0][0]) / 2 : xPos;
|
|
8019
8159
|
}
|
|
8020
8160
|
}
|
|
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
8161
|
if (isRotated || isTreemapType) {
|
|
8032
8162
|
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
|
8033
8163
|
}
|
|
8034
|
-
return xPos + getTextPos
|
|
8164
|
+
return xPos + getTextPos.call(this, d, "x");
|
|
8035
8165
|
},
|
|
8036
8166
|
/**
|
|
8037
8167
|
* Gets the y coordinate of the text
|
|
@@ -8098,20 +8228,10 @@ var text = {
|
|
|
8098
8228
|
}
|
|
8099
8229
|
}
|
|
8100
8230
|
}
|
|
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
8231
|
if (!isRotated || isTreemapType) {
|
|
8112
8232
|
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
|
8113
8233
|
}
|
|
8114
|
-
return yPos + getTextPos
|
|
8234
|
+
return yPos + getTextPos.call(this, d, "y");
|
|
8115
8235
|
},
|
|
8116
8236
|
/**
|
|
8117
8237
|
* Calculate if two or more text nodes are overlapping
|
|
@@ -8181,7 +8301,7 @@ var text = {
|
|
|
8181
8301
|
* @returns {string|number} text-anchor value or position in pixel
|
|
8182
8302
|
* @private
|
|
8183
8303
|
*/
|
|
8184
|
-
function
|
|
8304
|
+
function getTextXPos(pos, width) {
|
|
8185
8305
|
if (pos === void 0) { pos = "left"; }
|
|
8186
8306
|
var isNum = isNumber(width);
|
|
8187
8307
|
var position;
|
|
@@ -8208,7 +8328,7 @@ var title = {
|
|
|
8208
8328
|
$el.title = $el.svg.append("g");
|
|
8209
8329
|
var text = $el.title
|
|
8210
8330
|
.append("text")
|
|
8211
|
-
.style("text-anchor",
|
|
8331
|
+
.style("text-anchor", getTextXPos(config.title_position))
|
|
8212
8332
|
.attr("class", $TEXT.title);
|
|
8213
8333
|
setTextValue(text, config.title_text, [0.3, 1.5]);
|
|
8214
8334
|
}
|
|
@@ -8221,50 +8341,12 @@ var title = {
|
|
|
8221
8341
|
var $$ = this;
|
|
8222
8342
|
var config = $$.config, current = $$.state.current, title = $$.$el.title;
|
|
8223
8343
|
if (title) {
|
|
8224
|
-
var
|
|
8225
|
-
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
else {
|
|
8229
|
-
title.attr("x", $$.xForTitle.call($$)).attr("y", y);
|
|
8230
|
-
}
|
|
8344
|
+
var x = getTextXPos(config.title_position, current.width);
|
|
8345
|
+
var y = (config.title_padding.top || 0) +
|
|
8346
|
+
$$.getTextRect($$.$el.title, $TEXT.title).height;
|
|
8347
|
+
title.attr("transform", "translate(".concat(x, ", ").concat(y, ")"));
|
|
8231
8348
|
}
|
|
8232
8349
|
},
|
|
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);
|
|
8255
|
-
}
|
|
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
|
-
},
|
|
8268
8350
|
/**
|
|
8269
8351
|
* Get title padding
|
|
8270
8352
|
* @returns {number} padding value
|
|
@@ -8272,7 +8354,10 @@ var title = {
|
|
|
8272
8354
|
*/
|
|
8273
8355
|
getTitlePadding: function () {
|
|
8274
8356
|
var $$ = this;
|
|
8275
|
-
|
|
8357
|
+
var $el = $$.$el, config = $$.config;
|
|
8358
|
+
return (config.title_padding.top || 0) +
|
|
8359
|
+
$$.getTextRect($el.title, $TEXT.title).height +
|
|
8360
|
+
(config.title_padding.bottom || 0);
|
|
8276
8361
|
},
|
|
8277
8362
|
};
|
|
8278
8363
|
|
|
@@ -8295,36 +8380,32 @@ var tooltip$1 = {
|
|
|
8295
8380
|
}
|
|
8296
8381
|
$$.bindTooltipResizePos();
|
|
8297
8382
|
},
|
|
8383
|
+
/**
|
|
8384
|
+
* Show tooltip at initialization.
|
|
8385
|
+
* Is called only when tooltip.init.show=true option is set
|
|
8386
|
+
* @private
|
|
8387
|
+
*/
|
|
8298
8388
|
initShowTooltip: function () {
|
|
8299
|
-
var _a
|
|
8389
|
+
var _a;
|
|
8390
|
+
var _b;
|
|
8300
8391
|
var $$ = this;
|
|
8301
8392
|
var config = $$.config, $el = $$.$el, _c = $$.state, hasAxis = _c.hasAxis, hasRadar = _c.hasRadar;
|
|
8302
8393
|
// Show tooltip if needed
|
|
8303
8394
|
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;
|
|
8395
|
+
var isArc = !(hasAxis || hasRadar);
|
|
8396
|
+
if (((_b = $$.axis) === null || _b === void 0 ? void 0 : _b.isTimeSeries()) && isString(config.tooltip_init_x)) {
|
|
8309
8397
|
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
8398
|
}
|
|
8317
|
-
|
|
8318
|
-
|
|
8319
|
-
|
|
8399
|
+
$$.api.tooltip.show({
|
|
8400
|
+
data: (_a = {},
|
|
8401
|
+
_a[isArc ? "index" : "x"] = config.tooltip_init_x,
|
|
8402
|
+
_a)
|
|
8320
8403
|
});
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
$el.tooltip.style("top", config.tooltip_init_position.top)
|
|
8327
|
-
.style("left", config.tooltip_init_position.left)
|
|
8404
|
+
var position = config.tooltip_init_position;
|
|
8405
|
+
if (!config.tooltip_contents.bindto && !isEmpty(position)) {
|
|
8406
|
+
var _d = position.top, top_1 = _d === void 0 ? 0 : _d, _e = position.left, left = _e === void 0 ? 50 : _e;
|
|
8407
|
+
$el.tooltip.style("top", isString(top_1) ? top_1 : "".concat(top_1, "px"))
|
|
8408
|
+
.style("left", isString(left) ? left : "".concat(left, "px"))
|
|
8328
8409
|
.style("display", null);
|
|
8329
8410
|
}
|
|
8330
8411
|
}
|
|
@@ -8356,13 +8437,34 @@ var tooltip$1 = {
|
|
|
8356
8437
|
getTooltipContent: function (d, defaultTitleFormat, defaultValueFormat, color) {
|
|
8357
8438
|
var $$ = this;
|
|
8358
8439
|
var api = $$.api, config = $$.config, state = $$.state, $el = $$.$el;
|
|
8440
|
+
// get formatter function
|
|
8359
8441
|
var _a = ["title", "name", "value"].map(function (v) {
|
|
8360
8442
|
var fn = config["tooltip_format_".concat(v)];
|
|
8361
8443
|
return isFunction(fn) ? fn.bind(api) : fn;
|
|
8362
|
-
}),
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8444
|
+
}), titleFn = _a[0], nameFn = _a[1], valueFn = _a[2];
|
|
8445
|
+
// determine fotmatter function with sanitization
|
|
8446
|
+
var titleFormat = function () {
|
|
8447
|
+
var arg = [];
|
|
8448
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8449
|
+
arg[_i] = arguments[_i];
|
|
8450
|
+
}
|
|
8451
|
+
return sanitize((titleFn || defaultTitleFormat).apply(void 0, arg));
|
|
8452
|
+
};
|
|
8453
|
+
var nameFormat = function () {
|
|
8454
|
+
var arg = [];
|
|
8455
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8456
|
+
arg[_i] = arguments[_i];
|
|
8457
|
+
}
|
|
8458
|
+
return sanitize((nameFn || (function (name) { return name; })).apply(void 0, arg));
|
|
8459
|
+
};
|
|
8460
|
+
var valueFormat = function () {
|
|
8461
|
+
var arg = [];
|
|
8462
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
8463
|
+
arg[_i] = arguments[_i];
|
|
8464
|
+
}
|
|
8465
|
+
var fn = valueFn || (state.hasTreemap || $$.isStackNormalized() ? function (v, ratio) { return "".concat((ratio * 100).toFixed(2), "%"); } : defaultValueFormat);
|
|
8466
|
+
return sanitize(fn.apply(void 0, arg));
|
|
8467
|
+
};
|
|
8366
8468
|
var order = config.tooltip_order;
|
|
8367
8469
|
var getRowValue = function (row) { return ($$.axis && $$.isBubbleZType(row) ? $$.getBubbleZData(row.value, "z") : $$.getBaseValue(row)); };
|
|
8368
8470
|
var getBgColor = $$.levelColor ? function (row) { return $$.levelColor(row.value); } : function (row) { return color(row); };
|
|
@@ -8408,8 +8510,7 @@ var tooltip$1 = {
|
|
|
8408
8510
|
return "continue";
|
|
8409
8511
|
}
|
|
8410
8512
|
if (isUndefined(text)) {
|
|
8411
|
-
var title = (state.hasAxis || state.hasRadar) &&
|
|
8412
|
-
sanitise(titleFormat ? titleFormat(row.x) : row.x);
|
|
8513
|
+
var title = (state.hasAxis || state.hasRadar) && titleFormat(row.x);
|
|
8413
8514
|
text = tplProcess(tpl[0], {
|
|
8414
8515
|
CLASS_TOOLTIP: $TOOLTIP.tooltip,
|
|
8415
8516
|
TITLE: isValue(title) ? (tplStr ? title : "<tr><th colspan=\"2\">".concat(title, "</th></tr>")) : ""
|
|
@@ -8419,26 +8520,33 @@ var tooltip$1 = {
|
|
|
8419
8520
|
param = ["arc", $$.$el.arcs.select("path.".concat($ARC.arc, "-").concat(row.id)).data()[0]];
|
|
8420
8521
|
row.ratio = $$.getRatio.apply($$, param);
|
|
8421
8522
|
}
|
|
8422
|
-
param
|
|
8423
|
-
|
|
8523
|
+
// arrange param to be passed to formatter
|
|
8524
|
+
param = [row.ratio, row.id, row.index];
|
|
8424
8525
|
if ($$.isAreaRangeType(row)) {
|
|
8425
|
-
var _b = ["high", "low"].map(function (v) { return
|
|
8426
|
-
|
|
8526
|
+
var _b = ["high", "low"].map(function (v) { return valueFormat.apply(void 0, __spreadArray([$$.getRangedData(row, v)], param, false)); }), high = _b[0], low = _b[1];
|
|
8527
|
+
var mid = valueFormat.apply(void 0, __spreadArray([getRowValue(row)], param, false));
|
|
8528
|
+
value = "<b>Mid:</b> ".concat(mid, " <b>High:</b> ").concat(high, " <b>Low:</b> ").concat(low);
|
|
8427
8529
|
}
|
|
8428
8530
|
else if ($$.isCandlestickType(row)) {
|
|
8429
|
-
var _c = ["open", "high", "low", "close", "volume"].map(function (v) {
|
|
8531
|
+
var _c = ["open", "high", "low", "close", "volume"].map(function (v) {
|
|
8532
|
+
var value = $$.getRangedData(row, v, "candlestick");
|
|
8533
|
+
return value ? valueFormat.apply(void 0, __spreadArray([$$.getRangedData(row, v, "candlestick")], param, false)) : undefined;
|
|
8534
|
+
}), open_1 = _c[0], high = _c[1], low = _c[2], close_1 = _c[3], volume = _c[4];
|
|
8430
8535
|
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
8536
|
}
|
|
8432
8537
|
else if ($$.isBarRangeType(row)) {
|
|
8433
|
-
var _d = row.value, start = _d[0], end = _d[1];
|
|
8434
|
-
value = "".concat(valueFormat(start), " ~ ").concat(valueFormat(end));
|
|
8538
|
+
var _d = row.value, start = _d[0], end = _d[1], id = row.id, index = row.index;
|
|
8539
|
+
value = "".concat(valueFormat(start, undefined, id, index), " ~ ").concat(valueFormat(end, undefined, id, index));
|
|
8540
|
+
}
|
|
8541
|
+
else {
|
|
8542
|
+
value = valueFormat.apply(void 0, __spreadArray([getRowValue(row)], param, false));
|
|
8435
8543
|
}
|
|
8436
8544
|
if (value !== undefined) {
|
|
8437
8545
|
// Skip elements when their name is set to null
|
|
8438
8546
|
if (row.name === null) {
|
|
8439
8547
|
return "continue";
|
|
8440
8548
|
}
|
|
8441
|
-
var name_1 =
|
|
8549
|
+
var name_1 = nameFormat.apply(void 0, __spreadArray([row.name], param, false));
|
|
8442
8550
|
var color_1 = getBgColor(row);
|
|
8443
8551
|
var contentValue_1 = {
|
|
8444
8552
|
CLASS_TOOLTIP_NAME: $TOOLTIP.tooltipName + $$.getTargetSelectorSuffix(row.id),
|
|
@@ -8478,20 +8586,20 @@ var tooltip$1 = {
|
|
|
8478
8586
|
* @private
|
|
8479
8587
|
*/
|
|
8480
8588
|
setTooltipPosition: function (dataToShow, eventTarget) {
|
|
8481
|
-
var _a, _b
|
|
8589
|
+
var _a, _b;
|
|
8482
8590
|
var $$ = this;
|
|
8483
|
-
var config = $$.config, scale = $$.scale, state = $$.state,
|
|
8591
|
+
var config = $$.config, scale = $$.scale, state = $$.state, _c = $$.$el, eventRect = _c.eventRect, tooltip = _c.tooltip;
|
|
8484
8592
|
var bindto = config.tooltip_contents.bindto;
|
|
8485
|
-
var datum =
|
|
8593
|
+
var datum = tooltip === null || tooltip === void 0 ? void 0 : tooltip.datum();
|
|
8486
8594
|
if (!bindto && datum) {
|
|
8487
|
-
var
|
|
8595
|
+
var _d = getPointer(state.event, eventTarget !== null && eventTarget !== void 0 ? eventTarget : eventRect === null || eventRect === void 0 ? void 0 : eventRect.node()), x = _d[0], y = _d[1]; // get mouse event position
|
|
8488
8596
|
var currPos = { x: x, y: y };
|
|
8489
8597
|
if (scale.x && datum && "x" in datum) {
|
|
8490
8598
|
currPos.xAxis = scale.x(datum.x);
|
|
8491
8599
|
}
|
|
8492
|
-
var
|
|
8600
|
+
var _e = datum.width, width = _e === void 0 ? 0 : _e, _f = datum.height, height = _f === void 0 ? 0 : _f;
|
|
8493
8601
|
// Get tooltip position
|
|
8494
|
-
var pos_1 = (
|
|
8602
|
+
var pos_1 = (_b = (_a = config.tooltip_position) === null || _a === void 0 ? void 0 : _a.bind($$.api)(dataToShow !== null && dataToShow !== void 0 ? dataToShow : JSON.parse(datum.current), width, height, eventRect === null || eventRect === void 0 ? void 0 : eventRect.node(), currPos)) !== null && _b !== void 0 ? _b : $$.getTooltipPosition.bind($$)(width, height, currPos);
|
|
8495
8603
|
["top", "left"].forEach(function (v) {
|
|
8496
8604
|
var value = pos_1[v];
|
|
8497
8605
|
tooltip.style(v, "".concat(value, "px"));
|
|
@@ -8565,17 +8673,16 @@ var tooltip$1 = {
|
|
|
8565
8673
|
* @private
|
|
8566
8674
|
*/
|
|
8567
8675
|
showTooltip: function (selectedData, eventTarget) {
|
|
8568
|
-
var _a;
|
|
8569
8676
|
var $$ = this;
|
|
8570
8677
|
var config = $$.config, tooltip = $$.$el.tooltip;
|
|
8571
8678
|
var dataToShow = selectedData.filter(function (d) { return d && isValue($$.getBaseValue(d)); });
|
|
8572
8679
|
if (!tooltip || dataToShow.length === 0 || !config.tooltip_show) {
|
|
8573
8680
|
return;
|
|
8574
8681
|
}
|
|
8575
|
-
var datum =
|
|
8682
|
+
var datum = tooltip.datum();
|
|
8576
8683
|
var dataStr = JSON.stringify(selectedData);
|
|
8577
8684
|
if (!datum || datum.current !== dataStr) {
|
|
8578
|
-
var
|
|
8685
|
+
var _a = selectedData.concat().sort()[0], index = _a.index, x = _a.x;
|
|
8579
8686
|
callFn(config.tooltip_onshow, $$.api, selectedData);
|
|
8580
8687
|
// set tooltip content
|
|
8581
8688
|
tooltip
|
|
@@ -8625,11 +8732,11 @@ var tooltip$1 = {
|
|
|
8625
8732
|
* @private
|
|
8626
8733
|
*/
|
|
8627
8734
|
hideTooltip: function (force) {
|
|
8628
|
-
var _a
|
|
8735
|
+
var _a;
|
|
8629
8736
|
var $$ = this;
|
|
8630
8737
|
var api = $$.api, config = $$.config, tooltip = $$.$el.tooltip;
|
|
8631
8738
|
if (tooltip && tooltip.style("display") !== "none" && (!config.tooltip_doNotHide || force)) {
|
|
8632
|
-
var selectedData = JSON.parse((
|
|
8739
|
+
var selectedData = JSON.parse((_a = tooltip.datum().current) !== null && _a !== void 0 ? _a : {});
|
|
8633
8740
|
callFn(config.tooltip_onhide, api, selectedData);
|
|
8634
8741
|
// hide tooltip
|
|
8635
8742
|
tooltip
|
|
@@ -10140,8 +10247,7 @@ function nodeToSvgDataUrl(node, option, orgSize) {
|
|
|
10140
10247
|
var styleXml = serializer.serializeToString(style);
|
|
10141
10248
|
// foreignObject not supported in IE11 and below
|
|
10142
10249
|
// https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
|
|
10143
|
-
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>")
|
|
10144
|
-
.replace("/\n/g", "%0A");
|
|
10250
|
+
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>");
|
|
10145
10251
|
return "data:image/svg+xml;base64,".concat(b64EncodeUnicode(dataStr));
|
|
10146
10252
|
}
|
|
10147
10253
|
/**
|
|
@@ -11184,6 +11290,7 @@ function getMinMax($$, type) {
|
|
|
11184
11290
|
var axis$1 = {
|
|
11185
11291
|
/**
|
|
11186
11292
|
* Get and set axis labels.
|
|
11293
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11187
11294
|
* @function axis․labels
|
|
11188
11295
|
* @instance
|
|
11189
11296
|
* @memberof Chart
|
|
@@ -11227,6 +11334,7 @@ var axis$1 = {
|
|
|
11227
11334
|
},
|
|
11228
11335
|
/**
|
|
11229
11336
|
* Get and set axis min value.
|
|
11337
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11230
11338
|
* @function axis․min
|
|
11231
11339
|
* @instance
|
|
11232
11340
|
* @memberof Chart
|
|
@@ -11262,6 +11370,7 @@ var axis$1 = {
|
|
|
11262
11370
|
},
|
|
11263
11371
|
/**
|
|
11264
11372
|
* Get and set axis max value.
|
|
11373
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11265
11374
|
* @function axis․max
|
|
11266
11375
|
* @instance
|
|
11267
11376
|
* @memberof Chart
|
|
@@ -11297,6 +11406,7 @@ var axis$1 = {
|
|
|
11297
11406
|
},
|
|
11298
11407
|
/**
|
|
11299
11408
|
* Get and set axis min and max value.
|
|
11409
|
+
* - **NOTE:** Only applicable for chart types which has x and y axes.
|
|
11300
11410
|
* @function axis․range
|
|
11301
11411
|
* @instance
|
|
11302
11412
|
* @memberof Chart
|
|
@@ -11381,7 +11491,7 @@ var apiCategory = {
|
|
|
11381
11491
|
return config.axis_x_categories[i];
|
|
11382
11492
|
},
|
|
11383
11493
|
/**
|
|
11384
|
-
* Set category names on category axis.
|
|
11494
|
+
* Set or get category names on category axis.
|
|
11385
11495
|
* @function categories
|
|
11386
11496
|
* @instance
|
|
11387
11497
|
* @memberof Chart
|
|
@@ -11395,8 +11505,9 @@ var apiCategory = {
|
|
|
11395
11505
|
categories: function (categories) {
|
|
11396
11506
|
var $$ = this.internal;
|
|
11397
11507
|
var config = $$.config;
|
|
11398
|
-
if (!
|
|
11399
|
-
|
|
11508
|
+
if (!categories || !Array.isArray(categories)) {
|
|
11509
|
+
var cat = config.axis_x_categories;
|
|
11510
|
+
return isEmpty(cat) ? Object.values($$.data.xs)[0] : cat;
|
|
11400
11511
|
}
|
|
11401
11512
|
config.axis_x_categories = categories;
|
|
11402
11513
|
$$.redraw();
|
|
@@ -12103,14 +12214,6 @@ var AxisRendererHelper = /** @class */ (function () {
|
|
|
12103
12214
|
return r;
|
|
12104
12215
|
});
|
|
12105
12216
|
}
|
|
12106
|
-
else {
|
|
12107
|
-
for (var i = Math.ceil(start); i < end; i++) {
|
|
12108
|
-
ticks.push(i);
|
|
12109
|
-
}
|
|
12110
|
-
if (ticks.length > 0 && ticks[0] > 0) {
|
|
12111
|
-
ticks.unshift(ticks[0] - (ticks[1] - ticks[0]));
|
|
12112
|
-
}
|
|
12113
|
-
}
|
|
12114
12217
|
return ticks;
|
|
12115
12218
|
};
|
|
12116
12219
|
AxisRendererHelper.prototype.copyScale = function () {
|
|
@@ -13731,14 +13834,14 @@ var eventrect = {
|
|
|
13731
13834
|
*/
|
|
13732
13835
|
unselectRect: function () {
|
|
13733
13836
|
var $$ = this;
|
|
13734
|
-
var
|
|
13837
|
+
var _a = $$.$el, circle = _a.circle, tooltip = _a.tooltip;
|
|
13735
13838
|
$$.$el.svg.select(".".concat($EVENT.eventRect)).style("cursor", null);
|
|
13736
13839
|
$$.hideGridFocus();
|
|
13737
13840
|
if (tooltip) {
|
|
13738
13841
|
$$.hideTooltip();
|
|
13739
13842
|
$$._handleLinkedCharts(false);
|
|
13740
13843
|
}
|
|
13741
|
-
circle &&
|
|
13844
|
+
circle && !$$.isPointFocusOnly() && $$.unexpandCircles();
|
|
13742
13845
|
$$.expandBarTypeShapes(false);
|
|
13743
13846
|
},
|
|
13744
13847
|
/**
|
|
@@ -13794,7 +13897,7 @@ var eventrect = {
|
|
|
13794
13897
|
var eventOnSameIdx = config.tooltip_grouped && index === eventReceiver.currentIdx;
|
|
13795
13898
|
// do nothing while dragging/flowing
|
|
13796
13899
|
if (state.dragging || state.flowing || $$.hasArcType() || eventOnSameIdx) {
|
|
13797
|
-
eventOnSameIdx && $$.setTooltipPosition();
|
|
13900
|
+
config.tooltip_show && eventOnSameIdx && $$.setTooltipPosition();
|
|
13798
13901
|
return;
|
|
13799
13902
|
}
|
|
13800
13903
|
if (index !== eventReceiver.currentIdx) {
|
|
@@ -14013,10 +14116,6 @@ var flow = {
|
|
|
14013
14116
|
else if (v === "gridLines.x") {
|
|
14014
14117
|
n.attr("x1", isRotated ? 0 : xv)
|
|
14015
14118
|
.attr("x2", isRotated ? state.width : xv);
|
|
14016
|
-
}
|
|
14017
|
-
else if (v === "gridLines.x") {
|
|
14018
|
-
n.select("line").attr("x1", isRotated ? 0 : xv)
|
|
14019
|
-
.attr("x2", isRotated ? state.width : xv);
|
|
14020
14119
|
n.select("text")
|
|
14021
14120
|
.attr("x", isRotated ? state.width : 0)
|
|
14022
14121
|
.attr("y", xv);
|
|
@@ -14036,10 +14135,7 @@ var flow = {
|
|
|
14036
14135
|
else {
|
|
14037
14136
|
var xFunc = function (d) { return cx(d) - config.point_r; };
|
|
14038
14137
|
var yFunc = function (d) { return cy(d) - config.point_r; };
|
|
14039
|
-
n.attr("x", xFunc)
|
|
14040
|
-
.attr("y", yFunc)
|
|
14041
|
-
.attr("cx", cx) // when pattern is used, it possibly contain 'circle' also.
|
|
14042
|
-
.attr("cy", cy);
|
|
14138
|
+
n.attr("x", xFunc).attr("y", yFunc);
|
|
14043
14139
|
}
|
|
14044
14140
|
}
|
|
14045
14141
|
else if (v === "region.list") {
|
|
@@ -14148,14 +14244,13 @@ var clip = {
|
|
|
14148
14244
|
var config = $$.config, _a = $$.state, margin = _a.margin, width = _a.width, height = _a.height;
|
|
14149
14245
|
var isRotated = config.axis_rotated;
|
|
14150
14246
|
var left = Math.max(30, margin.left) - (isRotated ? 0 : 20);
|
|
14151
|
-
var x = isRotated ? -(1 + left) : -(left - 1);
|
|
14152
|
-
var y = -Math.max(15, margin.top);
|
|
14153
|
-
var w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
14154
14247
|
// less than 20 is not enough to show the axis label 'outer' without legend
|
|
14155
14248
|
var h = (isRotated ? (margin.top + height) + 10 : margin.bottom) + 20;
|
|
14249
|
+
var x = isRotated ? -(1 + left) : -(left - 1);
|
|
14250
|
+
var w = isRotated ? margin.left + 20 : width + 10 + left;
|
|
14156
14251
|
node
|
|
14157
14252
|
.attr("x", x)
|
|
14158
|
-
.attr("y",
|
|
14253
|
+
.attr("y", -2)
|
|
14159
14254
|
.attr("width", w)
|
|
14160
14255
|
.attr("height", h);
|
|
14161
14256
|
},
|
|
@@ -14353,105 +14448,84 @@ var grid = {
|
|
|
14353
14448
|
// hide if arc type
|
|
14354
14449
|
grid.main.style("visibility", $$.hasArcType() ? "hidden" : null);
|
|
14355
14450
|
$$.hideGridFocus();
|
|
14356
|
-
$$.
|
|
14357
|
-
$$.
|
|
14451
|
+
$$.updateGridLines("x");
|
|
14452
|
+
$$.updateGridLines("y");
|
|
14358
14453
|
},
|
|
14359
14454
|
/**
|
|
14360
|
-
* Update
|
|
14455
|
+
* Update Grid lines
|
|
14456
|
+
* @param {string} type x | y
|
|
14361
14457
|
* @private
|
|
14362
14458
|
*/
|
|
14363
|
-
|
|
14459
|
+
updateGridLines: function (type) {
|
|
14364
14460
|
var $$ = this;
|
|
14365
14461
|
var config = $$.config, _a = $$.$el, gridLines = _a.gridLines, main = _a.main, $T = $$.$T;
|
|
14366
14462
|
var isRotated = config.axis_rotated;
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
.
|
|
14463
|
+
var isX = type === "x";
|
|
14464
|
+
config["grid_".concat(type, "_show")] && $$["update".concat(type.toUpperCase(), "Grid")]();
|
|
14465
|
+
var lines = main.select(".".concat($GRID["".concat(type, "gridLines")]))
|
|
14466
|
+
.selectAll(".".concat($GRID["".concat(type, "gridLine")]))
|
|
14467
|
+
.data(config["grid_".concat(type, "_lines")]);
|
|
14371
14468
|
// exit
|
|
14372
|
-
$T(
|
|
14469
|
+
$T(lines.exit())
|
|
14373
14470
|
.style("opacity", "0")
|
|
14374
14471
|
.remove();
|
|
14375
14472
|
// enter
|
|
14376
|
-
var
|
|
14377
|
-
|
|
14378
|
-
.style("opacity", "0");
|
|
14379
|
-
xgridLine.append("text")
|
|
14380
|
-
.attr("transform", isRotated ? null : "rotate(-90)")
|
|
14381
|
-
.attr("dy", -5)
|
|
14473
|
+
var gridLine = lines.enter().append("g");
|
|
14474
|
+
gridLine.append("line")
|
|
14382
14475
|
.style("opacity", "0");
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14476
|
+
lines = gridLine.merge(lines);
|
|
14477
|
+
lines.each(function (d) {
|
|
14478
|
+
var g = select(this);
|
|
14479
|
+
if (g.select("text").empty() && d.text) {
|
|
14480
|
+
g.append("text")
|
|
14481
|
+
.style("opacity", "0");
|
|
14482
|
+
}
|
|
14483
|
+
});
|
|
14484
|
+
$T(lines
|
|
14485
|
+
.attr("class", function (d) { return "".concat($GRID["".concat(type, "gridLine")], " ").concat(d.class || "").trim(); })
|
|
14386
14486
|
.select("text")
|
|
14387
14487
|
.attr("text-anchor", getGridTextAnchor)
|
|
14388
|
-
.attr("
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
var $$ = this;
|
|
14399
|
-
var config = $$.config, _a = $$.state, width = _a.width, height = _a.height, $el = $$.$el, $T = $$.$T;
|
|
14400
|
-
var isRotated = config.axis_rotated;
|
|
14401
|
-
config.grid_y_show && $$.updateYGrid();
|
|
14402
|
-
var ygridLines = $el.main.select(".".concat($GRID.ygridLines))
|
|
14403
|
-
.selectAll(".".concat($GRID.ygridLine))
|
|
14404
|
-
.data(config.grid_y_lines);
|
|
14405
|
-
// exit
|
|
14406
|
-
$T(ygridLines.exit())
|
|
14407
|
-
.style("opacity", "0")
|
|
14408
|
-
.remove();
|
|
14409
|
-
// enter
|
|
14410
|
-
var ygridLine = ygridLines.enter().append("g");
|
|
14411
|
-
ygridLine.append("line")
|
|
14412
|
-
.style("opacity", "0");
|
|
14413
|
-
ygridLine.append("text")
|
|
14414
|
-
.attr("transform", isRotated ? "rotate(-90)" : "")
|
|
14415
|
-
.style("opacity", "0");
|
|
14416
|
-
ygridLines = ygridLine.merge(ygridLines);
|
|
14417
|
-
// update
|
|
14418
|
-
var yv = $$.yv.bind($$);
|
|
14419
|
-
$T(ygridLines
|
|
14420
|
-
.attr("class", function (d) { return "".concat($GRID.ygridLine, " ").concat(d.class || "").trim(); })
|
|
14421
|
-
.select("line"))
|
|
14422
|
-
.attr("x1", isRotated ? yv : 0)
|
|
14423
|
-
.attr("x2", isRotated ? yv : width)
|
|
14424
|
-
.attr("y1", isRotated ? 0 : yv)
|
|
14425
|
-
.attr("y2", isRotated ? height : yv)
|
|
14426
|
-
.style("opacity", null);
|
|
14427
|
-
$T(ygridLines.select("text")
|
|
14428
|
-
.attr("text-anchor", getGridTextAnchor)
|
|
14429
|
-
.attr("dx", getGridTextDx))
|
|
14430
|
-
.attr("dy", -5)
|
|
14431
|
-
.attr("x", getGridTextX(isRotated, width, height))
|
|
14432
|
-
.attr("y", yv)
|
|
14433
|
-
.text(function (d) { return d.text; })
|
|
14434
|
-
.style("opacity", null);
|
|
14435
|
-
$el.gridLines.y = ygridLines;
|
|
14488
|
+
.attr("transform", function () { return (isX ?
|
|
14489
|
+
(isRotated ? null : "rotate(-90)") :
|
|
14490
|
+
(isRotated ? "rotate(-90)" : null)); })
|
|
14491
|
+
.attr("dx", getGridTextDx)
|
|
14492
|
+
.attr("dy", -5))
|
|
14493
|
+
.text(function (d) {
|
|
14494
|
+
var _a;
|
|
14495
|
+
return (_a = d.text) !== null && _a !== void 0 ? _a : this.remove();
|
|
14496
|
+
});
|
|
14497
|
+
gridLines[type] = lines;
|
|
14436
14498
|
},
|
|
14437
14499
|
redrawGrid: function (withTransition) {
|
|
14438
14500
|
var $$ = this;
|
|
14439
14501
|
var isRotated = $$.config.axis_rotated, _a = $$.state, width = _a.width, height = _a.height, gridLines = $$.$el.gridLines, $T = $$.$T;
|
|
14440
14502
|
var xv = $$.xv.bind($$);
|
|
14441
|
-
var
|
|
14442
|
-
var
|
|
14443
|
-
|
|
14503
|
+
var yv = $$.yv.bind($$);
|
|
14504
|
+
var xLines = gridLines.x.select("line");
|
|
14505
|
+
var xTexts = gridLines.x.select("text");
|
|
14506
|
+
var yLines = gridLines.y.select("line");
|
|
14507
|
+
var yTexts = gridLines.y.select("text");
|
|
14508
|
+
xLines = $T(xLines, withTransition)
|
|
14444
14509
|
.attr("x1", isRotated ? 0 : xv)
|
|
14445
14510
|
.attr("x2", isRotated ? width : xv)
|
|
14446
14511
|
.attr("y1", isRotated ? xv : 0)
|
|
14447
14512
|
.attr("y2", isRotated ? xv : height);
|
|
14448
|
-
|
|
14513
|
+
xTexts = $T(xTexts, withTransition)
|
|
14449
14514
|
.attr("x", getGridTextX(!isRotated, width, height))
|
|
14450
|
-
.attr("y", xv)
|
|
14451
|
-
|
|
14515
|
+
.attr("y", xv);
|
|
14516
|
+
yLines = $T(yLines, withTransition)
|
|
14517
|
+
.attr("x1", isRotated ? yv : 0)
|
|
14518
|
+
.attr("x2", isRotated ? yv : width)
|
|
14519
|
+
.attr("y1", isRotated ? 0 : yv)
|
|
14520
|
+
.attr("y2", isRotated ? height : yv);
|
|
14521
|
+
yTexts = $T(yTexts, withTransition)
|
|
14522
|
+
.attr("x", getGridTextX(isRotated, width, height))
|
|
14523
|
+
.attr("y", yv);
|
|
14452
14524
|
return [
|
|
14453
|
-
|
|
14454
|
-
|
|
14525
|
+
xLines.style("opacity", null),
|
|
14526
|
+
xTexts.style("opacity", null),
|
|
14527
|
+
yLines.style("opacity", null),
|
|
14528
|
+
yTexts.style("opacity", null)
|
|
14455
14529
|
];
|
|
14456
14530
|
},
|
|
14457
14531
|
initFocusGrid: function () {
|
|
@@ -14626,7 +14700,7 @@ var grid = {
|
|
|
14626
14700
|
.remove();
|
|
14627
14701
|
var gridLines = "grid_".concat(forX ? "x" : "y", "_lines");
|
|
14628
14702
|
config[gridLines] = config[gridLines].filter(toShow);
|
|
14629
|
-
}
|
|
14703
|
+
}
|
|
14630
14704
|
};
|
|
14631
14705
|
|
|
14632
14706
|
/**
|
|
@@ -14657,7 +14731,8 @@ var region = {
|
|
|
14657
14731
|
$T(regions.exit())
|
|
14658
14732
|
.style("opacity", "0")
|
|
14659
14733
|
.remove();
|
|
14660
|
-
var regionsEnter = regions
|
|
14734
|
+
var regionsEnter = regions
|
|
14735
|
+
.enter()
|
|
14661
14736
|
.append("g");
|
|
14662
14737
|
regionsEnter
|
|
14663
14738
|
.append("rect")
|
|
@@ -14665,16 +14740,35 @@ var region = {
|
|
|
14665
14740
|
region.list = regionsEnter
|
|
14666
14741
|
.merge(regions)
|
|
14667
14742
|
.attr("class", $$.classRegion.bind($$));
|
|
14743
|
+
region.list.each(function (d) {
|
|
14744
|
+
var _a;
|
|
14745
|
+
var g = select(this);
|
|
14746
|
+
if (g.select("text").empty() && ((_a = d.label) === null || _a === void 0 ? void 0 : _a.text)) {
|
|
14747
|
+
select(this).append("text")
|
|
14748
|
+
.style("opacity", "0");
|
|
14749
|
+
}
|
|
14750
|
+
});
|
|
14668
14751
|
},
|
|
14669
14752
|
redrawRegion: function (withTransition) {
|
|
14670
14753
|
var $$ = this;
|
|
14671
14754
|
var region = $$.$el.region, $T = $$.$T;
|
|
14672
14755
|
var regions = region.list.select("rect");
|
|
14756
|
+
var label = region.list.selectAll("text");
|
|
14673
14757
|
regions = $T(regions, withTransition)
|
|
14674
14758
|
.attr("x", $$.regionX.bind($$))
|
|
14675
14759
|
.attr("y", $$.regionY.bind($$))
|
|
14676
14760
|
.attr("width", $$.regionWidth.bind($$))
|
|
14677
14761
|
.attr("height", $$.regionHeight.bind($$));
|
|
14762
|
+
label = $T(label, withTransition)
|
|
14763
|
+
.attr("transform", function (d) {
|
|
14764
|
+
var _a;
|
|
14765
|
+
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;
|
|
14766
|
+
return "translate(".concat($$.regionX.bind($$)(d) + x, ", ").concat($$.regionY.bind($$)(d) + y, ")").concat(rotated ? " rotate(-90)" : "");
|
|
14767
|
+
})
|
|
14768
|
+
.attr("text-anchor", function (d) { var _a; return (((_a = d.label) === null || _a === void 0 ? void 0 : _a.rotated) ? "end" : null); })
|
|
14769
|
+
.attr("dy", "1em")
|
|
14770
|
+
.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; })
|
|
14771
|
+
.text(function (d) { var _a; return (_a = d.label) === null || _a === void 0 ? void 0 : _a.text; });
|
|
14678
14772
|
return [
|
|
14679
14773
|
regions
|
|
14680
14774
|
.style("fill-opacity", function (d) { return (isValue(d.opacity) ? d.opacity : null); })
|
|
@@ -14683,7 +14777,8 @@ var region = {
|
|
|
14683
14777
|
select(this.parentNode)
|
|
14684
14778
|
.selectAll("rect:not([x])")
|
|
14685
14779
|
.remove();
|
|
14686
|
-
})
|
|
14780
|
+
}),
|
|
14781
|
+
label.style("opacity", null)
|
|
14687
14782
|
];
|
|
14688
14783
|
},
|
|
14689
14784
|
getRegionXY: function (type, d) {
|
|
@@ -14887,10 +14982,6 @@ var sizeAxis = {
|
|
|
14887
14982
|
}
|
|
14888
14983
|
};
|
|
14889
14984
|
|
|
14890
|
-
/**
|
|
14891
|
-
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
14892
|
-
* billboard.js project is licensed under the MIT license
|
|
14893
|
-
*/
|
|
14894
14985
|
/**
|
|
14895
14986
|
* Axis based chart data config options
|
|
14896
14987
|
*/
|
|
@@ -15080,6 +15171,7 @@ var x = {
|
|
|
15080
15171
|
* - **log** type:
|
|
15081
15172
|
* - the x values specified by [`data.x`](#.data%25E2%2580%25A4x)(or by any equivalent option), must be exclusively-positive.
|
|
15082
15173
|
* - x axis min value should be >= 0.
|
|
15174
|
+
* - for 'category' type, `data.xs` option isn't supported.
|
|
15083
15175
|
*
|
|
15084
15176
|
* @name axis․x․type
|
|
15085
15177
|
* @memberof Options
|
|
@@ -17609,8 +17701,9 @@ var shapeArc = {
|
|
|
17609
17701
|
// touch events
|
|
17610
17702
|
if (isTouch && $$.hasArcType() && !$$.radars) {
|
|
17611
17703
|
var getEventArc_1 = function (event) {
|
|
17612
|
-
var
|
|
17613
|
-
var
|
|
17704
|
+
var _a, _b;
|
|
17705
|
+
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;
|
|
17706
|
+
var eventArc = select(doc.elementFromPoint(clientX, clientY));
|
|
17614
17707
|
return eventArc;
|
|
17615
17708
|
};
|
|
17616
17709
|
$$.$el.svg
|
|
@@ -18094,14 +18187,12 @@ var shapeCandlestick = {
|
|
|
18094
18187
|
var $$ = this;
|
|
18095
18188
|
var $el = $$.$el;
|
|
18096
18189
|
var classChart = $$.getChartClass("Candlestick");
|
|
18097
|
-
var classFocus = $$.classFocus.bind($$);
|
|
18098
18190
|
if (!$el.candlestick) {
|
|
18099
18191
|
$$.initCandlestick();
|
|
18100
18192
|
}
|
|
18101
18193
|
var mainUpdate = $$.$el.main.select(".".concat($CANDLESTICK.chartCandlesticks))
|
|
18102
18194
|
.selectAll(".".concat($CANDLESTICK.chartCandlestick))
|
|
18103
|
-
.data(targets)
|
|
18104
|
-
.attr("class", function (d) { return classChart(d) + classFocus(d); });
|
|
18195
|
+
.data(targets);
|
|
18105
18196
|
mainUpdate.enter().append("g")
|
|
18106
18197
|
.attr("class", classChart)
|
|
18107
18198
|
.style("pointer-events", "none");
|
|
@@ -18131,9 +18222,6 @@ var shapeCandlestick = {
|
|
|
18131
18222
|
.attr("class", classSetter);
|
|
18132
18223
|
candlestickEnter.append("line");
|
|
18133
18224
|
candlestickEnter.append("path");
|
|
18134
|
-
if (!$root.candlestick) {
|
|
18135
|
-
$root.candlestick = {};
|
|
18136
|
-
}
|
|
18137
18225
|
$root.candlestick = candlestick.merge(candlestickEnter)
|
|
18138
18226
|
.style("opacity", initialOpacity);
|
|
18139
18227
|
},
|
|
@@ -18196,7 +18284,6 @@ var shapeCandlestick = {
|
|
|
18196
18284
|
generateGetCandlestickPoints: function (indices, isSub) {
|
|
18197
18285
|
if (isSub === void 0) { isSub = false; }
|
|
18198
18286
|
var $$ = this;
|
|
18199
|
-
var config = $$.config;
|
|
18200
18287
|
var axis = isSub ? $$.axis.subX : $$.axis.x;
|
|
18201
18288
|
var targetsNum = $$.getIndicesMax(indices) + 1;
|
|
18202
18289
|
var barW = $$.getBarW("candlestick", axis, targetsNum);
|
|
@@ -18210,7 +18297,7 @@ var shapeCandlestick = {
|
|
|
18210
18297
|
var width = isNumber(barW) ? barW : barW[d.id] || barW._$width;
|
|
18211
18298
|
var value = $$.getCandlestickData(d);
|
|
18212
18299
|
var points;
|
|
18213
|
-
if (value) {
|
|
18300
|
+
if (value && isNumber(value.open) && isNumber(value.close)) {
|
|
18214
18301
|
var posX = {
|
|
18215
18302
|
start: x(d),
|
|
18216
18303
|
end: 0
|
|
@@ -18225,10 +18312,6 @@ var shapeCandlestick = {
|
|
|
18225
18312
|
high: y(value.high),
|
|
18226
18313
|
low: y(value.low)
|
|
18227
18314
|
};
|
|
18228
|
-
// fix posY not to overflow opposite quadrant
|
|
18229
|
-
if (config.axis_rotated && ((d.value > 0 && posY.start < y0) || (d.value < 0 && y0 < posY.start))) {
|
|
18230
|
-
posY.start = y0;
|
|
18231
|
-
}
|
|
18232
18315
|
posY.start -= (y0 - offset);
|
|
18233
18316
|
points = [
|
|
18234
18317
|
[posX.start, posY.start],
|
|
@@ -18734,7 +18817,7 @@ var shapePoint = {
|
|
|
18734
18817
|
var config = this.config;
|
|
18735
18818
|
var opacity = config.point_opacity;
|
|
18736
18819
|
if (isUndefined(opacity)) {
|
|
18737
|
-
opacity = config.point_show && !
|
|
18820
|
+
opacity = config.point_show && !this.isPointFocusOnly() ? null : "0";
|
|
18738
18821
|
opacity = isValue(this.getBaseValue(d)) ?
|
|
18739
18822
|
(this.isBubbleType(d) || this.isScatterType(d) ?
|
|
18740
18823
|
"0.5" : opacity) : "0";
|
|
@@ -18802,9 +18885,10 @@ var shapePoint = {
|
|
|
18802
18885
|
if (isSub === void 0) { isSub = false; }
|
|
18803
18886
|
var $$ = this;
|
|
18804
18887
|
var config = $$.config, state = $$.state, $el = $$.$el;
|
|
18805
|
-
var focusOnly =
|
|
18888
|
+
var focusOnly = $$.isPointFocusOnly();
|
|
18806
18889
|
var $root = isSub ? $el.subchart : $el;
|
|
18807
18890
|
if (config.point_show && !state.toggling) {
|
|
18891
|
+
config.point_radialGradient && $$.updateLinearGradient();
|
|
18808
18892
|
var circles = $root.main.selectAll(".".concat($CIRCLE.circles))
|
|
18809
18893
|
.selectAll(".".concat($CIRCLE.circle))
|
|
18810
18894
|
.data(function (d) { return (($$.isLineType(d) && $$.shouldDrawPointsForLine(d)) ||
|
|
@@ -18813,12 +18897,24 @@ var shapePoint = {
|
|
|
18813
18897
|
circles.exit().remove();
|
|
18814
18898
|
circles.enter()
|
|
18815
18899
|
.filter(Boolean)
|
|
18816
|
-
.append($$.point("create", this, $$.pointR.bind($$), $$.
|
|
18900
|
+
.append($$.point("create", this, $$.pointR.bind($$), $$.updateCircleColor.bind($$)));
|
|
18817
18901
|
$root.circle = $root.main.selectAll(".".concat($CIRCLE.circles, " .").concat($CIRCLE.circle))
|
|
18818
18902
|
.style("stroke", $$.getStylePropValue($$.color))
|
|
18819
18903
|
.style("opacity", $$.initialOpacityForCircle.bind($$));
|
|
18820
18904
|
}
|
|
18821
18905
|
},
|
|
18906
|
+
/**
|
|
18907
|
+
* Update circle color
|
|
18908
|
+
* @param {object} d Data object
|
|
18909
|
+
* @returns {string} Color string
|
|
18910
|
+
* @private
|
|
18911
|
+
*/
|
|
18912
|
+
updateCircleColor: function (d) {
|
|
18913
|
+
var $$ = this;
|
|
18914
|
+
var fn = $$.getStylePropValue($$.color);
|
|
18915
|
+
return $$.config.point_radialGradient ?
|
|
18916
|
+
$$.getGradienColortUrl(d.id) : (fn ? fn(d) : null);
|
|
18917
|
+
},
|
|
18822
18918
|
redrawCircle: function (cx, cy, withTransition, flow, isSub) {
|
|
18823
18919
|
if (isSub === void 0) { isSub = false; }
|
|
18824
18920
|
var $$ = this;
|
|
@@ -18828,7 +18924,7 @@ var shapePoint = {
|
|
|
18828
18924
|
if (!$$.config.point_show) {
|
|
18829
18925
|
return [];
|
|
18830
18926
|
}
|
|
18831
|
-
var fn = $$.point("update", $$, cx, cy, $$.
|
|
18927
|
+
var fn = $$.point("update", $$, cx, cy, $$.updateCircleColor.bind($$), withTransition, flow, selectedCircles);
|
|
18832
18928
|
var posAttr = $$.isCirclePoint() ? "c" : "";
|
|
18833
18929
|
var t = getRandom();
|
|
18834
18930
|
var opacityStyleFn = $$.opacityForCircle.bind($$);
|
|
@@ -18853,9 +18949,9 @@ var shapePoint = {
|
|
|
18853
18949
|
*/
|
|
18854
18950
|
showCircleFocus: function (d) {
|
|
18855
18951
|
var $$ = this;
|
|
18856
|
-
var
|
|
18952
|
+
var _a = $$.state, hasRadar = _a.hasRadar, resizing = _a.resizing, toggling = _a.toggling, transiting = _a.transiting, $el = $$.$el;
|
|
18857
18953
|
var circle = $el.circle;
|
|
18858
|
-
if (transiting === false &&
|
|
18954
|
+
if (transiting === false && $$.isPointFocusOnly() && circle) {
|
|
18859
18955
|
var cx = (hasRadar ? $$.radarCircleX : $$.circleX).bind($$);
|
|
18860
18956
|
var cy = (hasRadar ? $$.radarCircleY : $$.circleY).bind($$);
|
|
18861
18957
|
var withTransition = toggling || isUndefined(d);
|
|
@@ -18890,8 +18986,8 @@ var shapePoint = {
|
|
|
18890
18986
|
*/
|
|
18891
18987
|
hideCircleFocus: function () {
|
|
18892
18988
|
var $$ = this;
|
|
18893
|
-
var
|
|
18894
|
-
if (
|
|
18989
|
+
var circle = $$.$el.circle;
|
|
18990
|
+
if ($$.isPointFocusOnly() && circle) {
|
|
18895
18991
|
$$.unexpandCircles();
|
|
18896
18992
|
circle.style("visibility", "hidden");
|
|
18897
18993
|
}
|
|
@@ -18977,6 +19073,16 @@ var shapePoint = {
|
|
|
18977
19073
|
return isFunction(selectR) ?
|
|
18978
19074
|
selectR(d) : (selectR || $$.pointR(d) * 4);
|
|
18979
19075
|
},
|
|
19076
|
+
/**
|
|
19077
|
+
* Check if point.focus.only option can be applied.
|
|
19078
|
+
* @returns {boolean}
|
|
19079
|
+
* @private
|
|
19080
|
+
*/
|
|
19081
|
+
isPointFocusOnly: function () {
|
|
19082
|
+
var $$ = this;
|
|
19083
|
+
return $$.config.point_focus_only &&
|
|
19084
|
+
!$$.hasType("bubble") && !$$.hasType("scatter") && !$$.hasArcType(null, ["radar"]);
|
|
19085
|
+
},
|
|
18980
19086
|
isWithinCircle: function (node, r) {
|
|
18981
19087
|
var mouse = getPointer(this.state.event, node);
|
|
18982
19088
|
var element = select(node);
|
|
@@ -19539,7 +19645,7 @@ var shapeRadar = {
|
|
|
19539
19645
|
bindRadarEvent: function () {
|
|
19540
19646
|
var $$ = this;
|
|
19541
19647
|
var config = $$.config, state = $$.state, _a = $$.$el, radar = _a.radar, svg = _a.svg;
|
|
19542
|
-
var focusOnly =
|
|
19648
|
+
var focusOnly = $$.isPointFocusOnly();
|
|
19543
19649
|
var inputType = state.inputType, transiting = state.transiting;
|
|
19544
19650
|
if (config.interaction_enabled) {
|
|
19545
19651
|
var isMouse_1 = inputType === "mouse";
|
|
@@ -19698,11 +19804,11 @@ var shapeTreemap = {
|
|
|
19698
19804
|
if (config.interaction_enabled) {
|
|
19699
19805
|
var isTouch = state.inputType === "touch";
|
|
19700
19806
|
$el.treemap
|
|
19701
|
-
.on(isTouch ? "touchstart" : "mousemove", function (event) {
|
|
19807
|
+
.on(isTouch ? "touchstart" : "mouseover mousemove", function (event) {
|
|
19702
19808
|
var data = getTarget(event);
|
|
19703
19809
|
if (data) {
|
|
19704
19810
|
$$.showTooltip([data], event.currentTarget);
|
|
19705
|
-
event.type
|
|
19811
|
+
/^(touchstart|mouseover)$/.test(event.type) && $$.setOverOut(true, data);
|
|
19706
19812
|
}
|
|
19707
19813
|
})
|
|
19708
19814
|
.on(isTouch ? "touchend" : "mouseout", function (event) {
|
|
@@ -19859,6 +19965,13 @@ var optPoint = {
|
|
|
19859
19965
|
* @property {boolean} [point.show=true] Whether to show each point in line.
|
|
19860
19966
|
* @property {number|Function} [point.r=2.5] The radius size of each point.
|
|
19861
19967
|
* - **NOTE:** Disabled for 'bubble' type
|
|
19968
|
+
* @property {boolean|object} [point.radialGradient=false] Set the radial gradient on point.<br><br>
|
|
19969
|
+
* Or customize by giving below object value:
|
|
19970
|
+
* - cx {number}: `cx` value (default: `0.3`)
|
|
19971
|
+
* - cy {number}: `cy` value (default: `0.3`)
|
|
19972
|
+
* - r {number}: `r` value (default: `0.7`)
|
|
19973
|
+
* - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
|
|
19974
|
+
* - (default: `[[0.1, $DATA_COLOR, 1], [0.9, $DATA_COLOR, 0]]`)
|
|
19862
19975
|
* @property {boolean} [point.focus.expand.enabled=true] Whether to expand each point on focus.
|
|
19863
19976
|
* @property {number} [point.focus.expand.r=point.r*1.75] The radius size of each point on focus.
|
|
19864
19977
|
* - **NOTE:** For 'bubble' type, the default is `bubbleSize*1.15`
|
|
@@ -19901,6 +20014,7 @@ var optPoint = {
|
|
|
19901
20014
|
* (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
|
|
19902
20015
|
* @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
|
|
19903
20016
|
* @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
|
|
20017
|
+
* @see [Demo: point radialGradient](https://naver.github.io/billboard.js/demo/#Point.RadialGradientPoint)
|
|
19904
20018
|
* @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
|
|
19905
20019
|
* @example
|
|
19906
20020
|
* point: {
|
|
@@ -19913,6 +20027,32 @@ var optPoint = {
|
|
|
19913
20027
|
* return r;
|
|
19914
20028
|
* },
|
|
19915
20029
|
*
|
|
20030
|
+
* // will generate follwing radialGradient:
|
|
20031
|
+
* // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/radialGradient
|
|
20032
|
+
* // <radualGradient cx="0.3" cy="0.3" r="0.7">
|
|
20033
|
+
* // <stop offset="0.1" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
20034
|
+
* // <stop offset="0.9" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
|
|
20035
|
+
* // </radialrGradient>
|
|
20036
|
+
* radialGradient: true,
|
|
20037
|
+
*
|
|
20038
|
+
* // Or customized gradient
|
|
20039
|
+
* radialGradient: {
|
|
20040
|
+
* cx: 0.3, // cx attributes
|
|
20041
|
+
* cy: 0.5, // cy attributes
|
|
20042
|
+
* r: 0.7, // r attributes
|
|
20043
|
+
* stops: [
|
|
20044
|
+
* // offset, stop-color, stop-opacity
|
|
20045
|
+
* [0, "#7cb5ec", 1],
|
|
20046
|
+
*
|
|
20047
|
+
* // setting 'null' for stop-color, will set its original data color
|
|
20048
|
+
* [0.5, null, 0],
|
|
20049
|
+
*
|
|
20050
|
+
* // setting 'function' for stop-color, will pass data id as argument.
|
|
20051
|
+
* // It should return color string or null value
|
|
20052
|
+
* [1, function(id) { return id === "data1" ? "red" : "blue"; }, 0],
|
|
20053
|
+
* ]
|
|
20054
|
+
* },
|
|
20055
|
+
*
|
|
19916
20056
|
* focus: {
|
|
19917
20057
|
* expand: {
|
|
19918
20058
|
* enabled: true,
|
|
@@ -19959,6 +20099,7 @@ var optPoint = {
|
|
|
19959
20099
|
*/
|
|
19960
20100
|
point_show: true,
|
|
19961
20101
|
point_r: 2.5,
|
|
20102
|
+
point_radialGradient: false,
|
|
19962
20103
|
point_sensitivity: 10,
|
|
19963
20104
|
point_focus_expand_enabled: true,
|
|
19964
20105
|
point_focus_expand_r: undefined,
|
|
@@ -19989,9 +20130,10 @@ var optArea = {
|
|
|
19989
20130
|
* @property {boolean} [area.front=true] Set area node to be positioned over line node.
|
|
19990
20131
|
* @property {boolean|object} [area.linearGradient=false] Set the linear gradient on area.<br><br>
|
|
19991
20132
|
* Or customize by giving below object value:
|
|
19992
|
-
* - x {Array}: `x1`, `x2` value
|
|
19993
|
-
* - y {Array}: `y1`, `y2` value
|
|
20133
|
+
* - x {Array}: `x1`, `x2` value (default: `[0, 0]`)
|
|
20134
|
+
* - y {Array}: `y1`, `y2` value (default: `[0, 1]`)
|
|
19994
20135
|
* - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
|
|
20136
|
+
* - (default: `[[0, $DATA_COLOR, 1], [1, $DATA_COLOR, 0]]`)
|
|
19995
20137
|
* @property {boolean} [area.zerobased=true] Set if min or max value will be 0 on area chart.
|
|
19996
20138
|
* @see [MDN's <linearGradient>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient), [<stop>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/stop)
|
|
19997
20139
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.AreaChart)
|
|
@@ -20008,6 +20150,7 @@ var optArea = {
|
|
|
20008
20150
|
* front: false,
|
|
20009
20151
|
*
|
|
20010
20152
|
* // will generate follwing linearGradient:
|
|
20153
|
+
* // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
|
|
20011
20154
|
* // <linearGradient x1="0" x2="0" y1="0" y2="1">
|
|
20012
20155
|
* // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
20013
20156
|
* // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
|
|
@@ -20058,9 +20201,10 @@ var optBar = {
|
|
|
20058
20201
|
* @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
20059
20202
|
* @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
|
|
20060
20203
|
* Or customize by giving below object value:
|
|
20061
|
-
* - x {Array}: `x1`, `x2` value
|
|
20062
|
-
* - y {Array}: `y1`, `y2` value
|
|
20204
|
+
* - x {Array}: `x1`, `x2` value (default: `[0, 0]`)
|
|
20205
|
+
* - y {Array}: `y1`, `y2` value (default: `[0, 1]`)
|
|
20063
20206
|
* - stops {Array}: Each item should be having `[offset, stop-color, stop-opacity]` values.
|
|
20207
|
+
* - (default: `[[0, $DATA_COLOR, 1], [1, $DATA_COLOR, 0]]`)
|
|
20064
20208
|
* @property {boolean} [bar.overlap=false] Bars will be rendered at same position, which will be overlapped each other. (for non-grouped bars only)
|
|
20065
20209
|
* @property {number} [bar.padding=0] The padding pixel value between each bar.
|
|
20066
20210
|
* @property {number} [bar.radius] Set the radius of bar edge in pixel.
|
|
@@ -20094,6 +20238,7 @@ var optBar = {
|
|
|
20094
20238
|
* },
|
|
20095
20239
|
*
|
|
20096
20240
|
* // will generate follwing linearGradient:
|
|
20241
|
+
* // for more info: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/linearGradient
|
|
20097
20242
|
* // <linearGradient x1="0" x2="0" y1="0" y2="1">
|
|
20098
20243
|
* // <stop offset="0" stop-color="$DATA_COLOR" stop-opacity="1"></stop>
|
|
20099
20244
|
* // <stop offset="1" stop-color="$DATA_COLOR" stop-opacity="0"></stop>
|
|
@@ -21246,113 +21391,157 @@ var apiSelection = {
|
|
|
21246
21391
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
21247
21392
|
* billboard.js project is licensed under the MIT license
|
|
21248
21393
|
*/
|
|
21249
|
-
|
|
21250
|
-
|
|
21251
|
-
|
|
21252
|
-
|
|
21253
|
-
|
|
21254
|
-
|
|
21255
|
-
|
|
21256
|
-
|
|
21257
|
-
|
|
21258
|
-
|
|
21259
|
-
|
|
21260
|
-
|
|
21261
|
-
|
|
21262
|
-
|
|
21263
|
-
|
|
21264
|
-
|
|
21265
|
-
|
|
21266
|
-
|
|
21267
|
-
|
|
21268
|
-
|
|
21269
|
-
|
|
21270
|
-
|
|
21271
|
-
|
|
21272
|
-
|
|
21273
|
-
|
|
21274
|
-
|
|
21275
|
-
|
|
21276
|
-
|
|
21277
|
-
var subchart = $$.$el.subchart, config = $$.config;
|
|
21278
|
-
var show = config.subchart_show;
|
|
21279
|
-
if (!show) {
|
|
21280
|
-
// unbind zoom event bound to chart rect area
|
|
21281
|
-
$$.unbindZoomEvent();
|
|
21282
|
-
config.subchart_show = !show;
|
|
21283
|
-
!subchart.main && $$.initSubchart();
|
|
21284
|
-
var $target = subchart.main.selectAll(".".concat($COMMON.target));
|
|
21285
|
-
// need to cover when new data has been loaded
|
|
21286
|
-
if ($$.data.targets.length !== $target.size()) {
|
|
21287
|
-
$$.updateSizes();
|
|
21288
|
-
$$.updateTargetsForSubchart($$.data.targets);
|
|
21289
|
-
$target = (_a = subchart.main) === null || _a === void 0 ? void 0 : _a.selectAll(".".concat($COMMON.target));
|
|
21290
|
-
}
|
|
21291
|
-
$target === null || $target === void 0 ? void 0 : $target.style("opacity", null);
|
|
21292
|
-
(_b = subchart.main) === null || _b === void 0 ? void 0 : _b.style("display", null);
|
|
21293
|
-
this.resize();
|
|
21394
|
+
/**
|
|
21395
|
+
* Select subchart by giving x domain range.
|
|
21396
|
+
* - **ℹ️ NOTE:**
|
|
21397
|
+
* - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
|
|
21398
|
+
* @function subchart
|
|
21399
|
+
* @instance
|
|
21400
|
+
* @memberof Chart
|
|
21401
|
+
* @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.
|
|
21402
|
+
* @returns {Array} domain value in array
|
|
21403
|
+
* @example
|
|
21404
|
+
* // Specify domain for subchart selection
|
|
21405
|
+
* chart.subchart([1, 2]);
|
|
21406
|
+
*
|
|
21407
|
+
* // Get the current subchart selection domain range
|
|
21408
|
+
* // Domain value may not be exact returning approximately values.
|
|
21409
|
+
* chart.subchart();
|
|
21410
|
+
*/
|
|
21411
|
+
// NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
|
|
21412
|
+
var subchart$1 = function (domainValue) {
|
|
21413
|
+
var _a;
|
|
21414
|
+
var $$ = this.internal;
|
|
21415
|
+
var axis = $$.axis, brush = $$.brush, config = $$.config, _b = $$.scale, x = _b.x, subX = _b.subX, state = $$.state;
|
|
21416
|
+
var domain;
|
|
21417
|
+
if (config.subchart_show) {
|
|
21418
|
+
domain = domainValue;
|
|
21419
|
+
if (Array.isArray(domain)) {
|
|
21420
|
+
if (axis.isTimeSeries()) {
|
|
21421
|
+
domain = domain.map(function (x) { return parseDate.bind($$)(x); });
|
|
21294
21422
|
}
|
|
21295
|
-
|
|
21296
|
-
|
|
21297
|
-
|
|
21298
|
-
|
|
21299
|
-
* @function subchart․hide
|
|
21300
|
-
* @instance
|
|
21301
|
-
* @memberof Chart
|
|
21302
|
-
* @example
|
|
21303
|
-
* chart.subchart.hide();
|
|
21304
|
-
*/
|
|
21305
|
-
hide: function () {
|
|
21306
|
-
var $$ = this.internal;
|
|
21307
|
-
var main = $$.$el.subchart.main, config = $$.config;
|
|
21308
|
-
if (config.subchart_show && (main === null || main === void 0 ? void 0 : main.style("display")) !== "none") {
|
|
21309
|
-
config.subchart_show = false;
|
|
21310
|
-
main.style("display", "none");
|
|
21311
|
-
this.resize();
|
|
21423
|
+
var isWithinRange = $$.withinRange(domain, $$.getZoomDomain("subX", true), $$.getZoomDomain("subX"));
|
|
21424
|
+
if (isWithinRange) {
|
|
21425
|
+
state.domain = domain;
|
|
21426
|
+
brush.move(brush.getSelection(), domain.map(subX));
|
|
21312
21427
|
}
|
|
21313
|
-
},
|
|
21314
|
-
/**
|
|
21315
|
-
* Toggle the visiblity of subchart
|
|
21316
|
-
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21317
|
-
* @function subchart․toggle
|
|
21318
|
-
* @instance
|
|
21319
|
-
* @memberof Chart
|
|
21320
|
-
* @example
|
|
21321
|
-
* // When subchart is hidden, will be shown
|
|
21322
|
-
* // When subchart is shown, will be hidden
|
|
21323
|
-
* chart.subchart.toggle();
|
|
21324
|
-
*/
|
|
21325
|
-
toggle: function () {
|
|
21326
|
-
var $$ = this.internal;
|
|
21327
|
-
var config = $$.config;
|
|
21328
|
-
this.subchart[config.subchart_show ? "hide" : "show"]();
|
|
21329
21428
|
}
|
|
21429
|
+
else {
|
|
21430
|
+
domain = (_a = state.domain) !== null && _a !== void 0 ? _a : x.orgDomain();
|
|
21431
|
+
}
|
|
21432
|
+
}
|
|
21433
|
+
return domain;
|
|
21434
|
+
};
|
|
21435
|
+
extend(subchart$1, {
|
|
21436
|
+
/**
|
|
21437
|
+
* Show subchart
|
|
21438
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21439
|
+
* @function subchart․show
|
|
21440
|
+
* @instance
|
|
21441
|
+
* @memberof Chart
|
|
21442
|
+
* @example
|
|
21443
|
+
* // for ESM imports, needs to import 'subchart' and must be instantiated first to enable subchart's API.
|
|
21444
|
+
* import {subchart} from "billboard.js";
|
|
21445
|
+
*
|
|
21446
|
+
* const chart = bb.generate({
|
|
21447
|
+
* ...
|
|
21448
|
+
* subchart: {
|
|
21449
|
+
* // need to be instantiated by calling 'subchart()'
|
|
21450
|
+
* enabled: subchart()
|
|
21451
|
+
*
|
|
21452
|
+
* // in case don't want subchart to be shown at initialization, instantiate with '!subchart()'
|
|
21453
|
+
* enabled: !subchart()
|
|
21454
|
+
* }
|
|
21455
|
+
* });
|
|
21456
|
+
*
|
|
21457
|
+
* chart.subchart.show();
|
|
21458
|
+
*/
|
|
21459
|
+
show: function () {
|
|
21460
|
+
var _a, _b;
|
|
21461
|
+
var $$ = this.internal;
|
|
21462
|
+
var subchart = $$.$el.subchart, config = $$.config;
|
|
21463
|
+
var show = config.subchart_show;
|
|
21464
|
+
if (!show) {
|
|
21465
|
+
// unbind zoom event bound to chart rect area
|
|
21466
|
+
$$.unbindZoomEvent();
|
|
21467
|
+
config.subchart_show = !show;
|
|
21468
|
+
!subchart.main && $$.initSubchart();
|
|
21469
|
+
var $target = subchart.main.selectAll(".".concat($COMMON.target));
|
|
21470
|
+
// need to cover when new data has been loaded
|
|
21471
|
+
if ($$.data.targets.length !== $target.size()) {
|
|
21472
|
+
$$.updateSizes();
|
|
21473
|
+
$$.updateTargetsForSubchart($$.data.targets);
|
|
21474
|
+
$target = (_a = subchart.main) === null || _a === void 0 ? void 0 : _a.selectAll(".".concat($COMMON.target));
|
|
21475
|
+
}
|
|
21476
|
+
$target === null || $target === void 0 ? void 0 : $target.style("opacity", null);
|
|
21477
|
+
(_b = subchart.main) === null || _b === void 0 ? void 0 : _b.style("display", null);
|
|
21478
|
+
this.resize();
|
|
21479
|
+
}
|
|
21480
|
+
},
|
|
21481
|
+
/**
|
|
21482
|
+
* Hide generated subchart
|
|
21483
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21484
|
+
* @function subchart․hide
|
|
21485
|
+
* @instance
|
|
21486
|
+
* @memberof Chart
|
|
21487
|
+
* @example
|
|
21488
|
+
* chart.subchart.hide();
|
|
21489
|
+
*/
|
|
21490
|
+
hide: function () {
|
|
21491
|
+
var $$ = this.internal;
|
|
21492
|
+
var main = $$.$el.subchart.main, config = $$.config;
|
|
21493
|
+
if (config.subchart_show && (main === null || main === void 0 ? void 0 : main.style("display")) !== "none") {
|
|
21494
|
+
config.subchart_show = false;
|
|
21495
|
+
main.style("display", "none");
|
|
21496
|
+
this.resize();
|
|
21497
|
+
}
|
|
21498
|
+
},
|
|
21499
|
+
/**
|
|
21500
|
+
* Toggle the visiblity of subchart
|
|
21501
|
+
* - **NOTE:** for ESM imports, needs to import 'subchart' exports and instantiate it by calling `subchart()`.
|
|
21502
|
+
* @function subchart․toggle
|
|
21503
|
+
* @instance
|
|
21504
|
+
* @memberof Chart
|
|
21505
|
+
* @example
|
|
21506
|
+
* // When subchart is hidden, will be shown
|
|
21507
|
+
* // When subchart is shown, will be hidden
|
|
21508
|
+
* chart.subchart.toggle();
|
|
21509
|
+
*/
|
|
21510
|
+
toggle: function () {
|
|
21511
|
+
var $$ = this.internal;
|
|
21512
|
+
var config = $$.config;
|
|
21513
|
+
this.subchart[config.subchart_show ? "hide" : "show"]();
|
|
21514
|
+
},
|
|
21515
|
+
/**
|
|
21516
|
+
* Reset subchart selection
|
|
21517
|
+
* @function subchart․reset
|
|
21518
|
+
* @instance
|
|
21519
|
+
* @memberof Chart
|
|
21520
|
+
* @example
|
|
21521
|
+
* // Reset subchart selection
|
|
21522
|
+
* chart.subchart.reset();
|
|
21523
|
+
*/
|
|
21524
|
+
reset: function () {
|
|
21525
|
+
var $$ = this.internal;
|
|
21526
|
+
var brush = $$.brush;
|
|
21527
|
+
brush.clear(brush.getSelection());
|
|
21330
21528
|
}
|
|
21529
|
+
});
|
|
21530
|
+
var apiSubchart = {
|
|
21531
|
+
subchart: subchart$1
|
|
21331
21532
|
};
|
|
21332
21533
|
|
|
21333
21534
|
/**
|
|
21334
21535
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
21335
21536
|
* billboard.js project is licensed under the MIT license
|
|
21336
21537
|
*/
|
|
21337
|
-
/**
|
|
21338
|
-
* Check if the given domain is within zoom range
|
|
21339
|
-
* @param {Array} domain Target domain value
|
|
21340
|
-
* @param {Array} current Current zoom domain value
|
|
21341
|
-
* @param {Array} range Zoom range value
|
|
21342
|
-
* @param {boolean} isInverted Whether the axis is inverted or not
|
|
21343
|
-
* @returns {boolean}
|
|
21344
|
-
* @private
|
|
21345
|
-
*/
|
|
21346
|
-
function withinRange(domain, current, range, isInverted) {
|
|
21347
|
-
if (isInverted === void 0) { isInverted = false; }
|
|
21348
|
-
var min = range[0], max = range[1];
|
|
21349
|
-
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]; })); });
|
|
21350
|
-
}
|
|
21351
21538
|
/**
|
|
21352
21539
|
* Zoom by giving x domain range.
|
|
21353
|
-
* -
|
|
21540
|
+
* - **ℹ️ NOTE:**
|
|
21354
21541
|
* - 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.
|
|
21355
21542
|
* - To be used [zoom.enabled](Options.html#.zoom) option should be set as `truthy`.
|
|
21543
|
+
* - When x axis type is `category`, domain range should be specified as index numbers.
|
|
21544
|
+
* - Due to the limitations of floating point precision, domain value may not be exact returning approximately values.
|
|
21356
21545
|
* @function zoom
|
|
21357
21546
|
* @instance
|
|
21358
21547
|
* @memberof Chart
|
|
@@ -21362,56 +21551,64 @@ function withinRange(domain, current, range, isInverted) {
|
|
|
21362
21551
|
* // Zoom to specified domain range
|
|
21363
21552
|
* chart.zoom([10, 20]);
|
|
21364
21553
|
*
|
|
21365
|
-
* // For timeseries, the domain value can be string, but the format should match with the 'data.xFormat' option.
|
|
21554
|
+
* // For timeseries x axis, the domain value can be string, but the format should match with the 'data.xFormat' option.
|
|
21366
21555
|
* chart.zoom(["2021-02-03", "2021-02-08"]);
|
|
21367
21556
|
*
|
|
21557
|
+
* // For category x axis, the domain value should be index number.
|
|
21558
|
+
* chart.zoom([0, 3]);
|
|
21559
|
+
*
|
|
21368
21560
|
* // Get the current zoomed domain range
|
|
21561
|
+
* // Domain value may not be exact returning approximately values.
|
|
21369
21562
|
* chart.zoom();
|
|
21370
21563
|
*/
|
|
21564
|
+
// NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
|
|
21371
21565
|
var zoom$1 = function (domainValue) {
|
|
21372
21566
|
var _a;
|
|
21567
|
+
var _b;
|
|
21373
21568
|
var $$ = this.internal;
|
|
21374
|
-
var $el = $$.$el, axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale;
|
|
21569
|
+
var $el = $$.$el, axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale, state = $$.state;
|
|
21375
21570
|
var isRotated = config.axis_rotated;
|
|
21376
|
-
var isInverted = config.axis_x_inverted;
|
|
21377
21571
|
var isCategorized = axis.isCategorized();
|
|
21378
|
-
var domain
|
|
21379
|
-
if (config.zoom_enabled
|
|
21380
|
-
|
|
21381
|
-
|
|
21382
|
-
|
|
21383
|
-
|
|
21384
|
-
|
|
21385
|
-
|
|
21386
|
-
|
|
21387
|
-
|
|
21388
|
-
|
|
21389
|
-
|
|
21390
|
-
|
|
21391
|
-
|
|
21392
|
-
$$.
|
|
21393
|
-
|
|
21572
|
+
var domain;
|
|
21573
|
+
if (config.zoom_enabled) {
|
|
21574
|
+
domain = domainValue;
|
|
21575
|
+
if (Array.isArray(domain)) {
|
|
21576
|
+
if (axis.isTimeSeries()) {
|
|
21577
|
+
domain = domain.map(function (x) { return parseDate.bind($$)(x); });
|
|
21578
|
+
}
|
|
21579
|
+
var isWithinRange = $$.withinRange(domain, $$.getZoomDomain("zoom", true), $$.getZoomDomain("zoom"));
|
|
21580
|
+
if (isWithinRange) {
|
|
21581
|
+
state.domain = domain;
|
|
21582
|
+
if (isCategorized) {
|
|
21583
|
+
domain = domain.map(function (v, i) { return Number(v) + (i === 0 ? 0 : 1); });
|
|
21584
|
+
}
|
|
21585
|
+
// hide any possible tooltip show before the zoom
|
|
21586
|
+
$$.api.tooltip.hide();
|
|
21587
|
+
if (config.subchart_show) {
|
|
21588
|
+
var x = scale.zoom || scale.x;
|
|
21589
|
+
$$.brush.getSelection().call($$.brush.move, domain.map(x));
|
|
21590
|
+
// resultDomain = domain;
|
|
21591
|
+
}
|
|
21592
|
+
else {
|
|
21593
|
+
// in case of 'config.zoom_rescale=true', use org.xScale
|
|
21594
|
+
var x = isCategorized ? scale.x.orgScale() : (org.xScale || scale.x);
|
|
21595
|
+
// Get transform from given domain value
|
|
21596
|
+
// https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
|
|
21597
|
+
var translate = [-x(domain[0]), 0];
|
|
21598
|
+
var transform = (_a = zoomIdentity
|
|
21599
|
+
.scale(x.range()[1] / (x(domain[1]) - x(domain[0]))))
|
|
21600
|
+
.translate.apply(_a, (isRotated ? translate.reverse() : translate));
|
|
21601
|
+
$el.eventRect
|
|
21602
|
+
.call($$.zoom.transform, transform);
|
|
21603
|
+
}
|
|
21604
|
+
$$.setZoomResetButton();
|
|
21394
21605
|
}
|
|
21395
|
-
|
|
21396
|
-
|
|
21397
|
-
|
|
21398
|
-
// Get transform from given domain value
|
|
21399
|
-
// https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
|
|
21400
|
-
var translate = [-x(domain[0]), 0];
|
|
21401
|
-
var transform = (_a = zoomIdentity
|
|
21402
|
-
.scale(x.range()[1] / (x(domain[1]) - x(domain[0]))))
|
|
21403
|
-
.translate.apply(_a, (isRotated ? translate.reverse() : translate));
|
|
21404
|
-
$el.eventRect
|
|
21405
|
-
.call($$.zoom.transform, transform);
|
|
21406
|
-
}
|
|
21407
|
-
$$.setZoomResetButton();
|
|
21606
|
+
}
|
|
21607
|
+
else {
|
|
21608
|
+
domain = $$.zoom.getDomain();
|
|
21408
21609
|
}
|
|
21409
21610
|
}
|
|
21410
|
-
|
|
21411
|
-
domain = scale.zoom ?
|
|
21412
|
-
scale.zoom.domain() : scale.x.orgDomain();
|
|
21413
|
-
}
|
|
21414
|
-
return domain;
|
|
21611
|
+
return (_b = state.domain) !== null && _b !== void 0 ? _b : domain;
|
|
21415
21612
|
};
|
|
21416
21613
|
extend(zoom$1, {
|
|
21417
21614
|
/**
|
|
@@ -21529,7 +21726,7 @@ var apiZoom = {
|
|
|
21529
21726
|
*/
|
|
21530
21727
|
unzoom: function () {
|
|
21531
21728
|
var $$ = this.internal;
|
|
21532
|
-
var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, zoomResetBtn = _a.zoomResetBtn;
|
|
21729
|
+
var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, zoomResetBtn = _a.zoomResetBtn, state = $$.state;
|
|
21533
21730
|
if ($$.scale.zoom) {
|
|
21534
21731
|
config.subchart_show ?
|
|
21535
21732
|
$$.brush.getSelection().call($$.brush.move, null) :
|
|
@@ -21540,6 +21737,7 @@ var apiZoom = {
|
|
|
21540
21737
|
if (zoomTransform(eventRect.node()) !== zoomIdentity) {
|
|
21541
21738
|
$$.zoom.transform(eventRect, zoomIdentity);
|
|
21542
21739
|
}
|
|
21740
|
+
state.domain = undefined;
|
|
21543
21741
|
}
|
|
21544
21742
|
}
|
|
21545
21743
|
};
|
|
@@ -21780,7 +21978,7 @@ var selection = _assign(_assign({}, drag), {
|
|
|
21780
21978
|
var toggle_1 = $$.getToggle(that, d).bind($$);
|
|
21781
21979
|
var toggledShape_1;
|
|
21782
21980
|
if (!config.data_selection_multiple) {
|
|
21783
|
-
var focusOnly =
|
|
21981
|
+
var focusOnly = $$.isPointFocusOnly();
|
|
21784
21982
|
var selector = ".".concat(focusOnly ? $SELECT.selectedCircles : $SHAPE.shapes);
|
|
21785
21983
|
if (config.data_selection_grouped) {
|
|
21786
21984
|
selector += $$.getTargetSelectorSuffix(d.id);
|
|
@@ -21812,29 +22010,32 @@ var subchart = {
|
|
|
21812
22010
|
*/
|
|
21813
22011
|
initBrush: function () {
|
|
21814
22012
|
var $$ = this;
|
|
21815
|
-
var config = $$.config, scale = $$.scale, subchart = $$.$el.subchart;
|
|
22013
|
+
var config = $$.config, scale = $$.scale, subchart = $$.$el.subchart, state = $$.state;
|
|
21816
22014
|
var isRotated = config.axis_rotated;
|
|
22015
|
+
var height = config.subchart_size_height;
|
|
21817
22016
|
var lastDomain;
|
|
22017
|
+
var lastSelection;
|
|
21818
22018
|
var timeout;
|
|
21819
22019
|
// set the brush
|
|
21820
22020
|
$$.brush = (isRotated ? brushY() : brushX()).handleSize(5);
|
|
21821
|
-
var getBrushSize = function () {
|
|
21822
|
-
var brush = $$.$el.svg.select(".".concat(CLASS.brush, " .overlay"));
|
|
21823
|
-
var brushSize = { width: 0, height: 0 };
|
|
21824
|
-
if (brush.size()) {
|
|
21825
|
-
brushSize.width = +brush.attr("width");
|
|
21826
|
-
brushSize.height = +brush.attr("height");
|
|
21827
|
-
}
|
|
21828
|
-
return brushSize[isRotated ? "width" : "height"];
|
|
21829
|
-
};
|
|
21830
22021
|
// bind brush event
|
|
21831
22022
|
$$.brush.on("start brush end", function (event) {
|
|
21832
|
-
var selection = event.selection, target = event.target, type = event.type;
|
|
22023
|
+
var selection = event.selection, sourceEvent = event.sourceEvent, target = event.target, type = event.type;
|
|
21833
22024
|
if (type === "start") {
|
|
21834
22025
|
$$.state.inputType === "touch" && $$.hideTooltip();
|
|
22026
|
+
lastSelection = sourceEvent ? selection : null;
|
|
22027
|
+
// sourceEvent && (state.domain = null);
|
|
21835
22028
|
}
|
|
22029
|
+
// if (type === "brush") {
|
|
21836
22030
|
if (/(start|brush)/.test(type)) {
|
|
21837
|
-
|
|
22031
|
+
// when brush selection updates happens on one edge, update only chainging edge and
|
|
22032
|
+
// is only for adjustment of given domain range to be used to return current domain range.
|
|
22033
|
+
type === "brush" && sourceEvent && state.domain && (lastSelection === null || lastSelection === void 0 ? void 0 : lastSelection.forEach(function (v, i) {
|
|
22034
|
+
if (v !== selection[i]) {
|
|
22035
|
+
state.domain[i] = scale.x.orgDomain()[i];
|
|
22036
|
+
}
|
|
22037
|
+
}));
|
|
22038
|
+
$$.redrawForBrush(type !== "start");
|
|
21838
22039
|
}
|
|
21839
22040
|
if (type === "end") {
|
|
21840
22041
|
lastDomain = scale.x.orgDomain();
|
|
@@ -21847,9 +22048,8 @@ var subchart = {
|
|
|
21847
22048
|
else {
|
|
21848
22049
|
$$.brush.handle.attr("display", null)
|
|
21849
22050
|
.attr("transform", function (d, i) {
|
|
21850
|
-
var pos =
|
|
21851
|
-
|
|
21852
|
-
return "translate(".concat(pos, ")");
|
|
22051
|
+
var pos = [selection[i], height / 2];
|
|
22052
|
+
return "translate(".concat(isRotated ? pos.reverse() : pos, ")");
|
|
21853
22053
|
});
|
|
21854
22054
|
}
|
|
21855
22055
|
}
|
|
@@ -21873,7 +22073,7 @@ var subchart = {
|
|
|
21873
22073
|
};
|
|
21874
22074
|
// set the brush extent
|
|
21875
22075
|
$$.brush.scale = function (scale) {
|
|
21876
|
-
var h = config.subchart_size_height
|
|
22076
|
+
var h = config.subchart_size_height;
|
|
21877
22077
|
var extent = $$.getExtent();
|
|
21878
22078
|
if (!extent && scale.range) {
|
|
21879
22079
|
extent = [[0, 0], [scale.range()[1], h]];
|
|
@@ -21958,11 +22158,11 @@ var subchart = {
|
|
|
21958
22158
|
var customHandleClass = "handle--custom";
|
|
21959
22159
|
// brush handle shape's path
|
|
21960
22160
|
var path = isRotated ? [
|
|
21961
|
-
"
|
|
21962
|
-
"
|
|
22161
|
+
"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",
|
|
22162
|
+
"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"
|
|
21963
22163
|
] : [
|
|
21964
|
-
"
|
|
21965
|
-
"
|
|
22164
|
+
"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",
|
|
22165
|
+
"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"
|
|
21966
22166
|
];
|
|
21967
22167
|
$$.brush.handle = brush.selectAll(".".concat(customHandleClass))
|
|
21968
22168
|
.data(isRotated ?
|
|
@@ -22060,17 +22260,23 @@ var subchart = {
|
|
|
22060
22260
|
$$.updateCircle(true);
|
|
22061
22261
|
$$.redrawCircle(cx, cy, withTransition, undefined, true);
|
|
22062
22262
|
}
|
|
22063
|
-
!state.rendered && initRange
|
|
22263
|
+
if (!state.rendered && initRange) {
|
|
22264
|
+
state.domain = initRange;
|
|
22265
|
+
$$.brush.move($$.brush.getSelection(), initRange.map($$.scale.x));
|
|
22266
|
+
}
|
|
22064
22267
|
}
|
|
22065
22268
|
}
|
|
22066
22269
|
},
|
|
22067
22270
|
/**
|
|
22068
22271
|
* Redraw the brush.
|
|
22272
|
+
* @param {boolean} [callCallbck=true] Call 'onbrush' callback or not.
|
|
22069
22273
|
* @private
|
|
22070
22274
|
*/
|
|
22071
|
-
redrawForBrush: function () {
|
|
22275
|
+
redrawForBrush: function (callCallbck) {
|
|
22276
|
+
var _a;
|
|
22277
|
+
if (callCallbck === void 0) { callCallbck = true; }
|
|
22072
22278
|
var $$ = this;
|
|
22073
|
-
var
|
|
22279
|
+
var _b = $$.config, onBrush = _b.subchart_onbrush, withY = _b.zoom_rescale, scale = $$.scale, state = $$.state;
|
|
22074
22280
|
$$.redraw({
|
|
22075
22281
|
withTransition: false,
|
|
22076
22282
|
withY: withY,
|
|
@@ -22078,7 +22284,8 @@ var subchart = {
|
|
|
22078
22284
|
withUpdateXDomain: true,
|
|
22079
22285
|
withDimension: false
|
|
22080
22286
|
});
|
|
22081
|
-
|
|
22287
|
+
callCallbck && state.rendered &&
|
|
22288
|
+
onBrush.bind($$.api)((_a = state.domain) !== null && _a !== void 0 ? _a : scale.x.orgDomain());
|
|
22082
22289
|
},
|
|
22083
22290
|
/**
|
|
22084
22291
|
* Transform context
|
|
@@ -22248,6 +22455,7 @@ var zoom = {
|
|
|
22248
22455
|
* @private
|
|
22249
22456
|
*/
|
|
22250
22457
|
onZoom: function (event) {
|
|
22458
|
+
var _a;
|
|
22251
22459
|
var $$ = this;
|
|
22252
22460
|
var config = $$.config, scale = $$.scale, state = $$.state, org = $$.org;
|
|
22253
22461
|
var sourceEvent = event.sourceEvent;
|
|
@@ -22259,6 +22467,7 @@ var zoom = {
|
|
|
22259
22467
|
}
|
|
22260
22468
|
if (event.sourceEvent) {
|
|
22261
22469
|
state.zooming = true;
|
|
22470
|
+
state.domain = undefined;
|
|
22262
22471
|
}
|
|
22263
22472
|
var isMousemove = (sourceEvent === null || sourceEvent === void 0 ? void 0 : sourceEvent.type) === "mousemove";
|
|
22264
22473
|
var isZoomOut = (sourceEvent === null || sourceEvent === void 0 ? void 0 : sourceEvent.wheelDelta) < 0;
|
|
@@ -22281,7 +22490,7 @@ var zoom = {
|
|
|
22281
22490
|
});
|
|
22282
22491
|
$$.state.cancelClick = isMousemove;
|
|
22283
22492
|
// do not call event cb when is .unzoom() is called
|
|
22284
|
-
!isUnZoom && callFn(config.zoom_onzoom, $$.api, $$.zoom.getDomain());
|
|
22493
|
+
!isUnZoom && callFn(config.zoom_onzoom, $$.api, (_a = $$.state.domain) !== null && _a !== void 0 ? _a : $$.zoom.getDomain());
|
|
22285
22494
|
},
|
|
22286
22495
|
/**
|
|
22287
22496
|
* 'end' event listener
|
|
@@ -22289,7 +22498,7 @@ var zoom = {
|
|
|
22289
22498
|
* @private
|
|
22290
22499
|
*/
|
|
22291
22500
|
onZoomEnd: function (event) {
|
|
22292
|
-
var _a;
|
|
22501
|
+
var _a, _b;
|
|
22293
22502
|
var $$ = this;
|
|
22294
22503
|
var config = $$.config, state = $$.state;
|
|
22295
22504
|
var startEvent = $$.zoom.startEvent;
|
|
@@ -22307,7 +22516,7 @@ var zoom = {
|
|
|
22307
22516
|
$$.updateZoom();
|
|
22308
22517
|
state.zooming = false;
|
|
22309
22518
|
// do not call event cb when is .unzoom() is called
|
|
22310
|
-
!isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, $$.zoom.getDomain());
|
|
22519
|
+
!isUnZoom && (e || state.dragging) && callFn(config.zoom_onzoomend, $$.api, (_b = $$.state.domain) !== null && _b !== void 0 ? _b : $$.zoom.getDomain());
|
|
22311
22520
|
},
|
|
22312
22521
|
/**
|
|
22313
22522
|
* Update zoom
|
|
@@ -22751,7 +22960,7 @@ var zoomModule = function () {
|
|
|
22751
22960
|
var defaults = {};
|
|
22752
22961
|
/**
|
|
22753
22962
|
* @namespace bb
|
|
22754
|
-
* @version 3.
|
|
22963
|
+
* @version 3.10.0-next.2
|
|
22755
22964
|
*/
|
|
22756
22965
|
var bb = {
|
|
22757
22966
|
/**
|
|
@@ -22761,7 +22970,7 @@ var bb = {
|
|
|
22761
22970
|
* bb.version; // "1.0.0"
|
|
22762
22971
|
* @memberof bb
|
|
22763
22972
|
*/
|
|
22764
|
-
version: "3.
|
|
22973
|
+
version: "3.10.0-next.2",
|
|
22765
22974
|
/**
|
|
22766
22975
|
* Generate chart
|
|
22767
22976
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|