billboard.js 3.6.2 → 3.7.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 (57) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +529 -167
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +1723 -1277
  6. package/dist/billboard.pkgd.min.js +4 -2
  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 +35 -3
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +35 -3
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +35 -3
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +35 -3
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +933 -923
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +966 -924
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +966 -924
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +966 -924
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +966 -924
  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 +375 -108
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
  32. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  33. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  34. package/package.json +40 -35
  35. package/src/Chart/api/chart.ts +13 -4
  36. package/src/Chart/api/export.ts +159 -14
  37. package/src/ChartInternal/Axis/Axis.ts +1 -1
  38. package/src/ChartInternal/Axis/AxisRendererHelper.ts +4 -2
  39. package/src/ChartInternal/data/IData.ts +1 -0
  40. package/src/ChartInternal/data/data.ts +21 -2
  41. package/src/ChartInternal/interactions/interaction.ts +6 -7
  42. package/src/ChartInternal/internals/domain.ts +11 -4
  43. package/src/ChartInternal/internals/format.ts +1 -1
  44. package/src/ChartInternal/internals/grid.ts +1 -1
  45. package/src/ChartInternal/shape/arc.ts +145 -68
  46. package/src/ChartInternal/shape/area.ts +3 -0
  47. package/src/ChartInternal/shape/bar.ts +3 -0
  48. package/src/ChartInternal/shape/line.ts +12 -15
  49. package/src/config/Options/common/tooltip.ts +11 -8
  50. package/src/config/Options/shape/arc.ts +47 -0
  51. package/src/config/Options/shape/gauge.ts +2 -2
  52. package/src/config/resolver/shape.ts +13 -4
  53. package/src/module/util.ts +1 -1
  54. package/types/chart.d.ts +7 -0
  55. package/types/options.d.ts +39 -624
  56. package/types/options.shape.d.ts +633 -0
  57. package/types/types.d.ts +2 -2
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.6.2
8
+ * @version 3.7.0-next.1
9
9
  */
10
10
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
11
11
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
@@ -547,13 +547,14 @@ function addCssRules(style, selector, prop) {
547
547
  function getCssRules(styleSheets) {
548
548
  var rules = [];
549
549
  styleSheets.forEach(function (sheet) {
550
+ var _a;
550
551
  try {
551
552
  if (sheet.cssRules && sheet.cssRules.length) {
552
553
  rules = rules.concat(toArray(sheet.cssRules));
553
554
  }
554
555
  }
555
556
  catch (e) {
556
- console.error("Error while reading rules from ".concat(sheet.href, ": ").concat(e.toString()));
557
+ (_a = win.console) === null || _a === void 0 ? void 0 : _a.warn("Error while reading rules from ".concat(sheet.href, ": ").concat(e.toString()));
557
558
  }
558
559
  });
559
560
  return rules;
@@ -2822,17 +2823,20 @@ var tooltip$2 = {
2822
2823
  * Specified function receives x of the data point to show.
2823
2824
  * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
2824
2825
  * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
2825
- * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip.<br>
2826
- * Specified function receives name, ratio, id and index of the data point to show. ratio will be undefined if the chart is not donut/pie/gauge.
2827
- * If undefined returned, the row of that value will be skipped.
2826
+ * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip. If undefined returned, the row of that value will be skipped to be called.
2827
+ * - Will pass following arguments to the given function:
2828
+ * - `value {string}`: Value of the data point
2829
+ * - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
2830
+ * - `id {string}`: id of the data point
2831
+ * - `index {number}`: Index of the data point
2828
2832
  * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
2829
2833
  * This option can be used to modify the tooltip position by returning object that has top and left.
2830
2834
  * - Will pass following arguments to the given function:
2831
- * - `data {Array}`: Current selected data array object.
2832
- * - `width {number}`: Width of tooltip.
2833
- * - `height {number}`: Height of tooltip.
2834
- * - `element {SVGElement}`: Tooltip event bound element
2835
- * - `pos {object}`: Current position of the tooltip.
2835
+ * - `data {Array}`: Current selected data array object.
2836
+ * - `width {number}`: Width of tooltip.
2837
+ * - `height {number}`: Height of tooltip.
2838
+ * - `element {SVGElement}`: Tooltip event bound element
2839
+ * - `pos {object}`: Current position of the tooltip.
2836
2840
  * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
2837
2841
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
2838
2842
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
@@ -3905,7 +3909,7 @@ var data$1 = {
3905
3909
  var $$ = this;
3906
3910
  var cacheKey = KEY.dataTotalPerIndex;
3907
3911
  var sum = $$.cache.get(cacheKey);
3908
- if ($$.isStackNormalized() && !sum) {
3912
+ if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
3909
3913
  sum = [];
3910
3914
  $$.data.targets.forEach(function (row) {
3911
3915
  row.values.forEach(function (v, i) {
@@ -4367,6 +4371,22 @@ var data$1 = {
4367
4371
  }
4368
4372
  return value;
4369
4373
  },
4374
+ /**
4375
+ * Set ratio for grouped data
4376
+ * @param {Array} data Data array
4377
+ * @private
4378
+ */
4379
+ setRatioForGroupedData: function (data) {
4380
+ var $$ = this;
4381
+ var config = $$.config;
4382
+ // calculate ratio if grouped data exists
4383
+ if (config.data_groups.length && data.some(function (d) { return $$.isGrouped(d.id); })) {
4384
+ var setter_1 = function (d) { return $$.getRatio("index", d, true); };
4385
+ data.forEach(function (v) {
4386
+ "values" in v ? v.values.forEach(setter_1) : setter_1(v);
4387
+ });
4388
+ }
4389
+ },
4370
4390
  /**
4371
4391
  * Get ratio value
4372
4392
  * @param {string} type Ratio for given type
@@ -4406,7 +4426,7 @@ var data$1 = {
4406
4426
  total = total.map(function (v, i) { return v - hiddenSum_1[i]; });
4407
4427
  }
4408
4428
  }
4409
- d.ratio = isNumber(d.value) && total && total[d.index] > 0 ?
4429
+ d.ratio = isNumber(d.value) && total ?
4410
4430
  d.value / total[d.index] : 0;
4411
4431
  ratio = d.ratio;
4412
4432
  }
@@ -4598,13 +4618,12 @@ var interaction = {
4598
4618
  return;
4599
4619
  }
4600
4620
  }
4621
+ // remove possible previous focused state
4622
+ main.selectAll(".".concat($COMMON.EXPANDED, ":not(.").concat($SHAPE.shape, "-").concat(index, ")"))
4623
+ .classed($COMMON.EXPANDED, false);
4601
4624
  var shapeAtIndex = main.selectAll(".".concat($SHAPE.shape, "-").concat(index))
4602
- .each(function () {
4603
- select(this).classed($COMMON.EXPANDED, true);
4604
- if (isSelectionEnabled) {
4605
- eventRect.style("cursor", isSelectionGrouped ? "pointer" : null);
4606
- }
4607
- })
4625
+ .classed($COMMON.EXPANDED, true)
4626
+ .style("cursor", isSelectable ? "pointer" : null)
4608
4627
  .filter(function (d) {
4609
4628
  return $$.isWithinShape(this, d);
4610
4629
  });
@@ -5257,10 +5276,8 @@ var domain = {
5257
5276
  return $$.hasType(v, yTargets, true) && config["".concat(type, "_zerobased")];
5258
5277
  });
5259
5278
  // MEMO: avoid inverting domain unexpectedly
5260
- yDomainMin = isValue(yMin) ? yMin :
5261
- (isValue(yMax) ? (yDomainMin < yMax ? yDomainMin : yMax - 10) : yDomainMin);
5262
- yDomainMax = isValue(yMax) ? yMax :
5263
- (isValue(yMin) ? (yMin < yDomainMax ? yDomainMax : yMin + 10) : yDomainMax);
5279
+ yDomainMin = isValue(yMin) ? yMin : (isValue(yMax) ? (yDomainMin <= yMax ? yDomainMin : yMax - 10) : yDomainMin);
5280
+ yDomainMax = isValue(yMax) ? yMax : (isValue(yMin) ? (yMin <= yDomainMax ? yDomainMax : yMin + 10) : yDomainMax);
5264
5281
  if (isNaN(yDomainMin)) { // set minimum to zero when not number
5265
5282
  yDomainMin = 0;
5266
5283
  }
@@ -5507,7 +5524,7 @@ function getFormat($$, typeValue, v) {
5507
5524
  var type = "axis_".concat(typeValue, "_tick_format");
5508
5525
  var format = config[type] ?
5509
5526
  config[type] : $$.defaultValueFormat;
5510
- return format(v);
5527
+ return format.call($$.api, v);
5511
5528
  }
5512
5529
  var format = {
5513
5530
  yFormat: function (v) {
@@ -9541,8 +9558,9 @@ var apiChart = {
9541
9558
  },
9542
9559
  /**
9543
9560
  * Get or set config option value.
9544
- * - **NOTE:** for without parameter occasion
9545
- * - will return all specified generation options object only. (will exclude any other options not specified at the initialization)
9561
+ * - **NOTE**
9562
+ * - The option key name must be specified as the last level.
9563
+ * - when no argument is given, will return all specified generation options object only. (will exclude any other options not specified at the initialization)
9546
9564
  * @function config
9547
9565
  * @instance
9548
9566
  * @memberof Chart
@@ -9556,12 +9574,20 @@ var apiChart = {
9556
9574
  * // Getter
9557
9575
  * chart.config("gauge.max");
9558
9576
  *
9577
+ * // Getter specified with top level key name will not work.
9578
+ * // The option key name must be specified as the last level.
9579
+ * // chart.config("gauge"); // will not work
9580
+ *
9559
9581
  * // without any arguments, it returns generation config object
9560
9582
  * chart.config(); // {data: { ... }, axis: { ... }, ...}
9561
9583
  *
9562
9584
  * // Setter
9563
9585
  * chart.config("gauge.max", 100);
9564
9586
  *
9587
+ * // Setter specified with top level key name will not work.
9588
+ * // The option key name must be specified as the last level.
9589
+ * // chart.config("gauge", {min: 10, max: 20}); // will not work
9590
+ *
9565
9591
  * // Setter & redraw with the new option
9566
9592
  * chart.config("gauge.max", 100, true);
9567
9593
  */
@@ -9580,7 +9606,7 @@ var apiChart = {
9580
9606
  res = config[key];
9581
9607
  }
9582
9608
  }
9583
- else {
9609
+ else if (arguments.length === 0 || isEmpty(name)) {
9584
9610
  res = state.orgConfig;
9585
9611
  }
9586
9612
  return res;
@@ -9790,8 +9816,11 @@ var apiData = { data: data };
9790
9816
  * @private
9791
9817
  * @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
9792
9818
  */
9793
- var b64EncodeUnicode = function (str) { return btoa(encodeURIComponent(str)
9794
- .replace(/%([0-9A-F]{2})/g, function (match, p) { return String.fromCharCode(Number("0x".concat(p))); })); };
9819
+ var b64EncodeUnicode = function (str) {
9820
+ var _a;
9821
+ return (_a = win.btoa) === null || _a === void 0 ? void 0 : _a.call(win, encodeURIComponent(str)
9822
+ .replace(/%([0-9A-F]{2})/g, function (match, p) { return String.fromCharCode(Number("0x".concat(p))); }));
9823
+ };
9795
9824
  /**
9796
9825
  * Convert svg node to data url
9797
9826
  * @param {HTMLElement} node target node
@@ -9808,6 +9837,15 @@ function nodeToSvgDataUrl(node, option, orgSize) {
9808
9837
  .filter(function (r) { return r.cssText; })
9809
9838
  .map(function (r) { return r.cssText; });
9810
9839
  clone.setAttribute("xmlns", namespaces.xhtml);
9840
+ // remove padding & margin
9841
+ clone.style.margin = "0";
9842
+ clone.style.padding = "0";
9843
+ // remove text nodes
9844
+ if (option.preserveFontStyle) {
9845
+ clone.querySelectorAll("text").forEach(function (t) {
9846
+ t.innerHTML = "";
9847
+ });
9848
+ }
9811
9849
  var nodeXml = serializer.serializeToString(clone);
9812
9850
  // escape css for XML
9813
9851
  var style = doc.createElement("style");
@@ -9819,12 +9857,113 @@ function nodeToSvgDataUrl(node, option, orgSize) {
9819
9857
  .replace("/\n/g", "%0A");
9820
9858
  return "data:image/svg+xml;base64,".concat(b64EncodeUnicode(dataStr));
9821
9859
  }
9860
+ /**
9861
+ * Get coordinate of the element
9862
+ * @param {SVGElement} elem Target element
9863
+ * @param {object} svgOffset SVG offset
9864
+ * @returns {object}
9865
+ * @private
9866
+ */
9867
+ function getCoords(elem, svgOffset) {
9868
+ var top = svgOffset.top, left = svgOffset.left;
9869
+ var _a = elem.getBBox(), x = _a.x, y = _a.y;
9870
+ var _b = elem.getScreenCTM(), a = _b.a, b = _b.b, c = _b.c, d = _b.d, e = _b.e, f = _b.f;
9871
+ var _c = elem.getBoundingClientRect(), width = _c.width, height = _c.height;
9872
+ return {
9873
+ x: (a * x) + (c * y) + e - left,
9874
+ y: (b * x) + (d * y) + f - top + (height - Math.round(height / 4)),
9875
+ width: width,
9876
+ height: height
9877
+ };
9878
+ }
9879
+ /**
9880
+ * Get text glyph
9881
+ * @param {SVGTextElement} svg Target svg node
9882
+ * @returns {Array}
9883
+ * @private
9884
+ */
9885
+ function getGlyph(svg) {
9886
+ var _a = svg.getBoundingClientRect(), left = _a.left, top = _a.top;
9887
+ var filterFn = function (t) { return t.textContent || t.childElementCount; };
9888
+ var glyph = [];
9889
+ toArray(svg.querySelectorAll("text"))
9890
+ .filter(filterFn)
9891
+ .forEach(function (t) {
9892
+ var getStyleFn = function (ts) {
9893
+ var _a;
9894
+ var _b = win.getComputedStyle(ts), fill = _b.fill, fontFamily = _b.fontFamily, fontSize = _b.fontSize, textAnchor = _b.textAnchor, transform = _b.transform;
9895
+ var _c = getCoords(ts, { left: left, top: top }), x = _c.x, y = _c.y, width = _c.width, height = _c.height;
9896
+ return _a = {},
9897
+ _a[ts.textContent] = {
9898
+ x: x,
9899
+ y: y,
9900
+ width: width,
9901
+ height: height,
9902
+ fill: fill,
9903
+ fontFamily: fontFamily,
9904
+ fontSize: fontSize,
9905
+ textAnchor: textAnchor,
9906
+ transform: transform
9907
+ },
9908
+ _a;
9909
+ };
9910
+ if (t.childElementCount > 1) {
9911
+ var text = [];
9912
+ toArray(t.querySelectorAll("tspan"))
9913
+ .filter(filterFn)
9914
+ .forEach(function (ts) {
9915
+ glyph.push(getStyleFn(ts));
9916
+ });
9917
+ return text;
9918
+ }
9919
+ else {
9920
+ glyph.push(getStyleFn(t));
9921
+ }
9922
+ });
9923
+ return glyph;
9924
+ }
9925
+ /**
9926
+ * Render text glyph
9927
+ * - NOTE: Called when the 'preserveFontStyle' option is true
9928
+ * @param {CanvasRenderingContext2D} ctx Canvas context
9929
+ * @param {Array} glyph Text glyph array
9930
+ * @private
9931
+ */
9932
+ function renderText(ctx, glyph) {
9933
+ glyph.forEach(function (g) {
9934
+ Object.keys(g).forEach(function (key) {
9935
+ var _a = g[key], x = _a.x, y = _a.y, width = _a.width, height = _a.height, fill = _a.fill, fontFamily = _a.fontFamily, fontSize = _a.fontSize, transform = _a.transform;
9936
+ ctx.save();
9937
+ ctx.font = "".concat(fontSize, " ").concat(fontFamily);
9938
+ ctx.fillStyle = fill;
9939
+ if (transform === "none") {
9940
+ ctx.fillText(key, x, y);
9941
+ }
9942
+ else {
9943
+ var args = transform
9944
+ .replace(/(matrix|\(|\))/g, "")
9945
+ .split(",");
9946
+ if (args.splice(4).every(function (v) { return +v === 0; })) {
9947
+ args.push(x + width - (width / 4));
9948
+ args.push(y - height + (height / 3));
9949
+ }
9950
+ else {
9951
+ args.push(x);
9952
+ args.push(y);
9953
+ }
9954
+ ctx.transform.apply(ctx, args);
9955
+ ctx.fillText(key, 0, 0);
9956
+ }
9957
+ ctx.restore();
9958
+ });
9959
+ });
9960
+ }
9822
9961
  var apiExport = {
9823
9962
  /**
9824
9963
  * Export chart as an image.
9825
9964
  * - **NOTE:**
9826
9965
  * - IE11 and below not work properly due to the lack of the feature(<a href="https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx">foreignObject</a>) support
9827
- * - The basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
9966
+ * - Every style applied to the chart & the basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
9828
9967
  * @function export
9829
9968
  * @instance
9830
9969
  * @memberof Chart
@@ -9833,6 +9972,12 @@ var apiExport = {
9833
9972
  * @param {number} [option.width={currentWidth}] width
9834
9973
  * @param {number} [option.height={currentHeigth}] height
9835
9974
  * @param {boolean} [option.preserveAspectRatio=true] Preserve aspect ratio on given size
9975
+ * @param {boolean} [option.preserveFontStyle=false] Preserve font style(font-family).<br>
9976
+ * **NOTE:**
9977
+ * - This option is useful when outlink web font style's `font-family` are applied to chart's text element.
9978
+ * - Text element's position(especially "transformed") can't be preserved correctly according the page's layout condition.
9979
+ * - If need to preserve accurate text position, embed the web font data within to the page and set `preserveFontStyle=false`.
9980
+ * - Checkout the embed example: <a href="https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html">https://stackblitz.com/edit/zfbya9-8nf9nn?file=index.html</a>
9836
9981
  * @param {Function} [callback] The callback to be invoked when export is ready.
9837
9982
  * @returns {string} dataURI
9838
9983
  * @example
@@ -9856,6 +10001,7 @@ var apiExport = {
9856
10001
  * width: 800,
9857
10002
  * height: 600,
9858
10003
  * preserveAspectRatio: false,
10004
+ * preserveFontStyle: false,
9859
10005
  * mimeType: "image/png"
9860
10006
  * },
9861
10007
  * dataUrl => { ... }
@@ -9864,15 +10010,17 @@ var apiExport = {
9864
10010
  "export": function (option, callback) {
9865
10011
  var _this = this;
9866
10012
  var $$ = this.internal;
9867
- var state = $$.state, chart = $$.$el.chart;
9868
- var _a = state.current, width = _a.width, height = _a.height;
10013
+ var state = $$.state, _a = $$.$el, chart = _a.chart, svg = _a.svg;
10014
+ var _b = state.current, width = _b.width, height = _b.height;
9869
10015
  var opt = mergeObj({
9870
10016
  width: width,
9871
10017
  height: height,
9872
10018
  preserveAspectRatio: true,
10019
+ preserveFontStyle: false,
9873
10020
  mimeType: "image/png"
9874
10021
  }, option);
9875
10022
  var svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, { width: width, height: height });
10023
+ var glyph = opt.preserveFontStyle ? getGlyph(svg.node()) : [];
9876
10024
  if (callback && isFunction(callback)) {
9877
10025
  var img_1 = new Image();
9878
10026
  img_1.crossOrigin = "Anonymous";
@@ -9882,6 +10030,11 @@ var apiExport = {
9882
10030
  canvas.width = opt.width || width;
9883
10031
  canvas.height = opt.height || height;
9884
10032
  ctx.drawImage(img_1, 0, 0);
10033
+ if (glyph.length) {
10034
+ renderText(ctx, glyph);
10035
+ // release glyph array
10036
+ glyph.length = 0;
10037
+ }
9885
10038
  callback.bind(_this)(canvas.toDataURL(opt.mimeType));
9886
10039
  };
9887
10040
  img_1.src = svgDataUrl;
@@ -11530,7 +11683,7 @@ var AxisRendererHelper = /** @class */ (function () {
11530
11683
  function (value) { return "translate(".concat(value + config.tickOffset, ",0)"); } :
11531
11684
  function (value) { return "translate(0,".concat(value, ")"); };
11532
11685
  return function (selection, scale) {
11533
- selection.attr("transform", function (d) { return fn(Math.ceil(scale(d))); });
11686
+ selection.attr("transform", function (d) { return (isValue(d) ? fn(Math.ceil(scale(d))) : null); });
11534
11687
  };
11535
11688
  };
11536
11689
  AxisRendererHelper.prototype.scaleExtent = function (domain) {
@@ -12517,7 +12670,7 @@ var Axis = /** @class */ (function () {
12517
12670
  var config = $$.config, current = $$.state.current, _a = $$.$el, svg = _a.svg, chart = _a.chart;
12518
12671
  var currentTickMax = current.maxTickWidths[id];
12519
12672
  var maxWidth = 0;
12520
- if (withoutRecompute || !config["axis_".concat(id, "_show")] || $$.filterTargetsToShow().length === 0) {
12673
+ if (withoutRecompute || !config["axis_".concat(id, "_show")] || (currentTickMax.size > 0 && $$.filterTargetsToShow().length === 0)) {
12521
12674
  return currentTickMax.size;
12522
12675
  }
12523
12676
  if (svg) {
@@ -13781,7 +13934,7 @@ var grid = {
13781
13934
  xgridLine.append("line")
13782
13935
  .style("opacity", "0");
13783
13936
  xgridLine.append("text")
13784
- .attr("transform", isRotated ? "" : "rotate(-90)")
13937
+ .attr("transform", isRotated ? null : "rotate(-90)")
13785
13938
  .attr("dy", -5)
13786
13939
  .style("opacity", "0");
13787
13940
  xLines = xgridLine.merge(xLines);
@@ -16133,6 +16286,99 @@ var options = [
16133
16286
  * Copyright (c) 2017 ~ present NAVER Corp.
16134
16287
  * billboard.js project is licensed under the MIT license
16135
16288
  */
16289
+ /**
16290
+ * Get radius functions
16291
+ * @param {number} expandRate Expand rate number.
16292
+ * - If 0, means for "normal" radius.
16293
+ * - If > 0, means for "expanded" radius.
16294
+ * @returns {object} radius functions
16295
+ * @private
16296
+ */
16297
+ function getRadiusFn(expandRate) {
16298
+ if (expandRate === void 0) { expandRate = 0; }
16299
+ var $$ = this;
16300
+ var config = $$.config, state = $$.state;
16301
+ var hasMultiArcGauge = $$.hasMultiArcGauge();
16302
+ var singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
16303
+ var expandWidth = expandRate ? (Math.min(state.radiusExpanded * expandRate - state.radius, singleArcWidth * 0.8 - (1 - expandRate) * 100)) : 0;
16304
+ return {
16305
+ /**
16306
+ * Getter of arc innerRadius value
16307
+ * @param {IArcData} d Data object
16308
+ * @returns {number} innerRadius value
16309
+ * @private
16310
+ */
16311
+ inner: function (d) {
16312
+ var innerRadius = $$.getRadius(d).innerRadius;
16313
+ return hasMultiArcGauge ?
16314
+ state.radius - singleArcWidth * (d.index + 1) :
16315
+ isNumber(innerRadius) ? innerRadius : 0;
16316
+ },
16317
+ /**
16318
+ * Getter of arc outerRadius value
16319
+ * @param {IArcData} d Data object
16320
+ * @returns {number} outerRadius value
16321
+ * @private
16322
+ */
16323
+ outer: function (d) {
16324
+ var outerRadius = $$.getRadius(d).outerRadius;
16325
+ var radius;
16326
+ if (hasMultiArcGauge) {
16327
+ radius = state.radius - singleArcWidth * d.index + expandWidth;
16328
+ }
16329
+ else if ($$.hasType("polar") && !expandRate) {
16330
+ radius = $$.getPolarOuterRadius(d, outerRadius);
16331
+ }
16332
+ else {
16333
+ radius = outerRadius;
16334
+ if (expandRate) {
16335
+ var radiusExpanded = state.radiusExpanded;
16336
+ if (state.radius !== outerRadius) {
16337
+ radiusExpanded -= Math.abs(state.radius - outerRadius);
16338
+ }
16339
+ radius = radiusExpanded * expandRate;
16340
+ }
16341
+ }
16342
+ return radius;
16343
+ },
16344
+ /**
16345
+ * Getter of arc cornerRadius value
16346
+ * @param {IArcData} d Data object
16347
+ * @param {number} outerRadius outer radius value
16348
+ * @returns {number} cornerRadius value
16349
+ * @private
16350
+ */
16351
+ corner: function (d, outerRadius) {
16352
+ var _a = config.arc_cornerRadius_ratio, ratio = _a === void 0 ? 0 : _a, _b = config.arc_cornerRadius, cornerRadius = _b === void 0 ? 0 : _b;
16353
+ var id = d.data.id, value = d.value;
16354
+ var corner = 0;
16355
+ if (ratio) {
16356
+ corner = ratio * outerRadius;
16357
+ }
16358
+ else {
16359
+ corner = isNumber(cornerRadius) ?
16360
+ cornerRadius : cornerRadius.call($$.api, id, value, outerRadius);
16361
+ }
16362
+ return corner;
16363
+ }
16364
+ };
16365
+ }
16366
+ /**
16367
+ * Get attrTween function to get interpolated value on transition
16368
+ * @param {Function} fn Arc function to execute
16369
+ * @returns {Function} attrTween function
16370
+ * @private
16371
+ */
16372
+ function getAttrTweenFn(fn) {
16373
+ return function (d) {
16374
+ var interpolate$1 = interpolate(this._current, d);
16375
+ this._current = d;
16376
+ return function (t) {
16377
+ var interpolated = interpolate$1(t);
16378
+ return fn(interpolated);
16379
+ };
16380
+ };
16381
+ }
16136
16382
  var shapeArc = {
16137
16383
  initPie: function () {
16138
16384
  var $$ = this;
@@ -16275,37 +16521,17 @@ var shapeArc = {
16275
16521
  },
16276
16522
  getSvgArc: function () {
16277
16523
  var $$ = this;
16278
- var state = $$.state;
16279
- var singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
16280
- var hasMultiArcGauge = $$.hasMultiArcGauge();
16281
- var hasPolar = $$.hasType("polar");
16524
+ var _a = getRadiusFn.call($$), inner = _a.inner, outer = _a.outer, corner = _a.corner;
16282
16525
  var arc$1 = arc()
16283
- .innerRadius(function (d) {
16284
- var innerRadius = $$.getRadius(d).innerRadius;
16285
- return hasMultiArcGauge ?
16286
- state.radius - singleArcWidth * (d.index + 1) :
16287
- isNumber(innerRadius) ? innerRadius : 0;
16288
- })
16289
- .outerRadius(function (d) {
16290
- var outerRadius = $$.getRadius(d).outerRadius;
16291
- var radius = outerRadius;
16292
- if (hasMultiArcGauge) {
16293
- radius = state.radius - singleArcWidth * d.index;
16294
- }
16295
- else if (hasPolar) {
16296
- radius = $$.getPolarOuterRadius(d, outerRadius);
16297
- }
16298
- return radius;
16299
- });
16526
+ .innerRadius(inner)
16527
+ .outerRadius(outer);
16300
16528
  var newArc = function (d, withoutUpdate) {
16529
+ var _a;
16301
16530
  var path = "M 0 0";
16302
16531
  if (d.value || d.data) {
16303
- var updated = !withoutUpdate && $$.updateAngle(d);
16304
- if (withoutUpdate) {
16305
- path = arc$1(d);
16306
- }
16307
- else if (updated) {
16308
- path = arc$1(updated);
16532
+ var data = withoutUpdate ? d : (_a = $$.updateAngle(d)) !== null && _a !== void 0 ? _a : null;
16533
+ if (data) {
16534
+ path = arc$1.cornerRadius(corner(data, outer(data)))(data);
16309
16535
  }
16310
16536
  }
16311
16537
  return path;
@@ -16314,34 +16540,27 @@ var shapeArc = {
16314
16540
  newArc.centroid = arc$1.centroid;
16315
16541
  return newArc;
16316
16542
  },
16543
+ /**
16544
+ * Get expanded arc path function
16545
+ * @param {number} rate Expand rate
16546
+ * @returns {Function} Expanded arc path getter function
16547
+ * @private
16548
+ */
16317
16549
  getSvgArcExpanded: function (rate) {
16550
+ if (rate === void 0) { rate = 1; }
16318
16551
  var $$ = this;
16319
- var state = $$.state;
16320
- var newRate = rate || 1;
16321
- var singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
16322
- var hasMultiArcGauge = $$.hasMultiArcGauge();
16323
- var expandWidth = Math.min(state.radiusExpanded * newRate - state.radius, singleArcWidth * 0.8 - (1 - newRate) * 100);
16552
+ var _a = getRadiusFn.call($$, rate), inner = _a.inner, outer = _a.outer, corner = _a.corner;
16324
16553
  var arc$1 = arc()
16325
- .innerRadius(function (d) { return (hasMultiArcGauge ?
16326
- state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius); })
16327
- .outerRadius(function (d) {
16328
- var radius;
16329
- if (hasMultiArcGauge) {
16330
- radius = state.radius - singleArcWidth * d.index + expandWidth;
16331
- }
16332
- else {
16333
- var outerRadius = $$.getRadius(d).outerRadius;
16334
- var radiusExpanded = state.radiusExpanded;
16335
- if (state.radius !== outerRadius) {
16336
- radiusExpanded -= Math.abs(state.radius - outerRadius);
16337
- }
16338
- radius = radiusExpanded * newRate;
16339
- }
16340
- return radius;
16341
- });
16554
+ .innerRadius(inner)
16555
+ .outerRadius(outer);
16342
16556
  return function (d) {
16343
16557
  var updated = $$.updateAngle(d);
16344
- return updated ? arc$1(updated) : "M 0 0";
16558
+ var outerR = outer(updated);
16559
+ var cornerR = 0;
16560
+ if (updated) {
16561
+ cornerR = corner(updated, outerR);
16562
+ }
16563
+ return updated ? arc$1.cornerRadius(cornerR)(updated) : "M 0 0";
16345
16564
  };
16346
16565
  },
16347
16566
  getArc: function (d, withoutUpdate, force) {
@@ -16390,7 +16609,7 @@ var shapeArc = {
16390
16609
  },
16391
16610
  convertToArcData: function (d) {
16392
16611
  return this.addName({
16393
- id: d.data ? d.data.id : d.id,
16612
+ id: "data" in d ? d.data.id : d.id,
16394
16613
  value: d.value,
16395
16614
  ratio: this.getRatio("arc", d),
16396
16615
  index: d.index
@@ -16445,10 +16664,10 @@ var shapeArc = {
16445
16664
  select(this).selectAll("path")
16446
16665
  .transition()
16447
16666
  .duration(expandDuration)
16448
- .attr("d", $$.svgArcExpanded)
16667
+ .attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$)))
16449
16668
  .transition()
16450
16669
  .duration(expandDuration * 2)
16451
- .attr("d", svgArcExpandedSub);
16670
+ .attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
16452
16671
  });
16453
16672
  },
16454
16673
  unexpandArc: function (targetIds) {
@@ -16462,7 +16681,7 @@ var shapeArc = {
16462
16681
  .selectAll("path")
16463
16682
  .transition()
16464
16683
  .duration(function (d) { return $$.getExpandConfig(d.data.id, "duration"); })
16465
- .attr("d", $$.svgArc);
16684
+ .attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
16466
16685
  svg.selectAll("".concat($ARC.arc))
16467
16686
  .style("opacity", null);
16468
16687
  },
@@ -16887,6 +17106,8 @@ var shapeArea = {
16887
17106
  })
16888
17107
  .merge(area);
16889
17108
  area.style("opacity", state.orgAreaOpacity);
17109
+ // calculate ratio if grouped data exists
17110
+ $$.setRatioForGroupedData($root.area.data());
16890
17111
  },
16891
17112
  /**
16892
17113
  * Redraw function
@@ -17056,6 +17277,8 @@ var shapeBar = {
17056
17277
  .style("fill", $$.updateBarColor.bind($$))
17057
17278
  .merge(bar)
17058
17279
  .style("opacity", initialOpacity);
17280
+ // calculate ratio if grouped data exists
17281
+ $$.setRatioForGroupedData($root.bar.data());
17059
17282
  },
17060
17283
  /**
17061
17284
  * Update bar color
@@ -17758,22 +17981,12 @@ var shapeLine = {
17758
17981
  var config = $$.config;
17759
17982
  var isRotated = config.axis_rotated;
17760
17983
  var isTimeSeries = $$.axis.isTimeSeries();
17761
- var xOffset = $$.axis.isCategorized() ? 0.5 : 0;
17762
17984
  var regions = [];
17763
17985
  var dasharray = "2 2"; // default value
17764
17986
  var xp;
17765
17987
  var yp;
17766
17988
  var diff;
17767
17989
  var diffx2;
17768
- // check weather data is within region
17769
- var isWithinRegions = function (withinX, withinRegions) {
17770
- for (var i = 0, reg = void 0; (reg = withinRegions[i]); i++) {
17771
- if (reg.start < withinX && withinX <= reg.end) {
17772
- return reg.style;
17773
- }
17774
- }
17775
- return false;
17776
- };
17777
17990
  // Check start/end of regions
17778
17991
  if (isDefined(_regions)) {
17779
17992
  var getValue = function (v, def) { return (isUndefined(v) ? def : (isTimeSeries ? parseDate.call($$, v) : v)); };
@@ -17810,7 +18023,7 @@ var shapeLine = {
17810
18023
  for (var i = 0, data = void 0; (data = d[i]); i++) {
17811
18024
  var prevData = d[i - 1];
17812
18025
  var hasPrevData = prevData && isValue(prevData.value);
17813
- var style = isWithinRegions(data.x, regions);
18026
+ var style = $$.isWithinRegions(data.x, regions);
17814
18027
  // https://github.com/naver/billboard.js/issues/1172
17815
18028
  if (!isValue(data.value)) {
17816
18029
  continue;
@@ -17827,7 +18040,7 @@ var shapeLine = {
17827
18040
  style = dasharray.split(" ");
17828
18041
  }
17829
18042
  // Draw with region // TODO: Fix for horizotal charts
17830
- xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
18043
+ xp = getScale(axisType.x, prevData.x, data.x);
17831
18044
  yp = getScale(axisType.y, prevData.value, data.value);
17832
18045
  var dx = x(data.x) - x(prevData.x);
17833
18046
  var dy = y(data.value) - y(prevData.value);
@@ -17845,6 +18058,14 @@ var shapeLine = {
17845
18058
  }
17846
18059
  return path;
17847
18060
  },
18061
+ isWithinRegions: function (withinX, withinRegions) {
18062
+ for (var i = 0, reg = void 0; (reg = withinRegions[i]); i++) {
18063
+ if (reg.start < withinX && withinX <= reg.end) {
18064
+ return reg.style;
18065
+ }
18066
+ }
18067
+ return false;
18068
+ },
17848
18069
  isWithinStep: function (that, y) {
17849
18070
  return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
17850
18071
  },
@@ -19285,6 +19506,52 @@ var optSpline = {
19285
19506
  spline_interpolation_type: "cardinal"
19286
19507
  };
19287
19508
 
19509
+ /**
19510
+ * Copyright (c) 2017 ~ present NAVER Corp.
19511
+ * billboard.js project is licensed under the MIT license
19512
+ */
19513
+ /**
19514
+ * area config options
19515
+ */
19516
+ var optArc = {
19517
+ /**
19518
+ * Set arc options
19519
+ * @name arc
19520
+ * @memberof Options
19521
+ * @type {object}
19522
+ * @property {object} arc Arc object
19523
+ * @property {number|Function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
19524
+ * - **NOTE:**
19525
+ * - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
19526
+ * @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
19527
+ * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
19528
+ * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
19529
+ * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
19530
+ * @example
19531
+ * arc: {
19532
+ * cornerRadius: 12,
19533
+ *
19534
+ * // can customize corner radius for each data with function callback
19535
+ * //
19536
+ * // The function will receive:
19537
+ * // - id {string}: Data id
19538
+ * // - value {number}: Data value
19539
+ * // - outerRadius {number}: Outer radius value
19540
+ * cornerRadius: function(id, value, outerRadius) {
19541
+ * return (id === "data1" && value > 10) ?
19542
+ * 50 : outerRadius * 1.2;
19543
+ * },
19544
+ *
19545
+ * // set ratio relative of outer radius
19546
+ * cornerRadius: {
19547
+ * ratio: 0.5
19548
+ * }
19549
+ * }
19550
+ */
19551
+ arc_cornerRadius: 0,
19552
+ arc_cornerRadius_ratio: 0
19553
+ };
19554
+
19288
19555
  /**
19289
19556
  * Copyright (c) 2017 ~ present NAVER Corp.
19290
19557
  * billboard.js project is licensed under the MIT license
@@ -19408,7 +19675,7 @@ var optGauge = {
19408
19675
  * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
19409
19676
  * - `startingAngle > Math.PI` defaults to `Math.PI`
19410
19677
  * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
19411
- * Negative value will draw the arc **counterclockwise**.
19678
+ * Negative value will draw the arc **counterclockwise**. Need to be used in conjunction with `gauge.fullCircle=true`.
19412
19679
  *
19413
19680
  * **Limitations:**
19414
19681
  * - -100 <= arcLength (in percent) <= 100
@@ -19421,7 +19688,7 @@ var optGauge = {
19421
19688
  * **Available Values:**
19422
19689
  * - single
19423
19690
  * - multi
19424
- * @property {string} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
19691
+ * @property {number} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
19425
19692
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
19426
19693
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
19427
19694
  * @example
@@ -19794,10 +20061,10 @@ var line = function () { return (extendLine(), (line = function () { return TYPE
19794
20061
  var spline = function () { return (extendLine(undefined, [optSpline]), (spline = function () { return TYPE.SPLINE; })()); };
19795
20062
  var step = function () { return (extendLine(), (step = function () { return TYPE.STEP; })()); };
19796
20063
  // Arc types
19797
- var donut = function () { return (extendArc(undefined, [optDonut]), (donut = function () { return TYPE.DONUT; })()); };
19798
- var gauge = function () { return (extendArc([shapeGauge], [optGauge]), (gauge = function () { return TYPE.GAUGE; })()); };
19799
- var pie = function () { return (extendArc(undefined, [optPie]), (pie = function () { return TYPE.PIE; })()); };
19800
- var polar = function () { return (extendArc([shapePolar], [optPolar]), (polar = function () { return TYPE.POLAR; })()); };
20064
+ var donut = function () { return (extendArc(undefined, [optArc, optDonut]), (donut = function () { return TYPE.DONUT; })()); };
20065
+ var gauge = function () { return (extendArc([shapeGauge], [optArc, optGauge]), (gauge = function () { return TYPE.GAUGE; })()); };
20066
+ var pie = function () { return (extendArc(undefined, [optArc, optPie]), (pie = function () { return TYPE.PIE; })()); };
20067
+ var polar = function () { return (extendArc([shapePolar], [optArc, optPolar]), (polar = function () { return TYPE.POLAR; })()); };
19801
20068
  var radar = function () { return (extendArc([shapePoint, shapeRadar], [optPoint, optRadar]), (radar = function () { return TYPE.RADAR; })()); };
19802
20069
  // Axis based types
19803
20070
  var bar = function () { return (extendAxis([shapeBar], optBar), (bar = function () { return TYPE.BAR; })()); };
@@ -21442,7 +21709,7 @@ var zoomModule = function () {
21442
21709
  var defaults = {};
21443
21710
  /**
21444
21711
  * @namespace bb
21445
- * @version 3.6.2
21712
+ * @version 3.7.0-next.1
21446
21713
  */
21447
21714
  var bb = {
21448
21715
  /**
@@ -21452,7 +21719,7 @@ var bb = {
21452
21719
  * bb.version; // "1.0.0"
21453
21720
  * @memberof bb
21454
21721
  */
21455
- version: "3.6.2",
21722
+ version: "3.7.0-next.1",
21456
21723
  /**
21457
21724
  * Generate chart
21458
21725
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: