billboard.js 3.3.3 → 3.4.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 (61) hide show
  1. package/dist/billboard.css +19 -14
  2. package/dist/billboard.js +343 -60
  3. package/dist/billboard.min.css +2 -2
  4. package/dist/billboard.min.js +2 -2
  5. package/dist/billboard.pkgd.js +343 -60
  6. package/dist/billboard.pkgd.min.js +2 -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 +27 -15
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
  11. package/dist/plugin/billboardjs-plugin-stanford.js +27 -15
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
  13. package/dist/plugin/billboardjs-plugin-tableview.js +22 -12
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +22 -12
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +2 -2
  18. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +27 -15
  19. package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +27 -15
  20. package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +22 -12
  21. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +22 -12
  22. package/dist/theme/datalab.css +24 -20
  23. package/dist/theme/datalab.min.css +2 -2
  24. package/dist/theme/graph.css +24 -20
  25. package/dist/theme/graph.min.css +2 -2
  26. package/dist/theme/insight.css +24 -20
  27. package/dist/theme/insight.min.css +2 -2
  28. package/dist-esm/billboard.js +310 -52
  29. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  30. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +3 -5
  31. package/dist-esm/plugin/billboardjs-plugin-stanford.js +3 -5
  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 +19 -19
  35. package/src/Chart/api/focus.ts +3 -2
  36. package/src/ChartInternal/Axis/Axis.ts +8 -6
  37. package/src/ChartInternal/ChartInternal.ts +23 -12
  38. package/src/ChartInternal/data/data.ts +1 -1
  39. package/src/ChartInternal/internals/color.ts +4 -3
  40. package/src/ChartInternal/internals/format.ts +5 -1
  41. package/src/ChartInternal/internals/redraw.ts +3 -0
  42. package/src/ChartInternal/internals/text.ts +1 -1
  43. package/src/ChartInternal/internals/transform.ts +4 -1
  44. package/src/ChartInternal/internals/type.ts +5 -0
  45. package/src/ChartInternal/shape/arc.ts +41 -17
  46. package/src/ChartInternal/shape/polar.ts +132 -0
  47. package/src/ChartInternal/shape/radar.ts +4 -4
  48. package/src/config/Options/data/data.ts +3 -0
  49. package/src/config/Options/shape/polar.ts +81 -0
  50. package/src/config/classes.ts +6 -3
  51. package/src/config/const.ts +3 -0
  52. package/src/config/resolver/shape.ts +4 -0
  53. package/src/core.ts +1 -0
  54. package/src/index.esm.ts +1 -0
  55. package/src/module/util.ts +18 -7
  56. package/src/scss/billboard.scss +13 -0
  57. package/src/scss/theme/datalab.scss +13 -0
  58. package/src/scss/theme/graph.scss +13 -0
  59. package/src/scss/theme/insight.scss +13 -0
  60. package/types/bb.d.ts +1 -0
  61. package/types/options.d.ts +72 -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.3.3
8
+ * @version 3.4.0-next.1
9
9
  */
10
10
  import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
11
11
  import { pointer, select, namespaces, selectAll } from 'd3-selection';
@@ -57,6 +57,7 @@ var TYPE = {
57
57
  GAUGE: "gauge",
58
58
  LINE: "line",
59
59
  PIE: "pie",
60
+ POLAR: "polar",
60
61
  RADAR: "radar",
61
62
  SCATTER: "scatter",
62
63
  SPLINE: "spline",
@@ -79,6 +80,7 @@ var TYPE_METHOD_NEEDED = {
79
80
  GAUGE: "initArc",
80
81
  LINE: "initLine",
81
82
  PIE: "initArc",
83
+ POLAR: "initPolar",
82
84
  RADAR: "initCircle",
83
85
  SCATTER: "initCircle",
84
86
  SPLINE: "initLine",
@@ -104,6 +106,7 @@ var TYPE_BY_CATEGORY = {
104
106
  TYPE.PIE,
105
107
  TYPE.DONUT,
106
108
  TYPE.GAUGE,
109
+ TYPE.POLAR,
107
110
  TYPE.RADAR
108
111
  ],
109
112
  Line: [
@@ -769,26 +772,36 @@ function isTabVisible() {
769
772
  * @private
770
773
  */
771
774
  function convertInputType(mouse, touch) {
775
+ var DocumentTouch = win.DocumentTouch, matchMedia = win.matchMedia, navigator = win.navigator;
772
776
  var hasTouch = false;
773
777
  if (touch) {
774
778
  // Some Edge desktop return true: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/20417074/
775
- if (win.navigator && "maxTouchPoints" in win.navigator) {
776
- hasTouch = win.navigator.maxTouchPoints > 0;
779
+ if (navigator && "maxTouchPoints" in navigator) {
780
+ hasTouch = navigator.maxTouchPoints > 0;
777
781
  // Ref: https://github.com/Modernizr/Modernizr/blob/master/feature-detects/touchevents.js
778
782
  // On IE11 with IE9 emulation mode, ('ontouchstart' in window) is returning true
779
783
  }
780
- else if ("ontouchmove" in win || (win.DocumentTouch && doc instanceof win.DocumentTouch)) {
784
+ else if ("ontouchmove" in win || (DocumentTouch && doc instanceof DocumentTouch)) {
781
785
  hasTouch = true;
782
786
  }
783
787
  else {
784
788
  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent#avoiding_user_agent_detection
785
- var mQ = win.matchMedia && matchMedia("(pointer:coarse)");
786
- if (mQ && mQ.media === "(pointer:coarse)") {
787
- hasTouch = !!mQ.matches;
789
+ if (matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia("(pointer:coarse)").matches) {
790
+ hasTouch = true;
791
+ }
792
+ else {
793
+ // Only as a last resort, fall back to user agent sniffing
794
+ var UA = navigator.userAgent;
795
+ hasTouch = (/\b(BlackBerry|webOS|iPhone|IEMobile)\b/i.test(UA) ||
796
+ /\b(Android|Windows Phone|iPad|iPod)\b/i.test(UA));
788
797
  }
789
798
  }
790
799
  }
791
- var hasMouse = mouse && !hasTouch ? ("onmouseover" in win) : false;
800
+ // Check if agent has mouse using any-hover, touch devices (e.g iPad) with external mouse will return true as long as mouse is connected
801
+ // https://css-tricks.com/interaction-media-features-and-their-potential-for-incorrect-assumptions/#aa-testing-the-capabilities-of-all-inputs
802
+ // Demo: https://patrickhlauke.github.io/touch/pointer-hover-any-pointer-any-hover/
803
+ var hasMouse = mouse && ["any-hover:hover", "any-pointer:fine"]
804
+ .some(function (v) { return matchMedia === null || matchMedia === void 0 ? void 0 : matchMedia("(".concat(v, ")")).matches; });
792
805
  return (hasMouse && "mouse") || (hasTouch && "touch") || null;
793
806
  }
794
807
 
@@ -945,12 +958,14 @@ var $GRID = {
945
958
  ygridLines: "bb-ygrid-lines",
946
959
  ygrids: "bb-ygrids"
947
960
  };
948
- var $RADAR = {
949
- chartRadar: "bb-chart-radar",
950
- chartRadars: "bb-chart-radars",
961
+ var $LEVEL = {
951
962
  level: "bb-level",
952
963
  levels: "bb-levels"
953
964
  };
965
+ var $RADAR = {
966
+ chartRadar: "bb-chart-radar",
967
+ chartRadars: "bb-chart-radars"
968
+ };
954
969
  var $REGION = {
955
970
  region: "bb-region",
956
971
  regions: "bb-regions"
@@ -1638,6 +1653,7 @@ var data$2 = {
1638
1653
  * - gauge
1639
1654
  * - line
1640
1655
  * - pie
1656
+ * - polar
1641
1657
  * - radar
1642
1658
  * - scatter
1643
1659
  * - spline
@@ -1666,6 +1682,7 @@ var data$2 = {
1666
1682
  * gauge,
1667
1683
  * line,
1668
1684
  * pie,
1685
+ * polar,
1669
1686
  * radar,
1670
1687
  * scatter,
1671
1688
  * spline,
@@ -1711,6 +1728,7 @@ var data$2 = {
1711
1728
  * gauge,
1712
1729
  * line,
1713
1730
  * pie,
1731
+ * polar,
1714
1732
  * radar,
1715
1733
  * scatter,
1716
1734
  * spline,
@@ -4763,12 +4781,13 @@ var color = {
4763
4781
  },
4764
4782
  /**
4765
4783
  * Append data backgound color filter definition
4784
+ * @param {string} color Color string
4766
4785
  * @private
4767
4786
  */
4768
- generateDataLabelBackgroundColorFilter: function () {
4787
+ generateDataLabelBackgroundColorFilter: function (color) {
4769
4788
  var $$ = this;
4770
4789
  var $el = $$.$el, config = $$.config, state = $$.state;
4771
- var backgroundColors = config.data_labels_backgroundColors;
4790
+ var backgroundColors = color || config.data_labels_backgroundColors;
4772
4791
  if (backgroundColors) {
4773
4792
  var ids = [];
4774
4793
  if (isString(backgroundColors)) {
@@ -4778,7 +4797,7 @@ var color = {
4778
4797
  ids = Object.keys(backgroundColors);
4779
4798
  }
4780
4799
  ids.forEach(function (v) {
4781
- var id = "".concat(state.datetimeId, "-labels-bg").concat($$.getTargetSelectorSuffix(v));
4800
+ var id = "".concat(state.datetimeId, "-labels-bg").concat($$.getTargetSelectorSuffix(v)).concat(color ? $$.getTargetSelectorSuffix(color) : "");
4782
4801
  $el.defs.append("filter")
4783
4802
  .attr("x", "0")
4784
4803
  .attr("y", "0")
@@ -5174,7 +5193,7 @@ var format = {
5174
5193
  getDefaultValueFormat: function () {
5175
5194
  var $$ = this;
5176
5195
  var defaultArcValueFormat = $$.defaultArcValueFormat, yFormat = $$.yFormat, y2Format = $$.y2Format;
5177
- var hasArc = $$.hasArcType(null, ["gauge", "radar"]);
5196
+ var hasArc = $$.hasArcType(null, ["gauge", "polar", "radar"]);
5178
5197
  return function (v, ratio, id) {
5179
5198
  var format = hasArc ? defaultArcValueFormat : ($$.axis && $$.axis.getId(id) === "y2" ? y2Format : yFormat);
5180
5199
  return format.call($$, v, ratio);
@@ -5186,6 +5205,9 @@ var format = {
5186
5205
  defaultArcValueFormat: function (v, ratio) {
5187
5206
  return "".concat((ratio * 100).toFixed(1), "%");
5188
5207
  },
5208
+ defaultPolarValueFormat: function (v) {
5209
+ return "".concat(v);
5210
+ },
5189
5211
  dataLabelFormat: function (targetId) {
5190
5212
  var $$ = this;
5191
5213
  var dataLabels = $$.config.data_labels;
@@ -5885,6 +5907,8 @@ var redraw = {
5885
5907
  $el.arcs && $$.redrawArc(duration, durationForExit, wth.Transform);
5886
5908
  // radar
5887
5909
  $el.radar && $$.redrawRadar();
5910
+ // polar
5911
+ $el.polar && $$.redrawPolar();
5888
5912
  }
5889
5913
  // @TODO: Axis & Radar type
5890
5914
  if (!state.resizing && ($$.hasPointType() || state.hasRadar)) {
@@ -7888,6 +7912,10 @@ var transform = {
7888
7912
  x = state.arcWidth / 2;
7889
7913
  y = state.arcHeight / 2;
7890
7914
  }
7915
+ else if (target === "polar") {
7916
+ x = state.arcWidth / 2;
7917
+ y = state.arcHeight / 2;
7918
+ }
7891
7919
  else if (target === "radar") {
7892
7920
  var width = $$.getRadarSize()[0];
7893
7921
  x = state.width / 2 - width;
@@ -8087,6 +8115,9 @@ var type = {
8087
8115
  isDonutType: function (d) {
8088
8116
  return this.isTypeOf(d, "donut");
8089
8117
  },
8118
+ isPolarType: function (d) {
8119
+ return this.isTypeOf(d, "polar");
8120
+ },
8090
8121
  isRadarType: function (d) {
8091
8122
  return this.isTypeOf(d, "radar");
8092
8123
  },
@@ -8094,6 +8125,7 @@ var type = {
8094
8125
  return this.isPieType(d) ||
8095
8126
  this.isDonutType(d) ||
8096
8127
  this.isGaugeType(d) ||
8128
+ this.isPolarType(d) ||
8097
8129
  this.isRadarType(d);
8098
8130
  },
8099
8131
  // determine if is 'circle' data point
@@ -8359,6 +8391,7 @@ var ChartInternal = /** @class */ (function () {
8359
8391
  var config = $$.config, scale = $$.scale, state = $$.state, $el = $$.$el, org = $$.org;
8360
8392
  var hasAxis = state.hasAxis;
8361
8393
  var hasInteraction = config.interaction_enabled;
8394
+ var hasPolar = $$.hasType("polar");
8362
8395
  // for arc type, set axes to not be shown
8363
8396
  // $$.hasArcType() && ["x", "y", "y2"].forEach(id => (config[`axis_${id}_show`] = false));
8364
8397
  if (hasAxis) {
@@ -8412,14 +8445,14 @@ var ChartInternal = /** @class */ (function () {
8412
8445
  config.svg_classname && $el.svg.attr("class", config.svg_classname);
8413
8446
  // Define defs
8414
8447
  var hasColorPatterns = (isFunction(config.color_tiles) && $$.patterns);
8415
- if (hasAxis || hasColorPatterns || config.data_labels_backgroundColors) {
8448
+ if (hasAxis || hasColorPatterns || config.data_labels_backgroundColors || hasPolar) {
8416
8449
  $el.defs = $el.svg.append("defs");
8417
8450
  if (hasAxis) {
8418
8451
  ["id", "idXAxis", "idYAxis", "idGrid"].forEach(function (v) {
8419
8452
  $$.appendClip($el.defs, state.clip[v]);
8420
8453
  });
8421
8454
  }
8422
- // Append data backgound color filter definition
8455
+ // Append data background color filter definition
8423
8456
  $$.generateDataLabelBackgroundColorFilter();
8424
8457
  // set color patterns
8425
8458
  if (hasColorPatterns) {
@@ -8508,6 +8541,7 @@ var ChartInternal = /** @class */ (function () {
8508
8541
  });
8509
8542
  }
8510
8543
  else {
8544
+ var hasPolar = $$.hasType("polar");
8511
8545
  if (!hasRadar) {
8512
8546
  types.push("Arc", "Pie");
8513
8547
  }
@@ -8517,6 +8551,9 @@ var ChartInternal = /** @class */ (function () {
8517
8551
  else if (hasRadar) {
8518
8552
  types.push("Radar");
8519
8553
  }
8554
+ else if (hasPolar) {
8555
+ types.push("Polar");
8556
+ }
8520
8557
  }
8521
8558
  types.forEach(function (v) {
8522
8559
  $$["init".concat(v)]();
@@ -8580,24 +8617,30 @@ var ChartInternal = /** @class */ (function () {
8580
8617
  var _a;
8581
8618
  var $$ = this;
8582
8619
  var _b = $$.state, hasAxis = _b.hasAxis, hasRadar = _b.hasRadar;
8620
+ var helper = function (type) { return $$["updateTargetsFor".concat(type)](targets.filter($$["is".concat(type, "Type")].bind($$))); };
8583
8621
  // Text
8584
8622
  $$.updateTargetsForText(targets);
8585
8623
  if (hasAxis) {
8586
8624
  ["bar", "candlestick", "line"].forEach(function (v) {
8587
8625
  var name = capitalize(v);
8588
8626
  if ((v === "line" && $$.hasTypeOf(name)) || $$.hasType(v)) {
8589
- $$["updateTargetsFor".concat(name)](targets.filter($$["is".concat(name, "Type")].bind($$)));
8627
+ helper(name);
8590
8628
  }
8591
8629
  });
8592
8630
  // Sub Chart
8593
8631
  $$.updateTargetsForSubchart &&
8594
8632
  $$.updateTargetsForSubchart(targets);
8633
+ // Arc, Polar, Radar
8595
8634
  }
8596
- else {
8597
- // Arc & Radar
8598
- $$.hasArcType(targets) && (hasRadar ?
8599
- $$.updateTargetsForRadar(targets.filter($$.isRadarType.bind($$))) :
8600
- $$.updateTargetsForArc(targets.filter($$.isArcType.bind($$))));
8635
+ else if ($$.hasArcType(targets)) {
8636
+ var type_1 = "Arc";
8637
+ if (hasRadar) {
8638
+ type_1 = "Radar";
8639
+ }
8640
+ else if ($$.hasType("polar")) {
8641
+ type_1 = "Polar";
8642
+ }
8643
+ helper(type_1);
8601
8644
  }
8602
8645
  // circle
8603
8646
  if ($$.hasType("bubble") || $$.hasType("scatter")) {
@@ -9276,7 +9319,7 @@ var apiFocus = {
9276
9319
  var targetIds = $$.mapToTargetIds(targetIdsValue);
9277
9320
  var candidates = $$.$el.svg.selectAll($$.selectorTargets(targetIds.filter($$.isTargetToShow, $$)));
9278
9321
  candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, true);
9279
- if ($$.hasArcType()) {
9322
+ if ($$.hasArcType(null, ["polar"])) {
9280
9323
  $$.unexpandArc(targetIds);
9281
9324
  $$.hasType("gauge") &&
9282
9325
  $$.undoMarkOverlapped($$, ".".concat($GAUGE.gaugeValue));
@@ -9308,7 +9351,7 @@ var apiFocus = {
9308
9351
  var targetIds = $$.mapToTargetIds(targetIdsValue);
9309
9352
  var candidates = $el.svg.selectAll($$.selectorTargets(targetIds)); // should be for all targets
9310
9353
  candidates.classed($FOCUS.focused, false).classed($FOCUS.defocused, false);
9311
- $$.hasArcType() && $$.unexpandArc(targetIds);
9354
+ $$.hasArcType(null, ["polar"]) && $$.unexpandArc(targetIds);
9312
9355
  if (config.legend_show) {
9313
9356
  $$.showLegend(targetIds.filter($$.isLegendToShow.bind($$)));
9314
9357
  $el.legend.selectAll($$.selectorLegends(targetIds))
@@ -12002,7 +12045,7 @@ var Axis = /** @class */ (function () {
12002
12045
  ["y", "y2"].forEach(function (key) {
12003
12046
  var prefix = "axis_".concat(key, "_");
12004
12047
  var axisScale = scale[key];
12005
- if (config["".concat(prefix, "show")] && axisScale) {
12048
+ if (axisScale) {
12006
12049
  var tickValues = config["".concat(prefix, "tick_values")];
12007
12050
  var tickCount = config["".concat(prefix, "tick_count")];
12008
12051
  axisScale.domain($$.getYDomain(targetsToShow, key, xDomainForZoom));
@@ -12054,10 +12097,11 @@ var Axis = /** @class */ (function () {
12054
12097
  break;
12055
12098
  }
12056
12099
  }
12057
- tickNodes.each(function (d) {
12058
- if (tickValues_1.indexOf(d) % intervalForCulling_1) {
12059
- var node = (lines_1 ? this.querySelector("text") : this);
12060
- node && (node.style.display = "none");
12100
+ tickNodes
12101
+ .each(function (d) {
12102
+ var node = (lines_1 ? this.querySelector("text") : this);
12103
+ if (node) {
12104
+ node.style.display = tickValues_1.indexOf(d) % intervalForCulling_1 ? "none" : null;
12061
12105
  }
12062
12106
  });
12063
12107
  }
@@ -15367,9 +15411,9 @@ var shapeArc = {
15367
15411
  var $$ = this;
15368
15412
  var config = $$.config;
15369
15413
  var dataType = config.data_type;
15370
- var padding = config.pie_padding;
15414
+ var padding = config["".concat(dataType, "_padding")];
15371
15415
  var startingAngle = config["".concat(dataType, "_startingAngle")] || 0;
15372
- var padAngle = ($$.hasType("pie") && padding ? padding * 0.01 :
15416
+ var padAngle = (padding ? padding * 0.01 :
15373
15417
  config["".concat(dataType, "_padAngle")]) || 0;
15374
15418
  $$.pie = pie$1()
15375
15419
  .startAngle(startingAngle)
@@ -15381,7 +15425,8 @@ var shapeArc = {
15381
15425
  updateRadius: function () {
15382
15426
  var $$ = this;
15383
15427
  var config = $$.config, state = $$.state;
15384
- var padding = config.pie_padding;
15428
+ var dataType = config.data_type;
15429
+ var padding = config["".concat(dataType, "_padding")];
15385
15430
  var w = config.gauge_width || config.donut_width;
15386
15431
  var gaugeArcWidth = $$.filterTargetsToShow($$.data.targets).length *
15387
15432
  config.gauge_arcs_minWidth;
@@ -15506,6 +15551,7 @@ var shapeArc = {
15506
15551
  var state = $$.state;
15507
15552
  var singleArcWidth = state.gaugeArcWidth / $$.filterTargetsToShow($$.data.targets).length;
15508
15553
  var hasMultiArcGauge = $$.hasMultiArcGauge();
15554
+ var hasPolar = $$.hasType("polar");
15509
15555
  var arc$1 = arc()
15510
15556
  .innerRadius(function (d) {
15511
15557
  var innerRadius = $$.getRadius(d).innerRadius;
@@ -15515,7 +15561,14 @@ var shapeArc = {
15515
15561
  })
15516
15562
  .outerRadius(function (d) {
15517
15563
  var outerRadius = $$.getRadius(d).outerRadius;
15518
- return hasMultiArcGauge ? (state.radius - singleArcWidth * d.index) : outerRadius;
15564
+ var radius = outerRadius;
15565
+ if (hasMultiArcGauge) {
15566
+ radius = state.radius - singleArcWidth * d.index;
15567
+ }
15568
+ else if (hasPolar) {
15569
+ radius = $$.getPolarOuterRadius(d, outerRadius);
15570
+ }
15571
+ return radius;
15519
15572
  });
15520
15573
  var newArc = function (d, withoutUpdate) {
15521
15574
  var path = "M 0 0";
@@ -15567,7 +15620,14 @@ var shapeArc = {
15567
15620
  getArc: function (d, withoutUpdate, force) {
15568
15621
  return force || this.isArcType(d.data) ? this.svgArc(d, withoutUpdate) : "M 0 0";
15569
15622
  },
15623
+ /**
15624
+ * Set transform attributes to arc label text
15625
+ * @param {Object} d Data object
15626
+ * @returns {string} Translate attribute string
15627
+ * @private
15628
+ */
15570
15629
  transformForArcLabel: function (d) {
15630
+ var _a;
15571
15631
  var $$ = this;
15572
15632
  var config = $$.config, radiusExpanded = $$.state.radiusExpanded;
15573
15633
  var updated = $$.updateAngle(d);
@@ -15581,11 +15641,15 @@ var shapeArc = {
15581
15641
  }
15582
15642
  else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
15583
15643
  var outerRadius = $$.getRadius(d).outerRadius;
15644
+ if ($$.hasType("polar")) {
15645
+ outerRadius = $$.getPolarOuterRadius(d, outerRadius);
15646
+ }
15584
15647
  var c = this.svgArc.centroid(updated);
15585
- var _a = c.map(function (v) { return (isNaN(v) ? 0 : v); }), x = _a[0], y = _a[1];
15648
+ var _b = c.map(function (v) { return (isNaN(v) ? 0 : v); }), x = _b[0], y = _b[1];
15586
15649
  var h = Math.sqrt(x * x + y * y);
15587
- var ratio = ($$.hasType("donut") && config.donut_label_ratio) ||
15588
- ($$.hasType("pie") && config.pie_label_ratio);
15650
+ var ratio = (_a = ["donut", "pie", "polar"]
15651
+ .filter($$.hasType.bind($$))
15652
+ .map(function (v) { return config["".concat(v, "_label_ratio")]; })) === null || _a === void 0 ? void 0 : _a[0];
15589
15653
  if (ratio) {
15590
15654
  ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
15591
15655
  }
@@ -15613,10 +15677,11 @@ var shapeArc = {
15613
15677
  .style("fill", $$.updateTextColor.bind($$))
15614
15678
  .attr("filter", $$.updateTextBacgroundColor.bind($$))
15615
15679
  .each(function (d) {
15680
+ var _a;
15616
15681
  var node = select(this);
15617
15682
  var updated = $$.updateAngle(d);
15618
15683
  var ratio = $$.getRatio("arc", updated);
15619
- var isUnderThreshold = $$.meetsLabelThreshold(ratio, ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge") || ($$.hasType("pie") && "pie"));
15684
+ var isUnderThreshold = $$.meetsLabelThreshold(ratio, (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) === null || _a === void 0 ? void 0 : _a[0]);
15620
15685
  if (isUnderThreshold) {
15621
15686
  var value = (updated || d).value;
15622
15687
  var text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
@@ -15710,19 +15775,18 @@ var shapeArc = {
15710
15775
  shouldShowArcLabel: function () {
15711
15776
  var $$ = this;
15712
15777
  var config = $$.config;
15713
- return ["pie", "donut", "gauge"]
15778
+ return ["donut", "gauge", "pie", "polar"]
15714
15779
  .some(function (v) { return $$.hasType(v) && config["".concat(v, "_label_show")]; });
15715
15780
  },
15716
15781
  getArcLabelFormat: function () {
15717
15782
  var $$ = this;
15718
15783
  var config = $$.config;
15719
- var format = config.pie_label_format;
15720
- if ($$.hasType("gauge")) {
15721
- format = config.gauge_label_format;
15722
- }
15723
- else if ($$.hasType("donut")) {
15724
- format = config.donut_label_format;
15725
- }
15784
+ var format = function (v) { return v; };
15785
+ ["donut", "gauge", "pie", "polar"]
15786
+ .filter($$.hasType.bind($$))
15787
+ .forEach(function (v) {
15788
+ format = config["".concat(v, "_label_format")];
15789
+ });
15726
15790
  return isFunction(format) ? format.bind($$.api) : format;
15727
15791
  },
15728
15792
  getArcTitle: function () {
@@ -15866,6 +15930,7 @@ var shapeArc = {
15866
15930
  });
15867
15931
  // bind arc events
15868
15932
  hasInteraction && $$.bindArcEvent(mainArc);
15933
+ $$.hasType("polar") && $$.redrawPolar();
15869
15934
  $$.hasType("gauge") && $$.redrawBackgroundArcs();
15870
15935
  $$.redrawArcText(duration);
15871
15936
  },
@@ -17521,6 +17586,115 @@ var shapePoint = {
17521
17586
  }
17522
17587
  };
17523
17588
 
17589
+ /**
17590
+ * Copyright (c) 2017 ~ present NAVER Corp.
17591
+ * billboard.js project is licensed under the MIT license
17592
+ */
17593
+ /**
17594
+ * Get data max value
17595
+ * @param {object} $$ ChartInternal instance
17596
+ * @returns {number} max value
17597
+ * @private
17598
+ */
17599
+ function getDataMax($$) {
17600
+ var levelMax = $$.config.polar_level_max;
17601
+ var dataMax = $$.getMinMaxData().max[0].value;
17602
+ // Apply level max only when is greater than the data max value
17603
+ if (levelMax && levelMax > dataMax) {
17604
+ dataMax = levelMax;
17605
+ }
17606
+ return dataMax;
17607
+ }
17608
+ var shapePolar = {
17609
+ /**
17610
+ * Initialize polar
17611
+ * @private
17612
+ */
17613
+ initPolar: function () {
17614
+ var $$ = this;
17615
+ var arcs = $$.$el.arcs, config = $$.config;
17616
+ var levelTextShow = config.polar_level_text_show;
17617
+ var levelTextBgColor = config.polar_level_text_backgroundColor;
17618
+ // append <g> for level
17619
+ arcs.levels = arcs.append("g")
17620
+ .attr("class", $LEVEL.levels);
17621
+ // set level text background color
17622
+ if (levelTextShow && levelTextBgColor) {
17623
+ $$.generateDataLabelBackgroundColorFilter(levelTextBgColor);
17624
+ }
17625
+ },
17626
+ /**
17627
+ * Get polar outer radius according to the data value
17628
+ * @param {object} d Data object
17629
+ * @param {numbet} outerRadius Outer radius
17630
+ * @returns {number} outer radius
17631
+ * @private
17632
+ */
17633
+ getPolarOuterRadius: function (d, outerRadius) {
17634
+ var dataMax = getDataMax(this);
17635
+ return ((d === null || d === void 0 ? void 0 : d.data.values[0].value) / dataMax) * outerRadius;
17636
+ },
17637
+ /**
17638
+ * Update polar based on given data array
17639
+ * @param {object} targets Data object
17640
+ * @private
17641
+ */
17642
+ updateTargetsForPolar: function (targets) {
17643
+ // borrow from Arc
17644
+ this.updateTargetsForArc(targets);
17645
+ },
17646
+ /**
17647
+ * Called whenever redraw happens
17648
+ * @private
17649
+ */
17650
+ redrawPolar: function () {
17651
+ var $$ = this;
17652
+ var config = $$.config;
17653
+ config.polar_level_show && $$.updatePolarLevel();
17654
+ },
17655
+ /**
17656
+ * Update polar level circle
17657
+ * @private
17658
+ */
17659
+ updatePolarLevel: function () {
17660
+ var $$ = this;
17661
+ var config = $$.config, state = $$.state, levels = $$.$el.arcs.levels;
17662
+ var depth = config.polar_level_depth;
17663
+ var dataMax = getDataMax($$);
17664
+ var levelData = getRange(0, depth);
17665
+ var outerRadius = state.radius;
17666
+ var levelRatio = levelData.map(function (l) { return outerRadius * ((l + 1) / depth); });
17667
+ var levelTextFormat = (config.polar_level_text_format || function () { }).bind($$.api);
17668
+ var level = levels
17669
+ .selectAll(".".concat($LEVEL.level))
17670
+ .data(levelData);
17671
+ level.exit().remove();
17672
+ var levelEnter = level.enter().append("g")
17673
+ .attr("class", function (d, i) { return "".concat($LEVEL.level, " ").concat($LEVEL.level, "-").concat(i); });
17674
+ // cx, cy, translate: Set center as origin (0,0) so that it can share same center with arcs
17675
+ levelEnter.append("circle");
17676
+ levelEnter
17677
+ .merge(level)
17678
+ .selectAll("circle")
17679
+ .style("visibility", config.polar_level_show ? null : "hidden")
17680
+ .attr("cx", 0)
17681
+ .attr("cy", 0)
17682
+ .attr("r", function (d) { return levelRatio[d]; });
17683
+ if (config.polar_level_text_show) {
17684
+ var levelTextBackgroundColor = config.polar_level_text_backgroundColor;
17685
+ var defsId = "#".concat(state.datetimeId, "-labels-bg").concat($$.getTargetSelectorSuffix(levelTextBackgroundColor));
17686
+ levelEnter.append("text")
17687
+ .style("text-anchor", "middle");
17688
+ levelEnter
17689
+ .merge(level)
17690
+ .selectAll("text")
17691
+ .attr("dy", function (d) { return -levelRatio[d] + 5; })
17692
+ .attr("filter", levelTextBackgroundColor ? "url(".concat(defsId, ")") : null)
17693
+ .text(function (d) { return levelTextFormat(dataMax / levelData.length * (d + 1)); });
17694
+ }
17695
+ }
17696
+ };
17697
+
17524
17698
  /**
17525
17699
  * Copyright (c) 2017 ~ present NAVER Corp.
17526
17700
  * billboard.js project is licensed under the MIT license
@@ -17553,7 +17727,7 @@ var shapeRadar = {
17553
17727
  .attr("class", $RADAR.chartRadars);
17554
17728
  // level
17555
17729
  $el.radar.levels = $el.radar.append("g")
17556
- .attr("class", $RADAR.levels);
17730
+ .attr("class", $LEVEL.levels);
17557
17731
  // axis
17558
17732
  $el.radar.axes = $el.radar.append("g")
17559
17733
  .attr("class", $AXIS.axis);
@@ -17651,11 +17825,11 @@ var shapeRadar = {
17651
17825
  return pos.join(" ");
17652
17826
  });
17653
17827
  var level = radarLevels
17654
- .selectAll(".".concat($RADAR.level))
17828
+ .selectAll(".".concat($LEVEL.level))
17655
17829
  .data(levelData);
17656
17830
  level.exit().remove();
17657
17831
  var levelEnter = level.enter().append("g")
17658
- .attr("class", function (d, i) { return "".concat($RADAR.level, " ").concat($RADAR.level, "-").concat(i); });
17832
+ .attr("class", function (d, i) { return "".concat($LEVEL.level, " ").concat($LEVEL.level, "-").concat(i); });
17659
17833
  levelEnter.append("polygon")
17660
17834
  .style("visibility", config.radar_level_show ? null : "hidden");
17661
17835
  if (showText) {
@@ -18632,6 +18806,88 @@ var optPie = {
18632
18806
  pie_startingAngle: 0
18633
18807
  };
18634
18808
 
18809
+ /**
18810
+ * Copyright (c) 2017 ~ present NAVER Corp.
18811
+ * billboard.js project is licensed under the MIT license
18812
+ */
18813
+ /**
18814
+ * x Axis config options
18815
+ */
18816
+ var optPolar = {
18817
+ /**
18818
+ * Set polar options
18819
+ * @name polar
18820
+ * @memberof Options
18821
+ * @type {object}
18822
+ * @property {object} polar Polar object
18823
+ * @property {boolean} [polar.label.show=true] Show or hide label on each polar piece.
18824
+ * @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
18825
+ * @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
18826
+ * @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
18827
+ * @property {number} [polar.level.depth=3] Set the level depth.
18828
+ * @property {boolean} [polar.level.show=true] Show or hide level.
18829
+ * @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
18830
+ * @property {Function} [polar.level.text.format] Set format function for the level value.<br>- Default value: `(x) => x % 1 === 0 ? x : x.toFixed(2)`
18831
+ * @property {boolean} [polar.level.text.show=true] Show or hide level text.
18832
+ * @property {number} [polar.padAngle=0] Set padding between data.
18833
+ * @property {number} [polar.padding=0] Sets the gap between pie arcs.
18834
+ * @property {number} [polar.startingAngle=0] Set starting angle where data draws.
18835
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
18836
+ * @example
18837
+ * polar: {
18838
+ * label: {
18839
+ * show: false,
18840
+ * format: function(value, ratio, id) {
18841
+ * return d3.format("$")(value);
18842
+ *
18843
+ * // to multiline, return with '\n' character
18844
+ * // return value +"%\nLine1\n2Line2";
18845
+ * },
18846
+ *
18847
+ * // 0.1(10%) ratio value means, the minimum ratio to show text label relative to the total value.
18848
+ * // if data value is below than 0.1, text label will be hidden.
18849
+ * threshold: 0.1,
18850
+ *
18851
+ * // set ratio callback. Should return ratio value
18852
+ * ratio: function(d, radius, h) {
18853
+ * ...
18854
+ * return ratio;
18855
+ * },
18856
+ * // or set ratio number
18857
+ * ratio: 0.5
18858
+ * },
18859
+ * level: {
18860
+ * depth: 3,
18861
+ * max: 500,
18862
+ * show: true,
18863
+ * text: {
18864
+ * format: function(x) {
18865
+ * return x + "%";
18866
+ * },
18867
+ * show: true,
18868
+ * backgroundColor: "red"
18869
+ * }
18870
+ * },
18871
+ * padAngle: 0.1,
18872
+ * padding: 0,
18873
+ * startingAngle: 1
18874
+ * }
18875
+ */
18876
+ polar_label_show: true,
18877
+ polar_label_format: undefined,
18878
+ polar_label_threshold: 0.05,
18879
+ polar_label_ratio: undefined,
18880
+ polar_level_depth: 3,
18881
+ polar_level_max: undefined,
18882
+ polar_level_show: true,
18883
+ polar_level_text_backgroundColor: "#fff",
18884
+ polar_level_text_format: function (x) { return (x % 1 === 0 ? x : x.toFixed(2)); },
18885
+ polar_level_text_show: true,
18886
+ polar_padAngle: 0,
18887
+ polar_padding: 0,
18888
+ polar_startingAngle: 0
18889
+ };
18890
+
18635
18891
  /**
18636
18892
  * Copyright (c) 2017 ~ present NAVER Corp.
18637
18893
  * billboard.js project is licensed under the MIT license
@@ -18757,6 +19013,7 @@ var step = function () { return (extendLine(), (step = function () { return TYPE
18757
19013
  var donut = function () { return (extendArc(undefined, [optDonut]), (donut = function () { return TYPE.DONUT; })()); };
18758
19014
  var gauge = function () { return (extendArc([shapeGauge], [optGauge]), (gauge = function () { return TYPE.GAUGE; })()); };
18759
19015
  var pie = function () { return (extendArc(undefined, [optPie]), (pie = function () { return TYPE.PIE; })()); };
19016
+ var polar = function () { return (extendArc([shapePolar], [optPolar]), (polar = function () { return TYPE.POLAR; })()); };
18760
19017
  var radar = function () { return (extendArc([shapePoint, shapeRadar], [optPoint, optRadar]), (radar = function () { return TYPE.RADAR; })()); };
18761
19018
  // Axis based types
18762
19019
  var bar = function () { return (extendAxis([shapeBar], optBar), (bar = function () { return TYPE.BAR; })()); };
@@ -20391,7 +20648,7 @@ var zoomModule = function () {
20391
20648
  var defaults = {};
20392
20649
  /**
20393
20650
  * @namespace bb
20394
- * @version 3.3.3
20651
+ * @version 3.4.0-next.1
20395
20652
  */
20396
20653
  var bb = {
20397
20654
  /**
@@ -20401,7 +20658,7 @@ var bb = {
20401
20658
  * bb.version; // "1.0.0"
20402
20659
  * @memberof bb
20403
20660
  */
20404
- version: "3.3.3",
20661
+ version: "3.4.0-next.1",
20405
20662
  /**
20406
20663
  * Generate chart
20407
20664
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
@@ -20448,6 +20705,7 @@ var bb = {
20448
20705
  * gauge,
20449
20706
  * line,
20450
20707
  * pie,
20708
+ * polar,
20451
20709
  * radar,
20452
20710
  * scatter,
20453
20711
  * spline,
@@ -20529,4 +20787,4 @@ var bb = {
20529
20787
  plugin: {}
20530
20788
  };
20531
20789
 
20532
- export { area, areaLineRange, areaSpline, areaSplineRange, areaStep, bar, bb, bubble, candlestick, bb as default, donut, gauge, line, pie, radar, scatter, selectionModule as selection, spline, step, subchartModule as subchart, zoomModule as zoom };
20790
+ export { area, areaLineRange, areaSpline, areaSplineRange, areaStep, bar, bb, bubble, candlestick, bb as default, donut, gauge, line, pie, polar, radar, scatter, selectionModule as selection, spline, step, subchartModule as subchart, zoomModule as zoom };