billboard.js 3.7.4 → 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.
Files changed (73) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +420 -256
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +2115 -1544
  6. package/dist/billboard.pkgd.min.js +3 -3
  7. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-sparkline.js +22 -19
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +22 -19
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +22 -19
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +22 -19
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +1696 -1289
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +1717 -1307
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +1718 -1308
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +1719 -1309
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +1752 -1325
  22. package/dist/theme/datalab.css +1 -1
  23. package/dist/theme/datalab.min.css +1 -1
  24. package/dist/theme/graph.css +1 -1
  25. package/dist/theme/graph.min.css +1 -1
  26. package/dist/theme/insight.css +1 -1
  27. package/dist/theme/insight.min.css +1 -1
  28. package/dist-esm/billboard.js +359 -211
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -9
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +6 -11
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +7 -12
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -7
  34. package/package.json +33 -33
  35. package/src/Chart/api/focus.ts +4 -4
  36. package/src/Chart/api/grid.ts +206 -0
  37. package/src/Chart/api/load.ts +31 -21
  38. package/src/Chart/api/regions.ts +28 -24
  39. package/src/Chart/api/zoom.ts +18 -3
  40. package/src/ChartInternal/Axis/Axis.ts +1 -0
  41. package/src/ChartInternal/Axis/AxisRenderer.ts +7 -2
  42. package/src/ChartInternal/ChartInternal.ts +1 -1
  43. package/src/ChartInternal/data/IData.ts +1 -1
  44. package/src/ChartInternal/data/convert.ts +6 -3
  45. package/src/ChartInternal/data/data.ts +22 -19
  46. package/src/ChartInternal/data/load.ts +19 -4
  47. package/src/ChartInternal/interactions/eventrect.ts +5 -0
  48. package/src/ChartInternal/interactions/subchart.ts +3 -2
  49. package/src/ChartInternal/interactions/zoom.ts +10 -3
  50. package/src/ChartInternal/internals/clip.ts +3 -2
  51. package/src/ChartInternal/internals/domain.ts +17 -8
  52. package/src/ChartInternal/internals/legend.ts +4 -1
  53. package/src/ChartInternal/internals/redraw.ts +0 -16
  54. package/src/ChartInternal/internals/scale.ts +7 -4
  55. package/src/ChartInternal/internals/size.axis.ts +14 -4
  56. package/src/ChartInternal/internals/size.ts +41 -18
  57. package/src/ChartInternal/internals/transform.ts +1 -1
  58. package/src/ChartInternal/internals/type.ts +10 -0
  59. package/src/ChartInternal/shape/bar.ts +2 -3
  60. package/src/config/Options/axis/x.ts +17 -0
  61. package/src/config/Options/axis/y.ts +2 -1
  62. package/src/config/Options/axis/y2.ts +2 -1
  63. package/src/config/Options/common/main.ts +19 -1
  64. package/src/config/Options/data/axis.ts +10 -1
  65. package/src/config/resolver/axis.ts +2 -4
  66. package/src/module/browser.ts +13 -5
  67. package/src/module/generator.ts +3 -3
  68. package/src/module/util.ts +7 -4
  69. package/types/axis.d.ts +8 -7
  70. package/types/chart.d.ts +6 -1
  71. package/types/options.d.ts +6 -0
  72. package/src/Chart/api/grid.x.ts +0 -90
  73. package/src/Chart/api/grid.y.ts +0 -92
package/dist/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.7.4
8
+ * @version 3.8.0-next.1
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -230,23 +230,25 @@ var _this = undefined;
230
230
  /* eslint-disable no-new-func, no-undef */
231
231
 
232
232
  var win = function () {
233
- _newArrowCheck(this, _this);
234
- var root = typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self;
235
- return root || Function("return this")();
236
- }.bind(undefined)();
233
+ _newArrowCheck(this, _this);
234
+ var root = typeof globalThis === "object" && globalThis !== null && globalThis.Object === Object && globalThis || typeof global === "object" && global !== null && global.Object === Object && global || typeof self === "object" && self !== null && self.Object === Object && self;
235
+ return root || Function("return this")();
236
+ }.bind(undefined)(),
237
+ hasRAF = typeof win.requestAnimationFrame === "function",
238
+ hasRIC = typeof win.requestIdleCallback === "function",
239
+ requestAnimationFrame = hasRAF ? win.requestAnimationFrame : function (cb) {
240
+ _newArrowCheck(this, _this);
241
+ return setTimeout(cb, 1);
242
+ }.bind(undefined),
243
+ cancelAnimationFrame = hasRAF ? win.cancelAnimationFrame : function (id) {
244
+ _newArrowCheck(this, _this);
245
+ return clearTimeout(id);
246
+ }.bind(undefined),
247
+ requestIdleCallback = hasRIC ? win.requestIdleCallback : requestAnimationFrame,
248
+ cancelIdleCallback = hasRIC ? win.cancelIdleCallback : cancelAnimationFrame,
249
+ browser_doc = win == null ? void 0 : win.document;
237
250
  /* eslint-enable no-new-func, no-undef */
238
-
239
251
  // fallback for non-supported environments
240
- win.requestIdleCallback = win.requestIdleCallback || function (cb) {
241
- _newArrowCheck(this, _this);
242
- return setTimeout(cb, 1);
243
- }.bind(undefined);
244
- // win.cancelIdleCallback = win.cancelIdleCallback || (id => clearTimeout(id));
245
- win.requestAnimationFrame = win.requestAnimationFrame || function (cb) {
246
- _newArrowCheck(this, _this);
247
- return setTimeout(cb, 1);
248
- }.bind(undefined);
249
- var browser_doc = win == null ? void 0 : win.document;
250
252
  ;// CONCATENATED MODULE: ./src/config/const.ts
251
253
  /**
252
254
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -691,7 +693,8 @@ function getRandom(asStr, min, max) {
691
693
  if (max === void 0) {
692
694
  max = 1e4;
693
695
  }
694
- var rand = Math.floor(Math.random() * (max - min) + min);
696
+ var crpt = win.crypto || win.msCrypto,
697
+ rand = crpt ? min + crpt.getRandomValues(new Uint32Array(1))[0] % (max - min + 1) : Math.floor(Math.random() * (max - min) + min);
695
698
  return asStr ? rand + "" : rand;
696
699
  }
697
700
 
@@ -1214,7 +1217,7 @@ function convertInputType(mouse, touch) {
1214
1217
  function runUntil(fn, conditionFn) {
1215
1218
  var _this18 = this;
1216
1219
  if (conditionFn() === !1) {
1217
- win.requestAnimationFrame(function () {
1220
+ requestAnimationFrame(function () {
1218
1221
  _newArrowCheck(this, _this18);
1219
1222
  return runUntil(fn, conditionFn);
1220
1223
  }.bind(this));
@@ -1826,15 +1829,30 @@ var Store = /*#__PURE__*/function () {
1826
1829
  * - `false`: Remove padding completely and make shape to fully occupy the container element.
1827
1830
  * - In this case, axes and subchart will be hidden.
1828
1831
  * - To adjust some padding from this state, use `axis.[x|y].padding` option.
1832
+ * @property {string} [padding.mode] padding mode
1833
+ * - `"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.
1829
1834
  * @property {number} [padding.top] padding on the top of chart
1830
1835
  * @property {number} [padding.right] padding on the right of chart
1831
1836
  * @property {number} [padding.bottom] padding on the bottom of chart
1832
1837
  * @property {number} [padding.left] padding on the left of chart
1833
1838
  * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Padding)
1839
+ * @see [Demo: Fit padding](https://naver.github.io/billboard.js/demo/#ChartOptions.FitPadding)
1834
1840
  * @example
1835
1841
  * // remove padding completely.
1836
1842
  * padding: false,
1837
1843
  *
1844
+ * padding: {
1845
+ * // specifying mode value, will reduce padding and make fit to the container element.
1846
+ * mode: "fit"
1847
+ *
1848
+ * // when mode is "fit", all padding values will be relative from fitted value.
1849
+ * // so, 0 will be initial fitted value.
1850
+ * top: 20,
1851
+ * right: 20,
1852
+ * bottom: 20,
1853
+ * left: 20
1854
+ * }
1855
+ *
1838
1856
  * // or specify padding value for each side
1839
1857
  * padding: {
1840
1858
  * top: 20,
@@ -1844,6 +1862,7 @@ var Store = /*#__PURE__*/function () {
1844
1862
  * }
1845
1863
  */
1846
1864
  padding: !0,
1865
+ padding_mode: undefined,
1847
1866
  padding_left: undefined,
1848
1867
  padding_right: undefined,
1849
1868
  padding_top: undefined,
@@ -1857,7 +1876,9 @@ var Store = /*#__PURE__*/function () {
1857
1876
  * @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
1858
1877
  * @property {boolean|number} [resize.timer=true] Set resize timer option.
1859
1878
  * - **NOTE:**
1860
- * - The resize function will be called using: true - `setTimeout()`, false - `requestIdleCallback()`.
1879
+ * - The resize function will be called using:
1880
+ * - true: `setTimeout()`
1881
+ * - false: `requestIdleCallback()`
1861
1882
  * - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
1862
1883
  * @example
1863
1884
  * resize: {
@@ -3698,7 +3719,7 @@ function generateResize(option) {
3698
3719
  var _this = this;
3699
3720
  // Delay all resize functions call, to prevent unintended excessive call from resize event
3700
3721
  callResizeFn.clear();
3701
- if (option === !1 && win.requestIdleCallback) {
3722
+ if (option === !1) {
3702
3723
  requestIdleCallback(function () {
3703
3724
  var _this2 = this;
3704
3725
  _newArrowCheck(this, _this);
@@ -4150,6 +4171,7 @@ function getDataKeyForJson(keysParam, config) {
4150
4171
  axis = $$.axis,
4151
4172
  config = $$.config,
4152
4173
  state = $$.state,
4174
+ chartType = config.data_type,
4153
4175
  isCategorized = !1,
4154
4176
  isTimeSeries = !1,
4155
4177
  isCustomX = !1;
@@ -4293,11 +4315,12 @@ function getDataKeyForJson(keysParam, config) {
4293
4315
  state.hasPositiveValue = $$.hasPositiveValueInTargets(targets);
4294
4316
 
4295
4317
  // set target types
4296
- if (config.data_type) {
4297
- $$.setTargetType($$.mapToIds(targets).filter(function (id) {
4318
+ if (chartType && $$.isValidChartType(chartType)) {
4319
+ var targetIds = $$.mapToIds(targets).filter(function (id) {
4298
4320
  _newArrowCheck(this, _this2);
4299
- return !(id in config.data_types);
4300
- }.bind(this)), config.data_type);
4321
+ return !(id in config.data_types) || !$$.isValidChartType(config.data_types[id]);
4322
+ }.bind(this));
4323
+ $$.setTargetType(targetIds, chartType);
4301
4324
  }
4302
4325
 
4303
4326
  // cache as original id keyed
@@ -4394,7 +4417,7 @@ function getDataKeyForJson(keysParam, config) {
4394
4417
  }.bind(this));
4395
4418
  },
4396
4419
  isMultipleX: function isMultipleX() {
4397
- return notEmpty(this.config.data_xs) || !this.config.data_xSort || this.hasType("bubble") || this.hasType("scatter");
4420
+ return notEmpty(this.config.data_xs) || this.hasType("bubble") || this.hasType("scatter");
4398
4421
  },
4399
4422
  addName: function addName(data) {
4400
4423
  var $$ = this,
@@ -4678,7 +4701,8 @@ function getDataKeyForJson(keysParam, config) {
4678
4701
  getMaxDataCountTarget: function getMaxDataCountTarget() {
4679
4702
  var _this18 = this,
4680
4703
  target = this.filterTargetsToShow() || [],
4681
- length = target.length;
4704
+ length = target.length,
4705
+ isInverted = this.config.axis_x_inverted;
4682
4706
  if (length > 1) {
4683
4707
  target = target.map(function (t) {
4684
4708
  _newArrowCheck(this, _this18);
@@ -4690,15 +4714,15 @@ function getDataKeyForJson(keysParam, config) {
4690
4714
  _newArrowCheck(this, _this18);
4691
4715
  return v.x;
4692
4716
  }.bind(this));
4693
- target = sortValue(getUnique(target)).map(function (x, index) {
4717
+ target = sortValue(getUnique(target)).map(function (x, index, array) {
4694
4718
  _newArrowCheck(this, _this18);
4695
4719
  return {
4696
4720
  x: x,
4697
- index: index
4721
+ index: isInverted ? array.length - index - 1 : index
4698
4722
  };
4699
4723
  }.bind(this));
4700
4724
  } else if (length) {
4701
- target = target[0].values;
4725
+ target = target[0].values.concat();
4702
4726
  }
4703
4727
  return target;
4704
4728
  },
@@ -5088,36 +5112,40 @@ function getDataKeyForJson(keysParam, config) {
5088
5112
  return values;
5089
5113
  }
5090
5114
 
5091
- // insert & append cloning first/last value to be fully rendered covering on each gap sides
5092
- var head = converted[0],
5093
- tail = converted[converted.length - 1],
5094
- id = head.id;
5095
- var x = head.x;
5096
-
5097
- // insert head
5098
- converted.unshift({
5099
- x: --x,
5100
- value: head.value,
5101
- id: id
5102
- });
5103
- isCategorized && stepType === "step-after" && converted.unshift({
5104
- x: --x,
5105
- value: head.value,
5106
- id: id
5107
- });
5115
+ // when all datas are null, return empty array
5116
+ // https://github.com/naver/billboard.js/issues/3124
5117
+ if (converted.length) {
5118
+ // insert & append cloning first/last value to be fully rendered covering on each gap sides
5119
+ var head = converted[0],
5120
+ tail = converted[converted.length - 1],
5121
+ id = head.id;
5122
+ var x = head.x;
5123
+
5124
+ // insert head
5125
+ converted.unshift({
5126
+ x: --x,
5127
+ value: head.value,
5128
+ id: id
5129
+ });
5130
+ isCategorized && stepType === "step-after" && converted.unshift({
5131
+ x: --x,
5132
+ value: head.value,
5133
+ id: id
5134
+ });
5108
5135
 
5109
- // append tail
5110
- x = tail.x;
5111
- converted.push({
5112
- x: ++x,
5113
- value: tail.value,
5114
- id: id
5115
- });
5116
- isCategorized && stepType === "step-before" && converted.push({
5117
- x: ++x,
5118
- value: tail.value,
5119
- id: id
5120
- });
5136
+ // append tail
5137
+ x = tail.x;
5138
+ converted.push({
5139
+ x: ++x,
5140
+ value: tail.value,
5141
+ id: id
5142
+ });
5143
+ isCategorized && stepType === "step-before" && converted.push({
5144
+ x: ++x,
5145
+ value: tail.value,
5146
+ id: id
5147
+ });
5148
+ }
5121
5149
  return converted;
5122
5150
  },
5123
5151
  convertValuesToRange: function convertValuesToRange(values) {
@@ -5306,7 +5334,7 @@ function getDataKeyForJson(keysParam, config) {
5306
5334
  */
5307
5335
  isBubbleZType: function isBubbleZType(d) {
5308
5336
  var $$ = this;
5309
- return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length === 2);
5337
+ return $$.isBubbleType(d) && (isObject(d.value) && ("z" in d.value || "y" in d.value) || isArray(d.value) && d.value.length >= 2);
5310
5338
  },
5311
5339
  /**
5312
5340
  * Determine if bar has ranged data
@@ -5318,7 +5346,7 @@ function getDataKeyForJson(keysParam, config) {
5318
5346
  var _this44 = this,
5319
5347
  $$ = this,
5320
5348
  value = d.value;
5321
- return $$.isBarType(d) && isArray(value) && value.length === 2 && value.every(function (v) {
5349
+ return $$.isBarType(d) && isArray(value) && value.length >= 2 && value.every(function (v) {
5322
5350
  _newArrowCheck(this, _this44);
5323
5351
  return isNumber(v);
5324
5352
  }.bind(this));
@@ -5343,11 +5371,27 @@ function getDataKeyForJson(keysParam, config) {
5343
5371
  */
5344
5372
 
5345
5373
 
5374
+
5375
+ /**
5376
+ * Call done callback with resize after transition
5377
+ * @param {Function} fn Callback function
5378
+ * @param {boolean} resizeAfter Weather to resize chart after the load
5379
+ * @private
5380
+ */
5381
+ function callDone(fn, resizeAfter) {
5382
+ if (resizeAfter === void 0) {
5383
+ resizeAfter = !1;
5384
+ }
5385
+ var $$ = this,
5386
+ api = $$.api;
5387
+ resizeAfter && $$.api.flush(!0);
5388
+ fn == null ? void 0 : fn.call(api);
5389
+ }
5346
5390
  /* harmony default export */ var load = ({
5347
5391
  load: function load(rawTargets, args) {
5348
5392
  var _this = this,
5349
- _args$done,
5350
5393
  $$ = this,
5394
+ data = $$.data,
5351
5395
  append = args.append,
5352
5396
  targets = rawTargets;
5353
5397
  if (targets) {
@@ -5367,7 +5411,7 @@ function getDataKeyForJson(keysParam, config) {
5367
5411
  }
5368
5412
 
5369
5413
  // Update/Add data
5370
- $$.data.targets.forEach(function (d) {
5414
+ data.targets.forEach(function (d) {
5371
5415
  _newArrowCheck(this, _this);
5372
5416
  for (var i = 0; i < targets.length; i++) {
5373
5417
  if (d.id === targets[i].id) {
@@ -5377,11 +5421,11 @@ function getDataKeyForJson(keysParam, config) {
5377
5421
  }
5378
5422
  }
5379
5423
  }.bind(this));
5380
- $$.data.targets = $$.data.targets.concat(targets); // add remained
5424
+ data.targets = data.targets.concat(targets); // add remained
5381
5425
  }
5382
5426
 
5383
5427
  // Set targets
5384
- $$.updateTargets($$.data.targets);
5428
+ $$.updateTargets(data.targets);
5385
5429
 
5386
5430
  // Redraw with new targets
5387
5431
  $$.redraw({
@@ -5392,7 +5436,7 @@ function getDataKeyForJson(keysParam, config) {
5392
5436
 
5393
5437
  // Update current state chart type and elements list after redraw
5394
5438
  $$.updateTypesElements();
5395
- (_args$done = args.done) == null ? void 0 : _args$done.call($$.api);
5439
+ callDone.call($$, args.done, args.resizeAfter);
5396
5440
  },
5397
5441
  loadFromArgs: function loadFromArgs(args) {
5398
5442
  var _this2 = this,
@@ -6395,7 +6439,9 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6395
6439
  getXDomain: function getXDomain(targets) {
6396
6440
  var $$ = this,
6397
6441
  axis = $$.axis,
6442
+ config = $$.config,
6398
6443
  x = $$.scale.x,
6444
+ isInverted = config.axis_x_inverted,
6399
6445
  domain = [$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")];
6400
6446
  var _domain$ = domain[0],
6401
6447
  min = _domain$ === void 0 ? 0 : _domain$,
@@ -6425,7 +6471,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6425
6471
  max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right;
6426
6472
  }
6427
6473
  }
6428
- return [min, max];
6474
+ return isInverted ? [max, min] : [min, max];
6429
6475
  },
6430
6476
  updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
6431
6477
  var $$ = this,
@@ -6437,7 +6483,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6437
6483
  zoomEnabled = config.zoom_enabled;
6438
6484
  if (withUpdateOrgXDomain) {
6439
6485
  var _$$$brush;
6440
- x.domain(domain || sortValue($$.getXDomain(targets)));
6486
+ x.domain(domain || sortValue($$.getXDomain(targets), !config.axis_x_inverted));
6441
6487
  org.xDomain = x.domain();
6442
6488
  zoomEnabled && $$.zoom.updateScaleExtent();
6443
6489
  subX.domain(x.domain());
@@ -6453,15 +6499,24 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6453
6499
  withTrim && x.domain($$.trimXDomain(x.orgDomain()));
6454
6500
  return x.domain();
6455
6501
  },
6502
+ /**
6503
+ * Trim x domain when given domain surpasses the range
6504
+ * @param {Array} domain Domain value
6505
+ * @returns {Array} Trimed domain if given domain is out of range
6506
+ * @private
6507
+ */
6456
6508
  trimXDomain: function trimXDomain(domain) {
6457
- var zoomDomain = this.getZoomDomain(),
6458
- min = zoomDomain[0],
6459
- max = zoomDomain[1];
6460
- if (domain[0] <= min) {
6461
- domain[1] = +domain[1] + (min - domain[0]);
6509
+ var $$ = this,
6510
+ isInverted = $$.config.axis_x_inverted,
6511
+ zoomDomain = $$.getZoomDomain(),
6512
+ _zoomDomain = zoomDomain,
6513
+ min = _zoomDomain[0],
6514
+ max = _zoomDomain[1];
6515
+ if (isInverted ? domain[0] >= min : domain[0] <= min) {
6462
6516
  domain[0] = min;
6517
+ domain[1] = +domain[1] + (min - domain[0]);
6463
6518
  }
6464
- if (max <= domain[1]) {
6519
+ if (isInverted ? domain[1] <= max : domain[1] >= max) {
6465
6520
  domain[0] = +domain[0] - (domain[1] - max);
6466
6521
  domain[1] = max;
6467
6522
  }
@@ -6806,13 +6861,15 @@ function getLegendColor(id) {
6806
6861
  * @private
6807
6862
  */
6808
6863
  getLegendHeight: function getLegendHeight() {
6809
- var $$ = this,
6864
+ var _$$$config$padding,
6865
+ $$ = this,
6810
6866
  _$$$state3 = $$.state,
6811
6867
  current = _$$$state3.current,
6812
6868
  isLegendRight = _$$$state3.isLegendRight,
6813
6869
  legendItemHeight = _$$$state3.legendItemHeight,
6814
- legendStep = _$$$state3.legendStep;
6815
- return $$.config.legend_show ? isLegendRight ? current.height : Math.max(20, legendItemHeight) * (legendStep + 1) : 0;
6870
+ legendStep = _$$$state3.legendStep,
6871
+ isFitPadding = ((_$$$config$padding = $$.config.padding) == null ? void 0 : _$$$config$padding.mode) === "fit";
6872
+ return $$.config.legend_show ? isLegendRight ? current.height : (isFitPadding ? 10 : Math.max(20, legendItemHeight)) * (legendStep + 1) : 0;
6816
6873
  },
6817
6874
  /**
6818
6875
  * Get the opacity of the legend that is unfocused
@@ -7583,20 +7640,6 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
7583
7640
 
7584
7641
  // Draw with new sizes & scales
7585
7642
  $$.redraw(options, transitions);
7586
- },
7587
- /**
7588
- * Redraw without rescale
7589
- * @private
7590
- */
7591
- redrawWithoutRescale: function redrawWithoutRescale() {
7592
- this.redraw({
7593
- withY: !1,
7594
- withDimension: !1,
7595
- withLegend: !1,
7596
- withSubchart: !1,
7597
- withEventRect: !1,
7598
- withTransitionForAxis: !1
7599
- });
7600
7643
  }
7601
7644
  });
7602
7645
  ;// CONCATENATED MODULE: ./src/ChartInternal/internals/scale.ts
@@ -7649,7 +7692,7 @@ function getScale(type, min, max) {
7649
7692
  getXScale: function getXScale(min, max, domain, offset) {
7650
7693
  var $$ = this,
7651
7694
  scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
7652
- return $$.getCustomizedScale(domain ? scale.domain(domain) : scale, offset);
7695
+ return $$.getCustomizedXScale(domain ? scale.domain(domain) : scale, offset);
7653
7696
  },
7654
7697
  /**
7655
7698
  * Get y Axis scale function
@@ -7683,19 +7726,20 @@ function getScale(type, min, max) {
7683
7726
  return this.scale[key];
7684
7727
  },
7685
7728
  /**
7686
- * Get customized scale
7729
+ * Get customized x axis scale
7687
7730
  * @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
7688
7731
  * @param {Function} offsetValue Offset getter to be sum
7689
7732
  * @returns {Function} Scale function
7690
7733
  * @private
7691
7734
  */
7692
- getCustomizedScale: function getCustomizedScale(scaleValue, offsetValue) {
7735
+ getCustomizedXScale: function getCustomizedXScale(scaleValue, offsetValue) {
7693
7736
  var _this = this,
7694
7737
  $$ = this,
7695
7738
  offset = offsetValue || function () {
7696
7739
  _newArrowCheck(this, _this);
7697
7740
  return $$.axis.x.tickOffset();
7698
7741
  }.bind(this),
7742
+ isInverted = $$.config.axis_x_inverted,
7699
7743
  scale = function (d, raw) {
7700
7744
  var v = scaleValue(d) + offset();
7701
7745
  return raw ? v : Math.ceil(v);
@@ -7719,7 +7763,7 @@ function getScale(type, min, max) {
7719
7763
  var domain = domainValue;
7720
7764
  if (!arguments.length) {
7721
7765
  domain = this.orgDomain();
7722
- return [domain[0], domain[1] + 1];
7766
+ return isInverted ? [domain[0] + 1, domain[1]] : [domain[0], domain[1] + 1];
7723
7767
  }
7724
7768
  scaleValue.domain(domain);
7725
7769
  return scale;
@@ -8362,47 +8406,60 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8362
8406
  return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
8363
8407
  },
8364
8408
  getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
8365
- var $$ = this,
8409
+ var _config$padding,
8410
+ $$ = this,
8366
8411
  config = $$.config,
8367
8412
  hasAxis = $$.state.hasAxis,
8368
8413
  isRotated = config.axis_rotated,
8414
+ isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
8369
8415
  axisId = isRotated ? "x" : "y",
8370
8416
  axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
8371
8417
  axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0;
8372
- var padding;
8418
+ if (!isFitPadding) {
8419
+ axisWidth = ceil10(axisWidth);
8420
+ }
8421
+ var padding = config["axis_" + axisId + "_inner"] || !config["axis_" + axisId + "_show"] ? 0 : axisWidth;
8373
8422
  if (isValue(config.padding_left)) {
8374
- padding = config.padding_left;
8423
+ padding = config.padding_left + (isFitPadding && isRotated ? axisWidth : 0);
8375
8424
  } else if (hasAxis && isRotated) {
8376
- padding = !config.axis_x_show ? 1 : Math.max(ceil10(axisWidth), 40);
8377
- } else if (hasAxis && (!config.axis_y_show || config.axis_y_inner)) {
8378
- // && !config.axis_rotated
8379
- padding = $$.axis.getAxisLabelPosition("y").isOuter ? 30 : 1;
8380
- } else {
8381
- padding = ceil10(axisWidth);
8425
+ padding = !config.axis_x_show ? 1 : isFitPadding ? axisWidth : Math.max(axisWidth, 40);
8426
+ }
8427
+ if (hasAxis && (isFitPadding || config["axis_" + axisId + "_inner"]) && config["axis_" + axisId + "_label"].text) {
8428
+ padding += $$.axis.getAxisLabelPosition("y").isOuter ? 20 : 0;
8382
8429
  }
8383
8430
  return padding + axisWidth * axesLen;
8384
8431
  },
8385
8432
  getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
8433
+ var _config$padding2, _$$$axis;
8386
8434
  if (withXAxisTickTextOverflow === void 0) {
8387
8435
  withXAxisTickTextOverflow = !1;
8388
8436
  }
8389
8437
  var $$ = this,
8390
8438
  config = $$.config,
8391
8439
  hasAxis = $$.state.hasAxis,
8440
+ isRotated = config.axis_rotated,
8441
+ isFitPadding = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit",
8442
+ defaultPadding = isFitPadding ? 2 : 10,
8392
8443
  legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
8393
8444
  axesLen = hasAxis ? config.axis_y2_axes.length : 0,
8394
- axisWidth = hasAxis ? $$.getAxisWidthByAxisId("y2") : 0,
8395
- xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(10) : 0;
8396
- var padding;
8445
+ axisLabelWidth = (_$$$axis = $$.axis) != null && _$$$axis.getAxisLabelPosition("y2").isOuter ? 20 : 0,
8446
+ xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
8447
+ var axisWidth = hasAxis && !config.axis_y2_inner ? $$.getAxisWidthByAxisId("y2") : 1;
8448
+ if (!isFitPadding) {
8449
+ axisWidth = ceil10(axisWidth);
8450
+ }
8451
+ var padding = isRotated ? 0 : Math.max(axisWidth + legendWidthOnRight, xAxisTickTextOverflow);
8397
8452
  if (isValue(config.padding_right)) {
8398
- padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
8399
- } else if ($$.axis && config.axis_rotated) {
8400
- padding = 10 + legendWidthOnRight;
8453
+ // padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
8454
+
8455
+ padding = config.padding_right + (isFitPadding && (isRotated || !config.axis_y2_show ? defaultPadding : padding)) + (hasAxis && !isFitPadding ? 1 : 0); // 1 is needed not to hide tick line
8456
+ } else if ($$.axis && isRotated) {
8457
+ padding = defaultPadding + legendWidthOnRight;
8401
8458
  } else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
8402
- // && !config.axis_rotated
8403
- padding = Math.max(2 + legendWidthOnRight + ($$.axis.getAxisLabelPosition("y2").isOuter ? 20 : 0), xAxisTickTextOverflow);
8404
- } else {
8405
- padding = Math.max(ceil10(axisWidth) + legendWidthOnRight, xAxisTickTextOverflow);
8459
+ padding = Math.max((isFitPadding && !config.axis_y2_show ? 2 : 1) + legendWidthOnRight + axisLabelWidth, xAxisTickTextOverflow);
8460
+ }
8461
+ if (hasAxis && !isRotated && isFitPadding && config.axis_y2_show && !config.axis_y2_inner && config.axis_y2_label.text) {
8462
+ padding += axisLabelWidth;
8406
8463
  }
8407
8464
  return padding + axisWidth * axesLen;
8408
8465
  },
@@ -8541,12 +8598,14 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8541
8598
  * @private
8542
8599
  */
8543
8600
  updateSizes: function updateSizes(isInit) {
8544
- var $$ = this,
8601
+ var _config$padding3,
8602
+ $$ = this,
8545
8603
  config = $$.config,
8546
8604
  state = $$.state,
8547
8605
  legend = $$.$el.legend,
8548
8606
  isRotated = config.axis_rotated,
8549
- isNonAxis = $$.hasArcType() || state.hasTreemap;
8607
+ isNonAxis = $$.hasArcType() || state.hasTreemap,
8608
+ isFitPadding = ((_config$padding3 = config.padding) == null ? void 0 : _config$padding3.mode) === "fit";
8550
8609
  isInit || $$.setContainerSize();
8551
8610
  var currLegend = {
8552
8611
  width: legend ? $$.getLegendWidth() : 0,
@@ -8567,7 +8626,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8567
8626
  bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + padding.bottom,
8568
8627
  left: subchartHeight + (isNonAxis ? 0 : padding.left)
8569
8628
  } : {
8570
- top: 4 + padding.top,
8629
+ top: (isFitPadding ? 0 : 4) + padding.top,
8571
8630
  // for top tick text
8572
8631
  right: isNonAxis ? 0 : $$.getCurrentPaddingRight(!0),
8573
8632
  bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
@@ -9836,7 +9895,7 @@ function getTextPos(pos, width) {
9836
9895
  y = isRotated ? state.height + padding : 0;
9837
9896
  } else if (target === "y2") {
9838
9897
  x = isRotated ? 0 : state.width + padding;
9839
- y = isRotated ? 1 - padding : 0;
9898
+ y = isRotated && padding ? 1 - padding : 0;
9840
9899
  } else if (target === "subX") {
9841
9900
  x = 0;
9842
9901
  y = isRotated ? 0 : state.height2;
@@ -9888,6 +9947,15 @@ function getTextPos(pos, width) {
9888
9947
 
9889
9948
 
9890
9949
  /* harmony default export */ var type = ({
9950
+ /**
9951
+ * Check if the given chart type is valid
9952
+ * @param {string} type Chart type string
9953
+ * @returns {boolean}
9954
+ * @private
9955
+ */
9956
+ isValidChartType: function isValidChartType(type) {
9957
+ return !!(type && Object.values(TYPE).indexOf(type) > -1);
9958
+ },
9891
9959
  setTargetType: function setTargetType(targetIds, type) {
9892
9960
  var _this = this,
9893
9961
  $$ = this,
@@ -10455,7 +10523,7 @@ var ChartInternal = /*#__PURE__*/function () {
10455
10523
 
10456
10524
  // Set domains for each scale
10457
10525
  if (x) {
10458
- x.domain(sortValue($$.getXDomain($$.data.targets)));
10526
+ x.domain(sortValue($$.getXDomain($$.data.targets), !config.axis_x_inverted));
10459
10527
  subX.domain(x.domain());
10460
10528
 
10461
10529
  // Save original x domain for zoom update
@@ -11715,17 +11783,17 @@ function renderText(ctx, glyph) {
11715
11783
  state.defocusedTargetIds = targetIds;
11716
11784
  },
11717
11785
  /**
11718
- * This API reverts specified targets.<br><br>
11719
- * 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.
11786
+ * Revert focused or defocused state to initial state.<br><br>
11787
+ * 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.
11720
11788
  * @function revert
11721
11789
  * @instance
11722
11790
  * @memberof Chart
11723
11791
  * @param {string|Array} targetIdsValue Target ids to be reverted
11724
11792
  * @example
11725
- * // data1 will be reverted.
11793
+ * // 'data1' will be reverted.
11726
11794
  * chart.revert("data1");
11727
11795
  *
11728
- * // data1 and data2 will be reverted.
11796
+ * // 'data1' and 'data2' will be reverted.
11729
11797
  * chart.revert(["data1", "data2"]);
11730
11798
  *
11731
11799
  * // all targets will be reverted.
@@ -11827,6 +11895,7 @@ var legend_legend = {
11827
11895
  */
11828
11896
 
11829
11897
 
11898
+
11830
11899
  /* harmony default export */ var api_load = ({
11831
11900
  /**
11832
11901
  * Load data to the chart.<br><br>
@@ -11841,23 +11910,29 @@ var legend_legend = {
11841
11910
  * @memberof Chart
11842
11911
  * @param {object} args The object can consist with following members:<br>
11843
11912
  *
11844
- * | Key | Description |
11845
- * | --- | --- |
11846
- * | - url<br>- json<br>- rows<br>- columns | The 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 |
11847
- * | data | Data objects to be loaded. Checkout the example. |
11848
- * | append | 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. |
11849
- * | names | Same as data.names() |
11850
- * | xs | Same as data.xs option |
11851
- * | classes | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
11852
- * | categories | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
11853
- * | axes | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
11854
- * | colors | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
11855
- * | headers | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
11856
- * | keys | 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) |
11857
- * | mimeType | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
11858
- * | - type<br>- types | The type of targets will be updated. type must be String and types must be Object. |
11859
- * | unload | 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. |
11860
- * | done | The specified function will be called after data loaded.|
11913
+ * | Key | Type | Description |
11914
+ * | --- | --- | --- |
11915
+ * | 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 |
11916
+ * | 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 |
11917
+ * | 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 |
11918
+ * | 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 |
11919
+ * | &nbsp; | | |
11920
+ * | 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. |
11921
+ * | axes | Object | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
11922
+ * | categories | Array | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
11923
+ * | classes | Object | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
11924
+ * | colors | Object | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
11925
+ * | data | Obejct | Data objects to be loaded. Checkout the example. |
11926
+ * | done | Function | The specified function will be called after data loaded.|
11927
+ * | headers | string | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
11928
+ * | 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) |
11929
+ * | mimeType | string | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
11930
+ * | names | Object | Same as data.names() |
11931
+ * | 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. |
11932
+ * | type | string | The type of targets will be updated. |
11933
+ * | types | Object | The types of targets will be updated. |
11934
+ * | 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. |
11935
+ * | xs | string | Same as data.xs option |
11861
11936
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataFromURL)
11862
11937
  * @example
11863
11938
  * // Load data1 and unload data2 and data3
@@ -11869,6 +11944,7 @@ var legend_legend = {
11869
11944
  * unload: ["data2", "data3"],
11870
11945
  * url: "...",
11871
11946
  * done: function() { ... }
11947
+ * resizeAfter: true // will resize after load
11872
11948
  * });
11873
11949
  * @example
11874
11950
  * const chart = bb.generate({
@@ -11998,7 +12074,7 @@ var legend_legend = {
11998
12074
  _newArrowCheck(this, _this);
11999
12075
  // to mitigate improper rendering for multiple consecutive calls
12000
12076
  // https://github.com/naver/billboard.js/issues/2121
12001
- win.requestIdleCallback(function () {
12077
+ requestIdleCallback(function () {
12002
12078
  _newArrowCheck(this, _this2);
12003
12079
  return $$.loadFromArgs(args);
12004
12080
  }.bind(this));
@@ -12022,13 +12098,15 @@ var legend_legend = {
12022
12098
  * | --- | --- | --- |
12023
12099
  * | ids | String &vert; Array | Target id data to be unloaded. If not given, all data will be unloaded. |
12024
12100
  * | done | Fuction | Callback after data is unloaded. |
12101
+ * | 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. |
12025
12102
  * @example
12026
12103
  * // Unload data2 and data3
12027
12104
  * chart.unload({
12028
12105
  * ids: ["data2", "data3"],
12029
12106
  * done: function() {
12030
12107
  * // called after the unloaded
12031
- * }
12108
+ * },
12109
+ * resizeAfter: true // will resize after unload
12032
12110
  * });
12033
12111
  */
12034
12112
  unload: function unload(argsValue) {
@@ -12053,7 +12131,7 @@ var legend_legend = {
12053
12131
  withLegend: !0
12054
12132
  });
12055
12133
  $$.cache.remove(ids);
12056
- args.done && args.done.call(this);
12134
+ callDone.call($$, args.done, args.resizeAfter);
12057
12135
  }.bind(this));
12058
12136
  }
12059
12137
  });
@@ -12740,19 +12818,61 @@ var axis = {
12740
12818
  return config.axis_x_categories;
12741
12819
  }
12742
12820
  });
12743
- ;// CONCATENATED MODULE: ./src/Chart/api/grid.x.ts
12821
+ ;// CONCATENATED MODULE: ./src/Chart/api/grid.ts
12744
12822
  /**
12745
12823
  * Copyright (c) 2017 ~ present NAVER Corp.
12746
12824
  * billboard.js project is licensed under the MIT license
12747
12825
  */
12748
12826
 
12827
+ /**
12828
+ * Update grid lines.
12829
+ * @param {Array} grids grid lines to update
12830
+ * @param {string} axisId axis' id: "x" or "y"
12831
+ * @returns {Array}
12832
+ * @private
12833
+ */
12834
+ function grid(grids, axisId) {
12835
+ var $$ = this.internal,
12836
+ config = $$.config,
12837
+ withTransition = config.transition_duration && isTabVisible(),
12838
+ gridPropLines = "grid_" + axisId + "_lines";
12839
+ if (!grids) {
12840
+ return config[gridPropLines];
12841
+ }
12842
+ config[gridPropLines] = grids;
12843
+ $$.updateGrid();
12844
+ $$.redrawGrid(withTransition);
12845
+ return config[gridPropLines];
12846
+ }
12847
+
12848
+ /**
12849
+ * Add grid lines.
12850
+ * @param {Array|object} grids grid lines to add
12851
+ * @param {string} axisId axis' id: "x" or "y"
12852
+ * @returns {Array}
12853
+ * @private
12854
+ */
12855
+ function _add(grids, axisId) {
12856
+ return grid.bind(this)(this.internal.config["grid_" + axisId + "_lines"].concat(grids || []), axisId);
12857
+ }
12858
+
12859
+ /**
12860
+ * Remove grid lines.
12861
+ * @param {object} grids grid lines to remove
12862
+ * @param {boolean} isXAxis weather is x axis or not
12863
+ * @private
12864
+ */
12865
+ function _remove(grids, isXAxis) {
12866
+ this.internal.removeGridLines(grids, isXAxis);
12867
+ }
12868
+
12749
12869
  /**
12750
12870
  * Update x grid lines.
12751
12871
  * @function xgrids
12752
12872
  * @instance
12753
12873
  * @memberof Chart
12754
12874
  * @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
12755
- * @returns {object}
12875
+ * @returns {Array}
12756
12876
  * @example
12757
12877
  * // Show 2 x grid lines
12758
12878
  * chart.xgrids([
@@ -12762,14 +12882,7 @@ var axis = {
12762
12882
  * // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
12763
12883
  */
12764
12884
  var xgrids = function (grids) {
12765
- var $$ = this.internal,
12766
- config = $$.config;
12767
- if (!grids) {
12768
- return config.grid_x_lines;
12769
- }
12770
- config.grid_x_lines = grids;
12771
- $$.redrawWithoutRescale();
12772
- return config.grid_x_lines;
12885
+ return grid.bind(this)(grids, "x");
12773
12886
  };
12774
12887
  extend(xgrids, {
12775
12888
  /**
@@ -12779,7 +12892,7 @@ extend(xgrids, {
12779
12892
  * @instance
12780
12893
  * @memberof Chart
12781
12894
  * @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.
12782
- * @returns {object}
12895
+ * @returns {Array}
12783
12896
  * @example
12784
12897
  * // Add a new x grid line
12785
12898
  * chart.xgrids.add(
@@ -12793,7 +12906,7 @@ extend(xgrids, {
12793
12906
  * ]);
12794
12907
  */
12795
12908
  add: function add(grids) {
12796
- return this.xgrids(this.internal.config.grid_x_lines.concat(grids || []));
12909
+ return _add.bind(this)(grids, "x");
12797
12910
  },
12798
12911
  /**
12799
12912
  * Remove x grid lines.<br>
@@ -12801,7 +12914,10 @@ extend(xgrids, {
12801
12914
  * @function xgrids․remove
12802
12915
  * @instance
12803
12916
  * @memberof Chart
12804
- * @param {object} params 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.
12917
+ * @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.
12918
+ * @param {number} [grids.value] target value
12919
+ * @param {string} [grids.class] target class
12920
+ * @returns {void}
12805
12921
  * @example
12806
12922
  * // x grid line on x = 2 will be removed
12807
12923
  * chart.xgrids.remove({value: 2});
@@ -12814,20 +12930,11 @@ extend(xgrids, {
12814
12930
  * // all of x grid lines will be removed
12815
12931
  * chart.xgrids.remove();
12816
12932
  */
12817
- remove: function remove(params) {
12933
+ remove: function remove(grids) {
12818
12934
  // TODO: multiple
12819
- this.internal.removeGridLines(params, !0);
12935
+ return _remove.bind(this)(grids, !0);
12820
12936
  }
12821
12937
  });
12822
- /* harmony default export */ var grid_x = ({
12823
- xgrids: xgrids
12824
- });
12825
- ;// CONCATENATED MODULE: ./src/Chart/api/grid.y.ts
12826
- /**
12827
- * Copyright (c) 2017 ~ present NAVER Corp.
12828
- * billboard.js project is licensed under the MIT license
12829
- */
12830
-
12831
12938
 
12832
12939
  /**
12833
12940
  * Update y grid lines.
@@ -12845,14 +12952,7 @@ extend(xgrids, {
12845
12952
  * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
12846
12953
  */
12847
12954
  var ygrids = function (grids) {
12848
- var $$ = this.internal,
12849
- config = $$.config;
12850
- if (!grids) {
12851
- return config.grid_y_lines;
12852
- }
12853
- config.grid_y_lines = grids;
12854
- $$.redrawWithoutRescale();
12855
- return config.grid_y_lines;
12955
+ return grid.bind(this)(grids, "y");
12856
12956
  };
12857
12957
  extend(ygrids, {
12858
12958
  /**
@@ -12876,7 +12976,7 @@ extend(ygrids, {
12876
12976
  * ]);
12877
12977
  */
12878
12978
  add: function add(grids) {
12879
- return this.ygrids(this.internal.config.grid_y_lines.concat(grids || []));
12979
+ return _add.bind(this)(grids, "y");
12880
12980
  },
12881
12981
  /**
12882
12982
  * Remove y grid lines.<br>
@@ -12884,9 +12984,10 @@ extend(ygrids, {
12884
12984
  * @function ygrids․remove
12885
12985
  * @instance
12886
12986
  * @memberof Chart
12887
- * @param {object} params 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.
12888
- * @param {number} [params.value] target value
12889
- * @param {string} [params.class] target class
12987
+ * @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.
12988
+ * @param {number} [grids.value] target value
12989
+ * @param {string} [grids.class] target class
12990
+ * @returns {void}
12890
12991
  * @example
12891
12992
  * // y grid line on y = 200 will be removed
12892
12993
  * chart.ygrids.remove({value: 200});
@@ -12899,12 +13000,13 @@ extend(ygrids, {
12899
13000
  * // all of y grid lines will be removed
12900
13001
  * chart.ygrids.remove();
12901
13002
  */
12902
- remove: function remove(params) {
13003
+ remove: function remove(grids) {
12903
13004
  // TODO: multiple
12904
- this.internal.removeGridLines(params, !1);
13005
+ return _remove.bind(this)(grids, !1);
12905
13006
  }
12906
13007
  });
12907
- /* harmony default export */ var grid_y = ({
13008
+ /* harmony default export */ var api_grid = ({
13009
+ xgrids: xgrids,
12908
13010
  ygrids: ygrids
12909
13011
  });
12910
13012
  ;// CONCATENATED MODULE: ./src/Chart/api/group.ts
@@ -12946,6 +13048,29 @@ extend(ygrids, {
12946
13048
  */
12947
13049
 
12948
13050
 
13051
+ /**
13052
+ * Region add/update function
13053
+ * @param {Array} regions Regions will be replaced with this argument. The format of this argument is the same as regions.
13054
+ * @param {boolean} isAdd If true, add new regions, otherwise update regions
13055
+ * @returns {Array} regions
13056
+ * @private
13057
+ */
13058
+ function regionsFn(regions, isAdd) {
13059
+ if (isAdd === void 0) {
13060
+ isAdd = !1;
13061
+ }
13062
+ var $$ = this.internal,
13063
+ config = $$.config,
13064
+ withTransition = config.transition_duration && isTabVisible();
13065
+ if (!regions) {
13066
+ return config.regions;
13067
+ }
13068
+ config.regions = isAdd ? config.regions.concat(regions) : regions;
13069
+ $$.updateRegion();
13070
+ $$.redrawRegion(withTransition);
13071
+ return isAdd ? config.regions : regions;
13072
+ }
13073
+
12949
13074
  /**
12950
13075
  * Update regions.
12951
13076
  * @function regions
@@ -12961,14 +13086,7 @@ extend(ygrids, {
12961
13086
  * ]);
12962
13087
  */
12963
13088
  var regions = function (_regions) {
12964
- var $$ = this.internal,
12965
- config = $$.config;
12966
- if (!_regions) {
12967
- return config.regions;
12968
- }
12969
- config.regions = _regions;
12970
- $$.redrawWithoutRescale();
12971
- return _regions;
13089
+ return regionsFn.bind(this)(_regions);
12972
13090
  };
12973
13091
  extend(regions, {
12974
13092
  /**
@@ -12992,14 +13110,7 @@ extend(regions, {
12992
13110
  *]);
12993
13111
  */
12994
13112
  add: function add(regions) {
12995
- var $$ = this.internal,
12996
- config = $$.config;
12997
- if (!regions) {
12998
- return config.regions;
12999
- }
13000
- config.regions = config.regions.concat(regions);
13001
- $$.redrawWithoutRescale();
13002
- return config.regions;
13113
+ return regionsFn.bind(this)(regions, !0);
13003
13114
  },
13004
13115
  /**
13005
13116
  * Remove regions.<br><br>
@@ -13821,7 +13932,7 @@ var AxisRenderer = /*#__PURE__*/function () {
13821
13932
  }
13822
13933
  var tickWidth = params.tickWidth;
13823
13934
  if (!tickWidth || tickWidth <= 0) {
13824
- tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
13935
+ tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(params.isInverted ? scale(ticks[0]) - scale(ticks[1]) : scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
13825
13936
  }
13826
13937
 
13827
13938
  // split given text by tick width size
@@ -14229,6 +14340,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14229
14340
  owner: $$
14230
14341
  }, isX && {
14231
14342
  isCategory: isCategory,
14343
+ isInverted: config.axis_x_inverted,
14232
14344
  tickMultiline: config.axis_x_tick_multiline,
14233
14345
  tickWidth: config.axis_x_tick_width,
14234
14346
  tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
@@ -14848,11 +14960,13 @@ var Axis_Axis = /*#__PURE__*/function () {
14848
14960
  * @private
14849
14961
  */
14850
14962
  redrawEventRect: function redrawEventRect() {
14851
- var $$ = this,
14963
+ var _this = this,
14964
+ $$ = this,
14852
14965
  config = $$.config,
14853
14966
  state = $$.state,
14854
14967
  $el = $$.$el,
14855
- isMultipleX = $$.isMultipleX();
14968
+ isMultipleX = $$.isMultipleX(),
14969
+ isInverted = config.axis_x_inverted;
14856
14970
  if ($el.eventRect) {
14857
14971
  $$.updateEventRect($el.eventRect, !0);
14858
14972
  } else {
@@ -14873,6 +14987,12 @@ var Axis_Axis = /*#__PURE__*/function () {
14873
14987
  if (!isMultipleX) {
14874
14988
  // Set data and update eventReceiver.data
14875
14989
  var xAxisTickValues = $$.getMaxDataCountTarget();
14990
+ if (!config.data_xSort || isInverted) {
14991
+ xAxisTickValues.sort(function (a, b) {
14992
+ _newArrowCheck(this, _this);
14993
+ return isInverted ? b.x - a.x : a.x - b.x;
14994
+ }.bind(this));
14995
+ }
14876
14996
 
14877
14997
  // update data's index value to be alinged with the x Axis
14878
14998
  $$.updateDataIndexByX(xAxisTickValues);
@@ -14883,7 +15003,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14883
15003
  $$.updateEventRectData();
14884
15004
  },
14885
15005
  bindTouchOnEventRect: function bindTouchOnEventRect(isMultipleX) {
14886
- var _this = this,
15006
+ var _this2 = this,
14887
15007
  $$ = this,
14888
15008
  config = $$.config,
14889
15009
  state = $$.state,
@@ -14891,7 +15011,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14891
15011
  eventRect = _$$$$el.eventRect,
14892
15012
  svg = _$$$$el.svg,
14893
15013
  selectRect = function (context) {
14894
- _newArrowCheck(this, _this);
15014
+ _newArrowCheck(this, _this2);
14895
15015
  if (isMultipleX) {
14896
15016
  $$.selectRectForMultipleXs(context);
14897
15017
  } else {
@@ -14901,7 +15021,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14901
15021
  }
14902
15022
  }.bind(this),
14903
15023
  unselectRect = function () {
14904
- _newArrowCheck(this, _this);
15024
+ _newArrowCheck(this, _this2);
14905
15025
  $$.unselectRect();
14906
15026
  $$.callOverOutForTouch();
14907
15027
  }.bind(this),
@@ -14910,7 +15030,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14910
15030
  preventThreshold = !isNaN(preventDefault) && preventDefault || null,
14911
15031
  startPx,
14912
15032
  preventEvent = function (event) {
14913
- _newArrowCheck(this, _this);
15033
+ _newArrowCheck(this, _this2);
14914
15034
  var eventType = event.type,
14915
15035
  touch = event.changedTouches[0],
14916
15036
  currentXY = touch["client" + (config.axis_rotated ? "Y" : "X")];
@@ -14931,11 +15051,11 @@ var Axis_Axis = /*#__PURE__*/function () {
14931
15051
  }.bind(this);
14932
15052
  // bind touch events
14933
15053
  eventRect.on("touchstart", function (event) {
14934
- _newArrowCheck(this, _this);
15054
+ _newArrowCheck(this, _this2);
14935
15055
  state.event = event;
14936
15056
  $$.updateEventRect();
14937
15057
  }.bind(this)).on("touchstart.eventRect touchmove.eventRect", function (event) {
14938
- _newArrowCheck(this, _this);
15058
+ _newArrowCheck(this, _this2);
14939
15059
  state.event = event;
14940
15060
  if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
14941
15061
  // if touch points are > 1, means doing zooming interaction. In this case do not execute tooltip codes.
@@ -14948,7 +15068,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14948
15068
  unselectRect();
14949
15069
  }
14950
15070
  }.bind(this), !0).on("touchend.eventRect", function (event) {
14951
- _newArrowCheck(this, _this);
15071
+ _newArrowCheck(this, _this2);
14952
15072
  state.event = event;
14953
15073
  if (!eventRect.empty() && eventRect.classed($EVENT.eventRect)) {
14954
15074
  if ($$.hasArcType() || !$$.toggleShape || state.cancelClick) {
@@ -14957,7 +15077,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14957
15077
  }
14958
15078
  }.bind(this), !0);
14959
15079
  svg.on("touchstart", function (event) {
14960
- _newArrowCheck(this, _this);
15080
+ _newArrowCheck(this, _this2);
14961
15081
  state.event = event;
14962
15082
  var target = event.target;
14963
15083
  if (target && target !== eventRect.node()) {
@@ -14972,7 +15092,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14972
15092
  * @private
14973
15093
  */
14974
15094
  updateEventRect: function updateEventRect(eventRect, force) {
14975
- var _this2 = this;
15095
+ var _this3 = this;
14976
15096
  if (force === void 0) {
14977
15097
  force = !1;
14978
15098
  }
@@ -14987,7 +15107,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14987
15107
  resizing = _state.resizing,
14988
15108
  rectElement = eventRect || $el.eventRect,
14989
15109
  updateClientRect = function () {
14990
- _newArrowCheck(this, _this2);
15110
+ _newArrowCheck(this, _this3);
14991
15111
  eventReceiver && (eventReceiver.rect = rectElement.node().getBoundingClientRect());
14992
15112
  }.bind(this);
14993
15113
  if (!rendered || resizing || force) {
@@ -15005,7 +15125,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15005
15125
  * @private
15006
15126
  */
15007
15127
  updateEventRectData: function updateEventRectData() {
15008
- var _this3 = this,
15128
+ var _this4 = this,
15009
15129
  $$ = this,
15010
15130
  config = $$.config,
15011
15131
  scale = $$.scale,
@@ -15027,21 +15147,21 @@ var Axis_Axis = /*#__PURE__*/function () {
15027
15147
  if ($$.axis.isCategorized()) {
15028
15148
  rectW = $$.getEventRectWidth();
15029
15149
  rectX = function (d) {
15030
- _newArrowCheck(this, _this3);
15150
+ _newArrowCheck(this, _this4);
15031
15151
  return xScale(d.x) - rectW / 2;
15032
15152
  }.bind(this);
15033
15153
  } else {
15034
15154
  var getPrevNextX = function (_ref) {
15035
15155
  var index = _ref.index;
15036
- _newArrowCheck(this, _this3);
15156
+ _newArrowCheck(this, _this4);
15037
15157
  return {
15038
15158
  prev: $$.getPrevX(index),
15039
15159
  next: $$.getNextX(index)
15040
15160
  };
15041
15161
  }.bind(this);
15042
15162
  rectW = function (d) {
15043
- var _this4 = this;
15044
- _newArrowCheck(this, _this3);
15163
+ var _this5 = this;
15164
+ _newArrowCheck(this, _this4);
15045
15165
  var x = getPrevNextX(d),
15046
15166
  xDomain = xScale.domain();
15047
15167
  var val;
@@ -15056,7 +15176,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15056
15176
  } else {
15057
15177
  Object.keys(x).forEach(function (key, i) {
15058
15178
  var _x$key;
15059
- _newArrowCheck(this, _this4);
15179
+ _newArrowCheck(this, _this5);
15060
15180
  x[key] = (_x$key = x[key]) != null ? _x$key : xDomain[i];
15061
15181
  }.bind(this));
15062
15182
  val = Math.max(0, (xScale(x.next) - xScale(x.prev)) / 2);
@@ -15064,7 +15184,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15064
15184
  return val;
15065
15185
  }.bind(this);
15066
15186
  rectX = function (d) {
15067
- _newArrowCheck(this, _this3);
15187
+ _newArrowCheck(this, _this4);
15068
15188
  var x = getPrevNextX(d);
15069
15189
  var val;
15070
15190
 
@@ -15086,13 +15206,13 @@ var Axis_Axis = /*#__PURE__*/function () {
15086
15206
  }
15087
15207
  var eventReceiver = state.eventReceiver,
15088
15208
  call = function (fn, v) {
15089
- _newArrowCheck(this, _this3);
15209
+ _newArrowCheck(this, _this4);
15090
15210
  return isFunction(fn) ? fn(v) : fn;
15091
15211
  }.bind(this);
15092
15212
  // reset for possible remains coords data before the data loading
15093
15213
  eventReceiver.coords.splice(eventReceiver.data.length);
15094
15214
  eventReceiver.data.forEach(function (d, i) {
15095
- _newArrowCheck(this, _this3);
15215
+ _newArrowCheck(this, _this4);
15096
15216
  eventReceiver.coords[i] = {
15097
15217
  x: call(x, d),
15098
15218
  y: call(y, d),
@@ -15102,7 +15222,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15102
15222
  }.bind(this));
15103
15223
  },
15104
15224
  selectRectForMultipleXs: function selectRectForMultipleXs(context) {
15105
- var _this5 = this,
15225
+ var _this6 = this,
15106
15226
  $$ = this,
15107
15227
  config = $$.config,
15108
15228
  state = $$.state,
@@ -15123,7 +15243,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15123
15243
  }
15124
15244
  var sameXData = $$.isBubbleType(closest) || $$.isScatterType(closest) || !config.tooltip_grouped ? [closest] : $$.filterByX(targetsToShow, closest.x),
15125
15245
  selectedData = sameXData.map(function (d) {
15126
- _newArrowCheck(this, _this5);
15246
+ _newArrowCheck(this, _this6);
15127
15247
  return $$.addName(d);
15128
15248
  }.bind(this)); // show tooltip when cursor is close to some point
15129
15249
  $$.showTooltip(selectedData, context);
@@ -15170,7 +15290,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15170
15290
  * @private
15171
15291
  */
15172
15292
  generateEventRectsForSingleX: function generateEventRectsForSingleX(eventRectEnter) {
15173
- var _this6 = this,
15293
+ var _this7 = this,
15174
15294
  $$ = this,
15175
15295
  config = $$.config,
15176
15296
  state = $$.state,
@@ -15184,12 +15304,12 @@ var Axis_Axis = /*#__PURE__*/function () {
15184
15304
  });
15185
15305
  if (state.inputType === "mouse") {
15186
15306
  var getData = function (event) {
15187
- _newArrowCheck(this, _this6);
15307
+ _newArrowCheck(this, _this7);
15188
15308
  var index = event ? $$.getDataIndexFromEvent(event) : eventReceiver.currentIdx;
15189
15309
  return index > -1 ? eventReceiver.data[index] : null;
15190
15310
  }.bind(this);
15191
15311
  rect.on("mouseover", function (event) {
15192
- _newArrowCheck(this, _this6);
15312
+ _newArrowCheck(this, _this7);
15193
15313
  state.event = event;
15194
15314
  $$.updateEventRect();
15195
15315
  }.bind(this)).on("mousemove", function (event) {
@@ -15227,7 +15347,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15227
15347
  // to determine current interacting element, so use 'mousemove' event instead.
15228
15348
  $$.setOverOut(index !== -1, index);
15229
15349
  }).on("mouseout", function (event) {
15230
- _newArrowCheck(this, _this6);
15350
+ _newArrowCheck(this, _this7);
15231
15351
  state.event = event;
15232
15352
 
15233
15353
  // chart is destroyed
@@ -15267,7 +15387,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15267
15387
  * @private
15268
15388
  */
15269
15389
  generateEventRectsForMultipleXs: function generateEventRectsForMultipleXs(eventRectEnter) {
15270
- var _this7 = this,
15390
+ var _this8 = this,
15271
15391
  $$ = this,
15272
15392
  state = $$.state;
15273
15393
  eventRectEnter.on("click", function (event) {
@@ -15279,7 +15399,7 @@ var Axis_Axis = /*#__PURE__*/function () {
15279
15399
  state.event = event;
15280
15400
  $$.selectRectForMultipleXs(this);
15281
15401
  }).on("mouseout", function (event) {
15282
- _newArrowCheck(this, _this7);
15402
+ _newArrowCheck(this, _this8);
15283
15403
  state.event = event;
15284
15404
 
15285
15405
  // chart is destroyed
@@ -15607,7 +15727,8 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15607
15727
  * @private
15608
15728
  */
15609
15729
  setYAxisClipPath: function setYAxisClipPath(node) {
15610
- var $$ = this,
15730
+ var _config$padding,
15731
+ $$ = this,
15611
15732
  config = $$.config,
15612
15733
  _$$$state3 = $$.state,
15613
15734
  margin = _$$$state3.margin,
@@ -15616,10 +15737,10 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15616
15737
  isRotated = config.axis_rotated,
15617
15738
  left = Math.max(30, margin.left) - (isRotated ? 20 : 0),
15618
15739
  isInner = config.axis_y_inner,
15619
- x = isInner ? -1 : isRotated ? -(1 + left) : -(left - 1),
15740
+ x = isInner && !isRotated ? config.axis_y_label.text ? -20 : -1 : isRotated ? -(1 + left) : -(left - 1),
15620
15741
  y = -(isRotated ? 20 : margin.top),
15621
15742
  w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
15622
- h = (isRotated ? margin.bottom : margin.top + height) + 10;
15743
+ h = (isRotated ? margin.bottom + (((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit" ? 10 : 0) : margin.top + height) + 10;
15623
15744
  node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
15624
15745
  },
15625
15746
  updateXAxisTickClip: function updateXAxisTickClip() {
@@ -15725,7 +15846,7 @@ function smoothLines(el, type) {
15725
15846
  });
15726
15847
  }
15727
15848
  }
15728
- /* harmony default export */ var grid = ({
15849
+ /* harmony default export */ var internals_grid = ({
15729
15850
  hasGrid: function hasGrid() {
15730
15851
  var _this4 = this,
15731
15852
  config = this.config;
@@ -16237,14 +16358,16 @@ function smoothLines(el, type) {
16237
16358
  var _$$$axis,
16238
16359
  position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id),
16239
16360
  width = $$.axis.getMaxTickWidth(id, withoutRecompute),
16240
- gap = width === 0 ? .5 : 0;
16241
- return width + (position.isInner ? 20 + gap : 40);
16361
+ gap = width === 0 ? .5 : 0,
16362
+ _$$$config$padding;
16363
+ return width + (((_$$$config$padding = $$.config.padding) == null ? void 0 : _$$$config$padding.mode) === "fit" ? position.isInner ? 10 + gap : 10 : position.isInner ? 20 + gap : 40);
16242
16364
  } else {
16243
16365
  return 40;
16244
16366
  }
16245
16367
  },
16246
16368
  getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
16247
- var $$ = this,
16369
+ var _config$padding,
16370
+ $$ = this,
16248
16371
  config = $$.config,
16249
16372
  state = $$.state,
16250
16373
  _state = state,
@@ -16252,8 +16375,12 @@ function smoothLines(el, type) {
16252
16375
  rotatedPadding = _state.rotatedPadding,
16253
16376
  isLegendRight = _state.isLegendRight,
16254
16377
  isLegendInset = _state.isLegendInset,
16255
- isRotated = config.axis_rotated;
16256
- var h = 30;
16378
+ isRotated = config.axis_rotated,
16379
+ isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
16380
+ isInner = config["axis_" + id + "_inner"],
16381
+ hasLabelText = config["axis_" + id + "_label"].text,
16382
+ _config$padding2,
16383
+ h = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit" ? isInner && !hasLabelText ? id === "y" ? 1 : 0 : 20 : 30;
16257
16384
  if (id === "x" && !config.axis_x_show) {
16258
16385
  return 8;
16259
16386
  }
@@ -16264,7 +16391,7 @@ function smoothLines(el, type) {
16264
16391
  return config.legend_show && !isLegendRight && !isLegendInset ? 10 : 1;
16265
16392
  }
16266
16393
  if (id === "y2" && !config.axis_y2_show) {
16267
- return rotatedPadding.top;
16394
+ return isFitPadding ? 0 : rotatedPadding.top;
16268
16395
  }
16269
16396
  var rotate = $$.getAxisTickRotate(id);
16270
16397
 
@@ -16280,7 +16407,12 @@ function smoothLines(el, type) {
16280
16407
  return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
16281
16408
  },
16282
16409
  getEventRectWidth: function getEventRectWidth() {
16283
- return Math.max(0, this.axis.x.tickInterval());
16410
+ var $$ = this,
16411
+ config = $$.config,
16412
+ axis = $$.axis,
16413
+ isInverted = config.axis_x_inverted,
16414
+ tickInterval = axis.x.tickInterval();
16415
+ return Math.max(0, isInverted ? Math.abs(tickInterval) : tickInterval);
16284
16416
  },
16285
16417
  /**
16286
16418
  * Get axis tick test rotate value
@@ -16398,13 +16530,22 @@ function smoothLines(el, type) {
16398
16530
  data_xLocaltime: !0,
16399
16531
  /**
16400
16532
  * Sort on x axis.
16533
+ * - **NOTE:** This option works for lineish(area/line/spline/step) types only.
16401
16534
  * @name data․xSort
16402
16535
  * @memberof Options
16403
16536
  * @type {boolean}
16404
16537
  * @default true
16538
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataXSort)
16405
16539
  * @example
16406
16540
  * data: {
16407
- * xSort: false
16541
+ * xSort: false,
16542
+ * x: "x",
16543
+ * columns: [
16544
+ * // The line graph will start to be drawn following the x axis sequence
16545
+ * // Below data, wil start drawing x=1: 200, x=2: 300, x=3: 100
16546
+ * ["x", 3, 1, 2],
16547
+ * ["data1", 100, 200, 300]
16548
+ * ]
16408
16549
  * }
16409
16550
  */
16410
16551
  data_xSort: !0,
@@ -16964,6 +17105,22 @@ function smoothLines(el, type) {
16964
17105
  * }
16965
17106
  */
16966
17107
  axis_x_min: undefined,
17108
+ /**
17109
+ * Change the direction of x axis.<br><br>
17110
+ * If true set, the direction will be `right -> left`.
17111
+ * @name axis․x․inverted
17112
+ * @memberof Options
17113
+ * @type {boolean}
17114
+ * @default false
17115
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
17116
+ * @example
17117
+ * axis: {
17118
+ * x: {
17119
+ * inverted: true
17120
+ * }
17121
+ * }
17122
+ */
17123
+ axis_x_inverted: !1,
16967
17124
  /**
16968
17125
  * Set padding for x axis.<br><br>
16969
17126
  * If this option is set, the range of x axis will increase/decrease according to the values.
@@ -17226,11 +17383,12 @@ function smoothLines(el, type) {
17226
17383
  axis_y_min: undefined,
17227
17384
  /**
17228
17385
  * Change the direction of y axis.<br><br>
17229
- * If true set, the direction will be from the top to the bottom.
17386
+ * If true set, the direction will be `top -> bottom`.
17230
17387
  * @name axis․y․inverted
17231
17388
  * @memberof Options
17232
17389
  * @type {boolean}
17233
17390
  * @default false
17391
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
17234
17392
  * @example
17235
17393
  * axis: {
17236
17394
  * y: {
@@ -17704,11 +17862,12 @@ function smoothLines(el, type) {
17704
17862
  axis_y2_min: undefined,
17705
17863
  /**
17706
17864
  * Change the direction of y2 axis.<br><br>
17707
- * If true set, the direction will be from the top to the bottom.
17865
+ * If true set, the direction will be `top -> bottom`.
17708
17866
  * @name axis․y2․inverted
17709
17867
  * @memberof Options
17710
17868
  * @type {boolean}
17711
17869
  * @default false
17870
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
17712
17871
  * @example
17713
17872
  * axis: {
17714
17873
  * y2: {
@@ -18200,7 +18359,6 @@ function axis_objectSpread(target) { for (var i = 1, source; i < arguments.lengt
18200
18359
 
18201
18360
 
18202
18361
 
18203
-
18204
18362
  // ChartInternal
18205
18363
 
18206
18364
 
@@ -18214,8 +18372,8 @@ function axis_objectSpread(target) { for (var i = 1, source; i < arguments.lengt
18214
18372
 
18215
18373
 
18216
18374
 
18217
- var api = [api_axis, api_category, grid_x, grid_y, flow, group, api_regions, x];
18218
- var internal = [Axis, clip, eventrect, interactions_flow, grid, region, size_axis];
18375
+ var api = [api_axis, api_category, flow, api_grid, group, api_regions, x];
18376
+ var internal = [Axis, clip, eventrect, interactions_flow, internals_grid, region, size_axis];
18219
18377
  var options = [data_axis, axis_axis, common_grid];
18220
18378
  // EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
18221
18379
  var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
@@ -19320,11 +19478,11 @@ function getAttrTweenFn(fn) {
19320
19478
  pathRadius = ["", ""]; // switch points if axis is rotated, not applicable for sub chart
19321
19479
  var radius = 0;
19322
19480
  var isGrouped = $$.isGrouped(d.id),
19323
- isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : !1; // const hasRadius = d.value !== 0 && getRadius;
19324
- if (getRadius && (!isGrouped || isRadiusData)) {
19481
+ isRadiusData = getRadius && isGrouped ? $$.isStackingRadiusData(d) : !1;
19482
+ if (getRadius) {
19325
19483
  var index = isRotated ? indexY : indexX,
19326
19484
  barW = points[2][index] - points[0][index];
19327
- radius = getRadius(barW);
19485
+ radius = !isGrouped || isRadiusData ? getRadius(barW) : 0;
19328
19486
  var arc = "a" + radius + "," + radius + " " + (isNegative ? "1 0 0" : "0 0 1") + " ";
19329
19487
  pathRadius[+!isRotated] = "" + arc + radius + "," + radius;
19330
19488
  pathRadius[+isRotated] = "" + arc + [-radius, radius][isRotated ? "sort" : "reverse"]();
@@ -22951,17 +23109,21 @@ var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack
22951
23109
  * @param {Array} domain Target domain value
22952
23110
  * @param {Array} current Current zoom domain value
22953
23111
  * @param {Array} range Zoom range value
23112
+ * @param {boolean} isInverted Whether the axis is inverted or not
22954
23113
  * @returns {boolean}
22955
23114
  * @private
22956
23115
  */
22957
- function withinRange(domain, current, range) {
22958
- var _this = this,
22959
- min = range[0],
23116
+ function withinRange(domain, current, range, isInverted) {
23117
+ var _this = this;
23118
+ if (isInverted === void 0) {
23119
+ isInverted = !1;
23120
+ }
23121
+ var min = range[0],
22960
23122
  max = range[1];
22961
23123
  return domain.every(function (v, i) {
22962
23124
  var _this2 = this;
22963
23125
  _newArrowCheck(this, _this);
22964
- return (i === 0 ? v >= min : v <= max) && !domain.every(function (v, i) {
23126
+ return (i === 0 ? isInverted ? +v <= min : +v >= min : isInverted ? +v >= max : +v <= max) && !domain.every(function (v, i) {
22965
23127
  _newArrowCheck(this, _this2);
22966
23128
  return v === current[i];
22967
23129
  }.bind(this));
@@ -22997,6 +23159,7 @@ var zoom = function (domainValue) {
22997
23159
  org = $$.org,
22998
23160
  scale = $$.scale,
22999
23161
  isRotated = config.axis_rotated,
23162
+ isInverted = config.axis_x_inverted,
23000
23163
  isCategorized = axis.isCategorized(),
23001
23164
  domain = domainValue;
23002
23165
  if (config.zoom_enabled && domain) {
@@ -23006,7 +23169,8 @@ var zoom = function (domainValue) {
23006
23169
  return parseDate.bind($$)(x);
23007
23170
  }.bind(this));
23008
23171
  }
23009
- if (withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain())) {
23172
+ var isWithinRange = withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain(), isInverted);
23173
+ if (isWithinRange) {
23010
23174
  if (isCategorized) {
23011
23175
  domain = domain.map(function (v, i) {
23012
23176
  _newArrowCheck(this, _this3);
@@ -23897,7 +24061,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
23897
24061
  if (!$$.state.xTickOffset) {
23898
24062
  $$.state.xTickOffset = $$.axis.x.tickOffset();
23899
24063
  }
23900
- scale.zoom = $$.getCustomizedScale(newScale);
24064
+ scale.zoom = $$.getCustomizedXScale(newScale);
23901
24065
  $$.axis.x.scale(scale.zoom);
23902
24066
  if (rescale) {
23903
24067
  // copy current initial x scale in case of rescale option is used
@@ -24029,7 +24193,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
24029
24193
  var zoomDomain = zoom.domain(),
24030
24194
  xDomain = subX.domain(),
24031
24195
  delta = .015,
24032
- isfullyShown = (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
24196
+ 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);
24033
24197
  // check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
24034
24198
  if (force || isfullyShown) {
24035
24199
  $$.axis.x.scale(subX);
@@ -24506,7 +24670,7 @@ var _defaults = {};
24506
24670
 
24507
24671
  /**
24508
24672
  * @namespace bb
24509
- * @version 3.7.4
24673
+ * @version 3.8.0-next.1
24510
24674
  */
24511
24675
  var bb = {
24512
24676
  /**
@@ -24516,7 +24680,7 @@ var bb = {
24516
24680
  * bb.version; // "1.0.0"
24517
24681
  * @memberof bb
24518
24682
  */
24519
- version: "3.7.4",
24683
+ version: "3.8.0-next.1",
24520
24684
  /**
24521
24685
  * Generate chart
24522
24686
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: