billboard.js 3.16.0 → 3.17.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 (65) hide show
  1. package/dist/billboard.css +4 -4
  2. package/dist/billboard.js +654 -80
  3. package/dist/billboard.min.css +1 -1
  4. package/dist/billboard.min.js +12 -12
  5. package/dist/billboard.pkgd.js +1996 -784
  6. package/dist/billboard.pkgd.min.js +18 -17
  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 +18 -2
  10. package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
  11. package/dist/plugin/billboardjs-plugin-stanford.js +18 -2
  12. package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
  13. package/dist/plugin/billboardjs-plugin-tableview.js +16 -2
  14. package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
  15. package/dist/plugin/billboardjs-plugin-textoverlap.js +16 -2
  16. package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
  17. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1344 -706
  18. package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +6 -5
  19. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1454 -800
  20. package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +8 -7
  21. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +1455 -801
  22. package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +13 -12
  23. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1454 -802
  24. package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -9
  25. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1455 -803
  26. package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -6
  27. package/dist/theme/dark.css +4 -4
  28. package/dist/theme/dark.min.css +1 -1
  29. package/dist/theme/datalab.css +4 -4
  30. package/dist/theme/datalab.min.css +1 -1
  31. package/dist/theme/graph.css +4 -4
  32. package/dist/theme/graph.min.css +1 -1
  33. package/dist/theme/insight.css +4 -4
  34. package/dist/theme/insight.min.css +1 -1
  35. package/dist/theme/modern.css +4 -4
  36. package/dist/theme/modern.min.css +1 -1
  37. package/dist-esm/billboard.js +706 -77
  38. package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
  39. package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -2
  40. package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -2
  41. package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
  42. package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
  43. package/package.json +20 -20
  44. package/src/ChartInternal/Axis/AxisRenderer.ts +20 -13
  45. package/src/ChartInternal/Axis/AxisRendererHelper.ts +9 -4
  46. package/src/ChartInternal/ChartInternal.ts +1 -1
  47. package/src/ChartInternal/data/data.ts +2 -2
  48. package/src/ChartInternal/internals/color.ts +20 -14
  49. package/src/ChartInternal/internals/text.ts +40 -125
  50. package/src/ChartInternal/internals/text.util.ts +320 -0
  51. package/src/ChartInternal/shape/arc.ts +41 -19
  52. package/src/ChartInternal/shape/treemap.ts +5 -6
  53. package/src/config/Options/axis/x.ts +18 -0
  54. package/src/config/Options/axis/y.ts +17 -0
  55. package/src/config/Options/axis/y2.ts +31 -0
  56. package/src/config/Options/data/data.ts +125 -4
  57. package/src/config/Options/shape/donut.ts +77 -1
  58. package/src/config/Options/shape/gauge.ts +69 -2
  59. package/src/config/Options/shape/pie.ts +68 -1
  60. package/src/config/Options/shape/polar.ts +68 -1
  61. package/src/config/classes.ts +2 -0
  62. package/src/module/util.ts +26 -0
  63. package/types/axis.d.ts +10 -0
  64. package/types/options.d.ts +138 -1
  65. package/types/options.shape.d.ts +302 -2
package/dist/billboard.js CHANGED
@@ -5,7 +5,7 @@
5
5
  * billboard.js, JavaScript chart library
6
6
  * https://naver.github.io/billboard.js/
7
7
  *
8
- * @version 3.16.0
8
+ * @version 3.17.0-next.1
9
9
  */
10
10
  (function webpackUniversalModuleDefinition(root, factory) {
11
11
  if(typeof exports === 'object' && typeof module === 'object')
@@ -379,6 +379,8 @@ const $TEXT = {
379
379
  text: "bb-text",
380
380
  texts: "bb-texts",
381
381
  title: "bb-title",
382
+ textBorderRect: "bb-text-border",
383
+ textLabelImage: "bb-text-label-image",
382
384
  TextOverlapping: "text-overlapping"
383
385
  };
384
386
  const $TOOLTIP = {
@@ -1709,7 +1711,10 @@ const $ZOOM = {
1709
1711
  * - `i` is the index of the data series point where the label is shown.
1710
1712
  * - `texts` is the array of whole corresponding data series' text labels.<br><br>
1711
1713
  * Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
1712
- * @property {string|object} [data.labels.backgroundColors] Set label text background colors.
1714
+ * @property {string|object|Function} [data.labels.backgroundColors] Set label text background colors.<br><br>
1715
+ * - **NOTE**: When function is set, background colors can be specified one color per dataset.
1716
+ * - Within the function, the last returned color for dataset will be used.
1717
+ * - Only can control set or unset background color for each values.
1713
1718
  * @property {string|object|Function} [data.labels.colors] Set label text colors.
1714
1719
  * @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
1715
1720
  * When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
@@ -1723,12 +1728,32 @@ const $ZOOM = {
1723
1728
  * @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
1724
1729
  * @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
1725
1730
  * - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
1731
+ * @property {boolean|object} [data.labels.border=false] Add border to data label text. NOTE: When set as `true`, styling aren't applied. Hence, need to set using `.bb-text-border` class.
1732
+ * @property {number|string|object} [data.labels.border.padding="3 5"] Border padding. Can be a single number, string or object with top, bottom, left, right properties.
1733
+ * @property {number} [data.labels.border.radius=10] Border radius value.
1734
+ * @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
1735
+ * @property {string} [data.labels.border.stroke="#000"] Border stroke color.
1736
+ * @property {string} [data.labels.border.fill="none"] Border fill color.
1737
+ * @property {object|Function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
1738
+ * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
1739
+ * The arguments are:<br>
1740
+ * - `v` is the value of the data point where the label is shown.
1741
+ * - `id` is the id of the data where the label is shown.
1742
+ * - `i` is the index of the data series point where the label is shown.
1743
+ * @property {string} data.labels.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
1744
+ * @property {number} data.labels.image.width Image width in pixels.
1745
+ * @property {number} data.labels.image.height Image height in pixels.
1746
+ * @property {object} [data.labels.image.pos] Image position relative to the label text.
1747
+ * @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
1748
+ * @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
1726
1749
  * @memberof Options
1727
1750
  * @type {object}
1728
1751
  * @default {}
1729
1752
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
1753
+ * @see [Demo: label border](https://naver.github.io/billboard.js/demo/#Data.DataLabelBorder)
1730
1754
  * @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
1731
1755
  * @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
1756
+ * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#Data.DataLabelImage)
1732
1757
  * @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
1733
1758
  * @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
1734
1759
  * @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
@@ -1761,7 +1786,15 @@ const $ZOOM = {
1761
1786
  * backgroundColors: {
1762
1787
  * data1: "green",
1763
1788
  * data2: "yellow"
1764
- * }
1789
+ * },
1790
+ *
1791
+ * // call back for label text background color
1792
+ * backgroundColors: function(color, d) {
1793
+ * // color: the default data label color string
1794
+ * // data: ex) {x: 0, value: 200, id: "data3", index: 0}
1795
+ * ....
1796
+ * return d.value > 200 ? "cyan" : "red";
1797
+ * },
1765
1798
  *
1766
1799
  * // apply for all label texts
1767
1800
  * colors: "red",
@@ -1801,7 +1834,76 @@ const $ZOOM = {
1801
1834
  * },
1802
1835
  *
1803
1836
  * // rotate degree for label text
1804
- * rotate: 90
1837
+ * rotate: 90,
1838
+ *
1839
+ * // add border to data label text
1840
+ * // NOTE: When set as `true`, styling aren't applied. Hence, need to set using '.bb-text-border' class.
1841
+ * // ex. ".bb-text-border { fill: red; stroke: #000; stroke-width: 2px; rx: 10px; ry: 10px; }"
1842
+ * border: true,
1843
+ *
1844
+ * // or set detailed border options
1845
+ * border: {
1846
+ * padding: 10, // set all padding to 10
1847
+ * padding: "5 10", // set top and bottom padding to 5, left and right padding to 10
1848
+ * padding: { // specify each padding
1849
+ * top: 3,
1850
+ * bottom: 5,
1851
+ * left: 10,
1852
+ * right: 13
1853
+ * },
1854
+ * radius: 10,
1855
+ * strokeWidth: 2,
1856
+ * stroke: "#000",
1857
+ * fill: "red"
1858
+ * },
1859
+ *
1860
+ * // set image to be displayed next to the label text
1861
+ * image: {
1862
+ * url: "./sample.svg",
1863
+ *
1864
+ * // use placeholder to dynamically set image URL based on data ID
1865
+ * url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
1866
+ * width: 35,
1867
+ * height: 35,
1868
+ * pos: {
1869
+ * x: 0,
1870
+ * y: 0
1871
+ * }
1872
+ * },
1873
+ *
1874
+ * // or use function to return image configuration dynamically
1875
+ * image: function(v, id, i) {
1876
+ * // v is the value of the data point where the label is shown.
1877
+ * // id is the id of the data where the label is shown.
1878
+ * // i is the index of the data series point where the label is shown.
1879
+ *
1880
+ * // Return different images based on value
1881
+ * if (v > 500) {
1882
+ * return {
1883
+ * url: "./high-value.svg",
1884
+ * width: 40,
1885
+ * height: 40,
1886
+ * pos: { x: 0, y: 0 }
1887
+ * };
1888
+ * } else if (v > 100) {
1889
+ * return {
1890
+ * url: "./medium-value.svg",
1891
+ * width: 30,
1892
+ * height: 30,
1893
+ * pos: { x: 0, y: 0 }
1894
+ * };
1895
+ * } else if(v < 5) {
1896
+ * // Return falsy value in case of don't want to show image
1897
+ * return null;
1898
+ * } else {
1899
+ * return {
1900
+ * url: "./low-value.svg",
1901
+ * width: 20,
1902
+ * height: 20,
1903
+ * pos: { x: 0, y: 0 }
1904
+ * };
1905
+ * }
1906
+ * }
1805
1907
  * }
1806
1908
  * }
1807
1909
  */
@@ -1809,6 +1911,7 @@ const $ZOOM = {
1809
1911
  data_labels_backgroundColors: void 0,
1810
1912
  data_labels_colors: void 0,
1811
1913
  data_labels_position: {},
1914
+ data_labels_imgUrl: void 0,
1812
1915
  /**
1813
1916
  * Hide each data when the chart appears.<br><br>
1814
1917
  * If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
@@ -2762,6 +2865,20 @@ function runUntil(fn, conditionFn) {
2762
2865
  fn();
2763
2866
  }
2764
2867
  }
2868
+ function parseShorthand(value) {
2869
+ if (isObject(value) && !isString(value)) {
2870
+ const obj = value;
2871
+ return {
2872
+ top: obj.top || 0,
2873
+ right: obj.right || 0,
2874
+ bottom: obj.bottom || 0,
2875
+ left: obj.left || 0
2876
+ };
2877
+ }
2878
+ const values = (isString(value) ? value.trim().split(/\s+/) : [value]).map((v) => +v || 0);
2879
+ const [a, b = a, c = a, d = b] = values;
2880
+ return { top: a, right: b, bottom: c, left: d };
2881
+ }
2765
2882
 
2766
2883
  ;// ./src/config/Options/Options.ts
2767
2884
  var Options_defProp = Object.defineProperty;
@@ -5070,7 +5187,7 @@ const schemeCategory10 = [
5070
5187
  },
5071
5188
  /**
5072
5189
  * Append data backgound color filter definition
5073
- * @param {string|object} color Color string
5190
+ * @param {string|object|Function} color Color string, object, or function
5074
5191
  * @param {object} attr filter attribute
5075
5192
  * @private
5076
5193
  */
@@ -5081,20 +5198,25 @@ const schemeCategory10 = [
5081
5198
  height: 1
5082
5199
  }) {
5083
5200
  const $$ = this;
5084
- const { $el, state } = $$;
5201
+ const { $el: { defs }, state } = $$;
5085
5202
  if (color) {
5086
5203
  let ids = [];
5087
5204
  if (isString(color)) {
5088
5205
  ids.push("");
5089
5206
  } else if (isObject(color)) {
5090
5207
  ids = Object.keys(color);
5208
+ } else if (isFunction(color)) {
5209
+ ids = $$.mapToTargetIds();
5091
5210
  }
5092
5211
  ids.forEach((v) => {
5093
5212
  const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${isString(color) ? $$.getTargetSelectorSuffix(color) : ""}`;
5094
- $el.defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(
5095
- `<feFlood flood-color="${v === "" ? color : color[v]}" />
5096
- <feComposite in="SourceGraphic" />`
5097
- );
5213
+ const colorValue = v === "" ? color : (color == null ? void 0 : color[v]) || "";
5214
+ if (defs.select(`#${id}`).empty()) {
5215
+ defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(
5216
+ `<feFlood flood-color="${colorValue}" />
5217
+ <feComposite in="SourceGraphic" />`
5218
+ );
5219
+ }
5098
5220
  });
5099
5221
  }
5100
5222
  },
@@ -6972,8 +7094,7 @@ function getScale(type = "linear", min, max) {
6972
7094
  }
6973
7095
  });
6974
7096
 
6975
- ;// ./src/ChartInternal/internals/text.ts
6976
-
7097
+ ;// ./src/ChartInternal/internals/text.util.ts
6977
7098
 
6978
7099
 
6979
7100
 
@@ -7028,13 +7149,139 @@ function getTextPos(d, type) {
7028
7149
  const { id, index, value } = d;
7029
7150
  return (_a = isFunction(position) ? position.bind(this.api)(type, value, id, index, this.$el.text) : (id in position ? position[id] : position)[type]) != null ? _a : 0;
7030
7151
  }
7152
+ function updateTextBorder(text, pos, rectClass) {
7153
+ var _a, _b;
7154
+ const $$ = this;
7155
+ const { config, $T } = $$;
7156
+ const isRotated = config.axis_rotated;
7157
+ const {
7158
+ border: {
7159
+ padding = "3 5",
7160
+ radius = 10,
7161
+ stroke = "#000",
7162
+ strokeWidth = 1,
7163
+ fill = "none"
7164
+ }
7165
+ } = config.data_labels;
7166
+ const borderPadding = parseShorthand(padding);
7167
+ const applyStyle = config.data_labels.border !== true;
7168
+ const textRect = getBBox(text);
7169
+ let borderRect = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(text.previousElementSibling);
7170
+ if (borderRect.empty() || ((_a = borderRect.node()) == null ? void 0 : _a.tagName) !== "rect" || !((_b = borderRect.attr("class")) == null ? void 0 : _b.includes(rectClass))) {
7171
+ borderRect = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(text.parentNode).insert("rect", () => text).attr("class", `${$TEXT.textBorderRect} ${rectClass}`).attr(
7172
+ "width",
7173
+ textRect.width + (applyStyle ? borderPadding.left + borderPadding.right : 0)
7174
+ ).attr(
7175
+ "height",
7176
+ textRect.height + (applyStyle ? borderPadding.top + borderPadding.bottom : 0)
7177
+ );
7178
+ if (applyStyle) {
7179
+ borderRect.style("fill", fill).style("stroke", stroke).style("stroke-width", `${strokeWidth}px`).attr("rx", radius).attr("ry", radius);
7180
+ }
7181
+ }
7182
+ $T(borderRect).attr(
7183
+ "x",
7184
+ pos.x - (applyStyle ? borderPadding.left : 0) - (isRotated ? 0 : textRect.width / 2)
7185
+ ).attr("y", pos.y - (applyStyle ? borderPadding.top : 0) - textRect.height / 4 * 3.2);
7186
+ }
7187
+ function meetsLabelThreshold(ratio = 0, type) {
7188
+ const $$ = this;
7189
+ const { config } = $$;
7190
+ const threshold = config[`${type}_label_threshold`] || 0;
7191
+ return ratio >= threshold;
7192
+ }
7193
+ function updateTextImage() {
7194
+ const $$ = this;
7195
+ const { $el: { text }, config } = $$;
7196
+ const isArc = $$.state.arcWidth;
7197
+ if (isArc ? $$.getArcLabelConfig("image") : config.data_labels.image) {
7198
+ text.filter(function() {
7199
+ const prev = this.previousElementSibling;
7200
+ if (prev) {
7201
+ return prev.tagName !== "image" || !prev.classList.contains($TEXT.textLabelImage);
7202
+ }
7203
+ return true;
7204
+ }).each(function(d) {
7205
+ var _a, _b, _c, _d;
7206
+ const { url, width, height, pos } = getDataLabelImgUrl.call($$, d);
7207
+ if (url) {
7208
+ const parentNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode);
7209
+ parentNode == null ? void 0 : parentNode.insert(
7210
+ "image",
7211
+ `${(_b = (_a = this.getAttribute("class")) == null ? void 0 : _a.replace(/(?:^(.)|\s)/g, ".$1")) != null ? _b : "text"}`
7212
+ ).style("opacity", "0").attr("href", (d2) => tplProcess(url, {
7213
+ ID: "id" in d2 ? d2.id : d2.data.id
7214
+ })).attr("class", $TEXT.textLabelImage).style("pointer-events", "none").attr("width", width).attr("height", height).attr("transform", pos ? `translate(${(_c = pos.x) != null ? _c : 0} ${(_d = pos.y) != null ? _d : 0})` : null);
7215
+ }
7216
+ });
7217
+ }
7218
+ }
7219
+ function getDataLabelImgUrl(d) {
7220
+ var _a;
7221
+ const $$ = this;
7222
+ const { config, state } = $$;
7223
+ const image = state.arcWidth ? $$.getArcLabelConfig("image") : config.data_labels.image;
7224
+ if (isFunction(image)) {
7225
+ return (_a = image.call($$.api, d.value, d.id, d.index)) != null ? _a : {
7226
+ url: "",
7227
+ width: 0,
7228
+ height: 0,
7229
+ pos: { x: 0, y: 0 }
7230
+ };
7231
+ } else if (image) {
7232
+ const { url = "", width = 0, height = 0, pos } = image;
7233
+ return {
7234
+ url,
7235
+ width,
7236
+ height,
7237
+ pos
7238
+ };
7239
+ }
7240
+ return null;
7241
+ }
7242
+ function updateTextImagePos(textNode, pos) {
7243
+ var _a;
7244
+ const $$ = this;
7245
+ const { config, state: { arcWidth, hasTreemap } } = $$;
7246
+ const isRotated = config.axis_rotated;
7247
+ const image = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(textNode.previousElementSibling);
7248
+ const isShown = (textNode2) => {
7249
+ var _a2;
7250
+ const isShown2 = textNode2.style.opacity !== "0" && textNode2.style.fillOpacity !== "0";
7251
+ return (arcWidth ? textNode2.textContent : isShown2) && ((_a2 = this.previousElementSibling) == null ? void 0 : _a2.tagName) !== "image";
7252
+ };
7253
+ if (!image.empty() && ((_a = image.node()) == null ? void 0 : _a.tagName) === "image") {
7254
+ const textRect = getBoundingRect(textNode);
7255
+ const w = +image.attr("width") / 2;
7256
+ const h = +image.attr("height") / 2;
7257
+ let x = pos.x - w;
7258
+ let y = pos.y - h - textRect.height / 2;
7259
+ if (isRotated) {
7260
+ pos.x += w;
7261
+ } else {
7262
+ if (hasTreemap) {
7263
+ x = -w;
7264
+ y = -(h * 2 + textRect.height);
7265
+ }
7266
+ if (!($$.hasType("pie") || $$.hasType("polar"))) {
7267
+ pos.y += h;
7268
+ }
7269
+ }
7270
+ $$.$T(image).style("opacity", isShown(textNode) ? null : "0").attr("x", x).attr("y", y);
7271
+ }
7272
+ }
7273
+
7274
+
7275
+ ;// ./src/ChartInternal/internals/text.ts
7276
+
7277
+
7278
+
7279
+
7280
+
7031
7281
  /* harmony default export */ var internals_text = ({
7032
7282
  opacityForText(d) {
7033
7283
  const $$ = this;
7034
- return $$.isBarType(d) && !$$.meetsLabelThreshold(
7035
- Math.abs($$.getRatio("bar", d)),
7036
- "bar"
7037
- ) ? "0" : $$.hasDataLabel ? null : "0";
7284
+ return $$.isBarType(d) && !meetsLabelThreshold.call($$, Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? null : "0";
7038
7285
  },
7039
7286
  /**
7040
7287
  * Initializes the text
@@ -7104,6 +7351,7 @@ function getTextPos(d, type) {
7104
7351
  setTextValue(node, value);
7105
7352
  }
7106
7353
  });
7354
+ updateTextImage.call($$);
7107
7355
  },
7108
7356
  updateTextColor(d) {
7109
7357
  const $$ = this;
@@ -7131,20 +7379,30 @@ function getTextPos(d, type) {
7131
7379
  /**
7132
7380
  * Update data label text background color
7133
7381
  * @param {object} d Data object
7134
- * @param {object|string} option option object
7382
+ * @param {object|string|Function} option option object
7135
7383
  * @returns {string|null}
7136
7384
  * @private
7137
7385
  */
7138
7386
  updateTextBGColor(d, option) {
7139
7387
  const $$ = this;
7140
- const { $el } = $$;
7388
+ const { $el: { defs } } = $$;
7141
7389
  let color = "";
7142
- if (isString(option) || isObject(option)) {
7390
+ if (option) {
7143
7391
  const id = isString(option) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id);
7144
- const filter = $el.defs.select(["filter[id*='labels-bg", "']"].join(id));
7392
+ const filter = defs.select(["filter[id*='labels-bg", "']"].join(id));
7145
7393
  if (filter.size()) {
7146
7394
  color = `url(#${filter.attr("id")})`;
7147
7395
  }
7396
+ if (isFunction(option)) {
7397
+ $$.generateTextBGColorFilter(option);
7398
+ const defaultColor = $$.color(d);
7399
+ const bgColor = option.bind($$.api)(defaultColor, d);
7400
+ if (bgColor) {
7401
+ filter.select("feFlood").attr("flood-color", bgColor);
7402
+ } else {
7403
+ color = "";
7404
+ }
7405
+ }
7148
7406
  }
7149
7407
  return color || null;
7150
7408
  },
@@ -7171,7 +7429,7 @@ function getTextPos(d, type) {
7171
7429
  ).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function(d, i) {
7172
7430
  const node = $T(
7173
7431
  hasTreemap && this.childElementCount ? this.parentNode : this,
7174
- !!(withTransition && this.getAttribute("x")),
7432
+ !!(withTransition && (this.getAttribute("x") || this.getAttribute("transform"))),
7175
7433
  t
7176
7434
  );
7177
7435
  const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
@@ -7183,11 +7441,13 @@ function getTextPos(d, type) {
7183
7441
  pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
7184
7442
  node.attr("text-anchor", anchorString);
7185
7443
  }
7444
+ updateTextImagePos.call($$, this, pos);
7186
7445
  if (this.childElementCount || angle) {
7187
7446
  node.attr("transform", `translate(${pos.x} ${pos.y}) ${rotateString}`);
7188
7447
  } else {
7189
7448
  node.attr("x", pos.x).attr("y", pos.y);
7190
7449
  }
7450
+ config.data_labels.border && updateTextBorder.call($$, node.node(), pos, `${$TEXT.textBorderRect}-${i}`);
7191
7451
  });
7192
7452
  return true;
7193
7453
  },
@@ -7424,19 +7684,6 @@ function getTextPos(d, type) {
7424
7684
  $$.$el.arcs.selectAll(selector).each(function() {
7425
7685
  (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed($TEXT.TextOverlapping, false);
7426
7686
  });
7427
- },
7428
- /**
7429
- * Check if meets the ratio to show data label text
7430
- * @param {number} ratio ratio to meet
7431
- * @param {string} type chart type
7432
- * @returns {boolean}
7433
- * @private
7434
- */
7435
- meetsLabelThreshold(ratio = 0, type) {
7436
- const $$ = this;
7437
- const { config } = $$;
7438
- const threshold = config[`${type}_label_threshold`] || 0;
7439
- return ratio >= threshold;
7440
7687
  }
7441
7688
  });
7442
7689
 
@@ -9005,7 +9252,7 @@ class ChartInternal {
9005
9252
  if (hasAxis || hasColorPatterns || hasPolar || hasTreemap || labelsBGColor || ((_a = $$.hasLegendDefsPoint) == null ? void 0 : _a.call($$))) {
9006
9253
  $el.defs = $el.svg.append("defs");
9007
9254
  if (hasAxis) {
9008
- ["id", "idXAxis", "idYAxis", "idGrid"].forEach((v) => {
9255
+ ["id", "idXAxis", "idYAxis", "idY2Axis", "idGrid"].forEach((v) => {
9009
9256
  $$.appendClip($el.defs, state.clip[v]);
9010
9257
  });
9011
9258
  }
@@ -12834,6 +13081,7 @@ class AxisRendererHelper {
12834
13081
  AxisRendererHelper_publicField(this, "owner");
12835
13082
  AxisRendererHelper_publicField(this, "config");
12836
13083
  AxisRendererHelper_publicField(this, "scale");
13084
+ AxisRendererHelper_publicField(this, "charSize", {});
12837
13085
  const scale = getScale();
12838
13086
  const { config, params } = owner;
12839
13087
  this.owner = owner;
@@ -12846,16 +13094,20 @@ class AxisRendererHelper {
12846
13094
  }
12847
13095
  /**
12848
13096
  * Compute a character dimension
13097
+ * @param {string} orient Axis orientation
12849
13098
  * @param {d3.selection} text SVG text selection
12850
13099
  * @param {boolean} memoize memoize the calculated size
12851
13100
  * @returns {{w: number, h: number}}
12852
13101
  * @private
12853
13102
  */
12854
- static getSizeFor1Char(text, memoize = true) {
13103
+ getSizeFor1Char(orient, text, memoize = true) {
12855
13104
  const size = {
12856
13105
  w: 5.5,
12857
13106
  h: 11.5
12858
13107
  };
13108
+ if (this.charSize[orient] && memoize) {
13109
+ return this.charSize[orient];
13110
+ }
12859
13111
  !text.empty() && text.text("0").call((el) => {
12860
13112
  try {
12861
13113
  const { width, height } = getBBox(el.node(), true);
@@ -12867,9 +13119,7 @@ class AxisRendererHelper {
12867
13119
  el.text("");
12868
13120
  }
12869
13121
  });
12870
- if (memoize) {
12871
- this.getSizeFor1Char = () => size;
12872
- }
13122
+ this.charSize[orient] = size;
12873
13123
  return size;
12874
13124
  }
12875
13125
  /**
@@ -13040,15 +13290,15 @@ class AxisRenderer {
13040
13290
  tickShow.text && tickEnter.append("text");
13041
13291
  const tickText = tick.select("text");
13042
13292
  const counts = [];
13043
- let sizeFor1Char;
13293
+ let sizeFor1Char = { w: 0, h: 0 };
13044
13294
  if (isFunction(evalTextSize)) {
13045
13295
  sizeFor1Char = evalTextSize.bind(ctx.params.owner.api)(tickText.node(), id);
13046
13296
  if (this.classList.contains($COMMON.dummy)) {
13047
13297
  this.sizeFor1Char = sizeFor1Char;
13048
13298
  }
13049
13299
  }
13050
- if (!sizeFor1Char) {
13051
- sizeFor1Char = AxisRendererHelper.getSizeFor1Char(tickText, !!evalTextSize);
13300
+ if (!sizeFor1Char || sizeFor1Char.w === 0 || sizeFor1Char.h === 0) {
13301
+ sizeFor1Char = ctx.helper.getSizeFor1Char(orient, tickText, !!evalTextSize);
13052
13302
  }
13053
13303
  let tspan = tickText.selectAll("tspan").data((d, index) => {
13054
13304
  const split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
@@ -13078,7 +13328,7 @@ class AxisRenderer {
13078
13328
  const textUpdate = tick.select("text");
13079
13329
  tickEnter.select("line").attr(`${axisPx}2`, innerTickSize * sign);
13080
13330
  tickEnter.select("text").attr(axisPx, tickLength * sign);
13081
- ctx.setTickLineTextPosition(lineUpdate, textUpdate);
13331
+ ctx.setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char);
13082
13332
  if (params.tickTitle) {
13083
13333
  const title = textUpdate.select("title");
13084
13334
  (title.empty() ? textUpdate.append("title") : title).text((index) => params.tickTitle[index]);
@@ -13147,12 +13397,16 @@ class AxisRenderer {
13147
13397
  * Set tick's line & text position
13148
13398
  * @param {d3.selection} lineUpdate Line selection
13149
13399
  * @param {d3.selection} textUpdate Text selection
13400
+ * @param {object} sizeFor1Char Size for 1 char
13150
13401
  * @private
13151
13402
  */
13152
- setTickLineTextPosition(lineUpdate, textUpdate) {
13403
+ setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char) {
13153
13404
  const tickPos = this.getTickXY();
13154
13405
  const { innerTickSize, orient, tickLength, tickOffset } = this.config;
13406
+ const axisId = this.params.id;
13155
13407
  const rotate = this.params.tickTextRotate;
13408
+ const baseHeight = 6;
13409
+ const charHeight = sizeFor1Char.h / 2 - baseHeight;
13156
13410
  const textAnchorForText = (r) => {
13157
13411
  const value = ["start", "end"];
13158
13412
  orient === "top" && value.reverse();
@@ -13161,7 +13415,8 @@ class AxisRenderer {
13161
13415
  const textTransform = (r) => r ? `rotate(${r})` : null;
13162
13416
  const yForText = (r) => {
13163
13417
  const r2 = r / (orient === "bottom" ? 15 : 23);
13164
- return r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
13418
+ const y = r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
13419
+ return y;
13165
13420
  };
13166
13421
  const {
13167
13422
  config: {
@@ -13169,9 +13424,10 @@ class AxisRenderer {
13169
13424
  axis_x_tick_text_inner: inner
13170
13425
  }
13171
13426
  } = this.params.owner;
13427
+ const tickLineInner = this.params.config[`axis_${axisId}_tick_inner`];
13172
13428
  switch (orient) {
13173
13429
  case "bottom":
13174
- lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this));
13430
+ lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", (d) => this.getTickSize.bind(this)(d) * (tickLineInner ? -1 : 1));
13175
13431
  textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).style("text-anchor", (d, i, { length }) => {
13176
13432
  if (!isRotated && i === 0 && (inner === true || inner.first)) {
13177
13433
  return "start";
@@ -13182,16 +13438,16 @@ class AxisRenderer {
13182
13438
  }).attr("transform", textTransform(rotate));
13183
13439
  break;
13184
13440
  case "top":
13185
- lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
13186
- textUpdate.attr("x", 0).attr("y", -yForText(rotate) * 2).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
13441
+ lineUpdate.attr("x2", 0).attr("y2", tickLineInner ? innerTickSize : -innerTickSize);
13442
+ textUpdate.attr("x", 0).attr("y", -(yForText(rotate) + charHeight + baseHeight)).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
13187
13443
  break;
13188
13444
  case "left":
13189
- lineUpdate.attr("x2", -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
13190
- textUpdate.attr("x", -tickLength).attr("y", tickOffset).style("text-anchor", "end");
13445
+ lineUpdate.attr("x2", tickLineInner ? innerTickSize : -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
13446
+ textUpdate.attr("x", -tickLength).attr("y", tickOffset + (isRotated ? charHeight / 4 : charHeight)).style("text-anchor", "end");
13191
13447
  break;
13192
13448
  case "right":
13193
- lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
13194
- textUpdate.attr("x", tickLength).attr("y", 0).style("text-anchor", "start");
13449
+ lineUpdate.attr("x2", tickLineInner ? -innerTickSize : innerTickSize).attr("y2", 0);
13450
+ textUpdate.attr("x", tickLength).attr("y", charHeight).style("text-anchor", "start");
13195
13451
  }
13196
13452
  }
13197
13453
  // this should be called only when category axis
@@ -13485,7 +13741,7 @@ class Axis_Axis {
13485
13741
  v.domain && scale.domain(v.domain);
13486
13742
  axes.push(
13487
13743
  d3Axis(scale).ticks(tick.count).tickFormat(
13488
- isFunction(tick.format) ? tick.format.bind($$.api) : (x) => x
13744
+ isFunction(tick.format) ? tick.format.bind($$.api) : ((x) => x)
13489
13745
  ).tickValues(tick.values).tickSizeOuter(tick.outer === false ? 0 : 6)
13490
13746
  );
13491
13747
  });
@@ -15735,6 +15991,23 @@ function smoothLines(el, type) {
15735
15991
  * }
15736
15992
  */
15737
15993
  axis_x_tick_count: void 0,
15994
+ /**
15995
+ * Set the axis tick line to be positioned inside of the chart.
15996
+ * @name axis․x․tick․inner
15997
+ * @memberof Options
15998
+ * @type {boolean}
15999
+ * @default false
16000
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
16001
+ * @example
16002
+ * axis: {
16003
+ * x: {
16004
+ * tick: {
16005
+ * inner: true
16006
+ * }
16007
+ * }
16008
+ * }
16009
+ */
16010
+ axis_x_tick_inner: false,
15738
16011
  /**
15739
16012
  * Show or hide x axis tick line.
15740
16013
  * @name axis․x․tick․show
@@ -16470,6 +16743,22 @@ function smoothLines(el, type) {
16470
16743
  * }
16471
16744
  */
16472
16745
  axis_y_tick_culling_reverse: false,
16746
+ /**
16747
+ * Set the axis tick line to be positioned inside of the chart.
16748
+ * @name axis․y․tick․inner
16749
+ * @memberof Options
16750
+ * @type {boolean}
16751
+ * @default false
16752
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
16753
+ * axis: {
16754
+ * y: {
16755
+ * tick: {
16756
+ * inner: true
16757
+ * }
16758
+ * }
16759
+ * }
16760
+ */
16761
+ axis_y_tick_inner: false,
16473
16762
  /**
16474
16763
  * Show y axis outer tick.
16475
16764
  * @name axis․y․tick․outer
@@ -16725,6 +17014,18 @@ function smoothLines(el, type) {
16725
17014
 
16726
17015
  ;// ./src/config/Options/axis/y2.ts
16727
17016
  /* harmony default export */ var y2 = ({
17017
+ /**
17018
+ * Set clip-path attribute for y2 axis element
17019
+ * - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
17020
+ * @name axis․y2․clipPath
17021
+ * @memberof Options
17022
+ * @type {boolean}
17023
+ * @default true
17024
+ * @example
17025
+ * // don't set 'clip-path' attribute
17026
+ * clipPath: false
17027
+ */
17028
+ axis_y2_clipPath: true,
16728
17029
  /**
16729
17030
  * Show or hide y2 axis.
16730
17031
  * - **NOTE**:
@@ -16958,6 +17259,23 @@ function smoothLines(el, type) {
16958
17259
  * }
16959
17260
  */
16960
17261
  axis_y2_tick_culling_reverse: false,
17262
+ /**
17263
+ * Set the axis tick line to be positioned inside of the chart.
17264
+ * @name axis․y2․tick․inner
17265
+ * @memberof Options
17266
+ * @type {boolean}
17267
+ * @default false
17268
+ * @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
17269
+ * @example
17270
+ * axis: {
17271
+ * y2: {
17272
+ * tick: {
17273
+ * inner: true
17274
+ * }
17275
+ * }
17276
+ * }
17277
+ */
17278
+ axis_y2_tick_inner: false,
16961
17279
  /**
16962
17280
  * Show or hide y2 axis outer tick.
16963
17281
  * @name axis․y2․tick․outer
@@ -17582,6 +17900,7 @@ var arc_spreadProps = (a, b) => arc_defProps(a, arc_getOwnPropDescs(b));
17582
17900
 
17583
17901
 
17584
17902
 
17903
+
17585
17904
  function getRadiusFn(expandRate = 0) {
17586
17905
  const $$ = this;
17587
17906
  const { config, state } = $$;
@@ -17872,7 +18191,9 @@ function getAttrTweenFn(fn) {
17872
18191
  return isFunction(format) ? format(range) : `${range}${isPercent ? "%" : ""}`;
17873
18192
  }).merge(rangeText));
17874
18193
  if ((!state.rendered || state.rendered && !fixed) && totalSum > 0) {
17875
- rangeText.attr("transform", (d, i) => $$.transformForArcLabel(pieData[i], true));
18194
+ rangeText.attr("transform", function(d, i) {
18195
+ return $$.transformForArcLabel(this, pieData[i], true);
18196
+ });
17876
18197
  }
17877
18198
  rangeText.style(
17878
18199
  "opacity",
@@ -17882,30 +18203,32 @@ function getAttrTweenFn(fn) {
17882
18203
  },
17883
18204
  /**
17884
18205
  * Set transform attributes to arc label text
18206
+ * @param {SVGTextElement} textNode Text node element
17885
18207
  * @param {object} d Data object
17886
18208
  * @param {boolean} forRange Weather is for ranged text option(arc.rangeText.values)
17887
18209
  * @returns {string} Translate attribute string
17888
18210
  * @private
17889
18211
  */
17890
- transformForArcLabel(d, forRange = false) {
18212
+ transformForArcLabel(textNode, d, forRange = false) {
17891
18213
  var _a, _b, _c;
17892
18214
  const $$ = this;
17893
18215
  const { config, state: { radiusExpanded } } = $$;
17894
18216
  const updated = $$.updateAngle(d, forRange);
18217
+ const pos = { x: 0, y: 0 };
17895
18218
  let translate = "";
18219
+ let ratio = 1;
17896
18220
  if (updated) {
17897
18221
  if (forRange || $$.hasMultiArcGauge()) {
17898
18222
  const y1 = Math.sin(updated.endAngle - Math.PI / 2);
17899
18223
  const rangeTextPosition = config.arc_rangeText_position;
17900
- let x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + (forRange ? 5 : 25));
17901
- let y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
18224
+ pos.x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + (forRange ? 5 : 25));
18225
+ pos.y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
17902
18226
  if (forRange && rangeTextPosition) {
17903
18227
  const rangeValues = config.arc_rangeText_values;
17904
- const pos = isFunction(rangeTextPosition) ? rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
17905
- x += (_a = pos == null ? void 0 : pos.x) != null ? _a : 0;
17906
- y += (_b = pos == null ? void 0 : pos.y) != null ? _b : 0;
18228
+ const position = isFunction(rangeTextPosition) ? rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
18229
+ pos.x += (_a = position == null ? void 0 : position.x) != null ? _a : 0;
18230
+ pos.y += (_b = position == null ? void 0 : position.y) != null ? _b : 0;
17907
18231
  }
17908
- translate = `translate(${x},${y})`;
17909
18232
  } else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
17910
18233
  let { outerRadius } = $$.getRadius(d);
17911
18234
  if ($$.hasType("polar")) {
@@ -17914,14 +18237,17 @@ function getAttrTweenFn(fn) {
17914
18237
  const c = this.svgArc.centroid(updated);
17915
18238
  const [x, y] = c.map((v) => isNaN(v) ? 0 : v);
17916
18239
  const h = Math.sqrt(x * x + y * y);
17917
- let ratio = (_c = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).map((v) => config[`${v}_label_ratio`])) == null ? void 0 : _c[0];
18240
+ pos.x = x;
18241
+ pos.y = y;
18242
+ ratio = (_c = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).map((v) => config[`${v}_label_ratio`])) == null ? void 0 : _c[0];
17918
18243
  if (ratio) {
17919
18244
  ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
17920
18245
  } else {
17921
18246
  ratio = outerRadius && (h ? (36 / outerRadius > 0.375 ? 1.175 - 36 / outerRadius : 0.8) * outerRadius / h : 0);
17922
18247
  }
17923
- translate = `translate(${x * ratio},${y * ratio})`;
17924
18248
  }
18249
+ updateTextImagePos.call($$, textNode, pos);
18250
+ translate = `translate(${pos.x * ratio},${pos.y * ratio})`;
17925
18251
  }
17926
18252
  return translate;
17927
18253
  },
@@ -17942,13 +18268,14 @@ function getAttrTweenFn(fn) {
17942
18268
  const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
17943
18269
  const updated = $$.updateAngle(d);
17944
18270
  const ratio = $$.getRatio("arc", updated);
17945
- const isUnderThreshold = $$.meetsLabelThreshold(
18271
+ const isUnderThreshold = meetsLabelThreshold.call(
18272
+ $$,
17946
18273
  ratio,
17947
18274
  (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _a[0]
17948
18275
  );
17949
18276
  if (isUnderThreshold) {
17950
18277
  const { value } = updated || d;
17951
- const text = ($$.getArcLabelFormat() || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
18278
+ const text = ($$.getArcLabelConfig("format") || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
17952
18279
  setTextValue(node, text, [-1, 1], hasGauge);
17953
18280
  } else {
17954
18281
  node.text("");
@@ -18024,14 +18351,18 @@ function getAttrTweenFn(fn) {
18024
18351
  const { config } = $$;
18025
18352
  return ["donut", "gauge", "pie", "polar"].some((v) => $$.hasType(v) && config[`${v}_label_show`]);
18026
18353
  },
18027
- getArcLabelFormat() {
18354
+ getArcLabelConfig(name = "format") {
18028
18355
  const $$ = this;
18029
18356
  const { config } = $$;
18030
- let format = (v) => v;
18357
+ let fn = (v) => v;
18031
18358
  ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).forEach((v) => {
18032
- format = config[`${v}_label_format`];
18359
+ fn = config[`${v}_label_${name}`];
18033
18360
  });
18034
- return isFunction(format) ? format.bind($$.api) : format;
18361
+ if (name === "format") {
18362
+ return isFunction(fn) ? fn.bind($$.api) : fn;
18363
+ } else {
18364
+ return fn;
18365
+ }
18035
18366
  },
18036
18367
  updateTargetsForArc(targets) {
18037
18368
  const $$ = this;
@@ -18369,7 +18700,11 @@ function getAttrTweenFn(fn) {
18369
18700
  const hasMultiArcGauge = $$.hasMultiArcGauge();
18370
18701
  let text;
18371
18702
  if (!(hasGauge && $$.data.targets.length === 1 && config.gauge_title)) {
18372
- text = main.selectAll(`.${$ARC.chartArc}`).select("text").style("opacity", "0").attr("class", (d) => $$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null).call($$.textForArcLabel.bind($$)).attr("transform", (d) => $$.transformForArcLabel.bind($$)(d)).style("font-size", (d) => $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? `${Math.round(state.radius / 5)}px` : null).transition().duration(duration).style(
18703
+ text = main.selectAll(`.${$ARC.chartArc}`).select("text").style("opacity", "0").attr("class", (d) => $$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null).call($$.textForArcLabel.bind($$)).style("font-size", (d) => $$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ? `${Math.round(state.radius / 5)}px` : null);
18704
+ updateTextImage.call($$);
18705
+ text.attr("transform", function(d) {
18706
+ return $$.transformForArcLabel.bind($$)(this, d);
18707
+ }).transition().duration(duration).style(
18373
18708
  "opacity",
18374
18709
  (d) => $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0"
18375
18710
  );
@@ -20578,6 +20913,7 @@ var external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_
20578
20913
 
20579
20914
 
20580
20915
 
20916
+
20581
20917
  function position(group, root) {
20582
20918
  const $$ = this;
20583
20919
  const { scale: { x, y }, state: { width } } = $$;
@@ -20771,10 +21107,7 @@ function getHierachyData(data) {
20771
21107
  const format = config.treemap_label_format;
20772
21108
  const ratio = $$.getRatio("treemap", d);
20773
21109
  const percentValue = (ratio * 100).toFixed(2);
20774
- const meetLabelThreshold = config.treemap_label_show && $$.meetsLabelThreshold(
20775
- ratio,
20776
- "treemap"
20777
- ) ? null : "0";
21110
+ const meetLabelThreshold = config.treemap_label_show && meetsLabelThreshold.call($$, ratio, "treemap") ? null : "0";
20778
21111
  return function(node) {
20779
21112
  node.style("opacity", meetLabelThreshold);
20780
21113
  return isFunction(format) ? format.bind($$.api)(value, ratio, id) : `${id}
@@ -21511,6 +21844,18 @@ ${percentValue}%`;
21511
21844
  * @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
21512
21845
  * @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
21513
21846
  * @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
21847
+ * @property {object|Function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
21848
+ * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
21849
+ * The arguments are:<br>
21850
+ * - `v` is the value of the data point where the label is shown.
21851
+ * - `id` is the id of the data where the label is shown.
21852
+ * - `i` is the index of the data series point where the label is shown.
21853
+ * @property {string} donut.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
21854
+ * @property {number} donut.label.image.width Image width in pixels.
21855
+ * @property {number} donut.label.image.height Image height in pixels.
21856
+ * @property {object} [donut.label.image.pos] Image position relative to the label text.
21857
+ * @property {number} [donut.label.image.pos.x=0] x coordinate position, relative the original.
21858
+ * @property {number} [donut.label.image.pos.y=0] y coordinate position, relative the original.
21514
21859
  * @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
21515
21860
  * @property {number} [donut.expand.rate=0.98] Set expand rate.
21516
21861
  * @property {number} [donut.expand.duration=50] Set expand transition time in ms.
@@ -21520,6 +21865,16 @@ ${percentValue}%`;
21520
21865
  * - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
21521
21866
  * @property {number} [donut.padAngle=0] Set padding between data.
21522
21867
  * @property {number} [donut.startingAngle=0] Set starting angle where data draws.
21868
+ * @see [Demo: Corner Radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
21869
+ * @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
21870
+ * @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
21871
+ * @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
21872
+ * @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
21873
+ * @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
21874
+ * @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
21875
+ * @see [Demo: Pad Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.padAngle)
21876
+ * @see [Demo: Starting Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.StartingAngle)
21877
+ *
21523
21878
  * @example
21524
21879
  * donut: {
21525
21880
  * label: {
@@ -21541,7 +21896,51 @@ ${percentValue}%`;
21541
21896
  * return ratio;
21542
21897
  * },
21543
21898
  * // or set ratio number
21544
- * ratio: 0.5
21899
+ * ratio: 0.5,
21900
+ *
21901
+ * // set image to be displayed next to the label text
21902
+ * image: {
21903
+ * url: "./sample.svg",
21904
+ *
21905
+ * // use placeholder to dynamically set image URL based on data ID
21906
+ * url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
21907
+ * width: 35,
21908
+ * height: 35,
21909
+ * pos: {
21910
+ * x: 0,
21911
+ * y: 0
21912
+ * }
21913
+ * },
21914
+ *
21915
+ * // or use function to return image configuration dynamically
21916
+ * image: function(v, id, i) {
21917
+ * // Return different images based on value
21918
+ * if (v > 500) {
21919
+ * return {
21920
+ * url: "./high-value.svg",
21921
+ * width: 40,
21922
+ * height: 40,
21923
+ * pos: { x: 0, y: 0 }
21924
+ * };
21925
+ * } else if (v > 100) {
21926
+ * return {
21927
+ * url: "./medium-value.svg",
21928
+ * width: 30,
21929
+ * height: 30,
21930
+ * pos: { x: 0, y: 0 }
21931
+ * };
21932
+ * } else if(v < 5) {
21933
+ * // Return falsy value in case of don't want to show image
21934
+ * return null;
21935
+ * } else {
21936
+ * return {
21937
+ * url: "./low-value.svg",
21938
+ * width: 20,
21939
+ * height: 20,
21940
+ * pos: { x: 0, y: 0 }
21941
+ * };
21942
+ * }
21943
+ * }
21545
21944
  * },
21546
21945
  *
21547
21946
  * // disable expand transition for interaction
@@ -21570,6 +21969,7 @@ ${percentValue}%`;
21570
21969
  donut_label_show: true,
21571
21970
  donut_label_format: void 0,
21572
21971
  donut_label_threshold: 0.05,
21972
+ donut_label_image: void 0,
21573
21973
  donut_label_ratio: void 0,
21574
21974
  donut_width: void 0,
21575
21975
  donut_title: "",
@@ -21632,6 +22032,18 @@ ${percentValue}%`;
21632
22032
  * - id {string}: data's id value
21633
22033
  * @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
21634
22034
  * @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
22035
+ * @property {object|Function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
22036
+ * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
22037
+ * The arguments are:<br>
22038
+ * - `v` is the value of the data point where the label is shown.
22039
+ * - `id` is the id of the data where the label is shown.
22040
+ * - `i` is the index of the data series point where the label is shown.
22041
+ * @property {string} gauge.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
22042
+ * @property {number} gauge.label.image.width Image width in pixels.
22043
+ * @property {number} gauge.label.image.height Image height in pixels.
22044
+ * @property {object} [gauge.label.image.pos] Image position relative to the label text.
22045
+ * @property {number} [gauge.label.image.pos.x=0] x coordinate position, relative the original.
22046
+ * @property {number} [gauge.label.image.pos.y=0] y coordinate position, relative the original.
21635
22047
  * @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
21636
22048
  * @property {number} [gauge.expand.rate=0.98] Set expand rate.
21637
22049
  * @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
@@ -21672,7 +22084,8 @@ ${percentValue}%`;
21672
22084
  * @see [Demo: enforceMinMax, min/max](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeMinMax)
21673
22085
  * @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
21674
22086
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
21675
- * @see [Demo: labelRatio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
22087
+ * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
22088
+ * @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
21676
22089
  * @example
21677
22090
  * gauge: {
21678
22091
  * background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
@@ -21700,7 +22113,51 @@ ${percentValue}%`;
21700
22113
  * return ratio;
21701
22114
  * },
21702
22115
  * // or set ratio number
21703
- * ratio: 0.5
22116
+ * ratio: 0.5,
22117
+ *
22118
+ * // set image to be displayed next to the label text
22119
+ * image: {
22120
+ * url: "./sample.svg",
22121
+ *
22122
+ * // use placeholder to dynamically set image URL based on data ID
22123
+ * url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
22124
+ * width: 35,
22125
+ * height: 35,
22126
+ * pos: {
22127
+ * x: 0,
22128
+ * y: 0
22129
+ * }
22130
+ * },
22131
+ *
22132
+ * // or use function to return image configuration dynamically
22133
+ * image: function(v, id, i) {
22134
+ * // Return different images based on value
22135
+ * if (v > 500) {
22136
+ * return {
22137
+ * url: "./high-value.svg",
22138
+ * width: 40,
22139
+ * height: 40,
22140
+ * pos: { x: 0, y: 0 }
22141
+ * };
22142
+ * } else if (v > 100) {
22143
+ * return {
22144
+ * url: "./medium-value.svg",
22145
+ * width: 30,
22146
+ * height: 30,
22147
+ * pos: { x: 0, y: 0 }
22148
+ * };
22149
+ * } else if(v < 5) {
22150
+ * // Return falsy value in case of don't want to show image
22151
+ * return null;
22152
+ * } else {
22153
+ * return {
22154
+ * url: "./low-value.svg",
22155
+ * width: 20,
22156
+ * height: 20,
22157
+ * pos: { x: 0, y: 0 }
22158
+ * };
22159
+ * }
22160
+ * }
21704
22161
  * },
21705
22162
  *
21706
22163
  * // disable expand transition for interaction
@@ -21743,6 +22200,7 @@ ${percentValue}%`;
21743
22200
  gauge_label_format: void 0,
21744
22201
  gauge_label_ratio: void 0,
21745
22202
  gauge_label_threshold: 0,
22203
+ gauge_label_image: void 0,
21746
22204
  gauge_enforceMinMax: false,
21747
22205
  gauge_min: 0,
21748
22206
  gauge_max: 100,
@@ -21770,6 +22228,18 @@ ${percentValue}%`;
21770
22228
  * @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
21771
22229
  * @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
21772
22230
  * @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
22231
+ * @property {object|Function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
22232
+ * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
22233
+ * The arguments are:<br>
22234
+ * - `v` is the value of the data point where the label is shown.
22235
+ * - `id` is the id of the data where the label is shown.
22236
+ * - `i` is the index of the data series point where the label is shown.
22237
+ * @property {string} pie.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
22238
+ * @property {number} pie.label.image.width Image width in pixels.
22239
+ * @property {number} pie.label.image.height Image height in pixels.
22240
+ * @property {object} [pie.label.image.pos] Image position relative to the label text.
22241
+ * @property {number} [pie.label.image.pos.x=0] x coordinate position, relative the original.
22242
+ * @property {number} [pie.label.image.pos.y=0] y coordinate position, relative the original.
21773
22243
  * @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
21774
22244
  * @property {number} [pie.expand.rate=0.98] Set expand rate.
21775
22245
  * @property {number} [pie.expand.duration=50] Set expand transition time in ms.
@@ -21782,6 +22252,7 @@ ${percentValue}%`;
21782
22252
  * @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
21783
22253
  * @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
21784
22254
  * @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
22255
+ * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
21785
22256
  * @example
21786
22257
  * pie: {
21787
22258
  * label: {
@@ -21803,7 +22274,51 @@ ${percentValue}%`;
21803
22274
  * return ratio;
21804
22275
  * },
21805
22276
  * // or set ratio number
21806
- * ratio: 0.5
22277
+ * ratio: 0.5,
22278
+ *
22279
+ * // set image to be displayed next to the label text
22280
+ * image: {
22281
+ * url: "./sample.svg",
22282
+ *
22283
+ * // use placeholder to dynamically set image URL based on data ID
22284
+ * url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
22285
+ * width: 35,
22286
+ * height: 35,
22287
+ * pos: {
22288
+ * x: 0,
22289
+ * y: 0
22290
+ * }
22291
+ * },
22292
+ *
22293
+ * // or use function to return image configuration dynamically
22294
+ * image: function(v, id, i) {
22295
+ * // Return different images based on value
22296
+ * if (v > 500) {
22297
+ * return {
22298
+ * url: "./high-value.svg",
22299
+ * width: 40,
22300
+ * height: 40,
22301
+ * pos: { x: 0, y: 0 }
22302
+ * };
22303
+ * } else if (v > 100) {
22304
+ * return {
22305
+ * url: "./medium-value.svg",
22306
+ * width: 30,
22307
+ * height: 30,
22308
+ * pos: { x: 0, y: 0 }
22309
+ * };
22310
+ * } else if(v < 5) {
22311
+ * // Return falsy value in case of don't want to show image
22312
+ * return null;
22313
+ * } else {
22314
+ * return {
22315
+ * url: "./low-value.svg",
22316
+ * width: 20,
22317
+ * height: 20,
22318
+ * pos: { x: 0, y: 0 }
22319
+ * };
22320
+ * }
22321
+ * }
21807
22322
  * },
21808
22323
  *
21809
22324
  * // disable expand transition for interaction
@@ -21842,6 +22357,7 @@ ${percentValue}%`;
21842
22357
  pie_label_format: void 0,
21843
22358
  pie_label_ratio: void 0,
21844
22359
  pie_label_threshold: 0.05,
22360
+ pie_label_image: void 0,
21845
22361
  pie_expand: {},
21846
22362
  pie_expand_rate: 0.98,
21847
22363
  pie_expand_duration: 50,
@@ -21864,6 +22380,18 @@ ${percentValue}%`;
21864
22380
  * @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
21865
22381
  * @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
21866
22382
  * @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
22383
+ * @property {object|Function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
22384
+ * When function is specified, will receives 3 arguments such as `v, id, i` and it must return an image object with `url`, `width`, `height`, and optional `pos` properties.<br><br>
22385
+ * The arguments are:<br>
22386
+ * - `v` is the value of the data point where the label is shown.
22387
+ * - `id` is the id of the data where the label is shown.
22388
+ * - `i` is the index of the data series point where the label is shown.
22389
+ * @property {string} polar.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
22390
+ * @property {number} polar.label.image.width Image width in pixels.
22391
+ * @property {number} polar.label.image.height Image height in pixels.
22392
+ * @property {object} [polar.label.image.pos] Image position relative to the label text.
22393
+ * @property {number} [polar.label.image.pos.x=0] x coordinate position, relative the original.
22394
+ * @property {number} [polar.label.image.pos.y=0] y coordinate position, relative the original.
21867
22395
  * @property {number} [polar.level.depth=3] Set the level depth.
21868
22396
  * @property {boolean} [polar.level.show=true] Show or hide level.
21869
22397
  * @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
@@ -21873,6 +22401,7 @@ ${percentValue}%`;
21873
22401
  * @property {number} [polar.padding=0] Sets the gap between pie arcs.
21874
22402
  * @property {number} [polar.startingAngle=0] Set starting angle where data draws.
21875
22403
  * @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
22404
+ * @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
21876
22405
  * @example
21877
22406
  * polar: {
21878
22407
  * label: {
@@ -21894,7 +22423,51 @@ ${percentValue}%`;
21894
22423
  * return ratio;
21895
22424
  * },
21896
22425
  * // or set ratio number
21897
- * ratio: 0.5
22426
+ * ratio: 0.5,
22427
+ *
22428
+ * // set image to be displayed next to the label text
22429
+ * image: {
22430
+ * url: "./sample.svg",
22431
+ *
22432
+ * // use placeholder to dynamically set image URL based on data ID
22433
+ * url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
22434
+ * width: 35,
22435
+ * height: 35,
22436
+ * pos: {
22437
+ * x: 0,
22438
+ * y: 0
22439
+ * }
22440
+ * },
22441
+ *
22442
+ * // or use function to return image configuration dynamically
22443
+ * image: function(v, id, i) {
22444
+ * // Return different images based on value
22445
+ * if (v > 500) {
22446
+ * return {
22447
+ * url: "./high-value.svg",
22448
+ * width: 40,
22449
+ * height: 40,
22450
+ * pos: { x: 0, y: 0 }
22451
+ * };
22452
+ * } else if (v > 100) {
22453
+ * return {
22454
+ * url: "./medium-value.svg",
22455
+ * width: 30,
22456
+ * height: 30,
22457
+ * pos: { x: 0, y: 0 }
22458
+ * };
22459
+ * } else if(v < 5) {
22460
+ * // Return falsy value in case of don't want to show image
22461
+ * return null;
22462
+ * } else {
22463
+ * return {
22464
+ * url: "./low-value.svg",
22465
+ * width: 20,
22466
+ * height: 20,
22467
+ * pos: { x: 0, y: 0 }
22468
+ * };
22469
+ * }
22470
+ * }
21898
22471
  * },
21899
22472
  * level: {
21900
22473
  * depth: 3,
@@ -21916,6 +22489,7 @@ ${percentValue}%`;
21916
22489
  polar_label_show: true,
21917
22490
  polar_label_format: void 0,
21918
22491
  polar_label_threshold: 0.05,
22492
+ polar_label_image: void 0,
21919
22493
  polar_label_ratio: void 0,
21920
22494
  polar_level_depth: 3,
21921
22495
  polar_level_max: void 0,
@@ -22141,7 +22715,7 @@ const bb = {
22141
22715
  * bb.version; // "1.0.0"
22142
22716
  * @memberof bb
22143
22717
  */
22144
- version: "3.16.0",
22718
+ version: "3.17.0-next.1",
22145
22719
  /**
22146
22720
  * Generate chart
22147
22721
  * - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when: