billboard.js 3.16.0 → 3.17.0
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.
- package/dist/billboard.css +4 -4
- package/dist/billboard.js +645 -82
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +12 -12
- package/dist/billboard.pkgd.js +1987 -786
- package/dist/billboard.pkgd.min.js +18 -17
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +18 -2
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-stanford.js +18 -2
- package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.js +16 -2
- package/dist/plugin/billboardjs-plugin-tableview.min.js +5 -5
- package/dist/plugin/billboardjs-plugin-textoverlap.js +16 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1344 -706
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +6 -5
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +1454 -800
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +8 -7
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +1455 -801
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +13 -12
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1454 -802
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -9
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1455 -803
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +7 -6
- package/dist/theme/dark.css +4 -4
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +4 -4
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +4 -4
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +4 -4
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +4 -4
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/billboard.js +697 -79
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +21 -21
- package/src/ChartInternal/Axis/AxisRenderer.ts +20 -13
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +9 -4
- package/src/ChartInternal/data/convert.ts +3 -3
- package/src/ChartInternal/data/data.ts +2 -2
- package/src/ChartInternal/internals/color.ts +20 -14
- package/src/ChartInternal/internals/text.ts +40 -125
- package/src/ChartInternal/internals/text.util.ts +320 -0
- package/src/ChartInternal/shape/arc.ts +41 -19
- package/src/ChartInternal/shape/treemap.ts +5 -6
- package/src/config/Options/axis/x.ts +18 -0
- package/src/config/Options/axis/y.ts +17 -0
- package/src/config/Options/axis/y2.ts +18 -0
- package/src/config/Options/common/boost.ts +1 -0
- package/src/config/Options/data/data.ts +125 -4
- package/src/config/Options/shape/donut.ts +77 -1
- package/src/config/Options/shape/gauge.ts +69 -2
- package/src/config/Options/shape/pie.ts +68 -1
- package/src/config/Options/shape/polar.ts +68 -1
- package/src/config/classes.ts +2 -0
- package/src/module/util.ts +26 -0
- package/types/axis.d.ts +10 -0
- package/types/options.d.ts +138 -1
- 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.
|
|
8
|
+
* @version 3.17.0
|
|
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 = {
|
|
@@ -413,6 +415,7 @@ const $ZOOM = {
|
|
|
413
415
|
* - **NOTE:**
|
|
414
416
|
* - For now, only applies for data conversion at the initial time.
|
|
415
417
|
* - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
|
|
418
|
+
* - When given data is empty, useWorker will be ignored.
|
|
416
419
|
* @example
|
|
417
420
|
* boost: {
|
|
418
421
|
* useCssRule: true,
|
|
@@ -1709,7 +1712,10 @@ const $ZOOM = {
|
|
|
1709
1712
|
* - `i` is the index of the data series point where the label is shown.
|
|
1710
1713
|
* - `texts` is the array of whole corresponding data series' text labels.<br><br>
|
|
1711
1714
|
* 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
|
|
1715
|
+
* @property {string|object|Function} [data.labels.backgroundColors] Set label text background colors.<br><br>
|
|
1716
|
+
* - **NOTE**: When function is set, background colors can be specified one color per dataset.
|
|
1717
|
+
* - Within the function, the last returned color for dataset will be used.
|
|
1718
|
+
* - Only can control set or unset background color for each values.
|
|
1713
1719
|
* @property {string|object|Function} [data.labels.colors] Set label text colors.
|
|
1714
1720
|
* @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
|
|
1715
1721
|
* 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 +1729,32 @@ const $ZOOM = {
|
|
|
1723
1729
|
* @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
|
|
1724
1730
|
* @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
|
|
1725
1731
|
* - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
|
|
1732
|
+
* @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.
|
|
1733
|
+
* @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.
|
|
1734
|
+
* @property {number} [data.labels.border.radius=10] Border radius value.
|
|
1735
|
+
* @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
|
|
1736
|
+
* @property {string} [data.labels.border.stroke="#000"] Border stroke color.
|
|
1737
|
+
* @property {string} [data.labels.border.fill="none"] Border fill color.
|
|
1738
|
+
* @property {object|Function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
|
|
1739
|
+
* 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>
|
|
1740
|
+
* The arguments are:<br>
|
|
1741
|
+
* - `v` is the value of the data point where the label is shown.
|
|
1742
|
+
* - `id` is the id of the data where the label is shown.
|
|
1743
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
1744
|
+
* @property {string} data.labels.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
1745
|
+
* @property {number} data.labels.image.width Image width in pixels.
|
|
1746
|
+
* @property {number} data.labels.image.height Image height in pixels.
|
|
1747
|
+
* @property {object} [data.labels.image.pos] Image position relative to the label text.
|
|
1748
|
+
* @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
|
|
1749
|
+
* @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
|
|
1726
1750
|
* @memberof Options
|
|
1727
1751
|
* @type {object}
|
|
1728
1752
|
* @default {}
|
|
1729
1753
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
|
|
1754
|
+
* @see [Demo: label border](https://naver.github.io/billboard.js/demo/#Data.DataLabelBorder)
|
|
1730
1755
|
* @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
|
|
1731
1756
|
* @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
|
|
1757
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#Data.DataLabelImage)
|
|
1732
1758
|
* @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
|
|
1733
1759
|
* @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
|
|
1734
1760
|
* @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
|
|
@@ -1761,7 +1787,15 @@ const $ZOOM = {
|
|
|
1761
1787
|
* backgroundColors: {
|
|
1762
1788
|
* data1: "green",
|
|
1763
1789
|
* data2: "yellow"
|
|
1764
|
-
* }
|
|
1790
|
+
* },
|
|
1791
|
+
*
|
|
1792
|
+
* // call back for label text background color
|
|
1793
|
+
* backgroundColors: function(color, d) {
|
|
1794
|
+
* // color: the default data label color string
|
|
1795
|
+
* // data: ex) {x: 0, value: 200, id: "data3", index: 0}
|
|
1796
|
+
* ....
|
|
1797
|
+
* return d.value > 200 ? "cyan" : "red";
|
|
1798
|
+
* },
|
|
1765
1799
|
*
|
|
1766
1800
|
* // apply for all label texts
|
|
1767
1801
|
* colors: "red",
|
|
@@ -1801,7 +1835,76 @@ const $ZOOM = {
|
|
|
1801
1835
|
* },
|
|
1802
1836
|
*
|
|
1803
1837
|
* // rotate degree for label text
|
|
1804
|
-
* rotate: 90
|
|
1838
|
+
* rotate: 90,
|
|
1839
|
+
*
|
|
1840
|
+
* // add border to data label text
|
|
1841
|
+
* // NOTE: When set as `true`, styling aren't applied. Hence, need to set using '.bb-text-border' class.
|
|
1842
|
+
* // ex. ".bb-text-border { fill: red; stroke: #000; stroke-width: 2px; rx: 10px; ry: 10px; }"
|
|
1843
|
+
* border: true,
|
|
1844
|
+
*
|
|
1845
|
+
* // or set detailed border options
|
|
1846
|
+
* border: {
|
|
1847
|
+
* padding: 10, // set all padding to 10
|
|
1848
|
+
* padding: "5 10", // set top and bottom padding to 5, left and right padding to 10
|
|
1849
|
+
* padding: { // specify each padding
|
|
1850
|
+
* top: 3,
|
|
1851
|
+
* bottom: 5,
|
|
1852
|
+
* left: 10,
|
|
1853
|
+
* right: 13
|
|
1854
|
+
* },
|
|
1855
|
+
* radius: 10,
|
|
1856
|
+
* strokeWidth: 2,
|
|
1857
|
+
* stroke: "#000",
|
|
1858
|
+
* fill: "red"
|
|
1859
|
+
* },
|
|
1860
|
+
*
|
|
1861
|
+
* // set image to be displayed next to the label text
|
|
1862
|
+
* image: {
|
|
1863
|
+
* url: "./sample.svg",
|
|
1864
|
+
*
|
|
1865
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
1866
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
1867
|
+
* width: 35,
|
|
1868
|
+
* height: 35,
|
|
1869
|
+
* pos: {
|
|
1870
|
+
* x: 0,
|
|
1871
|
+
* y: 0
|
|
1872
|
+
* }
|
|
1873
|
+
* },
|
|
1874
|
+
*
|
|
1875
|
+
* // or use function to return image configuration dynamically
|
|
1876
|
+
* image: function(v, id, i) {
|
|
1877
|
+
* // v is the value of the data point where the label is shown.
|
|
1878
|
+
* // id is the id of the data where the label is shown.
|
|
1879
|
+
* // i is the index of the data series point where the label is shown.
|
|
1880
|
+
*
|
|
1881
|
+
* // Return different images based on value
|
|
1882
|
+
* if (v > 500) {
|
|
1883
|
+
* return {
|
|
1884
|
+
* url: "./high-value.svg",
|
|
1885
|
+
* width: 40,
|
|
1886
|
+
* height: 40,
|
|
1887
|
+
* pos: { x: 0, y: 0 }
|
|
1888
|
+
* };
|
|
1889
|
+
* } else if (v > 100) {
|
|
1890
|
+
* return {
|
|
1891
|
+
* url: "./medium-value.svg",
|
|
1892
|
+
* width: 30,
|
|
1893
|
+
* height: 30,
|
|
1894
|
+
* pos: { x: 0, y: 0 }
|
|
1895
|
+
* };
|
|
1896
|
+
* } else if(v < 5) {
|
|
1897
|
+
* // Return falsy value in case of don't want to show image
|
|
1898
|
+
* return null;
|
|
1899
|
+
* } else {
|
|
1900
|
+
* return {
|
|
1901
|
+
* url: "./low-value.svg",
|
|
1902
|
+
* width: 20,
|
|
1903
|
+
* height: 20,
|
|
1904
|
+
* pos: { x: 0, y: 0 }
|
|
1905
|
+
* };
|
|
1906
|
+
* }
|
|
1907
|
+
* }
|
|
1805
1908
|
* }
|
|
1806
1909
|
* }
|
|
1807
1910
|
*/
|
|
@@ -1809,6 +1912,7 @@ const $ZOOM = {
|
|
|
1809
1912
|
data_labels_backgroundColors: void 0,
|
|
1810
1913
|
data_labels_colors: void 0,
|
|
1811
1914
|
data_labels_position: {},
|
|
1915
|
+
data_labels_imgUrl: void 0,
|
|
1812
1916
|
/**
|
|
1813
1917
|
* Hide each data when the chart appears.<br><br>
|
|
1814
1918
|
* If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
|
|
@@ -2762,6 +2866,20 @@ function runUntil(fn, conditionFn) {
|
|
|
2762
2866
|
fn();
|
|
2763
2867
|
}
|
|
2764
2868
|
}
|
|
2869
|
+
function parseShorthand(value) {
|
|
2870
|
+
if (isObject(value) && !isString(value)) {
|
|
2871
|
+
const obj = value;
|
|
2872
|
+
return {
|
|
2873
|
+
top: obj.top || 0,
|
|
2874
|
+
right: obj.right || 0,
|
|
2875
|
+
bottom: obj.bottom || 0,
|
|
2876
|
+
left: obj.left || 0
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2879
|
+
const values = (isString(value) ? value.trim().split(/\s+/) : [value]).map((v) => +v || 0);
|
|
2880
|
+
const [a, b = a, c = a, d = b] = values;
|
|
2881
|
+
return { top: a, right: b, bottom: c, left: d };
|
|
2882
|
+
}
|
|
2765
2883
|
|
|
2766
2884
|
;// ./src/config/Options/Options.ts
|
|
2767
2885
|
var Options_defProp = Object.defineProperty;
|
|
@@ -3595,14 +3713,14 @@ function setXS(ids, data, params) {
|
|
|
3595
3713
|
callback
|
|
3596
3714
|
);
|
|
3597
3715
|
} else if (data.json) {
|
|
3598
|
-
runWorker(useWorker, json, callback, [columns, rows])(
|
|
3716
|
+
runWorker(data.json.length ? useWorker : false, json, callback, [columns, rows])(
|
|
3599
3717
|
data.json,
|
|
3600
3718
|
getDataKeyForJson(data.keys, config)
|
|
3601
3719
|
);
|
|
3602
3720
|
} else if (data.rows) {
|
|
3603
|
-
runWorker(useWorker, rows, callback)(data.rows);
|
|
3721
|
+
runWorker(data.rows.length ? useWorker : false, rows, callback)(data.rows);
|
|
3604
3722
|
} else if (data.columns) {
|
|
3605
|
-
runWorker(useWorker, columns, callback)(data.columns);
|
|
3723
|
+
runWorker(data.columns.length ? useWorker : false, columns, callback)(data.columns);
|
|
3606
3724
|
} else if (args.bindto) {
|
|
3607
3725
|
throw Error("url or json or rows or columns is required.");
|
|
3608
3726
|
}
|
|
@@ -5070,7 +5188,7 @@ const schemeCategory10 = [
|
|
|
5070
5188
|
},
|
|
5071
5189
|
/**
|
|
5072
5190
|
* Append data backgound color filter definition
|
|
5073
|
-
* @param {string|object} color Color string
|
|
5191
|
+
* @param {string|object|Function} color Color string, object, or function
|
|
5074
5192
|
* @param {object} attr filter attribute
|
|
5075
5193
|
* @private
|
|
5076
5194
|
*/
|
|
@@ -5081,20 +5199,25 @@ const schemeCategory10 = [
|
|
|
5081
5199
|
height: 1
|
|
5082
5200
|
}) {
|
|
5083
5201
|
const $$ = this;
|
|
5084
|
-
const { $el, state } = $$;
|
|
5202
|
+
const { $el: { defs }, state } = $$;
|
|
5085
5203
|
if (color) {
|
|
5086
5204
|
let ids = [];
|
|
5087
5205
|
if (isString(color)) {
|
|
5088
5206
|
ids.push("");
|
|
5089
5207
|
} else if (isObject(color)) {
|
|
5090
5208
|
ids = Object.keys(color);
|
|
5209
|
+
} else if (isFunction(color)) {
|
|
5210
|
+
ids = $$.mapToTargetIds();
|
|
5091
5211
|
}
|
|
5092
5212
|
ids.forEach((v) => {
|
|
5093
5213
|
const id = `${state.datetimeId}-labels-bg${$$.getTargetSelectorSuffix(v)}${isString(color) ? $$.getTargetSelectorSuffix(color) : ""}`;
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5214
|
+
const colorValue = v === "" ? color : (color == null ? void 0 : color[v]) || "";
|
|
5215
|
+
if (defs.select(`#${id}`).empty()) {
|
|
5216
|
+
defs.append("filter").attr("x", attr.x).attr("y", attr.y).attr("width", attr.width).attr("height", attr.height).attr("id", id).html(
|
|
5217
|
+
`<feFlood flood-color="${colorValue}" />
|
|
5218
|
+
<feComposite in="SourceGraphic" />`
|
|
5219
|
+
);
|
|
5220
|
+
}
|
|
5098
5221
|
});
|
|
5099
5222
|
}
|
|
5100
5223
|
},
|
|
@@ -6972,8 +7095,7 @@ function getScale(type = "linear", min, max) {
|
|
|
6972
7095
|
}
|
|
6973
7096
|
});
|
|
6974
7097
|
|
|
6975
|
-
;// ./src/ChartInternal/internals/text.ts
|
|
6976
|
-
|
|
7098
|
+
;// ./src/ChartInternal/internals/text.util.ts
|
|
6977
7099
|
|
|
6978
7100
|
|
|
6979
7101
|
|
|
@@ -7028,13 +7150,139 @@ function getTextPos(d, type) {
|
|
|
7028
7150
|
const { id, index, value } = d;
|
|
7029
7151
|
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
7152
|
}
|
|
7153
|
+
function updateTextBorder(text, pos, rectClass) {
|
|
7154
|
+
var _a, _b;
|
|
7155
|
+
const $$ = this;
|
|
7156
|
+
const { config, $T } = $$;
|
|
7157
|
+
const isRotated = config.axis_rotated;
|
|
7158
|
+
const {
|
|
7159
|
+
border: {
|
|
7160
|
+
padding = "3 5",
|
|
7161
|
+
radius = 10,
|
|
7162
|
+
stroke = "#000",
|
|
7163
|
+
strokeWidth = 1,
|
|
7164
|
+
fill = "none"
|
|
7165
|
+
}
|
|
7166
|
+
} = config.data_labels;
|
|
7167
|
+
const borderPadding = parseShorthand(padding);
|
|
7168
|
+
const applyStyle = config.data_labels.border !== true;
|
|
7169
|
+
const textRect = getBBox(text);
|
|
7170
|
+
let borderRect = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(text.previousElementSibling);
|
|
7171
|
+
if (borderRect.empty() || ((_a = borderRect.node()) == null ? void 0 : _a.tagName) !== "rect" || !((_b = borderRect.attr("class")) == null ? void 0 : _b.includes(rectClass))) {
|
|
7172
|
+
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(
|
|
7173
|
+
"width",
|
|
7174
|
+
textRect.width + (applyStyle ? borderPadding.left + borderPadding.right : 0)
|
|
7175
|
+
).attr(
|
|
7176
|
+
"height",
|
|
7177
|
+
textRect.height + (applyStyle ? borderPadding.top + borderPadding.bottom : 0)
|
|
7178
|
+
);
|
|
7179
|
+
if (applyStyle) {
|
|
7180
|
+
borderRect.style("fill", fill).style("stroke", stroke).style("stroke-width", `${strokeWidth}px`).attr("rx", radius).attr("ry", radius);
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
$T(borderRect).attr(
|
|
7184
|
+
"x",
|
|
7185
|
+
pos.x - (applyStyle ? borderPadding.left : 0) - (isRotated ? 0 : textRect.width / 2)
|
|
7186
|
+
).attr("y", pos.y - (applyStyle ? borderPadding.top : 0) - textRect.height / 4 * 3.2);
|
|
7187
|
+
}
|
|
7188
|
+
function meetsLabelThreshold(ratio = 0, type) {
|
|
7189
|
+
const $$ = this;
|
|
7190
|
+
const { config } = $$;
|
|
7191
|
+
const threshold = config[`${type}_label_threshold`] || 0;
|
|
7192
|
+
return ratio >= threshold;
|
|
7193
|
+
}
|
|
7194
|
+
function updateTextImage() {
|
|
7195
|
+
const $$ = this;
|
|
7196
|
+
const { $el: { text }, config } = $$;
|
|
7197
|
+
const isArc = $$.state.arcWidth;
|
|
7198
|
+
if (isArc ? $$.getArcLabelConfig("image") : config.data_labels.image) {
|
|
7199
|
+
text.filter(function() {
|
|
7200
|
+
const prev = this.previousElementSibling;
|
|
7201
|
+
if (prev) {
|
|
7202
|
+
return prev.tagName !== "image" || !prev.classList.contains($TEXT.textLabelImage);
|
|
7203
|
+
}
|
|
7204
|
+
return true;
|
|
7205
|
+
}).each(function(d) {
|
|
7206
|
+
var _a, _b, _c, _d;
|
|
7207
|
+
const { url, width, height, pos } = getDataLabelImgUrl.call($$, d);
|
|
7208
|
+
if (url) {
|
|
7209
|
+
const parentNode = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this.parentNode);
|
|
7210
|
+
parentNode == null ? void 0 : parentNode.insert(
|
|
7211
|
+
"image",
|
|
7212
|
+
`${(_b = (_a = this.getAttribute("class")) == null ? void 0 : _a.replace(/(?:^(.)|\s)/g, ".$1")) != null ? _b : "text"}`
|
|
7213
|
+
).style("opacity", "0").attr("href", (d2) => tplProcess(url, {
|
|
7214
|
+
ID: "id" in d2 ? d2.id : d2.data.id
|
|
7215
|
+
})).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);
|
|
7216
|
+
}
|
|
7217
|
+
});
|
|
7218
|
+
}
|
|
7219
|
+
}
|
|
7220
|
+
function getDataLabelImgUrl(d) {
|
|
7221
|
+
var _a;
|
|
7222
|
+
const $$ = this;
|
|
7223
|
+
const { config, state } = $$;
|
|
7224
|
+
const image = state.arcWidth ? $$.getArcLabelConfig("image") : config.data_labels.image;
|
|
7225
|
+
if (isFunction(image)) {
|
|
7226
|
+
return (_a = image.call($$.api, d.value, d.id, d.index)) != null ? _a : {
|
|
7227
|
+
url: "",
|
|
7228
|
+
width: 0,
|
|
7229
|
+
height: 0,
|
|
7230
|
+
pos: { x: 0, y: 0 }
|
|
7231
|
+
};
|
|
7232
|
+
} else if (image) {
|
|
7233
|
+
const { url = "", width = 0, height = 0, pos } = image;
|
|
7234
|
+
return {
|
|
7235
|
+
url,
|
|
7236
|
+
width,
|
|
7237
|
+
height,
|
|
7238
|
+
pos
|
|
7239
|
+
};
|
|
7240
|
+
}
|
|
7241
|
+
return null;
|
|
7242
|
+
}
|
|
7243
|
+
function updateTextImagePos(textNode, pos) {
|
|
7244
|
+
var _a;
|
|
7245
|
+
const $$ = this;
|
|
7246
|
+
const { config, state: { arcWidth, hasTreemap } } = $$;
|
|
7247
|
+
const isRotated = config.axis_rotated;
|
|
7248
|
+
const image = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(textNode.previousElementSibling);
|
|
7249
|
+
const isShown = (textNode2) => {
|
|
7250
|
+
var _a2;
|
|
7251
|
+
const isShown2 = textNode2.style.opacity !== "0" && textNode2.style.fillOpacity !== "0";
|
|
7252
|
+
return (arcWidth ? textNode2.textContent : isShown2) && ((_a2 = this.previousElementSibling) == null ? void 0 : _a2.tagName) !== "image";
|
|
7253
|
+
};
|
|
7254
|
+
if (!image.empty() && ((_a = image.node()) == null ? void 0 : _a.tagName) === "image") {
|
|
7255
|
+
const textRect = getBoundingRect(textNode);
|
|
7256
|
+
const w = +image.attr("width") / 2;
|
|
7257
|
+
const h = +image.attr("height") / 2;
|
|
7258
|
+
let x = pos.x - w;
|
|
7259
|
+
let y = pos.y - h - textRect.height / 2;
|
|
7260
|
+
if (isRotated) {
|
|
7261
|
+
pos.x += w;
|
|
7262
|
+
} else {
|
|
7263
|
+
if (hasTreemap) {
|
|
7264
|
+
x = -w;
|
|
7265
|
+
y = -(h * 2 + textRect.height);
|
|
7266
|
+
}
|
|
7267
|
+
if (!($$.hasType("pie") || $$.hasType("polar"))) {
|
|
7268
|
+
pos.y += h;
|
|
7269
|
+
}
|
|
7270
|
+
}
|
|
7271
|
+
$$.$T(image).style("opacity", isShown(textNode) ? null : "0").attr("x", x).attr("y", y);
|
|
7272
|
+
}
|
|
7273
|
+
}
|
|
7274
|
+
|
|
7275
|
+
|
|
7276
|
+
;// ./src/ChartInternal/internals/text.ts
|
|
7277
|
+
|
|
7278
|
+
|
|
7279
|
+
|
|
7280
|
+
|
|
7281
|
+
|
|
7031
7282
|
/* harmony default export */ var internals_text = ({
|
|
7032
7283
|
opacityForText(d) {
|
|
7033
7284
|
const $$ = this;
|
|
7034
|
-
return $$.isBarType(d) &&
|
|
7035
|
-
Math.abs($$.getRatio("bar", d)),
|
|
7036
|
-
"bar"
|
|
7037
|
-
) ? "0" : $$.hasDataLabel ? null : "0";
|
|
7285
|
+
return $$.isBarType(d) && !meetsLabelThreshold.call($$, Math.abs($$.getRatio("bar", d)), "bar") ? "0" : $$.hasDataLabel ? null : "0";
|
|
7038
7286
|
},
|
|
7039
7287
|
/**
|
|
7040
7288
|
* Initializes the text
|
|
@@ -7104,6 +7352,7 @@ function getTextPos(d, type) {
|
|
|
7104
7352
|
setTextValue(node, value);
|
|
7105
7353
|
}
|
|
7106
7354
|
});
|
|
7355
|
+
updateTextImage.call($$);
|
|
7107
7356
|
},
|
|
7108
7357
|
updateTextColor(d) {
|
|
7109
7358
|
const $$ = this;
|
|
@@ -7131,20 +7380,30 @@ function getTextPos(d, type) {
|
|
|
7131
7380
|
/**
|
|
7132
7381
|
* Update data label text background color
|
|
7133
7382
|
* @param {object} d Data object
|
|
7134
|
-
* @param {object|string} option option object
|
|
7383
|
+
* @param {object|string|Function} option option object
|
|
7135
7384
|
* @returns {string|null}
|
|
7136
7385
|
* @private
|
|
7137
7386
|
*/
|
|
7138
7387
|
updateTextBGColor(d, option) {
|
|
7139
7388
|
const $$ = this;
|
|
7140
|
-
const { $el } = $$;
|
|
7389
|
+
const { $el: { defs } } = $$;
|
|
7141
7390
|
let color = "";
|
|
7142
|
-
if (
|
|
7391
|
+
if (option) {
|
|
7143
7392
|
const id = isString(option) ? "" : $$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id);
|
|
7144
|
-
const filter =
|
|
7393
|
+
const filter = defs.select(["filter[id*='labels-bg", "']"].join(id));
|
|
7145
7394
|
if (filter.size()) {
|
|
7146
7395
|
color = `url(#${filter.attr("id")})`;
|
|
7147
7396
|
}
|
|
7397
|
+
if (isFunction(option)) {
|
|
7398
|
+
$$.generateTextBGColorFilter(option);
|
|
7399
|
+
const defaultColor = $$.color(d);
|
|
7400
|
+
const bgColor = option.bind($$.api)(defaultColor, d);
|
|
7401
|
+
if (bgColor) {
|
|
7402
|
+
filter.select("feFlood").attr("flood-color", bgColor);
|
|
7403
|
+
} else {
|
|
7404
|
+
color = "";
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7148
7407
|
}
|
|
7149
7408
|
return color || null;
|
|
7150
7409
|
},
|
|
@@ -7171,7 +7430,7 @@ function getTextPos(d, type) {
|
|
|
7171
7430
|
).style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$)).each(function(d, i) {
|
|
7172
7431
|
const node = $T(
|
|
7173
7432
|
hasTreemap && this.childElementCount ? this.parentNode : this,
|
|
7174
|
-
!!(withTransition && this.getAttribute("x")),
|
|
7433
|
+
!!(withTransition && (this.getAttribute("x") || this.getAttribute("transform"))),
|
|
7175
7434
|
t
|
|
7176
7435
|
);
|
|
7177
7436
|
const isInverted = config[`axis_${axis == null ? void 0 : axis.getId(d.id)}_inverted`];
|
|
@@ -7183,11 +7442,13 @@ function getTextPos(d, type) {
|
|
|
7183
7442
|
pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
|
|
7184
7443
|
node.attr("text-anchor", anchorString);
|
|
7185
7444
|
}
|
|
7445
|
+
updateTextImagePos.call($$, this, pos);
|
|
7186
7446
|
if (this.childElementCount || angle) {
|
|
7187
7447
|
node.attr("transform", `translate(${pos.x} ${pos.y}) ${rotateString}`);
|
|
7188
7448
|
} else {
|
|
7189
7449
|
node.attr("x", pos.x).attr("y", pos.y);
|
|
7190
7450
|
}
|
|
7451
|
+
config.data_labels.border && updateTextBorder.call($$, node.node(), pos, `${$TEXT.textBorderRect}-${i}`);
|
|
7191
7452
|
});
|
|
7192
7453
|
return true;
|
|
7193
7454
|
},
|
|
@@ -7424,19 +7685,6 @@ function getTextPos(d, type) {
|
|
|
7424
7685
|
$$.$el.arcs.selectAll(selector).each(function() {
|
|
7425
7686
|
(0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.selectAll)([this, this.previousSibling]).classed($TEXT.TextOverlapping, false);
|
|
7426
7687
|
});
|
|
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
7688
|
}
|
|
7441
7689
|
});
|
|
7442
7690
|
|
|
@@ -12834,6 +13082,7 @@ class AxisRendererHelper {
|
|
|
12834
13082
|
AxisRendererHelper_publicField(this, "owner");
|
|
12835
13083
|
AxisRendererHelper_publicField(this, "config");
|
|
12836
13084
|
AxisRendererHelper_publicField(this, "scale");
|
|
13085
|
+
AxisRendererHelper_publicField(this, "charSize", {});
|
|
12837
13086
|
const scale = getScale();
|
|
12838
13087
|
const { config, params } = owner;
|
|
12839
13088
|
this.owner = owner;
|
|
@@ -12846,16 +13095,20 @@ class AxisRendererHelper {
|
|
|
12846
13095
|
}
|
|
12847
13096
|
/**
|
|
12848
13097
|
* Compute a character dimension
|
|
13098
|
+
* @param {string} orient Axis orientation
|
|
12849
13099
|
* @param {d3.selection} text SVG text selection
|
|
12850
13100
|
* @param {boolean} memoize memoize the calculated size
|
|
12851
13101
|
* @returns {{w: number, h: number}}
|
|
12852
13102
|
* @private
|
|
12853
13103
|
*/
|
|
12854
|
-
|
|
13104
|
+
getSizeFor1Char(orient, text, memoize = true) {
|
|
12855
13105
|
const size = {
|
|
12856
13106
|
w: 5.5,
|
|
12857
13107
|
h: 11.5
|
|
12858
13108
|
};
|
|
13109
|
+
if (this.charSize[orient] && memoize) {
|
|
13110
|
+
return this.charSize[orient];
|
|
13111
|
+
}
|
|
12859
13112
|
!text.empty() && text.text("0").call((el) => {
|
|
12860
13113
|
try {
|
|
12861
13114
|
const { width, height } = getBBox(el.node(), true);
|
|
@@ -12867,9 +13120,7 @@ class AxisRendererHelper {
|
|
|
12867
13120
|
el.text("");
|
|
12868
13121
|
}
|
|
12869
13122
|
});
|
|
12870
|
-
|
|
12871
|
-
this.getSizeFor1Char = () => size;
|
|
12872
|
-
}
|
|
13123
|
+
this.charSize[orient] = size;
|
|
12873
13124
|
return size;
|
|
12874
13125
|
}
|
|
12875
13126
|
/**
|
|
@@ -13040,15 +13291,15 @@ class AxisRenderer {
|
|
|
13040
13291
|
tickShow.text && tickEnter.append("text");
|
|
13041
13292
|
const tickText = tick.select("text");
|
|
13042
13293
|
const counts = [];
|
|
13043
|
-
let sizeFor1Char;
|
|
13294
|
+
let sizeFor1Char = { w: 0, h: 0 };
|
|
13044
13295
|
if (isFunction(evalTextSize)) {
|
|
13045
13296
|
sizeFor1Char = evalTextSize.bind(ctx.params.owner.api)(tickText.node(), id);
|
|
13046
13297
|
if (this.classList.contains($COMMON.dummy)) {
|
|
13047
13298
|
this.sizeFor1Char = sizeFor1Char;
|
|
13048
13299
|
}
|
|
13049
13300
|
}
|
|
13050
|
-
if (!sizeFor1Char) {
|
|
13051
|
-
sizeFor1Char =
|
|
13301
|
+
if (!sizeFor1Char || sizeFor1Char.w === 0 || sizeFor1Char.h === 0) {
|
|
13302
|
+
sizeFor1Char = ctx.helper.getSizeFor1Char(orient, tickText, !!evalTextSize);
|
|
13052
13303
|
}
|
|
13053
13304
|
let tspan = tickText.selectAll("tspan").data((d, index) => {
|
|
13054
13305
|
const split = params.tickMultiline ? splitTickText(d, scale1, ticks, isLeftRight, sizeFor1Char.w) : isArray(helper.textFormatted(d)) ? helper.textFormatted(d).concat() : [helper.textFormatted(d)];
|
|
@@ -13078,7 +13329,7 @@ class AxisRenderer {
|
|
|
13078
13329
|
const textUpdate = tick.select("text");
|
|
13079
13330
|
tickEnter.select("line").attr(`${axisPx}2`, innerTickSize * sign);
|
|
13080
13331
|
tickEnter.select("text").attr(axisPx, tickLength * sign);
|
|
13081
|
-
ctx.setTickLineTextPosition(lineUpdate, textUpdate);
|
|
13332
|
+
ctx.setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char);
|
|
13082
13333
|
if (params.tickTitle) {
|
|
13083
13334
|
const title = textUpdate.select("title");
|
|
13084
13335
|
(title.empty() ? textUpdate.append("title") : title).text((index) => params.tickTitle[index]);
|
|
@@ -13147,12 +13398,16 @@ class AxisRenderer {
|
|
|
13147
13398
|
* Set tick's line & text position
|
|
13148
13399
|
* @param {d3.selection} lineUpdate Line selection
|
|
13149
13400
|
* @param {d3.selection} textUpdate Text selection
|
|
13401
|
+
* @param {object} sizeFor1Char Size for 1 char
|
|
13150
13402
|
* @private
|
|
13151
13403
|
*/
|
|
13152
|
-
setTickLineTextPosition(lineUpdate, textUpdate) {
|
|
13404
|
+
setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char) {
|
|
13153
13405
|
const tickPos = this.getTickXY();
|
|
13154
13406
|
const { innerTickSize, orient, tickLength, tickOffset } = this.config;
|
|
13407
|
+
const axisId = this.params.id;
|
|
13155
13408
|
const rotate = this.params.tickTextRotate;
|
|
13409
|
+
const baseHeight = 6;
|
|
13410
|
+
const charHeight = sizeFor1Char.h / 2 - baseHeight;
|
|
13156
13411
|
const textAnchorForText = (r) => {
|
|
13157
13412
|
const value = ["start", "end"];
|
|
13158
13413
|
orient === "top" && value.reverse();
|
|
@@ -13161,7 +13416,8 @@ class AxisRenderer {
|
|
|
13161
13416
|
const textTransform = (r) => r ? `rotate(${r})` : null;
|
|
13162
13417
|
const yForText = (r) => {
|
|
13163
13418
|
const r2 = r / (orient === "bottom" ? 15 : 23);
|
|
13164
|
-
|
|
13419
|
+
const y = r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
|
|
13420
|
+
return y;
|
|
13165
13421
|
};
|
|
13166
13422
|
const {
|
|
13167
13423
|
config: {
|
|
@@ -13169,9 +13425,10 @@ class AxisRenderer {
|
|
|
13169
13425
|
axis_x_tick_text_inner: inner
|
|
13170
13426
|
}
|
|
13171
13427
|
} = this.params.owner;
|
|
13428
|
+
const tickLineInner = this.params.config[`axis_${axisId}_tick_inner`];
|
|
13172
13429
|
switch (orient) {
|
|
13173
13430
|
case "bottom":
|
|
13174
|
-
lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", this.getTickSize.bind(this));
|
|
13431
|
+
lineUpdate.attr("x1", tickPos.x).attr("x2", tickPos.x).attr("y2", (d) => this.getTickSize.bind(this)(d) * (tickLineInner ? -1 : 1));
|
|
13175
13432
|
textUpdate.attr("x", 0).attr("y", yForText(rotate)).style("text-anchor", textAnchorForText(rotate)).style("text-anchor", (d, i, { length }) => {
|
|
13176
13433
|
if (!isRotated && i === 0 && (inner === true || inner.first)) {
|
|
13177
13434
|
return "start";
|
|
@@ -13182,16 +13439,16 @@ class AxisRenderer {
|
|
|
13182
13439
|
}).attr("transform", textTransform(rotate));
|
|
13183
13440
|
break;
|
|
13184
13441
|
case "top":
|
|
13185
|
-
lineUpdate.attr("x2", 0).attr("y2", -innerTickSize);
|
|
13186
|
-
textUpdate.attr("x", 0).attr("y", -yForText(rotate)
|
|
13442
|
+
lineUpdate.attr("x2", 0).attr("y2", tickLineInner ? innerTickSize : -innerTickSize);
|
|
13443
|
+
textUpdate.attr("x", 0).attr("y", -(yForText(rotate) + charHeight + baseHeight)).style("text-anchor", textAnchorForText(rotate)).attr("transform", textTransform(rotate));
|
|
13187
13444
|
break;
|
|
13188
13445
|
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");
|
|
13446
|
+
lineUpdate.attr("x2", tickLineInner ? innerTickSize : -innerTickSize).attr("y1", tickPos.y).attr("y2", tickPos.y);
|
|
13447
|
+
textUpdate.attr("x", -tickLength).attr("y", tickOffset + (isRotated ? charHeight / 4 : charHeight)).style("text-anchor", "end");
|
|
13191
13448
|
break;
|
|
13192
13449
|
case "right":
|
|
13193
|
-
lineUpdate.attr("x2", innerTickSize).attr("y2", 0);
|
|
13194
|
-
textUpdate.attr("x", tickLength).attr("y",
|
|
13450
|
+
lineUpdate.attr("x2", tickLineInner ? -innerTickSize : innerTickSize).attr("y2", 0);
|
|
13451
|
+
textUpdate.attr("x", tickLength).attr("y", charHeight).style("text-anchor", "start");
|
|
13195
13452
|
}
|
|
13196
13453
|
}
|
|
13197
13454
|
// this should be called only when category axis
|
|
@@ -13485,7 +13742,7 @@ class Axis_Axis {
|
|
|
13485
13742
|
v.domain && scale.domain(v.domain);
|
|
13486
13743
|
axes.push(
|
|
13487
13744
|
d3Axis(scale).ticks(tick.count).tickFormat(
|
|
13488
|
-
isFunction(tick.format) ? tick.format.bind($$.api) : (x) => x
|
|
13745
|
+
isFunction(tick.format) ? tick.format.bind($$.api) : ((x) => x)
|
|
13489
13746
|
).tickValues(tick.values).tickSizeOuter(tick.outer === false ? 0 : 6)
|
|
13490
13747
|
);
|
|
13491
13748
|
});
|
|
@@ -15735,6 +15992,23 @@ function smoothLines(el, type) {
|
|
|
15735
15992
|
* }
|
|
15736
15993
|
*/
|
|
15737
15994
|
axis_x_tick_count: void 0,
|
|
15995
|
+
/**
|
|
15996
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
15997
|
+
* @name axis․x․tick․inner
|
|
15998
|
+
* @memberof Options
|
|
15999
|
+
* @type {boolean}
|
|
16000
|
+
* @default false
|
|
16001
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
16002
|
+
* @example
|
|
16003
|
+
* axis: {
|
|
16004
|
+
* x: {
|
|
16005
|
+
* tick: {
|
|
16006
|
+
* inner: true
|
|
16007
|
+
* }
|
|
16008
|
+
* }
|
|
16009
|
+
* }
|
|
16010
|
+
*/
|
|
16011
|
+
axis_x_tick_inner: false,
|
|
15738
16012
|
/**
|
|
15739
16013
|
* Show or hide x axis tick line.
|
|
15740
16014
|
* @name axis․x․tick․show
|
|
@@ -16470,6 +16744,22 @@ function smoothLines(el, type) {
|
|
|
16470
16744
|
* }
|
|
16471
16745
|
*/
|
|
16472
16746
|
axis_y_tick_culling_reverse: false,
|
|
16747
|
+
/**
|
|
16748
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
16749
|
+
* @name axis․y․tick․inner
|
|
16750
|
+
* @memberof Options
|
|
16751
|
+
* @type {boolean}
|
|
16752
|
+
* @default false
|
|
16753
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
16754
|
+
* axis: {
|
|
16755
|
+
* y: {
|
|
16756
|
+
* tick: {
|
|
16757
|
+
* inner: true
|
|
16758
|
+
* }
|
|
16759
|
+
* }
|
|
16760
|
+
* }
|
|
16761
|
+
*/
|
|
16762
|
+
axis_y_tick_inner: false,
|
|
16473
16763
|
/**
|
|
16474
16764
|
* Show y axis outer tick.
|
|
16475
16765
|
* @name axis․y․tick․outer
|
|
@@ -16958,6 +17248,23 @@ function smoothLines(el, type) {
|
|
|
16958
17248
|
* }
|
|
16959
17249
|
*/
|
|
16960
17250
|
axis_y2_tick_culling_reverse: false,
|
|
17251
|
+
/**
|
|
17252
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
17253
|
+
* @name axis․y2․tick․inner
|
|
17254
|
+
* @memberof Options
|
|
17255
|
+
* @type {boolean}
|
|
17256
|
+
* @default false
|
|
17257
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
17258
|
+
* @example
|
|
17259
|
+
* axis: {
|
|
17260
|
+
* y2: {
|
|
17261
|
+
* tick: {
|
|
17262
|
+
* inner: true
|
|
17263
|
+
* }
|
|
17264
|
+
* }
|
|
17265
|
+
* }
|
|
17266
|
+
*/
|
|
17267
|
+
axis_y2_tick_inner: false,
|
|
16961
17268
|
/**
|
|
16962
17269
|
* Show or hide y2 axis outer tick.
|
|
16963
17270
|
* @name axis․y2․tick․outer
|
|
@@ -17582,6 +17889,7 @@ var arc_spreadProps = (a, b) => arc_defProps(a, arc_getOwnPropDescs(b));
|
|
|
17582
17889
|
|
|
17583
17890
|
|
|
17584
17891
|
|
|
17892
|
+
|
|
17585
17893
|
function getRadiusFn(expandRate = 0) {
|
|
17586
17894
|
const $$ = this;
|
|
17587
17895
|
const { config, state } = $$;
|
|
@@ -17872,7 +18180,9 @@ function getAttrTweenFn(fn) {
|
|
|
17872
18180
|
return isFunction(format) ? format(range) : `${range}${isPercent ? "%" : ""}`;
|
|
17873
18181
|
}).merge(rangeText));
|
|
17874
18182
|
if ((!state.rendered || state.rendered && !fixed) && totalSum > 0) {
|
|
17875
|
-
rangeText.attr("transform", (d, i)
|
|
18183
|
+
rangeText.attr("transform", function(d, i) {
|
|
18184
|
+
return $$.transformForArcLabel(this, pieData[i], true);
|
|
18185
|
+
});
|
|
17876
18186
|
}
|
|
17877
18187
|
rangeText.style(
|
|
17878
18188
|
"opacity",
|
|
@@ -17882,30 +18192,32 @@ function getAttrTweenFn(fn) {
|
|
|
17882
18192
|
},
|
|
17883
18193
|
/**
|
|
17884
18194
|
* Set transform attributes to arc label text
|
|
18195
|
+
* @param {SVGTextElement} textNode Text node element
|
|
17885
18196
|
* @param {object} d Data object
|
|
17886
18197
|
* @param {boolean} forRange Weather is for ranged text option(arc.rangeText.values)
|
|
17887
18198
|
* @returns {string} Translate attribute string
|
|
17888
18199
|
* @private
|
|
17889
18200
|
*/
|
|
17890
|
-
transformForArcLabel(d, forRange = false) {
|
|
18201
|
+
transformForArcLabel(textNode, d, forRange = false) {
|
|
17891
18202
|
var _a, _b, _c;
|
|
17892
18203
|
const $$ = this;
|
|
17893
18204
|
const { config, state: { radiusExpanded } } = $$;
|
|
17894
18205
|
const updated = $$.updateAngle(d, forRange);
|
|
18206
|
+
const pos = { x: 0, y: 0 };
|
|
17895
18207
|
let translate = "";
|
|
18208
|
+
let ratio = 1;
|
|
17896
18209
|
if (updated) {
|
|
17897
18210
|
if (forRange || $$.hasMultiArcGauge()) {
|
|
17898
18211
|
const y1 = Math.sin(updated.endAngle - Math.PI / 2);
|
|
17899
18212
|
const rangeTextPosition = config.arc_rangeText_position;
|
|
17900
|
-
|
|
17901
|
-
|
|
18213
|
+
pos.x = Math.cos(updated.endAngle - Math.PI / 2) * (radiusExpanded + (forRange ? 5 : 25));
|
|
18214
|
+
pos.y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
|
|
17902
18215
|
if (forRange && rangeTextPosition) {
|
|
17903
18216
|
const rangeValues = config.arc_rangeText_values;
|
|
17904
|
-
const
|
|
17905
|
-
x += (_a =
|
|
17906
|
-
y += (_b =
|
|
18217
|
+
const position = isFunction(rangeTextPosition) ? rangeTextPosition(rangeValues[d.index]) : rangeTextPosition;
|
|
18218
|
+
pos.x += (_a = position == null ? void 0 : position.x) != null ? _a : 0;
|
|
18219
|
+
pos.y += (_b = position == null ? void 0 : position.y) != null ? _b : 0;
|
|
17907
18220
|
}
|
|
17908
|
-
translate = `translate(${x},${y})`;
|
|
17909
18221
|
} else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
|
|
17910
18222
|
let { outerRadius } = $$.getRadius(d);
|
|
17911
18223
|
if ($$.hasType("polar")) {
|
|
@@ -17914,14 +18226,17 @@ function getAttrTweenFn(fn) {
|
|
|
17914
18226
|
const c = this.svgArc.centroid(updated);
|
|
17915
18227
|
const [x, y] = c.map((v) => isNaN(v) ? 0 : v);
|
|
17916
18228
|
const h = Math.sqrt(x * x + y * y);
|
|
17917
|
-
|
|
18229
|
+
pos.x = x;
|
|
18230
|
+
pos.y = y;
|
|
18231
|
+
ratio = (_c = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).map((v) => config[`${v}_label_ratio`])) == null ? void 0 : _c[0];
|
|
17918
18232
|
if (ratio) {
|
|
17919
18233
|
ratio = isFunction(ratio) ? ratio.bind($$.api)(d, outerRadius, h) : ratio;
|
|
17920
18234
|
} else {
|
|
17921
18235
|
ratio = outerRadius && (h ? (36 / outerRadius > 0.375 ? 1.175 - 36 / outerRadius : 0.8) * outerRadius / h : 0);
|
|
17922
18236
|
}
|
|
17923
|
-
translate = `translate(${x * ratio},${y * ratio})`;
|
|
17924
18237
|
}
|
|
18238
|
+
updateTextImagePos.call($$, textNode, pos);
|
|
18239
|
+
translate = `translate(${pos.x * ratio},${pos.y * ratio})`;
|
|
17925
18240
|
}
|
|
17926
18241
|
return translate;
|
|
17927
18242
|
},
|
|
@@ -17942,13 +18257,14 @@ function getAttrTweenFn(fn) {
|
|
|
17942
18257
|
const node = (0,external_commonjs_d3_selection_commonjs2_d3_selection_amd_d3_selection_root_d3_.select)(this);
|
|
17943
18258
|
const updated = $$.updateAngle(d);
|
|
17944
18259
|
const ratio = $$.getRatio("arc", updated);
|
|
17945
|
-
const isUnderThreshold =
|
|
18260
|
+
const isUnderThreshold = meetsLabelThreshold.call(
|
|
18261
|
+
$$,
|
|
17946
18262
|
ratio,
|
|
17947
18263
|
(_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) == null ? void 0 : _a[0]
|
|
17948
18264
|
);
|
|
17949
18265
|
if (isUnderThreshold) {
|
|
17950
18266
|
const { value } = updated || d;
|
|
17951
|
-
const text = ($$.
|
|
18267
|
+
const text = ($$.getArcLabelConfig("format") || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
|
|
17952
18268
|
setTextValue(node, text, [-1, 1], hasGauge);
|
|
17953
18269
|
} else {
|
|
17954
18270
|
node.text("");
|
|
@@ -18024,14 +18340,18 @@ function getAttrTweenFn(fn) {
|
|
|
18024
18340
|
const { config } = $$;
|
|
18025
18341
|
return ["donut", "gauge", "pie", "polar"].some((v) => $$.hasType(v) && config[`${v}_label_show`]);
|
|
18026
18342
|
},
|
|
18027
|
-
|
|
18343
|
+
getArcLabelConfig(name = "format") {
|
|
18028
18344
|
const $$ = this;
|
|
18029
18345
|
const { config } = $$;
|
|
18030
|
-
let
|
|
18346
|
+
let fn = (v) => v;
|
|
18031
18347
|
["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$)).forEach((v) => {
|
|
18032
|
-
|
|
18348
|
+
fn = config[`${v}_label_${name}`];
|
|
18033
18349
|
});
|
|
18034
|
-
|
|
18350
|
+
if (name === "format") {
|
|
18351
|
+
return isFunction(fn) ? fn.bind($$.api) : fn;
|
|
18352
|
+
} else {
|
|
18353
|
+
return fn;
|
|
18354
|
+
}
|
|
18035
18355
|
},
|
|
18036
18356
|
updateTargetsForArc(targets) {
|
|
18037
18357
|
const $$ = this;
|
|
@@ -18369,7 +18689,11 @@ function getAttrTweenFn(fn) {
|
|
|
18369
18689
|
const hasMultiArcGauge = $$.hasMultiArcGauge();
|
|
18370
18690
|
let text;
|
|
18371
18691
|
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($$)).
|
|
18692
|
+
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);
|
|
18693
|
+
updateTextImage.call($$);
|
|
18694
|
+
text.attr("transform", function(d) {
|
|
18695
|
+
return $$.transformForArcLabel.bind($$)(this, d);
|
|
18696
|
+
}).transition().duration(duration).style(
|
|
18373
18697
|
"opacity",
|
|
18374
18698
|
(d) => $$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0"
|
|
18375
18699
|
);
|
|
@@ -20578,6 +20902,7 @@ var external_commonjs_d3_hierarchy_commonjs2_d3_hierarchy_amd_d3_hierarchy_root_
|
|
|
20578
20902
|
|
|
20579
20903
|
|
|
20580
20904
|
|
|
20905
|
+
|
|
20581
20906
|
function position(group, root) {
|
|
20582
20907
|
const $$ = this;
|
|
20583
20908
|
const { scale: { x, y }, state: { width } } = $$;
|
|
@@ -20771,10 +21096,7 @@ function getHierachyData(data) {
|
|
|
20771
21096
|
const format = config.treemap_label_format;
|
|
20772
21097
|
const ratio = $$.getRatio("treemap", d);
|
|
20773
21098
|
const percentValue = (ratio * 100).toFixed(2);
|
|
20774
|
-
const meetLabelThreshold = config.treemap_label_show &&
|
|
20775
|
-
ratio,
|
|
20776
|
-
"treemap"
|
|
20777
|
-
) ? null : "0";
|
|
21099
|
+
const meetLabelThreshold = config.treemap_label_show && meetsLabelThreshold.call($$, ratio, "treemap") ? null : "0";
|
|
20778
21100
|
return function(node) {
|
|
20779
21101
|
node.style("opacity", meetLabelThreshold);
|
|
20780
21102
|
return isFunction(format) ? format.bind($$.api)(value, ratio, id) : `${id}
|
|
@@ -21511,6 +21833,18 @@ ${percentValue}%`;
|
|
|
21511
21833
|
* @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
|
|
21512
21834
|
* @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
21513
21835
|
* @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
|
|
21836
|
+
* @property {object|Function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
|
|
21837
|
+
* 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>
|
|
21838
|
+
* The arguments are:<br>
|
|
21839
|
+
* - `v` is the value of the data point where the label is shown.
|
|
21840
|
+
* - `id` is the id of the data where the label is shown.
|
|
21841
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
21842
|
+
* @property {string} donut.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
21843
|
+
* @property {number} donut.label.image.width Image width in pixels.
|
|
21844
|
+
* @property {number} donut.label.image.height Image height in pixels.
|
|
21845
|
+
* @property {object} [donut.label.image.pos] Image position relative to the label text.
|
|
21846
|
+
* @property {number} [donut.label.image.pos.x=0] x coordinate position, relative the original.
|
|
21847
|
+
* @property {number} [donut.label.image.pos.y=0] y coordinate position, relative the original.
|
|
21514
21848
|
* @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
|
|
21515
21849
|
* @property {number} [donut.expand.rate=0.98] Set expand rate.
|
|
21516
21850
|
* @property {number} [donut.expand.duration=50] Set expand transition time in ms.
|
|
@@ -21520,6 +21854,16 @@ ${percentValue}%`;
|
|
|
21520
21854
|
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
21521
21855
|
* @property {number} [donut.padAngle=0] Set padding between data.
|
|
21522
21856
|
* @property {number} [donut.startingAngle=0] Set starting angle where data draws.
|
|
21857
|
+
* @see [Demo: Corner Radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
21858
|
+
* @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
|
|
21859
|
+
* @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
|
|
21860
|
+
* @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
|
|
21861
|
+
* @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
|
|
21862
|
+
* @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
|
|
21863
|
+
* @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
|
|
21864
|
+
* @see [Demo: Pad Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.padAngle)
|
|
21865
|
+
* @see [Demo: Starting Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.StartingAngle)
|
|
21866
|
+
*
|
|
21523
21867
|
* @example
|
|
21524
21868
|
* donut: {
|
|
21525
21869
|
* label: {
|
|
@@ -21541,7 +21885,51 @@ ${percentValue}%`;
|
|
|
21541
21885
|
* return ratio;
|
|
21542
21886
|
* },
|
|
21543
21887
|
* // or set ratio number
|
|
21544
|
-
* ratio: 0.5
|
|
21888
|
+
* ratio: 0.5,
|
|
21889
|
+
*
|
|
21890
|
+
* // set image to be displayed next to the label text
|
|
21891
|
+
* image: {
|
|
21892
|
+
* url: "./sample.svg",
|
|
21893
|
+
*
|
|
21894
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
21895
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
21896
|
+
* width: 35,
|
|
21897
|
+
* height: 35,
|
|
21898
|
+
* pos: {
|
|
21899
|
+
* x: 0,
|
|
21900
|
+
* y: 0
|
|
21901
|
+
* }
|
|
21902
|
+
* },
|
|
21903
|
+
*
|
|
21904
|
+
* // or use function to return image configuration dynamically
|
|
21905
|
+
* image: function(v, id, i) {
|
|
21906
|
+
* // Return different images based on value
|
|
21907
|
+
* if (v > 500) {
|
|
21908
|
+
* return {
|
|
21909
|
+
* url: "./high-value.svg",
|
|
21910
|
+
* width: 40,
|
|
21911
|
+
* height: 40,
|
|
21912
|
+
* pos: { x: 0, y: 0 }
|
|
21913
|
+
* };
|
|
21914
|
+
* } else if (v > 100) {
|
|
21915
|
+
* return {
|
|
21916
|
+
* url: "./medium-value.svg",
|
|
21917
|
+
* width: 30,
|
|
21918
|
+
* height: 30,
|
|
21919
|
+
* pos: { x: 0, y: 0 }
|
|
21920
|
+
* };
|
|
21921
|
+
* } else if(v < 5) {
|
|
21922
|
+
* // Return falsy value in case of don't want to show image
|
|
21923
|
+
* return null;
|
|
21924
|
+
* } else {
|
|
21925
|
+
* return {
|
|
21926
|
+
* url: "./low-value.svg",
|
|
21927
|
+
* width: 20,
|
|
21928
|
+
* height: 20,
|
|
21929
|
+
* pos: { x: 0, y: 0 }
|
|
21930
|
+
* };
|
|
21931
|
+
* }
|
|
21932
|
+
* }
|
|
21545
21933
|
* },
|
|
21546
21934
|
*
|
|
21547
21935
|
* // disable expand transition for interaction
|
|
@@ -21570,6 +21958,7 @@ ${percentValue}%`;
|
|
|
21570
21958
|
donut_label_show: true,
|
|
21571
21959
|
donut_label_format: void 0,
|
|
21572
21960
|
donut_label_threshold: 0.05,
|
|
21961
|
+
donut_label_image: void 0,
|
|
21573
21962
|
donut_label_ratio: void 0,
|
|
21574
21963
|
donut_width: void 0,
|
|
21575
21964
|
donut_title: "",
|
|
@@ -21632,6 +22021,18 @@ ${percentValue}%`;
|
|
|
21632
22021
|
* - id {string}: data's id value
|
|
21633
22022
|
* @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
|
|
21634
22023
|
* @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
22024
|
+
* @property {object|Function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22025
|
+
* 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>
|
|
22026
|
+
* The arguments are:<br>
|
|
22027
|
+
* - `v` is the value of the data point where the label is shown.
|
|
22028
|
+
* - `id` is the id of the data where the label is shown.
|
|
22029
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
22030
|
+
* @property {string} gauge.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
22031
|
+
* @property {number} gauge.label.image.width Image width in pixels.
|
|
22032
|
+
* @property {number} gauge.label.image.height Image height in pixels.
|
|
22033
|
+
* @property {object} [gauge.label.image.pos] Image position relative to the label text.
|
|
22034
|
+
* @property {number} [gauge.label.image.pos.x=0] x coordinate position, relative the original.
|
|
22035
|
+
* @property {number} [gauge.label.image.pos.y=0] y coordinate position, relative the original.
|
|
21635
22036
|
* @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
|
|
21636
22037
|
* @property {number} [gauge.expand.rate=0.98] Set expand rate.
|
|
21637
22038
|
* @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
|
|
@@ -21672,7 +22073,8 @@ ${percentValue}%`;
|
|
|
21672
22073
|
* @see [Demo: enforceMinMax, min/max](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeMinMax)
|
|
21673
22074
|
* @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
|
|
21674
22075
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
|
|
21675
|
-
* @see [Demo:
|
|
22076
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
|
|
22077
|
+
* @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
|
|
21676
22078
|
* @example
|
|
21677
22079
|
* gauge: {
|
|
21678
22080
|
* background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
|
|
@@ -21700,7 +22102,51 @@ ${percentValue}%`;
|
|
|
21700
22102
|
* return ratio;
|
|
21701
22103
|
* },
|
|
21702
22104
|
* // or set ratio number
|
|
21703
|
-
* ratio: 0.5
|
|
22105
|
+
* ratio: 0.5,
|
|
22106
|
+
*
|
|
22107
|
+
* // set image to be displayed next to the label text
|
|
22108
|
+
* image: {
|
|
22109
|
+
* url: "./sample.svg",
|
|
22110
|
+
*
|
|
22111
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
22112
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
22113
|
+
* width: 35,
|
|
22114
|
+
* height: 35,
|
|
22115
|
+
* pos: {
|
|
22116
|
+
* x: 0,
|
|
22117
|
+
* y: 0
|
|
22118
|
+
* }
|
|
22119
|
+
* },
|
|
22120
|
+
*
|
|
22121
|
+
* // or use function to return image configuration dynamically
|
|
22122
|
+
* image: function(v, id, i) {
|
|
22123
|
+
* // Return different images based on value
|
|
22124
|
+
* if (v > 500) {
|
|
22125
|
+
* return {
|
|
22126
|
+
* url: "./high-value.svg",
|
|
22127
|
+
* width: 40,
|
|
22128
|
+
* height: 40,
|
|
22129
|
+
* pos: { x: 0, y: 0 }
|
|
22130
|
+
* };
|
|
22131
|
+
* } else if (v > 100) {
|
|
22132
|
+
* return {
|
|
22133
|
+
* url: "./medium-value.svg",
|
|
22134
|
+
* width: 30,
|
|
22135
|
+
* height: 30,
|
|
22136
|
+
* pos: { x: 0, y: 0 }
|
|
22137
|
+
* };
|
|
22138
|
+
* } else if(v < 5) {
|
|
22139
|
+
* // Return falsy value in case of don't want to show image
|
|
22140
|
+
* return null;
|
|
22141
|
+
* } else {
|
|
22142
|
+
* return {
|
|
22143
|
+
* url: "./low-value.svg",
|
|
22144
|
+
* width: 20,
|
|
22145
|
+
* height: 20,
|
|
22146
|
+
* pos: { x: 0, y: 0 }
|
|
22147
|
+
* };
|
|
22148
|
+
* }
|
|
22149
|
+
* }
|
|
21704
22150
|
* },
|
|
21705
22151
|
*
|
|
21706
22152
|
* // disable expand transition for interaction
|
|
@@ -21743,6 +22189,7 @@ ${percentValue}%`;
|
|
|
21743
22189
|
gauge_label_format: void 0,
|
|
21744
22190
|
gauge_label_ratio: void 0,
|
|
21745
22191
|
gauge_label_threshold: 0,
|
|
22192
|
+
gauge_label_image: void 0,
|
|
21746
22193
|
gauge_enforceMinMax: false,
|
|
21747
22194
|
gauge_min: 0,
|
|
21748
22195
|
gauge_max: 100,
|
|
@@ -21770,6 +22217,18 @@ ${percentValue}%`;
|
|
|
21770
22217
|
* @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
|
|
21771
22218
|
* @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
|
|
21772
22219
|
* @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
22220
|
+
* @property {object|Function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22221
|
+
* 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>
|
|
22222
|
+
* The arguments are:<br>
|
|
22223
|
+
* - `v` is the value of the data point where the label is shown.
|
|
22224
|
+
* - `id` is the id of the data where the label is shown.
|
|
22225
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
22226
|
+
* @property {string} pie.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
22227
|
+
* @property {number} pie.label.image.width Image width in pixels.
|
|
22228
|
+
* @property {number} pie.label.image.height Image height in pixels.
|
|
22229
|
+
* @property {object} [pie.label.image.pos] Image position relative to the label text.
|
|
22230
|
+
* @property {number} [pie.label.image.pos.x=0] x coordinate position, relative the original.
|
|
22231
|
+
* @property {number} [pie.label.image.pos.y=0] y coordinate position, relative the original.
|
|
21773
22232
|
* @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
|
|
21774
22233
|
* @property {number} [pie.expand.rate=0.98] Set expand rate.
|
|
21775
22234
|
* @property {number} [pie.expand.duration=50] Set expand transition time in ms.
|
|
@@ -21782,6 +22241,7 @@ ${percentValue}%`;
|
|
|
21782
22241
|
* @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
|
|
21783
22242
|
* @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
|
|
21784
22243
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
|
|
22244
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
|
|
21785
22245
|
* @example
|
|
21786
22246
|
* pie: {
|
|
21787
22247
|
* label: {
|
|
@@ -21803,7 +22263,51 @@ ${percentValue}%`;
|
|
|
21803
22263
|
* return ratio;
|
|
21804
22264
|
* },
|
|
21805
22265
|
* // or set ratio number
|
|
21806
|
-
* ratio: 0.5
|
|
22266
|
+
* ratio: 0.5,
|
|
22267
|
+
*
|
|
22268
|
+
* // set image to be displayed next to the label text
|
|
22269
|
+
* image: {
|
|
22270
|
+
* url: "./sample.svg",
|
|
22271
|
+
*
|
|
22272
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
22273
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
22274
|
+
* width: 35,
|
|
22275
|
+
* height: 35,
|
|
22276
|
+
* pos: {
|
|
22277
|
+
* x: 0,
|
|
22278
|
+
* y: 0
|
|
22279
|
+
* }
|
|
22280
|
+
* },
|
|
22281
|
+
*
|
|
22282
|
+
* // or use function to return image configuration dynamically
|
|
22283
|
+
* image: function(v, id, i) {
|
|
22284
|
+
* // Return different images based on value
|
|
22285
|
+
* if (v > 500) {
|
|
22286
|
+
* return {
|
|
22287
|
+
* url: "./high-value.svg",
|
|
22288
|
+
* width: 40,
|
|
22289
|
+
* height: 40,
|
|
22290
|
+
* pos: { x: 0, y: 0 }
|
|
22291
|
+
* };
|
|
22292
|
+
* } else if (v > 100) {
|
|
22293
|
+
* return {
|
|
22294
|
+
* url: "./medium-value.svg",
|
|
22295
|
+
* width: 30,
|
|
22296
|
+
* height: 30,
|
|
22297
|
+
* pos: { x: 0, y: 0 }
|
|
22298
|
+
* };
|
|
22299
|
+
* } else if(v < 5) {
|
|
22300
|
+
* // Return falsy value in case of don't want to show image
|
|
22301
|
+
* return null;
|
|
22302
|
+
* } else {
|
|
22303
|
+
* return {
|
|
22304
|
+
* url: "./low-value.svg",
|
|
22305
|
+
* width: 20,
|
|
22306
|
+
* height: 20,
|
|
22307
|
+
* pos: { x: 0, y: 0 }
|
|
22308
|
+
* };
|
|
22309
|
+
* }
|
|
22310
|
+
* }
|
|
21807
22311
|
* },
|
|
21808
22312
|
*
|
|
21809
22313
|
* // disable expand transition for interaction
|
|
@@ -21842,6 +22346,7 @@ ${percentValue}%`;
|
|
|
21842
22346
|
pie_label_format: void 0,
|
|
21843
22347
|
pie_label_ratio: void 0,
|
|
21844
22348
|
pie_label_threshold: 0.05,
|
|
22349
|
+
pie_label_image: void 0,
|
|
21845
22350
|
pie_expand: {},
|
|
21846
22351
|
pie_expand_rate: 0.98,
|
|
21847
22352
|
pie_expand_duration: 50,
|
|
@@ -21864,6 +22369,18 @@ ${percentValue}%`;
|
|
|
21864
22369
|
* @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
|
|
21865
22370
|
* @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
21866
22371
|
* @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
|
|
22372
|
+
* @property {object|Function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22373
|
+
* 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>
|
|
22374
|
+
* The arguments are:<br>
|
|
22375
|
+
* - `v` is the value of the data point where the label is shown.
|
|
22376
|
+
* - `id` is the id of the data where the label is shown.
|
|
22377
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
22378
|
+
* @property {string} polar.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
22379
|
+
* @property {number} polar.label.image.width Image width in pixels.
|
|
22380
|
+
* @property {number} polar.label.image.height Image height in pixels.
|
|
22381
|
+
* @property {object} [polar.label.image.pos] Image position relative to the label text.
|
|
22382
|
+
* @property {number} [polar.label.image.pos.x=0] x coordinate position, relative the original.
|
|
22383
|
+
* @property {number} [polar.label.image.pos.y=0] y coordinate position, relative the original.
|
|
21867
22384
|
* @property {number} [polar.level.depth=3] Set the level depth.
|
|
21868
22385
|
* @property {boolean} [polar.level.show=true] Show or hide level.
|
|
21869
22386
|
* @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
|
|
@@ -21873,6 +22390,7 @@ ${percentValue}%`;
|
|
|
21873
22390
|
* @property {number} [polar.padding=0] Sets the gap between pie arcs.
|
|
21874
22391
|
* @property {number} [polar.startingAngle=0] Set starting angle where data draws.
|
|
21875
22392
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
|
|
22393
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
|
|
21876
22394
|
* @example
|
|
21877
22395
|
* polar: {
|
|
21878
22396
|
* label: {
|
|
@@ -21894,7 +22412,51 @@ ${percentValue}%`;
|
|
|
21894
22412
|
* return ratio;
|
|
21895
22413
|
* },
|
|
21896
22414
|
* // or set ratio number
|
|
21897
|
-
* ratio: 0.5
|
|
22415
|
+
* ratio: 0.5,
|
|
22416
|
+
*
|
|
22417
|
+
* // set image to be displayed next to the label text
|
|
22418
|
+
* image: {
|
|
22419
|
+
* url: "./sample.svg",
|
|
22420
|
+
*
|
|
22421
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
22422
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
22423
|
+
* width: 35,
|
|
22424
|
+
* height: 35,
|
|
22425
|
+
* pos: {
|
|
22426
|
+
* x: 0,
|
|
22427
|
+
* y: 0
|
|
22428
|
+
* }
|
|
22429
|
+
* },
|
|
22430
|
+
*
|
|
22431
|
+
* // or use function to return image configuration dynamically
|
|
22432
|
+
* image: function(v, id, i) {
|
|
22433
|
+
* // Return different images based on value
|
|
22434
|
+
* if (v > 500) {
|
|
22435
|
+
* return {
|
|
22436
|
+
* url: "./high-value.svg",
|
|
22437
|
+
* width: 40,
|
|
22438
|
+
* height: 40,
|
|
22439
|
+
* pos: { x: 0, y: 0 }
|
|
22440
|
+
* };
|
|
22441
|
+
* } else if (v > 100) {
|
|
22442
|
+
* return {
|
|
22443
|
+
* url: "./medium-value.svg",
|
|
22444
|
+
* width: 30,
|
|
22445
|
+
* height: 30,
|
|
22446
|
+
* pos: { x: 0, y: 0 }
|
|
22447
|
+
* };
|
|
22448
|
+
* } else if(v < 5) {
|
|
22449
|
+
* // Return falsy value in case of don't want to show image
|
|
22450
|
+
* return null;
|
|
22451
|
+
* } else {
|
|
22452
|
+
* return {
|
|
22453
|
+
* url: "./low-value.svg",
|
|
22454
|
+
* width: 20,
|
|
22455
|
+
* height: 20,
|
|
22456
|
+
* pos: { x: 0, y: 0 }
|
|
22457
|
+
* };
|
|
22458
|
+
* }
|
|
22459
|
+
* }
|
|
21898
22460
|
* },
|
|
21899
22461
|
* level: {
|
|
21900
22462
|
* depth: 3,
|
|
@@ -21916,6 +22478,7 @@ ${percentValue}%`;
|
|
|
21916
22478
|
polar_label_show: true,
|
|
21917
22479
|
polar_label_format: void 0,
|
|
21918
22480
|
polar_label_threshold: 0.05,
|
|
22481
|
+
polar_label_image: void 0,
|
|
21919
22482
|
polar_label_ratio: void 0,
|
|
21920
22483
|
polar_level_depth: 3,
|
|
21921
22484
|
polar_level_max: void 0,
|
|
@@ -22141,7 +22704,7 @@ const bb = {
|
|
|
22141
22704
|
* bb.version; // "1.0.0"
|
|
22142
22705
|
* @memberof bb
|
|
22143
22706
|
*/
|
|
22144
|
-
version: "3.
|
|
22707
|
+
version: "3.17.0",
|
|
22145
22708
|
/**
|
|
22146
22709
|
* Generate chart
|
|
22147
22710
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|