billboard.js 3.7.5 → 3.8.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +1 -1
- package/dist/billboard.js +368 -221
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +371 -224
- package/dist/billboard.pkgd.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +20 -18
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +20 -18
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +20 -18
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +20 -18
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +4 -4
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +22 -20
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +22 -20
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +22 -20
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +49 -30
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist-esm/billboard.js +339 -204
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -9
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +6 -11
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +7 -12
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -7
- package/package.json +25 -25
- package/src/Chart/api/focus.ts +4 -4
- package/src/Chart/api/grid.ts +206 -0
- package/src/Chart/api/load.ts +31 -21
- package/src/Chart/api/regions.ts +28 -24
- package/src/Chart/api/zoom.ts +18 -3
- package/src/ChartInternal/Axis/Axis.ts +1 -0
- package/src/ChartInternal/Axis/AxisRenderer.ts +7 -2
- package/src/ChartInternal/ChartInternal.ts +1 -1
- package/src/ChartInternal/data/convert.ts +6 -3
- package/src/ChartInternal/data/data.ts +19 -15
- package/src/ChartInternal/data/load.ts +19 -4
- package/src/ChartInternal/interactions/eventrect.ts +3 -2
- package/src/ChartInternal/interactions/subchart.ts +3 -2
- package/src/ChartInternal/interactions/zoom.ts +10 -3
- package/src/ChartInternal/internals/clip.ts +3 -2
- package/src/ChartInternal/internals/domain.ts +17 -8
- package/src/ChartInternal/internals/legend.ts +4 -1
- package/src/ChartInternal/internals/redraw.ts +0 -16
- package/src/ChartInternal/internals/scale.ts +7 -4
- package/src/ChartInternal/internals/size.axis.ts +14 -4
- package/src/ChartInternal/internals/size.ts +41 -18
- package/src/ChartInternal/internals/transform.ts +1 -1
- package/src/ChartInternal/internals/type.ts +10 -0
- package/src/config/Options/axis/x.ts +17 -0
- package/src/config/Options/axis/y.ts +2 -1
- package/src/config/Options/axis/y2.ts +2 -1
- package/src/config/Options/common/main.ts +19 -1
- package/src/config/resolver/axis.ts +2 -4
- package/src/module/browser.ts +13 -5
- package/src/module/generator.ts +3 -3
- package/src/module/util.ts +2 -2
- package/types/axis.d.ts +8 -7
- package/types/chart.d.ts +6 -1
- package/types/options.d.ts +6 -0
- package/src/Chart/api/grid.x.ts +0 -90
- package/src/Chart/api/grid.y.ts +0 -92
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.8.0-next.1
|
|
9
9
|
*/
|
|
10
10
|
import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
|
|
11
11
|
import { pointer, select, namespaces, selectAll } from 'd3-selection';
|
|
@@ -33,9 +33,12 @@ var win = (function () {
|
|
|
33
33
|
})();
|
|
34
34
|
/* eslint-enable no-new-func, no-undef */
|
|
35
35
|
// fallback for non-supported environments
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
var hasRAF = typeof win.requestAnimationFrame === "function";
|
|
37
|
+
var hasRIC = typeof win.requestIdleCallback === "function";
|
|
38
|
+
var requestAnimationFrame = hasRAF ? win.requestAnimationFrame : (function (cb) { return setTimeout(cb, 1); });
|
|
39
|
+
var cancelAnimationFrame = hasRAF ? win.cancelAnimationFrame : (function (id) { return clearTimeout(id); });
|
|
40
|
+
var requestIdleCallback = hasRIC ? win.requestIdleCallback : requestAnimationFrame;
|
|
41
|
+
hasRIC ? win.cancelIdleCallback : cancelAnimationFrame;
|
|
39
42
|
var doc = win === null || win === void 0 ? void 0 : win.document;
|
|
40
43
|
|
|
41
44
|
/**
|
|
@@ -834,7 +837,7 @@ function convertInputType(mouse, touch) {
|
|
|
834
837
|
*/
|
|
835
838
|
function runUntil(fn, conditionFn) {
|
|
836
839
|
if (conditionFn() === false) {
|
|
837
|
-
|
|
840
|
+
requestAnimationFrame(function () { return runUntil(fn, conditionFn); });
|
|
838
841
|
}
|
|
839
842
|
else {
|
|
840
843
|
fn();
|
|
@@ -973,7 +976,7 @@ var $EVENT = {
|
|
|
973
976
|
eventRect: "bb-event-rect",
|
|
974
977
|
eventRects: "bb-event-rects",
|
|
975
978
|
eventRectsMultiple: "bb-event-rects-multiple",
|
|
976
|
-
eventRectsSingle: "bb-event-rects-single"
|
|
979
|
+
eventRectsSingle: "bb-event-rects-single",
|
|
977
980
|
};
|
|
978
981
|
var $FOCUS = {
|
|
979
982
|
focused: "bb-focused",
|
|
@@ -1013,7 +1016,7 @@ var $SELECT = {
|
|
|
1013
1016
|
};
|
|
1014
1017
|
var $SHAPE = {
|
|
1015
1018
|
shape: "bb-shape",
|
|
1016
|
-
shapes: "bb-shapes"
|
|
1019
|
+
shapes: "bb-shapes",
|
|
1017
1020
|
};
|
|
1018
1021
|
var $SUBCHART = {
|
|
1019
1022
|
brush: "bb-brush",
|
|
@@ -1082,12 +1085,12 @@ var Element = /** @class */ (function () {
|
|
|
1082
1085
|
grid: {
|
|
1083
1086
|
main: null,
|
|
1084
1087
|
x: null,
|
|
1085
|
-
y: null
|
|
1088
|
+
y: null, // ygrid,
|
|
1086
1089
|
},
|
|
1087
1090
|
gridLines: {
|
|
1088
1091
|
main: null,
|
|
1089
1092
|
x: null,
|
|
1090
|
-
y: null
|
|
1093
|
+
y: null, // ygridLines
|
|
1091
1094
|
},
|
|
1092
1095
|
region: {
|
|
1093
1096
|
main: null,
|
|
@@ -1156,7 +1159,7 @@ var State = /** @class */ (function () {
|
|
|
1156
1159
|
y2: { size: 0, domain: "" }
|
|
1157
1160
|
},
|
|
1158
1161
|
// current used chart type list
|
|
1159
|
-
types: []
|
|
1162
|
+
types: [],
|
|
1160
1163
|
},
|
|
1161
1164
|
// legend
|
|
1162
1165
|
isLegendRight: false,
|
|
@@ -1381,15 +1384,30 @@ var main = {
|
|
|
1381
1384
|
* - `false`: Remove padding completely and make shape to fully occupy the container element.
|
|
1382
1385
|
* - In this case, axes and subchart will be hidden.
|
|
1383
1386
|
* - To adjust some padding from this state, use `axis.[x|y].padding` option.
|
|
1387
|
+
* @property {string} [padding.mode] padding mode
|
|
1388
|
+
* - `"fit"`: Reduce padding as much as possible to make chart fit to the container element for chart types w/axis.<br>When specified, all padding values will be relative from fitted value.
|
|
1384
1389
|
* @property {number} [padding.top] padding on the top of chart
|
|
1385
1390
|
* @property {number} [padding.right] padding on the right of chart
|
|
1386
1391
|
* @property {number} [padding.bottom] padding on the bottom of chart
|
|
1387
1392
|
* @property {number} [padding.left] padding on the left of chart
|
|
1388
1393
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Padding)
|
|
1394
|
+
* @see [Demo: Fit padding](https://naver.github.io/billboard.js/demo/#ChartOptions.FitPadding)
|
|
1389
1395
|
* @example
|
|
1390
1396
|
* // remove padding completely.
|
|
1391
1397
|
* padding: false,
|
|
1392
1398
|
*
|
|
1399
|
+
* padding: {
|
|
1400
|
+
* // specifying mode value, will reduce padding and make fit to the container element.
|
|
1401
|
+
* mode: "fit"
|
|
1402
|
+
*
|
|
1403
|
+
* // when mode is "fit", all padding values will be relative from fitted value.
|
|
1404
|
+
* // so, 0 will be initial fitted value.
|
|
1405
|
+
* top: 20,
|
|
1406
|
+
* right: 20,
|
|
1407
|
+
* bottom: 20,
|
|
1408
|
+
* left: 20
|
|
1409
|
+
* }
|
|
1410
|
+
*
|
|
1393
1411
|
* // or specify padding value for each side
|
|
1394
1412
|
* padding: {
|
|
1395
1413
|
* top: 20,
|
|
@@ -1399,6 +1417,7 @@ var main = {
|
|
|
1399
1417
|
* }
|
|
1400
1418
|
*/
|
|
1401
1419
|
padding: true,
|
|
1420
|
+
padding_mode: undefined,
|
|
1402
1421
|
padding_left: undefined,
|
|
1403
1422
|
padding_right: undefined,
|
|
1404
1423
|
padding_top: undefined,
|
|
@@ -1412,7 +1431,9 @@ var main = {
|
|
|
1412
1431
|
* @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
|
|
1413
1432
|
* @property {boolean|number} [resize.timer=true] Set resize timer option.
|
|
1414
1433
|
* - **NOTE:**
|
|
1415
|
-
* - The resize function will be called using:
|
|
1434
|
+
* - The resize function will be called using:
|
|
1435
|
+
* - true: `setTimeout()`
|
|
1436
|
+
* - false: `requestIdleCallback()`
|
|
1416
1437
|
* - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
|
|
1417
1438
|
* @example
|
|
1418
1439
|
* resize: {
|
|
@@ -3169,7 +3190,7 @@ function generateResize(option) {
|
|
|
3169
3190
|
var callResizeFn = function () {
|
|
3170
3191
|
// Delay all resize functions call, to prevent unintended excessive call from resize event
|
|
3171
3192
|
callResizeFn.clear();
|
|
3172
|
-
if (option === false
|
|
3193
|
+
if (option === false) {
|
|
3173
3194
|
requestIdleCallback(function () {
|
|
3174
3195
|
fn.forEach(function (f) { return f(); });
|
|
3175
3196
|
}, { timeout: 200 });
|
|
@@ -3572,6 +3593,7 @@ var dataConvert = {
|
|
|
3572
3593
|
var _this = this;
|
|
3573
3594
|
var $$ = this;
|
|
3574
3595
|
var axis = $$.axis, config = $$.config, state = $$.state;
|
|
3596
|
+
var chartType = config.data_type;
|
|
3575
3597
|
var isCategorized = false;
|
|
3576
3598
|
var isTimeSeries = false;
|
|
3577
3599
|
var isCustomX = false;
|
|
@@ -3684,9 +3706,10 @@ var dataConvert = {
|
|
|
3684
3706
|
state.hasNegativeValue = $$.hasNegativeValueInTargets(targets);
|
|
3685
3707
|
state.hasPositiveValue = $$.hasPositiveValueInTargets(targets);
|
|
3686
3708
|
// set target types
|
|
3687
|
-
if (
|
|
3688
|
-
$$.
|
|
3689
|
-
.filter(function (id) { return !(id in config.data_types)
|
|
3709
|
+
if (chartType && $$.isValidChartType(chartType)) {
|
|
3710
|
+
var targetIds = $$.mapToIds(targets)
|
|
3711
|
+
.filter(function (id) { return !(id in config.data_types) || !$$.isValidChartType(config.data_types[id]); });
|
|
3712
|
+
$$.setTargetType(targetIds, chartType);
|
|
3690
3713
|
}
|
|
3691
3714
|
// cache as original id keyed
|
|
3692
3715
|
targets.forEach(function (d) { return $$.cache.add(d.id_org, d, true); });
|
|
@@ -3993,12 +4016,13 @@ var data$1 = {
|
|
|
3993
4016
|
getMaxDataCountTarget: function () {
|
|
3994
4017
|
var target = this.filterTargetsToShow() || [];
|
|
3995
4018
|
var length = target.length;
|
|
4019
|
+
var isInverted = this.config.axis_x_inverted;
|
|
3996
4020
|
if (length > 1) {
|
|
3997
4021
|
target = target.map(function (t) { return t.values; })
|
|
3998
4022
|
.reduce(function (a, b) { return a.concat(b); })
|
|
3999
4023
|
.map(function (v) { return v.x; });
|
|
4000
4024
|
target = sortValue(getUnique(target))
|
|
4001
|
-
.map(function (x, index) { return ({ x: x, index: index }); });
|
|
4025
|
+
.map(function (x, index, array) { return ({ x: x, index: isInverted ? array.length - index - 1 : index }); });
|
|
4002
4026
|
}
|
|
4003
4027
|
else if (length) {
|
|
4004
4028
|
target = target[0].values.concat();
|
|
@@ -4320,20 +4344,24 @@ var data$1 = {
|
|
|
4320
4344
|
if (!(isCategorized || /step\-(after|before)/.test(stepType))) {
|
|
4321
4345
|
return values;
|
|
4322
4346
|
}
|
|
4323
|
-
//
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4347
|
+
// when all datas are null, return empty array
|
|
4348
|
+
// https://github.com/naver/billboard.js/issues/3124
|
|
4349
|
+
if (converted.length) {
|
|
4350
|
+
// insert & append cloning first/last value to be fully rendered covering on each gap sides
|
|
4351
|
+
var head = converted[0];
|
|
4352
|
+
var tail = converted[converted.length - 1];
|
|
4353
|
+
var id = head.id;
|
|
4354
|
+
var x = head.x;
|
|
4355
|
+
// insert head
|
|
4331
4356
|
converted.unshift({ x: --x, value: head.value, id: id });
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4357
|
+
isCategorized && stepType === "step-after" &&
|
|
4358
|
+
converted.unshift({ x: --x, value: head.value, id: id });
|
|
4359
|
+
// append tail
|
|
4360
|
+
x = tail.x;
|
|
4336
4361
|
converted.push({ x: ++x, value: tail.value, id: id });
|
|
4362
|
+
isCategorized && stepType === "step-before" &&
|
|
4363
|
+
converted.push({ x: ++x, value: tail.value, id: id });
|
|
4364
|
+
}
|
|
4337
4365
|
return converted;
|
|
4338
4366
|
},
|
|
4339
4367
|
convertValuesToRange: function (values) {
|
|
@@ -4519,10 +4547,23 @@ var data$1 = {
|
|
|
4519
4547
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
4520
4548
|
* billboard.js project is licensed under the MIT license
|
|
4521
4549
|
*/
|
|
4550
|
+
/**
|
|
4551
|
+
* Call done callback with resize after transition
|
|
4552
|
+
* @param {Function} fn Callback function
|
|
4553
|
+
* @param {boolean} resizeAfter Weather to resize chart after the load
|
|
4554
|
+
* @private
|
|
4555
|
+
*/
|
|
4556
|
+
function callDone(fn, resizeAfter) {
|
|
4557
|
+
if (resizeAfter === void 0) { resizeAfter = false; }
|
|
4558
|
+
var $$ = this;
|
|
4559
|
+
var api = $$.api;
|
|
4560
|
+
resizeAfter && $$.api.flush(true);
|
|
4561
|
+
fn === null || fn === void 0 ? void 0 : fn.call(api);
|
|
4562
|
+
}
|
|
4522
4563
|
var dataLoad = {
|
|
4523
4564
|
load: function (rawTargets, args) {
|
|
4524
|
-
var _a;
|
|
4525
4565
|
var $$ = this;
|
|
4566
|
+
var data = $$.data;
|
|
4526
4567
|
var append = args.append;
|
|
4527
4568
|
var targets = rawTargets;
|
|
4528
4569
|
if (targets) {
|
|
@@ -4539,7 +4580,7 @@ var dataLoad = {
|
|
|
4539
4580
|
});
|
|
4540
4581
|
}
|
|
4541
4582
|
// Update/Add data
|
|
4542
|
-
|
|
4583
|
+
data.targets.forEach(function (d) {
|
|
4543
4584
|
for (var i = 0; i < targets.length; i++) {
|
|
4544
4585
|
if (d.id === targets[i].id) {
|
|
4545
4586
|
d.values = append ?
|
|
@@ -4549,10 +4590,10 @@ var dataLoad = {
|
|
|
4549
4590
|
}
|
|
4550
4591
|
}
|
|
4551
4592
|
});
|
|
4552
|
-
|
|
4593
|
+
data.targets = data.targets.concat(targets); // add remained
|
|
4553
4594
|
}
|
|
4554
4595
|
// Set targets
|
|
4555
|
-
$$.updateTargets(
|
|
4596
|
+
$$.updateTargets(data.targets);
|
|
4556
4597
|
// Redraw with new targets
|
|
4557
4598
|
$$.redraw({
|
|
4558
4599
|
withUpdateOrgXDomain: true,
|
|
@@ -4561,7 +4602,7 @@ var dataLoad = {
|
|
|
4561
4602
|
});
|
|
4562
4603
|
// Update current state chart type and elements list after redraw
|
|
4563
4604
|
$$.updateTypesElements();
|
|
4564
|
-
(
|
|
4605
|
+
callDone.call($$, args.done, args.resizeAfter);
|
|
4565
4606
|
},
|
|
4566
4607
|
loadFromArgs: function (args) {
|
|
4567
4608
|
var $$ = this;
|
|
@@ -4924,7 +4965,7 @@ var classModule = {
|
|
|
4924
4965
|
};
|
|
4925
4966
|
},
|
|
4926
4967
|
classRegion: function (d, i) {
|
|
4927
|
-
return "".concat(this.generateClass(CLASS.region, i), " ").concat("class" in d ? d
|
|
4968
|
+
return "".concat(this.generateClass(CLASS.region, i), " ").concat("class" in d ? d.class : "");
|
|
4928
4969
|
},
|
|
4929
4970
|
classTarget: function (id) {
|
|
4930
4971
|
var additionalClassSuffix = this.config.data_classes[id];
|
|
@@ -4984,7 +5025,7 @@ var category = {
|
|
|
4984
5025
|
categoryName: function (i) {
|
|
4985
5026
|
var categories = this.config.axis_x_categories;
|
|
4986
5027
|
return i < (categories === null || categories === void 0 ? void 0 : categories.length) ? categories[i] : i;
|
|
4987
|
-
}
|
|
5028
|
+
},
|
|
4988
5029
|
};
|
|
4989
5030
|
|
|
4990
5031
|
/**
|
|
@@ -5425,7 +5466,8 @@ var domain = {
|
|
|
5425
5466
|
*/
|
|
5426
5467
|
getXDomain: function (targets) {
|
|
5427
5468
|
var $$ = this;
|
|
5428
|
-
var axis = $$.axis, x = $$.scale.x;
|
|
5469
|
+
var axis = $$.axis, config = $$.config, x = $$.scale.x;
|
|
5470
|
+
var isInverted = config.axis_x_inverted;
|
|
5429
5471
|
var domain = [
|
|
5430
5472
|
$$.getXDomainMinMax(targets, "min"),
|
|
5431
5473
|
$$.getXDomainMinMax(targets, "max")
|
|
@@ -5454,7 +5496,7 @@ var domain = {
|
|
|
5454
5496
|
max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right;
|
|
5455
5497
|
}
|
|
5456
5498
|
}
|
|
5457
|
-
return [min, max];
|
|
5499
|
+
return isInverted ? [max, min] : [min, max];
|
|
5458
5500
|
},
|
|
5459
5501
|
updateXDomain: function (targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
|
|
5460
5502
|
var _a;
|
|
@@ -5462,7 +5504,7 @@ var domain = {
|
|
|
5462
5504
|
var config = $$.config, org = $$.org, _b = $$.scale, x = _b.x, subX = _b.subX;
|
|
5463
5505
|
var zoomEnabled = config.zoom_enabled;
|
|
5464
5506
|
if (withUpdateOrgXDomain) {
|
|
5465
|
-
x.domain(domain || sortValue($$.getXDomain(targets)));
|
|
5507
|
+
x.domain(domain || sortValue($$.getXDomain(targets), !config.axis_x_inverted));
|
|
5466
5508
|
org.xDomain = x.domain();
|
|
5467
5509
|
zoomEnabled && $$.zoom.updateScaleExtent();
|
|
5468
5510
|
subX.domain(x.domain());
|
|
@@ -5478,14 +5520,22 @@ var domain = {
|
|
|
5478
5520
|
withTrim && x.domain($$.trimXDomain(x.orgDomain()));
|
|
5479
5521
|
return x.domain();
|
|
5480
5522
|
},
|
|
5523
|
+
/**
|
|
5524
|
+
* Trim x domain when given domain surpasses the range
|
|
5525
|
+
* @param {Array} domain Domain value
|
|
5526
|
+
* @returns {Array} Trimed domain if given domain is out of range
|
|
5527
|
+
* @private
|
|
5528
|
+
*/
|
|
5481
5529
|
trimXDomain: function (domain) {
|
|
5482
|
-
var
|
|
5530
|
+
var $$ = this;
|
|
5531
|
+
var isInverted = $$.config.axis_x_inverted;
|
|
5532
|
+
var zoomDomain = $$.getZoomDomain();
|
|
5483
5533
|
var min = zoomDomain[0], max = zoomDomain[1];
|
|
5484
|
-
if (domain[0] <= min) {
|
|
5485
|
-
domain[1] = +domain[1] + (min - domain[0]);
|
|
5534
|
+
if (isInverted ? domain[0] >= min : domain[0] <= min) {
|
|
5486
5535
|
domain[0] = min;
|
|
5536
|
+
domain[1] = +domain[1] + (min - domain[0]);
|
|
5487
5537
|
}
|
|
5488
|
-
if (
|
|
5538
|
+
if (isInverted ? domain[1] <= max : domain[1] >= max) {
|
|
5489
5539
|
domain[0] = +domain[0] - (domain[1] - max);
|
|
5490
5540
|
domain[1] = max;
|
|
5491
5541
|
}
|
|
@@ -5806,10 +5856,12 @@ var legend$1 = {
|
|
|
5806
5856
|
* @private
|
|
5807
5857
|
*/
|
|
5808
5858
|
getLegendHeight: function () {
|
|
5859
|
+
var _a;
|
|
5809
5860
|
var $$ = this;
|
|
5810
|
-
var
|
|
5861
|
+
var _b = $$.state, current = _b.current, isLegendRight = _b.isLegendRight, legendItemHeight = _b.legendItemHeight, legendStep = _b.legendStep;
|
|
5862
|
+
var isFitPadding = ((_a = $$.config.padding) === null || _a === void 0 ? void 0 : _a.mode) === "fit";
|
|
5811
5863
|
return $$.config.legend_show ? (isLegendRight ?
|
|
5812
|
-
current.height : Math.max(20, legendItemHeight) * (legendStep + 1)) : 0;
|
|
5864
|
+
current.height : (isFitPadding ? 10 : Math.max(20, legendItemHeight)) * (legendStep + 1)) : 0;
|
|
5813
5865
|
},
|
|
5814
5866
|
/**
|
|
5815
5867
|
* Get the opacity of the legend that is unfocused
|
|
@@ -6521,20 +6573,6 @@ var redraw = {
|
|
|
6521
6573
|
}
|
|
6522
6574
|
// Draw with new sizes & scales
|
|
6523
6575
|
$$.redraw(options, transitions);
|
|
6524
|
-
},
|
|
6525
|
-
/**
|
|
6526
|
-
* Redraw without rescale
|
|
6527
|
-
* @private
|
|
6528
|
-
*/
|
|
6529
|
-
redrawWithoutRescale: function () {
|
|
6530
|
-
this.redraw({
|
|
6531
|
-
withY: false,
|
|
6532
|
-
withDimension: false,
|
|
6533
|
-
withLegend: false,
|
|
6534
|
-
withSubchart: false,
|
|
6535
|
-
withEventRect: false,
|
|
6536
|
-
withTransitionForAxis: false
|
|
6537
|
-
});
|
|
6538
6576
|
}
|
|
6539
6577
|
};
|
|
6540
6578
|
|
|
@@ -6578,7 +6616,7 @@ var scale = {
|
|
|
6578
6616
|
getXScale: function (min, max, domain, offset) {
|
|
6579
6617
|
var $$ = this;
|
|
6580
6618
|
var scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
|
|
6581
|
-
return $$.
|
|
6619
|
+
return $$.getCustomizedXScale(domain ? scale.domain(domain) : scale, offset);
|
|
6582
6620
|
},
|
|
6583
6621
|
/**
|
|
6584
6622
|
* Get y Axis scale function
|
|
@@ -6610,15 +6648,16 @@ var scale = {
|
|
|
6610
6648
|
return this.scale[key];
|
|
6611
6649
|
},
|
|
6612
6650
|
/**
|
|
6613
|
-
* Get customized scale
|
|
6651
|
+
* Get customized x axis scale
|
|
6614
6652
|
* @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
|
|
6615
6653
|
* @param {Function} offsetValue Offset getter to be sum
|
|
6616
6654
|
* @returns {Function} Scale function
|
|
6617
6655
|
* @private
|
|
6618
6656
|
*/
|
|
6619
|
-
|
|
6657
|
+
getCustomizedXScale: function (scaleValue, offsetValue) {
|
|
6620
6658
|
var $$ = this;
|
|
6621
6659
|
var offset = offsetValue || (function () { return $$.axis.x.tickOffset(); });
|
|
6660
|
+
var isInverted = $$.config.axis_x_inverted;
|
|
6622
6661
|
var scale = function (d, raw) {
|
|
6623
6662
|
var v = scaleValue(d) + offset();
|
|
6624
6663
|
return raw ? v : Math.ceil(v);
|
|
@@ -6635,7 +6674,9 @@ var scale = {
|
|
|
6635
6674
|
var domain = domainValue;
|
|
6636
6675
|
if (!arguments.length) {
|
|
6637
6676
|
domain = this.orgDomain();
|
|
6638
|
-
return
|
|
6677
|
+
return isInverted ?
|
|
6678
|
+
[domain[0] + 1, domain[1]] :
|
|
6679
|
+
[domain[0], domain[1] + 1];
|
|
6639
6680
|
}
|
|
6640
6681
|
scaleValue.domain(domain);
|
|
6641
6682
|
return scale;
|
|
@@ -7197,50 +7238,63 @@ var size = {
|
|
|
7197
7238
|
return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
|
|
7198
7239
|
},
|
|
7199
7240
|
getCurrentPaddingLeft: function (withoutRecompute) {
|
|
7241
|
+
var _a;
|
|
7200
7242
|
var $$ = this;
|
|
7201
7243
|
var config = $$.config, hasAxis = $$.state.hasAxis;
|
|
7202
7244
|
var isRotated = config.axis_rotated;
|
|
7245
|
+
var isFitPadding = ((_a = config.padding) === null || _a === void 0 ? void 0 : _a.mode) === "fit";
|
|
7203
7246
|
var axisId = isRotated ? "x" : "y";
|
|
7204
7247
|
var axesLen = hasAxis ? config["axis_".concat(axisId, "_axes")].length : 0;
|
|
7205
7248
|
var axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0;
|
|
7206
|
-
|
|
7249
|
+
if (!isFitPadding) {
|
|
7250
|
+
axisWidth = ceil10(axisWidth);
|
|
7251
|
+
}
|
|
7252
|
+
var padding = config["axis_".concat(axisId, "_inner")] || !config["axis_".concat(axisId, "_show")] ? 0 : axisWidth;
|
|
7207
7253
|
if (isValue(config.padding_left)) {
|
|
7208
|
-
padding = config.padding_left;
|
|
7254
|
+
padding = config.padding_left + (isFitPadding && isRotated ? axisWidth : 0);
|
|
7209
7255
|
}
|
|
7210
7256
|
else if (hasAxis && isRotated) {
|
|
7211
7257
|
padding = !config.axis_x_show ?
|
|
7212
|
-
1 : Math.max(
|
|
7258
|
+
1 : (isFitPadding ? axisWidth : Math.max(axisWidth, 40));
|
|
7213
7259
|
}
|
|
7214
|
-
|
|
7215
|
-
padding
|
|
7216
|
-
}
|
|
7217
|
-
else {
|
|
7218
|
-
padding = ceil10(axisWidth);
|
|
7260
|
+
if (hasAxis && (isFitPadding || config["axis_".concat(axisId, "_inner")]) && config["axis_".concat(axisId, "_label")].text) {
|
|
7261
|
+
padding += $$.axis.getAxisLabelPosition("y").isOuter ? 20 : 0;
|
|
7219
7262
|
}
|
|
7220
7263
|
return padding + (axisWidth * axesLen);
|
|
7221
7264
|
},
|
|
7222
7265
|
getCurrentPaddingRight: function (withXAxisTickTextOverflow) {
|
|
7266
|
+
var _a, _b;
|
|
7223
7267
|
if (withXAxisTickTextOverflow === void 0) { withXAxisTickTextOverflow = false; }
|
|
7224
7268
|
var $$ = this;
|
|
7225
7269
|
var config = $$.config, hasAxis = $$.state.hasAxis;
|
|
7226
|
-
var
|
|
7270
|
+
var isRotated = config.axis_rotated;
|
|
7271
|
+
var isFitPadding = ((_a = config.padding) === null || _a === void 0 ? void 0 : _a.mode) === "fit";
|
|
7272
|
+
var defaultPadding = isFitPadding ? 2 : 10;
|
|
7227
7273
|
var legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0;
|
|
7228
7274
|
var axesLen = hasAxis ? config.axis_y2_axes.length : 0;
|
|
7229
|
-
var
|
|
7275
|
+
var axisLabelWidth = ((_b = $$.axis) === null || _b === void 0 ? void 0 : _b.getAxisLabelPosition("y2").isOuter) ? 20 : 0;
|
|
7230
7276
|
var xAxisTickTextOverflow = withXAxisTickTextOverflow ?
|
|
7231
7277
|
$$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
|
|
7232
|
-
var
|
|
7278
|
+
var axisWidth = hasAxis && !config.axis_y2_inner ? $$.getAxisWidthByAxisId("y2") : 1;
|
|
7279
|
+
if (!isFitPadding) {
|
|
7280
|
+
axisWidth = ceil10(axisWidth);
|
|
7281
|
+
}
|
|
7282
|
+
var padding = isRotated ? 0 : Math.max(axisWidth + legendWidthOnRight, xAxisTickTextOverflow);
|
|
7233
7283
|
if (isValue(config.padding_right)) {
|
|
7234
|
-
padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
|
|
7284
|
+
// padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
|
|
7285
|
+
padding = config.padding_right +
|
|
7286
|
+
(isFitPadding && (isRotated || !config.axis_y2_show ? defaultPadding : padding)) +
|
|
7287
|
+
(hasAxis && !isFitPadding ? 1 : 0); // 1 is needed not to hide tick line
|
|
7235
7288
|
}
|
|
7236
|
-
else if ($$.axis &&
|
|
7289
|
+
else if ($$.axis && isRotated) {
|
|
7237
7290
|
padding = defaultPadding + legendWidthOnRight;
|
|
7238
7291
|
}
|
|
7239
|
-
else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
|
|
7240
|
-
padding = Math.max(
|
|
7292
|
+
else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
|
|
7293
|
+
padding = Math.max((isFitPadding && !config.axis_y2_show ? 2 : 1) + legendWidthOnRight + axisLabelWidth, xAxisTickTextOverflow);
|
|
7241
7294
|
}
|
|
7242
|
-
|
|
7243
|
-
|
|
7295
|
+
if (hasAxis && !isRotated && isFitPadding &&
|
|
7296
|
+
config.axis_y2_show && !config.axis_y2_inner && config.axis_y2_label.text) {
|
|
7297
|
+
padding += axisLabelWidth;
|
|
7244
7298
|
}
|
|
7245
7299
|
return padding + (axisWidth * axesLen);
|
|
7246
7300
|
},
|
|
@@ -7380,11 +7434,12 @@ var size = {
|
|
|
7380
7434
|
* @private
|
|
7381
7435
|
*/
|
|
7382
7436
|
updateSizes: function (isInit) {
|
|
7383
|
-
var _a, _b;
|
|
7437
|
+
var _a, _b, _c;
|
|
7384
7438
|
var $$ = this;
|
|
7385
7439
|
var config = $$.config, state = $$.state, legend = $$.$el.legend;
|
|
7386
7440
|
var isRotated = config.axis_rotated;
|
|
7387
7441
|
var isNonAxis = $$.hasArcType() || state.hasTreemap;
|
|
7442
|
+
var isFitPadding = ((_a = config.padding) === null || _a === void 0 ? void 0 : _a.mode) === "fit";
|
|
7388
7443
|
!isInit && $$.setContainerSize();
|
|
7389
7444
|
var currLegend = {
|
|
7390
7445
|
width: legend ? $$.getLegendWidth() : 0,
|
|
@@ -7407,7 +7462,7 @@ var size = {
|
|
|
7407
7462
|
bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + padding.bottom,
|
|
7408
7463
|
left: subchartHeight + (isNonAxis ? 0 : padding.left)
|
|
7409
7464
|
} : {
|
|
7410
|
-
top: 4 + padding.top,
|
|
7465
|
+
top: (isFitPadding ? 0 : 4) + padding.top,
|
|
7411
7466
|
right: isNonAxis ? 0 : $$.getCurrentPaddingRight(true),
|
|
7412
7467
|
bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
|
|
7413
7468
|
left: isNonAxis ? 0 : padding.left
|
|
@@ -7432,7 +7487,7 @@ var size = {
|
|
|
7432
7487
|
bottom: 0,
|
|
7433
7488
|
left: 0
|
|
7434
7489
|
};
|
|
7435
|
-
(
|
|
7490
|
+
(_b = $$.updateSizeForLegend) === null || _b === void 0 ? void 0 : _b.call($$, currLegend);
|
|
7436
7491
|
state.width = state.current.width - state.margin.left - state.margin.right;
|
|
7437
7492
|
state.height = state.current.height - state.margin.top - state.margin.bottom;
|
|
7438
7493
|
if (state.width < 0) {
|
|
@@ -7460,7 +7515,7 @@ var size = {
|
|
|
7460
7515
|
if (hasGauge && !config.gauge_fullCircle) {
|
|
7461
7516
|
state.arcHeight += state.height - $$.getPaddingBottomForGauge();
|
|
7462
7517
|
}
|
|
7463
|
-
(
|
|
7518
|
+
(_c = $$.updateRadius) === null || _c === void 0 ? void 0 : _c.call($$);
|
|
7464
7519
|
}
|
|
7465
7520
|
if (state.isLegendRight && isNonAxis) {
|
|
7466
7521
|
state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
|
|
@@ -8170,7 +8225,7 @@ var title = {
|
|
|
8170
8225
|
getTitlePadding: function () {
|
|
8171
8226
|
var $$ = this;
|
|
8172
8227
|
return $$.yForTitle() + ($$.config.title_padding.bottom || 0);
|
|
8173
|
-
}
|
|
8228
|
+
},
|
|
8174
8229
|
};
|
|
8175
8230
|
|
|
8176
8231
|
var tooltip$1 = {
|
|
@@ -8595,7 +8650,7 @@ var transform = {
|
|
|
8595
8650
|
}
|
|
8596
8651
|
else if (target === "y2") {
|
|
8597
8652
|
x = isRotated ? 0 : state.width + padding;
|
|
8598
|
-
y = isRotated ? 1 - padding : 0;
|
|
8653
|
+
y = isRotated && padding ? 1 - padding : 0;
|
|
8599
8654
|
}
|
|
8600
8655
|
else if (target === "subX") {
|
|
8601
8656
|
x = 0;
|
|
@@ -8651,6 +8706,15 @@ var transform = {
|
|
|
8651
8706
|
* billboard.js project is licensed under the MIT license
|
|
8652
8707
|
*/
|
|
8653
8708
|
var typeInternals = {
|
|
8709
|
+
/**
|
|
8710
|
+
* Check if the given chart type is valid
|
|
8711
|
+
* @param {string} type Chart type string
|
|
8712
|
+
* @returns {boolean}
|
|
8713
|
+
* @private
|
|
8714
|
+
*/
|
|
8715
|
+
isValidChartType: function (type) {
|
|
8716
|
+
return !!(type && Object.values(TYPE).indexOf(type) > -1);
|
|
8717
|
+
},
|
|
8654
8718
|
setTargetType: function (targetIds, type) {
|
|
8655
8719
|
var $$ = this;
|
|
8656
8720
|
var config = $$.config, withoutFadeIn = $$.state.withoutFadeIn;
|
|
@@ -9136,7 +9200,7 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9136
9200
|
var x = scale.x, y = scale.y, y2 = scale.y2, subX = scale.subX, subY = scale.subY, subY2 = scale.subY2;
|
|
9137
9201
|
// Set domains for each scale
|
|
9138
9202
|
if (x) {
|
|
9139
|
-
x.domain(sortValue($$.getXDomain($$.data.targets)));
|
|
9203
|
+
x.domain(sortValue($$.getXDomain($$.data.targets), !config.axis_x_inverted));
|
|
9140
9204
|
subX.domain(x.domain());
|
|
9141
9205
|
// Save original x domain for zoom update
|
|
9142
9206
|
org.xDomain = x.domain();
|
|
@@ -9328,7 +9392,7 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9328
9392
|
.attr("clip-path", state.clip.path);
|
|
9329
9393
|
}
|
|
9330
9394
|
element
|
|
9331
|
-
.attr("class", bg
|
|
9395
|
+
.attr("class", bg.class || null)
|
|
9332
9396
|
.attr("width", "100%")
|
|
9333
9397
|
.attr("height", "100%");
|
|
9334
9398
|
}
|
|
@@ -9609,7 +9673,7 @@ var apiChart = {
|
|
|
9609
9673
|
}) : $$.updateAndRedraw({
|
|
9610
9674
|
withLegend: true,
|
|
9611
9675
|
withTransition: false,
|
|
9612
|
-
withTransitionForTransform: false
|
|
9676
|
+
withTransitionForTransform: false,
|
|
9613
9677
|
});
|
|
9614
9678
|
// reset subchart selection & selection state
|
|
9615
9679
|
if (!state.resizing && $$.brush) {
|
|
@@ -10115,7 +10179,7 @@ var apiExport = {
|
|
|
10115
10179
|
* dataUrl => { ... }
|
|
10116
10180
|
* );
|
|
10117
10181
|
*/
|
|
10118
|
-
|
|
10182
|
+
export: function (option, callback) {
|
|
10119
10183
|
var _this = this;
|
|
10120
10184
|
var $$ = this.internal;
|
|
10121
10185
|
var state = $$.state, _a = $$.$el, chart = _a.chart, svg = _a.svg;
|
|
@@ -10223,17 +10287,17 @@ var apiFocus = {
|
|
|
10223
10287
|
state.defocusedTargetIds = targetIds;
|
|
10224
10288
|
},
|
|
10225
10289
|
/**
|
|
10226
|
-
*
|
|
10227
|
-
* You can specify multiple targets by giving an array that includes id as
|
|
10290
|
+
* Revert focused or defocused state to initial state.<br><br>
|
|
10291
|
+
* You can specify multiple targets by giving an array that includes id as string. If no argument is given, all of targets will be reverted.
|
|
10228
10292
|
* @function revert
|
|
10229
10293
|
* @instance
|
|
10230
10294
|
* @memberof Chart
|
|
10231
10295
|
* @param {string|Array} targetIdsValue Target ids to be reverted
|
|
10232
10296
|
* @example
|
|
10233
|
-
* // data1 will be reverted.
|
|
10297
|
+
* // 'data1' will be reverted.
|
|
10234
10298
|
* chart.revert("data1");
|
|
10235
10299
|
*
|
|
10236
|
-
* // data1 and data2 will be reverted.
|
|
10300
|
+
* // 'data1' and 'data2' will be reverted.
|
|
10237
10301
|
* chart.revert(["data1", "data2"]);
|
|
10238
10302
|
*
|
|
10239
10303
|
* // all targets will be reverted.
|
|
@@ -10338,23 +10402,29 @@ var apiLoad = {
|
|
|
10338
10402
|
* @memberof Chart
|
|
10339
10403
|
* @param {object} args The object can consist with following members:<br>
|
|
10340
10404
|
*
|
|
10341
|
-
* | Key | Description |
|
|
10342
|
-
* | --- | --- |
|
|
10343
|
-
* |
|
|
10344
|
-
* |
|
|
10345
|
-
* |
|
|
10346
|
-
* |
|
|
10347
|
-
* |
|
|
10348
|
-
* |
|
|
10349
|
-
* |
|
|
10350
|
-
* |
|
|
10351
|
-
* |
|
|
10352
|
-
* |
|
|
10353
|
-
* |
|
|
10354
|
-
* |
|
|
10355
|
-
* |
|
|
10356
|
-
* |
|
|
10357
|
-
* |
|
|
10405
|
+
* | Key | Type | Description |
|
|
10406
|
+
* | --- | --- | --- |
|
|
10407
|
+
* | columns | Array | The `columns` data will be loaded. If data that has the same target id is given, the chart will be updated. Otherwise, new target will be added |
|
|
10408
|
+
* | json | Array | The `json` data will be loaded. If data that has the same target id is given, the chart will be updated. Otherwise, new target will be added |
|
|
10409
|
+
* | rows | Array | The `rows` data will be loaded. If data that has the same target id is given, the chart will be updated. Otherwise, new target will be added |
|
|
10410
|
+
* | url | string | The data from `url` will be loaded. If data that has the same target id is given, the chart will be updated. Otherwise, new target will be added |
|
|
10411
|
+
* | | | |
|
|
10412
|
+
* | append | boolean | Load data appending it to the current dataseries.<br>If the existing chart has`x` value, should provide with corresponding `x` value for newly loaded data. |
|
|
10413
|
+
* | axes | Object | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
|
|
10414
|
+
* | categories | Array | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
|
|
10415
|
+
* | classes | Object | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
|
|
10416
|
+
* | colors | Object | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
|
|
10417
|
+
* | data | Obejct | Data objects to be loaded. Checkout the example. |
|
|
10418
|
+
* | done | Function | The specified function will be called after data loaded.|
|
|
10419
|
+
* | headers | string | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
|
|
10420
|
+
* | keys | Object | Choose which JSON objects keys correspond to desired data.<br>**NOTE:** Only for JSON object given as array.<br>@see [data․keys](Options.html#.data%25E2%2580%25A4keys) |
|
|
10421
|
+
* | mimeType | string | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
|
|
10422
|
+
* | names | Object | Same as data.names() |
|
|
10423
|
+
* | resizeAfter | boolean | Resize after the load. Default value is `false`.<br>- This option won't call `onresize` neither `onresized`.<br>- When set to 'true', will call `.flush(true)` at the end of load. |
|
|
10424
|
+
* | type | string | The type of targets will be updated. |
|
|
10425
|
+
* | types | Object | The types of targets will be updated. |
|
|
10426
|
+
* | unload | Array | Specify the data will be unloaded before loading new data. If true given, all of data will be unloaded. If target ids given as String or Array, specified targets will be unloaded. If absent or false given, unload will not occur. |
|
|
10427
|
+
* | xs | string | Same as data.xs option |
|
|
10358
10428
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataFromURL)
|
|
10359
10429
|
* @example
|
|
10360
10430
|
* // Load data1 and unload data2 and data3
|
|
@@ -10366,6 +10436,7 @@ var apiLoad = {
|
|
|
10366
10436
|
* unload: ["data2", "data3"],
|
|
10367
10437
|
* url: "...",
|
|
10368
10438
|
* done: function() { ... }
|
|
10439
|
+
* resizeAfter: true // will resize after load
|
|
10369
10440
|
* });
|
|
10370
10441
|
* @example
|
|
10371
10442
|
* const chart = bb.generate({
|
|
@@ -10483,7 +10554,7 @@ var apiLoad = {
|
|
|
10483
10554
|
$$.unload($$.mapToTargetIds(args.unload === true ? null : args.unload), function () {
|
|
10484
10555
|
// to mitigate improper rendering for multiple consecutive calls
|
|
10485
10556
|
// https://github.com/naver/billboard.js/issues/2121
|
|
10486
|
-
|
|
10557
|
+
requestIdleCallback(function () { return $$.loadFromArgs(args); });
|
|
10487
10558
|
});
|
|
10488
10559
|
}
|
|
10489
10560
|
else {
|
|
@@ -10505,17 +10576,18 @@ var apiLoad = {
|
|
|
10505
10576
|
* | --- | --- | --- |
|
|
10506
10577
|
* | ids | String | Array | Target id data to be unloaded. If not given, all data will be unloaded. |
|
|
10507
10578
|
* | done | Fuction | Callback after data is unloaded. |
|
|
10579
|
+
* | resizeAfter | boolean | Resize after the unload. Default value is `false`.<br>- This option won't call `onresize` neither `onresized`.<br>- When set to 'true', will call `.flush(true)` at the end of unload. |
|
|
10508
10580
|
* @example
|
|
10509
10581
|
* // Unload data2 and data3
|
|
10510
10582
|
* chart.unload({
|
|
10511
10583
|
* ids: ["data2", "data3"],
|
|
10512
10584
|
* done: function() {
|
|
10513
10585
|
* // called after the unloaded
|
|
10514
|
-
* }
|
|
10586
|
+
* },
|
|
10587
|
+
* resizeAfter: true // will resize after unload
|
|
10515
10588
|
* });
|
|
10516
10589
|
*/
|
|
10517
10590
|
unload: function (argsValue) {
|
|
10518
|
-
var _this = this;
|
|
10519
10591
|
var $$ = this.internal;
|
|
10520
10592
|
var args = argsValue || {};
|
|
10521
10593
|
if (isArray(args)) {
|
|
@@ -10532,7 +10604,7 @@ var apiLoad = {
|
|
|
10532
10604
|
withLegend: true
|
|
10533
10605
|
});
|
|
10534
10606
|
$$.cache.remove(ids);
|
|
10535
|
-
args.done
|
|
10607
|
+
callDone.call($$, args.done, args.resizeAfter);
|
|
10536
10608
|
});
|
|
10537
10609
|
}
|
|
10538
10610
|
};
|
|
@@ -11184,13 +11256,53 @@ var apiCategory = {
|
|
|
11184
11256
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
11185
11257
|
* billboard.js project is licensed under the MIT license
|
|
11186
11258
|
*/
|
|
11259
|
+
/**
|
|
11260
|
+
* Update grid lines.
|
|
11261
|
+
* @param {Array} grids grid lines to update
|
|
11262
|
+
* @param {string} axisId axis' id: "x" or "y"
|
|
11263
|
+
* @returns {Array}
|
|
11264
|
+
* @private
|
|
11265
|
+
*/
|
|
11266
|
+
function grid$1(grids, axisId) {
|
|
11267
|
+
var $$ = this.internal;
|
|
11268
|
+
var config = $$.config;
|
|
11269
|
+
var withTransition = config.transition_duration && isTabVisible();
|
|
11270
|
+
var gridPropLines = "grid_".concat(axisId, "_lines");
|
|
11271
|
+
if (!grids) {
|
|
11272
|
+
return config[gridPropLines];
|
|
11273
|
+
}
|
|
11274
|
+
config[gridPropLines] = grids;
|
|
11275
|
+
$$.updateGrid();
|
|
11276
|
+
$$.redrawGrid(withTransition);
|
|
11277
|
+
return config[gridPropLines];
|
|
11278
|
+
}
|
|
11279
|
+
/**
|
|
11280
|
+
* Add grid lines.
|
|
11281
|
+
* @param {Array|object} grids grid lines to add
|
|
11282
|
+
* @param {string} axisId axis' id: "x" or "y"
|
|
11283
|
+
* @returns {Array}
|
|
11284
|
+
* @private
|
|
11285
|
+
*/
|
|
11286
|
+
function add(grids, axisId) {
|
|
11287
|
+
var gridPropLines = "grid_".concat(axisId, "_lines");
|
|
11288
|
+
return grid$1.bind(this)(this.internal.config[gridPropLines].concat(grids || []), axisId);
|
|
11289
|
+
}
|
|
11290
|
+
/**
|
|
11291
|
+
* Remove grid lines.
|
|
11292
|
+
* @param {object} grids grid lines to remove
|
|
11293
|
+
* @param {boolean} isXAxis weather is x axis or not
|
|
11294
|
+
* @private
|
|
11295
|
+
*/
|
|
11296
|
+
function remove(grids, isXAxis) {
|
|
11297
|
+
this.internal.removeGridLines(grids, isXAxis);
|
|
11298
|
+
}
|
|
11187
11299
|
/**
|
|
11188
11300
|
* Update x grid lines.
|
|
11189
11301
|
* @function xgrids
|
|
11190
11302
|
* @instance
|
|
11191
11303
|
* @memberof Chart
|
|
11192
11304
|
* @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
|
|
11193
|
-
* @returns {
|
|
11305
|
+
* @returns {Array}
|
|
11194
11306
|
* @example
|
|
11195
11307
|
* // Show 2 x grid lines
|
|
11196
11308
|
* chart.xgrids([
|
|
@@ -11200,14 +11312,7 @@ var apiCategory = {
|
|
|
11200
11312
|
* // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
|
|
11201
11313
|
*/
|
|
11202
11314
|
var xgrids = function (grids) {
|
|
11203
|
-
|
|
11204
|
-
var config = $$.config;
|
|
11205
|
-
if (!grids) {
|
|
11206
|
-
return config.grid_x_lines;
|
|
11207
|
-
}
|
|
11208
|
-
config.grid_x_lines = grids;
|
|
11209
|
-
$$.redrawWithoutRescale();
|
|
11210
|
-
return config.grid_x_lines;
|
|
11315
|
+
return grid$1.bind(this)(grids, "x");
|
|
11211
11316
|
};
|
|
11212
11317
|
extend(xgrids, {
|
|
11213
11318
|
/**
|
|
@@ -11217,7 +11322,7 @@ extend(xgrids, {
|
|
|
11217
11322
|
* @instance
|
|
11218
11323
|
* @memberof Chart
|
|
11219
11324
|
* @param {Array|object} grids New x grid lines will be added. The format of this argument is the same as grid.x.lines and it's possible to give an Object if only one line will be added.
|
|
11220
|
-
* @returns {
|
|
11325
|
+
* @returns {Array}
|
|
11221
11326
|
* @example
|
|
11222
11327
|
* // Add a new x grid line
|
|
11223
11328
|
* chart.xgrids.add(
|
|
@@ -11231,8 +11336,7 @@ extend(xgrids, {
|
|
|
11231
11336
|
* ]);
|
|
11232
11337
|
*/
|
|
11233
11338
|
add: function (grids) {
|
|
11234
|
-
return
|
|
11235
|
-
.concat(grids || []));
|
|
11339
|
+
return add.bind(this)(grids, "x");
|
|
11236
11340
|
},
|
|
11237
11341
|
/**
|
|
11238
11342
|
* Remove x grid lines.<br>
|
|
@@ -11240,7 +11344,10 @@ extend(xgrids, {
|
|
|
11240
11344
|
* @function xgrids․remove
|
|
11241
11345
|
* @instance
|
|
11242
11346
|
* @memberof Chart
|
|
11243
|
-
* @param {object}
|
|
11347
|
+
* @param {object} grids This argument should include value or class. If value is given, the x grid lines that have specified x value will be removed. If class is given, the x grid lines that have specified class will be removed. If args is not given, all of x grid lines will be removed.
|
|
11348
|
+
* @param {number} [grids.value] target value
|
|
11349
|
+
* @param {string} [grids.class] target class
|
|
11350
|
+
* @returns {void}
|
|
11244
11351
|
* @example
|
|
11245
11352
|
* // x grid line on x = 2 will be removed
|
|
11246
11353
|
* chart.xgrids.remove({value: 2});
|
|
@@ -11253,16 +11360,10 @@ extend(xgrids, {
|
|
|
11253
11360
|
* // all of x grid lines will be removed
|
|
11254
11361
|
* chart.xgrids.remove();
|
|
11255
11362
|
*/
|
|
11256
|
-
remove: function (
|
|
11257
|
-
|
|
11363
|
+
remove: function (grids) {
|
|
11364
|
+
return remove.bind(this)(grids, true);
|
|
11258
11365
|
}
|
|
11259
11366
|
});
|
|
11260
|
-
var apiXGrid = { xgrids: xgrids };
|
|
11261
|
-
|
|
11262
|
-
/**
|
|
11263
|
-
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
11264
|
-
* billboard.js project is licensed under the MIT license
|
|
11265
|
-
*/
|
|
11266
11367
|
/**
|
|
11267
11368
|
* Update y grid lines.
|
|
11268
11369
|
* @function ygrids
|
|
@@ -11279,14 +11380,7 @@ var apiXGrid = { xgrids: xgrids };
|
|
|
11279
11380
|
* // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
|
|
11280
11381
|
*/
|
|
11281
11382
|
var ygrids = function (grids) {
|
|
11282
|
-
|
|
11283
|
-
var config = $$.config;
|
|
11284
|
-
if (!grids) {
|
|
11285
|
-
return config.grid_y_lines;
|
|
11286
|
-
}
|
|
11287
|
-
config.grid_y_lines = grids;
|
|
11288
|
-
$$.redrawWithoutRescale();
|
|
11289
|
-
return config.grid_y_lines;
|
|
11383
|
+
return grid$1.bind(this)(grids, "y");
|
|
11290
11384
|
};
|
|
11291
11385
|
extend(ygrids, {
|
|
11292
11386
|
/**
|
|
@@ -11310,8 +11404,7 @@ extend(ygrids, {
|
|
|
11310
11404
|
* ]);
|
|
11311
11405
|
*/
|
|
11312
11406
|
add: function (grids) {
|
|
11313
|
-
return
|
|
11314
|
-
.concat(grids || []));
|
|
11407
|
+
return add.bind(this)(grids, "y");
|
|
11315
11408
|
},
|
|
11316
11409
|
/**
|
|
11317
11410
|
* Remove y grid lines.<br>
|
|
@@ -11319,9 +11412,10 @@ extend(ygrids, {
|
|
|
11319
11412
|
* @function ygrids․remove
|
|
11320
11413
|
* @instance
|
|
11321
11414
|
* @memberof Chart
|
|
11322
|
-
* @param {object}
|
|
11323
|
-
* @param {number} [
|
|
11324
|
-
* @param {string} [
|
|
11415
|
+
* @param {object} grids This argument should include value or class. If value is given, the y grid lines that have specified y value will be removed. If class is given, the y grid lines that have specified class will be removed. If args is not given, all of y grid lines will be removed.
|
|
11416
|
+
* @param {number} [grids.value] target value
|
|
11417
|
+
* @param {string} [grids.class] target class
|
|
11418
|
+
* @returns {void}
|
|
11325
11419
|
* @example
|
|
11326
11420
|
* // y grid line on y = 200 will be removed
|
|
11327
11421
|
* chart.ygrids.remove({value: 200});
|
|
@@ -11334,11 +11428,11 @@ extend(ygrids, {
|
|
|
11334
11428
|
* // all of y grid lines will be removed
|
|
11335
11429
|
* chart.ygrids.remove();
|
|
11336
11430
|
*/
|
|
11337
|
-
remove: function (
|
|
11338
|
-
|
|
11431
|
+
remove: function (grids) {
|
|
11432
|
+
return remove.bind(this)(grids, false);
|
|
11339
11433
|
}
|
|
11340
11434
|
});
|
|
11341
|
-
var
|
|
11435
|
+
var apiGrid = { xgrids: xgrids, ygrids: ygrids };
|
|
11342
11436
|
|
|
11343
11437
|
/**
|
|
11344
11438
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
@@ -11374,6 +11468,26 @@ var apiGroup = {
|
|
|
11374
11468
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
11375
11469
|
* billboard.js project is licensed under the MIT license
|
|
11376
11470
|
*/
|
|
11471
|
+
/**
|
|
11472
|
+
* Region add/update function
|
|
11473
|
+
* @param {Array} regions Regions will be replaced with this argument. The format of this argument is the same as regions.
|
|
11474
|
+
* @param {boolean} isAdd If true, add new regions, otherwise update regions
|
|
11475
|
+
* @returns {Array} regions
|
|
11476
|
+
* @private
|
|
11477
|
+
*/
|
|
11478
|
+
function regionsFn(regions, isAdd) {
|
|
11479
|
+
if (isAdd === void 0) { isAdd = false; }
|
|
11480
|
+
var $$ = this.internal;
|
|
11481
|
+
var config = $$.config;
|
|
11482
|
+
var withTransition = config.transition_duration && isTabVisible();
|
|
11483
|
+
if (!regions) {
|
|
11484
|
+
return config.regions;
|
|
11485
|
+
}
|
|
11486
|
+
config.regions = isAdd ? config.regions.concat(regions) : regions;
|
|
11487
|
+
$$.updateRegion();
|
|
11488
|
+
$$.redrawRegion(withTransition);
|
|
11489
|
+
return isAdd ? config.regions : regions;
|
|
11490
|
+
}
|
|
11377
11491
|
/**
|
|
11378
11492
|
* Update regions.
|
|
11379
11493
|
* @function regions
|
|
@@ -11389,14 +11503,7 @@ var apiGroup = {
|
|
|
11389
11503
|
* ]);
|
|
11390
11504
|
*/
|
|
11391
11505
|
var regions = function (regions) {
|
|
11392
|
-
|
|
11393
|
-
var config = $$.config;
|
|
11394
|
-
if (!regions) {
|
|
11395
|
-
return config.regions;
|
|
11396
|
-
}
|
|
11397
|
-
config.regions = regions;
|
|
11398
|
-
$$.redrawWithoutRescale();
|
|
11399
|
-
return regions;
|
|
11506
|
+
return regionsFn.bind(this)(regions);
|
|
11400
11507
|
};
|
|
11401
11508
|
extend(regions, {
|
|
11402
11509
|
/**
|
|
@@ -11420,14 +11527,7 @@ extend(regions, {
|
|
|
11420
11527
|
*]);
|
|
11421
11528
|
*/
|
|
11422
11529
|
add: function (regions) {
|
|
11423
|
-
|
|
11424
|
-
var config = $$.config;
|
|
11425
|
-
if (!regions) {
|
|
11426
|
-
return config.regions;
|
|
11427
|
-
}
|
|
11428
|
-
config.regions = config.regions.concat(regions);
|
|
11429
|
-
$$.redrawWithoutRescale();
|
|
11430
|
-
return config.regions;
|
|
11530
|
+
return regionsFn.bind(this)(regions, true);
|
|
11431
11531
|
},
|
|
11432
11532
|
/**
|
|
11433
11533
|
* Remove regions.<br><br>
|
|
@@ -11462,10 +11562,10 @@ extend(regions, {
|
|
|
11462
11562
|
if (Object.keys(options).length) {
|
|
11463
11563
|
regions = regions.filter(function (region) {
|
|
11464
11564
|
var found = false;
|
|
11465
|
-
if (!region
|
|
11565
|
+
if (!region.class) {
|
|
11466
11566
|
return true;
|
|
11467
11567
|
}
|
|
11468
|
-
region
|
|
11568
|
+
region.class.split(" ").forEach(function (c) {
|
|
11469
11569
|
if (classes.indexOf(c) >= 0) {
|
|
11470
11570
|
found = true;
|
|
11471
11571
|
}
|
|
@@ -11731,7 +11831,7 @@ var apiFlow = {
|
|
|
11731
11831
|
length: length,
|
|
11732
11832
|
duration: isValue(args.duration) ? args.duration : $$.config.transition_duration,
|
|
11733
11833
|
done: args.done,
|
|
11734
|
-
orgDataCount: orgDataCount
|
|
11834
|
+
orgDataCount: orgDataCount,
|
|
11735
11835
|
},
|
|
11736
11836
|
withLegend: true,
|
|
11737
11837
|
withTransition: orgDataCount > 1,
|
|
@@ -12193,8 +12293,9 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
12193
12293
|
}
|
|
12194
12294
|
var tickWidth = params.tickWidth;
|
|
12195
12295
|
if (!tickWidth || tickWidth <= 0) {
|
|
12196
|
-
tickWidth = isLeftRight ? 95 : (params.isCategory ?
|
|
12197
|
-
|
|
12296
|
+
tickWidth = isLeftRight ? 95 : (params.isCategory ? (Math.ceil(params.isInverted ?
|
|
12297
|
+
scale(ticks[0]) - scale(ticks[1]) :
|
|
12298
|
+
scale(ticks[1]) - scale(ticks[0])) - 12) : 110);
|
|
12198
12299
|
}
|
|
12199
12300
|
// split given text by tick width size
|
|
12200
12301
|
// eslint-disable-next-line
|
|
@@ -12558,6 +12659,7 @@ var Axis = /** @class */ (function () {
|
|
|
12558
12659
|
owner: $$
|
|
12559
12660
|
}, isX && {
|
|
12560
12661
|
isCategory: isCategory,
|
|
12662
|
+
isInverted: config.axis_x_inverted,
|
|
12561
12663
|
tickMultiline: config.axis_x_tick_multiline,
|
|
12562
12664
|
tickWidth: config.axis_x_tick_width,
|
|
12563
12665
|
tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
|
|
@@ -13132,6 +13234,7 @@ var eventrect = {
|
|
|
13132
13234
|
var $$ = this;
|
|
13133
13235
|
var config = $$.config, state = $$.state, $el = $$.$el;
|
|
13134
13236
|
var isMultipleX = $$.isMultipleX();
|
|
13237
|
+
var isInverted = config.axis_x_inverted;
|
|
13135
13238
|
if ($el.eventRect) {
|
|
13136
13239
|
$$.updateEventRect($el.eventRect, true);
|
|
13137
13240
|
}
|
|
@@ -13160,8 +13263,8 @@ var eventrect = {
|
|
|
13160
13263
|
if (!isMultipleX) {
|
|
13161
13264
|
// Set data and update eventReceiver.data
|
|
13162
13265
|
var xAxisTickValues = $$.getMaxDataCountTarget();
|
|
13163
|
-
if (!config.data_xSort) {
|
|
13164
|
-
xAxisTickValues.sort(function (a, b) { return a.x - b.x; });
|
|
13266
|
+
if (!config.data_xSort || isInverted) {
|
|
13267
|
+
xAxisTickValues.sort(function (a, b) { return (isInverted ? b.x - a.x : a.x - b.x); });
|
|
13165
13268
|
}
|
|
13166
13269
|
// update data's index value to be alinged with the x Axis
|
|
13167
13270
|
$$.updateDataIndexByX(xAxisTickValues);
|
|
@@ -13847,15 +13950,17 @@ var clip = {
|
|
|
13847
13950
|
* @private
|
|
13848
13951
|
*/
|
|
13849
13952
|
setYAxisClipPath: function (node) {
|
|
13953
|
+
var _a;
|
|
13850
13954
|
var $$ = this;
|
|
13851
|
-
var config = $$.config,
|
|
13955
|
+
var config = $$.config, _b = $$.state, margin = _b.margin, width = _b.width, height = _b.height;
|
|
13852
13956
|
var isRotated = config.axis_rotated;
|
|
13853
13957
|
var left = Math.max(30, margin.left) - (isRotated ? 20 : 0);
|
|
13854
13958
|
var isInner = config.axis_y_inner;
|
|
13855
|
-
var x = isInner
|
|
13959
|
+
var x = isInner && !isRotated ? (config.axis_y_label.text ? -20 : -1) :
|
|
13960
|
+
(isRotated ? -(1 + left) : -(left - 1));
|
|
13856
13961
|
var y = -(isRotated ? 20 : margin.top);
|
|
13857
13962
|
var w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
|
|
13858
|
-
var h = (isRotated ? margin.bottom : (margin.top + height)) + 10;
|
|
13963
|
+
var h = (isRotated ? margin.bottom + (((_a = config.padding) === null || _a === void 0 ? void 0 : _a.mode) === "fit" ? 10 : 0) : (margin.top + height)) + 10;
|
|
13859
13964
|
node
|
|
13860
13965
|
.attr("x", x)
|
|
13861
13966
|
.attr("y", y)
|
|
@@ -13979,12 +14084,12 @@ var grid = {
|
|
|
13979
14084
|
"x1": 0,
|
|
13980
14085
|
"x2": state.width,
|
|
13981
14086
|
"y1": pos,
|
|
13982
|
-
"y2": pos
|
|
14087
|
+
"y2": pos,
|
|
13983
14088
|
} : {
|
|
13984
14089
|
"x1": pos,
|
|
13985
14090
|
"x2": pos,
|
|
13986
14091
|
"y1": 0,
|
|
13987
|
-
"y2": state.height
|
|
14092
|
+
"y2": state.height,
|
|
13988
14093
|
};
|
|
13989
14094
|
grid.x = main.select(".".concat($GRID.xgrids))
|
|
13990
14095
|
.selectAll(".".concat($GRID.xgrid))
|
|
@@ -14062,7 +14167,7 @@ var grid = {
|
|
|
14062
14167
|
.style("opacity", "0");
|
|
14063
14168
|
xLines = xgridLine.merge(xLines);
|
|
14064
14169
|
$T(xLines
|
|
14065
|
-
.attr("class", function (d) { return "".concat($GRID.xgridLine, " ").concat(d
|
|
14170
|
+
.attr("class", function (d) { return "".concat($GRID.xgridLine, " ").concat(d.class || "").trim(); })
|
|
14066
14171
|
.select("text")
|
|
14067
14172
|
.attr("text-anchor", getGridTextAnchor)
|
|
14068
14173
|
.attr("dx", getGridTextDx))
|
|
@@ -14097,7 +14202,7 @@ var grid = {
|
|
|
14097
14202
|
// update
|
|
14098
14203
|
var yv = $$.yv.bind($$);
|
|
14099
14204
|
$T(ygridLines
|
|
14100
|
-
.attr("class", function (d) { return "".concat($GRID.ygridLine, " ").concat(d
|
|
14205
|
+
.attr("class", function (d) { return "".concat($GRID.ygridLine, " ").concat(d.class || "").trim(); })
|
|
14101
14206
|
.select("line"))
|
|
14102
14207
|
.attr("x1", isRotated ? yv : 0)
|
|
14103
14208
|
.attr("x2", isRotated ? yv : width)
|
|
@@ -14285,7 +14390,7 @@ var grid = {
|
|
|
14285
14390
|
return params ? function (line) {
|
|
14286
14391
|
var found = false;
|
|
14287
14392
|
(isArray(params) ? params.concat() : [params]).forEach(function (param) {
|
|
14288
|
-
if ((("value" in param && line.value === param.value) || ("class" in param && line
|
|
14393
|
+
if ((("value" in param && line.value === param.value) || ("class" in param && line.class === param.class))) {
|
|
14289
14394
|
found = true;
|
|
14290
14395
|
}
|
|
14291
14396
|
});
|
|
@@ -14306,7 +14411,7 @@ var grid = {
|
|
|
14306
14411
|
.remove();
|
|
14307
14412
|
var gridLines = "grid_".concat(forX ? "x" : "y", "_lines");
|
|
14308
14413
|
config[gridLines] = config[gridLines].filter(toShow);
|
|
14309
|
-
}
|
|
14414
|
+
},
|
|
14310
14415
|
};
|
|
14311
14416
|
|
|
14312
14417
|
/**
|
|
@@ -14427,7 +14532,7 @@ var region = {
|
|
|
14427
14532
|
},
|
|
14428
14533
|
isRegionOnX: function (d) {
|
|
14429
14534
|
return !d.axis || d.axis === "x";
|
|
14430
|
-
}
|
|
14535
|
+
},
|
|
14431
14536
|
};
|
|
14432
14537
|
|
|
14433
14538
|
var sizeAxis = {
|
|
@@ -14445,24 +14550,30 @@ var sizeAxis = {
|
|
|
14445
14550
|
$$.getHorizontalAxisHeight(id);
|
|
14446
14551
|
},
|
|
14447
14552
|
getAxisWidthByAxisId: function (id, withoutRecompute) {
|
|
14448
|
-
var _a;
|
|
14553
|
+
var _a, _b;
|
|
14449
14554
|
var $$ = this;
|
|
14450
14555
|
if ($$.axis) {
|
|
14451
14556
|
var position = (_a = $$.axis) === null || _a === void 0 ? void 0 : _a.getLabelPositionById(id);
|
|
14452
14557
|
var width = $$.axis.getMaxTickWidth(id, withoutRecompute);
|
|
14453
14558
|
var gap = width === 0 ? 0.5 : 0;
|
|
14454
|
-
return width + (
|
|
14559
|
+
return width + (((_b = $$.config.padding) === null || _b === void 0 ? void 0 : _b.mode) === "fit" ?
|
|
14560
|
+
position.isInner ? (10 + gap) : 10 :
|
|
14561
|
+
position.isInner ? (20 + gap) : 40);
|
|
14455
14562
|
}
|
|
14456
14563
|
else {
|
|
14457
14564
|
return 40;
|
|
14458
14565
|
}
|
|
14459
14566
|
},
|
|
14460
14567
|
getHorizontalAxisHeight: function (id) {
|
|
14568
|
+
var _a, _b;
|
|
14461
14569
|
var $$ = this;
|
|
14462
14570
|
var config = $$.config, state = $$.state;
|
|
14463
14571
|
var current = state.current, rotatedPadding = state.rotatedPadding, isLegendRight = state.isLegendRight, isLegendInset = state.isLegendInset;
|
|
14464
14572
|
var isRotated = config.axis_rotated;
|
|
14465
|
-
var
|
|
14573
|
+
var isFitPadding = ((_a = config.padding) === null || _a === void 0 ? void 0 : _a.mode) === "fit";
|
|
14574
|
+
var isInner = config["axis_".concat(id, "_inner")];
|
|
14575
|
+
var hasLabelText = config["axis_".concat(id, "_label")].text;
|
|
14576
|
+
var h = ((_b = config.padding) === null || _b === void 0 ? void 0 : _b.mode) === "fit" ? (isInner && !hasLabelText ? (id === "y" ? 1 : 0) : 20) : 30;
|
|
14466
14577
|
if (id === "x" && !config.axis_x_show) {
|
|
14467
14578
|
return 8;
|
|
14468
14579
|
}
|
|
@@ -14475,7 +14586,7 @@ var sizeAxis = {
|
|
|
14475
14586
|
!isLegendInset ? 10 : 1;
|
|
14476
14587
|
}
|
|
14477
14588
|
if (id === "y2" && !config.axis_y2_show) {
|
|
14478
|
-
return rotatedPadding.top;
|
|
14589
|
+
return isFitPadding ? 0 : rotatedPadding.top;
|
|
14479
14590
|
}
|
|
14480
14591
|
var rotate = $$.getAxisTickRotate(id);
|
|
14481
14592
|
// Calculate x/y axis height when tick rotated
|
|
@@ -14494,7 +14605,11 @@ var sizeAxis = {
|
|
|
14494
14605
|
(id === "y2" && !isRotated ? -10 : 0);
|
|
14495
14606
|
},
|
|
14496
14607
|
getEventRectWidth: function () {
|
|
14497
|
-
|
|
14608
|
+
var $$ = this;
|
|
14609
|
+
var config = $$.config, axis = $$.axis;
|
|
14610
|
+
var isInverted = config.axis_x_inverted;
|
|
14611
|
+
var tickInterval = axis.x.tickInterval();
|
|
14612
|
+
return Math.max(0, isInverted ? Math.abs(tickInterval) : tickInterval);
|
|
14498
14613
|
},
|
|
14499
14614
|
/**
|
|
14500
14615
|
* Get axis tick test rotate value
|
|
@@ -15191,6 +15306,22 @@ var x = {
|
|
|
15191
15306
|
* }
|
|
15192
15307
|
*/
|
|
15193
15308
|
axis_x_min: undefined,
|
|
15309
|
+
/**
|
|
15310
|
+
* Change the direction of x axis.<br><br>
|
|
15311
|
+
* If true set, the direction will be `right -> left`.
|
|
15312
|
+
* @name axis․x․inverted
|
|
15313
|
+
* @memberof Options
|
|
15314
|
+
* @type {boolean}
|
|
15315
|
+
* @default false
|
|
15316
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
|
|
15317
|
+
* @example
|
|
15318
|
+
* axis: {
|
|
15319
|
+
* x: {
|
|
15320
|
+
* inverted: true
|
|
15321
|
+
* }
|
|
15322
|
+
* }
|
|
15323
|
+
*/
|
|
15324
|
+
axis_x_inverted: false,
|
|
15194
15325
|
/**
|
|
15195
15326
|
* Set padding for x axis.<br><br>
|
|
15196
15327
|
* If this option is set, the range of x axis will increase/decrease according to the values.
|
|
@@ -15453,11 +15584,12 @@ var y = {
|
|
|
15453
15584
|
axis_y_min: undefined,
|
|
15454
15585
|
/**
|
|
15455
15586
|
* Change the direction of y axis.<br><br>
|
|
15456
|
-
* If true set, the direction will be
|
|
15587
|
+
* If true set, the direction will be `top -> bottom`.
|
|
15457
15588
|
* @name axis․y․inverted
|
|
15458
15589
|
* @memberof Options
|
|
15459
15590
|
* @type {boolean}
|
|
15460
15591
|
* @default false
|
|
15592
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
|
|
15461
15593
|
* @example
|
|
15462
15594
|
* axis: {
|
|
15463
15595
|
* y: {
|
|
@@ -15928,11 +16060,12 @@ var y2 = {
|
|
|
15928
16060
|
axis_y2_min: undefined,
|
|
15929
16061
|
/**
|
|
15930
16062
|
* Change the direction of y2 axis.<br><br>
|
|
15931
|
-
* If true set, the direction will be
|
|
16063
|
+
* If true set, the direction will be `top -> bottom`.
|
|
15932
16064
|
* @name axis․y2․inverted
|
|
15933
16065
|
* @memberof Options
|
|
15934
16066
|
* @type {boolean}
|
|
15935
16067
|
* @default false
|
|
16068
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
|
|
15936
16069
|
* @example
|
|
15937
16070
|
* axis: {
|
|
15938
16071
|
* y2: {
|
|
@@ -16392,9 +16525,8 @@ var optGrid = {
|
|
|
16392
16525
|
var api = [
|
|
16393
16526
|
apiAxis,
|
|
16394
16527
|
apiCategory,
|
|
16395
|
-
apiXGrid,
|
|
16396
|
-
apiYGrid,
|
|
16397
16528
|
apiFlow,
|
|
16529
|
+
apiGrid,
|
|
16398
16530
|
apiGroup,
|
|
16399
16531
|
apiRegion,
|
|
16400
16532
|
apiX
|
|
@@ -16744,7 +16876,7 @@ var shapeArc = {
|
|
|
16744
16876
|
id: "data" in d ? d.data.id : d.id,
|
|
16745
16877
|
value: d.value,
|
|
16746
16878
|
ratio: this.getRatio("arc", d),
|
|
16747
|
-
index: d.index
|
|
16879
|
+
index: d.index,
|
|
16748
16880
|
});
|
|
16749
16881
|
},
|
|
16750
16882
|
textForArcLabel: function (selection) {
|
|
@@ -18210,7 +18342,7 @@ var shapeLine = {
|
|
|
18210
18342
|
var linePoint = this.config.line_point;
|
|
18211
18343
|
return linePoint === true ||
|
|
18212
18344
|
(isArray(linePoint) && linePoint.indexOf(d.id) !== -1);
|
|
18213
|
-
}
|
|
18345
|
+
},
|
|
18214
18346
|
};
|
|
18215
18347
|
|
|
18216
18348
|
var getTransitionName = function () { return getRandom(); };
|
|
@@ -19824,7 +19956,7 @@ var optScatter = {
|
|
|
19824
19956
|
* zerobased: false
|
|
19825
19957
|
* }
|
|
19826
19958
|
*/
|
|
19827
|
-
scatter_zerobased: false
|
|
19959
|
+
scatter_zerobased: false,
|
|
19828
19960
|
};
|
|
19829
19961
|
|
|
19830
19962
|
/**
|
|
@@ -20720,12 +20852,14 @@ var apiSubchart = {
|
|
|
20720
20852
|
* @param {Array} domain Target domain value
|
|
20721
20853
|
* @param {Array} current Current zoom domain value
|
|
20722
20854
|
* @param {Array} range Zoom range value
|
|
20855
|
+
* @param {boolean} isInverted Whether the axis is inverted or not
|
|
20723
20856
|
* @returns {boolean}
|
|
20724
20857
|
* @private
|
|
20725
20858
|
*/
|
|
20726
|
-
function withinRange(domain, current, range) {
|
|
20859
|
+
function withinRange(domain, current, range, isInverted) {
|
|
20860
|
+
if (isInverted === void 0) { isInverted = false; }
|
|
20727
20861
|
var min = range[0], max = range[1];
|
|
20728
|
-
return domain.every(function (v, i) { return (i === 0 ? (v >= min) : (v <= max)) && !(domain.every(function (v, i) { return v === current[i]; })); });
|
|
20862
|
+
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]; })); });
|
|
20729
20863
|
}
|
|
20730
20864
|
/**
|
|
20731
20865
|
* Zoom by giving x domain range.
|
|
@@ -20752,13 +20886,15 @@ var zoom$1 = function (domainValue) {
|
|
|
20752
20886
|
var $$ = this.internal;
|
|
20753
20887
|
var $el = $$.$el, axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale;
|
|
20754
20888
|
var isRotated = config.axis_rotated;
|
|
20889
|
+
var isInverted = config.axis_x_inverted;
|
|
20755
20890
|
var isCategorized = axis.isCategorized();
|
|
20756
20891
|
var domain = domainValue;
|
|
20757
20892
|
if (config.zoom_enabled && domain) {
|
|
20758
20893
|
if (axis.isTimeSeries()) {
|
|
20759
20894
|
domain = domain.map(function (x) { return parseDate.bind($$)(x); });
|
|
20760
20895
|
}
|
|
20761
|
-
|
|
20896
|
+
var isWithinRange = withinRange(domain, $$.getZoomDomain(true), $$.getZoomDomain(), isInverted);
|
|
20897
|
+
if (isWithinRange) {
|
|
20762
20898
|
if (isCategorized) {
|
|
20763
20899
|
domain = domain.map(function (v, i) { return Number(v) + (i === 0 ? 0 : 1); });
|
|
20764
20900
|
}
|
|
@@ -21581,7 +21717,7 @@ var zoom = {
|
|
|
21581
21717
|
if (!$$.state.xTickOffset) {
|
|
21582
21718
|
$$.state.xTickOffset = $$.axis.x.tickOffset();
|
|
21583
21719
|
}
|
|
21584
|
-
scale.zoom = $$.
|
|
21720
|
+
scale.zoom = $$.getCustomizedXScale(newScale);
|
|
21585
21721
|
$$.axis.x.scale(scale.zoom);
|
|
21586
21722
|
if (rescale) {
|
|
21587
21723
|
// copy current initial x scale in case of rescale option is used
|
|
@@ -21698,8 +21834,7 @@ var zoom = {
|
|
|
21698
21834
|
var zoomDomain = zoom.domain();
|
|
21699
21835
|
var xDomain = subX.domain();
|
|
21700
21836
|
var delta = 0.015; // arbitrary value
|
|
21701
|
-
var isfullyShown = (zoomDomain[0] <= xDomain[0] || (zoomDomain[0] - delta) <= xDomain[0]) &&
|
|
21702
|
-
(xDomain[1] <= zoomDomain[1] || xDomain[1] <= (zoomDomain[1] - delta));
|
|
21837
|
+
var isfullyShown = $$.config.axis_x_inverted ? (zoomDomain[0] >= xDomain[0] || (zoomDomain[0] + delta) >= xDomain[0]) && (xDomain[1] >= zoomDomain[1] || xDomain[1] >= (zoomDomain[1] + delta)) : (zoomDomain[0] <= xDomain[0] || (zoomDomain[0] - delta) <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= (zoomDomain[1] - delta));
|
|
21703
21838
|
// check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
|
|
21704
21839
|
if (force || isfullyShown) {
|
|
21705
21840
|
$$.axis.x.scale(subX);
|
|
@@ -22129,7 +22264,7 @@ var zoomModule = function () {
|
|
|
22129
22264
|
var defaults = {};
|
|
22130
22265
|
/**
|
|
22131
22266
|
* @namespace bb
|
|
22132
|
-
* @version 3.
|
|
22267
|
+
* @version 3.8.0-next.1
|
|
22133
22268
|
*/
|
|
22134
22269
|
var bb = {
|
|
22135
22270
|
/**
|
|
@@ -22139,7 +22274,7 @@ var bb = {
|
|
|
22139
22274
|
* bb.version; // "1.0.0"
|
|
22140
22275
|
* @memberof bb
|
|
22141
22276
|
*/
|
|
22142
|
-
version: "3.
|
|
22277
|
+
version: "3.8.0-next.1",
|
|
22143
22278
|
/**
|
|
22144
22279
|
* Generate chart
|
|
22145
22280
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|