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-esm/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
|
import { pointer, select, namespaces, selectAll } from 'd3-selection';
|
|
11
11
|
import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
|
|
@@ -222,6 +222,8 @@ var $TEXT = {
|
|
|
222
222
|
text: "bb-text",
|
|
223
223
|
texts: "bb-texts",
|
|
224
224
|
title: "bb-title",
|
|
225
|
+
textBorderRect: "bb-text-border",
|
|
226
|
+
textLabelImage: "bb-text-label-image",
|
|
225
227
|
TextOverlapping: "text-overlapping"
|
|
226
228
|
};
|
|
227
229
|
var $TOOLTIP = {
|
|
@@ -262,6 +264,7 @@ var boost = {
|
|
|
262
264
|
* - **NOTE:**
|
|
263
265
|
* - For now, only applies for data conversion at the initial time.
|
|
264
266
|
* - As of Web Worker's async nature, handling chart instance synchrously is not recommended.
|
|
267
|
+
* - When given data is empty, useWorker will be ignored.
|
|
265
268
|
* @example
|
|
266
269
|
* boost: {
|
|
267
270
|
* useCssRule: true,
|
|
@@ -1582,7 +1585,10 @@ var data$2 = {
|
|
|
1582
1585
|
* - `i` is the index of the data series point where the label is shown.
|
|
1583
1586
|
* - `texts` is the array of whole corresponding data series' text labels.<br><br>
|
|
1584
1587
|
* Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
|
|
1585
|
-
* @property {string|object} [data.labels.backgroundColors] Set label text background colors
|
|
1588
|
+
* @property {string|object|Function} [data.labels.backgroundColors] Set label text background colors.<br><br>
|
|
1589
|
+
* - **NOTE**: When function is set, background colors can be specified one color per dataset.
|
|
1590
|
+
* - Within the function, the last returned color for dataset will be used.
|
|
1591
|
+
* - Only can control set or unset background color for each values.
|
|
1586
1592
|
* @property {string|object|Function} [data.labels.colors] Set label text colors.
|
|
1587
1593
|
* @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
|
|
1588
1594
|
* When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
|
|
@@ -1596,12 +1602,32 @@ var data$2 = {
|
|
|
1596
1602
|
* @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
|
|
1597
1603
|
* @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
|
|
1598
1604
|
* - **NOTE:** Depend on rotate value, text position need to be adjusted manually(using `data.labels.position` option) to be shown nicely.
|
|
1605
|
+
* @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.
|
|
1606
|
+
* @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.
|
|
1607
|
+
* @property {number} [data.labels.border.radius=10] Border radius value.
|
|
1608
|
+
* @property {number} [data.labels.border.strokeWidth=1] Border stroke width.
|
|
1609
|
+
* @property {string} [data.labels.border.stroke="#000"] Border stroke color.
|
|
1610
|
+
* @property {string} [data.labels.border.fill="none"] Border fill color.
|
|
1611
|
+
* @property {object|Function} [data.labels.image] Set image to be displayed next to the label text.<br><br>
|
|
1612
|
+
* 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>
|
|
1613
|
+
* The arguments are:<br>
|
|
1614
|
+
* - `v` is the value of the data point where the label is shown.
|
|
1615
|
+
* - `id` is the id of the data where the label is shown.
|
|
1616
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
1617
|
+
* @property {string} data.labels.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
1618
|
+
* @property {number} data.labels.image.width Image width in pixels.
|
|
1619
|
+
* @property {number} data.labels.image.height Image height in pixels.
|
|
1620
|
+
* @property {object} [data.labels.image.pos] Image position relative to the label text.
|
|
1621
|
+
* @property {number} [data.labels.image.pos.x=0] x coordinate position, relative the original.
|
|
1622
|
+
* @property {number} [data.labels.image.pos.y=0] y coordinate position, relative the original.
|
|
1599
1623
|
* @memberof Options
|
|
1600
1624
|
* @type {object}
|
|
1601
1625
|
* @default {}
|
|
1602
1626
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Data.DataLabel)
|
|
1627
|
+
* @see [Demo: label border](https://naver.github.io/billboard.js/demo/#Data.DataLabelBorder)
|
|
1603
1628
|
* @see [Demo: label colors](https://naver.github.io/billboard.js/demo/#Data.DataLabelColors)
|
|
1604
1629
|
* @see [Demo: label format](https://naver.github.io/billboard.js/demo/#Data.DataLabelFormat)
|
|
1630
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#Data.DataLabelImage)
|
|
1605
1631
|
* @see [Demo: label multiline](https://naver.github.io/billboard.js/demo/#Data.DataLabelMultiline)
|
|
1606
1632
|
* @see [Demo: label overlap](https://naver.github.io/billboard.js/demo/#Data.DataLabelOverlap)
|
|
1607
1633
|
* @see [Demo: label position](https://naver.github.io/billboard.js/demo/#Data.DataLabelPosition)
|
|
@@ -1634,7 +1660,15 @@ var data$2 = {
|
|
|
1634
1660
|
* backgroundColors: {
|
|
1635
1661
|
* data1: "green",
|
|
1636
1662
|
* data2: "yellow"
|
|
1637
|
-
* }
|
|
1663
|
+
* },
|
|
1664
|
+
*
|
|
1665
|
+
* // call back for label text background color
|
|
1666
|
+
* backgroundColors: function(color, d) {
|
|
1667
|
+
* // color: the default data label color string
|
|
1668
|
+
* // data: ex) {x: 0, value: 200, id: "data3", index: 0}
|
|
1669
|
+
* ....
|
|
1670
|
+
* return d.value > 200 ? "cyan" : "red";
|
|
1671
|
+
* },
|
|
1638
1672
|
*
|
|
1639
1673
|
* // apply for all label texts
|
|
1640
1674
|
* colors: "red",
|
|
@@ -1674,7 +1708,76 @@ var data$2 = {
|
|
|
1674
1708
|
* },
|
|
1675
1709
|
*
|
|
1676
1710
|
* // rotate degree for label text
|
|
1677
|
-
* rotate: 90
|
|
1711
|
+
* rotate: 90,
|
|
1712
|
+
*
|
|
1713
|
+
* // add border to data label text
|
|
1714
|
+
* // NOTE: When set as `true`, styling aren't applied. Hence, need to set using '.bb-text-border' class.
|
|
1715
|
+
* // ex. ".bb-text-border { fill: red; stroke: #000; stroke-width: 2px; rx: 10px; ry: 10px; }"
|
|
1716
|
+
* border: true,
|
|
1717
|
+
*
|
|
1718
|
+
* // or set detailed border options
|
|
1719
|
+
* border: {
|
|
1720
|
+
* padding: 10, // set all padding to 10
|
|
1721
|
+
* padding: "5 10", // set top and bottom padding to 5, left and right padding to 10
|
|
1722
|
+
* padding: { // specify each padding
|
|
1723
|
+
* top: 3,
|
|
1724
|
+
* bottom: 5,
|
|
1725
|
+
* left: 10,
|
|
1726
|
+
* right: 13
|
|
1727
|
+
* },
|
|
1728
|
+
* radius: 10,
|
|
1729
|
+
* strokeWidth: 2,
|
|
1730
|
+
* stroke: "#000",
|
|
1731
|
+
* fill: "red"
|
|
1732
|
+
* },
|
|
1733
|
+
*
|
|
1734
|
+
* // set image to be displayed next to the label text
|
|
1735
|
+
* image: {
|
|
1736
|
+
* url: "./sample.svg",
|
|
1737
|
+
*
|
|
1738
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
1739
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
1740
|
+
* width: 35,
|
|
1741
|
+
* height: 35,
|
|
1742
|
+
* pos: {
|
|
1743
|
+
* x: 0,
|
|
1744
|
+
* y: 0
|
|
1745
|
+
* }
|
|
1746
|
+
* },
|
|
1747
|
+
*
|
|
1748
|
+
* // or use function to return image configuration dynamically
|
|
1749
|
+
* image: function(v, id, i) {
|
|
1750
|
+
* // v is the value of the data point where the label is shown.
|
|
1751
|
+
* // id is the id of the data where the label is shown.
|
|
1752
|
+
* // i is the index of the data series point where the label is shown.
|
|
1753
|
+
*
|
|
1754
|
+
* // Return different images based on value
|
|
1755
|
+
* if (v > 500) {
|
|
1756
|
+
* return {
|
|
1757
|
+
* url: "./high-value.svg",
|
|
1758
|
+
* width: 40,
|
|
1759
|
+
* height: 40,
|
|
1760
|
+
* pos: { x: 0, y: 0 }
|
|
1761
|
+
* };
|
|
1762
|
+
* } else if (v > 100) {
|
|
1763
|
+
* return {
|
|
1764
|
+
* url: "./medium-value.svg",
|
|
1765
|
+
* width: 30,
|
|
1766
|
+
* height: 30,
|
|
1767
|
+
* pos: { x: 0, y: 0 }
|
|
1768
|
+
* };
|
|
1769
|
+
* } else if(v < 5) {
|
|
1770
|
+
* // Return falsy value in case of don't want to show image
|
|
1771
|
+
* return null;
|
|
1772
|
+
* } else {
|
|
1773
|
+
* return {
|
|
1774
|
+
* url: "./low-value.svg",
|
|
1775
|
+
* width: 20,
|
|
1776
|
+
* height: 20,
|
|
1777
|
+
* pos: { x: 0, y: 0 }
|
|
1778
|
+
* };
|
|
1779
|
+
* }
|
|
1780
|
+
* }
|
|
1678
1781
|
* }
|
|
1679
1782
|
* }
|
|
1680
1783
|
*/
|
|
@@ -1682,6 +1785,7 @@ var data$2 = {
|
|
|
1682
1785
|
data_labels_backgroundColors: undefined,
|
|
1683
1786
|
data_labels_colors: undefined,
|
|
1684
1787
|
data_labels_position: {},
|
|
1788
|
+
data_labels_imgUrl: undefined,
|
|
1685
1789
|
/**
|
|
1686
1790
|
* Hide each data when the chart appears.<br><br>
|
|
1687
1791
|
* If true specified, all of data will be hidden. If multiple ids specified as an array, those will be hidden.
|
|
@@ -2998,6 +3102,26 @@ function runUntil(fn, conditionFn) {
|
|
|
2998
3102
|
fn();
|
|
2999
3103
|
}
|
|
3000
3104
|
}
|
|
3105
|
+
/**
|
|
3106
|
+
* Parse CSS shorthand values (padding, margin, border-radius, etc.)
|
|
3107
|
+
* @param {number|string|object} value Shorthand value(s)
|
|
3108
|
+
* @returns {object} Parsed object with top, right, bottom, left properties
|
|
3109
|
+
* @private
|
|
3110
|
+
*/
|
|
3111
|
+
function parseShorthand(value) {
|
|
3112
|
+
if (isObject(value) && !isString(value)) {
|
|
3113
|
+
var obj = value;
|
|
3114
|
+
return {
|
|
3115
|
+
top: obj.top || 0,
|
|
3116
|
+
right: obj.right || 0,
|
|
3117
|
+
bottom: obj.bottom || 0,
|
|
3118
|
+
left: obj.left || 0
|
|
3119
|
+
};
|
|
3120
|
+
}
|
|
3121
|
+
var values = (isString(value) ? value.trim().split(/\s+/) : [value]).map(function (v) { return +v || 0; });
|
|
3122
|
+
var a = values[0], _a = values[1], b = _a === void 0 ? a : _a, _b = values[2], c = _b === void 0 ? a : _b, _c = values[3], d = _c === void 0 ? b : _c;
|
|
3123
|
+
return { top: a, right: b, bottom: c, left: d };
|
|
3124
|
+
}
|
|
3001
3125
|
|
|
3002
3126
|
/**
|
|
3003
3127
|
* Class to set options on generating chart.
|
|
@@ -3961,13 +4085,13 @@ var dataConvert = {
|
|
|
3961
4085
|
url(data.url, data.mimeType, data.headers, getDataKeyForJson(data.keys, config), callback);
|
|
3962
4086
|
}
|
|
3963
4087
|
else if (data.json) {
|
|
3964
|
-
runWorker(useWorker, json, callback, [columns, rows])(data.json, getDataKeyForJson(data.keys, config));
|
|
4088
|
+
runWorker(data.json.length ? useWorker : false, json, callback, [columns, rows])(data.json, getDataKeyForJson(data.keys, config));
|
|
3965
4089
|
}
|
|
3966
4090
|
else if (data.rows) {
|
|
3967
|
-
runWorker(useWorker, rows, callback)(data.rows);
|
|
4091
|
+
runWorker(data.rows.length ? useWorker : false, rows, callback)(data.rows);
|
|
3968
4092
|
}
|
|
3969
4093
|
else if (data.columns) {
|
|
3970
|
-
runWorker(useWorker, columns, callback)(data.columns);
|
|
4094
|
+
runWorker(data.columns.length ? useWorker : false, columns, callback)(data.columns);
|
|
3971
4095
|
}
|
|
3972
4096
|
else if (args.bindto) {
|
|
3973
4097
|
throw Error("url or json or rows or columns is required.");
|
|
@@ -5630,7 +5754,7 @@ var color = {
|
|
|
5630
5754
|
},
|
|
5631
5755
|
/**
|
|
5632
5756
|
* Append data backgound color filter definition
|
|
5633
|
-
* @param {string|object} color Color string
|
|
5757
|
+
* @param {string|object|Function} color Color string, object, or function
|
|
5634
5758
|
* @param {object} attr filter attribute
|
|
5635
5759
|
* @private
|
|
5636
5760
|
*/
|
|
@@ -5642,7 +5766,7 @@ var color = {
|
|
|
5642
5766
|
height: 1
|
|
5643
5767
|
}; }
|
|
5644
5768
|
var $$ = this;
|
|
5645
|
-
var
|
|
5769
|
+
var defs = $$.$el.defs, state = $$.state;
|
|
5646
5770
|
if (color) {
|
|
5647
5771
|
var ids = [];
|
|
5648
5772
|
if (isString(color)) {
|
|
@@ -5651,17 +5775,24 @@ var color = {
|
|
|
5651
5775
|
else if (isObject(color)) {
|
|
5652
5776
|
ids = Object.keys(color);
|
|
5653
5777
|
}
|
|
5778
|
+
else if (isFunction(color)) {
|
|
5779
|
+
ids = $$.mapToTargetIds();
|
|
5780
|
+
}
|
|
5654
5781
|
ids.forEach(function (v) {
|
|
5655
5782
|
var id = "".concat(state.datetimeId, "-labels-bg").concat($$.getTargetSelectorSuffix(v)).concat(isString(color) ? $$.getTargetSelectorSuffix(color) : "");
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
.
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5783
|
+
var colorValue = v === "" ? color : (color === null || color === void 0 ? void 0 : color[v]) || "";
|
|
5784
|
+
if (defs.select("#".concat(id)).empty()) {
|
|
5785
|
+
defs.append("filter")
|
|
5786
|
+
.attr("x", attr.x)
|
|
5787
|
+
.attr("y", attr.y)
|
|
5788
|
+
.attr("width", attr.width)
|
|
5789
|
+
.attr("height", attr.height)
|
|
5790
|
+
.attr("id", id)
|
|
5791
|
+
.html("<feFlood flood-color=\"".concat(colorValue, "\" />\n\t\t\t\t\t\t\t<feComposite in=\"SourceGraphic\" />"));
|
|
5792
|
+
}
|
|
5663
5793
|
});
|
|
5664
5794
|
}
|
|
5795
|
+
// Note: For function type, filters will be created dynamically in updateTextBGColor
|
|
5665
5796
|
},
|
|
5666
5797
|
/**
|
|
5667
5798
|
* Get data gradient color url
|
|
@@ -7912,10 +8043,174 @@ function getTextPos(d, type) {
|
|
|
7912
8043
|
position.bind(this.api)(type, value, id, index, this.$el.text) :
|
|
7913
8044
|
(id in position ? position[id] : position)[type])) !== null && _a !== void 0 ? _a : 0;
|
|
7914
8045
|
}
|
|
8046
|
+
/**
|
|
8047
|
+
* Update text border
|
|
8048
|
+
* @param {SVGTextElement} text Text element
|
|
8049
|
+
* @param {Coord} pos Position object
|
|
8050
|
+
* @param {string} rectClass Class name
|
|
8051
|
+
* @private
|
|
8052
|
+
*/
|
|
8053
|
+
function updateTextBorder(text, pos, rectClass) {
|
|
8054
|
+
var _a, _b;
|
|
8055
|
+
var $$ = this;
|
|
8056
|
+
var config = $$.config, $T = $$.$T;
|
|
8057
|
+
var isRotated = config.axis_rotated;
|
|
8058
|
+
var _c = config.data_labels.border, _d = _c.padding, padding = _d === void 0 ? "3 5" : _d, _e = _c.radius, radius = _e === void 0 ? 10 : _e, _f = _c.stroke, stroke = _f === void 0 ? "#000" : _f, _g = _c.strokeWidth, strokeWidth = _g === void 0 ? 1 : _g, _h = _c.fill, fill = _h === void 0 ? "none" : _h;
|
|
8059
|
+
var borderPadding = parseShorthand(padding);
|
|
8060
|
+
var applyStyle = config.data_labels.border !== true;
|
|
8061
|
+
var textRect = getBBox(text);
|
|
8062
|
+
var borderRect = select(text.previousElementSibling);
|
|
8063
|
+
if (borderRect.empty() ||
|
|
8064
|
+
((_a = borderRect.node()) === null || _a === void 0 ? void 0 : _a.tagName) !== "rect" ||
|
|
8065
|
+
!((_b = borderRect.attr("class")) === null || _b === void 0 ? void 0 : _b.includes(rectClass))) {
|
|
8066
|
+
borderRect = select(text.parentNode)
|
|
8067
|
+
.insert("rect", function () { return text; })
|
|
8068
|
+
.attr("class", "".concat($TEXT.textBorderRect, " ").concat(rectClass))
|
|
8069
|
+
.attr("width", textRect.width + (applyStyle ? borderPadding.left + borderPadding.right : 0))
|
|
8070
|
+
.attr("height", textRect.height + (applyStyle ? borderPadding.top + borderPadding.bottom : 0));
|
|
8071
|
+
if (applyStyle) {
|
|
8072
|
+
borderRect
|
|
8073
|
+
.style("fill", fill)
|
|
8074
|
+
.style("stroke", stroke)
|
|
8075
|
+
.style("stroke-width", "".concat(strokeWidth, "px"))
|
|
8076
|
+
.attr("rx", radius)
|
|
8077
|
+
.attr("ry", radius);
|
|
8078
|
+
}
|
|
8079
|
+
}
|
|
8080
|
+
$T(borderRect)
|
|
8081
|
+
.attr("x", pos.x - (applyStyle ? borderPadding.left : 0) - (isRotated ? 0 : textRect.width / 2))
|
|
8082
|
+
.attr("y", pos.y - (applyStyle ? borderPadding.top : 0) - (textRect.height / 4 * 3.2));
|
|
8083
|
+
}
|
|
8084
|
+
/**
|
|
8085
|
+
* Check if meets the ratio to show data label text
|
|
8086
|
+
* @param {number} ratio ratio to meet
|
|
8087
|
+
* @param {string} type chart type
|
|
8088
|
+
* @returns {boolean}
|
|
8089
|
+
* @private
|
|
8090
|
+
*/
|
|
8091
|
+
function meetsLabelThreshold(ratio, type) {
|
|
8092
|
+
if (ratio === void 0) { ratio = 0; }
|
|
8093
|
+
var $$ = this;
|
|
8094
|
+
var config = $$.config;
|
|
8095
|
+
var threshold = config["".concat(type, "_label_threshold")] || 0;
|
|
8096
|
+
return ratio >= threshold;
|
|
8097
|
+
}
|
|
8098
|
+
/**
|
|
8099
|
+
* Update text image
|
|
8100
|
+
* @private
|
|
8101
|
+
*/
|
|
8102
|
+
function updateTextImage() {
|
|
8103
|
+
var $$ = this;
|
|
8104
|
+
var text = $$.$el.text, config = $$.config;
|
|
8105
|
+
var isArc = $$.state.arcWidth;
|
|
8106
|
+
if (isArc ? $$.getArcLabelConfig("image") : config.data_labels.image) {
|
|
8107
|
+
text.filter(function () {
|
|
8108
|
+
var prev = this.previousElementSibling;
|
|
8109
|
+
if (prev) {
|
|
8110
|
+
return prev.tagName !== "image" || !prev.classList.contains($TEXT.textLabelImage);
|
|
8111
|
+
}
|
|
8112
|
+
return true;
|
|
8113
|
+
}).each(function (d) {
|
|
8114
|
+
var _a, _b, _c, _d;
|
|
8115
|
+
var _e = getDataLabelImgUrl.call($$, d), url = _e.url, width = _e.width, height = _e.height, pos = _e.pos;
|
|
8116
|
+
if (url) {
|
|
8117
|
+
var parentNode = select(this.parentNode);
|
|
8118
|
+
// Insert image before text
|
|
8119
|
+
parentNode === null || parentNode === void 0 ? void 0 : parentNode.insert("image", "".concat((_b = (_a = this.getAttribute("class")) === null || _a === void 0 ? void 0 : _a.replace(/(?:^(.)|\s)/g, ".$1")) !== null && _b !== void 0 ? _b : "text")).style("opacity", "0").attr("href", function (d) {
|
|
8120
|
+
return tplProcess(url, {
|
|
8121
|
+
ID: ("id" in d) ? d.id : d.data.id
|
|
8122
|
+
});
|
|
8123
|
+
}).attr("class", $TEXT.textLabelImage).style("pointer-events", "none").attr("width", width).attr("height", height).attr("transform", pos ? "translate(".concat((_c = pos.x) !== null && _c !== void 0 ? _c : 0, " ").concat((_d = pos.y) !== null && _d !== void 0 ? _d : 0, ")") : null);
|
|
8124
|
+
}
|
|
8125
|
+
});
|
|
8126
|
+
}
|
|
8127
|
+
}
|
|
8128
|
+
/**
|
|
8129
|
+
* Get image URL for data label
|
|
8130
|
+
* @param {object} d Data object
|
|
8131
|
+
* @returns {string|null} Image URL
|
|
8132
|
+
* @private
|
|
8133
|
+
*/
|
|
8134
|
+
function getDataLabelImgUrl(d) {
|
|
8135
|
+
var _a;
|
|
8136
|
+
var $$ = this;
|
|
8137
|
+
var config = $$.config, state = $$.state;
|
|
8138
|
+
var image = state.arcWidth ? $$.getArcLabelConfig("image") : config.data_labels.image;
|
|
8139
|
+
if (isFunction(image)) {
|
|
8140
|
+
return (_a = image.call($$.api, d.value, d.id, d.index)) !== null && _a !== void 0 ? _a : {
|
|
8141
|
+
url: "",
|
|
8142
|
+
width: 0,
|
|
8143
|
+
height: 0,
|
|
8144
|
+
pos: { x: 0, y: 0 }
|
|
8145
|
+
};
|
|
8146
|
+
}
|
|
8147
|
+
else if (image) {
|
|
8148
|
+
var _b = image.url, url = _b === void 0 ? "" : _b, _c = image.width, width = _c === void 0 ? 0 : _c, _d = image.height, height = _d === void 0 ? 0 : _d, pos = image.pos;
|
|
8149
|
+
return {
|
|
8150
|
+
url: url,
|
|
8151
|
+
width: width,
|
|
8152
|
+
height: height,
|
|
8153
|
+
pos: pos
|
|
8154
|
+
};
|
|
8155
|
+
}
|
|
8156
|
+
return null;
|
|
8157
|
+
}
|
|
8158
|
+
/**
|
|
8159
|
+
* Update text image position
|
|
8160
|
+
* @param {SVGTextElement} textNode Text element
|
|
8161
|
+
* @param {object} pos Position object
|
|
8162
|
+
* @param {number} pos.x X coordinate
|
|
8163
|
+
* @param {number} pos.y Y coordinate
|
|
8164
|
+
* @private
|
|
8165
|
+
*/
|
|
8166
|
+
function updateTextImagePos(textNode, pos) {
|
|
8167
|
+
var _this = this;
|
|
8168
|
+
var _a;
|
|
8169
|
+
var $$ = this;
|
|
8170
|
+
var config = $$.config, _b = $$.state, arcWidth = _b.arcWidth, hasTreemap = _b.hasTreemap;
|
|
8171
|
+
var isRotated = config.axis_rotated;
|
|
8172
|
+
var image = select(textNode.previousElementSibling);
|
|
8173
|
+
var isShown = function (textNode) {
|
|
8174
|
+
var _a;
|
|
8175
|
+
var isShown = textNode.style.opacity !== "0" && textNode.style.fillOpacity !== "0";
|
|
8176
|
+
return (arcWidth ? textNode.textContent : isShown) &&
|
|
8177
|
+
((_a = _this.previousElementSibling) === null || _a === void 0 ? void 0 : _a.tagName) !== "image";
|
|
8178
|
+
};
|
|
8179
|
+
if (!image.empty() && ((_a = image.node()) === null || _a === void 0 ? void 0 : _a.tagName) === "image") {
|
|
8180
|
+
var textRect = getBoundingRect(textNode);
|
|
8181
|
+
var w = +image.attr("width") / 2;
|
|
8182
|
+
var h = +image.attr("height") / 2;
|
|
8183
|
+
var x = pos.x - w;
|
|
8184
|
+
var y = pos.y - h - textRect.height / 2;
|
|
8185
|
+
if (isRotated) {
|
|
8186
|
+
pos.x += w;
|
|
8187
|
+
}
|
|
8188
|
+
else {
|
|
8189
|
+
if (hasTreemap) {
|
|
8190
|
+
x = -w;
|
|
8191
|
+
y = -(h * 2 + textRect.height);
|
|
8192
|
+
}
|
|
8193
|
+
// exclude pie & polar type
|
|
8194
|
+
if (!($$.hasType("pie") || $$.hasType("polar"))) {
|
|
8195
|
+
pos.y += h;
|
|
8196
|
+
}
|
|
8197
|
+
}
|
|
8198
|
+
$$.$T(image)
|
|
8199
|
+
.style("opacity", isShown(textNode) ? null : "0")
|
|
8200
|
+
.attr("x", x)
|
|
8201
|
+
.attr("y", y);
|
|
8202
|
+
}
|
|
8203
|
+
}
|
|
8204
|
+
|
|
8205
|
+
/**
|
|
8206
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
8207
|
+
* billboard.js project is licensed under the MIT license
|
|
8208
|
+
*/
|
|
7915
8209
|
var text = {
|
|
7916
8210
|
opacityForText: function (d) {
|
|
7917
8211
|
var $$ = this;
|
|
7918
|
-
return $$.isBarType(d) &&
|
|
8212
|
+
return $$.isBarType(d) &&
|
|
8213
|
+
!meetsLabelThreshold.call($$, Math.abs($$.getRatio("bar", d)), "bar") ?
|
|
7919
8214
|
"0" :
|
|
7920
8215
|
($$.hasDataLabel ? null : "0");
|
|
7921
8216
|
},
|
|
@@ -8006,6 +8301,8 @@ var text = {
|
|
|
8006
8301
|
setTextValue(node, value);
|
|
8007
8302
|
}
|
|
8008
8303
|
});
|
|
8304
|
+
// Add images if imgUrl is specified
|
|
8305
|
+
updateTextImage.call($$);
|
|
8009
8306
|
},
|
|
8010
8307
|
updateTextColor: function (d) {
|
|
8011
8308
|
var $$ = this;
|
|
@@ -8037,22 +8334,34 @@ var text = {
|
|
|
8037
8334
|
/**
|
|
8038
8335
|
* Update data label text background color
|
|
8039
8336
|
* @param {object} d Data object
|
|
8040
|
-
* @param {object|string} option option object
|
|
8337
|
+
* @param {object|string|Function} option option object
|
|
8041
8338
|
* @returns {string|null}
|
|
8042
8339
|
* @private
|
|
8043
8340
|
*/
|
|
8044
8341
|
updateTextBGColor: function (d, option) {
|
|
8045
8342
|
var $$ = this;
|
|
8046
|
-
var
|
|
8343
|
+
var defs = $$.$el.defs;
|
|
8047
8344
|
var color = "";
|
|
8048
|
-
if (
|
|
8345
|
+
if (option) {
|
|
8049
8346
|
var id = isString(option) ?
|
|
8050
8347
|
"" :
|
|
8051
8348
|
$$.getTargetSelectorSuffix("id" in d ? d.id : d.data.id);
|
|
8052
|
-
var filter =
|
|
8349
|
+
var filter = defs.select(["filter[id*='labels-bg", "']"].join(id));
|
|
8053
8350
|
if (filter.size()) {
|
|
8054
8351
|
color = "url(#".concat(filter.attr("id"), ")");
|
|
8055
8352
|
}
|
|
8353
|
+
if (isFunction(option)) {
|
|
8354
|
+
$$.generateTextBGColorFilter(option);
|
|
8355
|
+
// Get default color and call function
|
|
8356
|
+
var defaultColor = $$.color(d);
|
|
8357
|
+
var bgColor = option.bind($$.api)(defaultColor, d);
|
|
8358
|
+
if (bgColor) {
|
|
8359
|
+
filter.select("feFlood").attr("flood-color", bgColor);
|
|
8360
|
+
}
|
|
8361
|
+
else {
|
|
8362
|
+
color = "";
|
|
8363
|
+
}
|
|
8364
|
+
}
|
|
8056
8365
|
}
|
|
8057
8366
|
return color || null;
|
|
8058
8367
|
},
|
|
@@ -8079,7 +8388,8 @@ var text = {
|
|
|
8079
8388
|
.style("fill-opacity", forFlow ? 0 : $$.opacityForText.bind($$))
|
|
8080
8389
|
.each(function (d, i) {
|
|
8081
8390
|
// do not apply transition for newly added text elements
|
|
8082
|
-
var node = $T(hasTreemap && this.childElementCount ? this.parentNode : this, !!(withTransition &&
|
|
8391
|
+
var node = $T(hasTreemap && this.childElementCount ? this.parentNode : this, !!(withTransition &&
|
|
8392
|
+
(this.getAttribute("x") || this.getAttribute("transform"))), t);
|
|
8083
8393
|
var isInverted = config["axis_".concat(axis === null || axis === void 0 ? void 0 : axis.getId(d.id), "_inverted")];
|
|
8084
8394
|
var pos = {
|
|
8085
8395
|
x: getX.bind(this)(d, i),
|
|
@@ -8089,6 +8399,7 @@ var text = {
|
|
|
8089
8399
|
pos = setRotatePos.bind($$)(d, pos, anchorString, isRotated, isInverted);
|
|
8090
8400
|
node.attr("text-anchor", anchorString);
|
|
8091
8401
|
}
|
|
8402
|
+
updateTextImagePos.call($$, this, pos);
|
|
8092
8403
|
// when is multiline
|
|
8093
8404
|
if (this.childElementCount || angle) {
|
|
8094
8405
|
node.attr("transform", "translate(".concat(pos.x, " ").concat(pos.y, ") ").concat(rotateString));
|
|
@@ -8096,6 +8407,8 @@ var text = {
|
|
|
8096
8407
|
else {
|
|
8097
8408
|
node.attr("x", pos.x).attr("y", pos.y);
|
|
8098
8409
|
}
|
|
8410
|
+
config.data_labels.border &&
|
|
8411
|
+
updateTextBorder.call($$, node.node(), pos, "".concat($TEXT.textBorderRect, "-").concat(i));
|
|
8099
8412
|
});
|
|
8100
8413
|
// need to return 'true' as of being pushed to the redraw list
|
|
8101
8414
|
// ref: getRedrawList()
|
|
@@ -8380,20 +8693,6 @@ var text = {
|
|
|
8380
8693
|
selectAll([this, this.previousSibling])
|
|
8381
8694
|
.classed($TEXT.TextOverlapping, false);
|
|
8382
8695
|
});
|
|
8383
|
-
},
|
|
8384
|
-
/**
|
|
8385
|
-
* Check if meets the ratio to show data label text
|
|
8386
|
-
* @param {number} ratio ratio to meet
|
|
8387
|
-
* @param {string} type chart type
|
|
8388
|
-
* @returns {boolean}
|
|
8389
|
-
* @private
|
|
8390
|
-
*/
|
|
8391
|
-
meetsLabelThreshold: function (ratio, type) {
|
|
8392
|
-
if (ratio === void 0) { ratio = 0; }
|
|
8393
|
-
var $$ = this;
|
|
8394
|
-
var config = $$.config;
|
|
8395
|
-
var threshold = config["".concat(type, "_label_threshold")] || 0;
|
|
8396
|
-
return ratio >= threshold;
|
|
8397
8696
|
}
|
|
8398
8697
|
};
|
|
8399
8698
|
|
|
@@ -12849,6 +13148,7 @@ var apiX = {
|
|
|
12849
13148
|
|
|
12850
13149
|
var AxisRendererHelper = /** @class */ (function () {
|
|
12851
13150
|
function AxisRendererHelper(owner) {
|
|
13151
|
+
this.charSize = {};
|
|
12852
13152
|
var scale = getScale();
|
|
12853
13153
|
var config = owner.config, params = owner.params;
|
|
12854
13154
|
this.owner = owner;
|
|
@@ -12862,18 +13162,22 @@ var AxisRendererHelper = /** @class */ (function () {
|
|
|
12862
13162
|
}
|
|
12863
13163
|
/**
|
|
12864
13164
|
* Compute a character dimension
|
|
13165
|
+
* @param {string} orient Axis orientation
|
|
12865
13166
|
* @param {d3.selection} text SVG text selection
|
|
12866
13167
|
* @param {boolean} memoize memoize the calculated size
|
|
12867
13168
|
* @returns {{w: number, h: number}}
|
|
12868
13169
|
* @private
|
|
12869
13170
|
*/
|
|
12870
|
-
AxisRendererHelper.getSizeFor1Char = function (text, memoize) {
|
|
13171
|
+
AxisRendererHelper.prototype.getSizeFor1Char = function (orient, text, memoize) {
|
|
12871
13172
|
if (memoize === void 0) { memoize = true; }
|
|
12872
13173
|
// default size for one character
|
|
12873
13174
|
var size = {
|
|
12874
13175
|
w: 5.5,
|
|
12875
13176
|
h: 11.5
|
|
12876
13177
|
};
|
|
13178
|
+
if (this.charSize[orient] && memoize) {
|
|
13179
|
+
return this.charSize[orient];
|
|
13180
|
+
}
|
|
12877
13181
|
!text.empty() && text
|
|
12878
13182
|
.text("0")
|
|
12879
13183
|
.call(function (el) {
|
|
@@ -12888,9 +13192,7 @@ var AxisRendererHelper = /** @class */ (function () {
|
|
|
12888
13192
|
el.text("");
|
|
12889
13193
|
}
|
|
12890
13194
|
});
|
|
12891
|
-
|
|
12892
|
-
this.getSizeFor1Char = function () { return size; };
|
|
12893
|
-
}
|
|
13195
|
+
this.charSize[orient] = size;
|
|
12894
13196
|
return size;
|
|
12895
13197
|
};
|
|
12896
13198
|
/**
|
|
@@ -13097,7 +13399,7 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
13097
13399
|
tickShow.text && tickEnter.append("text");
|
|
13098
13400
|
var tickText = tick.select("text");
|
|
13099
13401
|
var counts_1 = [];
|
|
13100
|
-
var sizeFor1Char_1;
|
|
13402
|
+
var sizeFor1Char_1 = { w: 0, h: 0 };
|
|
13101
13403
|
if (isFunction(evalTextSize)) {
|
|
13102
13404
|
// set evalTextSize to dummy axis element to be used in .getMaxTickSize()
|
|
13103
13405
|
sizeFor1Char_1 = evalTextSize.bind(ctx.params.owner.api)(tickText.node(), id);
|
|
@@ -13105,8 +13407,8 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
13105
13407
|
this.sizeFor1Char = sizeFor1Char_1;
|
|
13106
13408
|
}
|
|
13107
13409
|
}
|
|
13108
|
-
if (!sizeFor1Char_1) {
|
|
13109
|
-
sizeFor1Char_1 =
|
|
13410
|
+
if (!sizeFor1Char_1 || sizeFor1Char_1.w === 0 || sizeFor1Char_1.h === 0) {
|
|
13411
|
+
sizeFor1Char_1 = ctx.helper.getSizeFor1Char(orient, tickText, !!evalTextSize);
|
|
13110
13412
|
}
|
|
13111
13413
|
var tspan = tickText
|
|
13112
13414
|
.selectAll("tspan")
|
|
@@ -13153,7 +13455,7 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
13153
13455
|
var textUpdate = tick.select("text");
|
|
13154
13456
|
tickEnter.select("line").attr("".concat(axisPx, "2"), innerTickSize * sign);
|
|
13155
13457
|
tickEnter.select("text").attr(axisPx, tickLength * sign);
|
|
13156
|
-
ctx.setTickLineTextPosition(lineUpdate, textUpdate);
|
|
13458
|
+
ctx.setTickLineTextPosition(lineUpdate, textUpdate, sizeFor1Char_1);
|
|
13157
13459
|
// Append <title> for tooltip display
|
|
13158
13460
|
if (params.tickTitle) {
|
|
13159
13461
|
var title = textUpdate.select("title");
|
|
@@ -13234,12 +13536,17 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
13234
13536
|
* Set tick's line & text position
|
|
13235
13537
|
* @param {d3.selection} lineUpdate Line selection
|
|
13236
13538
|
* @param {d3.selection} textUpdate Text selection
|
|
13539
|
+
* @param {object} sizeFor1Char Size for 1 char
|
|
13237
13540
|
* @private
|
|
13238
13541
|
*/
|
|
13239
|
-
AxisRenderer.prototype.setTickLineTextPosition = function (lineUpdate, textUpdate) {
|
|
13542
|
+
AxisRenderer.prototype.setTickLineTextPosition = function (lineUpdate, textUpdate, sizeFor1Char) {
|
|
13543
|
+
var _this = this;
|
|
13240
13544
|
var tickPos = this.getTickXY();
|
|
13241
13545
|
var _a = this.config, innerTickSize = _a.innerTickSize, orient = _a.orient, tickLength = _a.tickLength, tickOffset = _a.tickOffset;
|
|
13546
|
+
var axisId = this.params.id;
|
|
13242
13547
|
var rotate = this.params.tickTextRotate;
|
|
13548
|
+
var baseHeight = 6;
|
|
13549
|
+
var charHeight = (sizeFor1Char.h / 2) - baseHeight;
|
|
13243
13550
|
var textAnchorForText = function (r) {
|
|
13244
13551
|
var value = ["start", "end"];
|
|
13245
13552
|
orient === "top" && value.reverse();
|
|
@@ -13248,15 +13555,17 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
13248
13555
|
var textTransform = function (r) { return (r ? "rotate(".concat(r, ")") : null); };
|
|
13249
13556
|
var yForText = function (r) {
|
|
13250
13557
|
var r2 = r / (orient === "bottom" ? 15 : 23);
|
|
13251
|
-
|
|
13558
|
+
var y = r ? 11.5 - 2.5 * r2 * (r > 0 ? 1 : -1) : tickLength;
|
|
13559
|
+
return y;
|
|
13252
13560
|
};
|
|
13253
13561
|
var _b = this.params.owner.config, isRotated = _b.axis_rotated, inner = _b.axis_x_tick_text_inner;
|
|
13562
|
+
var tickLineInner = this.params.config["axis_".concat(axisId, "_tick_inner")];
|
|
13254
13563
|
switch (orient) {
|
|
13255
13564
|
case "bottom":
|
|
13256
13565
|
lineUpdate
|
|
13257
13566
|
.attr("x1", tickPos.x)
|
|
13258
13567
|
.attr("x2", tickPos.x)
|
|
13259
|
-
.attr("y2",
|
|
13568
|
+
.attr("y2", function (d) { return _this.getTickSize.bind(_this)(d) * (tickLineInner ? -1 : 1); });
|
|
13260
13569
|
textUpdate
|
|
13261
13570
|
.attr("x", 0)
|
|
13262
13571
|
.attr("y", yForText(rotate))
|
|
@@ -13276,30 +13585,30 @@ var AxisRenderer = /** @class */ (function () {
|
|
|
13276
13585
|
case "top":
|
|
13277
13586
|
lineUpdate
|
|
13278
13587
|
.attr("x2", 0)
|
|
13279
|
-
.attr("y2", -innerTickSize);
|
|
13588
|
+
.attr("y2", tickLineInner ? innerTickSize : -innerTickSize);
|
|
13280
13589
|
textUpdate
|
|
13281
13590
|
.attr("x", 0)
|
|
13282
|
-
.attr("y", -yForText(rotate)
|
|
13591
|
+
.attr("y", -(yForText(rotate) + charHeight + baseHeight))
|
|
13283
13592
|
.style("text-anchor", textAnchorForText(rotate))
|
|
13284
13593
|
.attr("transform", textTransform(rotate));
|
|
13285
13594
|
break;
|
|
13286
13595
|
case "left":
|
|
13287
13596
|
lineUpdate
|
|
13288
|
-
.attr("x2", -innerTickSize)
|
|
13597
|
+
.attr("x2", tickLineInner ? innerTickSize : -innerTickSize)
|
|
13289
13598
|
.attr("y1", tickPos.y)
|
|
13290
13599
|
.attr("y2", tickPos.y);
|
|
13291
13600
|
textUpdate
|
|
13292
13601
|
.attr("x", -tickLength)
|
|
13293
|
-
.attr("y", tickOffset)
|
|
13602
|
+
.attr("y", tickOffset + (isRotated ? charHeight / 4 : charHeight))
|
|
13294
13603
|
.style("text-anchor", "end");
|
|
13295
13604
|
break;
|
|
13296
13605
|
case "right":
|
|
13297
13606
|
lineUpdate
|
|
13298
|
-
.attr("x2", innerTickSize)
|
|
13607
|
+
.attr("x2", tickLineInner ? -innerTickSize : innerTickSize)
|
|
13299
13608
|
.attr("y2", 0);
|
|
13300
13609
|
textUpdate
|
|
13301
13610
|
.attr("x", tickLength)
|
|
13302
|
-
.attr("y",
|
|
13611
|
+
.attr("y", charHeight)
|
|
13303
13612
|
.style("text-anchor", "start");
|
|
13304
13613
|
}
|
|
13305
13614
|
};
|
|
@@ -16236,6 +16545,23 @@ var x = {
|
|
|
16236
16545
|
* }
|
|
16237
16546
|
*/
|
|
16238
16547
|
axis_x_tick_count: undefined,
|
|
16548
|
+
/**
|
|
16549
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
16550
|
+
* @name axis․x․tick․inner
|
|
16551
|
+
* @memberof Options
|
|
16552
|
+
* @type {boolean}
|
|
16553
|
+
* @default false
|
|
16554
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
16555
|
+
* @example
|
|
16556
|
+
* axis: {
|
|
16557
|
+
* x: {
|
|
16558
|
+
* tick: {
|
|
16559
|
+
* inner: true
|
|
16560
|
+
* }
|
|
16561
|
+
* }
|
|
16562
|
+
* }
|
|
16563
|
+
*/
|
|
16564
|
+
axis_x_tick_inner: false,
|
|
16239
16565
|
/**
|
|
16240
16566
|
* Show or hide x axis tick line.
|
|
16241
16567
|
* @name axis․x․tick․show
|
|
@@ -16977,6 +17303,22 @@ var y = {
|
|
|
16977
17303
|
* }
|
|
16978
17304
|
*/
|
|
16979
17305
|
axis_y_tick_culling_reverse: false,
|
|
17306
|
+
/**
|
|
17307
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
17308
|
+
* @name axis․y․tick․inner
|
|
17309
|
+
* @memberof Options
|
|
17310
|
+
* @type {boolean}
|
|
17311
|
+
* @default false
|
|
17312
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
17313
|
+
* axis: {
|
|
17314
|
+
* y: {
|
|
17315
|
+
* tick: {
|
|
17316
|
+
* inner: true
|
|
17317
|
+
* }
|
|
17318
|
+
* }
|
|
17319
|
+
* }
|
|
17320
|
+
*/
|
|
17321
|
+
axis_y_tick_inner: false,
|
|
16980
17322
|
/**
|
|
16981
17323
|
* Show y axis outer tick.
|
|
16982
17324
|
* @name axis․y․tick․outer
|
|
@@ -17471,6 +17813,23 @@ var y2 = {
|
|
|
17471
17813
|
* }
|
|
17472
17814
|
*/
|
|
17473
17815
|
axis_y2_tick_culling_reverse: false,
|
|
17816
|
+
/**
|
|
17817
|
+
* Set the axis tick line to be positioned inside of the chart.
|
|
17818
|
+
* @name axis․y2․tick․inner
|
|
17819
|
+
* @memberof Options
|
|
17820
|
+
* @type {boolean}
|
|
17821
|
+
* @default false
|
|
17822
|
+
* @see [Demo](https://naver.github.io/billboard.js/demo/#Axis.TickInner)
|
|
17823
|
+
* @example
|
|
17824
|
+
* axis: {
|
|
17825
|
+
* y2: {
|
|
17826
|
+
* tick: {
|
|
17827
|
+
* inner: true
|
|
17828
|
+
* }
|
|
17829
|
+
* }
|
|
17830
|
+
* }
|
|
17831
|
+
*/
|
|
17832
|
+
axis_y2_tick_inner: false,
|
|
17474
17833
|
/**
|
|
17475
17834
|
* Show or hide y2 axis outer tick.
|
|
17476
17835
|
* @name axis․y2․tick․outer
|
|
@@ -18386,41 +18745,46 @@ var shapeArc = {
|
|
|
18386
18745
|
})
|
|
18387
18746
|
.merge(rangeText));
|
|
18388
18747
|
if ((!state.rendered || (state.rendered && !fixed)) && totalSum_1 > 0) {
|
|
18389
|
-
rangeText.attr("transform", function (d, i) {
|
|
18748
|
+
rangeText.attr("transform", function (d, i) {
|
|
18749
|
+
return $$.transformForArcLabel(this, pieData_1[i], true);
|
|
18750
|
+
});
|
|
18390
18751
|
}
|
|
18391
18752
|
rangeText.style("opacity", function (d) { return (!fixed && (d > totalSum_1 || totalSum_1 === 0) ? "0" : null); });
|
|
18392
18753
|
}
|
|
18393
18754
|
},
|
|
18394
18755
|
/**
|
|
18395
18756
|
* Set transform attributes to arc label text
|
|
18757
|
+
* @param {SVGTextElement} textNode Text node element
|
|
18396
18758
|
* @param {object} d Data object
|
|
18397
18759
|
* @param {boolean} forRange Weather is for ranged text option(arc.rangeText.values)
|
|
18398
18760
|
* @returns {string} Translate attribute string
|
|
18399
18761
|
* @private
|
|
18400
18762
|
*/
|
|
18401
|
-
transformForArcLabel: function (d, forRange) {
|
|
18763
|
+
transformForArcLabel: function (textNode, d, forRange) {
|
|
18402
18764
|
var _a, _b, _c;
|
|
18403
18765
|
if (forRange === void 0) { forRange = false; }
|
|
18404
18766
|
var $$ = this;
|
|
18405
18767
|
var config = $$.config, radiusExpanded = $$.state.radiusExpanded;
|
|
18406
18768
|
var updated = $$.updateAngle(d, forRange);
|
|
18769
|
+
var pos = { x: 0, y: 0 };
|
|
18407
18770
|
var translate = "";
|
|
18771
|
+
var ratio = 1;
|
|
18408
18772
|
if (updated) {
|
|
18409
18773
|
if (forRange || $$.hasMultiArcGauge()) {
|
|
18410
18774
|
var y1 = Math.sin(updated.endAngle - Math.PI / 2);
|
|
18411
18775
|
var rangeTextPosition = config.arc_rangeText_position;
|
|
18412
|
-
|
|
18776
|
+
pos.x = Math.cos(updated.endAngle - Math.PI / 2) *
|
|
18413
18777
|
(radiusExpanded + (forRange ? 5 : 25));
|
|
18414
|
-
|
|
18778
|
+
pos.y = y1 * (radiusExpanded + 15 - Math.abs(y1 * 10)) + 3;
|
|
18415
18779
|
if (forRange && rangeTextPosition) {
|
|
18416
18780
|
var rangeValues = config.arc_rangeText_values;
|
|
18417
|
-
var
|
|
18781
|
+
var position = isFunction(rangeTextPosition) ?
|
|
18418
18782
|
rangeTextPosition(rangeValues[d.index]) :
|
|
18419
18783
|
rangeTextPosition;
|
|
18420
|
-
x += (_a =
|
|
18421
|
-
y += (_b =
|
|
18784
|
+
pos.x += (_a = position === null || position === void 0 ? void 0 : position.x) !== null && _a !== void 0 ? _a : 0;
|
|
18785
|
+
pos.y += (_b = position === null || position === void 0 ? void 0 : position.y) !== null && _b !== void 0 ? _b : 0;
|
|
18422
18786
|
}
|
|
18423
|
-
translate =
|
|
18787
|
+
// translate = `translate(${x},${y})`;
|
|
18424
18788
|
}
|
|
18425
18789
|
else if (!$$.hasType("gauge") || $$.data.targets.length > 1) {
|
|
18426
18790
|
var outerRadius = $$.getRadius(d).outerRadius;
|
|
@@ -18430,7 +18794,9 @@ var shapeArc = {
|
|
|
18430
18794
|
var c = this.svgArc.centroid(updated);
|
|
18431
18795
|
var _d = c.map(function (v) { return (isNaN(v) ? 0 : v); }), x = _d[0], y = _d[1];
|
|
18432
18796
|
var h = Math.sqrt(x * x + y * y);
|
|
18433
|
-
|
|
18797
|
+
pos.x = x;
|
|
18798
|
+
pos.y = y;
|
|
18799
|
+
ratio = (_c = ["donut", "gauge", "pie", "polar"]
|
|
18434
18800
|
.filter($$.hasType.bind($$))
|
|
18435
18801
|
.map(function (v) { return config["".concat(v, "_label_ratio")]; })) === null || _c === void 0 ? void 0 : _c[0];
|
|
18436
18802
|
if (ratio) {
|
|
@@ -18442,8 +18808,9 @@ var shapeArc = {
|
|
|
18442
18808
|
outerRadius / h :
|
|
18443
18809
|
0);
|
|
18444
18810
|
}
|
|
18445
|
-
translate = "translate(".concat(x * ratio, ",").concat(y * ratio, ")");
|
|
18446
18811
|
}
|
|
18812
|
+
updateTextImagePos.call($$, textNode, pos);
|
|
18813
|
+
translate = "translate(".concat(pos.x * ratio, ",").concat(pos.y * ratio, ")");
|
|
18447
18814
|
}
|
|
18448
18815
|
return translate;
|
|
18449
18816
|
},
|
|
@@ -18469,10 +18836,10 @@ var shapeArc = {
|
|
|
18469
18836
|
var node = select(this);
|
|
18470
18837
|
var updated = $$.updateAngle(d);
|
|
18471
18838
|
var ratio = $$.getRatio("arc", updated);
|
|
18472
|
-
var isUnderThreshold =
|
|
18839
|
+
var isUnderThreshold = meetsLabelThreshold.call($$, ratio, (_a = ["donut", "gauge", "pie", "polar"].filter($$.hasType.bind($$))) === null || _a === void 0 ? void 0 : _a[0]);
|
|
18473
18840
|
if (isUnderThreshold) {
|
|
18474
18841
|
var value = (updated || d).value;
|
|
18475
|
-
var text = ($$.
|
|
18842
|
+
var text = ($$.getArcLabelConfig("format") || $$.defaultArcValueFormat)(value, ratio, d.data.id).toString();
|
|
18476
18843
|
setTextValue(node, text, [-1, 1], hasGauge);
|
|
18477
18844
|
}
|
|
18478
18845
|
else {
|
|
@@ -18567,16 +18934,22 @@ var shapeArc = {
|
|
|
18567
18934
|
return ["donut", "gauge", "pie", "polar"]
|
|
18568
18935
|
.some(function (v) { return $$.hasType(v) && config["".concat(v, "_label_show")]; });
|
|
18569
18936
|
},
|
|
18570
|
-
|
|
18937
|
+
getArcLabelConfig: function (name) {
|
|
18938
|
+
if (name === void 0) { name = "format"; }
|
|
18571
18939
|
var $$ = this;
|
|
18572
18940
|
var config = $$.config;
|
|
18573
|
-
var
|
|
18941
|
+
var fn = function (v) { return v; };
|
|
18574
18942
|
["donut", "gauge", "pie", "polar"]
|
|
18575
18943
|
.filter($$.hasType.bind($$))
|
|
18576
18944
|
.forEach(function (v) {
|
|
18577
|
-
|
|
18945
|
+
fn = config["".concat(v, "_label_").concat(name)];
|
|
18578
18946
|
});
|
|
18579
|
-
|
|
18947
|
+
if (name === "format") {
|
|
18948
|
+
return isFunction(fn) ? fn.bind($$.api) : fn;
|
|
18949
|
+
}
|
|
18950
|
+
else {
|
|
18951
|
+
return fn;
|
|
18952
|
+
}
|
|
18580
18953
|
},
|
|
18581
18954
|
updateTargetsForArc: function (targets) {
|
|
18582
18955
|
var $$ = this;
|
|
@@ -19000,10 +19373,14 @@ var shapeArc = {
|
|
|
19000
19373
|
.style("opacity", "0")
|
|
19001
19374
|
.attr("class", function (d) { return ($$.isGaugeType(d.data) ? $GAUGE.gaugeValue : null); })
|
|
19002
19375
|
.call($$.textForArcLabel.bind($$))
|
|
19003
|
-
.attr("transform", function (d) { return $$.transformForArcLabel.bind($$)(d); })
|
|
19004
19376
|
.style("font-size", function (d) { return ($$.isGaugeType(d.data) && $$.data.targets.length === 1 && !hasMultiArcGauge ?
|
|
19005
19377
|
"".concat(Math.round(state.radius / 5), "px") :
|
|
19006
|
-
null); })
|
|
19378
|
+
null); });
|
|
19379
|
+
updateTextImage.call($$);
|
|
19380
|
+
text
|
|
19381
|
+
.attr("transform", function (d) {
|
|
19382
|
+
return $$.transformForArcLabel.bind($$)(this, d);
|
|
19383
|
+
})
|
|
19007
19384
|
.transition()
|
|
19008
19385
|
.duration(duration)
|
|
19009
19386
|
.style("opacity", function (d) { return ($$.isTargetToShow(d.data.id) && $$.isArcType(d.data) ? null : "0"); });
|
|
@@ -21814,7 +22191,7 @@ var shapeTreemap = {
|
|
|
21814
22191
|
var format = config.treemap_label_format;
|
|
21815
22192
|
var ratio = $$.getRatio("treemap", d);
|
|
21816
22193
|
var percentValue = (ratio * 100).toFixed(2);
|
|
21817
|
-
var meetLabelThreshold = config.treemap_label_show &&
|
|
22194
|
+
var meetLabelThreshold = config.treemap_label_show && meetsLabelThreshold.call($$, ratio, "treemap") ?
|
|
21818
22195
|
null :
|
|
21819
22196
|
"0";
|
|
21820
22197
|
return function (node) {
|
|
@@ -22610,6 +22987,18 @@ var optDonut = {
|
|
|
22610
22987
|
* @property {Function} [donut.label.format] Set formatter for the label on each donut piece.
|
|
22611
22988
|
* @property {number} [donut.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
22612
22989
|
* @property {number|Function} [donut.label.ratio=undefined] Set ratio of labels position.
|
|
22990
|
+
* @property {object|Function} [donut.label.image] Set image to be displayed next to the label text.<br><br>
|
|
22991
|
+
* 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>
|
|
22992
|
+
* The arguments are:<br>
|
|
22993
|
+
* - `v` is the value of the data point where the label is shown.
|
|
22994
|
+
* - `id` is the id of the data where the label is shown.
|
|
22995
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
22996
|
+
* @property {string} donut.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
22997
|
+
* @property {number} donut.label.image.width Image width in pixels.
|
|
22998
|
+
* @property {number} donut.label.image.height Image height in pixels.
|
|
22999
|
+
* @property {object} [donut.label.image.pos] Image position relative to the label text.
|
|
23000
|
+
* @property {number} [donut.label.image.pos.x=0] x coordinate position, relative the original.
|
|
23001
|
+
* @property {number} [donut.label.image.pos.y=0] y coordinate position, relative the original.
|
|
22613
23002
|
* @property {boolean} [donut.expand=true] Enable or disable expanding donut pieces.
|
|
22614
23003
|
* @property {number} [donut.expand.rate=0.98] Set expand rate.
|
|
22615
23004
|
* @property {number} [donut.expand.duration=50] Set expand transition time in ms.
|
|
@@ -22619,6 +23008,16 @@ var optDonut = {
|
|
|
22619
23008
|
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
22620
23009
|
* @property {number} [donut.padAngle=0] Set padding between data.
|
|
22621
23010
|
* @property {number} [donut.startingAngle=0] Set starting angle where data draws.
|
|
23011
|
+
* @see [Demo: Corner Radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
23012
|
+
* @see [Demo: Needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
|
|
23013
|
+
* @see [Demo: Range Text](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutRangeText)
|
|
23014
|
+
* @see [Demo: Label Image](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelImage)
|
|
23015
|
+
* @see [Demo: Label Ratio](https://naver.github.io/billboard.js/demo/#DonutChartOptions.LabelRatio)
|
|
23016
|
+
* @see [Demo: Multiline Label](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineLabel)
|
|
23017
|
+
* @see [Demo: Multiline Title](https://naver.github.io/billboard.js/demo/#DonutChartOptions.MultilineTitle)
|
|
23018
|
+
* @see [Demo: Pad Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.padAngle)
|
|
23019
|
+
* @see [Demo: Starting Angle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.StartingAngle)
|
|
23020
|
+
*
|
|
22622
23021
|
* @example
|
|
22623
23022
|
* donut: {
|
|
22624
23023
|
* label: {
|
|
@@ -22640,7 +23039,51 @@ var optDonut = {
|
|
|
22640
23039
|
* return ratio;
|
|
22641
23040
|
* },
|
|
22642
23041
|
* // or set ratio number
|
|
22643
|
-
* ratio: 0.5
|
|
23042
|
+
* ratio: 0.5,
|
|
23043
|
+
*
|
|
23044
|
+
* // set image to be displayed next to the label text
|
|
23045
|
+
* image: {
|
|
23046
|
+
* url: "./sample.svg",
|
|
23047
|
+
*
|
|
23048
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
23049
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
23050
|
+
* width: 35,
|
|
23051
|
+
* height: 35,
|
|
23052
|
+
* pos: {
|
|
23053
|
+
* x: 0,
|
|
23054
|
+
* y: 0
|
|
23055
|
+
* }
|
|
23056
|
+
* },
|
|
23057
|
+
*
|
|
23058
|
+
* // or use function to return image configuration dynamically
|
|
23059
|
+
* image: function(v, id, i) {
|
|
23060
|
+
* // Return different images based on value
|
|
23061
|
+
* if (v > 500) {
|
|
23062
|
+
* return {
|
|
23063
|
+
* url: "./high-value.svg",
|
|
23064
|
+
* width: 40,
|
|
23065
|
+
* height: 40,
|
|
23066
|
+
* pos: { x: 0, y: 0 }
|
|
23067
|
+
* };
|
|
23068
|
+
* } else if (v > 100) {
|
|
23069
|
+
* return {
|
|
23070
|
+
* url: "./medium-value.svg",
|
|
23071
|
+
* width: 30,
|
|
23072
|
+
* height: 30,
|
|
23073
|
+
* pos: { x: 0, y: 0 }
|
|
23074
|
+
* };
|
|
23075
|
+
* } else if(v < 5) {
|
|
23076
|
+
* // Return falsy value in case of don't want to show image
|
|
23077
|
+
* return null;
|
|
23078
|
+
* } else {
|
|
23079
|
+
* return {
|
|
23080
|
+
* url: "./low-value.svg",
|
|
23081
|
+
* width: 20,
|
|
23082
|
+
* height: 20,
|
|
23083
|
+
* pos: { x: 0, y: 0 }
|
|
23084
|
+
* };
|
|
23085
|
+
* }
|
|
23086
|
+
* }
|
|
22644
23087
|
* },
|
|
22645
23088
|
*
|
|
22646
23089
|
* // disable expand transition for interaction
|
|
@@ -22669,6 +23112,7 @@ var optDonut = {
|
|
|
22669
23112
|
donut_label_show: true,
|
|
22670
23113
|
donut_label_format: undefined,
|
|
22671
23114
|
donut_label_threshold: 0.05,
|
|
23115
|
+
donut_label_image: undefined,
|
|
22672
23116
|
donut_label_ratio: undefined,
|
|
22673
23117
|
donut_width: undefined,
|
|
22674
23118
|
donut_title: "",
|
|
@@ -22743,6 +23187,18 @@ var optGauge = {
|
|
|
22743
23187
|
* - id {string}: data's id value
|
|
22744
23188
|
* @property {number|Function} [gauge.label.ratio=undefined] Set ratio of labels position.
|
|
22745
23189
|
* @property {number} [gauge.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
23190
|
+
* @property {object|Function} [gauge.label.image] Set image to be displayed next to the label text.<br><br>
|
|
23191
|
+
* 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>
|
|
23192
|
+
* The arguments are:<br>
|
|
23193
|
+
* - `v` is the value of the data point where the label is shown.
|
|
23194
|
+
* - `id` is the id of the data where the label is shown.
|
|
23195
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
23196
|
+
* @property {string} gauge.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
23197
|
+
* @property {number} gauge.label.image.width Image width in pixels.
|
|
23198
|
+
* @property {number} gauge.label.image.height Image height in pixels.
|
|
23199
|
+
* @property {object} [gauge.label.image.pos] Image position relative to the label text.
|
|
23200
|
+
* @property {number} [gauge.label.image.pos.x=0] x coordinate position, relative the original.
|
|
23201
|
+
* @property {number} [gauge.label.image.pos.y=0] y coordinate position, relative the original.
|
|
22746
23202
|
* @property {boolean} [gauge.expand=true] Enable or disable expanding gauge.
|
|
22747
23203
|
* @property {number} [gauge.expand.rate=0.98] Set expand rate.
|
|
22748
23204
|
* @property {number} [gauge.expand.duration=50] Set the expand transition time in milliseconds.
|
|
@@ -22783,7 +23239,8 @@ var optGauge = {
|
|
|
22783
23239
|
* @see [Demo: enforceMinMax, min/max](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeMinMax)
|
|
22784
23240
|
* @see [Demo: archLength](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeArcLength)
|
|
22785
23241
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeStartingAngle)
|
|
22786
|
-
* @see [Demo:
|
|
23242
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelImage)
|
|
23243
|
+
* @see [Demo: label ratio](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeLabelRatio)
|
|
22787
23244
|
* @example
|
|
22788
23245
|
* gauge: {
|
|
22789
23246
|
* background: "#eee", // will set 'fill' css prop for '.bb-chart-arcs-background' classed element.
|
|
@@ -22811,7 +23268,51 @@ var optGauge = {
|
|
|
22811
23268
|
* return ratio;
|
|
22812
23269
|
* },
|
|
22813
23270
|
* // or set ratio number
|
|
22814
|
-
* ratio: 0.5
|
|
23271
|
+
* ratio: 0.5,
|
|
23272
|
+
*
|
|
23273
|
+
* // set image to be displayed next to the label text
|
|
23274
|
+
* image: {
|
|
23275
|
+
* url: "./sample.svg",
|
|
23276
|
+
*
|
|
23277
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
23278
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
23279
|
+
* width: 35,
|
|
23280
|
+
* height: 35,
|
|
23281
|
+
* pos: {
|
|
23282
|
+
* x: 0,
|
|
23283
|
+
* y: 0
|
|
23284
|
+
* }
|
|
23285
|
+
* },
|
|
23286
|
+
*
|
|
23287
|
+
* // or use function to return image configuration dynamically
|
|
23288
|
+
* image: function(v, id, i) {
|
|
23289
|
+
* // Return different images based on value
|
|
23290
|
+
* if (v > 500) {
|
|
23291
|
+
* return {
|
|
23292
|
+
* url: "./high-value.svg",
|
|
23293
|
+
* width: 40,
|
|
23294
|
+
* height: 40,
|
|
23295
|
+
* pos: { x: 0, y: 0 }
|
|
23296
|
+
* };
|
|
23297
|
+
* } else if (v > 100) {
|
|
23298
|
+
* return {
|
|
23299
|
+
* url: "./medium-value.svg",
|
|
23300
|
+
* width: 30,
|
|
23301
|
+
* height: 30,
|
|
23302
|
+
* pos: { x: 0, y: 0 }
|
|
23303
|
+
* };
|
|
23304
|
+
* } else if(v < 5) {
|
|
23305
|
+
* // Return falsy value in case of don't want to show image
|
|
23306
|
+
* return null;
|
|
23307
|
+
* } else {
|
|
23308
|
+
* return {
|
|
23309
|
+
* url: "./low-value.svg",
|
|
23310
|
+
* width: 20,
|
|
23311
|
+
* height: 20,
|
|
23312
|
+
* pos: { x: 0, y: 0 }
|
|
23313
|
+
* };
|
|
23314
|
+
* }
|
|
23315
|
+
* }
|
|
22815
23316
|
* },
|
|
22816
23317
|
*
|
|
22817
23318
|
* // disable expand transition for interaction
|
|
@@ -22854,6 +23355,7 @@ var optGauge = {
|
|
|
22854
23355
|
gauge_label_format: undefined,
|
|
22855
23356
|
gauge_label_ratio: undefined,
|
|
22856
23357
|
gauge_label_threshold: 0,
|
|
23358
|
+
gauge_label_image: undefined,
|
|
22857
23359
|
gauge_enforceMinMax: false,
|
|
22858
23360
|
gauge_min: 0,
|
|
22859
23361
|
gauge_max: 100,
|
|
@@ -22887,6 +23389,18 @@ var optPie = {
|
|
|
22887
23389
|
* @property {Function} [pie.label.format] Set formatter for the label on each pie piece.
|
|
22888
23390
|
* @property {number|Function} [pie.label.ratio=undefined] Set ratio of labels position.
|
|
22889
23391
|
* @property {number} [pie.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
23392
|
+
* @property {object|Function} [pie.label.image] Set image to be displayed next to the label text.<br><br>
|
|
23393
|
+
* 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>
|
|
23394
|
+
* The arguments are:<br>
|
|
23395
|
+
* - `v` is the value of the data point where the label is shown.
|
|
23396
|
+
* - `id` is the id of the data where the label is shown.
|
|
23397
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
23398
|
+
* @property {string} pie.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
23399
|
+
* @property {number} pie.label.image.width Image width in pixels.
|
|
23400
|
+
* @property {number} pie.label.image.height Image height in pixels.
|
|
23401
|
+
* @property {object} [pie.label.image.pos] Image position relative to the label text.
|
|
23402
|
+
* @property {number} [pie.label.image.pos.x=0] x coordinate position, relative the original.
|
|
23403
|
+
* @property {number} [pie.label.image.pos.y=0] y coordinate position, relative the original.
|
|
22890
23404
|
* @property {boolean|object} [pie.expand=true] Enable or disable expanding pie pieces.
|
|
22891
23405
|
* @property {number} [pie.expand.rate=0.98] Set expand rate.
|
|
22892
23406
|
* @property {number} [pie.expand.duration=50] Set expand transition time in ms.
|
|
@@ -22899,6 +23413,7 @@ var optPie = {
|
|
|
22899
23413
|
* @see [Demo: innerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.InnerRadius)
|
|
22900
23414
|
* @see [Demo: outerRadius](https://naver.github.io/billboard.js/demo/#PieChartOptions.OuterRadius)
|
|
22901
23415
|
* @see [Demo: startingAngle](https://naver.github.io/billboard.js/demo/#PieChartOptions.StartingAngle)
|
|
23416
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PieChartOptions.LabelImage)
|
|
22902
23417
|
* @example
|
|
22903
23418
|
* pie: {
|
|
22904
23419
|
* label: {
|
|
@@ -22920,7 +23435,51 @@ var optPie = {
|
|
|
22920
23435
|
* return ratio;
|
|
22921
23436
|
* },
|
|
22922
23437
|
* // or set ratio number
|
|
22923
|
-
* ratio: 0.5
|
|
23438
|
+
* ratio: 0.5,
|
|
23439
|
+
*
|
|
23440
|
+
* // set image to be displayed next to the label text
|
|
23441
|
+
* image: {
|
|
23442
|
+
* url: "./sample.svg",
|
|
23443
|
+
*
|
|
23444
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
23445
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
23446
|
+
* width: 35,
|
|
23447
|
+
* height: 35,
|
|
23448
|
+
* pos: {
|
|
23449
|
+
* x: 0,
|
|
23450
|
+
* y: 0
|
|
23451
|
+
* }
|
|
23452
|
+
* },
|
|
23453
|
+
*
|
|
23454
|
+
* // or use function to return image configuration dynamically
|
|
23455
|
+
* image: function(v, id, i) {
|
|
23456
|
+
* // Return different images based on value
|
|
23457
|
+
* if (v > 500) {
|
|
23458
|
+
* return {
|
|
23459
|
+
* url: "./high-value.svg",
|
|
23460
|
+
* width: 40,
|
|
23461
|
+
* height: 40,
|
|
23462
|
+
* pos: { x: 0, y: 0 }
|
|
23463
|
+
* };
|
|
23464
|
+
* } else if (v > 100) {
|
|
23465
|
+
* return {
|
|
23466
|
+
* url: "./medium-value.svg",
|
|
23467
|
+
* width: 30,
|
|
23468
|
+
* height: 30,
|
|
23469
|
+
* pos: { x: 0, y: 0 }
|
|
23470
|
+
* };
|
|
23471
|
+
* } else if(v < 5) {
|
|
23472
|
+
* // Return falsy value in case of don't want to show image
|
|
23473
|
+
* return null;
|
|
23474
|
+
* } else {
|
|
23475
|
+
* return {
|
|
23476
|
+
* url: "./low-value.svg",
|
|
23477
|
+
* width: 20,
|
|
23478
|
+
* height: 20,
|
|
23479
|
+
* pos: { x: 0, y: 0 }
|
|
23480
|
+
* };
|
|
23481
|
+
* }
|
|
23482
|
+
* }
|
|
22924
23483
|
* },
|
|
22925
23484
|
*
|
|
22926
23485
|
* // disable expand transition for interaction
|
|
@@ -22959,6 +23518,7 @@ var optPie = {
|
|
|
22959
23518
|
pie_label_format: undefined,
|
|
22960
23519
|
pie_label_ratio: undefined,
|
|
22961
23520
|
pie_label_threshold: 0.05,
|
|
23521
|
+
pie_label_image: undefined,
|
|
22962
23522
|
pie_expand: {},
|
|
22963
23523
|
pie_expand_rate: 0.98,
|
|
22964
23524
|
pie_expand_duration: 50,
|
|
@@ -22987,6 +23547,18 @@ var optPolar = {
|
|
|
22987
23547
|
* @property {Function} [polar.label.format] Set formatter for the label on each polar piece.
|
|
22988
23548
|
* @property {number} [polar.label.threshold=0.05] Set threshold ratio to show/hide labels.
|
|
22989
23549
|
* @property {number|Function} [polar.label.ratio=undefined] Set ratio of labels position.
|
|
23550
|
+
* @property {object|Function} [polar.label.image] Set image to be displayed next to the label text.<br><br>
|
|
23551
|
+
* 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>
|
|
23552
|
+
* The arguments are:<br>
|
|
23553
|
+
* - `v` is the value of the data point where the label is shown.
|
|
23554
|
+
* - `id` is the id of the data where the label is shown.
|
|
23555
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
23556
|
+
* @property {string} polar.label.image.url Image URL path. Can use placeholder `{=ID}` which will be replaced with the data ID.
|
|
23557
|
+
* @property {number} polar.label.image.width Image width in pixels.
|
|
23558
|
+
* @property {number} polar.label.image.height Image height in pixels.
|
|
23559
|
+
* @property {object} [polar.label.image.pos] Image position relative to the label text.
|
|
23560
|
+
* @property {number} [polar.label.image.pos.x=0] x coordinate position, relative the original.
|
|
23561
|
+
* @property {number} [polar.label.image.pos.y=0] y coordinate position, relative the original.
|
|
22990
23562
|
* @property {number} [polar.level.depth=3] Set the level depth.
|
|
22991
23563
|
* @property {boolean} [polar.level.show=true] Show or hide level.
|
|
22992
23564
|
* @property {string} [polar.level.text.backgroundColor="#fff"] Set label text's background color.
|
|
@@ -22996,6 +23568,7 @@ var optPolar = {
|
|
|
22996
23568
|
* @property {number} [polar.padding=0] Sets the gap between pie arcs.
|
|
22997
23569
|
* @property {number} [polar.startingAngle=0] Set starting angle where data draws.
|
|
22998
23570
|
* @see [Demo](https://naver.github.io/billboard.js/demo/#Chart.PolarChart)
|
|
23571
|
+
* @see [Demo: label image](https://naver.github.io/billboard.js/demo/#PolarChartOptions.LabelImage)
|
|
22999
23572
|
* @example
|
|
23000
23573
|
* polar: {
|
|
23001
23574
|
* label: {
|
|
@@ -23017,7 +23590,51 @@ var optPolar = {
|
|
|
23017
23590
|
* return ratio;
|
|
23018
23591
|
* },
|
|
23019
23592
|
* // or set ratio number
|
|
23020
|
-
* ratio: 0.5
|
|
23593
|
+
* ratio: 0.5,
|
|
23594
|
+
*
|
|
23595
|
+
* // set image to be displayed next to the label text
|
|
23596
|
+
* image: {
|
|
23597
|
+
* url: "./sample.svg",
|
|
23598
|
+
*
|
|
23599
|
+
* // use placeholder to dynamically set image URL based on data ID
|
|
23600
|
+
* url: "./images/{=ID}.svg", // will be replaced to "./images/data1.svg", "./images/data2.svg", etc.
|
|
23601
|
+
* width: 35,
|
|
23602
|
+
* height: 35,
|
|
23603
|
+
* pos: {
|
|
23604
|
+
* x: 0,
|
|
23605
|
+
* y: 0
|
|
23606
|
+
* }
|
|
23607
|
+
* },
|
|
23608
|
+
*
|
|
23609
|
+
* // or use function to return image configuration dynamically
|
|
23610
|
+
* image: function(v, id, i) {
|
|
23611
|
+
* // Return different images based on value
|
|
23612
|
+
* if (v > 500) {
|
|
23613
|
+
* return {
|
|
23614
|
+
* url: "./high-value.svg",
|
|
23615
|
+
* width: 40,
|
|
23616
|
+
* height: 40,
|
|
23617
|
+
* pos: { x: 0, y: 0 }
|
|
23618
|
+
* };
|
|
23619
|
+
* } else if (v > 100) {
|
|
23620
|
+
* return {
|
|
23621
|
+
* url: "./medium-value.svg",
|
|
23622
|
+
* width: 30,
|
|
23623
|
+
* height: 30,
|
|
23624
|
+
* pos: { x: 0, y: 0 }
|
|
23625
|
+
* };
|
|
23626
|
+
* } else if(v < 5) {
|
|
23627
|
+
* // Return falsy value in case of don't want to show image
|
|
23628
|
+
* return null;
|
|
23629
|
+
* } else {
|
|
23630
|
+
* return {
|
|
23631
|
+
* url: "./low-value.svg",
|
|
23632
|
+
* width: 20,
|
|
23633
|
+
* height: 20,
|
|
23634
|
+
* pos: { x: 0, y: 0 }
|
|
23635
|
+
* };
|
|
23636
|
+
* }
|
|
23637
|
+
* }
|
|
23021
23638
|
* },
|
|
23022
23639
|
* level: {
|
|
23023
23640
|
* depth: 3,
|
|
@@ -23039,6 +23656,7 @@ var optPolar = {
|
|
|
23039
23656
|
polar_label_show: true,
|
|
23040
23657
|
polar_label_format: undefined,
|
|
23041
23658
|
polar_label_threshold: 0.05,
|
|
23659
|
+
polar_label_image: undefined,
|
|
23042
23660
|
polar_label_ratio: undefined,
|
|
23043
23661
|
polar_level_depth: 3,
|
|
23044
23662
|
polar_level_max: undefined,
|
|
@@ -24971,7 +25589,7 @@ var zoomModule = function () {
|
|
|
24971
25589
|
var defaults = Object.create(null);
|
|
24972
25590
|
/**
|
|
24973
25591
|
* @namespace bb
|
|
24974
|
-
* @version 3.
|
|
25592
|
+
* @version 3.17.0
|
|
24975
25593
|
*/
|
|
24976
25594
|
var bb = {
|
|
24977
25595
|
/**
|
|
@@ -24981,7 +25599,7 @@ var bb = {
|
|
|
24981
25599
|
* bb.version; // "1.0.0"
|
|
24982
25600
|
* @memberof bb
|
|
24983
25601
|
*/
|
|
24984
|
-
version: "3.
|
|
25602
|
+
version: "3.17.0",
|
|
24985
25603
|
/**
|
|
24986
25604
|
* Generate chart
|
|
24987
25605
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|