billboard.js 3.10.3 → 3.11.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +0 -1
  2. package/dist/billboard.css +5 -4
  3. package/dist/billboard.js +598 -220
  4. package/dist/billboard.min.css +2 -2
  5. package/dist/billboard.min.js +2 -2
  6. package/dist/billboard.pkgd.js +2828 -2456
  7. package/dist/billboard.pkgd.min.js +2 -4
  8. package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  9. package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.js +31 -15
  11. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.js +31 -15
  13. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.js +30 -15
  15. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.js +30 -15
  17. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2222 -2214
  19. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2252 -2228
  21. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +2 -2
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +2253 -2229
  23. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +2 -2
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +2253 -2230
  25. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +2 -2
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2259 -2238
  27. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
  28. package/dist/theme/dark.css +7 -7
  29. package/dist/theme/dark.min.css +2 -2
  30. package/dist/theme/datalab.css +7 -7
  31. package/dist/theme/datalab.min.css +2 -2
  32. package/dist/theme/graph.css +7 -7
  33. package/dist/theme/graph.min.css +2 -2
  34. package/dist/theme/insight.css +7 -7
  35. package/dist/theme/insight.min.css +2 -2
  36. package/dist/theme/modern.css +7 -7
  37. package/dist/theme/modern.min.css +2 -2
  38. package/dist-esm/billboard.js +517 -180
  39. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  40. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -4
  41. package/dist-esm/plugin/billboardjs-plugin-stanford.js +7 -9
  42. package/dist-esm/plugin/billboardjs-plugin-tableview.js +3 -4
  43. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +3 -4
  44. package/package.json +42 -46
  45. package/src/Chart/api/zoom.ts +5 -20
  46. package/src/ChartInternal/Axis/Axis.ts +5 -3
  47. package/src/ChartInternal/Axis/AxisRenderer.ts +14 -0
  48. package/src/ChartInternal/ChartInternal.ts +1 -1
  49. package/src/ChartInternal/data/data.ts +12 -5
  50. package/src/ChartInternal/data/load.ts +37 -1
  51. package/src/ChartInternal/interactions/eventrect.ts +11 -4
  52. package/src/ChartInternal/interactions/interaction.ts +2 -1
  53. package/src/ChartInternal/interactions/zoom.ts +28 -0
  54. package/src/ChartInternal/internals/domain.ts +24 -1
  55. package/src/ChartInternal/internals/legend.ts +28 -2
  56. package/src/ChartInternal/internals/scale.ts +3 -3
  57. package/src/ChartInternal/internals/size.axis.ts +8 -3
  58. package/src/ChartInternal/internals/size.ts +14 -1
  59. package/src/ChartInternal/internals/tooltip.ts +12 -6
  60. package/src/ChartInternal/internals/transform.ts +6 -2
  61. package/src/ChartInternal/internals/type.ts +1 -1
  62. package/src/ChartInternal/shape/arc.ts +110 -34
  63. package/src/ChartInternal/shape/gauge.ts +8 -4
  64. package/src/ChartInternal/shape/radar.ts +58 -45
  65. package/src/config/Options/axis/x.ts +27 -1
  66. package/src/config/Options/axis/y2.ts +13 -0
  67. package/src/config/Options/common/legend.ts +17 -0
  68. package/src/config/Options/common/tooltip.ts +1 -0
  69. package/src/config/Options/shape/arc.ts +40 -3
  70. package/src/config/Options/shape/gauge.ts +23 -2
  71. package/src/config/Options/shape/pie.ts +2 -2
  72. package/src/config/classes.ts +1 -0
  73. package/src/module/Cache.ts +1 -0
  74. package/src/module/util.ts +16 -2
  75. package/src/scss/billboard.scss +2 -1
  76. package/src/scss/theme/dark.scss +2 -1
  77. package/src/scss/theme/datalab.scss +2 -1
  78. package/src/scss/theme/graph.scss +2 -1
  79. package/src/scss/theme/insight.scss +2 -1
  80. package/src/scss/theme/modern.scss +2 -1
  81. package/types/options.d.ts +28 -4
  82. package/types/options.shape.d.ts +44 -0
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.10.3
8
+ * @version 3.11.0-next.2
9
9
  */
10
10
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
11
11
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
@@ -355,9 +355,9 @@ function getRectSegList(path) {
355
355
  * */
356
356
  var _a = path.getBBox(), x = _a.x, y = _a.y, width = _a.width, height = _a.height;
357
357
  return [
358
- { x: x, y: y + height },
359
- { x: x, y: y },
360
- { x: x + width, y: y },
358
+ { x: x, y: y + height }, // seg0
359
+ { x: x, y: y }, // seg1
360
+ { x: x + width, y: y }, // seg2
361
361
  { x: x + width, y: y + height } // seg3
362
362
  ];
363
363
  }
@@ -570,11 +570,11 @@ var toArray = function (v) { return [].slice.call(v); };
570
570
  * @private
571
571
  */
572
572
  function addCssRules(style, selector, prop) {
573
- var rootSelctor = style.rootSelctor, sheet = style.sheet;
573
+ var _a = style.rootSelector, rootSelector = _a === void 0 ? "" : _a, sheet = style.sheet;
574
574
  var getSelector = function (s) { return s
575
575
  .replace(/\s?(bb-)/g, ".$1")
576
576
  .replace(/\.+/g, "."); };
577
- var rule = "".concat(rootSelctor, " ").concat(getSelector(selector), " {").concat(prop.join(";"), "}");
577
+ var rule = "".concat(rootSelector, " ").concat(getSelector(selector), " {").concat(prop.join(";"), "}");
578
578
  return sheet[sheet.insertRule ? "insertRule" : "addRule"](rule, sheet.cssRules.length);
579
579
  }
580
580
  /**
@@ -598,6 +598,19 @@ function getCssRules(styleSheets) {
598
598
  });
599
599
  return rules;
600
600
  }
601
+ /**
602
+ * Get current window and container scroll position
603
+ * @param {HTMLElement} node Target element
604
+ * @returns {object} window scroll position
605
+ * @private
606
+ */
607
+ function getScrollPosition(node) {
608
+ var _a, _b, _c, _d, _e, _f;
609
+ return {
610
+ x: (_c = ((_b = (_a = win.pageXOffset) !== null && _a !== void 0 ? _a : win.scrollX) !== null && _b !== void 0 ? _b : 0) + node.scrollLeft) !== null && _c !== void 0 ? _c : 0,
611
+ y: (_f = ((_e = (_d = win.pageYOffset) !== null && _d !== void 0 ? _d : win.scrollY) !== null && _e !== void 0 ? _e : 0) + node.scrollTop) !== null && _f !== void 0 ? _f : 0
612
+ };
613
+ }
601
614
  /**
602
615
  * Gets the SVGMatrix of an SVGGElement
603
616
  * @param {SVGElement} node Node element
@@ -936,6 +949,7 @@ var $COMMON = {
936
949
  var $ARC = {
937
950
  arc: "bb-arc",
938
951
  arcLabelLine: "bb-arc-label-line",
952
+ arcRange: "bb-arc-range",
939
953
  arcs: "bb-arcs",
940
954
  chartArc: "bb-chart-arc",
941
955
  chartArcs: "bb-chart-arcs",
@@ -1102,31 +1116,31 @@ var Element = /** @class */ (function () {
1102
1116
  legend: null,
1103
1117
  title: null,
1104
1118
  subchart: {
1105
- main: null,
1106
- bar: null,
1107
- line: null,
1119
+ main: null, // $$.context
1120
+ bar: null, // $$.contextBar
1121
+ line: null, // $$.contextLine
1108
1122
  area: null // $$.contextArea
1109
1123
  },
1110
1124
  arcs: null,
1111
- bar: null,
1125
+ bar: null, // mainBar,
1112
1126
  candlestick: null,
1113
- line: null,
1114
- area: null,
1115
- circle: null,
1127
+ line: null, // mainLine,
1128
+ area: null, // mainArea,
1129
+ circle: null, // mainCircle,
1116
1130
  radar: null,
1117
- text: null,
1131
+ text: null, // mainText,
1118
1132
  grid: {
1119
- main: null,
1120
- x: null,
1133
+ main: null, // grid (also focus)
1134
+ x: null, // xgrid,
1121
1135
  y: null, // ygrid,
1122
1136
  },
1123
1137
  gridLines: {
1124
- main: null,
1125
- x: null,
1138
+ main: null, // gridLines
1139
+ x: null, // xgridLines,
1126
1140
  y: null, // ygridLines
1127
1141
  },
1128
1142
  region: {
1129
- main: null,
1143
+ main: null, // region
1130
1144
  list: null // mainRegion
1131
1145
  },
1132
1146
  eventRect: null,
@@ -1207,9 +1221,9 @@ var State = /** @class */ (function () {
1207
1221
  legendItemHeight: 0,
1208
1222
  legendHasRendered: false,
1209
1223
  eventReceiver: {
1210
- currentIdx: -1,
1211
- rect: {},
1212
- data: [],
1224
+ currentIdx: -1, // current event interaction index
1225
+ rect: {}, // event rect's clientBoundingRect
1226
+ data: [], // event data bound of previoous eventRect
1213
1227
  coords: [] // coordination value of previous eventRect
1214
1228
  },
1215
1229
  axis: {
@@ -1233,7 +1247,7 @@ var State = /** @class */ (function () {
1233
1247
  idYAxis: "",
1234
1248
  idXAxisTickTexts: "",
1235
1249
  idGrid: "",
1236
- idSubchart: "",
1250
+ idSubchart: "", // clipIdForSubchart
1237
1251
  path: "",
1238
1252
  pathXAxis: "",
1239
1253
  pathYAxis: "",
@@ -1241,7 +1255,7 @@ var State = /** @class */ (function () {
1241
1255
  pathGrid: ""
1242
1256
  },
1243
1257
  // state
1244
- event: null,
1258
+ event: null, // event object
1245
1259
  dragStart: null,
1246
1260
  dragging: false,
1247
1261
  flowing: false,
@@ -1249,14 +1263,14 @@ var State = /** @class */ (function () {
1249
1263
  mouseover: false,
1250
1264
  rendered: false,
1251
1265
  transiting: false,
1252
- redrawing: false,
1253
- resizing: false,
1254
- toggling: false,
1266
+ redrawing: false, // if redraw() is on process
1267
+ resizing: false, // resize event called
1268
+ toggling: false, // legend toggle
1255
1269
  zooming: false,
1256
1270
  hasNegativeValue: false,
1257
1271
  hasPositiveValue: true,
1258
1272
  orgAreaOpacity: "0.2",
1259
- orgConfig: {},
1273
+ orgConfig: {}, // user original genration config
1260
1274
  // ID strings
1261
1275
  hiddenTargetIds: [],
1262
1276
  hiddenLegendIds: [],
@@ -2789,7 +2803,12 @@ var legend$2 = {
2789
2803
  * - **Available Values:**
2790
2804
  * - circle
2791
2805
  * - rectangle
2806
+ * @property {boolean} [legend.format] Set formatter function for legend text.
2807
+ * The argument:<br>
2808
+ * - `id`: legend text(which is data id) value
2809
+ * @property {boolean} [legend.tooltip=false] Show full legend text value using system tooltip(via `<title>` element).
2792
2810
  * @property {boolean} [legend.usePoint=false] Whether to use custom points in legend.
2811
+ * @see [Demo: format](https://naver.github.io/billboard.js/demo/#Legend.LegendFormat)
2793
2812
  * @see [Demo: item.interaction](https://naver.github.io/billboard.js/demo/#Legend.LegendItemInteraction)
2794
2813
  * @see [Demo: item.tile.type](https://naver.github.io/billboard.js/demo/#Legend.LegendItemTileType)
2795
2814
  * @see [Demo: position](https://naver.github.io/billboard.js/demo/#Legend.LegendPosition)
@@ -2852,6 +2871,16 @@ var legend$2 = {
2852
2871
  * r: 10
2853
2872
  * }
2854
2873
  * },
2874
+ * format: function(id) {
2875
+ * // set ellipsis string when length is > 5
2876
+ * // to get full legend value, combine with 'legend.tooltip=true'
2877
+ * if (id.length > 5) {
2878
+ * id = id.substr(0, 5) + "...";
2879
+ * }
2880
+ *
2881
+ * return id;
2882
+ * },
2883
+ * tooltip: true,
2855
2884
  * usePoint: true
2856
2885
  * }
2857
2886
  */
@@ -2872,9 +2901,11 @@ var legend$2 = {
2872
2901
  legend_item_tile_height: 10,
2873
2902
  legend_item_tile_r: 5,
2874
2903
  legend_item_tile_type: "rectangle",
2904
+ legend_format: undefined,
2875
2905
  legend_padding: 0,
2876
2906
  legend_position: "bottom",
2877
2907
  legend_show: true,
2908
+ legend_tooltip: false,
2878
2909
  legend_usePoint: false
2879
2910
  };
2880
2911
 
@@ -2983,6 +3014,7 @@ var tooltip$2 = {
2983
3014
  * - **{=CLASS_TOOLTIP_NAME}**: default tooltip data class name (ex. `bb-tooltip-name-data1`)
2984
3015
  * - **{=TITLE}**: title value.
2985
3016
  * - **{=COLOR}**: data color.
3017
+ * - **{=NAME}**: data id value.
2986
3018
  * - **{=VALUE}**: data value.
2987
3019
  * @property {object} [tooltip.contents.text=undefined] Set additional text content within data loop, using template syntax.
2988
3020
  * - **NOTE:** It should contain `{ key: Array, ... }` value
@@ -3209,6 +3241,7 @@ var KEY = {
3209
3241
  dataTotalPerIndex: "$totalPerIndex",
3210
3242
  legendItemTextBox: "legendItemTextBox",
3211
3243
  radarPoints: "$radarPoints",
3244
+ radarTextWidth: "$radarTextWidth",
3212
3245
  setOverOut: "setOverOut",
3213
3246
  callOverOutForTouch: "callOverOutForTouch",
3214
3247
  textRect: "textRect"
@@ -4332,9 +4365,10 @@ var data$1 = {
4332
4365
  var fn;
4333
4366
  if (orderAsc || orderDesc) {
4334
4367
  var reducer_1 = function (p, c) { return p + Math.abs(c.value); };
4368
+ var sum_1 = function (v) { return (isNumber(v) ? v : ("values" in v ? v.values.reduce(reducer_1, 0) : v.value)); };
4335
4369
  fn = function (t1, t2) {
4336
- var t1Sum = "values" in t1 ? t1.values.reduce(reducer_1, 0) : t1.value;
4337
- var t2Sum = "values" in t2 ? t2.values.reduce(reducer_1, 0) : t2.value;
4370
+ var t1Sum = sum_1(t1);
4371
+ var t2Sum = sum_1(t2);
4338
4372
  return isReversed ?
4339
4373
  (orderAsc ? t1Sum - t2Sum : t2Sum - t1Sum) :
4340
4374
  (orderAsc ? t2Sum - t1Sum : t1Sum - t2Sum);
@@ -4371,7 +4405,7 @@ var data$1 = {
4371
4405
  */
4372
4406
  getDataIndexFromEvent: function (event) {
4373
4407
  var $$ = this;
4374
- var config = $$.config, _a = $$.state, hasRadar = _a.hasRadar, inputType = _a.inputType, _b = _a.eventReceiver, coords = _b.coords, rect = _b.rect;
4408
+ var $el = $$.$el, config = $$.config, _a = $$.state, hasRadar = _a.hasRadar, inputType = _a.inputType, _b = _a.eventReceiver, coords = _b.coords, rect = _b.rect;
4375
4409
  var index;
4376
4410
  if (hasRadar) {
4377
4411
  var target = event.target;
@@ -4384,9 +4418,12 @@ var data$1 = {
4384
4418
  }
4385
4419
  else {
4386
4420
  var isRotated = config.axis_rotated;
4421
+ var scrollPos = getScrollPosition($el.chart.node());
4387
4422
  // get data based on the mouse coords
4388
4423
  var e = inputType === "touch" && event.changedTouches ? event.changedTouches[0] : event;
4389
- index = findIndex(coords, isRotated ? e.clientY - rect.top : e.clientX - rect.left, 0, coords.length - 1, isRotated);
4424
+ index = findIndex(coords, isRotated ?
4425
+ e.clientY + scrollPos.y - rect.top :
4426
+ e.clientX + scrollPos.x - rect.left, 0, coords.length - 1, isRotated);
4390
4427
  }
4391
4428
  return index;
4392
4429
  },
@@ -4603,7 +4640,7 @@ var data$1 = {
4603
4640
  }
4604
4641
  else {
4605
4642
  var gaugeArcLength = config.gauge_fullCircle ?
4606
- $$.getArcLength() : $$.getGaugeStartAngle() * -2;
4643
+ $$.getArcLength() : $$.getStartingAngle() * -2;
4607
4644
  var arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
4608
4645
  ratio = (d.endAngle - d.startAngle) / arcLength;
4609
4646
  }
@@ -4715,8 +4752,13 @@ function callDone(fn, resizeAfter) {
4715
4752
  var dataLoad = {
4716
4753
  load: function (rawTargets, args) {
4717
4754
  var $$ = this;
4718
- var data = $$.data;
4755
+ var axis = $$.axis, data = $$.data, org = $$.org, scale = $$.scale;
4719
4756
  var append = args.append;
4757
+ var zoomState = {
4758
+ domain: null,
4759
+ currentDomain: null,
4760
+ x: null
4761
+ };
4720
4762
  var targets = rawTargets;
4721
4763
  if (targets) {
4722
4764
  // filter loading targets if needed
@@ -4746,12 +4788,36 @@ var dataLoad = {
4746
4788
  }
4747
4789
  // Set targets
4748
4790
  $$.updateTargets(data.targets);
4791
+ if (scale.zoom) {
4792
+ zoomState.x = axis.isCategorized() ? scale.x.orgScale() : (org.xScale || scale.x).copy();
4793
+ zoomState.domain = $$.getXDomain(data.targets); // get updated xDomain
4794
+ zoomState.x.domain(zoomState.domain);
4795
+ zoomState.currentDomain = $$.zoom.getDomain(); // current zoomed domain
4796
+ // reset zoom state when new data loaded is out of range
4797
+ if (!$$.withinRange(zoomState.currentDomain, undefined, zoomState.domain)) {
4798
+ scale.x.domain(zoomState.domain);
4799
+ scale.zoom = null;
4800
+ $$.$el.eventRect.property("__zoom", null);
4801
+ }
4802
+ }
4749
4803
  // Redraw with new targets
4750
4804
  $$.redraw({
4751
4805
  withUpdateOrgXDomain: true,
4752
4806
  withUpdateXDomain: true,
4753
4807
  withLegend: true
4754
4808
  });
4809
+ // when load happens on zoom state
4810
+ if (scale.zoom) {
4811
+ // const x = (axis.isCategorized() ? scale.x.orgScale() : (org.xScale || scale.x)).copy();
4812
+ org.xDomain = zoomState.domain;
4813
+ org.xScale = zoomState.x;
4814
+ if (axis.isCategorized()) {
4815
+ zoomState.currentDomain = $$.getZoomDomainValue(zoomState.currentDomain);
4816
+ org.xDomain = $$.getZoomDomainValue(org.xDomain);
4817
+ org.xScale = zoomState.x.domain(org.xDomain);
4818
+ }
4819
+ $$.updateCurrentZoomTransform(zoomState.x, zoomState.currentDomain);
4820
+ }
4755
4821
  // Update current state chart type and elements list after redraw
4756
4822
  $$.updateTypesElements();
4757
4823
  callDone.call($$, args.done, args.resizeAfter);
@@ -4980,7 +5046,8 @@ var interaction = {
4980
5046
  screenX: x,
4981
5047
  screenY: y,
4982
5048
  clientX: x,
4983
- clientY: y
5049
+ clientY: y,
5050
+ bubbles: hasRadar // radar type needs to bubble up event
4984
5051
  };
4985
5052
  emulateEvent[/^(mouse|click)/.test(type) ? "mouse" : "touch"](hasTreemap ? treemap.node() : element, type, params);
4986
5053
  }
@@ -5704,6 +5771,24 @@ var domain = {
5704
5771
  }
5705
5772
  return [min, max];
5706
5773
  },
5774
+ /**
5775
+ * Return zoom domain from given domain
5776
+ * - 'category' type need to add offset to original value
5777
+ * @param {Array} domainValue domain value
5778
+ * @returns {Array} Zoom domain
5779
+ * @private
5780
+ */
5781
+ getZoomDomainValue: function (domainValue) {
5782
+ var $$ = this;
5783
+ var config = $$.config, axis = $$.axis;
5784
+ if (axis.isCategorized() && Array.isArray(domainValue)) {
5785
+ var isInverted_1 = config.axis_x_inverted;
5786
+ // need to add offset to original value for 'category' type
5787
+ var domain = domainValue.map(function (v, i) { return Number(v) + (i === 0 ? +isInverted_1 : +!isInverted_1); });
5788
+ return domain;
5789
+ }
5790
+ return domainValue;
5791
+ },
5707
5792
  /**
5708
5793
  * Converts pixels to axis' scale values
5709
5794
  * @param {string} type Axis type
@@ -5734,6 +5819,7 @@ var domain = {
5734
5819
  * @private
5735
5820
  */
5736
5821
  withinRange: function (domain, current, range) {
5822
+ if (current === void 0) { current = [0, 0]; }
5737
5823
  var $$ = this;
5738
5824
  var isInverted = $$.config.axis_x_inverted;
5739
5825
  var _a = range, min = _a[0], max = _a[1];
@@ -5847,6 +5933,20 @@ function getLegendColor(id) {
5847
5933
  $$.color(data);
5848
5934
  return color;
5849
5935
  }
5936
+ /**
5937
+ * Get formatted text value
5938
+ * @param {string} id Legend text id
5939
+ * @returns {string} Formatted legend text
5940
+ */
5941
+ function getFormattedText(id) {
5942
+ var _a;
5943
+ var config = this.config;
5944
+ var text = (_a = config.data_names[id]) !== null && _a !== void 0 ? _a : id;
5945
+ if (isFunction(config.legend_format)) {
5946
+ text = config.legend_format(text);
5947
+ }
5948
+ return text;
5949
+ }
5850
5950
  var legend$1 = {
5851
5951
  /**
5852
5952
  * Initialize the legend.
@@ -6299,9 +6399,14 @@ var legend$1 = {
6299
6399
  .attr("class", $LEGEND.legendBackground)
6300
6400
  .append("rect");
6301
6401
  }
6402
+ if (config.legend_tooltip) {
6403
+ legend.selectAll("title")
6404
+ .data(targetIdz)
6405
+ .text(function (id) { return id; });
6406
+ }
6302
6407
  var texts = legend.selectAll("text")
6303
6408
  .data(targetIdz)
6304
- .text(function (id) { return (isDefined(config.data_names[id]) ? config.data_names[id] : id); }) // MEMO: needed for update
6409
+ .text(getFormattedText.bind($$)) // MEMO: needed for update
6305
6410
  .each(function (id, i) {
6306
6411
  updatePositions(this, id, i);
6307
6412
  });
@@ -6427,8 +6532,11 @@ var legend$1 = {
6427
6532
  .enter()
6428
6533
  .append("g");
6429
6534
  $$.setLegendItem(l);
6535
+ if (config.legend_tooltip) {
6536
+ l.append("title").text(function (id) { return id; });
6537
+ }
6430
6538
  l.append("text")
6431
- .text(function (id) { return (isDefined(config.data_names[id]) ? config.data_names[id] : id); })
6539
+ .text(getFormattedText.bind($$))
6432
6540
  .each(function (id, i) {
6433
6541
  updatePositions(this, id, i);
6434
6542
  })
@@ -6794,8 +6902,8 @@ function getScale(type, min, max) {
6794
6902
  var scale = {
6795
6903
  /**
6796
6904
  * Get x Axis scale function
6797
- * @param {number} min Min value
6798
- * @param {number} max Max value
6905
+ * @param {number} min Min range value
6906
+ * @param {number} max Max range value
6799
6907
  * @param {Array} domain Domain value
6800
6908
  * @param {Function} offset The offset getter to be sum
6801
6909
  * @returns {Function} scale
@@ -6803,7 +6911,7 @@ var scale = {
6803
6911
  */
6804
6912
  getXScale: function (min, max, domain, offset) {
6805
6913
  var $$ = this;
6806
- var scale = $$.scale.zoom || getScale($$.axis.getAxisType("x"), min, max);
6914
+ var scale = ($$.state.loading !== "append" && $$.scale.zoom) || getScale($$.axis.getAxisType("x"), min, max);
6807
6915
  return $$.getCustomizedXScale(domain ? scale.domain(domain) : scale, offset);
6808
6916
  },
6809
6917
  /**
@@ -7652,7 +7760,7 @@ var size = {
7652
7760
  * @private
7653
7761
  */
7654
7762
  updateSizes: function (isInit) {
7655
- var _a, _b, _c;
7763
+ var _a, _b, _c, _d, _e;
7656
7764
  var $$ = this;
7657
7765
  var config = $$.config, state = $$.state, legend = $$.$el.legend;
7658
7766
  var isRotated = config.axis_rotated;
@@ -7687,7 +7795,7 @@ var size = {
7687
7795
  bottom: legendSize.bottom + padding.bottom,
7688
7796
  left: subchartHeight + (isNonAxis ? 0 : padding.left)
7689
7797
  } : {
7690
- top: (isFitPadding ? 0 : 4) + padding.top,
7798
+ top: (isFitPadding ? 0 : 4) + padding.top, // for top tick text
7691
7799
  right: isNonAxis ? 0 : padding.right + legendSize.right,
7692
7800
  bottom: gaugeHeight + subchartHeight + legendSize.bottom + padding.bottom,
7693
7801
  left: isNonAxis ? 0 : padding.left
@@ -7735,12 +7843,24 @@ var size = {
7735
7843
  if ($$.hasArcType()) {
7736
7844
  var hasGauge = $$.hasType("gauge");
7737
7845
  var isLegendRight = config.legend_show && state.isLegendRight;
7738
- state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0);
7846
+ var textWidth = (_c = (state.hasRadar && $$.cache.get(KEY.radarTextWidth))) !== null && _c !== void 0 ? _c : 0;
7847
+ state.arcWidth = state.width - (isLegendRight ? currLegend.width + 10 : 0) - textWidth;
7739
7848
  state.arcHeight = state.height - (isLegendRight && !hasGauge ? 0 : 10);
7849
+ if ((_d = config.arc_rangeText_values) === null || _d === void 0 ? void 0 : _d.length) {
7850
+ if (hasGauge) {
7851
+ state.arcWidth -= 25;
7852
+ state.arcHeight -= 10;
7853
+ state.margin.left += 10;
7854
+ }
7855
+ else {
7856
+ state.arcHeight -= 20;
7857
+ state.margin.top += 10;
7858
+ }
7859
+ }
7740
7860
  if (hasGauge && !config.gauge_fullCircle) {
7741
7861
  state.arcHeight += state.height - $$.getPaddingBottomForGauge();
7742
7862
  }
7743
- (_c = $$.updateRadius) === null || _c === void 0 ? void 0 : _c.call($$);
7863
+ (_e = $$.updateRadius) === null || _e === void 0 ? void 0 : _e.call($$);
7744
7864
  }
7745
7865
  if (state.isLegendRight && isNonAxis) {
7746
7866
  state.margin3.left = state.arcWidth / 2 + state.radiusExpanded * 1.1;
@@ -8681,6 +8801,7 @@ var tooltip$1 = {
8681
8801
  var width = state.width, height = state.height, current = state.current, isLegendRight = state.isLegendRight, inputType = state.inputType;
8682
8802
  var hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
8683
8803
  var hasTreemap = state.hasTreemap;
8804
+ var hasRadar = state.hasRadar;
8684
8805
  var isRotated = config.axis_rotated;
8685
8806
  var hasArcType = $$.hasArcType();
8686
8807
  var svgLeft = $$.getSvgLeft(true);
@@ -8688,14 +8809,21 @@ var tooltip$1 = {
8688
8809
  var size = 20;
8689
8810
  var x = currPos.x, y = currPos.y;
8690
8811
  // Determine tooltip position
8691
- if (hasArcType) {
8692
- var raw = inputType === "touch" || $$.hasType("radar");
8812
+ if (hasRadar) {
8813
+ x += x >= (width / 2) ? 15 : -(tWidth + 15);
8814
+ y += 15;
8815
+ }
8816
+ else if (hasArcType) {
8817
+ var raw = inputType === "touch";
8693
8818
  if (!raw) {
8694
8819
  x += (width - (isLegendRight ? $$.getLegendWidth() : 0)) / 2;
8695
- y += hasGauge ? height : height / 2;
8820
+ y += hasGauge ? height : (height / 2) + tHeight;
8696
8821
  }
8697
8822
  }
8698
- else if (!hasTreemap) {
8823
+ else if (hasTreemap) {
8824
+ y += tHeight;
8825
+ }
8826
+ else {
8699
8827
  var padding = {
8700
8828
  top: $$.getCurrentPaddingByDirection("top", true),
8701
8829
  left: $$.getCurrentPaddingByDirection("left", true)
@@ -8715,8 +8843,8 @@ var tooltip$1 = {
8715
8843
  x -= tWidth + (hasTreemap || hasArcType ? 0 : (isRotated ? size * 2 : 38));
8716
8844
  }
8717
8845
  if (y + tHeight > current.height) {
8718
- var gap = hasTreemap ? 0 : 30;
8719
- y -= hasGauge ? tHeight * 3 : tHeight + gap;
8846
+ var gap = hasTreemap ? tHeight + 10 : 30;
8847
+ y -= hasGauge ? tHeight * 1.5 : tHeight + gap;
8720
8848
  }
8721
8849
  var pos = { top: y, left: x };
8722
8850
  // make sure to not be positioned out of viewport
@@ -8895,6 +9023,7 @@ var tooltip$1 = {
8895
9023
  */
8896
9024
  var transform = {
8897
9025
  getTranslate: function (target, index) {
9026
+ var _a;
8898
9027
  if (index === void 0) { index = 0; }
8899
9028
  var $$ = this;
8900
9029
  var config = $$.config, state = $$.state;
@@ -8936,15 +9065,18 @@ var transform = {
8936
9065
  else if (target === "arc") {
8937
9066
  x = state.arcWidth / 2;
8938
9067
  y = state.arcHeight / 2;
9068
+ if ((_a = config.arc_rangeText_values) === null || _a === void 0 ? void 0 : _a.length) {
9069
+ y += 5 + ($$.hasType("gauge") && config.title_text ? 10 : 0);
9070
+ }
8939
9071
  }
8940
9072
  else if (target === "polar") {
8941
9073
  x = state.arcWidth / 2;
8942
9074
  y = state.arcHeight / 2;
8943
9075
  }
8944
9076
  else if (target === "radar") {
8945
- var width = $$.getRadarSize()[0];
9077
+ var _b = $$.getRadarSize(), width = _b[0], height = _b[1];
8946
9078
  x = state.width / 2 - width;
8947
- y = asHalfPixel(state.margin.top);
9079
+ y = state.height / 2 - height;
8948
9080
  }
8949
9081
  return "translate(".concat(x, ", ").concat(y, ")");
8950
9082
  },
@@ -9089,8 +9221,9 @@ var typeInternals = {
9089
9221
  * @private
9090
9222
  */
9091
9223
  isTypeOf: function (d, type) {
9224
+ var _a;
9092
9225
  var id = isString(d) ? d : d.id;
9093
- var dataType = this.config.data_types[id] || this.config.data_type;
9226
+ var dataType = this.config && (((_a = this.config.data_types) === null || _a === void 0 ? void 0 : _a[id]) || this.config.data_type);
9094
9227
  return isArray(type) ?
9095
9228
  type.indexOf(dataType) >= 0 : dataType === type;
9096
9229
  },
@@ -9264,8 +9397,8 @@ var ChartInternal = /** @class */ (function () {
9264
9397
  this.format = {
9265
9398
  extraLineClasses: null,
9266
9399
  xAxisTick: null,
9267
- dataTime: null,
9268
- defaultAxisTime: null,
9400
+ dataTime: null, // dataTimeFormat
9401
+ defaultAxisTime: null, // defaultAxisTimeFormat
9269
9402
  axisTime: null // axisTimeFormat
9270
9403
  };
9271
9404
  var $$ = this;
@@ -9510,7 +9643,7 @@ var ChartInternal = /** @class */ (function () {
9510
9643
  config.data_labels_backgroundColors) {
9511
9644
  $el.defs = $el.svg.append("defs");
9512
9645
  if (hasAxis) {
9513
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
9646
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach(function (v) {
9514
9647
  $$.appendClip($el.defs, state.clip[v]);
9515
9648
  });
9516
9649
  }
@@ -12553,6 +12686,7 @@ var AxisRenderer = /** @class */ (function () {
12553
12686
  var r2 = r / (orient === "bottom" ? 15 : 23);
12554
12687
  return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
12555
12688
  };
12689
+ var _b = this.params.owner.config, isRotated = _b.axis_rotated, inner = _b.axis_x_tick_text_inner;
12556
12690
  switch (orient) {
12557
12691
  case "bottom":
12558
12692
  lineUpdate
@@ -12563,6 +12697,16 @@ var AxisRenderer = /** @class */ (function () {
12563
12697
  .attr("x", 0)
12564
12698
  .attr("y", yForText(rotate))
12565
12699
  .style("text-anchor", textAnchorForText(rotate))
12700
+ .style("text-anchor", function (d, i, _a) {
12701
+ var length = _a.length;
12702
+ if (!isRotated && i === 0 && (inner === true || inner.first)) {
12703
+ return "start";
12704
+ }
12705
+ else if (!isRotated && i === length - 1 && (inner === true || inner.last)) {
12706
+ return "end";
12707
+ }
12708
+ return textAnchorForText(rotate);
12709
+ })
12566
12710
  .attr("transform", textTransform(rotate));
12567
12711
  break;
12568
12712
  case "top":
@@ -13282,7 +13426,7 @@ var Axis = /** @class */ (function () {
13282
13426
  };
13283
13427
  Axis.prototype.getXAxisTickTextY2Overflow = function (defaultPadding) {
13284
13428
  var $$ = this.owner;
13285
- var axis = $$.axis, config = $$.config, state = $$.state;
13429
+ var axis = $$.axis, config = $$.config, _a = $$.state, current = _a.current, isLegendRight = _a.isLegendRight, legendItemWidth = _a.legendItemWidth;
13286
13430
  var xAxisTickRotate = $$.getAxisTickRotate("x");
13287
13431
  var positiveRotation = xAxisTickRotate > 0 && xAxisTickRotate < 90;
13288
13432
  if ((axis.isCategorized() || axis.isTimeSeries()) &&
@@ -13290,8 +13434,10 @@ var Axis = /** @class */ (function () {
13290
13434
  (!config.axis_x_tick_culling || isEmpty(config.axis_x_tick_culling)) &&
13291
13435
  !config.axis_x_tick_multiline &&
13292
13436
  positiveRotation) {
13293
- var widthWithoutCurrentPaddingLeft = state.current.width - $$.getCurrentPaddingByDirection("left");
13294
- var maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding);
13437
+ var y2AxisWidth = (config.axis_y2_show && current.maxTickSize.y2.width) || 0;
13438
+ var legendWidth = (isLegendRight && legendItemWidth) || 0;
13439
+ var widthWithoutCurrentPaddingLeft = current.width - $$.getCurrentPaddingByDirection("left");
13440
+ var maxOverflow = this.getXAxisTickMaxOverflow(xAxisTickRotate, widthWithoutCurrentPaddingLeft - defaultPadding) - y2AxisWidth - legendWidth;
13295
13441
  var xAxisTickTextY2Overflow = Math.max(0, maxOverflow) +
13296
13442
  defaultPadding; // for display inconsistencies between browsers
13297
13443
  return Math.min(xAxisTickTextY2Overflow, widthWithoutCurrentPaddingLeft / 2);
@@ -13704,7 +13850,14 @@ var eventrect = {
13704
13850
  var eventReceiver = state.eventReceiver, width = state.width, height = state.height, rendered = state.rendered, resizing = state.resizing;
13705
13851
  var rectElement = eventRect || $el.eventRect;
13706
13852
  var updateClientRect = function () {
13707
- eventReceiver && (eventReceiver.rect = rectElement.node().getBoundingClientRect());
13853
+ if (eventReceiver) {
13854
+ var scrollPos = getScrollPosition($el.chart.node());
13855
+ eventReceiver.rect = rectElement.node()
13856
+ .getBoundingClientRect()
13857
+ .toJSON();
13858
+ eventReceiver.rect.top += scrollPos.y;
13859
+ eventReceiver.rect.left += scrollPos.x;
13860
+ }
13708
13861
  };
13709
13862
  if (!rendered || resizing || force) {
13710
13863
  rectElement
@@ -14665,9 +14818,9 @@ var grid = {
14665
14818
  // will contain 'x1, y1, x2, y2' order
14666
14819
  xy = isRotated ?
14667
14820
  [
14668
- null,
14669
- pos.x,
14670
- isEdge ? pos.y : width,
14821
+ null, // x1
14822
+ pos.x, // y1
14823
+ isEdge ? pos.y : width, // x2
14671
14824
  pos.x // y2
14672
14825
  ] : [
14673
14826
  pos.x,
@@ -14680,9 +14833,9 @@ var grid = {
14680
14833
  var isY2 = $$.axis.getId(d.id) === "y2";
14681
14834
  xy = isRotated ?
14682
14835
  [
14683
- pos.y,
14684
- isEdge && !isY2 ? pos.x : null,
14685
- pos.y,
14836
+ pos.y, // x1
14837
+ isEdge && !isY2 ? pos.x : null, // y1
14838
+ pos.y, // x2
14686
14839
  isEdge && isY2 ? pos.x : height // y2
14687
14840
  ] : [
14688
14841
  isEdge && isY2 ? pos.x : null,
@@ -14982,7 +15135,8 @@ var sizeAxis = {
14982
15135
  return isFitPadding ? 0 : rotatedPadding.top;
14983
15136
  }
14984
15137
  var maxtickSize = $$.axis.getMaxTickSize(id);
14985
- if (maxtickSize.height > defaultHeight) {
15138
+ var isXAxisTickRotated = config.axis_x_tick_rotate > 0 && (!config.axis_x_tick_autorotate || $$.needToRotateXAxisTickTexts());
15139
+ if ((config.axis_x_tick_multiline || isXAxisTickRotated) && maxtickSize.height > defaultHeight) {
14986
15140
  h += maxtickSize.height - defaultHeight;
14987
15141
  }
14988
15142
  return h +
@@ -15046,8 +15200,9 @@ var sizeAxis = {
15046
15200
  */
15047
15201
  needToRotateXAxisTickTexts: function () {
15048
15202
  var $$ = this;
15049
- var _a = $$.state, axis = _a.axis, current = _a.current;
15050
- var xAxisLength = current.width -
15203
+ var _a = $$.state, axis = _a.axis, current = _a.current, isLegendRight = _a.isLegendRight, legendItemWidth = _a.legendItemWidth;
15204
+ var legendWidth = isLegendRight && legendItemWidth;
15205
+ var xAxisLength = current.width - legendWidth -
15051
15206
  $$.getCurrentPaddingByDirection("left") - $$.getCurrentPaddingByDirection("right");
15052
15207
  var tickCountWithPadding = axis.x.tickCount +
15053
15208
  axis.x.padding.left + axis.x.padding.right;
@@ -15448,6 +15603,31 @@ var x = {
15448
15603
  * }
15449
15604
  */
15450
15605
  axis_x_tick_text_show: true,
15606
+ /**
15607
+ * Set the first/last axis tick text to be positioned inside of the chart on non-rotated axis.
15608
+ * @name axis․x․tick․text․inner
15609
+ * @memberof Options
15610
+ * @type {boolean|object}
15611
+ * @default false
15612
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.XAxisTickInner)
15613
+ * @example
15614
+ * axis: {
15615
+ * x: {
15616
+ * tick: {
15617
+ * text: {
15618
+ * inner: true,
15619
+ *
15620
+ * // or specify each position of the first and last tick text
15621
+ * inner: {
15622
+ * first: true,
15623
+ * last: true
15624
+ * }
15625
+ * }
15626
+ * }
15627
+ * }
15628
+ * }
15629
+ */
15630
+ axis_x_tick_text_inner: false,
15451
15631
  /**
15452
15632
  * Set the x Axis tick text's position relatively its original position
15453
15633
  * @name axis․x․tick․text․position
@@ -15624,7 +15804,7 @@ var x = {
15624
15804
  */
15625
15805
  axis_x_tick_width: null,
15626
15806
  /**
15627
- * Set to display system tooltip(via 'title' attribute) for tick text
15807
+ * Set to display system tooltip(via `<title>` element) for tick text
15628
15808
  * - **NOTE:** Only available for category axis type (`axis.x.type='category'`)
15629
15809
  * @name axis․x․tick․tooltip
15630
15810
  * @memberof Options
@@ -16369,6 +16549,18 @@ var y = {
16369
16549
  * y2 Axis config options
16370
16550
  */
16371
16551
  var y2 = {
16552
+ /**
16553
+ * Set clip-path attribute for y2 axis element
16554
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
16555
+ * @name axis․y2․clipPath
16556
+ * @memberof Options
16557
+ * @type {boolean}
16558
+ * @default true
16559
+ * @example
16560
+ * // don't set 'clip-path' attribute
16561
+ * clipPath: false
16562
+ */
16563
+ axis_y2_clipPath: true,
16372
16564
  /**
16373
16565
  * Show or hide y2 axis.
16374
16566
  * - **NOTE**:
@@ -17050,7 +17242,7 @@ var shapeArc = {
17050
17242
  .startAngle(startingAngle)
17051
17243
  .endAngle(startingAngle + (2 * Math.PI))
17052
17244
  .padAngle(padAngle)
17053
- .value(function (d) { return d.values.reduce(function (a, b) { return a + b.value; }, 0); })
17245
+ .value(function (d) { var _a, _b; return (_b = (_a = d.values) === null || _a === void 0 ? void 0 : _a.reduce(function (a, b) { return a + b.value; }, 0)) !== null && _b !== void 0 ? _b : d; })
17054
17246
  .sort($$.getSortCompareFn.bind($$)(true));
17055
17247
  },
17056
17248
  updateRadius: function () {
@@ -17114,13 +17306,14 @@ var shapeArc = {
17114
17306
  }
17115
17307
  return len * Math.PI;
17116
17308
  },
17117
- getGaugeStartAngle: function () {
17309
+ getStartingAngle: function () {
17118
17310
  var $$ = this;
17119
17311
  var config = $$.config;
17120
- var isFullCircle = config.gauge_fullCircle;
17312
+ var dataType = config.data_type;
17313
+ var isFullCircle = $$.hasType("gauge") ? config.gauge_fullCircle : false;
17121
17314
  var defaultStartAngle = -1 * Math.PI / 2;
17122
17315
  var defaultEndAngle = Math.PI / 2;
17123
- var startAngle = config.gauge_startingAngle;
17316
+ var startAngle = config["".concat(dataType, "_startingAngle")] || 0;
17124
17317
  if (!isFullCircle && startAngle <= defaultStartAngle) {
17125
17318
  startAngle = defaultStartAngle;
17126
17319
  }
@@ -17132,51 +17325,67 @@ var shapeArc = {
17132
17325
  }
17133
17326
  return startAngle;
17134
17327
  },
17135
- updateAngle: function (dValue) {
17328
+ /**
17329
+ * Update angle data
17330
+ * @param {object} dValue Data object
17331
+ * @param {boolean} forRange Weather is for ranged text option(arc.rangeText.values)
17332
+ * @returns {object|null} Updated angle data
17333
+ * @private
17334
+ */
17335
+ updateAngle: function (dValue, forRange) {
17336
+ var _a;
17337
+ if (forRange === void 0) { forRange = false; }
17136
17338
  var $$ = this;
17137
17339
  var config = $$.config, state = $$.state;
17340
+ var hasGauge = forRange && $$.hasType("gauge");
17341
+ // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
17342
+ // const totalSum = $$.getTotalDataSum(state.rendered);
17138
17343
  var pie = $$.pie;
17139
17344
  var d = dValue;
17140
17345
  var found = false;
17141
17346
  if (!config) {
17142
17347
  return null;
17143
17348
  }
17144
- var gStart = $$.getGaugeStartAngle();
17145
- var radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
17349
+ var gStart = $$.getStartingAngle();
17350
+ var radius = config.gauge_fullCircle || (forRange && !hasGauge) ?
17351
+ $$.getArcLength() : gStart * -2;
17146
17352
  if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
17147
- var min = config.gauge_min, max = config.gauge_max;
17353
+ var gMin = config.gauge_min, gMax = config.gauge_max;
17148
17354
  // to prevent excluding total data sum during the init(when data.hide option is used), use $$.rendered state value
17149
17355
  var totalSum = $$.getTotalDataSum(state.rendered);
17150
17356
  // https://github.com/naver/billboard.js/issues/2123
17151
- var gEnd = radius * ((totalSum - min) / (max - min));
17357
+ var gEnd = radius * ((totalSum - gMin) / (gMax - gMin));
17152
17358
  pie = pie
17153
17359
  .startAngle(gStart)
17154
17360
  .endAngle(gEnd + gStart);
17155
17361
  }
17156
- pie($$.filterTargetsToShow())
17157
- .forEach(function (t, i) {
17158
- var _a;
17159
- if (!found && t.data.id === ((_a = d.data) === null || _a === void 0 ? void 0 : _a.id)) {
17160
- found = true;
17161
- d = t;
17162
- d.index = i;
17163
- }
17164
- });
17362
+ if (forRange === false) {
17363
+ pie($$.filterTargetsToShow())
17364
+ .forEach(function (t, i) {
17365
+ var _a;
17366
+ if (!found && t.data.id === ((_a = d.data) === null || _a === void 0 ? void 0 : _a.id)) {
17367
+ found = true;
17368
+ d = t;
17369
+ d.index = i;
17370
+ }
17371
+ });
17372
+ }
17165
17373
  if (isNaN(d.startAngle)) {
17166
17374
  d.startAngle = 0;
17167
17375
  }
17168
17376
  if (isNaN(d.endAngle)) {
17169
17377
  d.endAngle = d.startAngle;
17170
17378
  }
17171
- if (d.data && $$.hasMultiArcGauge()) {
17172
- var gMin = config.gauge_min;
17173
- var gMax = config.gauge_max;
17174
- var gTic = radius / (gMax - gMin);
17175
- var gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin);
17379
+ if (forRange || (d.data && (config.gauge_enforceMinMax || $$.hasMultiArcGauge()))) {
17380
+ var gMin = config.gauge_min, gMax = config.gauge_max;
17381
+ var max = forRange && !hasGauge ? $$.getTotalDataSum(state.rendered) : gMax;
17382
+ var gTic = radius / (max - gMin);
17383
+ var value = (_a = d.value) !== null && _a !== void 0 ? _a : 0;
17384
+ var gValue = value < gMin ? 0 : value < max ? value - gMin : (max - gMin);
17176
17385
  d.startAngle = gStart;
17177
17386
  d.endAngle = gStart + gTic * gValue;
17178
17387
  }
17179
- return found ? d : null;
17388
+ return found || forRange ? d : null;
17180
17389
  },
17181
17390
  getSvgArc: function () {
17182
17391
  var $$ = this;
@@ -17225,23 +17434,70 @@ var shapeArc = {
17225
17434
  getArc: function (d, withoutUpdate, force) {
17226
17435
  return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
17227
17436
  },
17437
+ /**
17438
+ * Render range value text
17439
+ * @private
17440
+ */
17441
+ redrawArcRangeText: function () {
17442
+ var $$ = this;
17443
+ var config = $$.config, arcs = $$.$el.arcs, state = $$.state, $T = $$.$T;
17444
+ var format = config.arc_rangeText_format;
17445
+ var fixed = $$.hasType("gauge") && config.arc_rangeText_fixed;
17446
+ var values = config.arc_rangeText_values;
17447
+ if (values === null || values === void 0 ? void 0 : values.length) {
17448
+ var isPercent_1 = config.arc_rangeText_unit === "%";
17449
+ var totalSum_1 = $$.getTotalDataSum(state.rendered);
17450
+ if (isPercent_1) {
17451
+ values = values.map(function (v) { return totalSum_1 / 100 * v; });
17452
+ }
17453
+ var pieData_1 = $$.pie(values).map(function (d, i) { return ((d.index = i), d); });
17454
+ var rangeText = arcs.selectAll(".".concat($ARC.arcRange))
17455
+ .data(values);
17456
+ rangeText.exit();
17457
+ rangeText = $T(rangeText.enter()
17458
+ .append("text")
17459
+ .attr("class", $ARC.arcRange)
17460
+ .style("text-anchor", "middle")
17461
+ .style("pointer-events", "none")
17462
+ .style("opacity", "0")
17463
+ .text(function (v) {
17464
+ var range = isPercent_1 ? (v / totalSum_1 * 100) : v;
17465
+ return isFunction(format) ? format(range) : ("".concat(range).concat(isPercent_1 ? "%" : ""));
17466
+ })
17467
+ .merge(rangeText));
17468
+ if ((!state.rendered || (state.rendered && !fixed)) && totalSum_1 > 0) {
17469
+ rangeText.attr("transform", function (d, i) { return $$.transformForArcLabel(pieData_1[i], true); });
17470
+ }
17471
+ rangeText.style("opacity", function (d) { return (!fixed && (d > totalSum_1 || totalSum_1 === 0) ? "0" : null); });
17472
+ }
17473
+ },
17228
17474
  /**
17229
17475
  * Set transform attributes to arc label text
17230
17476
  * @param {object} d Data object
17477
+ * @param {boolean} forRange Weather is for ranged text option(arc.rangeText.values)
17231
17478
  * @returns {string} Translate attribute string
17232
17479
  * @private
17233
17480
  */
17234
- transformForArcLabel: function (d) {
17235
- var _a;
17481
+ transformForArcLabel: function (d, forRange) {
17482
+ var _a, _b, _c;
17483
+ if (forRange === void 0) { forRange = false; }
17236
17484
  var $$ = this;
17237
17485
  var config = $$.config, radiusExpanded = $$.state.radiusExpanded;
17238
- var updated = $$.updateAngle(d);
17486
+ var updated = $$.updateAngle(d, forRange);
17239
17487
  var translate = "";
17240
17488
  if (updated) {
17241
- if ($$.hasMultiArcGauge()) {
17489
+ if (forRange || $$.hasMultiArcGauge()) {
17242
17490
  var y1 = Math.sin(updated.endAngle - Math.PI / 2);
17243
- var x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + 25);
17491
+ var rangeTextPosition = config.arc_rangeText_position;
17492
+ var x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + (forRange ? 5 : 25));
17244
17493
  var y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
17494
+ if (forRange && rangeTextPosition) {
17495
+ var rangeValues = config.arc_rangeText_values;
17496
+ var pos = isFunction(rangeTextPosition) ?
17497
+ rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
17498
+ x += (_a = pos === null || pos === void 0 ? void 0 : pos.x) !== null && _a !== void 0 ? _a : 0;
17499
+ y += (_b = pos === null || pos === void 0 ? void 0 : pos.y) !== null && _b !== void 0 ? _b : 0;
17500
+ }
17245
17501
  translate = "translate(".concat(x, ",").concat(y, ")");
17246
17502
  }
17247
17503
  else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
@@ -17250,11 +17506,11 @@ var shapeArc = {
17250
17506
  outerRadius = $$.getPolarOuterRadius(d, outerRadius);
17251
17507
  }
17252
17508
  var c = this.svgArc.centroid(updated);
17253
- var _b = c.map(function (v) { return (isNaN(v) ? 0 : v); }), x = _b[0], y = _b[1];
17509
+ var _d = c.map(function (v) { return (isNaN(v) ? 0 : v); }), x = _d[0], y = _d[1];
17254
17510
  var h = Math.sqrt(x * x + y * y);
17255
- var ratio = (_a = ["donut", "pie", "polar"]
17511
+ var ratio = (_c = ["donut", "gauge", "pie", "polar"]
17256
17512
  .filter($$.hasType.bind($$))
17257
- .map(function (v) { return config["".concat(v, "_label_ratio")]; })) === null || _a === void 0 ? void 0 : _a[0];
17513
+ .map(function (v) { return config["".concat(v, "_label_ratio")]; })) === null || _c === void 0 ? void 0 : _c[0];
17258
17514
  if (ratio) {
17259
17515
  ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
17260
17516
  }
@@ -17510,7 +17766,7 @@ var shapeArc = {
17510
17766
  .merge(mainArc);
17511
17767
  if ($$.hasType("gauge")) {
17512
17768
  $$.updateGaugeMax();
17513
- $$.hasMultiArcGauge() && $$.redrawMultiArcGauge();
17769
+ $$.hasMultiArcGauge() && $$.redrawArcGaugeLine();
17514
17770
  }
17515
17771
  mainArc
17516
17772
  .attr("transform", function (d) { return (!$$.isGaugeType(d.data) && withTransform ? "scale(0)" : ""); })
@@ -17571,6 +17827,7 @@ var shapeArc = {
17571
17827
  $$.hasType("gauge") && $$.redrawBackgroundArcs();
17572
17828
  config.arc_needle_show && $$.redrawNeedle();
17573
17829
  $$.redrawArcText(duration);
17830
+ $$.redrawArcRangeText();
17574
17831
  },
17575
17832
  /**
17576
17833
  * Update needle element
@@ -17654,7 +17911,7 @@ var shapeArc = {
17654
17911
  }
17655
17912
  state.current.needle = value;
17656
17913
  if (hasGauge) {
17657
- startingAngle = $$.getGaugeStartAngle();
17914
+ startingAngle = $$.getStartingAngle();
17658
17915
  var radius = config.gauge_fullCircle ? arcLength : startingAngle * -2;
17659
17916
  var min = config.gauge_min, max = config.gauge_max;
17660
17917
  radian = radius * ((value - min) / (max - min));
@@ -17671,7 +17928,7 @@ var shapeArc = {
17671
17928
  var isFullCircle = config.gauge_fullCircle;
17672
17929
  var showEmptyTextLabel = $$.filterTargetsToShow($$.data.targets).length === 0 &&
17673
17930
  !!config.data_empty_label_text;
17674
- var startAngle = $$.getGaugeStartAngle();
17931
+ var startAngle = $$.getStartingAngle();
17675
17932
  var endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
17676
17933
  var backgroundArc = $$.$el.arcs.select("".concat(hasMultiArcGauge ? "g" : "", ".").concat($ARC.chartArcsBackground));
17677
17934
  if (hasMultiArcGauge) {
@@ -17811,7 +18068,7 @@ var shapeArc = {
17811
18068
  .style("opacity", "0")
17812
18069
  .attr("class", function (d) { return ($$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null); })
17813
18070
  .call($$.textForArcLabel.bind($$))
17814
- .attr("transform", $$.transformForArcLabel.bind($$))
18071
+ .attr("transform", function (d) { return $$.transformForArcLabel.bind($$)(d); })
17815
18072
  .style("font-size", function (d) { return ($$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ?
17816
18073
  "".concat(Math.round(state.radius / 5), "px") : null); })
17817
18074
  .transition()
@@ -18005,7 +18262,7 @@ var shapeArea = {
18005
18262
  return [
18006
18263
  [posX, offset],
18007
18264
  [posX, posY - (y0 - offset)],
18008
- [posX, posY - (y0 - offset)],
18265
+ [posX, posY - (y0 - offset)], // needed for compatibility
18009
18266
  [posX, offset] // needed for compatibility
18010
18267
  ];
18011
18268
  };
@@ -18457,11 +18714,14 @@ var shapeGauge = {
18457
18714
  initGauge: function () {
18458
18715
  var $$ = this;
18459
18716
  var config = $$.config, arcs = $$.$el.arcs;
18460
- var appendText = function (className) {
18717
+ var appendText = function (className, value) {
18718
+ if (className === void 0) { className = null; }
18719
+ if (value === void 0) { value = ""; }
18461
18720
  arcs.append("text")
18462
18721
  .attr("class", className)
18463
18722
  .style("text-anchor", "middle")
18464
- .style("pointer-events", "none");
18723
+ .style("pointer-events", "none")
18724
+ .text(value);
18465
18725
  };
18466
18726
  if ($$.hasType("gauge")) {
18467
18727
  var hasMulti = $$.hasMultiArcGauge();
@@ -18469,6 +18729,7 @@ var shapeGauge = {
18469
18729
  .attr("class", $ARC.chartArcsBackground)
18470
18730
  .style("fill", (!hasMulti && config.gauge_background) || null);
18471
18731
  config.gauge_units && appendText($GAUGE.chartArcsGaugeUnit);
18732
+ // append min/max value text
18472
18733
  if (config.gauge_label_show) {
18473
18734
  appendText($GAUGE.chartArcsGaugeMin);
18474
18735
  !config.gauge_fullCircle && appendText($GAUGE.chartArcsGaugeMax);
@@ -18483,11 +18744,11 @@ var shapeGauge = {
18483
18744
  var max = hasMultiGauge ?
18484
18745
  $$.getMinMaxData().max[0].value : $$.getTotalDataSum(state.rendered);
18485
18746
  // if gauge_max less than max, make max to max value
18486
- if (max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max) {
18747
+ if (!config.gauge_enforceMinMax && (max + config.gauge_min * (config.gauge_min > 0 ? -1 : 1) > config.gauge_max)) {
18487
18748
  config.gauge_max = max - config.gauge_min;
18488
18749
  }
18489
18750
  },
18490
- redrawMultiArcGauge: function () {
18751
+ redrawArcGaugeLine: function () {
18491
18752
  var $$ = this;
18492
18753
  var config = $$.config, state = $$.state, $el = $$.$el;
18493
18754
  var hiddenTargetIds = $$.state.hiddenTargetIds;
@@ -19260,7 +19521,7 @@ var shapePoint = {
19260
19521
  var point = [posX, posY - (y0 - offset)];
19261
19522
  return [
19262
19523
  point,
19263
- point,
19524
+ point, // from here and below, needed for compatibility
19264
19525
  point,
19265
19526
  point
19266
19527
  ];
@@ -19518,7 +19779,8 @@ function getPosition(isClockwise, type, edge, pos, range, ratio) {
19518
19779
  return range * (1 - ratio * func(index * r / edge));
19519
19780
  }
19520
19781
  // cache key
19521
- var cacheKey = KEY.radarPoints;
19782
+ var cacheKeyPoints = KEY.radarPoints;
19783
+ var cacheKeyTextWidth = KEY.radarTextWidth;
19522
19784
  var shapeRadar = {
19523
19785
  initRadar: function () {
19524
19786
  var $$ = this;
@@ -19536,13 +19798,19 @@ var shapeRadar = {
19536
19798
  $el.radar.shapes = $el.radar.append("g")
19537
19799
  .attr("class", $SHAPE.shapes);
19538
19800
  current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
19801
+ if (config.radar_axis_text_show) {
19802
+ config.interaction_enabled && $$.bindRadarEvent();
19803
+ // it needs to calculate dimension at the initialization
19804
+ $$.updateRadarLevel();
19805
+ $$.updateRadarAxes();
19806
+ }
19539
19807
  }
19540
19808
  },
19541
19809
  getRadarSize: function () {
19542
19810
  var $$ = this;
19543
19811
  var config = $$.config, _a = $$.state, arcWidth = _a.arcWidth, arcHeight = _a.arcHeight;
19544
19812
  var padding = config.axis_x_categories.length < 4 ? -20 : 10;
19545
- var size = (Math.min(arcWidth, arcHeight) - padding) / 2;
19813
+ var size = ((Math.min(arcWidth, arcHeight) - padding) / 2);
19546
19814
  return [size, size];
19547
19815
  },
19548
19816
  updateTargetsForRadar: function (targets) {
@@ -19570,7 +19838,7 @@ var shapeRadar = {
19570
19838
  var $$ = this;
19571
19839
  var targets = $$.data.targets;
19572
19840
  var _a = $$.getRadarSize(), width = _a[0], height = _a[1];
19573
- var points = $$.cache.get(cacheKey) || {};
19841
+ var points = $$.cache.get(cacheKeyPoints) || {};
19574
19842
  var size = points._size;
19575
19843
  // recalculate position only when the previous dimension has been changed
19576
19844
  if (!size || (size.width !== width && size.height !== height)) {
@@ -19578,7 +19846,7 @@ var shapeRadar = {
19578
19846
  points[d.id] = d.values.map(function (v, i) { return ($$.getRadarPosition(["x", "y"], i, undefined, $$.getRatio("radar", v))); });
19579
19847
  });
19580
19848
  points._size = { width: width, height: height };
19581
- $$.cache.add(cacheKey, points);
19849
+ $$.cache.add(cacheKeyPoints, points);
19582
19850
  }
19583
19851
  },
19584
19852
  redrawRadar: function () {
@@ -19596,7 +19864,7 @@ var shapeRadar = {
19596
19864
  }
19597
19865
  },
19598
19866
  generateGetRadarPoints: function () {
19599
- var points = this.cache.get(cacheKey);
19867
+ var points = this.cache.get(cacheKeyPoints);
19600
19868
  return function (d, i) {
19601
19869
  var point = points[d.id][i];
19602
19870
  return [
@@ -19683,6 +19951,7 @@ var shapeRadar = {
19683
19951
  // axis text
19684
19952
  if (config.radar_axis_text_show) {
19685
19953
  var _b = config.radar_axis_text_position, _c = _b.x, x_1 = _c === void 0 ? 0 : _c, _d = _b.y, y_1 = _d === void 0 ? 0 : _d;
19954
+ var textWidth = $$.cache.get(cacheKeyTextWidth) || 0;
19686
19955
  axis.select("text")
19687
19956
  .style("text-anchor", "middle")
19688
19957
  .attr("dy", ".5em")
@@ -19717,54 +19986,57 @@ var shapeRadar = {
19717
19986
  }
19718
19987
  return "translate(".concat(posX, " ").concat(posY, ")");
19719
19988
  });
19989
+ if (!textWidth) {
19990
+ var widths = [radar.axes, radar.levels].map(function (v) { return getPathBox(v.node()).width; });
19991
+ if (widths.every(function (v) { return v > 0; })) {
19992
+ $$.cache.add(cacheKeyTextWidth, widths[0] - widths[1]);
19993
+ }
19994
+ }
19720
19995
  }
19721
- $$.bindRadarEvent();
19722
19996
  },
19723
19997
  bindRadarEvent: function () {
19724
19998
  var $$ = this;
19725
- var config = $$.config, state = $$.state, _a = $$.$el, radar = _a.radar, svg = _a.svg;
19999
+ var state = $$.state, _a = $$.$el, radar = _a.radar, svg = _a.svg;
19726
20000
  var focusOnly = $$.isPointFocusOnly();
19727
20001
  var inputType = state.inputType, transiting = state.transiting;
19728
- if (config.interaction_enabled) {
19729
- var isMouse_1 = inputType === "mouse";
19730
- var hide = function (event) {
19731
- state.event = event;
19732
- // const index = getIndex(event);
19733
- var index = $$.getDataIndexFromEvent(event);
19734
- var noIndex = isUndefined(index);
19735
- if (isMouse_1 || noIndex) {
19736
- $$.hideTooltip();
19737
- focusOnly ?
19738
- $$.hideCircleFocus() :
19739
- $$.unexpandCircles();
19740
- if (isMouse_1) {
19741
- $$.setOverOut(false, index);
19742
- }
19743
- else if (noIndex) {
19744
- $$.callOverOutForTouch();
19745
- }
20002
+ var isMouse = inputType === "mouse";
20003
+ var hide = function (event) {
20004
+ state.event = event;
20005
+ // const index = getIndex(event);
20006
+ var index = $$.getDataIndexFromEvent(event);
20007
+ var noIndex = isUndefined(index);
20008
+ if (isMouse || noIndex) {
20009
+ $$.hideTooltip();
20010
+ focusOnly ?
20011
+ $$.hideCircleFocus() :
20012
+ $$.unexpandCircles();
20013
+ if (isMouse) {
20014
+ $$.setOverOut(false, index);
19746
20015
  }
19747
- };
19748
- radar.axes.selectAll("text")
19749
- .on(isMouse_1 ? "mouseover " : "touchstart", function (event) {
19750
- if (transiting) { // skip while transiting
19751
- return;
20016
+ else if (noIndex) {
20017
+ $$.callOverOutForTouch();
19752
20018
  }
19753
- state.event = event;
19754
- var index = $$.getDataIndexFromEvent(event);
19755
- $$.selectRectForSingle(svg.node(), index);
19756
- isMouse_1 ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
19757
- })
19758
- .on("mouseout", isMouse_1 ? hide : null);
19759
- if (!isMouse_1) {
19760
- svg.on("touchstart", hide);
19761
20019
  }
20020
+ };
20021
+ radar.axes
20022
+ .on(isMouse ? "mouseover " : "touchstart", function (event) {
20023
+ if (transiting) { // skip while transiting
20024
+ return;
20025
+ }
20026
+ state.event = event;
20027
+ var index = $$.getDataIndexFromEvent(event);
20028
+ $$.selectRectForSingle(svg.node(), index);
20029
+ isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
20030
+ })
20031
+ .on("mouseout", isMouse ? hide : null);
20032
+ if (!isMouse) {
20033
+ svg.on("touchstart", hide);
19762
20034
  }
19763
20035
  },
19764
20036
  updateRadarShape: function () {
19765
20037
  var $$ = this;
19766
20038
  var targets = $$.data.targets.filter(function (d) { return $$.isRadarType(d); });
19767
- var points = $$.cache.get(cacheKey);
20039
+ var points = $$.cache.get(cacheKeyPoints);
19768
20040
  var areas = $$.$el.radar.shapes
19769
20041
  .selectAll("polygon")
19770
20042
  .data(targets);
@@ -19787,7 +20059,7 @@ var shapeRadar = {
19787
20059
  * @private
19788
20060
  */
19789
20061
  radarCircleX: function (d) {
19790
- return this.cache.get(cacheKey)[d.id][d.index][0];
20062
+ return this.cache.get(cacheKeyPoints)[d.id][d.index][0];
19791
20063
  },
19792
20064
  /**
19793
20065
  * Get data point y coordinate
@@ -19796,7 +20068,7 @@ var shapeRadar = {
19796
20068
  * @private
19797
20069
  */
19798
20070
  radarCircleY: function (d) {
19799
- return this.cache.get(cacheKey)[d.id][d.index][1];
20071
+ return this.cache.get(cacheKeyPoints)[d.id][d.index][1];
19800
20072
  }
19801
20073
  };
19802
20074
 
@@ -19832,7 +20104,7 @@ function convertDataToTreemapData(data) {
19832
20104
  var value = values[0].value;
19833
20105
  return {
19834
20106
  name: id,
19835
- id: id,
20107
+ id: id, // needed to keep compatibility on whole code logic
19836
20108
  value: value,
19837
20109
  ratio: $$.getRatio("treemap", values[0])
19838
20110
  };
@@ -20670,11 +20942,23 @@ var optArc = {
20670
20942
  * @property {number} [arc.needle.bottom.ry=1] Set needle bottom [ry radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
20671
20943
  * @property {number} [arc.needle.bottom.width=15] Set needle bottom width in pixel.
20672
20944
  * @property {number} [arc.needle.bottom.len=0] Set needle bottom length in pixel. Setting this value, will make bottom larger starting from center.
20945
+ * @property {object} [arc.rangeText] Set rangeText options.
20946
+ * @property {Array} [arc.rangeText.values] Set range text values to be shown around Arc.
20947
+ * - When `unit: 'absolute'`: Given values are treated as absolute values.
20948
+ * - When `unit: '%'`: Given values are treated as percentages.
20949
+ * @property {string} [arc.rangeText.unit="absolute"] Specify the range text unit.
20950
+ * - "absolute": Show absolute value
20951
+ * - "%": Show percentage value
20952
+ * @property {boolean} [arc.rangeText.fiexed=false] Set if range text shown will be fixed w/o data toggle update. Only available for gauge chart.
20953
+ * @property {Function} [arc.rangeText.format] Set format function for the range text.
20954
+ * @property {number} [arc.rangeText.position] Set position function or object for the range text.
20673
20955
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
20674
- * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
20675
20956
  * @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
20676
20957
  * @see [Demo: Donut needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
20677
- * @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/##GaugeChartOptions.GaugeNeedle)
20958
+ * @see [Demo: Donut RangeText](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
20959
+ * @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
20960
+ * @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeNeedle)
20961
+ * @see [Demo: Gauge RangeText](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeRangeText)
20678
20962
  * @example
20679
20963
  * arc: {
20680
20964
  * cornerRadius: 12,
@@ -20731,6 +21015,21 @@ var optArc = {
20731
21015
  * width: 10
20732
21016
  * len: 10
20733
21017
  * }
21018
+ * },
21019
+ *
21020
+ * rangeText: {
21021
+ * values: [15, 30, 50, 75, 95],
21022
+ * unit: "%",
21023
+ * fixed: false, // only available for gauge chart
21024
+ * format: function(v) {
21025
+ * return v === 15 ? "Fifteen" : v;
21026
+ * },
21027
+ *
21028
+ * position: function(v) {
21029
+ * return v === 15 ? {x: 20, y: 10} : null; // can return one props value also.
21030
+ * },
21031
+ * position: {x: 10, y: 15},
21032
+ * position: {x: 10}
20734
21033
  * }
20735
21034
  * }
20736
21035
  */
@@ -20747,7 +21046,12 @@ var optArc = {
20747
21046
  arc_needle_bottom_rx: 1,
20748
21047
  arc_needle_bottom_ry: 1,
20749
21048
  arc_needle_bottom_width: 15,
20750
- arc_needle_bottom_len: 0
21049
+ arc_needle_bottom_len: 0,
21050
+ arc_rangeText_values: undefined,
21051
+ arc_rangeText_unit: "absolute",
21052
+ arc_rangeText_fixed: false,
21053
+ arc_rangeText_format: undefined,
21054
+ arc_rangeText_position: undefined
20751
21055
  };
20752
21056
 
20753
21057
  /**
@@ -20854,16 +21158,20 @@ var optGauge = {
20854
21158
  * @property {boolean} [gauge.background=""] Set background color. (The `.bb-chart-arcs-background` element)
20855
21159
  * @property {boolean} [gauge.fullCircle=false] Show full circle as donut. When set to 'true', the max label will not be showed due to start and end points are same location.
20856
21160
  * @property {boolean} [gauge.label.show=true] Show or hide label on gauge.
21161
+ * @property {Function} [gauge.label.extents] Set customized min/max label text.
20857
21162
  * @property {Function} [gauge.label.format] Set formatter for the label on gauge. Label text can be multilined with `\n` character.<br>
20858
21163
  * Will pass following arguments to the given function:
20859
21164
  * - value {number}: absolute value
20860
21165
  * - ratio {number}: value's ratio
20861
21166
  * - id {string}: data's id value
20862
- * @property {Function} [gauge.label.extents] Set customized min/max label text.
21167
+ * @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
20863
21168
  * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
20864
21169
  * @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
20865
21170
  * @property {number} [gauge.expand.rate=0.98] Set expand rate.
20866
21171
  * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
21172
+ * @property {boolean} [gauge.enforceMinMax=false] Enforce to given min/max value.
21173
+ * - When `gauge.min=50` and given value is `30`, gauge will render as empty value.
21174
+ * - When `gauge.max=100` and given value is `120`, gauge will render till 100, not surpassing max value.
20867
21175
  * @property {number} [gauge.min=0] Set min value of the gauge.
20868
21176
  * @property {number} [gauge.max=100] Set max value of the gauge.
20869
21177
  * @property {number} [gauge.startingAngle=-1 * Math.PI / 2] Set starting angle where data draws.
@@ -20894,8 +21202,10 @@ var optGauge = {
20894
21202
  * - single
20895
21203
  * - multi
20896
21204
  * @property {number} [gauge.arcs.minWidth=5] Set minimal width of gauge arcs until the innerRadius disappears.
21205
+ * @see [Demo: enforceMinMax, min/max](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeMinMax)
20897
21206
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
20898
21207
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
21208
+ * @see [Demo: labelRatio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
20899
21209
  * @example
20900
21210
  * gauge: {
20901
21211
  * background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
@@ -20916,6 +21226,14 @@ var optGauge = {
20916
21226
  * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
20917
21227
  * // if data value is below than 0.1, text label will be hidden.
20918
21228
  * threshold: 0.1,
21229
+ *
21230
+ * // set ratio callback. Should return ratio value
21231
+ * ratio: function(d, radius, h) {
21232
+ * ...
21233
+ * return ratio;
21234
+ * },
21235
+ * // or set ratio number
21236
+ * ratio: 0.5
20919
21237
  * },
20920
21238
  *
20921
21239
  * // disable expand transition for interaction
@@ -20929,6 +21247,11 @@ var optGauge = {
20929
21247
  * rate: 1
20930
21248
  * },
20931
21249
  *
21250
+ * // enforce min/max value.
21251
+ * // when given value < min, will render as empty value.
21252
+ * // when value > max, will render to given max value not surpassing it.
21253
+ * enforceMinMax: true,
21254
+ *
20932
21255
  * min: -100,
20933
21256
  * max: 200,
20934
21257
  * type: "single" // or 'multi'
@@ -20949,9 +21272,11 @@ var optGauge = {
20949
21272
  gauge_background: "",
20950
21273
  gauge_fullCircle: false,
20951
21274
  gauge_label_show: true,
20952
- gauge_label_format: undefined,
20953
21275
  gauge_label_extents: undefined,
21276
+ gauge_label_format: undefined,
21277
+ gauge_label_ratio: undefined,
20954
21278
  gauge_label_threshold: 0,
21279
+ gauge_enforceMinMax: false,
20955
21280
  gauge_min: 0,
20956
21281
  gauge_max: 100,
20957
21282
  gauge_type: "single",
@@ -20982,8 +21307,8 @@ var optPie = {
20982
21307
  * @property {object} pie Pie object
20983
21308
  * @property {boolean} [pie.label.show=true] Show or hide label on each pie piece.
20984
21309
  * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
20985
- * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
20986
21310
  * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
21311
+ * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
20987
21312
  * @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
20988
21313
  * @property {number} [pie.expand.rate=0.98] Set expand rate.
20989
21314
  * @property {number} [pie.expand.duration=50] Set expand transition time in ms.
@@ -21054,8 +21379,8 @@ var optPie = {
21054
21379
  */
21055
21380
  pie_label_show: true,
21056
21381
  pie_label_format: undefined,
21057
- pie_label_threshold: 0.05,
21058
21382
  pie_label_ratio: undefined,
21383
+ pie_label_threshold: 0.05,
21059
21384
  pie_expand: {},
21060
21385
  pie_expand_rate: 0.98,
21061
21386
  pie_expand_duration: 50,
@@ -21642,10 +21967,8 @@ var apiSubchart = {
21642
21967
  // NOTE: declared funciton assigning to variable to prevent duplicated method generation in JSDoc.
21643
21968
  var zoom$1 = function (domainValue) {
21644
21969
  var _a;
21645
- var _b;
21646
21970
  var $$ = this.internal;
21647
- var $el = $$.$el, axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale, state = $$.state;
21648
- var isRotated = config.axis_rotated;
21971
+ var axis = $$.axis, config = $$.config, org = $$.org, scale = $$.scale, state = $$.state;
21649
21972
  var isCategorized = axis.isCategorized();
21650
21973
  var domain;
21651
21974
  if (config.zoom_enabled) {
@@ -21657,9 +21980,7 @@ var zoom$1 = function (domainValue) {
21657
21980
  var isWithinRange = $$.withinRange(domain, $$.getZoomDomain("zoom", true), $$.getZoomDomain("zoom"));
21658
21981
  if (isWithinRange) {
21659
21982
  state.domain = domain;
21660
- if (isCategorized) {
21661
- domain = domain.map(function (v, i) { return Number(v) + (i === 0 ? 0 : 1); });
21662
- }
21983
+ domain = $$.getZoomDomainValue(domain);
21663
21984
  // hide any possible tooltip show before the zoom
21664
21985
  $$.api.tooltip.hide();
21665
21986
  if (config.subchart_show) {
@@ -21670,14 +21991,7 @@ var zoom$1 = function (domainValue) {
21670
21991
  else {
21671
21992
  // in case of 'config.zoom_rescale=true', use org.xScale
21672
21993
  var x = isCategorized ? scale.x.orgScale() : (org.xScale || scale.x);
21673
- // Get transform from given domain value
21674
- // https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
21675
- var translate = [-x(domain[0]), 0];
21676
- var transform = (_a = zoomIdentity
21677
- .scale(x.range()[1] / (x(domain[1]) - x(domain[0]))))
21678
- .translate.apply(_a, (isRotated ? translate.reverse() : translate));
21679
- $el.eventRect
21680
- .call($$.zoom.transform, transform);
21994
+ $$.updateCurrentZoomTransform(x, domain);
21681
21995
  }
21682
21996
  $$.setZoomResetButton();
21683
21997
  }
@@ -21686,7 +22000,7 @@ var zoom$1 = function (domainValue) {
21686
22000
  domain = $$.zoom.getDomain();
21687
22001
  }
21688
22002
  }
21689
- return (_b = state.domain) !== null && _b !== void 0 ? _b : domain;
22003
+ return (_a = state.domain) !== null && _a !== void 0 ? _a : domain;
21690
22004
  };
21691
22005
  extend(zoom$1, {
21692
22006
  /**
@@ -21804,8 +22118,8 @@ var apiZoom = {
21804
22118
  */
21805
22119
  unzoom: function () {
21806
22120
  var $$ = this.internal;
21807
- var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, zoomResetBtn = _a.zoomResetBtn, state = $$.state;
21808
- if ($$.scale.zoom) {
22121
+ var config = $$.config, _a = $$.$el, eventRect = _a.eventRect, zoomResetBtn = _a.zoomResetBtn, zoom = $$.scale.zoom, state = $$.state;
22122
+ if (zoom) {
21809
22123
  config.subchart_show ?
21810
22124
  $$.brush.getSelection().call($$.brush.move, null) :
21811
22125
  $$.zoom.updateTransformScale(zoomIdentity);
@@ -22497,6 +22811,10 @@ var zoom = {
22497
22811
  !org.xScale && (org.xScale = scale.x.copy());
22498
22812
  scale.x.domain(domain);
22499
22813
  }
22814
+ else if (org.xScale) {
22815
+ scale.x.domain(org.xScale.domain());
22816
+ org.xScale = null;
22817
+ }
22500
22818
  };
22501
22819
  /**
22502
22820
  * Get zoom domain
@@ -22618,6 +22936,25 @@ var zoom = {
22618
22936
  }
22619
22937
  }
22620
22938
  },
22939
+ /**
22940
+ * Set zoom transform to event rect
22941
+ * @param {Function} x x Axis scale function
22942
+ * @param {Array} domain Domain value to be set
22943
+ * @private
22944
+ */
22945
+ updateCurrentZoomTransform: function (x, domain) {
22946
+ var _a;
22947
+ var $$ = this;
22948
+ var eventRect = $$.$el.eventRect, config = $$.config;
22949
+ var isRotated = config.axis_rotated;
22950
+ // Get transform from given domain value
22951
+ // https://github.com/d3/d3-zoom/issues/57#issuecomment-246434951
22952
+ var translate = [-x(domain[0]), 0];
22953
+ var transform = (_a = zoomIdentity
22954
+ .scale(x.range()[1] / (x(domain[1]) - x(domain[0]))))
22955
+ .translate.apply(_a, (isRotated ? translate.reverse() : translate));
22956
+ eventRect.call($$.zoom.transform, transform);
22957
+ },
22621
22958
  /**
22622
22959
  * Attach zoom event on <rect>
22623
22960
  * @private
@@ -23037,7 +23374,7 @@ var zoomModule = function () {
23037
23374
  var defaults = {};
23038
23375
  /**
23039
23376
  * @namespace bb
23040
- * @version 3.10.3
23377
+ * @version 3.11.0-next.2
23041
23378
  */
23042
23379
  var bb = {
23043
23380
  /**
@@ -23047,7 +23384,7 @@ var bb = {
23047
23384
  * bb.version; // "1.0.0"
23048
23385
  * @memberof bb
23049
23386
  */
23050
- version: "3.10.3",
23387
+ version: "3.11.0-next.2",
23051
23388
  /**
23052
23389
  * Generate chart
23053
23390
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: