billboard.js 3.8.2 → 3.9.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +7 -7
- package/dist/billboard.js +386 -71
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +868 -361
- package/dist/billboard.pkgd.min.js +2 -2
- 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 +4 -3
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-stanford.js +4 -3
- package/dist/plugin/billboardjs-plugin-stanford.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-tableview.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.js +484 -292
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.js +487 -294
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.js +488 -295
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.js +489 -297
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.js +501 -320
- package/dist/theme/dark.css +298 -0
- package/dist/theme/dark.min.css +9 -0
- package/dist/theme/datalab.css +9 -2
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +7 -5
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +7 -5
- package/dist/theme/insight.min.css +2 -2
- package/dist-esm/billboard.js +367 -59
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +4 -3
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +4 -3
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +35 -34
- package/src/Chart/Chart.ts +30 -1
- package/src/ChartInternal/ChartInternal.ts +12 -4
- package/src/ChartInternal/data/IData.ts +5 -0
- package/src/ChartInternal/data/data.ts +23 -9
- package/src/ChartInternal/internals/size.ts +5 -1
- package/src/ChartInternal/internals/text.ts +20 -15
- package/src/ChartInternal/internals/tooltip.ts +4 -3
- package/src/ChartInternal/shape/arc.ts +161 -18
- package/src/ChartInternal/shape/bar.ts +7 -3
- package/src/ChartInternal/shape/bubble.ts +0 -1
- package/src/ChartInternal/shape/point.ts +2 -0
- package/src/config/Options/common/legend.ts +1 -1
- package/src/config/Options/common/point.ts +30 -2
- package/src/config/Options/data/data.ts +22 -6
- package/src/config/Options/shape/arc.ts +73 -1
- package/src/config/Options/shape/bar.ts +7 -1
- package/src/config/Options/shape/donut.ts +5 -0
- package/src/config/Options/shape/gauge.ts +6 -0
- package/src/config/Store/State.ts +2 -1
- package/src/config/classes.ts +2 -1
- package/src/scss/billboard.scss +8 -5
- package/src/scss/theme/dark.scss +423 -0
- package/src/scss/theme/datalab.scss +11 -0
- package/src/scss/theme/graph.scss +9 -4
- package/src/scss/theme/insight.scss +9 -4
- package/types/options.d.ts +36 -14
- package/types/options.shape.d.ts +81 -4
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.9.0-next.2
|
|
9
9
|
*/
|
|
10
10
|
import { timeParse, utcParse, timeFormat, utcFormat } from 'd3-time-format';
|
|
11
11
|
import { pointer, select, namespaces, selectAll } from 'd3-selection';
|
|
@@ -915,7 +915,8 @@ var $ARC = {
|
|
|
915
915
|
chartArc: "bb-chart-arc",
|
|
916
916
|
chartArcs: "bb-chart-arcs",
|
|
917
917
|
chartArcsBackground: "bb-chart-arcs-background",
|
|
918
|
-
chartArcsTitle: "bb-chart-arcs-title"
|
|
918
|
+
chartArcsTitle: "bb-chart-arcs-title",
|
|
919
|
+
needle: "bb-needle"
|
|
919
920
|
};
|
|
920
921
|
var $AREA = {
|
|
921
922
|
area: "bb-area",
|
|
@@ -1167,6 +1168,7 @@ var State = /** @class */ (function () {
|
|
|
1167
1168
|
},
|
|
1168
1169
|
// current used chart type list
|
|
1169
1170
|
types: [],
|
|
1171
|
+
needle: undefined, // arc needle current value
|
|
1170
1172
|
},
|
|
1171
1173
|
// legend
|
|
1172
1174
|
isLegendRight: false,
|
|
@@ -1211,7 +1213,7 @@ var State = /** @class */ (function () {
|
|
|
1211
1213
|
pathXAxisTickTexts: "",
|
|
1212
1214
|
pathGrid: ""
|
|
1213
1215
|
},
|
|
1214
|
-
//
|
|
1216
|
+
// state
|
|
1215
1217
|
event: null,
|
|
1216
1218
|
dragStart: null,
|
|
1217
1219
|
dragging: false,
|
|
@@ -2009,7 +2011,7 @@ var data$2 = {
|
|
|
2009
2011
|
* @property {boolean} [data.labels=false] Show or hide labels on each data points
|
|
2010
2012
|
* @property {boolean} [data.labels.centered=false] Centerize labels on `bar` shape. (**NOTE:** works only for 'bar' type)
|
|
2011
2013
|
* @property {Function} [data.labels.format] Set formatter function for data labels.<br>
|
|
2012
|
-
* The formatter function receives 4 arguments such as v, id, i,
|
|
2014
|
+
* The formatter function receives 4 arguments such as `v, id, i, texts` and it **must return a string** (`\n` character will be used as line break) that will be shown as the label.<br><br>
|
|
2013
2015
|
* The arguments are:<br>
|
|
2014
2016
|
* - `v` is the value of the data point where the label is shown.
|
|
2015
2017
|
* - `id` is the id of the data where the label is shown.
|
|
@@ -2018,7 +2020,14 @@ var data$2 = {
|
|
|
2018
2020
|
* Formatter function can be defined for each data by specifying as an object and D3 formatter function can be set (ex. d3.format('$'))
|
|
2019
2021
|
* @property {string|object} [data.labels.backgroundColors] Set label text background colors.
|
|
2020
2022
|
* @property {string|object|Function} [data.labels.colors] Set label text colors.
|
|
2021
|
-
* @property {object} [data.labels.position] Set each dataset position, relative the original
|
|
2023
|
+
* @property {object|Function} [data.labels.position] Set each dataset position, relative the original.<br><br>
|
|
2024
|
+
* When function is specified, will receives 5 arguments such as `type, v, id, i, texts` and it must return a position number.<br><br>
|
|
2025
|
+
* The arguments are:<br>
|
|
2026
|
+
* - `type` coordinate type string, which will be 'x' or 'y'.
|
|
2027
|
+
* - `v` is the value of the data point where the label is shown.
|
|
2028
|
+
* - `id` is the id of the data where the label is shown.
|
|
2029
|
+
* - `i` is the index of the data series point where the label is shown.
|
|
2030
|
+
* - `texts` is the array of whole corresponding data series' text labels.<br><br>
|
|
2022
2031
|
* @property {number} [data.labels.position.x=0] x coordinate position, relative the original.
|
|
2023
2032
|
* @property {number} [data.labels.position.y=0] y coordinate position, relative the original.
|
|
2024
2033
|
* @property {object} [data.labels.rotate] Rotate label text. Specify degree value in a range of `0 ~ 360`.
|
|
@@ -2039,7 +2048,7 @@ var data$2 = {
|
|
|
2039
2048
|
*
|
|
2040
2049
|
* // or set specific options
|
|
2041
2050
|
* labels: {
|
|
2042
|
-
* format: function(v, id, i,
|
|
2051
|
+
* format: function(v, id, i, texts) {
|
|
2043
2052
|
* ...
|
|
2044
2053
|
* // to multiline, return with '\n' character
|
|
2045
2054
|
* return "Line1\nLine2";
|
|
@@ -2081,6 +2090,13 @@ var data$2 = {
|
|
|
2081
2090
|
* return d.value > 200 ? "cyan" : color;
|
|
2082
2091
|
* },
|
|
2083
2092
|
*
|
|
2093
|
+
* // return x, y coordinate position
|
|
2094
|
+
* // apt to handle each text position manually
|
|
2095
|
+
* position: function(type, v, id, i, texts) {
|
|
2096
|
+
* ...
|
|
2097
|
+
* return type == "x" ? 10 : 20;
|
|
2098
|
+
* },
|
|
2099
|
+
*
|
|
2084
2100
|
* // set x, y coordinate position
|
|
2085
2101
|
* position: {
|
|
2086
2102
|
* x: -10,
|
|
@@ -2706,7 +2722,7 @@ var legend$2 = {
|
|
|
2706
2722
|
* - **step**:
|
|
2707
2723
|
* - defines the max step the legend has (e.g. If 2 set and legend has 3 legend item, the legend 2 columns).
|
|
2708
2724
|
* @property {boolean} [legend.equally=false] Set to all items have same width size.
|
|
2709
|
-
* @property {
|
|
2725
|
+
* @property {number} [legend.padding=0] Set padding value
|
|
2710
2726
|
* @property {Function} [legend.item.onclick=undefined] Set click event handler to the legend item.
|
|
2711
2727
|
* @property {Function} [legend.item.onover=undefined] Set mouse/touch over event handler to the legend item.
|
|
2712
2728
|
* @property {Function} [legend.item.onout=undefined] Set mouse/touch out event handler to the legend item.
|
|
@@ -4302,7 +4318,17 @@ var data$1 = {
|
|
|
4302
4318
|
var $$ = this;
|
|
4303
4319
|
var config = $$.config, main = $$.$el.main;
|
|
4304
4320
|
var data = values.filter(function (v) { return v && isValue(v.value); });
|
|
4305
|
-
var
|
|
4321
|
+
var getSensitivity = function (d) {
|
|
4322
|
+
var sensitivity = config.point_sensitivity;
|
|
4323
|
+
if (isFunction(sensitivity)) {
|
|
4324
|
+
sensitivity = sensitivity.call($$.api, d);
|
|
4325
|
+
}
|
|
4326
|
+
else if (sensitivity === "radius") {
|
|
4327
|
+
sensitivity = d.r;
|
|
4328
|
+
}
|
|
4329
|
+
return sensitivity;
|
|
4330
|
+
};
|
|
4331
|
+
var minDist;
|
|
4306
4332
|
var closest;
|
|
4307
4333
|
// find mouseovering bar/candlestick
|
|
4308
4334
|
// https://github.com/naver/billboard.js/issues/2434
|
|
@@ -4321,6 +4347,7 @@ var data$1 = {
|
|
|
4321
4347
|
.filter(function (v) { return !$$.isBarType(v.id) && !$$.isCandlestickType(v.id); })
|
|
4322
4348
|
.forEach(function (v) {
|
|
4323
4349
|
var d = $$.dist(v, pos);
|
|
4350
|
+
minDist = getSensitivity(v);
|
|
4324
4351
|
if (d < minDist) {
|
|
4325
4352
|
minDist = d;
|
|
4326
4353
|
closest = v;
|
|
@@ -4331,8 +4358,8 @@ var data$1 = {
|
|
|
4331
4358
|
dist: function (data, pos) {
|
|
4332
4359
|
var $$ = this;
|
|
4333
4360
|
var isRotated = $$.config.axis_rotated, scale = $$.scale;
|
|
4334
|
-
var xIndex = isRotated
|
|
4335
|
-
var yIndex = isRotated
|
|
4361
|
+
var xIndex = +isRotated; // true: 1, false: 0
|
|
4362
|
+
var yIndex = +!isRotated; // true: 0, false: 1
|
|
4336
4363
|
var y = $$.circleY(data, data.index);
|
|
4337
4364
|
var x = (scale.zoom || scale.x)(data.x);
|
|
4338
4365
|
return Math.sqrt(Math.pow(x - pos[xIndex], 2) + Math.pow(y - pos[yIndex], 2));
|
|
@@ -4459,7 +4486,8 @@ var data$1 = {
|
|
|
4459
4486
|
// otherwise, based on the rendered angle value
|
|
4460
4487
|
}
|
|
4461
4488
|
else {
|
|
4462
|
-
var gaugeArcLength = config.gauge_fullCircle ?
|
|
4489
|
+
var gaugeArcLength = config.gauge_fullCircle ?
|
|
4490
|
+
$$.getArcLength() : $$.getGaugeStartAngle() * -2;
|
|
4463
4491
|
var arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
|
|
4464
4492
|
ratio = (d.endAngle - d.startAngle) / arcLength;
|
|
4465
4493
|
}
|
|
@@ -7462,6 +7490,9 @@ var size = {
|
|
|
7462
7490
|
xAxisHeight : 30;
|
|
7463
7491
|
var subchartHeight = config.subchart_show && !isNonAxis ?
|
|
7464
7492
|
(config.subchart_size_height + subchartXAxisHeight) : 0;
|
|
7493
|
+
// when needle is shown with legend, it need some bottom space to not overlap with legend text
|
|
7494
|
+
var gaugeHeight = $$.hasType("gauge") && config.arc_needle_show &&
|
|
7495
|
+
!config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0;
|
|
7465
7496
|
var padding = $$.getCurrentPadding();
|
|
7466
7497
|
// for main
|
|
7467
7498
|
state.margin = !isNonAxis && isRotated ? {
|
|
@@ -7472,7 +7503,7 @@ var size = {
|
|
|
7472
7503
|
} : {
|
|
7473
7504
|
top: (isFitPadding ? 0 : 4) + padding.top,
|
|
7474
7505
|
right: isNonAxis ? 0 : $$.getCurrentPaddingRight(true),
|
|
7475
|
-
bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
|
|
7506
|
+
bottom: gaugeHeight + xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
|
|
7476
7507
|
left: isNonAxis ? 0 : padding.left
|
|
7477
7508
|
};
|
|
7478
7509
|
state.margin = $$.getResettedPadding(state.margin);
|
|
@@ -7642,6 +7673,21 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
|
|
|
7642
7673
|
}
|
|
7643
7674
|
return { x: x, y: y };
|
|
7644
7675
|
}
|
|
7676
|
+
/**
|
|
7677
|
+
* Get data.labels.position value
|
|
7678
|
+
* @param {object} d Data object
|
|
7679
|
+
* @param {string} type x | y
|
|
7680
|
+
* @returns {number} Position value
|
|
7681
|
+
* @private
|
|
7682
|
+
*/
|
|
7683
|
+
function getTextPos$1(d, type) {
|
|
7684
|
+
var _a;
|
|
7685
|
+
var position = this.config.data_labels_position;
|
|
7686
|
+
var id = d.id, index = d.index, value = d.value;
|
|
7687
|
+
return (_a = (isFunction(position) ?
|
|
7688
|
+
position.bind(this.api)(type, value, id, index, this.$el.text) :
|
|
7689
|
+
(id in position ? position[id] : position)[type])) !== null && _a !== void 0 ? _a : 0;
|
|
7690
|
+
}
|
|
7645
7691
|
var text = {
|
|
7646
7692
|
opacityForText: function (d) {
|
|
7647
7693
|
var $$ = this;
|
|
@@ -7923,17 +7969,6 @@ var text = {
|
|
|
7923
7969
|
}
|
|
7924
7970
|
return 0;
|
|
7925
7971
|
},
|
|
7926
|
-
/**
|
|
7927
|
-
* Get data.labels.position value
|
|
7928
|
-
* @param {string} id Data id value
|
|
7929
|
-
* @param {string} type x | y
|
|
7930
|
-
* @returns {number} Position value
|
|
7931
|
-
* @private
|
|
7932
|
-
*/
|
|
7933
|
-
getTextPos: function (id, type) {
|
|
7934
|
-
var pos = this.config.data_labels_position;
|
|
7935
|
-
return (id in pos ? pos[id] : pos)[type] || 0;
|
|
7936
|
-
},
|
|
7937
7972
|
/**
|
|
7938
7973
|
* Gets the x coordinate of the text
|
|
7939
7974
|
* @param {object} points Data points position
|
|
@@ -7991,7 +8026,7 @@ var text = {
|
|
|
7991
8026
|
if (isRotated || isTreemapType) {
|
|
7992
8027
|
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
|
7993
8028
|
}
|
|
7994
|
-
return xPos +
|
|
8029
|
+
return xPos + getTextPos$1.call(this, d, "x");
|
|
7995
8030
|
},
|
|
7996
8031
|
/**
|
|
7997
8032
|
* Gets the y coordinate of the text
|
|
@@ -8071,7 +8106,7 @@ var text = {
|
|
|
8071
8106
|
if (!isRotated || isTreemapType) {
|
|
8072
8107
|
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
|
8073
8108
|
}
|
|
8074
|
-
return yPos +
|
|
8109
|
+
return yPos + getTextPos$1.call(this, d, "y");
|
|
8075
8110
|
},
|
|
8076
8111
|
/**
|
|
8077
8112
|
* Calculate if two or more text nodes are overlapping
|
|
@@ -8446,6 +8481,7 @@ var tooltip$1 = {
|
|
|
8446
8481
|
var width = state.width, height = state.height, current = state.current, isLegendRight = state.isLegendRight, inputType = state.inputType, event = state.event;
|
|
8447
8482
|
var hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
|
|
8448
8483
|
var hasTreemap = state.hasTreemap;
|
|
8484
|
+
var isRotated = config.axis_rotated;
|
|
8449
8485
|
var svgLeft = $$.getSvgLeft(true);
|
|
8450
8486
|
var chartRight = svgLeft + current.width - $$.getCurrentPaddingRight();
|
|
8451
8487
|
var chartLeft = $$.getCurrentPaddingLeft(true);
|
|
@@ -8461,9 +8497,9 @@ var tooltip$1 = {
|
|
|
8461
8497
|
}
|
|
8462
8498
|
else if (!hasTreemap) {
|
|
8463
8499
|
var dataScale = scale.x(dataToShow[0].x);
|
|
8464
|
-
if (
|
|
8500
|
+
if (isRotated) {
|
|
8465
8501
|
y = dataScale + size;
|
|
8466
|
-
x += svgLeft
|
|
8502
|
+
x += svgLeft;
|
|
8467
8503
|
chartRight -= svgLeft;
|
|
8468
8504
|
}
|
|
8469
8505
|
else {
|
|
@@ -8473,7 +8509,7 @@ var tooltip$1 = {
|
|
|
8473
8509
|
}
|
|
8474
8510
|
// when tooltip left + tWidth > chart's width
|
|
8475
8511
|
if ((x + tWidth + 15) > chartRight) {
|
|
8476
|
-
x -= tWidth + (hasTreemap ? 0 : chartLeft);
|
|
8512
|
+
x -= isRotated ? tWidth - chartLeft : tWidth + (hasTreemap ? 0 : chartLeft);
|
|
8477
8513
|
}
|
|
8478
8514
|
if (y + tHeight > current.height) {
|
|
8479
8515
|
var gap = hasTreemap ? 0 : 30;
|
|
@@ -9284,6 +9320,7 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9284
9320
|
.classed($COMMON.chart, true)
|
|
9285
9321
|
.attr("clip-path", hasAxis ? state.clip.path : null);
|
|
9286
9322
|
$$.callPluginHook("$init");
|
|
9323
|
+
$$.initChartElements();
|
|
9287
9324
|
if (hasAxis) {
|
|
9288
9325
|
// Cover whole with rects for events
|
|
9289
9326
|
hasInteraction && ((_a = $$.initEventRect) === null || _a === void 0 ? void 0 : _a.call($$));
|
|
@@ -9292,7 +9329,6 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9292
9329
|
// Add Axis here, when clipPath is 'true'
|
|
9293
9330
|
config.clipPath && ((_b = $$.axis) === null || _b === void 0 ? void 0 : _b.init());
|
|
9294
9331
|
}
|
|
9295
|
-
$$.initChartElements();
|
|
9296
9332
|
// Set targets
|
|
9297
9333
|
$$.updateTargets($$.data.targets);
|
|
9298
9334
|
// Draw with targets
|
|
@@ -9327,7 +9363,11 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9327
9363
|
var _a = $$.state, hasAxis = _a.hasAxis, hasRadar = _a.hasRadar, hasTreemap = _a.hasTreemap;
|
|
9328
9364
|
var types = [];
|
|
9329
9365
|
if (hasAxis) {
|
|
9330
|
-
["bar", "bubble", "candlestick", "line"]
|
|
9366
|
+
var shapes = ["bar", "bubble", "candlestick", "line"];
|
|
9367
|
+
if ($$.config.bar_front) {
|
|
9368
|
+
shapes.push(shapes.shift());
|
|
9369
|
+
}
|
|
9370
|
+
shapes.forEach(function (v) {
|
|
9331
9371
|
var name = capitalize(v);
|
|
9332
9372
|
if ((v === "line" && $$.hasTypeOf(name)) || $$.hasType(v)) {
|
|
9333
9373
|
types.push(name);
|
|
@@ -9363,7 +9403,8 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9363
9403
|
*/
|
|
9364
9404
|
ChartInternal.prototype.setChartElements = function () {
|
|
9365
9405
|
var $$ = this;
|
|
9366
|
-
var _a = $$.$el, chart = _a.chart, svg = _a.svg, defs = _a.defs, main = _a.main, tooltip = _a.tooltip, legend = _a.legend, title = _a.title, grid = _a.grid, arc = _a.arcs, circles = _a.circle, bars = _a.bar, candlestick = _a.candlestick, lines = _a.line, areas = _a.area, texts = _a.text;
|
|
9406
|
+
var _a = $$.$el, chart = _a.chart, svg = _a.svg, defs = _a.defs, main = _a.main, tooltip = _a.tooltip, legend = _a.legend, title = _a.title, grid = _a.grid, needle = _a.needle, arc = _a.arcs, circles = _a.circle, bars = _a.bar, candlestick = _a.candlestick, lines = _a.line, areas = _a.area, texts = _a.text;
|
|
9407
|
+
// public
|
|
9367
9408
|
$$.api.$ = {
|
|
9368
9409
|
chart: chart,
|
|
9369
9410
|
svg: svg,
|
|
@@ -9378,6 +9419,7 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9378
9419
|
bar: { bars: bars },
|
|
9379
9420
|
candlestick: candlestick,
|
|
9380
9421
|
line: { lines: lines, areas: areas },
|
|
9422
|
+
needle: needle,
|
|
9381
9423
|
text: { texts: texts }
|
|
9382
9424
|
};
|
|
9383
9425
|
};
|
|
@@ -10902,6 +10944,10 @@ var apiTooltip = { tooltip: tooltip };
|
|
|
10902
10944
|
* @property {d3.selection} $.svg Main svg element
|
|
10903
10945
|
* @property {d3.selection} $.defs Definition element
|
|
10904
10946
|
* @property {d3.selection} $.main Main grouping element
|
|
10947
|
+
* @property {d3.selection} $.needle Needle element
|
|
10948
|
+
* - **NOTE:**
|
|
10949
|
+
* - The element will have `bb-needle` as class name.
|
|
10950
|
+
* - Will provide speical helper `.updateHelper(value: number, updateConfig: boolean)` method to facilitate needle position update.
|
|
10905
10951
|
* @property {d3.selection} $.tooltip Tooltip element
|
|
10906
10952
|
* @property {d3.selection} $.legend Legend element
|
|
10907
10953
|
* @property {d3.selection} $.title Title element
|
|
@@ -10918,10 +10964,35 @@ var apiTooltip = { tooltip: tooltip };
|
|
|
10918
10964
|
* @property {d3.selection} $.text.texts Data label text elements
|
|
10919
10965
|
* @memberof Chart
|
|
10920
10966
|
* @example
|
|
10921
|
-
*
|
|
10967
|
+
* const chart = bb.generate({ ... });
|
|
10922
10968
|
*
|
|
10923
10969
|
* chart.$.chart; // wrapper element
|
|
10924
10970
|
* chart.$.line.circles; // all data point circle elements
|
|
10971
|
+
* @example
|
|
10972
|
+
* // Update arc needle position
|
|
10973
|
+
* const chart = bb.generate({
|
|
10974
|
+
* data: {
|
|
10975
|
+
* type: "donut"
|
|
10976
|
+
* },
|
|
10977
|
+
* arc: {
|
|
10978
|
+
* needle: {
|
|
10979
|
+
* show: true,
|
|
10980
|
+
* ...
|
|
10981
|
+
* }
|
|
10982
|
+
* }
|
|
10983
|
+
* });
|
|
10984
|
+
*
|
|
10985
|
+
* chart.$.needle.updateHelper(70); // update needle position to point value 70.
|
|
10986
|
+
*
|
|
10987
|
+
* // update needle position to point value 70 and the config value.
|
|
10988
|
+
* // NOTE: updating config value, will update needle pointer initial value too.
|
|
10989
|
+
* chart.$.needle.updateHelper(70, true);
|
|
10990
|
+
*
|
|
10991
|
+
* // update needle point position every 1 second
|
|
10992
|
+
* let i = 0;
|
|
10993
|
+
* setInterval(() => {
|
|
10994
|
+
* chart.$.needle.updateHelper(i += 10);
|
|
10995
|
+
* }, 1000)
|
|
10925
10996
|
*/
|
|
10926
10997
|
/**
|
|
10927
10998
|
* Plugin instance array
|
|
@@ -16735,7 +16806,7 @@ var shapeArc = {
|
|
|
16735
16806
|
}
|
|
16736
16807
|
return len * Math.PI;
|
|
16737
16808
|
},
|
|
16738
|
-
|
|
16809
|
+
getGaugeStartAngle: function () {
|
|
16739
16810
|
var $$ = this;
|
|
16740
16811
|
var config = $$.config;
|
|
16741
16812
|
var isFullCircle = config.gauge_fullCircle;
|
|
@@ -16762,7 +16833,7 @@ var shapeArc = {
|
|
|
16762
16833
|
if (!config) {
|
|
16763
16834
|
return null;
|
|
16764
16835
|
}
|
|
16765
|
-
var gStart = $$.
|
|
16836
|
+
var gStart = $$.getGaugeStartAngle();
|
|
16766
16837
|
var radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
|
|
16767
16838
|
if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
|
|
16768
16839
|
var min = config.gauge_min, max = config.gauge_max;
|
|
@@ -16776,7 +16847,8 @@ var shapeArc = {
|
|
|
16776
16847
|
}
|
|
16777
16848
|
pie($$.filterTargetsToShow())
|
|
16778
16849
|
.forEach(function (t, i) {
|
|
16779
|
-
|
|
16850
|
+
var _a;
|
|
16851
|
+
if (!found && t.data.id === ((_a = d.data) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
16780
16852
|
found = true;
|
|
16781
16853
|
d = t;
|
|
16782
16854
|
d.index = i;
|
|
@@ -17014,11 +17086,6 @@ var shapeArc = {
|
|
|
17014
17086
|
});
|
|
17015
17087
|
return isFunction(format) ? format.bind($$.api) : format;
|
|
17016
17088
|
},
|
|
17017
|
-
getArcTitle: function () {
|
|
17018
|
-
var $$ = this;
|
|
17019
|
-
var type = ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge");
|
|
17020
|
-
return type ? $$.config["".concat(type, "_title")] : "";
|
|
17021
|
-
},
|
|
17022
17089
|
updateTargetsForArc: function (targets) {
|
|
17023
17090
|
var $$ = this;
|
|
17024
17091
|
var $el = $$.$el;
|
|
@@ -17057,20 +17124,55 @@ var shapeArc = {
|
|
|
17057
17124
|
},
|
|
17058
17125
|
/**
|
|
17059
17126
|
* Set arc title text
|
|
17127
|
+
* @param {string} str Title text
|
|
17060
17128
|
* @private
|
|
17061
17129
|
*/
|
|
17062
|
-
setArcTitle: function () {
|
|
17130
|
+
setArcTitle: function (str) {
|
|
17063
17131
|
var $$ = this;
|
|
17064
|
-
var title = $$.getArcTitle();
|
|
17132
|
+
var title = str || $$.getArcTitle();
|
|
17065
17133
|
var hasGauge = $$.hasType("gauge");
|
|
17066
17134
|
if (title) {
|
|
17067
|
-
var
|
|
17068
|
-
|
|
17069
|
-
|
|
17135
|
+
var className = hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle;
|
|
17136
|
+
var text = $$.$el.arcs.select(".".concat(className));
|
|
17137
|
+
if (text.empty()) {
|
|
17138
|
+
text = $$.$el.arcs.append("text")
|
|
17139
|
+
.attr("class", className)
|
|
17140
|
+
.style("text-anchor", "middle");
|
|
17141
|
+
}
|
|
17070
17142
|
hasGauge && text.attr("dy", "-0.3em");
|
|
17071
17143
|
setTextValue(text, title, hasGauge ? undefined : [-0.6, 1.35], true);
|
|
17072
17144
|
}
|
|
17073
17145
|
},
|
|
17146
|
+
/**
|
|
17147
|
+
* Return arc title text
|
|
17148
|
+
* @returns {string} Arc title text
|
|
17149
|
+
* @private
|
|
17150
|
+
*/
|
|
17151
|
+
getArcTitle: function () {
|
|
17152
|
+
var $$ = this;
|
|
17153
|
+
var type = ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge");
|
|
17154
|
+
return type ? $$.config["".concat(type, "_title")] : "";
|
|
17155
|
+
},
|
|
17156
|
+
/**
|
|
17157
|
+
* Get arc title text with needle value
|
|
17158
|
+
* @returns {string|boolean} When title contains needle template string will return processed string, otherwise false
|
|
17159
|
+
* @private
|
|
17160
|
+
*/
|
|
17161
|
+
getArcTitleWithNeedleValue: function () {
|
|
17162
|
+
var $$ = this;
|
|
17163
|
+
var config = $$.config, state = $$.state;
|
|
17164
|
+
var title = $$.getArcTitle();
|
|
17165
|
+
if (title && $$.config.arc_needle_show && /{=[A-Z_]+}/.test(title)) {
|
|
17166
|
+
var value = state.current.needle;
|
|
17167
|
+
if (!isNumber(value)) {
|
|
17168
|
+
value = config.arc_needle_value;
|
|
17169
|
+
}
|
|
17170
|
+
return tplProcess(title, {
|
|
17171
|
+
NEEDLE_VALUE: isNumber(value) ? value : 0
|
|
17172
|
+
});
|
|
17173
|
+
}
|
|
17174
|
+
return false;
|
|
17175
|
+
},
|
|
17074
17176
|
redrawArc: function (duration, durationForExit, withTransform) {
|
|
17075
17177
|
var $$ = this;
|
|
17076
17178
|
var config = $$.config, state = $$.state, main = $$.$el.main;
|
|
@@ -17158,8 +17260,101 @@ var shapeArc = {
|
|
|
17158
17260
|
hasInteraction && $$.bindArcEvent(mainArc);
|
|
17159
17261
|
$$.hasType("polar") && $$.redrawPolar();
|
|
17160
17262
|
$$.hasType("gauge") && $$.redrawBackgroundArcs();
|
|
17263
|
+
config.arc_needle_show && $$.redrawNeedle();
|
|
17161
17264
|
$$.redrawArcText(duration);
|
|
17162
17265
|
},
|
|
17266
|
+
/**
|
|
17267
|
+
* Update needle element
|
|
17268
|
+
* @private
|
|
17269
|
+
*/
|
|
17270
|
+
redrawNeedle: function () {
|
|
17271
|
+
var $$ = this;
|
|
17272
|
+
var $el = $$.$el, config = $$.config, _a = $$.state, hiddenTargetIds = _a.hiddenTargetIds, radius = _a.radius;
|
|
17273
|
+
var length = (radius - 1) / 100 * config.arc_needle_length;
|
|
17274
|
+
var hasDataToShow = hiddenTargetIds.length !== $$.data.targets.length;
|
|
17275
|
+
var needle = $$.$el.arcs.select(".".concat($ARC.needle));
|
|
17276
|
+
// needle options
|
|
17277
|
+
var pathFn = config.arc_needle_path;
|
|
17278
|
+
var baseWidth = config.arc_needle_bottom_width / 2;
|
|
17279
|
+
var topWidth = config.arc_needle_top_width / 2;
|
|
17280
|
+
var topRx = config.arc_needle_top_rx;
|
|
17281
|
+
var topRy = config.arc_needle_top_ry;
|
|
17282
|
+
var bottomLen = config.arc_needle_bottom_len;
|
|
17283
|
+
var bottomRx = config.arc_needle_bottom_rx;
|
|
17284
|
+
var bottomRy = config.arc_needle_bottom_ry;
|
|
17285
|
+
var needleAngle = $$.getNeedleAngle();
|
|
17286
|
+
var updateNeedleValue = function () {
|
|
17287
|
+
var title = $$.getArcTitleWithNeedleValue();
|
|
17288
|
+
title && $$.setArcTitle(title);
|
|
17289
|
+
};
|
|
17290
|
+
updateNeedleValue();
|
|
17291
|
+
if (needle.empty()) {
|
|
17292
|
+
needle = $el.arcs
|
|
17293
|
+
.append("path")
|
|
17294
|
+
.classed($ARC.needle, true);
|
|
17295
|
+
$el.needle = needle;
|
|
17296
|
+
/**
|
|
17297
|
+
* Function to be exposed as public to facilitate updating needle
|
|
17298
|
+
* @param {number} v Value to be updated
|
|
17299
|
+
* @param {boolean} updateConfig Weather update config's value
|
|
17300
|
+
* @private
|
|
17301
|
+
*/
|
|
17302
|
+
$el.needle.updateHelper = function (v, updateConfig) {
|
|
17303
|
+
if (updateConfig === void 0) { updateConfig = false; }
|
|
17304
|
+
if ($el.needle.style("display") !== "none") {
|
|
17305
|
+
$$.$T($el.needle)
|
|
17306
|
+
.style("transform", "rotate(".concat($$.getNeedleAngle(v), "deg)"))
|
|
17307
|
+
.call(endall, function () {
|
|
17308
|
+
updateConfig && (config.arc_needle_value = v);
|
|
17309
|
+
updateNeedleValue();
|
|
17310
|
+
});
|
|
17311
|
+
}
|
|
17312
|
+
};
|
|
17313
|
+
}
|
|
17314
|
+
if (hasDataToShow) {
|
|
17315
|
+
var path = isFunction(pathFn) ?
|
|
17316
|
+
pathFn.call($$, length) :
|
|
17317
|
+
"M-".concat(baseWidth, " ").concat(bottomLen, " A").concat(bottomRx, " ").concat(bottomRy, " 0 0 0 ").concat(baseWidth, " ").concat(bottomLen, " L").concat(topWidth, " -").concat(length, " A").concat(topRx, " ").concat(topRy, " 0 0 0 -").concat(topWidth, " -").concat(length, " L-").concat(baseWidth, " ").concat(bottomLen, " Z");
|
|
17318
|
+
$$.$T(needle)
|
|
17319
|
+
.attr("d", path)
|
|
17320
|
+
.style("fill", config.arc_needle_color)
|
|
17321
|
+
.style("display", null)
|
|
17322
|
+
.style("transform", "rotate(".concat(needleAngle, "deg)"));
|
|
17323
|
+
}
|
|
17324
|
+
else {
|
|
17325
|
+
needle.style("display", "none");
|
|
17326
|
+
}
|
|
17327
|
+
},
|
|
17328
|
+
/**
|
|
17329
|
+
* Get needle angle value relative given value
|
|
17330
|
+
* @param {number} v Value to be calculated angle
|
|
17331
|
+
* @returns {number} angle value
|
|
17332
|
+
* @private
|
|
17333
|
+
*/
|
|
17334
|
+
getNeedleAngle: function (v) {
|
|
17335
|
+
var $$ = this;
|
|
17336
|
+
var config = $$.config, state = $$.state;
|
|
17337
|
+
var arcLength = $$.getArcLength();
|
|
17338
|
+
var hasGauge = $$.hasType("gauge");
|
|
17339
|
+
var total = $$.getTotalDataSum(true);
|
|
17340
|
+
var value = isDefined(v) ? v : config.arc_needle_value;
|
|
17341
|
+
var startingAngle = config["".concat(config.data_type, "_startingAngle")] || 0;
|
|
17342
|
+
var radian = 0;
|
|
17343
|
+
if (!isNumber(value)) {
|
|
17344
|
+
value = hasGauge && $$.data.targets.length === 1 ? total : 0;
|
|
17345
|
+
}
|
|
17346
|
+
state.current.needle = value;
|
|
17347
|
+
if (hasGauge) {
|
|
17348
|
+
startingAngle = $$.getGaugeStartAngle();
|
|
17349
|
+
var radius = config.gauge_fullCircle ? arcLength : startingAngle * -2;
|
|
17350
|
+
var min = config.gauge_min, max = config.gauge_max;
|
|
17351
|
+
radian = radius * ((value - min) / (max - min));
|
|
17352
|
+
}
|
|
17353
|
+
else {
|
|
17354
|
+
radian = arcLength * (value / total);
|
|
17355
|
+
}
|
|
17356
|
+
return (startingAngle + radian) * (180 / Math.PI);
|
|
17357
|
+
},
|
|
17163
17358
|
redrawBackgroundArcs: function () {
|
|
17164
17359
|
var $$ = this;
|
|
17165
17360
|
var config = $$.config, state = $$.state;
|
|
@@ -17167,7 +17362,7 @@ var shapeArc = {
|
|
|
17167
17362
|
var isFullCircle = config.gauge_fullCircle;
|
|
17168
17363
|
var showEmptyTextLabel = $$.filterTargetsToShow($$.data.targets).length === 0 &&
|
|
17169
17364
|
!!config.data_empty_label_text;
|
|
17170
|
-
var startAngle = $$.
|
|
17365
|
+
var startAngle = $$.getGaugeStartAngle();
|
|
17171
17366
|
var endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
|
|
17172
17367
|
var backgroundArc = $$.$el.arcs.select("".concat(hasMultiArcGauge ? "g" : "", ".").concat($ARC.chartArcsBackground));
|
|
17173
17368
|
if (hasMultiArcGauge) {
|
|
@@ -17496,9 +17691,11 @@ var shapeArea = {
|
|
|
17496
17691
|
var shapeBar = {
|
|
17497
17692
|
initBar: function () {
|
|
17498
17693
|
var _a = this, $el = _a.$el, config = _a.config, clip = _a.state.clip;
|
|
17499
|
-
$el.bar = $el.main.select(".".concat($COMMON.chart))
|
|
17500
|
-
|
|
17501
|
-
.
|
|
17694
|
+
$el.bar = $el.main.select(".".concat($COMMON.chart));
|
|
17695
|
+
$el.bar = config.bar_front ?
|
|
17696
|
+
$el.bar.append("g") :
|
|
17697
|
+
$el.bar.insert("g", ":first-child");
|
|
17698
|
+
$el.bar
|
|
17502
17699
|
.attr("class", $BAR.chartBars)
|
|
17503
17700
|
.call(this.setCssRule(false, ".".concat($BAR.chartBars), ["pointer-events:none"]));
|
|
17504
17701
|
// set clip-path attribute when condition meet
|
|
@@ -18048,7 +18245,6 @@ var shapeBubble = {
|
|
|
18048
18245
|
if ($$.hasType("bubble")) {
|
|
18049
18246
|
config.point_show = true;
|
|
18050
18247
|
config.point_type = "circle";
|
|
18051
|
-
config.point_sensitivity = 25;
|
|
18052
18248
|
}
|
|
18053
18249
|
},
|
|
18054
18250
|
/**
|
|
@@ -18610,6 +18806,7 @@ var shapePoint = {
|
|
|
18610
18806
|
else if (isFunction(pointR)) {
|
|
18611
18807
|
r = pointR.bind($$.api)(d);
|
|
18612
18808
|
}
|
|
18809
|
+
d.r = r;
|
|
18613
18810
|
return r;
|
|
18614
18811
|
},
|
|
18615
18812
|
pointExpandedR: function (d) {
|
|
@@ -19486,10 +19683,6 @@ var shapeTreemap = {
|
|
|
19486
19683
|
}
|
|
19487
19684
|
};
|
|
19488
19685
|
|
|
19489
|
-
/**
|
|
19490
|
-
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
19491
|
-
* billboard.js project is licensed under the MIT license
|
|
19492
|
-
*/
|
|
19493
19686
|
/**
|
|
19494
19687
|
* point config options
|
|
19495
19688
|
*/
|
|
@@ -19511,7 +19704,20 @@ var optPoint = {
|
|
|
19511
19704
|
* - **NOTE:**
|
|
19512
19705
|
* - `null` will make to not set inline 'opacity' css prop.
|
|
19513
19706
|
* - when no value(or undefined) is set, it defaults to set opacity value according its chart types.
|
|
19514
|
-
* @property {number} [point.sensitivity=10] The senstivity value for interaction boundary.
|
|
19707
|
+
* @property {number|string|Function} [point.sensitivity=10] The senstivity value for interaction boundary.
|
|
19708
|
+
* - **Available Values:**
|
|
19709
|
+
* - {number}: Absolute sensitivity value which is the distance from the data point in pixel.
|
|
19710
|
+
* - "radius": sensitivity based on point's radius
|
|
19711
|
+
* - Function: callback for each point to determine the sensitivity<br>
|
|
19712
|
+
* ```js
|
|
19713
|
+
* sensitivity: function(d) {
|
|
19714
|
+
* // ex. of argument d:
|
|
19715
|
+
* // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
|
|
19716
|
+
*
|
|
19717
|
+
* // returning d.r, will make sensitivity same as point's radius value.
|
|
19718
|
+
* return d.r;
|
|
19719
|
+
* }
|
|
19720
|
+
* ```
|
|
19515
19721
|
* @property {number} [point.select.r=point.r*4] The radius size of each point on selected.
|
|
19516
19722
|
* @property {string} [point.type="circle"] The type of point to be drawn
|
|
19517
19723
|
* - **NOTE:**
|
|
@@ -19532,6 +19738,7 @@ var optPoint = {
|
|
|
19532
19738
|
* (ex. `<polygon points='2.5 0 0 5 5 5'></polygon>`)
|
|
19533
19739
|
* @see [Demo: point type](https://naver.github.io/billboard.js/demo/#Point.RectanglePoints)
|
|
19534
19740
|
* @see [Demo: point focus only](https://naver.github.io/billboard.js/demo/#Point.FocusOnly)
|
|
19741
|
+
* @see [Demo: point sensitivity](https://naver.github.io/billboard.js/demo/#Point.PointSensitivity)
|
|
19535
19742
|
* @example
|
|
19536
19743
|
* point: {
|
|
19537
19744
|
* show: false,
|
|
@@ -19564,6 +19771,18 @@ var optPoint = {
|
|
|
19564
19771
|
* // having lower value, means how closer to be for interaction
|
|
19565
19772
|
* sensitivity: 3,
|
|
19566
19773
|
*
|
|
19774
|
+
* // sensitivity based on point's radius
|
|
19775
|
+
* sensitivity: "radius",
|
|
19776
|
+
*
|
|
19777
|
+
* // callback for each point to determine the sensitivity
|
|
19778
|
+
* sensitivity: function(d) {
|
|
19779
|
+
* // ex. of argument d:
|
|
19780
|
+
* // ==> {x: 2, value: 55, id: 'data3', index: 2, r: 19.820624179302296}
|
|
19781
|
+
*
|
|
19782
|
+
* // returning d.r, will make sensitivity same as point's radius value.
|
|
19783
|
+
* return d.r;
|
|
19784
|
+
* }
|
|
19785
|
+
*
|
|
19567
19786
|
* // valid values are "circle" or "rectangle"
|
|
19568
19787
|
* type: "rectangle",
|
|
19569
19788
|
*
|
|
@@ -19671,6 +19890,7 @@ var optBar = {
|
|
|
19671
19890
|
* @memberof Options
|
|
19672
19891
|
* @type {object}
|
|
19673
19892
|
* @property {object} bar Bar object
|
|
19893
|
+
* @property {boolean} [bar.front=false] Set 'bar' to be positioned over(on the top) other shapes elements.
|
|
19674
19894
|
* @property {number} [bar.indices.removeNull=false] Remove nullish data on bar indices positions.
|
|
19675
19895
|
* @property {number} [bar.label.threshold=0] Set threshold ratio to show/hide labels.
|
|
19676
19896
|
* @property {boolean|object} [bar.linearGradient=false] Set the linear gradient on bar.<br><br>
|
|
@@ -19693,6 +19913,7 @@ var optBar = {
|
|
|
19693
19913
|
* @property {number} [bar.width.dataname.ratio=0.6] Change the width of bar chart by ratio.
|
|
19694
19914
|
* @property {number} [bar.width.dataname.max] The maximum width value for ratio.
|
|
19695
19915
|
* @property {boolean} [bar.zerobased=true] Set if min or max value will be 0 on bar chart.
|
|
19916
|
+
* @see [Demo: bar front](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarFront)
|
|
19696
19917
|
* @see [Demo: bar indices](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarIndices)
|
|
19697
19918
|
* @see [Demo: bar overlap](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarOverlap)
|
|
19698
19919
|
* @see [Demo: bar padding](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarPadding)
|
|
@@ -19701,6 +19922,9 @@ var optBar = {
|
|
|
19701
19922
|
* @see [Demo: bar width variant](https://naver.github.io/billboard.js/demo/#BarChartOptions.BarWidthVariant)
|
|
19702
19923
|
* @example
|
|
19703
19924
|
* bar: {
|
|
19925
|
+
* // make bar shape to be positioned over the other shape elements
|
|
19926
|
+
* front: true,
|
|
19927
|
+
*
|
|
19704
19928
|
* // remove nullish data on bar indices postions
|
|
19705
19929
|
* indices: {
|
|
19706
19930
|
* removeNull: true
|
|
@@ -19771,9 +19995,10 @@ var optBar = {
|
|
|
19771
19995
|
* zerobased: false
|
|
19772
19996
|
* }
|
|
19773
19997
|
*/
|
|
19998
|
+
bar_front: false,
|
|
19999
|
+
bar_indices_removeNull: false,
|
|
19774
20000
|
bar_label_threshold: 0,
|
|
19775
20001
|
bar_linearGradient: false,
|
|
19776
|
-
bar_indices_removeNull: false,
|
|
19777
20002
|
bar_overlap: false,
|
|
19778
20003
|
bar_padding: 0,
|
|
19779
20004
|
bar_radius: undefined,
|
|
@@ -20039,9 +20264,31 @@ var optArc = {
|
|
|
20039
20264
|
* - **NOTE:**
|
|
20040
20265
|
* - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
|
|
20041
20266
|
* @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
|
|
20267
|
+
* @property {object} [arc.needle] Set needle options.
|
|
20268
|
+
* @property {boolean} [arc.needle.show=false] Show or hide needle.
|
|
20269
|
+
* @property {string} [arc.needle.color] Set needle filled color.
|
|
20270
|
+
* @property {Function} [arc.needle.path] Set custom needle path function.
|
|
20271
|
+
* - **NOTE:**
|
|
20272
|
+
* - The path should be starting from 0,0 (which is center) to top center coordinate.
|
|
20273
|
+
* - The function will receive, `length`{number} parameter which indicating the needle length in pixel relative to radius.
|
|
20274
|
+
* @property {number} [arc.needle.value] Set needle value.
|
|
20275
|
+
* - **NOTE:**
|
|
20276
|
+
* - For single gauge chart, needle will point the data value by default, otherwise will point 0(zero).
|
|
20277
|
+
* @property {number} [arc.needle.length=100] Set needle length in percentages relative to radius.
|
|
20278
|
+
* @property {object} [arc.needle.top] Set needle top options.
|
|
20279
|
+
* @property {number} [arc.needle.top.rx=0] Set needle top [rx radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
|
|
20280
|
+
* @property {number} [arc.needle.top.ry=0] Set needle top [ry radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
|
|
20281
|
+
* @property {number} [arc.needle.top.width=0] Set needle top width in pixel.
|
|
20282
|
+
* @property {object} [arc.needle.bottom] Set needle bottom options.
|
|
20283
|
+
* @property {number} [arc.needle.bottom.rx=1] Set needle bottom [rx radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
|
|
20284
|
+
* @property {number} [arc.needle.bottom.ry=1] Set needle bottom [ry radius value](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve).
|
|
20285
|
+
* @property {number} [arc.needle.bottom.width=15] Set needle bottom width in pixel.
|
|
20286
|
+
* @property {number} [arc.needle.bottom.len=0] Set needle bottom length in pixel. Setting this value, will make bottom larger starting from center.
|
|
20042
20287
|
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
20043
20288
|
* @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
|
|
20044
20289
|
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
|
|
20290
|
+
* @see [Demo: Donut needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
|
|
20291
|
+
* @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/##GaugeChartOptions.GaugeNeedle)
|
|
20045
20292
|
* @example
|
|
20046
20293
|
* arc: {
|
|
20047
20294
|
* cornerRadius: 12,
|
|
@@ -20060,11 +20307,61 @@ var optArc = {
|
|
|
20060
20307
|
* // set ratio relative of outer radius
|
|
20061
20308
|
* cornerRadius: {
|
|
20062
20309
|
* ratio: 0.5
|
|
20310
|
+
* },
|
|
20311
|
+
*
|
|
20312
|
+
* needle: {
|
|
20313
|
+
* show: true,
|
|
20314
|
+
* color: "red", // any valid CSS color
|
|
20315
|
+
* path: function(length) {
|
|
20316
|
+
* const len = length - 20;
|
|
20317
|
+
*
|
|
20318
|
+
* // will return upper arrow shape path
|
|
20319
|
+
* // Note: The path should begun from '0,0' coordinate to top center.
|
|
20320
|
+
* const path = `M 0 -${len + 20}
|
|
20321
|
+
* L -12 -${len}
|
|
20322
|
+
* L -5 -${len}
|
|
20323
|
+
* L -5 0
|
|
20324
|
+
* A 1 1 0 0 0 5 0
|
|
20325
|
+
* L 5 -${len}
|
|
20326
|
+
* L 12 -${len} Z`;
|
|
20327
|
+
*
|
|
20328
|
+
* return path;
|
|
20329
|
+
* },
|
|
20330
|
+
* value: 40, // will make needle to point value 40.
|
|
20331
|
+
* length: 80, // needle length in percentages relative to radius.
|
|
20332
|
+
*
|
|
20333
|
+
* top: {
|
|
20334
|
+
* // rx and ry are the two radii of the ellipse;
|
|
20335
|
+
* // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
|
|
20336
|
+
* rx: 1,
|
|
20337
|
+
* ry: 1,
|
|
20338
|
+
* width: 5
|
|
20339
|
+
* },
|
|
20340
|
+
* bottom: {
|
|
20341
|
+
* // rx and ry are the two radii of the ellipse;
|
|
20342
|
+
* // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
|
|
20343
|
+
* rx: 1,
|
|
20344
|
+
* ry: 1,
|
|
20345
|
+
* width: 10
|
|
20346
|
+
* len: 10
|
|
20347
|
+
* }
|
|
20063
20348
|
* }
|
|
20064
20349
|
* }
|
|
20065
20350
|
*/
|
|
20066
20351
|
arc_cornerRadius: 0,
|
|
20067
|
-
arc_cornerRadius_ratio: 0
|
|
20352
|
+
arc_cornerRadius_ratio: 0,
|
|
20353
|
+
arc_needle_show: false,
|
|
20354
|
+
arc_needle_color: undefined,
|
|
20355
|
+
arc_needle_value: undefined,
|
|
20356
|
+
arc_needle_path: undefined,
|
|
20357
|
+
arc_needle_length: 100,
|
|
20358
|
+
arc_needle_top_rx: 0,
|
|
20359
|
+
arc_needle_top_ry: 0,
|
|
20360
|
+
arc_needle_top_width: 0,
|
|
20361
|
+
arc_needle_bottom_rx: 1,
|
|
20362
|
+
arc_needle_bottom_ry: 1,
|
|
20363
|
+
arc_needle_bottom_width: 15,
|
|
20364
|
+
arc_needle_bottom_len: 0
|
|
20068
20365
|
};
|
|
20069
20366
|
|
|
20070
20367
|
/**
|
|
@@ -20090,6 +20387,8 @@ var optDonut = {
|
|
|
20090
20387
|
* @property {number} [donut.expand.duration=50] Set expand transition time in ms.
|
|
20091
20388
|
* @property {number} [donut.width] Set width of donut chart.
|
|
20092
20389
|
* @property {string} [donut.title=""] Set title of donut chart. Use `\n` character for line break.
|
|
20390
|
+
* - **NOTE:**
|
|
20391
|
+
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
20093
20392
|
* @property {number} [donut.padAngle=0] Set padding between data.
|
|
20094
20393
|
* @property {number} [donut.startingAngle=0] Set starting angle where data draws.
|
|
20095
20394
|
* @example
|
|
@@ -20132,6 +20431,9 @@ var optDonut = {
|
|
|
20132
20431
|
* startingAngle: 1,
|
|
20133
20432
|
* title: "Donut Title"
|
|
20134
20433
|
*
|
|
20434
|
+
* // when 'arc.needle.show=true' is set, can show current needle value.
|
|
20435
|
+
* title: "Needle value:\n{=NEEDLE_VALUE}",
|
|
20436
|
+
*
|
|
20135
20437
|
* // title with line break
|
|
20136
20438
|
* title: "Title1\nTitle2"
|
|
20137
20439
|
* }
|
|
@@ -20197,6 +20499,8 @@ var optGauge = {
|
|
|
20197
20499
|
* - 'arcLength < -100' defaults to -100
|
|
20198
20500
|
* - 'arcLength > 100' defaults to 100
|
|
20199
20501
|
* @property {string} [gauge.title=""] Set title of gauge chart. Use `\n` character for line break.
|
|
20502
|
+
* - **NOTE:**
|
|
20503
|
+
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
20200
20504
|
* @property {string} [gauge.units] Set units of the gauge.
|
|
20201
20505
|
* @property {number} [gauge.width] Set width of gauge chart.
|
|
20202
20506
|
* @property {string} [gauge.type="single"] Set type of gauge to be displayed.<br><br>
|
|
@@ -20243,6 +20547,10 @@ var optGauge = {
|
|
|
20243
20547
|
* max: 200,
|
|
20244
20548
|
* type: "single" // or 'multi'
|
|
20245
20549
|
* title: "Title Text",
|
|
20550
|
+
*
|
|
20551
|
+
* // when 'arc.needle.show=true' is set, can show current needle value.
|
|
20552
|
+
* title: "Needle value:\n{=NEEDLE_VALUE}",
|
|
20553
|
+
*
|
|
20246
20554
|
* units: "%",
|
|
20247
20555
|
* width: 10,
|
|
20248
20556
|
* startingAngle: -1 * Math.PI / 2,
|
|
@@ -22280,7 +22588,7 @@ var zoomModule = function () {
|
|
|
22280
22588
|
var defaults = {};
|
|
22281
22589
|
/**
|
|
22282
22590
|
* @namespace bb
|
|
22283
|
-
* @version 3.
|
|
22591
|
+
* @version 3.9.0-next.2
|
|
22284
22592
|
*/
|
|
22285
22593
|
var bb = {
|
|
22286
22594
|
/**
|
|
@@ -22290,7 +22598,7 @@ var bb = {
|
|
|
22290
22598
|
* bb.version; // "1.0.0"
|
|
22291
22599
|
* @memberof bb
|
|
22292
22600
|
*/
|
|
22293
|
-
version: "3.
|
|
22601
|
+
version: "3.9.0-next.2",
|
|
22294
22602
|
/**
|
|
22295
22603
|
* Generate chart
|
|
22296
22604
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|