billboard.js 3.6.3 → 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 (55) hide show
  1. package/dist/billboard.css +1 -1
  2. package/dist/billboard.js +524 -160
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +1660 -1227
  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 +875 -880
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +908 -881
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +908 -881
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +908 -881
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +908 -881
  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 +369 -101
  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/data/IData.ts +1 -0
  39. package/src/ChartInternal/data/data.ts +21 -2
  40. package/src/ChartInternal/internals/domain.ts +11 -4
  41. package/src/ChartInternal/internals/format.ts +1 -1
  42. package/src/ChartInternal/internals/grid.ts +1 -1
  43. package/src/ChartInternal/shape/arc.ts +145 -68
  44. package/src/ChartInternal/shape/area.ts +3 -0
  45. package/src/ChartInternal/shape/bar.ts +3 -0
  46. package/src/ChartInternal/shape/line.ts +12 -15
  47. package/src/config/Options/common/tooltip.ts +11 -8
  48. package/src/config/Options/shape/arc.ts +47 -0
  49. package/src/config/Options/shape/gauge.ts +2 -2
  50. package/src/config/resolver/shape.ts +13 -4
  51. package/src/module/util.ts +1 -1
  52. package/types/chart.d.ts +7 -0
  53. package/types/options.d.ts +39 -624
  54. package/types/options.shape.d.ts +633 -0
  55. 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.3
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
  }
@@ -5256,10 +5276,8 @@ var domain = {
5256
5276
  return $$.hasType(v, yTargets, true) && config["".concat(type, "_zerobased")];
5257
5277
  });
5258
5278
  // MEMO: avoid inverting domain unexpectedly
5259
- yDomainMin = isValue(yMin) ? yMin :
5260
- (isValue(yMax) ? (yDomainMin < yMax ? yDomainMin : yMax - 10) : yDomainMin);
5261
- yDomainMax = isValue(yMax) ? yMax :
5262
- (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);
5263
5281
  if (isNaN(yDomainMin)) { // set minimum to zero when not number
5264
5282
  yDomainMin = 0;
5265
5283
  }
@@ -5506,7 +5524,7 @@ function getFormat($$, typeValue, v) {
5506
5524
  var type = "axis_".concat(typeValue, "_tick_format");
5507
5525
  var format = config[type] ?
5508
5526
  config[type] : $$.defaultValueFormat;
5509
- return format(v);
5527
+ return format.call($$.api, v);
5510
5528
  }
5511
5529
  var format = {
5512
5530
  yFormat: function (v) {
@@ -9540,8 +9558,9 @@ var apiChart = {
9540
9558
  },
9541
9559
  /**
9542
9560
  * Get or set config option value.
9543
- * - **NOTE:** for without parameter occasion
9544
- * - 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)
9545
9564
  * @function config
9546
9565
  * @instance
9547
9566
  * @memberof Chart
@@ -9555,12 +9574,20 @@ var apiChart = {
9555
9574
  * // Getter
9556
9575
  * chart.config("gauge.max");
9557
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
+ *
9558
9581
  * // without any arguments, it returns generation config object
9559
9582
  * chart.config(); // {data: { ... }, axis: { ... }, ...}
9560
9583
  *
9561
9584
  * // Setter
9562
9585
  * chart.config("gauge.max", 100);
9563
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
+ *
9564
9591
  * // Setter & redraw with the new option
9565
9592
  * chart.config("gauge.max", 100, true);
9566
9593
  */
@@ -9579,7 +9606,7 @@ var apiChart = {
9579
9606
  res = config[key];
9580
9607
  }
9581
9608
  }
9582
- else {
9609
+ else if (arguments.length === 0 || isEmpty(name)) {
9583
9610
  res = state.orgConfig;
9584
9611
  }
9585
9612
  return res;
@@ -9789,8 +9816,11 @@ var apiData = { data: data };
9789
9816
  * @private
9790
9817
  * @see https://developer.mozilla.org/ko/docs/Web/API/WindowBase64/Base64_encoding_and_decoding
9791
9818
  */
9792
- var b64EncodeUnicode = function (str) { return btoa(encodeURIComponent(str)
9793
- .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
+ };
9794
9824
  /**
9795
9825
  * Convert svg node to data url
9796
9826
  * @param {HTMLElement} node target node
@@ -9807,6 +9837,15 @@ function nodeToSvgDataUrl(node, option, orgSize) {
9807
9837
  .filter(function (r) { return r.cssText; })
9808
9838
  .map(function (r) { return r.cssText; });
9809
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
+ }
9810
9849
  var nodeXml = serializer.serializeToString(clone);
9811
9850
  // escape css for XML
9812
9851
  var style = doc.createElement("style");
@@ -9818,12 +9857,113 @@ function nodeToSvgDataUrl(node, option, orgSize) {
9818
9857
  .replace("/\n/g", "%0A");
9819
9858
  return "data:image/svg+xml;base64,".concat(b64EncodeUnicode(dataStr));
9820
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
+ }
9821
9961
  var apiExport = {
9822
9962
  /**
9823
9963
  * Export chart as an image.
9824
9964
  * - **NOTE:**
9825
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
9826
- * - 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.
9827
9967
  * @function export
9828
9968
  * @instance
9829
9969
  * @memberof Chart
@@ -9832,6 +9972,12 @@ var apiExport = {
9832
9972
  * @param {number} [option.width={currentWidth}] width
9833
9973
  * @param {number} [option.height={currentHeigth}] height
9834
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>
9835
9981
  * @param {Function} [callback] The callback to be invoked when export is ready.
9836
9982
  * @returns {string} dataURI
9837
9983
  * @example
@@ -9855,6 +10001,7 @@ var apiExport = {
9855
10001
  * width: 800,
9856
10002
  * height: 600,
9857
10003
  * preserveAspectRatio: false,
10004
+ * preserveFontStyle: false,
9858
10005
  * mimeType: "image/png"
9859
10006
  * },
9860
10007
  * dataUrl => { ... }
@@ -9863,15 +10010,17 @@ var apiExport = {
9863
10010
  "export": function (option, callback) {
9864
10011
  var _this = this;
9865
10012
  var $$ = this.internal;
9866
- var state = $$.state, chart = $$.$el.chart;
9867
- 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;
9868
10015
  var opt = mergeObj({
9869
10016
  width: width,
9870
10017
  height: height,
9871
10018
  preserveAspectRatio: true,
10019
+ preserveFontStyle: false,
9872
10020
  mimeType: "image/png"
9873
10021
  }, option);
9874
10022
  var svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, { width: width, height: height });
10023
+ var glyph = opt.preserveFontStyle ? getGlyph(svg.node()) : [];
9875
10024
  if (callback && isFunction(callback)) {
9876
10025
  var img_1 = new Image();
9877
10026
  img_1.crossOrigin = "Anonymous";
@@ -9881,6 +10030,11 @@ var apiExport = {
9881
10030
  canvas.width = opt.width || width;
9882
10031
  canvas.height = opt.height || height;
9883
10032
  ctx.drawImage(img_1, 0, 0);
10033
+ if (glyph.length) {
10034
+ renderText(ctx, glyph);
10035
+ // release glyph array
10036
+ glyph.length = 0;
10037
+ }
9884
10038
  callback.bind(_this)(canvas.toDataURL(opt.mimeType));
9885
10039
  };
9886
10040
  img_1.src = svgDataUrl;
@@ -12516,7 +12670,7 @@ var Axis = /** @class */ (function () {
12516
12670
  var config = $$.config, current = $$.state.current, _a = $$.$el, svg = _a.svg, chart = _a.chart;
12517
12671
  var currentTickMax = current.maxTickWidths[id];
12518
12672
  var maxWidth = 0;
12519
- if (withoutRecompute || !config["axis_".concat(id, "_show")] || $$.filterTargetsToShow().length === 0) {
12673
+ if (withoutRecompute || !config["axis_".concat(id, "_show")] || (currentTickMax.size > 0 && $$.filterTargetsToShow().length === 0)) {
12520
12674
  return currentTickMax.size;
12521
12675
  }
12522
12676
  if (svg) {
@@ -13780,7 +13934,7 @@ var grid = {
13780
13934
  xgridLine.append("line")
13781
13935
  .style("opacity", "0");
13782
13936
  xgridLine.append("text")
13783
- .attr("transform", isRotated ? "" : "rotate(-90)")
13937
+ .attr("transform", isRotated ? null : "rotate(-90)")
13784
13938
  .attr("dy", -5)
13785
13939
  .style("opacity", "0");
13786
13940
  xLines = xgridLine.merge(xLines);
@@ -16132,6 +16286,99 @@ var options = [
16132
16286
  * Copyright (c) 2017 ~ present NAVER Corp.
16133
16287
  * billboard.js project is licensed under the MIT license
16134
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
+ }
16135
16382
  var shapeArc = {
16136
16383
  initPie: function () {
16137
16384
  var $$ = this;
@@ -16274,37 +16521,17 @@ var shapeArc = {
16274
16521
  },
16275
16522
  getSvgArc: function () {
16276
16523
  var $$ = this;
16277
- var state = $$.state;
16278
- var singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
16279
- var hasMultiArcGauge = $$.hasMultiArcGauge();
16280
- var hasPolar = $$.hasType("polar");
16524
+ var _a = getRadiusFn.call($$), inner = _a.inner, outer = _a.outer, corner = _a.corner;
16281
16525
  var arc$1 = arc()
16282
- .innerRadius(function (d) {
16283
- var innerRadius = $$.getRadius(d).innerRadius;
16284
- return hasMultiArcGauge ?
16285
- state.radius - singleArcWidth * (d.index + 1) :
16286
- isNumber(innerRadius) ? innerRadius : 0;
16287
- })
16288
- .outerRadius(function (d) {
16289
- var outerRadius = $$.getRadius(d).outerRadius;
16290
- var radius = outerRadius;
16291
- if (hasMultiArcGauge) {
16292
- radius = state.radius - singleArcWidth * d.index;
16293
- }
16294
- else if (hasPolar) {
16295
- radius = $$.getPolarOuterRadius(d, outerRadius);
16296
- }
16297
- return radius;
16298
- });
16526
+ .innerRadius(inner)
16527
+ .outerRadius(outer);
16299
16528
  var newArc = function (d, withoutUpdate) {
16529
+ var _a;
16300
16530
  var path = "M 0 0";
16301
16531
  if (d.value || d.data) {
16302
- var updated = !withoutUpdate && $$.updateAngle(d);
16303
- if (withoutUpdate) {
16304
- path = arc$1(d);
16305
- }
16306
- else if (updated) {
16307
- 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);
16308
16535
  }
16309
16536
  }
16310
16537
  return path;
@@ -16313,34 +16540,27 @@ var shapeArc = {
16313
16540
  newArc.centroid = arc$1.centroid;
16314
16541
  return newArc;
16315
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
+ */
16316
16549
  getSvgArcExpanded: function (rate) {
16550
+ if (rate === void 0) { rate = 1; }
16317
16551
  var $$ = this;
16318
- var state = $$.state;
16319
- var newRate = rate || 1;
16320
- var singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
16321
- var hasMultiArcGauge = $$.hasMultiArcGauge();
16322
- 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;
16323
16553
  var arc$1 = arc()
16324
- .innerRadius(function (d) { return (hasMultiArcGauge ?
16325
- state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius); })
16326
- .outerRadius(function (d) {
16327
- var radius;
16328
- if (hasMultiArcGauge) {
16329
- radius = state.radius - singleArcWidth * d.index + expandWidth;
16330
- }
16331
- else {
16332
- var outerRadius = $$.getRadius(d).outerRadius;
16333
- var radiusExpanded = state.radiusExpanded;
16334
- if (state.radius !== outerRadius) {
16335
- radiusExpanded -= Math.abs(state.radius - outerRadius);
16336
- }
16337
- radius = radiusExpanded * newRate;
16338
- }
16339
- return radius;
16340
- });
16554
+ .innerRadius(inner)
16555
+ .outerRadius(outer);
16341
16556
  return function (d) {
16342
16557
  var updated = $$.updateAngle(d);
16343
- 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";
16344
16564
  };
16345
16565
  },
16346
16566
  getArc: function (d, withoutUpdate, force) {
@@ -16389,7 +16609,7 @@ var shapeArc = {
16389
16609
  },
16390
16610
  convertToArcData: function (d) {
16391
16611
  return this.addName({
16392
- id: d.data ? d.data.id : d.id,
16612
+ id: "data" in d ? d.data.id : d.id,
16393
16613
  value: d.value,
16394
16614
  ratio: this.getRatio("arc", d),
16395
16615
  index: d.index
@@ -16444,10 +16664,10 @@ var shapeArc = {
16444
16664
  select(this).selectAll("path")
16445
16665
  .transition()
16446
16666
  .duration(expandDuration)
16447
- .attr("d", $$.svgArcExpanded)
16667
+ .attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$)))
16448
16668
  .transition()
16449
16669
  .duration(expandDuration * 2)
16450
- .attr("d", svgArcExpandedSub);
16670
+ .attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
16451
16671
  });
16452
16672
  },
16453
16673
  unexpandArc: function (targetIds) {
@@ -16461,7 +16681,7 @@ var shapeArc = {
16461
16681
  .selectAll("path")
16462
16682
  .transition()
16463
16683
  .duration(function (d) { return $$.getExpandConfig(d.data.id, "duration"); })
16464
- .attr("d", $$.svgArc);
16684
+ .attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
16465
16685
  svg.selectAll("".concat($ARC.arc))
16466
16686
  .style("opacity", null);
16467
16687
  },
@@ -16886,6 +17106,8 @@ var shapeArea = {
16886
17106
  })
16887
17107
  .merge(area);
16888
17108
  area.style("opacity", state.orgAreaOpacity);
17109
+ // calculate ratio if grouped data exists
17110
+ $$.setRatioForGroupedData($root.area.data());
16889
17111
  },
16890
17112
  /**
16891
17113
  * Redraw function
@@ -17055,6 +17277,8 @@ var shapeBar = {
17055
17277
  .style("fill", $$.updateBarColor.bind($$))
17056
17278
  .merge(bar)
17057
17279
  .style("opacity", initialOpacity);
17280
+ // calculate ratio if grouped data exists
17281
+ $$.setRatioForGroupedData($root.bar.data());
17058
17282
  },
17059
17283
  /**
17060
17284
  * Update bar color
@@ -17757,22 +17981,12 @@ var shapeLine = {
17757
17981
  var config = $$.config;
17758
17982
  var isRotated = config.axis_rotated;
17759
17983
  var isTimeSeries = $$.axis.isTimeSeries();
17760
- var xOffset = $$.axis.isCategorized() ? 0.5 : 0;
17761
17984
  var regions = [];
17762
17985
  var dasharray = "2 2"; // default value
17763
17986
  var xp;
17764
17987
  var yp;
17765
17988
  var diff;
17766
17989
  var diffx2;
17767
- // check weather data is within region
17768
- var isWithinRegions = function (withinX, withinRegions) {
17769
- for (var i = 0, reg = void 0; (reg = withinRegions[i]); i++) {
17770
- if (reg.start < withinX && withinX <= reg.end) {
17771
- return reg.style;
17772
- }
17773
- }
17774
- return false;
17775
- };
17776
17990
  // Check start/end of regions
17777
17991
  if (isDefined(_regions)) {
17778
17992
  var getValue = function (v, def) { return (isUndefined(v) ? def : (isTimeSeries ? parseDate.call($$, v) : v)); };
@@ -17809,7 +18023,7 @@ var shapeLine = {
17809
18023
  for (var i = 0, data = void 0; (data = d[i]); i++) {
17810
18024
  var prevData = d[i - 1];
17811
18025
  var hasPrevData = prevData && isValue(prevData.value);
17812
- var style = isWithinRegions(data.x, regions);
18026
+ var style = $$.isWithinRegions(data.x, regions);
17813
18027
  // https://github.com/naver/billboard.js/issues/1172
17814
18028
  if (!isValue(data.value)) {
17815
18029
  continue;
@@ -17826,7 +18040,7 @@ var shapeLine = {
17826
18040
  style = dasharray.split(" ");
17827
18041
  }
17828
18042
  // Draw with region // TODO: Fix for horizotal charts
17829
- xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
18043
+ xp = getScale(axisType.x, prevData.x, data.x);
17830
18044
  yp = getScale(axisType.y, prevData.value, data.value);
17831
18045
  var dx = x(data.x) - x(prevData.x);
17832
18046
  var dy = y(data.value) - y(prevData.value);
@@ -17844,6 +18058,14 @@ var shapeLine = {
17844
18058
  }
17845
18059
  return path;
17846
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
+ },
17847
18069
  isWithinStep: function (that, y) {
17848
18070
  return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
17849
18071
  },
@@ -19284,6 +19506,52 @@ var optSpline = {
19284
19506
  spline_interpolation_type: "cardinal"
19285
19507
  };
19286
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
+
19287
19555
  /**
19288
19556
  * Copyright (c) 2017 ~ present NAVER Corp.
19289
19557
  * billboard.js project is licensed under the MIT license
@@ -19407,7 +19675,7 @@ var optGauge = {
19407
19675
  * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
19408
19676
  * - `startingAngle > Math.PI` defaults to `Math.PI`
19409
19677
  * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
19410
- * 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`.
19411
19679
  *
19412
19680
  * **Limitations:**
19413
19681
  * - -100 <= arcLength (in percent) <= 100
@@ -19420,7 +19688,7 @@ var optGauge = {
19420
19688
  * **Available Values:**
19421
19689
  * - single
19422
19690
  * - multi
19423
- * @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.
19424
19692
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
19425
19693
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
19426
19694
  * @example
@@ -19793,10 +20061,10 @@ var line = function () { return (extendLine(), (line = function () { return TYPE
19793
20061
  var spline = function () { return (extendLine(undefined, [optSpline]), (spline = function () { return TYPE.SPLINE; })()); };
19794
20062
  var step = function () { return (extendLine(), (step = function () { return TYPE.STEP; })()); };
19795
20063
  // Arc types
19796
- var donut = function () { return (extendArc(undefined, [optDonut]), (donut = function () { return TYPE.DONUT; })()); };
19797
- var gauge = function () { return (extendArc([shapeGauge], [optGauge]), (gauge = function () { return TYPE.GAUGE; })()); };
19798
- var pie = function () { return (extendArc(undefined, [optPie]), (pie = function () { return TYPE.PIE; })()); };
19799
- 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; })()); };
19800
20068
  var radar = function () { return (extendArc([shapePoint, shapeRadar], [optPoint, optRadar]), (radar = function () { return TYPE.RADAR; })()); };
19801
20069
  // Axis based types
19802
20070
  var bar = function () { return (extendAxis([shapeBar], optBar), (bar = function () { return TYPE.BAR; })()); };
@@ -21441,7 +21709,7 @@ var zoomModule = function () {
21441
21709
  var defaults = {};
21442
21710
  /**
21443
21711
  * @namespace bb
21444
- * @version 3.6.3
21712
+ * @version 3.7.0-next.1
21445
21713
  */
21446
21714
  var bb = {
21447
21715
  /**
@@ -21451,7 +21719,7 @@ var bb = {
21451
21719
  * bb.version; // "1.0.0"
21452
21720
  * @memberof bb
21453
21721
  */
21454
- version: "3.6.3",
21722
+ version: "3.7.0-next.1",
21455
21723
  /**
21456
21724
  * Generate chart
21457
21725
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: