billboard.js 3.7.5 → 3.8.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +468 -268
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +512 -284
  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 +36 -19
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +35 -19
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +32 -18
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +33 -18
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +45 -17
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +80 -35
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +80 -36
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +77 -35
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +133 -69
  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 +349 -213
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -11
  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 +28 -28
  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/convert.ts +6 -3
  44. package/src/ChartInternal/data/data.ts +19 -15
  45. package/src/ChartInternal/data/load.ts +19 -4
  46. package/src/ChartInternal/interactions/eventrect.ts +3 -2
  47. package/src/ChartInternal/interactions/subchart.ts +3 -2
  48. package/src/ChartInternal/interactions/zoom.ts +10 -3
  49. package/src/ChartInternal/internals/clip.ts +3 -2
  50. package/src/ChartInternal/internals/domain.ts +17 -8
  51. package/src/ChartInternal/internals/legend.ts +4 -1
  52. package/src/ChartInternal/internals/redraw.ts +0 -16
  53. package/src/ChartInternal/internals/region.ts +9 -9
  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/point.ts +3 -2
  60. package/src/Plugin/sparkline/index.ts +9 -1
  61. package/src/config/Options/axis/x.ts +17 -0
  62. package/src/config/Options/axis/y.ts +2 -1
  63. package/src/config/Options/axis/y2.ts +2 -1
  64. package/src/config/Options/common/main.ts +19 -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 +2 -2
  69. package/types/axis.d.ts +8 -7
  70. package/types/chart.d.ts +6 -1
  71. package/types/options.d.ts +7 -4
  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.5
8
+ * @version 3.8.0-next.2
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.
@@ -436,6 +438,18 @@ var isValue = function (v) {
436
438
  _newArrowCheck(this, util_this);
437
439
  return obj && !(obj != null && obj.nodeType) && isObjectType(obj) && !isArray(obj);
438
440
  }.bind(undefined);
441
+ /**
442
+ * Check if is array
443
+ * @param {Array} arr Data to be checked
444
+ * @returns {boolean}
445
+ * @private
446
+ */
447
+ /**
448
+ * Check if is object
449
+ * @param {object} obj Data to be checked
450
+ * @returns {boolean}
451
+ * @private
452
+ */
439
453
  /**
440
454
  * Get specified key value from object
441
455
  * If default value is given, will return if given key value not found
@@ -1215,7 +1229,7 @@ function convertInputType(mouse, touch) {
1215
1229
  function runUntil(fn, conditionFn) {
1216
1230
  var _this18 = this;
1217
1231
  if (conditionFn() === !1) {
1218
- win.requestAnimationFrame(function () {
1232
+ requestAnimationFrame(function () {
1219
1233
  _newArrowCheck(this, _this18);
1220
1234
  return runUntil(fn, conditionFn);
1221
1235
  }.bind(this));
@@ -1827,15 +1841,30 @@ var Store = /*#__PURE__*/function () {
1827
1841
  * - `false`: Remove padding completely and make shape to fully occupy the container element.
1828
1842
  * - In this case, axes and subchart will be hidden.
1829
1843
  * - To adjust some padding from this state, use `axis.[x|y].padding` option.
1844
+ * @property {string} [padding.mode] padding mode
1845
+ * - `"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.
1830
1846
  * @property {number} [padding.top] padding on the top of chart
1831
1847
  * @property {number} [padding.right] padding on the right of chart
1832
1848
  * @property {number} [padding.bottom] padding on the bottom of chart
1833
1849
  * @property {number} [padding.left] padding on the left of chart
1834
1850
  * @see [Demo](https://naver.github.io/billboard.js/demo/#ChartOptions.Padding)
1851
+ * @see [Demo: Fit padding](https://naver.github.io/billboard.js/demo/#ChartOptions.FitPadding)
1835
1852
  * @example
1836
1853
  * // remove padding completely.
1837
1854
  * padding: false,
1838
1855
  *
1856
+ * padding: {
1857
+ * // specifying mode value, will reduce padding and make fit to the container element.
1858
+ * mode: "fit"
1859
+ *
1860
+ * // when mode is "fit", all padding values will be relative from fitted value.
1861
+ * // so, 0 will be initial fitted value.
1862
+ * top: 20,
1863
+ * right: 20,
1864
+ * bottom: 20,
1865
+ * left: 20
1866
+ * }
1867
+ *
1839
1868
  * // or specify padding value for each side
1840
1869
  * padding: {
1841
1870
  * top: 20,
@@ -1845,6 +1874,7 @@ var Store = /*#__PURE__*/function () {
1845
1874
  * }
1846
1875
  */
1847
1876
  padding: !0,
1877
+ padding_mode: undefined,
1848
1878
  padding_left: undefined,
1849
1879
  padding_right: undefined,
1850
1880
  padding_top: undefined,
@@ -1858,7 +1888,9 @@ var Store = /*#__PURE__*/function () {
1858
1888
  * @property {boolean} [resize.auto=true] Set chart resize automatically on viewport changes.
1859
1889
  * @property {boolean|number} [resize.timer=true] Set resize timer option.
1860
1890
  * - **NOTE:**
1861
- * - The resize function will be called using: true - `setTimeout()`, false - `requestIdleCallback()`.
1891
+ * - The resize function will be called using:
1892
+ * - true: `setTimeout()`
1893
+ * - false: `requestIdleCallback()`
1862
1894
  * - Given number(delay in ms) value, resize function will be triggered using `setTimer()` with given delay.
1863
1895
  * @example
1864
1896
  * resize: {
@@ -3699,7 +3731,7 @@ function generateResize(option) {
3699
3731
  var _this = this;
3700
3732
  // Delay all resize functions call, to prevent unintended excessive call from resize event
3701
3733
  callResizeFn.clear();
3702
- if (option === !1 && win.requestIdleCallback) {
3734
+ if (option === !1) {
3703
3735
  requestIdleCallback(function () {
3704
3736
  var _this2 = this;
3705
3737
  _newArrowCheck(this, _this);
@@ -4151,6 +4183,7 @@ function getDataKeyForJson(keysParam, config) {
4151
4183
  axis = $$.axis,
4152
4184
  config = $$.config,
4153
4185
  state = $$.state,
4186
+ chartType = config.data_type,
4154
4187
  isCategorized = !1,
4155
4188
  isTimeSeries = !1,
4156
4189
  isCustomX = !1;
@@ -4219,7 +4252,8 @@ function getDataKeyForJson(keysParam, config) {
4219
4252
  return config.axis_x_categories.indexOf(v) > -1;
4220
4253
  }.bind(this)),
4221
4254
  isDataAppend = data.__append__,
4222
- xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0;
4255
+ xIndex = xKey === null && isDataAppend ? $$.api.data.values(id).length : 0; // when .load() with 'append' option is used for indexed axis
4256
+ // @ts-ignore
4223
4257
  return {
4224
4258
  id: convertedId,
4225
4259
  id_org: id,
@@ -4294,11 +4328,12 @@ function getDataKeyForJson(keysParam, config) {
4294
4328
  state.hasPositiveValue = $$.hasPositiveValueInTargets(targets);
4295
4329
 
4296
4330
  // set target types
4297
- if (config.data_type) {
4298
- $$.setTargetType($$.mapToIds(targets).filter(function (id) {
4331
+ if (chartType && $$.isValidChartType(chartType)) {
4332
+ var targetIds = $$.mapToIds(targets).filter(function (id) {
4299
4333
  _newArrowCheck(this, _this2);
4300
- return !(id in config.data_types);
4301
- }.bind(this)), config.data_type);
4334
+ return !(id in config.data_types) || !$$.isValidChartType(config.data_types[id]);
4335
+ }.bind(this));
4336
+ $$.setTargetType(targetIds, chartType);
4302
4337
  }
4303
4338
 
4304
4339
  // cache as original id keyed
@@ -4679,7 +4714,8 @@ function getDataKeyForJson(keysParam, config) {
4679
4714
  getMaxDataCountTarget: function getMaxDataCountTarget() {
4680
4715
  var _this18 = this,
4681
4716
  target = this.filterTargetsToShow() || [],
4682
- length = target.length;
4717
+ length = target.length,
4718
+ isInverted = this.config.axis_x_inverted;
4683
4719
  if (length > 1) {
4684
4720
  target = target.map(function (t) {
4685
4721
  _newArrowCheck(this, _this18);
@@ -4691,11 +4727,11 @@ function getDataKeyForJson(keysParam, config) {
4691
4727
  _newArrowCheck(this, _this18);
4692
4728
  return v.x;
4693
4729
  }.bind(this));
4694
- target = sortValue(getUnique(target)).map(function (x, index) {
4730
+ target = sortValue(getUnique(target)).map(function (x, index, array) {
4695
4731
  _newArrowCheck(this, _this18);
4696
4732
  return {
4697
4733
  x: x,
4698
- index: index
4734
+ index: isInverted ? array.length - index - 1 : index
4699
4735
  };
4700
4736
  }.bind(this));
4701
4737
  } else if (length) {
@@ -4974,6 +5010,9 @@ function getDataKeyForJson(keysParam, config) {
4974
5010
  isRotated = config.axis_rotated,
4975
5011
  e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event,
4976
5012
  index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
5013
+
5014
+ // get data based on the mouse coords
5015
+
4977
5016
  return index;
4978
5017
  },
4979
5018
  getDataLabelLength: function getDataLabelLength(min, max, key) {
@@ -5020,7 +5059,6 @@ function getDataKeyForJson(keysParam, config) {
5020
5059
  return $$.findClosest(target.values, pos);
5021
5060
  }.bind(this));
5022
5061
  // map to array of closest points of each target
5023
-
5024
5062
  // decide closest point and return
5025
5063
  return $$.findClosest(candidates, pos);
5026
5064
  },
@@ -5089,36 +5127,40 @@ function getDataKeyForJson(keysParam, config) {
5089
5127
  return values;
5090
5128
  }
5091
5129
 
5092
- // insert & append cloning first/last value to be fully rendered covering on each gap sides
5093
- var head = converted[0],
5094
- tail = converted[converted.length - 1],
5095
- id = head.id;
5096
- var x = head.x;
5097
-
5098
- // insert head
5099
- converted.unshift({
5100
- x: --x,
5101
- value: head.value,
5102
- id: id
5103
- });
5104
- isCategorized && stepType === "step-after" && converted.unshift({
5105
- x: --x,
5106
- value: head.value,
5107
- id: id
5108
- });
5130
+ // when all datas are null, return empty array
5131
+ // https://github.com/naver/billboard.js/issues/3124
5132
+ if (converted.length) {
5133
+ // insert & append cloning first/last value to be fully rendered covering on each gap sides
5134
+ var head = converted[0],
5135
+ tail = converted[converted.length - 1],
5136
+ id = head.id;
5137
+ var x = head.x;
5138
+
5139
+ // insert head
5140
+ converted.unshift({
5141
+ x: --x,
5142
+ value: head.value,
5143
+ id: id
5144
+ });
5145
+ isCategorized && stepType === "step-after" && converted.unshift({
5146
+ x: --x,
5147
+ value: head.value,
5148
+ id: id
5149
+ });
5109
5150
 
5110
- // append tail
5111
- x = tail.x;
5112
- converted.push({
5113
- x: ++x,
5114
- value: tail.value,
5115
- id: id
5116
- });
5117
- isCategorized && stepType === "step-before" && converted.push({
5118
- x: ++x,
5119
- value: tail.value,
5120
- id: id
5121
- });
5151
+ // append tail
5152
+ x = tail.x;
5153
+ converted.push({
5154
+ x: ++x,
5155
+ value: tail.value,
5156
+ id: id
5157
+ });
5158
+ isCategorized && stepType === "step-before" && converted.push({
5159
+ x: ++x,
5160
+ value: tail.value,
5161
+ id: id
5162
+ });
5163
+ }
5122
5164
  return converted;
5123
5165
  },
5124
5166
  convertValuesToRange: function convertValuesToRange(values) {
@@ -5344,11 +5386,27 @@ function getDataKeyForJson(keysParam, config) {
5344
5386
  */
5345
5387
 
5346
5388
 
5389
+
5390
+ /**
5391
+ * Call done callback with resize after transition
5392
+ * @param {Function} fn Callback function
5393
+ * @param {boolean} resizeAfter Weather to resize chart after the load
5394
+ * @private
5395
+ */
5396
+ function callDone(fn, resizeAfter) {
5397
+ if (resizeAfter === void 0) {
5398
+ resizeAfter = !1;
5399
+ }
5400
+ var $$ = this,
5401
+ api = $$.api;
5402
+ resizeAfter && $$.api.flush(!0);
5403
+ fn == null ? void 0 : fn.call(api);
5404
+ }
5347
5405
  /* harmony default export */ var load = ({
5348
5406
  load: function load(rawTargets, args) {
5349
5407
  var _this = this,
5350
- _args$done,
5351
5408
  $$ = this,
5409
+ data = $$.data,
5352
5410
  append = args.append,
5353
5411
  targets = rawTargets;
5354
5412
  if (targets) {
@@ -5368,7 +5426,7 @@ function getDataKeyForJson(keysParam, config) {
5368
5426
  }
5369
5427
 
5370
5428
  // Update/Add data
5371
- $$.data.targets.forEach(function (d) {
5429
+ data.targets.forEach(function (d) {
5372
5430
  _newArrowCheck(this, _this);
5373
5431
  for (var i = 0; i < targets.length; i++) {
5374
5432
  if (d.id === targets[i].id) {
@@ -5378,11 +5436,11 @@ function getDataKeyForJson(keysParam, config) {
5378
5436
  }
5379
5437
  }
5380
5438
  }.bind(this));
5381
- $$.data.targets = $$.data.targets.concat(targets); // add remained
5439
+ data.targets = data.targets.concat(targets); // add remained
5382
5440
  }
5383
5441
 
5384
5442
  // Set targets
5385
- $$.updateTargets($$.data.targets);
5443
+ $$.updateTargets(data.targets);
5386
5444
 
5387
5445
  // Redraw with new targets
5388
5446
  $$.redraw({
@@ -5393,7 +5451,7 @@ function getDataKeyForJson(keysParam, config) {
5393
5451
 
5394
5452
  // Update current state chart type and elements list after redraw
5395
5453
  $$.updateTypesElements();
5396
- (_args$done = args.done) == null ? void 0 : _args$done.call($$.api);
5454
+ callDone.call($$, args.done, args.resizeAfter);
5397
5455
  },
5398
5456
  loadFromArgs: function loadFromArgs(args) {
5399
5457
  var _this2 = this,
@@ -5604,6 +5662,7 @@ var external_commonjs_d3_drag_commonjs2_d3_drag_amd_d3_drag_root_d3_ = __webpack
5604
5662
  return v !== this;
5605
5663
  }.bind(this));
5606
5664
  }); // select based on the index
5665
+ // filter if has new selection
5607
5666
  // call onout callback
5608
5667
  if (!isOver || shapesAtIndex.empty() || last.length === shape.size() && shape.nodes().every(function (v, i) {
5609
5668
  _newArrowCheck(this, _this5);
@@ -6396,7 +6455,9 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6396
6455
  getXDomain: function getXDomain(targets) {
6397
6456
  var $$ = this,
6398
6457
  axis = $$.axis,
6458
+ config = $$.config,
6399
6459
  x = $$.scale.x,
6460
+ isInverted = config.axis_x_inverted,
6400
6461
  domain = [$$.getXDomainMinMax(targets, "min"), $$.getXDomainMinMax(targets, "max")];
6401
6462
  var _domain$ = domain[0],
6402
6463
  min = _domain$ === void 0 ? 0 : _domain$,
@@ -6426,7 +6487,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6426
6487
  max = isTimeSeries ? new Date(lastX.getTime() + padding.right) : lastX + padding.right;
6427
6488
  }
6428
6489
  }
6429
- return [min, max];
6490
+ return isInverted ? [max, min] : [min, max];
6430
6491
  },
6431
6492
  updateXDomain: function updateXDomain(targets, withUpdateXDomain, withUpdateOrgXDomain, withTrim, domain) {
6432
6493
  var $$ = this,
@@ -6438,7 +6499,7 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6438
6499
  zoomEnabled = config.zoom_enabled;
6439
6500
  if (withUpdateOrgXDomain) {
6440
6501
  var _$$$brush;
6441
- x.domain(domain || sortValue($$.getXDomain(targets)));
6502
+ x.domain(domain || sortValue($$.getXDomain(targets), !config.axis_x_inverted));
6442
6503
  org.xDomain = x.domain();
6443
6504
  zoomEnabled && $$.zoom.updateScaleExtent();
6444
6505
  subX.domain(x.domain());
@@ -6454,15 +6515,24 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6454
6515
  withTrim && x.domain($$.trimXDomain(x.orgDomain()));
6455
6516
  return x.domain();
6456
6517
  },
6518
+ /**
6519
+ * Trim x domain when given domain surpasses the range
6520
+ * @param {Array} domain Domain value
6521
+ * @returns {Array} Trimed domain if given domain is out of range
6522
+ * @private
6523
+ */
6457
6524
  trimXDomain: function trimXDomain(domain) {
6458
- var zoomDomain = this.getZoomDomain(),
6459
- min = zoomDomain[0],
6460
- max = zoomDomain[1];
6461
- if (domain[0] <= min) {
6462
- domain[1] = +domain[1] + (min - domain[0]);
6525
+ var $$ = this,
6526
+ isInverted = $$.config.axis_x_inverted,
6527
+ zoomDomain = $$.getZoomDomain(),
6528
+ _zoomDomain = zoomDomain,
6529
+ min = _zoomDomain[0],
6530
+ max = _zoomDomain[1];
6531
+ if (isInverted ? domain[0] >= min : domain[0] <= min) {
6463
6532
  domain[0] = min;
6533
+ domain[1] = +domain[1] + (min - domain[0]);
6464
6534
  }
6465
- if (max <= domain[1]) {
6535
+ if (isInverted ? domain[1] <= max : domain[1] >= max) {
6466
6536
  domain[0] = +domain[0] - (domain[1] - max);
6467
6537
  domain[1] = max;
6468
6538
  }
@@ -6807,13 +6877,15 @@ function getLegendColor(id) {
6807
6877
  * @private
6808
6878
  */
6809
6879
  getLegendHeight: function getLegendHeight() {
6810
- var $$ = this,
6880
+ var _$$$config$padding,
6881
+ $$ = this,
6811
6882
  _$$$state3 = $$.state,
6812
6883
  current = _$$$state3.current,
6813
6884
  isLegendRight = _$$$state3.isLegendRight,
6814
6885
  legendItemHeight = _$$$state3.legendItemHeight,
6815
- legendStep = _$$$state3.legendStep;
6816
- return $$.config.legend_show ? isLegendRight ? current.height : Math.max(20, legendItemHeight) * (legendStep + 1) : 0;
6886
+ legendStep = _$$$state3.legendStep,
6887
+ isFitPadding = ((_$$$config$padding = $$.config.padding) == null ? void 0 : _$$$config$padding.mode) === "fit";
6888
+ return $$.config.legend_show ? isLegendRight ? current.height : (isFitPadding ? 10 : Math.max(20, legendItemHeight)) * (legendStep + 1) : 0;
6817
6889
  },
6818
6890
  /**
6819
6891
  * Get the opacity of the legend that is unfocused
@@ -7026,7 +7098,7 @@ function getLegendColor(id) {
7026
7098
  return !isDefined(config.data_names[id]) || config.data_names[id] !== null;
7027
7099
  }.bind(this)),
7028
7100
  withTransition = options.withTransition,
7029
- updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes);
7101
+ updatePositions = $$.getUpdateLegendPositions(targetIdz, dimension, sizes); // Skip elements when their name is set to null
7030
7102
  if (state.isLegendInset) {
7031
7103
  dimension.step = config.legend_inset_step ? config.legend_inset_step : targetIdz.length;
7032
7104
  $$.updateLegendStep(dimension.step);
@@ -7159,7 +7231,7 @@ function getLegendColor(id) {
7159
7231
  sizes.margins[dimension.step] = state.isLegendInset ? 10 : margin;
7160
7232
  sizes.offsets[id2] = dimension.totalLength;
7161
7233
  dimension.totalLength += itemLength;
7162
- };
7234
+ }; // MEMO: care about condifion of step, totalLength
7163
7235
  if (index === 0) {
7164
7236
  dimension.totalLength = 0;
7165
7237
  dimension.step = 0;
@@ -7227,6 +7299,8 @@ function getLegendColor(id) {
7227
7299
  isRectangle = legendType !== "circle",
7228
7300
  isLegendRightOrInset = state.isLegendRight || state.isLegendInset,
7229
7301
  l = legend.selectAll("." + $LEGEND.legendItem).data(targetIdz).enter().append("g");
7302
+ // Define g for legend area
7303
+
7230
7304
  $$.setLegendItem(l);
7231
7305
  l.append("text").text(function (id) {
7232
7306
  _newArrowCheck(this, _this6);
@@ -7475,7 +7549,8 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
7475
7549
  flowFn && flowFn();
7476
7550
  state.redrawing = !1;
7477
7551
  callFn(config.onrendered, $$.api);
7478
- }.bind(this);
7552
+ }.bind(this); // redraw list
7553
+ // callback function after redraw ends
7479
7554
  if (afterRedraw) {
7480
7555
  // Only use transition when current tab is visible.
7481
7556
  if (withTransition && redrawList.length) {
@@ -7584,20 +7659,6 @@ var external_commonjs_d3_transition_commonjs2_d3_transition_amd_d3_transition_ro
7584
7659
 
7585
7660
  // Draw with new sizes & scales
7586
7661
  $$.redraw(options, transitions);
7587
- },
7588
- /**
7589
- * Redraw without rescale
7590
- * @private
7591
- */
7592
- redrawWithoutRescale: function redrawWithoutRescale() {
7593
- this.redraw({
7594
- withY: !1,
7595
- withDimension: !1,
7596
- withLegend: !1,
7597
- withSubchart: !1,
7598
- withEventRect: !1,
7599
- withTransitionForAxis: !1
7600
- });
7601
7662
  }
7602
7663
  });
7603
7664
  ;// CONCATENATED MODULE: ./src/ChartInternal/internals/scale.ts
@@ -7650,7 +7711,7 @@ function getScale(type, min, max) {
7650
7711
  getXScale: function getXScale(min, max, domain, offset) {
7651
7712
  var $$ = this,
7652
7713
  scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
7653
- return $$.getCustomizedScale(domain ? scale.domain(domain) : scale, offset);
7714
+ return $$.getCustomizedXScale(domain ? scale.domain(domain) : scale, offset);
7654
7715
  },
7655
7716
  /**
7656
7717
  * Get y Axis scale function
@@ -7684,19 +7745,20 @@ function getScale(type, min, max) {
7684
7745
  return this.scale[key];
7685
7746
  },
7686
7747
  /**
7687
- * Get customized scale
7748
+ * Get customized x axis scale
7688
7749
  * @param {d3.scaleLinear|d3.scaleTime} scaleValue Scale function
7689
7750
  * @param {Function} offsetValue Offset getter to be sum
7690
7751
  * @returns {Function} Scale function
7691
7752
  * @private
7692
7753
  */
7693
- getCustomizedScale: function getCustomizedScale(scaleValue, offsetValue) {
7754
+ getCustomizedXScale: function getCustomizedXScale(scaleValue, offsetValue) {
7694
7755
  var _this = this,
7695
7756
  $$ = this,
7696
7757
  offset = offsetValue || function () {
7697
7758
  _newArrowCheck(this, _this);
7698
7759
  return $$.axis.x.tickOffset();
7699
7760
  }.bind(this),
7761
+ isInverted = $$.config.axis_x_inverted,
7700
7762
  scale = function (d, raw) {
7701
7763
  var v = scaleValue(d) + offset();
7702
7764
  return raw ? v : Math.ceil(v);
@@ -7720,7 +7782,7 @@ function getScale(type, min, max) {
7720
7782
  var domain = domainValue;
7721
7783
  if (!arguments.length) {
7722
7784
  domain = this.orgDomain();
7723
- return [domain[0], domain[1] + 1];
7785
+ return isInverted ? [domain[0] + 1, domain[1]] : [domain[0], domain[1] + 1];
7724
7786
  }
7725
7787
  scaleValue.domain(domain);
7726
7788
  return scale;
@@ -7771,6 +7833,11 @@ function getScale(type, min, max) {
7771
7833
  },
7772
7834
  xDomain = updateXDomain && ((_scale$x = scale.x) == null ? void 0 : _scale$x.orgDomain()),
7773
7835
  xSubDomain = updateXDomain && org.xDomain;
7836
+ // update edges
7837
+
7838
+ // update scales
7839
+ // x Axis
7840
+
7774
7841
  scale.x = $$.getXScale(min.x, max.x, xDomain, function () {
7775
7842
  _newArrowCheck(this, _this2);
7776
7843
  return axis.x.tickOffset();
@@ -7974,7 +8041,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
7974
8041
  xs = _$$$config.data_xs,
7975
8042
  removeNull = _$$$config.bar_indices_removeNull,
7976
8043
  id = d.id,
7977
- index = d.index;
8044
+ index = d.index; // eslint-disable-line
7978
8045
  if ($$.isBarType(id) && removeNull) {
7979
8046
  var ind = {};
7980
8047
 
@@ -8019,6 +8086,8 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8019
8086
  return p + c;
8020
8087
  }.bind(this),
8021
8088
  halfWidth = isObjectType(offset) && (offset._$total.length ? offset._$total.reduce(sum) / 2 : 0);
8089
+ // total shapes half width
8090
+
8022
8091
  return function (d) {
8023
8092
  _newArrowCheck(this, _this5);
8024
8093
  var ind = $$.getIndices(indices, d, "getShapeX"),
@@ -8363,47 +8432,60 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8363
8432
  return padding + (axesLen ? $$.getHorizontalAxisHeight(axisId) * axesLen : 0);
8364
8433
  },
8365
8434
  getCurrentPaddingLeft: function getCurrentPaddingLeft(withoutRecompute) {
8366
- var $$ = this,
8435
+ var _config$padding,
8436
+ $$ = this,
8367
8437
  config = $$.config,
8368
8438
  hasAxis = $$.state.hasAxis,
8369
8439
  isRotated = config.axis_rotated,
8440
+ isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
8370
8441
  axisId = isRotated ? "x" : "y",
8371
8442
  axesLen = hasAxis ? config["axis_" + axisId + "_axes"].length : 0,
8372
8443
  axisWidth = hasAxis ? $$.getAxisWidthByAxisId(axisId, withoutRecompute) : 0;
8373
- var padding;
8444
+ if (!isFitPadding) {
8445
+ axisWidth = ceil10(axisWidth);
8446
+ }
8447
+ var padding = config["axis_" + axisId + "_inner"] || !config["axis_" + axisId + "_show"] ? 0 : axisWidth;
8374
8448
  if (isValue(config.padding_left)) {
8375
- padding = config.padding_left;
8449
+ padding = config.padding_left + (isFitPadding && isRotated ? axisWidth : 0);
8376
8450
  } else if (hasAxis && isRotated) {
8377
- padding = !config.axis_x_show ? 1 : Math.max(ceil10(axisWidth), 40);
8378
- } else if (hasAxis && (!config.axis_y_show || config.axis_y_inner)) {
8379
- // && !config.axis_rotated
8380
- padding = $$.axis.getAxisLabelPosition("y").isOuter ? 30 : 1;
8381
- } else {
8382
- padding = ceil10(axisWidth);
8451
+ padding = !config.axis_x_show ? 1 : isFitPadding ? axisWidth : Math.max(axisWidth, 40);
8452
+ }
8453
+ if (hasAxis && (isFitPadding || config["axis_" + axisId + "_inner"]) && config["axis_" + axisId + "_label"].text) {
8454
+ padding += $$.axis.getAxisLabelPosition("y").isOuter ? 20 : 0;
8383
8455
  }
8384
8456
  return padding + axisWidth * axesLen;
8385
8457
  },
8386
8458
  getCurrentPaddingRight: function getCurrentPaddingRight(withXAxisTickTextOverflow) {
8459
+ var _config$padding2, _$$$axis;
8387
8460
  if (withXAxisTickTextOverflow === void 0) {
8388
8461
  withXAxisTickTextOverflow = !1;
8389
8462
  }
8390
8463
  var $$ = this,
8391
8464
  config = $$.config,
8392
8465
  hasAxis = $$.state.hasAxis,
8466
+ isRotated = config.axis_rotated,
8467
+ isFitPadding = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit",
8468
+ defaultPadding = isFitPadding ? 2 : 10,
8393
8469
  legendWidthOnRight = $$.state.isLegendRight ? $$.getLegendWidth() + 20 : 0,
8394
8470
  axesLen = hasAxis ? config.axis_y2_axes.length : 0,
8395
- axisWidth = hasAxis ? $$.getAxisWidthByAxisId("y2") : 0,
8396
- xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(10) : 0;
8397
- var padding;
8471
+ axisLabelWidth = (_$$$axis = $$.axis) != null && _$$$axis.getAxisLabelPosition("y2").isOuter ? 20 : 0,
8472
+ xAxisTickTextOverflow = withXAxisTickTextOverflow ? $$.axis.getXAxisTickTextY2Overflow(defaultPadding) : 0;
8473
+ var axisWidth = hasAxis && !config.axis_y2_inner ? $$.getAxisWidthByAxisId("y2") : 1;
8474
+ if (!isFitPadding) {
8475
+ axisWidth = ceil10(axisWidth);
8476
+ }
8477
+ var padding = isRotated ? 0 : Math.max(axisWidth + legendWidthOnRight, xAxisTickTextOverflow);
8398
8478
  if (isValue(config.padding_right)) {
8399
- padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
8400
- } else if ($$.axis && config.axis_rotated) {
8401
- padding = 10 + legendWidthOnRight;
8479
+ // padding = config.padding_right + (hasAxis ? 1 : 0); // 1 is needed not to hide tick line
8480
+
8481
+ padding = config.padding_right + (isFitPadding && (isRotated || !config.axis_y2_show ? defaultPadding : padding)) + (hasAxis && !isFitPadding ? 1 : 0); // 1 is needed not to hide tick line
8482
+ } else if ($$.axis && isRotated) {
8483
+ padding = defaultPadding + legendWidthOnRight;
8402
8484
  } else if ($$.axis && (!config.axis_y2_show || config.axis_y2_inner)) {
8403
- // && !config.axis_rotated
8404
- padding = Math.max(2 + legendWidthOnRight + ($$.axis.getAxisLabelPosition("y2").isOuter ? 20 : 0), xAxisTickTextOverflow);
8405
- } else {
8406
- padding = Math.max(ceil10(axisWidth) + legendWidthOnRight, xAxisTickTextOverflow);
8485
+ padding = Math.max((isFitPadding && !config.axis_y2_show ? 2 : 1) + legendWidthOnRight + axisLabelWidth, xAxisTickTextOverflow);
8486
+ }
8487
+ if (hasAxis && !isRotated && isFitPadding && config.axis_y2_show && !config.axis_y2_inner && config.axis_y2_label.text) {
8488
+ padding += axisLabelWidth;
8407
8489
  }
8408
8490
  return padding + axisWidth * axesLen;
8409
8491
  },
@@ -8542,12 +8624,14 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8542
8624
  * @private
8543
8625
  */
8544
8626
  updateSizes: function updateSizes(isInit) {
8545
- var $$ = this,
8627
+ var _config$padding3,
8628
+ $$ = this,
8546
8629
  config = $$.config,
8547
8630
  state = $$.state,
8548
8631
  legend = $$.$el.legend,
8549
8632
  isRotated = config.axis_rotated,
8550
- isNonAxis = $$.hasArcType() || state.hasTreemap;
8633
+ isNonAxis = $$.hasArcType() || state.hasTreemap,
8634
+ isFitPadding = ((_config$padding3 = config.padding) == null ? void 0 : _config$padding3.mode) === "fit";
8551
8635
  isInit || $$.setContainerSize();
8552
8636
  var currLegend = {
8553
8637
  width: legend ? $$.getLegendWidth() : 0,
@@ -8568,7 +8652,7 @@ var external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_ = __webp
8568
8652
  bottom: $$.getHorizontalAxisHeight("y") + legendHeightForBottom + padding.bottom,
8569
8653
  left: subchartHeight + (isNonAxis ? 0 : padding.left)
8570
8654
  } : {
8571
- top: 4 + padding.top,
8655
+ top: (isFitPadding ? 0 : 4) + padding.top,
8572
8656
  // for top tick text
8573
8657
  right: isNonAxis ? 0 : $$.getCurrentPaddingRight(!0),
8574
8658
  bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
@@ -9180,6 +9264,8 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
9180
9264
  _newArrowCheck(this, _this5);
9181
9265
  return Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
9182
9266
  }.bind(this);
9267
+ // Calculates the length of the hypotenuse
9268
+
9183
9269
  textNode.node() && filteredTextNodes.each(function () {
9184
9270
  var coordinate = getTranslation(this),
9185
9271
  filteredTextNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
@@ -9692,6 +9778,8 @@ function getTextPos(pos, width) {
9692
9778
  y: y
9693
9779
  },
9694
9780
  data = (_selectedData$filter = selectedData.filter(Boolean)) == null ? void 0 : _selectedData$filter.shift();
9781
+ // get mouse event position
9782
+
9695
9783
  if (scale.x && data && "x" in data) {
9696
9784
  currPos.xAxis = scale.x(data.x);
9697
9785
  }
@@ -9837,7 +9925,7 @@ function getTextPos(pos, width) {
9837
9925
  y = isRotated ? state.height + padding : 0;
9838
9926
  } else if (target === "y2") {
9839
9927
  x = isRotated ? 0 : state.width + padding;
9840
- y = isRotated ? 1 - padding : 0;
9928
+ y = isRotated && padding ? 1 - padding : 0;
9841
9929
  } else if (target === "subX") {
9842
9930
  x = 0;
9843
9931
  y = isRotated ? 0 : state.height2;
@@ -9889,6 +9977,15 @@ function getTextPos(pos, width) {
9889
9977
 
9890
9978
 
9891
9979
  /* harmony default export */ var type = ({
9980
+ /**
9981
+ * Check if the given chart type is valid
9982
+ * @param {string} type Chart type string
9983
+ * @returns {boolean}
9984
+ * @private
9985
+ */
9986
+ isValidChartType: function isValidChartType(type) {
9987
+ return !!(type && Object.values(TYPE).indexOf(type) > -1);
9988
+ },
9892
9989
  setTargetType: function setTargetType(targetIds, type) {
9893
9990
  var _this = this,
9894
9991
  $$ = this,
@@ -10161,38 +10258,28 @@ function getTextPos(pos, width) {
10161
10258
  * @private
10162
10259
  */
10163
10260
  var ChartInternal = /*#__PURE__*/function () {
10164
- // API interface
10165
- // config object
10166
- // cache instance
10167
- // elements
10168
- // state variables
10169
- // all Chart instances array within page (equivalent of 'bb.instances')
10170
-
10171
- // data object
10172
-
10173
- // Axis
10174
- // Axis
10175
-
10176
- // scales
10177
-
10178
- // original values
10179
-
10180
- // formatter function
10181
-
10182
- // format function
10183
-
10184
10261
  function ChartInternal(api) {
10185
10262
  this.api = void 0;
10263
+ // API interface
10186
10264
  this.config = void 0;
10265
+ // config object
10187
10266
  this.cache = void 0;
10267
+ // cache instance
10188
10268
  this.$el = void 0;
10269
+ // elements
10189
10270
  this.state = void 0;
10271
+ // state variables
10190
10272
  this.charts = void 0;
10273
+ // all Chart instances array within page (equivalent of 'bb.instances')
10274
+ // data object
10191
10275
  this.data = {
10192
10276
  xs: {},
10193
10277
  targets: []
10194
10278
  };
10279
+ // Axis
10195
10280
  this.axis = void 0;
10281
+ // Axis
10282
+ // scales
10196
10283
  this.scale = {
10197
10284
  x: null,
10198
10285
  y: null,
@@ -10202,15 +10289,18 @@ var ChartInternal = /*#__PURE__*/function () {
10202
10289
  subY2: null,
10203
10290
  zoom: null
10204
10291
  };
10292
+ // original values
10205
10293
  this.org = {
10206
10294
  xScale: null,
10207
10295
  xDomain: null
10208
10296
  };
10297
+ // formatter function
10209
10298
  this.color = void 0;
10210
10299
  this.patterns = void 0;
10211
10300
  this.levelColor = void 0;
10212
10301
  this.point = void 0;
10213
10302
  this.brush = void 0;
10303
+ // format function
10214
10304
  this.format = {
10215
10305
  extraLineClasses: null,
10216
10306
  xAxisTick: null,
@@ -10420,7 +10510,6 @@ var ChartInternal = /*#__PURE__*/function () {
10420
10510
  hasPolar = $$.hasType("polar");
10421
10511
  // for arc type, set axes to not be shown
10422
10512
  // $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
10423
-
10424
10513
  if (hasAxis) {
10425
10514
  $$.axis = $$.getAxisInstance();
10426
10515
  config.zoom_enabled && $$.initZoom();
@@ -10456,7 +10545,7 @@ var ChartInternal = /*#__PURE__*/function () {
10456
10545
 
10457
10546
  // Set domains for each scale
10458
10547
  if (x) {
10459
- x.domain(sortValue($$.getXDomain($$.data.targets)));
10548
+ x.domain(sortValue($$.getXDomain($$.data.targets), !config.axis_x_inverted));
10460
10549
  subX.domain(x.domain());
10461
10550
 
10462
10551
  // Save original x domain for zoom update
@@ -11716,17 +11805,17 @@ function renderText(ctx, glyph) {
11716
11805
  state.defocusedTargetIds = targetIds;
11717
11806
  },
11718
11807
  /**
11719
- * This API reverts specified targets.<br><br>
11720
- * 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.
11808
+ * Revert focused or defocused state to initial state.<br><br>
11809
+ * 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.
11721
11810
  * @function revert
11722
11811
  * @instance
11723
11812
  * @memberof Chart
11724
11813
  * @param {string|Array} targetIdsValue Target ids to be reverted
11725
11814
  * @example
11726
- * // data1 will be reverted.
11815
+ * // 'data1' will be reverted.
11727
11816
  * chart.revert("data1");
11728
11817
  *
11729
- * // data1 and data2 will be reverted.
11818
+ * // 'data1' and 'data2' will be reverted.
11730
11819
  * chart.revert(["data1", "data2"]);
11731
11820
  *
11732
11821
  * // all targets will be reverted.
@@ -11828,6 +11917,7 @@ var legend_legend = {
11828
11917
  */
11829
11918
 
11830
11919
 
11920
+
11831
11921
  /* harmony default export */ var api_load = ({
11832
11922
  /**
11833
11923
  * Load data to the chart.<br><br>
@@ -11842,23 +11932,29 @@ var legend_legend = {
11842
11932
  * @memberof Chart
11843
11933
  * @param {object} args The object can consist with following members:<br>
11844
11934
  *
11845
- * | Key | Description |
11846
- * | --- | --- |
11847
- * | - 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 |
11848
- * | data | Data objects to be loaded. Checkout the example. |
11849
- * | 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. |
11850
- * | names | Same as data.names() |
11851
- * | xs | Same as data.xs option |
11852
- * | classes | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
11853
- * | categories | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
11854
- * | axes | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
11855
- * | colors | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
11856
- * | headers | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
11857
- * | 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) |
11858
- * | mimeType | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
11859
- * | - type<br>- types | The type of targets will be updated. type must be String and types must be Object. |
11860
- * | 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. |
11861
- * | done | The specified function will be called after data loaded.|
11935
+ * | Key | Type | Description |
11936
+ * | --- | --- | --- |
11937
+ * | 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 |
11938
+ * | 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 |
11939
+ * | 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 |
11940
+ * | 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 |
11941
+ * | &nbsp; | | |
11942
+ * | 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. |
11943
+ * | axes | Object | The axes specified by data.axes will be updated. axes must be Object that has target id as keys. |
11944
+ * | categories | Array | The categories specified by axis.x.categories or data.x will be updated. categories must be Array. |
11945
+ * | classes | Object | The classes specified by data.classes will be updated. classes must be Object that has target id as keys. |
11946
+ * | colors | Object | The colors specified by data.colors will be updated. colors must be Object that has target id as keys. |
11947
+ * | data | Obejct | Data objects to be loaded. Checkout the example. |
11948
+ * | done | Function | The specified function will be called after data loaded.|
11949
+ * | headers | string | Set request header if loading via `data.url`.<br>@see [data․headers](Options.html#.data%25E2%2580%25A4headers) |
11950
+ * | 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) |
11951
+ * | mimeType | string | Set 'json' if loading JSON via url.<br>@see [data․mimeType](Options.html#.data%25E2%2580%25A4mimeType) |
11952
+ * | names | Object | Same as data.names() |
11953
+ * | 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. |
11954
+ * | type | string | The type of targets will be updated. |
11955
+ * | types | Object | The types of targets will be updated. |
11956
+ * | 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. |
11957
+ * | xs | string | Same as data.xs option |
11862
11958
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataFromURL)
11863
11959
  * @example
11864
11960
  * // Load data1 and unload data2 and data3
@@ -11870,6 +11966,7 @@ var legend_legend = {
11870
11966
  * unload: ["data2", "data3"],
11871
11967
  * url: "...",
11872
11968
  * done: function() { ... }
11969
+ * resizeAfter: true // will resize after load
11873
11970
  * });
11874
11971
  * @example
11875
11972
  * const chart = bb.generate({
@@ -11999,7 +12096,7 @@ var legend_legend = {
11999
12096
  _newArrowCheck(this, _this);
12000
12097
  // to mitigate improper rendering for multiple consecutive calls
12001
12098
  // https://github.com/naver/billboard.js/issues/2121
12002
- win.requestIdleCallback(function () {
12099
+ requestIdleCallback(function () {
12003
12100
  _newArrowCheck(this, _this2);
12004
12101
  return $$.loadFromArgs(args);
12005
12102
  }.bind(this));
@@ -12023,13 +12120,15 @@ var legend_legend = {
12023
12120
  * | --- | --- | --- |
12024
12121
  * | ids | String &vert; Array | Target id data to be unloaded. If not given, all data will be unloaded. |
12025
12122
  * | done | Fuction | Callback after data is unloaded. |
12123
+ * | 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. |
12026
12124
  * @example
12027
12125
  * // Unload data2 and data3
12028
12126
  * chart.unload({
12029
12127
  * ids: ["data2", "data3"],
12030
12128
  * done: function() {
12031
12129
  * // called after the unloaded
12032
- * }
12130
+ * },
12131
+ * resizeAfter: true // will resize after unload
12033
12132
  * });
12034
12133
  */
12035
12134
  unload: function unload(argsValue) {
@@ -12054,7 +12153,7 @@ var legend_legend = {
12054
12153
  withLegend: !0
12055
12154
  });
12056
12155
  $$.cache.remove(ids);
12057
- args.done && args.done.call(this);
12156
+ callDone.call($$, args.done, args.resizeAfter);
12058
12157
  }.bind(this));
12059
12158
  }
12060
12159
  });
@@ -12741,19 +12840,61 @@ var axis = {
12741
12840
  return config.axis_x_categories;
12742
12841
  }
12743
12842
  });
12744
- ;// CONCATENATED MODULE: ./src/Chart/api/grid.x.ts
12843
+ ;// CONCATENATED MODULE: ./src/Chart/api/grid.ts
12745
12844
  /**
12746
12845
  * Copyright (c) 2017 ~ present NAVER Corp.
12747
12846
  * billboard.js project is licensed under the MIT license
12748
12847
  */
12749
12848
 
12849
+ /**
12850
+ * Update grid lines.
12851
+ * @param {Array} grids grid lines to update
12852
+ * @param {string} axisId axis' id: "x" or "y"
12853
+ * @returns {Array}
12854
+ * @private
12855
+ */
12856
+ function grid(grids, axisId) {
12857
+ var $$ = this.internal,
12858
+ config = $$.config,
12859
+ withTransition = config.transition_duration && isTabVisible(),
12860
+ gridPropLines = "grid_" + axisId + "_lines";
12861
+ if (!grids) {
12862
+ return config[gridPropLines];
12863
+ }
12864
+ config[gridPropLines] = grids;
12865
+ $$.updateGrid();
12866
+ $$.redrawGrid(withTransition);
12867
+ return config[gridPropLines];
12868
+ }
12869
+
12870
+ /**
12871
+ * Add grid lines.
12872
+ * @param {Array|object} grids grid lines to add
12873
+ * @param {string} axisId axis' id: "x" or "y"
12874
+ * @returns {Array}
12875
+ * @private
12876
+ */
12877
+ function _add(grids, axisId) {
12878
+ return grid.bind(this)(this.internal.config["grid_" + axisId + "_lines"].concat(grids || []), axisId);
12879
+ }
12880
+
12881
+ /**
12882
+ * Remove grid lines.
12883
+ * @param {object} grids grid lines to remove
12884
+ * @param {boolean} isXAxis weather is x axis or not
12885
+ * @private
12886
+ */
12887
+ function _remove(grids, isXAxis) {
12888
+ this.internal.removeGridLines(grids, isXAxis);
12889
+ }
12890
+
12750
12891
  /**
12751
12892
  * Update x grid lines.
12752
12893
  * @function xgrids
12753
12894
  * @instance
12754
12895
  * @memberof Chart
12755
12896
  * @param {Array} grids X grid lines will be replaced with this argument. The format of this argument is the same as grid.x.lines.
12756
- * @returns {object}
12897
+ * @returns {Array}
12757
12898
  * @example
12758
12899
  * // Show 2 x grid lines
12759
12900
  * chart.xgrids([
@@ -12763,14 +12904,7 @@ var axis = {
12763
12904
  * // --> Returns: [{value: 1, text: "Label 1"}, {value: 4, text: "Label 4"}]
12764
12905
  */
12765
12906
  var xgrids = function (grids) {
12766
- var $$ = this.internal,
12767
- config = $$.config;
12768
- if (!grids) {
12769
- return config.grid_x_lines;
12770
- }
12771
- config.grid_x_lines = grids;
12772
- $$.redrawWithoutRescale();
12773
- return config.grid_x_lines;
12907
+ return grid.bind(this)(grids, "x");
12774
12908
  };
12775
12909
  extend(xgrids, {
12776
12910
  /**
@@ -12780,7 +12914,7 @@ extend(xgrids, {
12780
12914
  * @instance
12781
12915
  * @memberof Chart
12782
12916
  * @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.
12783
- * @returns {object}
12917
+ * @returns {Array}
12784
12918
  * @example
12785
12919
  * // Add a new x grid line
12786
12920
  * chart.xgrids.add(
@@ -12794,7 +12928,7 @@ extend(xgrids, {
12794
12928
  * ]);
12795
12929
  */
12796
12930
  add: function add(grids) {
12797
- return this.xgrids(this.internal.config.grid_x_lines.concat(grids || []));
12931
+ return _add.bind(this)(grids, "x");
12798
12932
  },
12799
12933
  /**
12800
12934
  * Remove x grid lines.<br>
@@ -12802,7 +12936,10 @@ extend(xgrids, {
12802
12936
  * @function xgrids․remove
12803
12937
  * @instance
12804
12938
  * @memberof Chart
12805
- * @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.
12939
+ * @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.
12940
+ * @param {number} [grids.value] target value
12941
+ * @param {string} [grids.class] target class
12942
+ * @returns {void}
12806
12943
  * @example
12807
12944
  * // x grid line on x = 2 will be removed
12808
12945
  * chart.xgrids.remove({value: 2});
@@ -12815,20 +12952,11 @@ extend(xgrids, {
12815
12952
  * // all of x grid lines will be removed
12816
12953
  * chart.xgrids.remove();
12817
12954
  */
12818
- remove: function remove(params) {
12955
+ remove: function remove(grids) {
12819
12956
  // TODO: multiple
12820
- this.internal.removeGridLines(params, !0);
12957
+ return _remove.bind(this)(grids, !0);
12821
12958
  }
12822
12959
  });
12823
- /* harmony default export */ var grid_x = ({
12824
- xgrids: xgrids
12825
- });
12826
- ;// CONCATENATED MODULE: ./src/Chart/api/grid.y.ts
12827
- /**
12828
- * Copyright (c) 2017 ~ present NAVER Corp.
12829
- * billboard.js project is licensed under the MIT license
12830
- */
12831
-
12832
12960
 
12833
12961
  /**
12834
12962
  * Update y grid lines.
@@ -12846,14 +12974,7 @@ extend(xgrids, {
12846
12974
  * // --> Returns: [{value: 100, text: "Label 1"}, {value: 400, text: "Label 4"}]
12847
12975
  */
12848
12976
  var ygrids = function (grids) {
12849
- var $$ = this.internal,
12850
- config = $$.config;
12851
- if (!grids) {
12852
- return config.grid_y_lines;
12853
- }
12854
- config.grid_y_lines = grids;
12855
- $$.redrawWithoutRescale();
12856
- return config.grid_y_lines;
12977
+ return grid.bind(this)(grids, "y");
12857
12978
  };
12858
12979
  extend(ygrids, {
12859
12980
  /**
@@ -12877,7 +12998,7 @@ extend(ygrids, {
12877
12998
  * ]);
12878
12999
  */
12879
13000
  add: function add(grids) {
12880
- return this.ygrids(this.internal.config.grid_y_lines.concat(grids || []));
13001
+ return _add.bind(this)(grids, "y");
12881
13002
  },
12882
13003
  /**
12883
13004
  * Remove y grid lines.<br>
@@ -12885,9 +13006,10 @@ extend(ygrids, {
12885
13006
  * @function ygrids․remove
12886
13007
  * @instance
12887
13008
  * @memberof Chart
12888
- * @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.
12889
- * @param {number} [params.value] target value
12890
- * @param {string} [params.class] target class
13009
+ * @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.
13010
+ * @param {number} [grids.value] target value
13011
+ * @param {string} [grids.class] target class
13012
+ * @returns {void}
12891
13013
  * @example
12892
13014
  * // y grid line on y = 200 will be removed
12893
13015
  * chart.ygrids.remove({value: 200});
@@ -12900,12 +13022,13 @@ extend(ygrids, {
12900
13022
  * // all of y grid lines will be removed
12901
13023
  * chart.ygrids.remove();
12902
13024
  */
12903
- remove: function remove(params) {
13025
+ remove: function remove(grids) {
12904
13026
  // TODO: multiple
12905
- this.internal.removeGridLines(params, !1);
13027
+ return _remove.bind(this)(grids, !1);
12906
13028
  }
12907
13029
  });
12908
- /* harmony default export */ var grid_y = ({
13030
+ /* harmony default export */ var api_grid = ({
13031
+ xgrids: xgrids,
12909
13032
  ygrids: ygrids
12910
13033
  });
12911
13034
  ;// CONCATENATED MODULE: ./src/Chart/api/group.ts
@@ -12947,6 +13070,29 @@ extend(ygrids, {
12947
13070
  */
12948
13071
 
12949
13072
 
13073
+ /**
13074
+ * Region add/update function
13075
+ * @param {Array} regions Regions will be replaced with this argument. The format of this argument is the same as regions.
13076
+ * @param {boolean} isAdd If true, add new regions, otherwise update regions
13077
+ * @returns {Array} regions
13078
+ * @private
13079
+ */
13080
+ function regionsFn(regions, isAdd) {
13081
+ if (isAdd === void 0) {
13082
+ isAdd = !1;
13083
+ }
13084
+ var $$ = this.internal,
13085
+ config = $$.config,
13086
+ withTransition = config.transition_duration && isTabVisible();
13087
+ if (!regions) {
13088
+ return config.regions;
13089
+ }
13090
+ config.regions = isAdd ? config.regions.concat(regions) : regions;
13091
+ $$.updateRegion();
13092
+ $$.redrawRegion(withTransition);
13093
+ return isAdd ? config.regions : regions;
13094
+ }
13095
+
12950
13096
  /**
12951
13097
  * Update regions.
12952
13098
  * @function regions
@@ -12962,14 +13108,7 @@ extend(ygrids, {
12962
13108
  * ]);
12963
13109
  */
12964
13110
  var regions = function (_regions) {
12965
- var $$ = this.internal,
12966
- config = $$.config;
12967
- if (!_regions) {
12968
- return config.regions;
12969
- }
12970
- config.regions = _regions;
12971
- $$.redrawWithoutRescale();
12972
- return _regions;
13111
+ return regionsFn.bind(this)(_regions);
12973
13112
  };
12974
13113
  extend(regions, {
12975
13114
  /**
@@ -12993,14 +13132,7 @@ extend(regions, {
12993
13132
  *]);
12994
13133
  */
12995
13134
  add: function add(regions) {
12996
- var $$ = this.internal,
12997
- config = $$.config;
12998
- if (!regions) {
12999
- return config.regions;
13000
- }
13001
- config.regions = config.regions.concat(regions);
13002
- $$.redrawWithoutRescale();
13003
- return config.regions;
13135
+ return regionsFn.bind(this)(regions, !0);
13004
13136
  },
13005
13137
  /**
13006
13138
  * Remove regions.<br><br>
@@ -13375,7 +13507,7 @@ var AxisRendererHelper = /*#__PURE__*/function () {
13375
13507
  size = {
13376
13508
  w: 5.5,
13377
13509
  h: 11.5
13378
- };
13510
+ }; // default size for one character
13379
13511
  node.empty() || node.select("text").text("0").call(function (el) {
13380
13512
  _newArrowCheck(this, _this);
13381
13513
  try {
@@ -13570,6 +13702,11 @@ var AxisRenderer = /*#__PURE__*/function () {
13570
13702
  axisPx = tickTransform === helper.axisX ? "y" : "x",
13571
13703
  sign = /^(top|left)$/.test(orient) ? -1 : 1,
13572
13704
  rotate = params.tickTextRotate;
13705
+
13706
+ // line/text enter and path update
13707
+
13708
+ // tick text helpers
13709
+
13573
13710
  this.config.range = scale.rangeExtent ? scale.rangeExtent() : helper.scaleExtent((params.orgXScale || scale).range());
13574
13711
  var innerTickSize = config.innerTickSize,
13575
13712
  tickLength = config.tickLength,
@@ -13585,6 +13722,7 @@ var AxisRenderer = /*#__PURE__*/function () {
13585
13722
  tick: axisShow ? params.config[prefix + "_tick_show"] : !1,
13586
13723
  text: axisShow ? params.config[prefix + "_tick_text_show"] : !1
13587
13724
  }; // // get the axis' tick position configuration
13725
+ // tick visiblity
13588
13726
  var $g;
13589
13727
  g.each(function () {
13590
13728
  var _this = this,
@@ -13822,7 +13960,7 @@ var AxisRenderer = /*#__PURE__*/function () {
13822
13960
  }
13823
13961
  var tickWidth = params.tickWidth;
13824
13962
  if (!tickWidth || tickWidth <= 0) {
13825
- tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
13963
+ tickWidth = isLeftRight ? 95 : params.isCategory ? Math.ceil(params.isInverted ? scale(ticks[0]) - scale(ticks[1]) : scale(ticks[1]) - scale(ticks[0])) - 12 : 110;
13826
13964
  }
13827
13965
 
13828
13966
  // split given text by tick width size
@@ -14230,6 +14368,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14230
14368
  owner: $$
14231
14369
  }, isX && {
14232
14370
  isCategory: isCategory,
14371
+ isInverted: config.axis_x_inverted,
14233
14372
  tickMultiline: config.axis_x_tick_multiline,
14234
14373
  tickWidth: config.axis_x_tick_width,
14235
14374
  tickTitle: isCategory && config.axis_x_tick_tooltip && $$.api.categories(),
@@ -14311,7 +14450,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14311
14450
  tickFormat = forSubchart ? config.subchart_axis_x_tick_format || config.axis_x_tick_format : config.axis_x_tick_format,
14312
14451
  isTimeSeries = this.isTimeSeries(),
14313
14452
  isCategorized = this.isCategorized(),
14314
- currFormat;
14453
+ currFormat; // enable different tick format for x and subX - subX format defaults to x format if not defined
14315
14454
  if (tickFormat) {
14316
14455
  if (isFunction(tickFormat)) {
14317
14456
  currFormat = tickFormat.bind($$.api);
@@ -14854,7 +14993,8 @@ var Axis_Axis = /*#__PURE__*/function () {
14854
14993
  config = $$.config,
14855
14994
  state = $$.state,
14856
14995
  $el = $$.$el,
14857
- isMultipleX = $$.isMultipleX();
14996
+ isMultipleX = $$.isMultipleX(),
14997
+ isInverted = config.axis_x_inverted;
14858
14998
  if ($el.eventRect) {
14859
14999
  $$.updateEventRect($el.eventRect, !0);
14860
15000
  } else {
@@ -14875,10 +15015,10 @@ var Axis_Axis = /*#__PURE__*/function () {
14875
15015
  if (!isMultipleX) {
14876
15016
  // Set data and update eventReceiver.data
14877
15017
  var xAxisTickValues = $$.getMaxDataCountTarget();
14878
- if (!config.data_xSort) {
15018
+ if (!config.data_xSort || isInverted) {
14879
15019
  xAxisTickValues.sort(function (a, b) {
14880
15020
  _newArrowCheck(this, _this);
14881
- return a.x - b.x;
15021
+ return isInverted ? b.x - a.x : a.x - b.x;
14882
15022
  }.bind(this));
14883
15023
  }
14884
15024
 
@@ -14936,7 +15076,8 @@ var Axis_Axis = /*#__PURE__*/function () {
14936
15076
  event.preventDefault();
14937
15077
  }
14938
15078
  }
14939
- }.bind(this);
15079
+ }.bind(this); // call event.preventDefault()
15080
+ // according 'interaction.inputType.touch.preventDefault' option
14940
15081
  // bind touch events
14941
15082
  eventRect.on("touchstart", function (event) {
14942
15083
  _newArrowCheck(this, _this2);
@@ -15528,7 +15669,7 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15528
15669
  flowEnd = $$.getValueOnIndex(dataValues, flowIndex + flowLength),
15529
15670
  translateX,
15530
15671
  orgDomain = x.domain(),
15531
- domain = $$.updateXDomain(targets, !0, !0);
15672
+ domain = $$.updateXDomain(targets, !0, !0); // update x domain to generate axis elements for flow
15532
15673
  // generate transform to flow
15533
15674
  if (!orgDataCount) {
15534
15675
  // if empty
@@ -15607,6 +15748,9 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15607
15748
  y = -Math.max(15, margin.top),
15608
15749
  w = isRotated ? margin.left + 20 : width + 10 + left,
15609
15750
  h = (isRotated ? margin.top + height + 10 : margin.bottom) + 20;
15751
+
15752
+ // less than 20 is not enough to show the axis label 'outer' without legend
15753
+
15610
15754
  node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
15611
15755
  },
15612
15756
  /**
@@ -15615,7 +15759,8 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15615
15759
  * @private
15616
15760
  */
15617
15761
  setYAxisClipPath: function setYAxisClipPath(node) {
15618
- var $$ = this,
15762
+ var _config$padding,
15763
+ $$ = this,
15619
15764
  config = $$.config,
15620
15765
  _$$$state3 = $$.state,
15621
15766
  margin = _$$$state3.margin,
@@ -15624,10 +15769,10 @@ var external_commonjs_d3_ease_commonjs2_d3_ease_amd_d3_ease_root_d3_ = __webpack
15624
15769
  isRotated = config.axis_rotated,
15625
15770
  left = Math.max(30, margin.left) - (isRotated ? 20 : 0),
15626
15771
  isInner = config.axis_y_inner,
15627
- x = isInner ? -1 : isRotated ? -(1 + left) : -(left - 1),
15772
+ x = isInner && !isRotated ? config.axis_y_label.text ? -20 : -1 : isRotated ? -(1 + left) : -(left - 1),
15628
15773
  y = -(isRotated ? 20 : margin.top),
15629
15774
  w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0),
15630
- h = (isRotated ? margin.bottom : margin.top + height) + 10;
15775
+ h = (isRotated ? margin.bottom + (((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit" ? 10 : 0) : margin.top + height) + 10;
15631
15776
  node.attr("x", x).attr("y", y).attr("width", w).attr("height", h);
15632
15777
  },
15633
15778
  updateXAxisTickClip: function updateXAxisTickClip() {
@@ -15733,7 +15878,7 @@ function smoothLines(el, type) {
15733
15878
  });
15734
15879
  }
15735
15880
  }
15736
- /* harmony default export */ var grid = ({
15881
+ /* harmony default export */ var internals_grid = ({
15737
15882
  hasGrid: function hasGrid() {
15738
15883
  var _this4 = this,
15739
15884
  config = this.config;
@@ -16134,13 +16279,13 @@ function smoothLines(el, type) {
16134
16279
 
16135
16280
  // hide if arc type
16136
16281
  region.main.style("visibility", $$.hasArcType() ? "hidden" : null);
16137
- // select <g> element
16138
16282
 
16139
- var list = region.main.selectAll("." + $REGION.region).data(config.regions);
16140
- $T(list.exit()).style("opacity", "0").remove();
16141
- list = list.enter().append("g").merge(list).attr("class", $$.classRegion.bind($$));
16142
- list.append("rect").style("fill-opacity", "0");
16143
- region.list = list;
16283
+ // select <g> element
16284
+ var regions = region.main.selectAll("." + $REGION.region).data(config.regions);
16285
+ $T(regions.exit()).style("opacity", "0").remove();
16286
+ var regionsEnter = regions.enter().append("g");
16287
+ regionsEnter.append("rect").style("fill-opacity", "0");
16288
+ region.list = regionsEnter.merge(regions).attr("class", $$.classRegion.bind($$));
16144
16289
  },
16145
16290
  redrawRegion: function redrawRegion(withTransition) {
16146
16291
  var _this = this,
@@ -16245,14 +16390,16 @@ function smoothLines(el, type) {
16245
16390
  var _$$$axis,
16246
16391
  position = (_$$$axis = $$.axis) == null ? void 0 : _$$$axis.getLabelPositionById(id),
16247
16392
  width = $$.axis.getMaxTickWidth(id, withoutRecompute),
16248
- gap = width === 0 ? .5 : 0;
16249
- return width + (position.isInner ? 20 + gap : 40);
16393
+ gap = width === 0 ? .5 : 0,
16394
+ _$$$config$padding;
16395
+ return width + (((_$$$config$padding = $$.config.padding) == null ? void 0 : _$$$config$padding.mode) === "fit" ? position.isInner ? 10 + gap : 10 : position.isInner ? 20 + gap : 40);
16250
16396
  } else {
16251
16397
  return 40;
16252
16398
  }
16253
16399
  },
16254
16400
  getHorizontalAxisHeight: function getHorizontalAxisHeight(id) {
16255
- var $$ = this,
16401
+ var _config$padding,
16402
+ $$ = this,
16256
16403
  config = $$.config,
16257
16404
  state = $$.state,
16258
16405
  _state = state,
@@ -16260,8 +16407,12 @@ function smoothLines(el, type) {
16260
16407
  rotatedPadding = _state.rotatedPadding,
16261
16408
  isLegendRight = _state.isLegendRight,
16262
16409
  isLegendInset = _state.isLegendInset,
16263
- isRotated = config.axis_rotated;
16264
- var h = 30;
16410
+ isRotated = config.axis_rotated,
16411
+ isFitPadding = ((_config$padding = config.padding) == null ? void 0 : _config$padding.mode) === "fit",
16412
+ isInner = config["axis_" + id + "_inner"],
16413
+ hasLabelText = config["axis_" + id + "_label"].text,
16414
+ _config$padding2,
16415
+ h = ((_config$padding2 = config.padding) == null ? void 0 : _config$padding2.mode) === "fit" ? isInner && !hasLabelText ? id === "y" ? 1 : 0 : 20 : 30;
16265
16416
  if (id === "x" && !config.axis_x_show) {
16266
16417
  return 8;
16267
16418
  }
@@ -16272,7 +16423,7 @@ function smoothLines(el, type) {
16272
16423
  return config.legend_show && !isLegendRight && !isLegendInset ? 10 : 1;
16273
16424
  }
16274
16425
  if (id === "y2" && !config.axis_y2_show) {
16275
- return rotatedPadding.top;
16426
+ return isFitPadding ? 0 : rotatedPadding.top;
16276
16427
  }
16277
16428
  var rotate = $$.getAxisTickRotate(id);
16278
16429
 
@@ -16288,7 +16439,12 @@ function smoothLines(el, type) {
16288
16439
  return h + ($$.axis.getLabelPositionById(id).isInner ? 0 : 10) + (id === "y2" && !isRotated ? -10 : 0);
16289
16440
  },
16290
16441
  getEventRectWidth: function getEventRectWidth() {
16291
- return Math.max(0, this.axis.x.tickInterval());
16442
+ var $$ = this,
16443
+ config = $$.config,
16444
+ axis = $$.axis,
16445
+ isInverted = config.axis_x_inverted,
16446
+ tickInterval = axis.x.tickInterval();
16447
+ return Math.max(0, isInverted ? Math.abs(tickInterval) : tickInterval);
16292
16448
  },
16293
16449
  /**
16294
16450
  * Get axis tick test rotate value
@@ -16981,6 +17137,22 @@ function smoothLines(el, type) {
16981
17137
  * }
16982
17138
  */
16983
17139
  axis_x_min: undefined,
17140
+ /**
17141
+ * Change the direction of x axis.<br><br>
17142
+ * If true set, the direction will be `right -> left`.
17143
+ * @name axis․x․inverted
17144
+ * @memberof Options
17145
+ * @type {boolean}
17146
+ * @default false
17147
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
17148
+ * @example
17149
+ * axis: {
17150
+ * x: {
17151
+ * inverted: true
17152
+ * }
17153
+ * }
17154
+ */
17155
+ axis_x_inverted: !1,
16984
17156
  /**
16985
17157
  * Set padding for x axis.<br><br>
16986
17158
  * If this option is set, the range of x axis will increase/decrease according to the values.
@@ -17243,11 +17415,12 @@ function smoothLines(el, type) {
17243
17415
  axis_y_min: undefined,
17244
17416
  /**
17245
17417
  * Change the direction of y axis.<br><br>
17246
- * If true set, the direction will be from the top to the bottom.
17418
+ * If true set, the direction will be `top -> bottom`.
17247
17419
  * @name axis․y․inverted
17248
17420
  * @memberof Options
17249
17421
  * @type {boolean}
17250
17422
  * @default false
17423
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
17251
17424
  * @example
17252
17425
  * axis: {
17253
17426
  * y: {
@@ -17721,11 +17894,12 @@ function smoothLines(el, type) {
17721
17894
  axis_y2_min: undefined,
17722
17895
  /**
17723
17896
  * Change the direction of y2 axis.<br><br>
17724
- * If true set, the direction will be from the top to the bottom.
17897
+ * If true set, the direction will be `top -> bottom`.
17725
17898
  * @name axis․y2․inverted
17726
17899
  * @memberof Options
17727
17900
  * @type {boolean}
17728
17901
  * @default false
17902
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.InvertedAxis)
17729
17903
  * @example
17730
17904
  * axis: {
17731
17905
  * y2: {
@@ -18217,7 +18391,6 @@ function axis_objectSpread(target) { for (var i = 1, source; i < arguments.lengt
18217
18391
 
18218
18392
 
18219
18393
 
18220
-
18221
18394
  // ChartInternal
18222
18395
 
18223
18396
 
@@ -18231,8 +18404,8 @@ function axis_objectSpread(target) { for (var i = 1, source; i < arguments.lengt
18231
18404
 
18232
18405
 
18233
18406
 
18234
- var api = [api_axis, api_category, grid_x, grid_y, flow, group, api_regions, x];
18235
- var internal = [Axis, clip, eventrect, interactions_flow, grid, region, size_axis];
18407
+ var api = [api_axis, api_category, flow, api_grid, group, api_regions, x];
18408
+ var internal = [Axis, clip, eventrect, interactions_flow, internals_grid, region, size_axis];
18236
18409
  var options = [data_axis, axis_axis, common_grid];
18237
18410
  // EXTERNAL MODULE: external {"commonjs":"d3-interpolate","commonjs2":"d3-interpolate","amd":"d3-interpolate","root":"d3"}
18238
18411
  var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_ = __webpack_require__(12);
@@ -18458,6 +18631,7 @@ function getAttrTweenFn(fn) {
18458
18631
  var min = config.gauge_min,
18459
18632
  max = config.gauge_max,
18460
18633
  totalSum = $$.getTotalDataSum(state.rendered); // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
18634
+ // https://github.com/naver/billboard.js/issues/2123
18461
18635
  pie = pie.startAngle(gStart).endAngle(radius * ((totalSum - min) / (max - min)) + gStart);
18462
18636
  }
18463
18637
  pie($$.filterTargetsToShow()).forEach(function (t, i) {
@@ -19161,7 +19335,7 @@ function getAttrTweenFn(fn) {
19161
19335
  var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
19162
19336
  offset = areaOffset(d, i) || y0,
19163
19337
  posX = x(d),
19164
- value = d.value;
19338
+ value = d.value; // offset is for stacked area chart
19165
19339
  var posY = y(d);
19166
19340
 
19167
19341
  // fix posY not to overflow opposite quadrant
@@ -19325,6 +19499,8 @@ function getAttrTweenFn(fn) {
19325
19499
  _newArrowCheck(this, _this4);
19326
19500
  return w * barRadiusRatio;
19327
19501
  }.bind(this) : null;
19502
+ // get the bar radius
19503
+
19328
19504
  return function (d, i) {
19329
19505
  _newArrowCheck(this, _this4);
19330
19506
  // 4 points that make a bar
@@ -19398,6 +19574,7 @@ function getAttrTweenFn(fn) {
19398
19574
  _newArrowCheck(this, _this5);
19399
19575
  return v.id;
19400
19576
  }.bind(this)); // Get sorted list
19577
+ // Get sorted Ids. Filter positive or negative values Ids from given value
19401
19578
  // If the given id stays in the last position, then radius should be applied.
19402
19579
  return value !== 0 && sortedIds.indexOf(id) === sortedIds.length - 1;
19403
19580
  },
@@ -19428,6 +19605,9 @@ function getAttrTweenFn(fn) {
19428
19605
  isInverted = config["axis_" + $$.axis.getId(id) + "_inverted"],
19429
19606
  value = d.value,
19430
19607
  posX = barX(d);
19608
+
19609
+ // offset is for stacked bar chart
19610
+
19431
19611
  var posY = barY(d);
19432
19612
 
19433
19613
  // fix posY not to overflow opposite quadrant
@@ -19535,7 +19715,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19535
19715
  var points = getPoints(d, i),
19536
19716
  value = $$.getCandlestickData(d),
19537
19717
  isUp = (_value = value) == null ? void 0 : _value._isUp,
19538
- indexX = +isRotated;
19718
+ indexX = +isRotated; // switch points if axis is rotated, not applicable for sub chart
19539
19719
  if (g.classed) {
19540
19720
  g.classed($CANDLESTICK[isUp ? "valueUp" : "valueDown"], !0);
19541
19721
  }
@@ -19589,7 +19769,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19589
19769
  var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
19590
19770
  offset = shapeOffset(d, i) || y0,
19591
19771
  width = isNumber(barW) ? barW : barW[d.id] || barW._$width,
19592
- value = $$.getCandlestickData(d);
19772
+ value = $$.getCandlestickData(d); // offset is for stacked bar chart
19593
19773
  var points;
19594
19774
  if (value) {
19595
19775
  var posX = {
@@ -19710,6 +19890,9 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19710
19890
  state = $$.state,
19711
19891
  hasMultiGauge = $$.hasMultiArcGauge(),
19712
19892
  max = hasMultiGauge ? $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
19893
+
19894
+ // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
19895
+
19713
19896
  // if gauge_max less than max, make max to max value
19714
19897
  if (max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max) {
19715
19898
  config.gauge_max = max - config.gauge_min;
@@ -20025,7 +20208,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
20025
20208
  xp,
20026
20209
  yp,
20027
20210
  diff,
20028
- diffx2;
20211
+ diffx2; // default value
20029
20212
  // Check start/end of regions
20030
20213
  if (isDefined(_regions)) {
20031
20214
  var getValue = function (v, def) {
@@ -20081,7 +20264,8 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
20081
20264
  axisType = {
20082
20265
  x: $$.axis.getAxisType("x"),
20083
20266
  y: $$.axis.getAxisType("y")
20084
- };
20267
+ }; // Define svg generator function for region
20268
+ // Generate
20085
20269
  var path = "";
20086
20270
  for (var _i = 0, data; data = d[_i]; _i++) {
20087
20271
  var prevData = d[_i - 1],
@@ -20309,7 +20493,7 @@ var getTransitionName = function () {
20309
20493
  if (d) {
20310
20494
  circle = circle.filter(function (t) {
20311
20495
  var _this5 = this,
20312
- data = d.filter(function (v) {
20496
+ data = d.filter == null ? void 0 : d.filter(function (v) {
20313
20497
  _newArrowCheck(this, _this5);
20314
20498
  return v.id === t.id;
20315
20499
  }.bind(this));
@@ -20492,12 +20676,12 @@ var getTransitionName = function () {
20492
20676
  x = $$.getShapeX(0, lineIndices, isSub),
20493
20677
  y = $$.getShapeY(isSub),
20494
20678
  lineOffset = $$.getShapeOffset($$.isLineType, lineIndices, isSub),
20495
- yScale = $$.getYScaleById.bind($$);
20679
+ yScale = $$.getYScaleById.bind($$); // partial duplication of generateGetBarPoints
20496
20680
  return function (d, i) {
20497
20681
  _newArrowCheck(this, _this8);
20498
20682
  var y0 = yScale.call($$, d.id, isSub)($$.getShapeYMin(d.id)),
20499
20683
  offset = lineOffset(d, i) || y0,
20500
- posX = x(d);
20684
+ posX = x(d); // offset is for stacked area chart
20501
20685
  var posY = y(d);
20502
20686
 
20503
20687
  // fix posY not to overflow opposite quadrant
@@ -20921,6 +21105,8 @@ var cacheKey = KEY.radarPoints;
20921
21105
  return pos.join(" ");
20922
21106
  }.bind(this)),
20923
21107
  level = radarLevels.selectAll("." + $LEVEL.level).data(levelData);
21108
+ // Generate points
21109
+
20924
21110
  level.exit().remove();
20925
21111
  var levelEnter = level.enter().append("g").attr("class", function (d, i) {
20926
21112
  _newArrowCheck(this, _this6);
@@ -22724,7 +22910,10 @@ var _area = function area() {
22724
22910
  _newArrowCheck(this, _this19);
22725
22911
  return TYPE.TREEMAP;
22726
22912
  }.bind(this))();
22727
- }.bind(undefined);
22913
+ }.bind(undefined); // Line types
22914
+ // Arc types
22915
+ // Axis based types
22916
+ // Non Axis based types
22728
22917
  ;// CONCATENATED MODULE: ./src/Chart/api/selection.ts
22729
22918
 
22730
22919
  /**
@@ -22968,17 +23157,21 @@ var external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_ = __webpack
22968
23157
  * @param {Array} domain Target domain value
22969
23158
  * @param {Array} current Current zoom domain value
22970
23159
  * @param {Array} range Zoom range value
23160
+ * @param {boolean} isInverted Whether the axis is inverted or not
22971
23161
  * @returns {boolean}
22972
23162
  * @private
22973
23163
  */
22974
- function withinRange(domain, current, range) {
22975
- var _this = this,
22976
- min = range[0],
23164
+ function withinRange(domain, current, range, isInverted) {
23165
+ var _this = this;
23166
+ if (isInverted === void 0) {
23167
+ isInverted = !1;
23168
+ }
23169
+ var min = range[0],
22977
23170
  max = range[1];
22978
23171
  return domain.every(function (v, i) {
22979
23172
  var _this2 = this;
22980
23173
  _newArrowCheck(this, _this);
22981
- return (i === 0 ? v >= min : v <= max) && !domain.every(function (v, i) {
23174
+ return (i === 0 ? isInverted ? +v <= min : +v >= min : isInverted ? +v >= max : +v <= max) && !domain.every(function (v, i) {
22982
23175
  _newArrowCheck(this, _this2);
22983
23176
  return v === current[i];
22984
23177
  }.bind(this));
@@ -23014,6 +23207,7 @@ var zoom = function (domainValue) {
23014
23207
  org = $$.org,
23015
23208
  scale = $$.scale,
23016
23209
  isRotated = config.axis_rotated,
23210
+ isInverted = config.axis_x_inverted,
23017
23211
  isCategorized = axis.isCategorized(),
23018
23212
  domain = domainValue;
23019
23213
  if (config.zoom_enabled && domain) {
@@ -23023,7 +23217,8 @@ var zoom = function (domainValue) {
23023
23217
  return parseDate.bind($$)(x);
23024
23218
  }.bind(this));
23025
23219
  }
23026
- if (withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain())) {
23220
+ var isWithinRange = withinRange(domain, $$.getZoomDomain(!0), $$.getZoomDomain(), isInverted);
23221
+ if (isWithinRange) {
23027
23222
  if (isCategorized) {
23028
23223
  domain = domain.map(function (v, i) {
23029
23224
  _newArrowCheck(this, _this3);
@@ -23041,7 +23236,10 @@ var zoom = function (domainValue) {
23041
23236
  var _d3ZoomIdentity$scale,
23042
23237
  _x = isCategorized ? scale.x.orgScale() : org.xScale || scale.x,
23043
23238
  translate = [-_x(domain[0]), 0],
23044
- transform = (_d3ZoomIdentity$scale = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(_x.range()[1] / (_x(domain[1]) - _x(domain[0])))).translate.apply(_d3ZoomIdentity$scale, isRotated ? translate.reverse() : translate);
23239
+ transform = (_d3ZoomIdentity$scale = external_commonjs_d3_zoom_commonjs2_d3_zoom_amd_d3_zoom_root_d3_.zoomIdentity.scale(_x.range()[1] / (_x(domain[1]) - _x(domain[0])))).translate.apply(_d3ZoomIdentity$scale, isRotated ? translate.reverse() : translate); // in case of 'config.zoom_rescale=true', use org.xScale
23240
+ // Get transform from given domain value
23241
+ // https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
23242
+
23045
23243
  $el.eventRect.call($$.zoom.transform, transform);
23046
23244
  }
23047
23245
  $$.setZoomResetButton();
@@ -23655,6 +23853,8 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
23655
23853
  isRotated = config.axis_rotated,
23656
23854
  initRange = config.subchart_init_range,
23657
23855
  path = isRotated ? ["M 5.2491724,29.749209 a 6,6 0 0 0 -5.50000003,-6.5 H -5.7508276 a 6,6 0 0 0 -6.0000004,6.5 z m -5.00000003,-2 H -6.7508276 m 6.99999997,-2 H -6.7508276Z", "M 5.2491724,23.249172 a 6,-6 0 0 1 -5.50000003,6.5 H -5.7508276 a 6,-6 0 0 1 -6.0000004,-6.5 z m -5.00000003,2 H -6.7508276 m 6.99999997,2 H -6.7508276Z"] : ["M 0 18 A 6 6 0 0 0 -6.5 23.5 V 29 A 6 6 0 0 0 0 35 Z M -2 23 V 30 M -4 23 V 30Z", "M 0 18 A 6 6 0 0 1 6.5 23.5 V 29 A 6 6 0 0 1 0 35 Z M 2 23 V 30 M 4 23 V 30Z"];
23856
+ // brush handle shape's path
23857
+
23658
23858
  $$.brush.handle = brush.selectAll(".handle--custom").data(isRotated ? [{
23659
23859
  type: "n"
23660
23860
  }, {
@@ -23914,7 +24114,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
23914
24114
  if (!$$.state.xTickOffset) {
23915
24115
  $$.state.xTickOffset = $$.axis.x.tickOffset();
23916
24116
  }
23917
- scale.zoom = $$.getCustomizedScale(newScale);
24117
+ scale.zoom = $$.getCustomizedXScale(newScale);
23918
24118
  $$.axis.x.scale(scale.zoom);
23919
24119
  if (rescale) {
23920
24120
  // copy current initial x scale in case of rescale option is used
@@ -24046,7 +24246,7 @@ function selection_objectSpread(target) { for (var i = 1, source; i < arguments.
24046
24246
  var zoomDomain = zoom.domain(),
24047
24247
  xDomain = subX.domain(),
24048
24248
  delta = .015,
24049
- isfullyShown = (zoomDomain[0] <= xDomain[0] || zoomDomain[0] - delta <= xDomain[0]) && (xDomain[1] <= zoomDomain[1] || xDomain[1] <= zoomDomain[1] - delta);
24249
+ 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); // arbitrary value
24050
24250
  // check if the zoomed chart is fully shown, then reset scale when zoom is out as initial
24051
24251
  if (force || isfullyShown) {
24052
24252
  $$.axis.x.scale(subX);
@@ -24523,7 +24723,7 @@ var _defaults = {};
24523
24723
 
24524
24724
  /**
24525
24725
  * @namespace bb
24526
- * @version 3.7.5
24726
+ * @version 3.8.0-next.2
24527
24727
  */
24528
24728
  var bb = {
24529
24729
  /**
@@ -24533,7 +24733,7 @@ var bb = {
24533
24733
  * bb.version; // "1.0.0"
24534
24734
  * @memberof bb
24535
24735
  */
24536
- version: "3.7.5",
24736
+ version: "3.8.0-next.2",
24537
24737
  /**
24538
24738
  * Generate chart
24539
24739
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: