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
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.6.3
8
+ * @version 3.7.0-next.1
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -305,8 +305,39 @@ var TYPE_BY_CATEGORY = {
305
305
  Step: [TYPE.STEP, TYPE.AREA_STEP],
306
306
  Spline: [TYPE.SPLINE, TYPE.AREA_SPLINE, TYPE.AREA_SPLINE_RANGE]
307
307
  };
308
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
309
+ function _typeof(obj) {
310
+ "@babel/helpers - typeof";
311
+
312
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
313
+ return typeof obj;
314
+ } : function (obj) {
315
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
316
+ }, _typeof(obj);
317
+ }
318
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPrimitive.js
319
+
320
+ function _toPrimitive(input, hint) {
321
+ if (_typeof(input) !== "object" || input === null) return input;
322
+ var prim = input[Symbol.toPrimitive];
323
+ if (prim !== undefined) {
324
+ var res = prim.call(input, hint || "default");
325
+ if (_typeof(res) !== "object") return res;
326
+ throw new TypeError("@@toPrimitive must return a primitive value.");
327
+ }
328
+ return (hint === "string" ? String : Number)(input);
329
+ }
330
+ ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
331
+
332
+
333
+ function _toPropertyKey(arg) {
334
+ var key = _toPrimitive(arg, "string");
335
+ return _typeof(key) === "symbol" ? key : String(key);
336
+ }
308
337
  ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
338
+
309
339
  function _defineProperty(obj, key, value) {
340
+ key = _toPropertyKey(key);
310
341
  if (key in obj) {
311
342
  Object.defineProperty(obj, key, {
312
343
  value: value,
@@ -833,7 +864,8 @@ function getCssRules(styleSheets) {
833
864
  rules = rules.concat(toArray(sheet.cssRules));
834
865
  }
835
866
  } catch (e) {
836
- console.error("Error while reading rules from " + sheet.href + ": " + e.toString());
867
+ var _window$console;
868
+ (_window$console = win.console) == null ? void 0 : _window$console.warn("Error while reading rules from " + sheet.href + ": " + e.toString());
837
869
  }
838
870
  }.bind(this));
839
871
  return rules;
@@ -3247,17 +3279,20 @@ var tooltip_this = undefined;
3247
3279
  * Specified function receives x of the data point to show.
3248
3280
  * @property {Function} [tooltip.format.name] Set format for the name of each data in tooltip.<br>
3249
3281
  * 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.
3250
- * @property {Function} [tooltip.format.value] Set format for the value of each data in tooltip.<br>
3251
- * 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.
3252
- * If undefined returned, the row of that value will be skipped.
3282
+ * @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.
3283
+ * - Will pass following arguments to the given function:
3284
+ * - `value {string}`: Value of the data point
3285
+ * - `ratio {number}`: Ratio of the data point in the `pie/donut/gauge` and `area/bar` when contains grouped data. Otherwise is `undefined`.
3286
+ * - `id {string}`: id of the data point
3287
+ * - `index {number}`: Index of the data point
3253
3288
  * @property {Function} [tooltip.position] Set custom position function for the tooltip.<br>
3254
3289
  * This option can be used to modify the tooltip position by returning object that has top and left.
3255
3290
  * - Will pass following arguments to the given function:
3256
- * - `data {Array}`: Current selected data array object.
3257
- * - `width {number}`: Width of tooltip.
3258
- * - `height {number}`: Height of tooltip.
3259
- * - `element {SVGElement}`: Tooltip event bound element
3260
- * - `pos {object}`: Current position of the tooltip.
3291
+ * - `data {Array}`: Current selected data array object.
3292
+ * - `width {number}`: Width of tooltip.
3293
+ * - `height {number}`: Height of tooltip.
3294
+ * - `element {SVGElement}`: Tooltip event bound element
3295
+ * - `pos {object}`: Current position of the tooltip.
3261
3296
  * @property {Function|object} [tooltip.contents] Set custom HTML for the tooltip.<br>
3262
3297
  * If tooltip.grouped is true, data includes multiple data points.<br><br>
3263
3298
  * Specified function receives `data` array and `defaultTitleFormat`, `defaultValueFormat` and `color` functions of the data point to show.
@@ -4513,7 +4548,7 @@ function getDataKeyForJson(keysParam, config) {
4513
4548
  $$ = this,
4514
4549
  cacheKey = KEY.dataTotalPerIndex,
4515
4550
  sum = $$.cache.get(cacheKey);
4516
- if ($$.isStackNormalized() && !sum) {
4551
+ if (($$.config.data_groups.length || $$.isStackNormalized()) && !sum) {
4517
4552
  sum = [];
4518
4553
  $$.data.targets.forEach(function (row) {
4519
4554
  var _this13 = this;
@@ -5105,6 +5140,30 @@ function getDataKeyForJson(keysParam, config) {
5105
5140
  }
5106
5141
  return value;
5107
5142
  },
5143
+ /**
5144
+ * Set ratio for grouped data
5145
+ * @param {Array} data Data array
5146
+ * @private
5147
+ */
5148
+ setRatioForGroupedData: function setRatioForGroupedData(data) {
5149
+ var _this39 = this,
5150
+ $$ = this,
5151
+ config = $$.config;
5152
+ // calculate ratio if grouped data exists
5153
+ if (config.data_groups.length && data.some(function (d) {
5154
+ _newArrowCheck(this, _this39);
5155
+ return $$.isGrouped(d.id);
5156
+ }.bind(this))) {
5157
+ var setter = function (d) {
5158
+ _newArrowCheck(this, _this39);
5159
+ return $$.getRatio("index", d, !0);
5160
+ }.bind(this);
5161
+ data.forEach(function (v) {
5162
+ _newArrowCheck(this, _this39);
5163
+ "values" in v ? v.values.forEach(setter) : setter(v);
5164
+ }.bind(this));
5165
+ }
5166
+ },
5108
5167
  /**
5109
5168
  * Get ratio value
5110
5169
  * @param {string} type Ratio for given type
@@ -5114,7 +5173,7 @@ function getDataKeyForJson(keysParam, config) {
5114
5173
  * @private
5115
5174
  */
5116
5175
  getRatio: function getRatio(type, d, asPercent) {
5117
- var _this39 = this;
5176
+ var _this40 = this;
5118
5177
  if (asPercent === void 0) {
5119
5178
  asPercent = !1;
5120
5179
  }
@@ -5143,27 +5202,27 @@ function getDataKeyForJson(keysParam, config) {
5143
5202
  var hiddenSum = dataValues(state.hiddenTargetIds, !1);
5144
5203
  if (hiddenSum.length) {
5145
5204
  hiddenSum = hiddenSum.reduce(function (acc, curr) {
5146
- var _this40 = this;
5147
- _newArrowCheck(this, _this39);
5205
+ var _this41 = this;
5206
+ _newArrowCheck(this, _this40);
5148
5207
  return acc.map(function (v, i) {
5149
- _newArrowCheck(this, _this40);
5208
+ _newArrowCheck(this, _this41);
5150
5209
  return (isNumber(v) ? v : 0) + curr[i];
5151
5210
  }.bind(this));
5152
5211
  }.bind(this));
5153
5212
  total = total.map(function (v, i) {
5154
- _newArrowCheck(this, _this39);
5213
+ _newArrowCheck(this, _this40);
5155
5214
  return v - hiddenSum[i];
5156
5215
  }.bind(this));
5157
5216
  }
5158
5217
  }
5159
- d.ratio = isNumber(d.value) && total && total[d.index] > 0 ? d.value / total[d.index] : 0;
5218
+ d.ratio = isNumber(d.value) && total ? d.value / total[d.index] : 0;
5160
5219
  ratio = d.ratio;
5161
5220
  } else if (type === "radar") {
5162
5221
  ratio = parseFloat(Math.max(d.value, 0) + "") / state.current.dataMax * config.radar_size_ratio;
5163
5222
  } else if (type === "bar") {
5164
5223
  var yScale = $$.getYScaleById.bind($$)(d.id),
5165
5224
  _max2 = yScale.domain().reduce(function (a, c) {
5166
- _newArrowCheck(this, _this39);
5225
+ _newArrowCheck(this, _this40);
5167
5226
  return c - a;
5168
5227
  }.bind(this));
5169
5228
  // when all data are 0, return 0
@@ -5178,18 +5237,18 @@ function getDataKeyForJson(keysParam, config) {
5178
5237
  * @private
5179
5238
  */
5180
5239
  updateDataIndexByX: function updateDataIndexByX(tickValues) {
5181
- var _this41 = this,
5240
+ var _this42 = this,
5182
5241
  $$ = this,
5183
5242
  tickValueMap = tickValues.reduce(function (out, tick, index) {
5184
- _newArrowCheck(this, _this41);
5243
+ _newArrowCheck(this, _this42);
5185
5244
  out[+tick.x] = index;
5186
5245
  return out;
5187
5246
  }.bind(this), {});
5188
5247
  $$.data.targets.forEach(function (t) {
5189
- var _this42 = this;
5190
- _newArrowCheck(this, _this41);
5248
+ var _this43 = this;
5249
+ _newArrowCheck(this, _this42);
5191
5250
  t.values.forEach(function (value, valueIndex) {
5192
- _newArrowCheck(this, _this42);
5251
+ _newArrowCheck(this, _this43);
5193
5252
  var index = tickValueMap[+value.x];
5194
5253
  if (index === undefined) {
5195
5254
  index = valueIndex;
@@ -5215,11 +5274,11 @@ function getDataKeyForJson(keysParam, config) {
5215
5274
  * @private
5216
5275
  */
5217
5276
  isBarRangeType: function isBarRangeType(d) {
5218
- var _this43 = this,
5277
+ var _this44 = this,
5219
5278
  $$ = this,
5220
5279
  value = d.value;
5221
5280
  return $$.isBarType(d) && isArray(value) && value.length === 2 && value.every(function (v) {
5222
- _newArrowCheck(this, _this43);
5281
+ _newArrowCheck(this, _this44);
5223
5282
  return isNumber(v);
5224
5283
  }.bind(this));
5225
5284
  },
@@ -6117,8 +6176,8 @@ var schemeCategory10 = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "
6117
6176
  return $$.hasType(v, yTargets, !0) && config[type + "_zerobased"];
6118
6177
  }.bind(this));
6119
6178
  // MEMO: avoid inverting domain unexpectedly
6120
- yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin < yMax ? yDomainMin : yMax - 10 : yDomainMin;
6121
- yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin < yDomainMax ? yDomainMax : yMin + 10 : yDomainMax;
6179
+ yDomainMin = isValue(yMin) ? yMin : isValue(yMax) ? yDomainMin <= yMax ? yDomainMin : yMax - 10 : yDomainMin;
6180
+ yDomainMax = isValue(yMax) ? yMax : isValue(yMin) ? yMin <= yDomainMax ? yDomainMax : yMin + 10 : yDomainMax;
6122
6181
  if (isNaN(yDomainMin)) {
6123
6182
  // set minimum to zero when not number
6124
6183
  yDomainMin = 0;
@@ -6407,7 +6466,7 @@ function getFormat($$, typeValue, v) {
6407
6466
  var config = $$.config,
6408
6467
  type = "axis_" + typeValue + "_tick_format",
6409
6468
  format = config[type] ? config[type] : $$.defaultValueFormat;
6410
- return format(v);
6469
+ return format.call($$.api, v);
6411
6470
  }
6412
6471
  /* harmony default export */ var format = ({
6413
6472
  yFormat: function yFormat(v) {
@@ -10850,8 +10909,9 @@ function loadConfig(config) {
10850
10909
  },
10851
10910
  /**
10852
10911
  * Get or set config option value.
10853
- * - **NOTE:** for without parameter occasion
10854
- * - will return all specified generation options object only. (will exclude any other options not specified at the initialization)
10912
+ * - **NOTE**
10913
+ * - The option key name must be specified as the last level.
10914
+ * - when no argument is given, will return all specified generation options object only. (will exclude any other options not specified at the initialization)
10855
10915
  * @function config
10856
10916
  * @instance
10857
10917
  * @memberof Chart
@@ -10865,12 +10925,20 @@ function loadConfig(config) {
10865
10925
  * // Getter
10866
10926
  * chart.config("gauge.max");
10867
10927
  *
10928
+ * // Getter specified with top level key name will not work.
10929
+ * // The option key name must be specified as the last level.
10930
+ * // chart.config("gauge"); // will not work
10931
+ *
10868
10932
  * // without any arguments, it returns generation config object
10869
10933
  * chart.config(); // {data: { ... }, axis: { ... }, ...}
10870
10934
  *
10871
10935
  * // Setter
10872
10936
  * chart.config("gauge.max", 100);
10873
10937
  *
10938
+ * // Setter specified with top level key name will not work.
10939
+ * // The option key name must be specified as the last level.
10940
+ * // chart.config("gauge", {min: 10, max: 20}); // will not work
10941
+ *
10874
10942
  * // Setter & redraw with the new option
10875
10943
  * chart.config("gauge.max", 100, true);
10876
10944
  */
@@ -10888,7 +10956,7 @@ function loadConfig(config) {
10888
10956
  } else {
10889
10957
  res = config[key];
10890
10958
  }
10891
- } else {
10959
+ } else if (arguments.length === 0 || isEmpty(name)) {
10892
10960
  res = state.orgConfig;
10893
10961
  }
10894
10962
  return res;
@@ -11131,7 +11199,7 @@ var export_this = undefined;
11131
11199
  var b64EncodeUnicode = function (str) {
11132
11200
  var _this2 = this;
11133
11201
  _newArrowCheck(this, export_this);
11134
- return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
11202
+ return win.btoa == null ? void 0 : win.btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p) {
11135
11203
  _newArrowCheck(this, _this2);
11136
11204
  return String.fromCharCode(+("0x" + p));
11137
11205
  }.bind(this)));
@@ -11160,6 +11228,18 @@ function nodeToSvgDataUrl(node, option, orgSize) {
11160
11228
  return r.cssText;
11161
11229
  }.bind(this));
11162
11230
  clone.setAttribute("xmlns", external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.namespaces.xhtml);
11231
+
11232
+ // remove padding & margin
11233
+ clone.style.margin = "0";
11234
+ clone.style.padding = "0";
11235
+
11236
+ // remove text nodes
11237
+ if (option.preserveFontStyle) {
11238
+ clone.querySelectorAll("text").forEach(function (t) {
11239
+ _newArrowCheck(this, _this3);
11240
+ t.innerHTML = "";
11241
+ }.bind(this));
11242
+ }
11163
11243
  var nodeXml = serializer.serializeToString(clone),
11164
11244
  style = browser_doc.createElement("style"); // escape css for XML
11165
11245
  style.appendChild(browser_doc.createTextNode(cssText.join("\n")));
@@ -11168,12 +11248,154 @@ function nodeToSvgDataUrl(node, option, orgSize) {
11168
11248
  // https://msdn.microsoft.com/en-us/library/hh834675(v=vs.85).aspx
11169
11249
  return "data:image/svg+xml;base64," + b64EncodeUnicode(dataStr);
11170
11250
  }
11251
+
11252
+ /**
11253
+ * Get coordinate of the element
11254
+ * @param {SVGElement} elem Target element
11255
+ * @param {object} svgOffset SVG offset
11256
+ * @returns {object}
11257
+ * @private
11258
+ */
11259
+ function getCoords(elem, svgOffset) {
11260
+ var top = svgOffset.top,
11261
+ left = svgOffset.left,
11262
+ _elem$getBBox = elem.getBBox(),
11263
+ x = _elem$getBBox.x,
11264
+ y = _elem$getBBox.y,
11265
+ _elem$getScreenCTM = elem.getScreenCTM(),
11266
+ a = _elem$getScreenCTM.a,
11267
+ b = _elem$getScreenCTM.b,
11268
+ c = _elem$getScreenCTM.c,
11269
+ d = _elem$getScreenCTM.d,
11270
+ e = _elem$getScreenCTM.e,
11271
+ f = _elem$getScreenCTM.f,
11272
+ _elem$getBoundingClie = elem.getBoundingClientRect(),
11273
+ width = _elem$getBoundingClie.width,
11274
+ height = _elem$getBoundingClie.height;
11275
+ return {
11276
+ x: a * x + c * y + e - left,
11277
+ y: b * x + d * y + f - top + (height - Math.round(height / 4)),
11278
+ width: width,
11279
+ height: height
11280
+ };
11281
+ }
11282
+
11283
+ /**
11284
+ * Get text glyph
11285
+ * @param {SVGTextElement} svg Target svg node
11286
+ * @returns {Array}
11287
+ * @private
11288
+ */
11289
+ function getGlyph(svg) {
11290
+ var _this4 = this,
11291
+ _svg$getBoundingClien = svg.getBoundingClientRect(),
11292
+ left = _svg$getBoundingClien.left,
11293
+ top = _svg$getBoundingClien.top,
11294
+ filterFn = function (t) {
11295
+ _newArrowCheck(this, _this4);
11296
+ return t.textContent || t.childElementCount;
11297
+ }.bind(this),
11298
+ glyph = [];
11299
+ toArray(svg.querySelectorAll("text")).filter(filterFn).forEach(function (t) {
11300
+ var _this5 = this;
11301
+ _newArrowCheck(this, _this4);
11302
+ // eslint-disable-line
11303
+ var getStyleFn = function (ts) {
11304
+ var _ref2;
11305
+ _newArrowCheck(this, _this5);
11306
+ var _window$getComputedSt = win.getComputedStyle(ts),
11307
+ fill = _window$getComputedSt.fill,
11308
+ fontFamily = _window$getComputedSt.fontFamily,
11309
+ fontSize = _window$getComputedSt.fontSize,
11310
+ textAnchor = _window$getComputedSt.textAnchor,
11311
+ transform = _window$getComputedSt.transform,
11312
+ _getCoords = getCoords(ts, {
11313
+ left: left,
11314
+ top: top
11315
+ }),
11316
+ x = _getCoords.x,
11317
+ y = _getCoords.y,
11318
+ width = _getCoords.width,
11319
+ height = _getCoords.height;
11320
+ return _ref2 = {}, _ref2[ts.textContent] = {
11321
+ x: x,
11322
+ y: y,
11323
+ width: width,
11324
+ height: height,
11325
+ fill: fill,
11326
+ fontFamily: fontFamily,
11327
+ fontSize: fontSize,
11328
+ textAnchor: textAnchor,
11329
+ transform: transform
11330
+ }, _ref2;
11331
+ }.bind(this);
11332
+ if (t.childElementCount > 1) {
11333
+ toArray(t.querySelectorAll("tspan")).filter(filterFn).forEach(function (ts) {
11334
+ _newArrowCheck(this, _this5);
11335
+ glyph.push(getStyleFn(ts));
11336
+ }.bind(this));
11337
+ return [];
11338
+ } else {
11339
+ glyph.push(getStyleFn(t));
11340
+ }
11341
+ }.bind(this));
11342
+ return glyph;
11343
+ }
11344
+
11345
+ /**
11346
+ * Render text glyph
11347
+ * - NOTE: Called when the 'preserveFontStyle' option is true
11348
+ * @param {CanvasRenderingContext2D} ctx Canvas context
11349
+ * @param {Array} glyph Text glyph array
11350
+ * @private
11351
+ */
11352
+ function renderText(ctx, glyph) {
11353
+ var _this6 = this;
11354
+ glyph.forEach(function (g) {
11355
+ var _this7 = this;
11356
+ _newArrowCheck(this, _this6);
11357
+ Object.keys(g).forEach(function (key) {
11358
+ var _this8 = this;
11359
+ _newArrowCheck(this, _this7);
11360
+ var _g$key = g[key],
11361
+ x = _g$key.x,
11362
+ y = _g$key.y,
11363
+ width = _g$key.width,
11364
+ height = _g$key.height,
11365
+ fill = _g$key.fill,
11366
+ fontFamily = _g$key.fontFamily,
11367
+ fontSize = _g$key.fontSize,
11368
+ transform = _g$key.transform;
11369
+ ctx.save();
11370
+ ctx.font = fontSize + " " + fontFamily;
11371
+ ctx.fillStyle = fill;
11372
+ if (transform === "none") {
11373
+ ctx.fillText(key, x, y);
11374
+ } else {
11375
+ var args = transform.replace(/(matrix|\(|\))/g, "").split(",");
11376
+ if (args.splice(4).every(function (v) {
11377
+ _newArrowCheck(this, _this8);
11378
+ return +v === 0;
11379
+ }.bind(this))) {
11380
+ args.push(x + width - width / 4);
11381
+ args.push(y - height + height / 3);
11382
+ } else {
11383
+ args.push(x);
11384
+ args.push(y);
11385
+ }
11386
+ ctx.transform.apply(ctx, args);
11387
+ ctx.fillText(key, 0, 0);
11388
+ }
11389
+ ctx.restore();
11390
+ }.bind(this));
11391
+ }.bind(this));
11392
+ }
11171
11393
  /* harmony default export */ var api_export = ({
11172
11394
  /**
11173
11395
  * Export chart as an image.
11174
11396
  * - **NOTE:**
11175
11397
  * - 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
11176
- * - The basic CSS file(ex. billboard.css) should be at same domain as API call context to get correct styled export image.
11398
+ * - 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.
11177
11399
  * @function export
11178
11400
  * @instance
11179
11401
  * @memberof Chart
@@ -11182,6 +11404,12 @@ function nodeToSvgDataUrl(node, option, orgSize) {
11182
11404
  * @param {number} [option.width={currentWidth}] width
11183
11405
  * @param {number} [option.height={currentHeigth}] height
11184
11406
  * @param {boolean} [option.preserveAspectRatio=true] Preserve aspect ratio on given size
11407
+ * @param {boolean} [option.preserveFontStyle=false] Preserve font style(font-family).<br>
11408
+ * **NOTE:**
11409
+ * - This option is useful when outlink web font style's `font-family` are applied to chart's text element.
11410
+ * - Text element's position(especially "transformed") can't be preserved correctly according the page's layout condition.
11411
+ * - If need to preserve accurate text position, embed the web font data within to the page and set `preserveFontStyle=false`.
11412
+ * - 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>
11185
11413
  * @param {Function} [callback] The callback to be invoked when export is ready.
11186
11414
  * @returns {string} dataURI
11187
11415
  * @example
@@ -11205,16 +11433,19 @@ function nodeToSvgDataUrl(node, option, orgSize) {
11205
11433
  * width: 800,
11206
11434
  * height: 600,
11207
11435
  * preserveAspectRatio: false,
11436
+ * preserveFontStyle: false,
11208
11437
  * mimeType: "image/png"
11209
11438
  * },
11210
11439
  * dataUrl => { ... }
11211
11440
  * );
11212
11441
  */
11213
11442
  export: function _export(option, callback) {
11214
- var _this4 = this,
11443
+ var _this9 = this,
11215
11444
  $$ = this.internal,
11216
11445
  state = $$.state,
11217
- chart = $$.$el.chart,
11446
+ _$$$$el = $$.$el,
11447
+ chart = _$$$$el.chart,
11448
+ svg = _$$$$el.svg,
11218
11449
  _state$current = state.current,
11219
11450
  width = _state$current.width,
11220
11451
  height = _state$current.height,
@@ -11222,22 +11453,30 @@ function nodeToSvgDataUrl(node, option, orgSize) {
11222
11453
  width: width,
11223
11454
  height: height,
11224
11455
  preserveAspectRatio: !0,
11456
+ preserveFontStyle: !1,
11225
11457
  mimeType: "image/png"
11226
11458
  }, option),
11227
11459
  svgDataUrl = nodeToSvgDataUrl(chart.node(), opt, {
11228
11460
  width: width,
11229
11461
  height: height
11230
- });
11462
+ }),
11463
+ glyph = opt.preserveFontStyle ? getGlyph(svg.node()) : [];
11231
11464
  if (callback && isFunction(callback)) {
11232
11465
  var img = new Image();
11233
11466
  img.crossOrigin = "Anonymous";
11234
11467
  img.onload = function () {
11235
- _newArrowCheck(this, _this4);
11468
+ _newArrowCheck(this, _this9);
11236
11469
  var canvas = browser_doc.createElement("canvas"),
11237
11470
  ctx = canvas.getContext("2d");
11238
11471
  canvas.width = opt.width || width;
11239
11472
  canvas.height = opt.height || height;
11240
11473
  ctx.drawImage(img, 0, 0);
11474
+ if (glyph.length) {
11475
+ renderText(ctx, glyph);
11476
+
11477
+ // release glyph array
11478
+ glyph.length = 0;
11479
+ }
11241
11480
  callback.bind(this)(canvas.toDataURL(opt.mimeType));
11242
11481
  }.bind(this);
11243
11482
  img.src = svgDataUrl;
@@ -14059,7 +14298,7 @@ var Axis_Axis = /*#__PURE__*/function () {
14059
14298
  chart = _$$$$el2.chart,
14060
14299
  currentTickMax = current.maxTickWidths[id],
14061
14300
  maxWidth = 0;
14062
- if (withoutRecompute || !config["axis_" + id + "_show"] || $$.filterTargetsToShow().length === 0) {
14301
+ if (withoutRecompute || !config["axis_" + id + "_show"] || currentTickMax.size > 0 && $$.filterTargetsToShow().length === 0) {
14063
14302
  return currentTickMax.size;
14064
14303
  }
14065
14304
  if (svg) {
@@ -15440,7 +15679,7 @@ function smoothLines(el, type) {
15440
15679
  // enter
15441
15680
  var xgridLine = xLines.enter().append("g");
15442
15681
  xgridLine.append("line").style("opacity", "0");
15443
- xgridLine.append("text").attr("transform", isRotated ? "" : "rotate(-90)").attr("dy", -5).style("opacity", "0");
15682
+ xgridLine.append("text").attr("transform", isRotated ? null : "rotate(-90)").attr("dy", -5).style("opacity", "0");
15444
15683
  xLines = xgridLine.merge(xLines);
15445
15684
  $T(xLines.attr("class", function (d) {
15446
15685
  _newArrowCheck(this, _this9);
@@ -17818,6 +18057,103 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
17818
18057
 
17819
18058
 
17820
18059
 
18060
+ /**
18061
+ * Get radius functions
18062
+ * @param {number} expandRate Expand rate number.
18063
+ * - If 0, means for "normal" radius.
18064
+ * - If > 0, means for "expanded" radius.
18065
+ * @returns {object} radius functions
18066
+ * @private
18067
+ */
18068
+ function getRadiusFn(expandRate) {
18069
+ if (expandRate === void 0) {
18070
+ expandRate = 0;
18071
+ }
18072
+ var $$ = this,
18073
+ config = $$.config,
18074
+ state = $$.state,
18075
+ hasMultiArcGauge = $$.hasMultiArcGauge(),
18076
+ singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
18077
+ expandWidth = expandRate ? Math.min(state.radiusExpanded * expandRate - state.radius, singleArcWidth * .8 - (1 - expandRate) * 100) : 0;
18078
+ return {
18079
+ /**
18080
+ * Getter of arc innerRadius value
18081
+ * @param {IArcData} d Data object
18082
+ * @returns {number} innerRadius value
18083
+ * @private
18084
+ */
18085
+ inner: function inner(d) {
18086
+ var _$$$getRadius = $$.getRadius(d),
18087
+ innerRadius = _$$$getRadius.innerRadius;
18088
+ return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
18089
+ },
18090
+ /**
18091
+ * Getter of arc outerRadius value
18092
+ * @param {IArcData} d Data object
18093
+ * @returns {number} outerRadius value
18094
+ * @private
18095
+ */
18096
+ outer: function outer(d) {
18097
+ var _$$$getRadius2 = $$.getRadius(d),
18098
+ outerRadius = _$$$getRadius2.outerRadius,
18099
+ radius;
18100
+ if (hasMultiArcGauge) {
18101
+ radius = state.radius - singleArcWidth * d.index + expandWidth;
18102
+ } else if ($$.hasType("polar") && !expandRate) {
18103
+ radius = $$.getPolarOuterRadius(d, outerRadius);
18104
+ } else {
18105
+ radius = outerRadius;
18106
+ if (expandRate) {
18107
+ var radiusExpanded = state.radiusExpanded;
18108
+ if (state.radius !== outerRadius) {
18109
+ radiusExpanded -= Math.abs(state.radius - outerRadius);
18110
+ }
18111
+ radius = radiusExpanded * expandRate;
18112
+ }
18113
+ }
18114
+ return radius;
18115
+ },
18116
+ /**
18117
+ * Getter of arc cornerRadius value
18118
+ * @param {IArcData} d Data object
18119
+ * @param {number} outerRadius outer radius value
18120
+ * @returns {number} cornerRadius value
18121
+ * @private
18122
+ */
18123
+ corner: function (d, outerRadius) {
18124
+ var _config$arc_cornerRad = config.arc_cornerRadius_ratio,
18125
+ ratio = _config$arc_cornerRad === void 0 ? 0 : _config$arc_cornerRad,
18126
+ _config$arc_cornerRad2 = config.arc_cornerRadius,
18127
+ cornerRadius = _config$arc_cornerRad2 === void 0 ? 0 : _config$arc_cornerRad2,
18128
+ id = d.data.id,
18129
+ value = d.value,
18130
+ corner = 0;
18131
+ if (ratio) {
18132
+ corner = ratio * outerRadius;
18133
+ } else {
18134
+ corner = isNumber(cornerRadius) ? cornerRadius : cornerRadius.call($$.api, id, value, outerRadius);
18135
+ }
18136
+ return corner;
18137
+ }
18138
+ };
18139
+ }
18140
+
18141
+ /**
18142
+ * Get attrTween function to get interpolated value on transition
18143
+ * @param {Function} fn Arc function to execute
18144
+ * @returns {Function} attrTween function
18145
+ * @private
18146
+ */
18147
+ function getAttrTweenFn(fn) {
18148
+ return function (d) {
18149
+ var interpolate = (0,external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate_root_d3_.interpolate)(this._current, d);
18150
+ this._current = d;
18151
+ return function (t) {
18152
+ var interpolated = interpolate(t);
18153
+ return fn(interpolated);
18154
+ };
18155
+ };
18156
+ }
17821
18157
  /* harmony default export */ var arc = ({
17822
18158
  initPie: function initPie() {
17823
18159
  var _this2 = this,
@@ -17957,37 +18293,19 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
17957
18293
  return found ? d : null;
17958
18294
  },
17959
18295
  getSvgArc: function getSvgArc() {
17960
- var _this5 = this,
17961
- $$ = this,
17962
- state = $$.state,
17963
- singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
17964
- hasMultiArcGauge = $$.hasMultiArcGauge(),
17965
- hasPolar = $$.hasType("polar"),
17966
- arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
17967
- _newArrowCheck(this, _this5);
17968
- var _$$$getRadius = $$.getRadius(d),
17969
- innerRadius = _$$$getRadius.innerRadius;
17970
- return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : isNumber(innerRadius) ? innerRadius : 0;
17971
- }.bind(this)).outerRadius(function (d) {
17972
- _newArrowCheck(this, _this5);
17973
- var _$$$getRadius2 = $$.getRadius(d),
17974
- outerRadius = _$$$getRadius2.outerRadius,
17975
- radius = outerRadius;
17976
- if (hasMultiArcGauge) {
17977
- radius = state.radius - singleArcWidth * d.index;
17978
- } else if (hasPolar) {
17979
- radius = $$.getPolarOuterRadius(d, outerRadius);
17980
- }
17981
- return radius;
17982
- }.bind(this)),
18296
+ var $$ = this,
18297
+ _getRadiusFn$call = getRadiusFn.call($$),
18298
+ inner = _getRadiusFn$call.inner,
18299
+ outer = _getRadiusFn$call.outer,
18300
+ corner = _getRadiusFn$call.corner,
18301
+ arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer),
17983
18302
  newArc = function (d, withoutUpdate) {
17984
18303
  var path = "M 0 0";
17985
18304
  if (d.value || d.data) {
17986
- var updated = !withoutUpdate && $$.updateAngle(d);
17987
- if (withoutUpdate) {
17988
- path = arc(d);
17989
- } else if (updated) {
17990
- path = arc(updated);
18305
+ var _$$$updateAngle,
18306
+ data = withoutUpdate ? d : (_$$$updateAngle = $$.updateAngle(d)) != null ? _$$$updateAngle : null;
18307
+ if (data) {
18308
+ path = arc.cornerRadius(corner(data, outer(data)))(data);
17991
18309
  }
17992
18310
  }
17993
18311
  return path;
@@ -17996,37 +18314,33 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
17996
18314
  newArc.centroid = arc.centroid;
17997
18315
  return newArc;
17998
18316
  },
18317
+ /**
18318
+ * Get expanded arc path function
18319
+ * @param {number} rate Expand rate
18320
+ * @returns {Function} Expanded arc path getter function
18321
+ * @private
18322
+ */
17999
18323
  getSvgArcExpanded: function getSvgArcExpanded(rate) {
18000
- var _this6 = this,
18001
- $$ = this,
18002
- state = $$.state,
18003
- newRate = rate || 1,
18004
- singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length,
18005
- hasMultiArcGauge = $$.hasMultiArcGauge(),
18006
- expandWidth = Math.min(state.radiusExpanded * newRate - state.radius, singleArcWidth * .8 - (1 - newRate) * 100),
18007
- arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(function (d) {
18008
- _newArrowCheck(this, _this6);
18009
- return hasMultiArcGauge ? state.radius - singleArcWidth * (d.index + 1) : $$.getRadius(d).innerRadius;
18010
- }.bind(this)).outerRadius(function (d) {
18011
- _newArrowCheck(this, _this6);
18012
- var radius;
18013
- if (hasMultiArcGauge) {
18014
- radius = state.radius - singleArcWidth * d.index + expandWidth;
18015
- } else {
18016
- var _$$$getRadius3 = $$.getRadius(d),
18017
- outerRadius = _$$$getRadius3.outerRadius,
18018
- radiusExpanded = state.radiusExpanded;
18019
- if (state.radius !== outerRadius) {
18020
- radiusExpanded -= Math.abs(state.radius - outerRadius);
18021
- }
18022
- radius = radiusExpanded * newRate;
18023
- }
18024
- return radius;
18025
- }.bind(this));
18324
+ var _this5 = this;
18325
+ if (rate === void 0) {
18326
+ rate = 1;
18327
+ }
18328
+ var $$ = this,
18329
+ _getRadiusFn$call2 = getRadiusFn.call($$, rate),
18330
+ inner = _getRadiusFn$call2.inner,
18331
+ outer = _getRadiusFn$call2.outer,
18332
+ corner = _getRadiusFn$call2.corner,
18333
+ arc = (0,external_commonjs_d3_shape_commonjs2_d3_shape_amd_d3_shape_root_d3_.arc)().innerRadius(inner).outerRadius(outer);
18026
18334
  return function (d) {
18027
- var updated = $$.updateAngle(d);
18028
- return updated ? arc(updated) : "M 0 0";
18029
- };
18335
+ _newArrowCheck(this, _this5);
18336
+ var updated = $$.updateAngle(d),
18337
+ outerR = outer(updated),
18338
+ cornerR = 0;
18339
+ if (updated) {
18340
+ cornerR = corner(updated, outerR);
18341
+ }
18342
+ return updated ? arc.cornerRadius(cornerR)(updated) : "M 0 0";
18343
+ }.bind(this);
18030
18344
  },
18031
18345
  getArc: function getArc(d, withoutUpdate, force) {
18032
18346
  return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
@@ -18038,7 +18352,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18038
18352
  * @private
18039
18353
  */
18040
18354
  transformForArcLabel: function transformForArcLabel(d) {
18041
- var _this7 = this,
18355
+ var _this6 = this,
18042
18356
  $$ = this,
18043
18357
  config = $$.config,
18044
18358
  radiusExpanded = $$.state.radiusExpanded,
@@ -18052,21 +18366,21 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18052
18366
  translate = "translate(" + x + "," + y + ")";
18053
18367
  } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
18054
18368
  var _filter$map,
18055
- _$$$getRadius4 = $$.getRadius(d),
18056
- outerRadius = _$$$getRadius4.outerRadius;
18369
+ _$$$getRadius3 = $$.getRadius(d),
18370
+ outerRadius = _$$$getRadius3.outerRadius;
18057
18371
  if ($$.hasType("polar")) {
18058
18372
  outerRadius = $$.getPolarOuterRadius(d, outerRadius);
18059
18373
  }
18060
18374
  var c = this.svgArc.centroid(updated),
18061
18375
  _c$map = c.map(function (v) {
18062
- _newArrowCheck(this, _this7);
18376
+ _newArrowCheck(this, _this6);
18063
18377
  return isNaN(v) ? 0 : v;
18064
18378
  }.bind(this)),
18065
18379
  x = _c$map[0],
18066
18380
  y = _c$map[1],
18067
18381
  h = Math.sqrt(x * x + y * y),
18068
18382
  ratio = (_filter$map = ["donut", "pie", "polar"].filter($$.hasType.bind($$)).map(function (v) {
18069
- _newArrowCheck(this, _this7);
18383
+ _newArrowCheck(this, _this6);
18070
18384
  return config[v + "_label_ratio"];
18071
18385
  }.bind(this))) == null ? void 0 : _filter$map[0];
18072
18386
  if (ratio) {
@@ -18081,7 +18395,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18081
18395
  },
18082
18396
  convertToArcData: function convertToArcData(d) {
18083
18397
  return this.addName({
18084
- id: d.data ? d.data.id : d.id,
18398
+ id: "data" in d ? d.data.id : d.id,
18085
18399
  value: d.value,
18086
18400
  ratio: this.getRatio("arc", d),
18087
18401
  index: d.index
@@ -18108,14 +18422,14 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18108
18422
  }
18109
18423
  },
18110
18424
  expandArc: function expandArc(targetIds) {
18111
- var _this8 = this,
18425
+ var _this7 = this,
18112
18426
  $$ = this,
18113
18427
  transiting = $$.state.transiting,
18114
18428
  $el = $$.$el;
18115
18429
  // MEMO: avoid to cancel transition
18116
18430
  if (transiting) {
18117
18431
  var interval = setInterval(function () {
18118
- _newArrowCheck(this, _this8);
18432
+ _newArrowCheck(this, _this7);
18119
18433
  if (!transiting) {
18120
18434
  clearInterval(interval);
18121
18435
  $el.legend.selectAll("." + $FOCUS.legendItemFocused).size() > 0 && $$.expandArc(targetIds);
@@ -18130,11 +18444,11 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18130
18444
  }
18131
18445
  var expandDuration = $$.getExpandConfig(d.data.id, "duration"),
18132
18446
  svgArcExpandedSub = $$.getSvgArcExpanded($$.getExpandConfig(d.data.id, "rate"));
18133
- (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attr("d", $$.svgArcExpanded).transition().duration(expandDuration * 2).attr("d", svgArcExpandedSub);
18447
+ (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this).selectAll("path").transition().duration(expandDuration).attrTween("d", getAttrTweenFn($$.svgArcExpanded.bind($$))).transition().duration(expandDuration * 2).attrTween("d", getAttrTweenFn(svgArcExpandedSub.bind($$)));
18134
18448
  });
18135
18449
  },
18136
18450
  unexpandArc: function unexpandArc(targetIds) {
18137
- var _this9 = this,
18451
+ var _this8 = this,
18138
18452
  $$ = this,
18139
18453
  transiting = $$.state.transiting,
18140
18454
  svg = $$.$el.svg;
@@ -18143,9 +18457,9 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18143
18457
  }
18144
18458
  var newTargetIds = $$.mapToTargetIds(targetIds);
18145
18459
  svg.selectAll($$.selectorTargets(newTargetIds, "." + $ARC.chartArc)).selectAll("path").transition().duration(function (d) {
18146
- _newArrowCheck(this, _this9);
18460
+ _newArrowCheck(this, _this8);
18147
18461
  return $$.getExpandConfig(d.data.id, "duration");
18148
- }.bind(this)).attr("d", $$.svgArc);
18462
+ }.bind(this)).attrTween("d", getAttrTweenFn($$.svgArc.bind($$)));
18149
18463
  svg.selectAll("" + $ARC.arc).style("opacity", null);
18150
18464
  },
18151
18465
  /**
@@ -18177,24 +18491,24 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18177
18491
  return $$.isDonutType(id) && config.donut_expand || $$.isGaugeType(id) && config.gauge_expand || $$.isPieType(id) && config.pie_expand;
18178
18492
  },
18179
18493
  shouldShowArcLabel: function shouldShowArcLabel() {
18180
- var _this10 = this,
18494
+ var _this9 = this,
18181
18495
  $$ = this,
18182
18496
  config = $$.config;
18183
18497
  return ["donut", "gauge", "pie", "polar"].some(function (v) {
18184
- _newArrowCheck(this, _this10);
18498
+ _newArrowCheck(this, _this9);
18185
18499
  return $$.hasType(v) && config[v + "_label_show"];
18186
18500
  }.bind(this));
18187
18501
  },
18188
18502
  getArcLabelFormat: function getArcLabelFormat() {
18189
- var _this11 = this,
18503
+ var _this10 = this,
18190
18504
  $$ = this,
18191
18505
  config = $$.config,
18192
18506
  format = function (v) {
18193
- _newArrowCheck(this, _this11);
18507
+ _newArrowCheck(this, _this10);
18194
18508
  return v;
18195
18509
  }.bind(this);
18196
18510
  ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).forEach(function (v) {
18197
- _newArrowCheck(this, _this11);
18511
+ _newArrowCheck(this, _this10);
18198
18512
  format = config[v + "_label_format"];
18199
18513
  }.bind(this));
18200
18514
  return isFunction(format) ? format.bind($$.api) : format;
@@ -18205,7 +18519,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18205
18519
  return type ? $$.config[type + "_title"] : "";
18206
18520
  },
18207
18521
  updateTargetsForArc: function updateTargetsForArc(targets) {
18208
- var _this12 = this,
18522
+ var _this11 = this,
18209
18523
  $$ = this,
18210
18524
  $el = $$.$el,
18211
18525
  hasGauge = $$.hasType("gauge"),
@@ -18214,7 +18528,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18214
18528
  classFocus = $$.classFocus.bind($$),
18215
18529
  chartArcs = $el.main.select("." + $ARC.chartArcs),
18216
18530
  mainPieUpdate = chartArcs.selectAll("." + $ARC.chartArc).data($$.pie(targets)).attr("class", function (d) {
18217
- _newArrowCheck(this, _this12);
18531
+ _newArrowCheck(this, _this11);
18218
18532
  return classChartArc(d) + classFocus(d.data);
18219
18533
  }.bind(this)),
18220
18534
  mainPieEnter = mainPieUpdate.enter().append("g").attr("class", classChartArc).call(this.setCssRule(!1, "." + $ARC.chartArcs + " text", ["pointer-events:none", "text-anchor:middle"]));
@@ -18245,7 +18559,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18245
18559
  }
18246
18560
  },
18247
18561
  redrawArc: function redrawArc(duration, durationForExit, withTransform) {
18248
- var _this13 = this,
18562
+ var _this12 = this,
18249
18563
  $$ = this,
18250
18564
  config = $$.config,
18251
18565
  state = $$.state,
@@ -18255,10 +18569,10 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18255
18569
  mainArc = main.selectAll("." + $ARC.arcs).selectAll("." + $ARC.arc).data($$.arcData.bind($$));
18256
18570
  mainArc.exit().transition().duration(durationForExit).style("opacity", "0").remove();
18257
18571
  mainArc = mainArc.enter().append("path").attr("class", $$.getClass("arc", !0)).style("fill", function (d) {
18258
- _newArrowCheck(this, _this13);
18572
+ _newArrowCheck(this, _this12);
18259
18573
  return $$.color(d.data);
18260
18574
  }.bind(this)).style("cursor", function (d) {
18261
- _newArrowCheck(this, _this13);
18575
+ _newArrowCheck(this, _this12);
18262
18576
  return isSelectable != null && isSelectable.bind != null && isSelectable.bind($$.api)(d) ? "pointer" : null;
18263
18577
  }.bind(this)).style("opacity", "0").each(function (d) {
18264
18578
  if ($$.isGaugeType(d.data)) {
@@ -18272,19 +18586,19 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18272
18586
  $$.hasMultiArcGauge() && $$.redrawMultiArcGauge();
18273
18587
  }
18274
18588
  mainArc.attr("transform", function (d) {
18275
- _newArrowCheck(this, _this13);
18589
+ _newArrowCheck(this, _this12);
18276
18590
  return !$$.isGaugeType(d.data) && withTransform ? "scale(0)" : "";
18277
18591
  }.bind(this)).style("opacity", function (d) {
18278
18592
  return d === this._current ? "0" : null;
18279
18593
  }).each(function () {
18280
- _newArrowCheck(this, _this13);
18594
+ _newArrowCheck(this, _this12);
18281
18595
  state.transiting = !0;
18282
18596
  }.bind(this)).transition().duration(duration).attrTween("d", function (d) {
18283
- var _this14 = this,
18597
+ var _this13 = this,
18284
18598
  updated = $$.updateAngle(d);
18285
18599
  if (!updated) {
18286
18600
  return function () {
18287
- _newArrowCheck(this, _this14);
18601
+ _newArrowCheck(this, _this13);
18288
18602
  return "M 0 0";
18289
18603
  }.bind(this);
18290
18604
  }
@@ -18303,7 +18617,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18303
18617
  return $$.getArc(interpolated, !0);
18304
18618
  };
18305
18619
  }).attr("transform", withTransform ? "scale(1)" : "").style("fill", function (d) {
18306
- _newArrowCheck(this, _this13);
18620
+ _newArrowCheck(this, _this12);
18307
18621
  var color;
18308
18622
  if ($$.levelColor) {
18309
18623
  color = $$.levelColor(d.data.values[0].value);
@@ -18319,8 +18633,8 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18319
18633
  .style("opacity", null).call(endall, function () {
18320
18634
  if ($$.levelColor) {
18321
18635
  var path = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this),
18322
- d = path.datum();
18323
- $$.updateLegendItemColor(d.data.id, path.style("fill"));
18636
+ _d = path.datum();
18637
+ $$.updateLegendItemColor(_d.data.id, path.style("fill"));
18324
18638
  }
18325
18639
  state.transiting = !1;
18326
18640
  callFn(config.onrendered, $$.api);
@@ -18333,7 +18647,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18333
18647
  $$.redrawArcText(duration);
18334
18648
  },
18335
18649
  redrawBackgroundArcs: function redrawBackgroundArcs() {
18336
- var _this15 = this,
18650
+ var _this14 = this,
18337
18651
  $$ = this,
18338
18652
  config = $$.config,
18339
18653
  state = $$.state,
@@ -18346,11 +18660,11 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18346
18660
  var index = 0;
18347
18661
  backgroundArc = backgroundArc.selectAll("path." + $ARC.chartArcsBackground).data($$.data.targets);
18348
18662
  backgroundArc.enter().append("path").attr("class", function (d, i) {
18349
- _newArrowCheck(this, _this15);
18663
+ _newArrowCheck(this, _this14);
18350
18664
  return $ARC.chartArcsBackground + " " + $ARC.chartArcsBackground + "-" + i;
18351
18665
  }.bind(this)).merge(backgroundArc).style("fill", config.gauge_background || null).attr("d", function (_ref2) {
18352
18666
  var id = _ref2.id;
18353
- _newArrowCheck(this, _this15);
18667
+ _newArrowCheck(this, _this14);
18354
18668
  if (state.hiddenTargetIds.indexOf(id) >= 0) {
18355
18669
  return "M 0 0";
18356
18670
  }
@@ -18367,7 +18681,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18367
18681
  backgroundArc.exit().remove();
18368
18682
  } else {
18369
18683
  backgroundArc.attr("d", function () {
18370
- _newArrowCheck(this, _this15);
18684
+ _newArrowCheck(this, _this14);
18371
18685
  var d = {
18372
18686
  data: [{
18373
18687
  value: config.gauge_max
@@ -18380,7 +18694,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18380
18694
  }
18381
18695
  },
18382
18696
  bindArcEvent: function bindArcEvent(arc) {
18383
- var _this16 = this,
18697
+ var _this15 = this,
18384
18698
  $$ = this,
18385
18699
  config = $$.config,
18386
18700
  state = $$.state,
@@ -18428,7 +18742,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18428
18742
  selectArc(this, arcData, id);
18429
18743
  $$.setOverOut(!0, arcData);
18430
18744
  }).on("mouseout", function (event, d) {
18431
- _newArrowCheck(this, _this16);
18745
+ _newArrowCheck(this, _this15);
18432
18746
  if (state.transiting) {
18433
18747
  // skip while transiting
18434
18748
  return;
@@ -18449,7 +18763,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18449
18763
  // touch events
18450
18764
  if (isTouch && $$.hasArcType() && !$$.radars) {
18451
18765
  var getEventArc = function (event) {
18452
- _newArrowCheck(this, _this16);
18766
+ _newArrowCheck(this, _this15);
18453
18767
  var touch = event.changedTouches[0],
18454
18768
  eventArc = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(browser_doc.elementFromPoint(touch.clientX, touch.clientY));
18455
18769
  return eventArc;
@@ -18472,7 +18786,7 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18472
18786
  }
18473
18787
  },
18474
18788
  redrawArcText: function redrawArcText(duration) {
18475
- var _this17 = this,
18789
+ var _this16 = this,
18476
18790
  $$ = this,
18477
18791
  config = $$.config,
18478
18792
  state = $$.state,
@@ -18485,13 +18799,13 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18485
18799
  // for gauge type, update text when has no title & multi data
18486
18800
  if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
18487
18801
  text = main.selectAll("." + $ARC.chartArc).select("text").style("opacity", "0").attr("class", function (d) {
18488
- _newArrowCheck(this, _this17);
18802
+ _newArrowCheck(this, _this16);
18489
18803
  return $$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null;
18490
18804
  }.bind(this)).call($$.textForArcLabel.bind($$)).attr("transform", $$.transformForArcLabel.bind($$)).style("font-size", function (d) {
18491
- _newArrowCheck(this, _this17);
18805
+ _newArrowCheck(this, _this16);
18492
18806
  return $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? Math.round(state.radius / 5) + "px" : null;
18493
18807
  }.bind(this)).transition().duration(duration).style("opacity", function (d) {
18494
- _newArrowCheck(this, _this17);
18808
+ _newArrowCheck(this, _this16);
18495
18809
  return $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0";
18496
18810
  }.bind(this));
18497
18811
  hasMultiArcGauge && text.attr("dy", "-.1em");
@@ -18561,6 +18875,9 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18561
18875
  return "0";
18562
18876
  }).merge(area);
18563
18877
  area.style("opacity", state.orgAreaOpacity);
18878
+
18879
+ // calculate ratio if grouped data exists
18880
+ $$.setRatioForGroupedData($root.area.data());
18564
18881
  },
18565
18882
  /**
18566
18883
  * Redraw function
@@ -18744,6 +19061,9 @@ var external_commonjs_d3_interpolate_commonjs2_d3_interpolate_amd_d3_interpolate
18744
19061
  var bar = $root.main.selectAll("." + $BAR.bars).selectAll("." + $BAR.bar).data($$.labelishData.bind($$));
18745
19062
  $T(bar.exit(), withTransition).style("opacity", "0").remove();
18746
19063
  $root.bar = bar.enter().append("path").attr("class", classBar).style("fill", $$.updateBarColor.bind($$)).merge(bar).style("opacity", initialOpacity);
19064
+
19065
+ // calculate ratio if grouped data exists
19066
+ $$.setRatioForGroupedData($root.bar.data());
18747
19067
  },
18748
19068
  /**
18749
19069
  * Update bar color
@@ -19504,22 +19824,11 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19504
19824
  config = $$.config,
19505
19825
  isRotated = config.axis_rotated,
19506
19826
  isTimeSeries = $$.axis.isTimeSeries(),
19507
- xOffset = $$.axis.isCategorized() ? .5 : 0,
19508
19827
  regions = [],
19509
- dasharray = "2 2",
19510
19828
  xp,
19511
19829
  yp,
19512
19830
  diff,
19513
- diffx2,
19514
- isWithinRegions = function (withinX, withinRegions) {
19515
- _newArrowCheck(this, _this5);
19516
- for (var i = 0, reg; reg = withinRegions[i]; i++) {
19517
- if (reg.start < withinX && withinX <= reg.end) {
19518
- return reg.style;
19519
- }
19520
- }
19521
- return !1;
19522
- }.bind(this);
19831
+ diffx2;
19523
19832
  // Check start/end of regions
19524
19833
  if (isDefined(_regions)) {
19525
19834
  var getValue = function (v, def) {
@@ -19530,7 +19839,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19530
19839
  var start = getValue(reg.start, d[0].x),
19531
19840
  end = getValue(reg.end, d[d.length - 1].x),
19532
19841
  style = reg.style || {
19533
- dasharray: dasharray
19842
+ dasharray: "2 2"
19534
19843
  };
19535
19844
  regions[i] = {
19536
19845
  start: start,
@@ -19580,7 +19889,7 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19580
19889
  for (var _i = 0, data; data = d[_i]; _i++) {
19581
19890
  var prevData = d[_i - 1],
19582
19891
  hasPrevData = prevData && isValue(prevData.value),
19583
- style = isWithinRegions(data.x, regions);
19892
+ style = $$.isWithinRegions(data.x, regions);
19584
19893
  // https://github.com/naver/billboard.js/issues/1172
19585
19894
  if (!isValue(data.value)) {
19586
19895
  continue;
@@ -19593,11 +19902,11 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19593
19902
  try {
19594
19903
  style = style.dasharray.split(" ");
19595
19904
  } catch (e) {
19596
- style = dasharray.split(" ");
19905
+ style = "2 2".split(" ");
19597
19906
  }
19598
19907
 
19599
19908
  // Draw with region // TODO: Fix for horizotal charts
19600
- xp = getScale(axisType.x, prevData.x + xOffset, data.x + xOffset);
19909
+ xp = getScale(axisType.x, prevData.x, data.x);
19601
19910
  yp = getScale(axisType.y, prevData.value, data.value);
19602
19911
  var dx = x(data.x) - x(prevData.x),
19603
19912
  dy = y(data.value) - y(prevData.value),
@@ -19616,6 +19925,14 @@ function candlestick_objectSpread(target) { for (var i = 1, source; i < argument
19616
19925
  }
19617
19926
  return path;
19618
19927
  },
19928
+ isWithinRegions: function isWithinRegions(withinX, withinRegions) {
19929
+ for (var i = 0, reg; reg = withinRegions[i]; i++) {
19930
+ if (reg.start < withinX && withinX <= reg.end) {
19931
+ return reg.style;
19932
+ }
19933
+ }
19934
+ return !1;
19935
+ },
19619
19936
  isWithinStep: function isWithinStep(that, y) {
19620
19937
  return Math.abs(y - getPointer(this.state.event, that)[1]) < 30;
19621
19938
  },
@@ -21140,6 +21457,52 @@ var cacheKey = KEY.radarPoints;
21140
21457
  */
21141
21458
  spline_interpolation_type: "cardinal"
21142
21459
  });
21460
+ ;// CONCATENATED MODULE: ./src/config/Options/shape/arc.ts
21461
+ /**
21462
+ * Copyright (c) 2017 ~ present NAVER Corp.
21463
+ * billboard.js project is licensed under the MIT license
21464
+ */
21465
+ /**
21466
+ * area config options
21467
+ */
21468
+ /* harmony default export */ var shape_arc = ({
21469
+ /**
21470
+ * Set arc options
21471
+ * @name arc
21472
+ * @memberof Options
21473
+ * @type {object}
21474
+ * @property {object} arc Arc object
21475
+ * @property {number|Function} [arc.cornerRadius=0] Set corner radius of Arc(donut/gauge/pie/polar) shape.
21476
+ * - **NOTE:**
21477
+ * - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
21478
+ * @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
21479
+ * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
21480
+ * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
21481
+ * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
21482
+ * @example
21483
+ * arc: {
21484
+ * cornerRadius: 12,
21485
+ *
21486
+ * // can customize corner radius for each data with function callback
21487
+ * //
21488
+ * // The function will receive:
21489
+ * // - id {string}: Data id
21490
+ * // - value {number}: Data value
21491
+ * // - outerRadius {number}: Outer radius value
21492
+ * cornerRadius: function(id, value, outerRadius) {
21493
+ * return (id === "data1" && value > 10) ?
21494
+ * 50 : outerRadius * 1.2;
21495
+ * },
21496
+ *
21497
+ * // set ratio relative of outer radius
21498
+ * cornerRadius: {
21499
+ * ratio: 0.5
21500
+ * }
21501
+ * }
21502
+ */
21503
+ arc_cornerRadius: 0,
21504
+ arc_cornerRadius_ratio: 0
21505
+ });
21143
21506
  ;// CONCATENATED MODULE: ./src/config/Options/shape/donut.ts
21144
21507
  /**
21145
21508
  * Copyright (c) 2017 ~ present NAVER Corp.
@@ -21264,7 +21627,7 @@ var cacheKey = KEY.radarPoints;
21264
21627
  * - `startingAngle < -1 * Math.PI` defaults to `Math.PI`
21265
21628
  * - `startingAngle > Math.PI` defaults to `Math.PI`
21266
21629
  * @property {number} [gauge.arcLength=100] Set the length of the arc to be drawn in percent from -100 to 100.<br>
21267
- * Negative value will draw the arc **counterclockwise**.
21630
+ * Negative value will draw the arc **counterclockwise**. Need to be used in conjunction with `gauge.fullCircle=true`.
21268
21631
  *
21269
21632
  * **Limitations:**
21270
21633
  * - -100 <= arcLength (in percent) <= 100
@@ -21277,7 +21640,7 @@ var cacheKey = KEY.radarPoints;
21277
21640
  * **Available Values:**
21278
21641
  * - single
21279
21642
  * - multi
21280
- * @property {string} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
21643
+ * @property {number} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
21281
21644
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
21282
21645
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
21283
21646
  * @example
@@ -21659,6 +22022,7 @@ var shape_this = undefined;
21659
22022
 
21660
22023
 
21661
22024
 
22025
+
21662
22026
  /**
21663
22027
  * Extend Axis
21664
22028
  * @param {Array} module Module to be extended
@@ -21761,7 +22125,7 @@ var _area = function area() {
21761
22125
  shape_donut = function () {
21762
22126
  var _this10 = this;
21763
22127
  _newArrowCheck(this, shape_this);
21764
- return extendArc(undefined, [donut]), (shape_donut = function () {
22128
+ return extendArc(undefined, [shape_arc, donut]), (shape_donut = function () {
21765
22129
  _newArrowCheck(this, _this10);
21766
22130
  return TYPE.DONUT;
21767
22131
  }.bind(this))();
@@ -21769,7 +22133,7 @@ var _area = function area() {
21769
22133
  resolver_shape_gauge = function () {
21770
22134
  var _this11 = this;
21771
22135
  _newArrowCheck(this, shape_this);
21772
- return extendArc([gauge], [shape_gauge]), (resolver_shape_gauge = function () {
22136
+ return extendArc([gauge], [shape_arc, shape_gauge]), (resolver_shape_gauge = function () {
21773
22137
  _newArrowCheck(this, _this11);
21774
22138
  return TYPE.GAUGE;
21775
22139
  }.bind(this))();
@@ -21777,7 +22141,7 @@ var _area = function area() {
21777
22141
  shape_pie = function () {
21778
22142
  var _this12 = this;
21779
22143
  _newArrowCheck(this, shape_this);
21780
- return extendArc(undefined, [pie]), (shape_pie = function () {
22144
+ return extendArc(undefined, [shape_arc, pie]), (shape_pie = function () {
21781
22145
  _newArrowCheck(this, _this12);
21782
22146
  return TYPE.PIE;
21783
22147
  }.bind(this))();
@@ -21785,7 +22149,7 @@ var _area = function area() {
21785
22149
  resolver_shape_polar = function () {
21786
22150
  var _this13 = this;
21787
22151
  _newArrowCheck(this, shape_this);
21788
- return extendArc([polar], [shape_polar]), (resolver_shape_polar = function () {
22152
+ return extendArc([polar], [shape_arc, shape_polar]), (resolver_shape_polar = function () {
21789
22153
  _newArrowCheck(this, _this13);
21790
22154
  return TYPE.POLAR;
21791
22155
  }.bind(this))();
@@ -23630,7 +23994,7 @@ var _defaults = {},
23630
23994
  * bb.version; // "1.0.0"
23631
23995
  * @memberof bb
23632
23996
  */
23633
- version: "3.6.3",
23997
+ version: "3.7.0-next.1",
23634
23998
  /**
23635
23999
  * Generate chart
23636
24000
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -23760,7 +24124,7 @@ var _defaults = {},
23760
24124
  };
23761
24125
  /**
23762
24126
  * @namespace bb
23763
- * @version 3.6.3
24127
+ * @version 3.7.0-next.1
23764
24128
  */
23765
24129
  ;// CONCATENATED MODULE: ./src/index.ts
23766
24130