billboard.js 3.8.2 → 3.9.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +7 -7
- package/dist/billboard.js +324 -59
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +2 -2
- package/dist/billboard.pkgd.js +806 -349
- 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 +307 -44
- 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 +34 -33
- package/src/Chart/Chart.ts +30 -1
- package/src/ChartInternal/ChartInternal.ts +3 -1
- package/src/ChartInternal/data/data.ts +2 -1
- 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/config/Options/common/legend.ts +1 -1
- package/src/config/Options/data/data.ts +22 -6
- package/src/config/Options/shape/arc.ts +73 -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 +29 -12
- package/types/options.shape.d.ts +72 -0
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.1
|
|
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.
|
|
@@ -4459,7 +4475,8 @@ var data$1 = {
|
|
|
4459
4475
|
// otherwise, based on the rendered angle value
|
|
4460
4476
|
}
|
|
4461
4477
|
else {
|
|
4462
|
-
var gaugeArcLength = config.gauge_fullCircle ?
|
|
4478
|
+
var gaugeArcLength = config.gauge_fullCircle ?
|
|
4479
|
+
$$.getArcLength() : $$.getGaugeStartAngle() * -2;
|
|
4463
4480
|
var arcLength = $$.hasType("gauge") ? gaugeArcLength : Math.PI * 2;
|
|
4464
4481
|
ratio = (d.endAngle - d.startAngle) / arcLength;
|
|
4465
4482
|
}
|
|
@@ -7462,6 +7479,9 @@ var size = {
|
|
|
7462
7479
|
xAxisHeight : 30;
|
|
7463
7480
|
var subchartHeight = config.subchart_show && !isNonAxis ?
|
|
7464
7481
|
(config.subchart_size_height + subchartXAxisHeight) : 0;
|
|
7482
|
+
// when needle is shown with legend, it need some bottom space to not overlap with legend text
|
|
7483
|
+
var gaugeHeight = $$.hasType("gauge") && config.arc_needle_show &&
|
|
7484
|
+
!config.gauge_fullCircle && !config.gauge_label_show ? 10 : 0;
|
|
7465
7485
|
var padding = $$.getCurrentPadding();
|
|
7466
7486
|
// for main
|
|
7467
7487
|
state.margin = !isNonAxis && isRotated ? {
|
|
@@ -7472,7 +7492,7 @@ var size = {
|
|
|
7472
7492
|
} : {
|
|
7473
7493
|
top: (isFitPadding ? 0 : 4) + padding.top,
|
|
7474
7494
|
right: isNonAxis ? 0 : $$.getCurrentPaddingRight(true),
|
|
7475
|
-
bottom: xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
|
|
7495
|
+
bottom: gaugeHeight + xAxisHeight + subchartHeight + legendHeightForBottom + padding.bottom,
|
|
7476
7496
|
left: isNonAxis ? 0 : padding.left
|
|
7477
7497
|
};
|
|
7478
7498
|
state.margin = $$.getResettedPadding(state.margin);
|
|
@@ -7642,6 +7662,21 @@ function setRotatePos(d, pos, anchor, isRotated, isInverted) {
|
|
|
7642
7662
|
}
|
|
7643
7663
|
return { x: x, y: y };
|
|
7644
7664
|
}
|
|
7665
|
+
/**
|
|
7666
|
+
* Get data.labels.position value
|
|
7667
|
+
* @param {object} d Data object
|
|
7668
|
+
* @param {string} type x | y
|
|
7669
|
+
* @returns {number} Position value
|
|
7670
|
+
* @private
|
|
7671
|
+
*/
|
|
7672
|
+
function getTextPos$1(d, type) {
|
|
7673
|
+
var _a;
|
|
7674
|
+
var position = this.config.data_labels_position;
|
|
7675
|
+
var id = d.id, index = d.index, value = d.value;
|
|
7676
|
+
return (_a = (isFunction(position) ?
|
|
7677
|
+
position.bind(this.api)(type, value, id, index, this.$el.text) :
|
|
7678
|
+
(id in position ? position[id] : position)[type])) !== null && _a !== void 0 ? _a : 0;
|
|
7679
|
+
}
|
|
7645
7680
|
var text = {
|
|
7646
7681
|
opacityForText: function (d) {
|
|
7647
7682
|
var $$ = this;
|
|
@@ -7923,17 +7958,6 @@ var text = {
|
|
|
7923
7958
|
}
|
|
7924
7959
|
return 0;
|
|
7925
7960
|
},
|
|
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
7961
|
/**
|
|
7938
7962
|
* Gets the x coordinate of the text
|
|
7939
7963
|
* @param {object} points Data points position
|
|
@@ -7991,7 +8015,7 @@ var text = {
|
|
|
7991
8015
|
if (isRotated || isTreemapType) {
|
|
7992
8016
|
xPos += $$.getCenteredTextPos(d, points, textElement, "x");
|
|
7993
8017
|
}
|
|
7994
|
-
return xPos +
|
|
8018
|
+
return xPos + getTextPos$1.call(this, d, "x");
|
|
7995
8019
|
},
|
|
7996
8020
|
/**
|
|
7997
8021
|
* Gets the y coordinate of the text
|
|
@@ -8071,7 +8095,7 @@ var text = {
|
|
|
8071
8095
|
if (!isRotated || isTreemapType) {
|
|
8072
8096
|
yPos += $$.getCenteredTextPos(d, points, textElement, "y");
|
|
8073
8097
|
}
|
|
8074
|
-
return yPos +
|
|
8098
|
+
return yPos + getTextPos$1.call(this, d, "y");
|
|
8075
8099
|
},
|
|
8076
8100
|
/**
|
|
8077
8101
|
* Calculate if two or more text nodes are overlapping
|
|
@@ -8446,6 +8470,7 @@ var tooltip$1 = {
|
|
|
8446
8470
|
var width = state.width, height = state.height, current = state.current, isLegendRight = state.isLegendRight, inputType = state.inputType, event = state.event;
|
|
8447
8471
|
var hasGauge = $$.hasType("gauge") && !config.gauge_fullCircle;
|
|
8448
8472
|
var hasTreemap = state.hasTreemap;
|
|
8473
|
+
var isRotated = config.axis_rotated;
|
|
8449
8474
|
var svgLeft = $$.getSvgLeft(true);
|
|
8450
8475
|
var chartRight = svgLeft + current.width - $$.getCurrentPaddingRight();
|
|
8451
8476
|
var chartLeft = $$.getCurrentPaddingLeft(true);
|
|
@@ -8461,9 +8486,9 @@ var tooltip$1 = {
|
|
|
8461
8486
|
}
|
|
8462
8487
|
else if (!hasTreemap) {
|
|
8463
8488
|
var dataScale = scale.x(dataToShow[0].x);
|
|
8464
|
-
if (
|
|
8489
|
+
if (isRotated) {
|
|
8465
8490
|
y = dataScale + size;
|
|
8466
|
-
x += svgLeft
|
|
8491
|
+
x += svgLeft;
|
|
8467
8492
|
chartRight -= svgLeft;
|
|
8468
8493
|
}
|
|
8469
8494
|
else {
|
|
@@ -8473,7 +8498,7 @@ var tooltip$1 = {
|
|
|
8473
8498
|
}
|
|
8474
8499
|
// when tooltip left + tWidth > chart's width
|
|
8475
8500
|
if ((x + tWidth + 15) > chartRight) {
|
|
8476
|
-
x -= tWidth + (hasTreemap ? 0 : chartLeft);
|
|
8501
|
+
x -= isRotated ? tWidth - chartLeft : tWidth + (hasTreemap ? 0 : chartLeft);
|
|
8477
8502
|
}
|
|
8478
8503
|
if (y + tHeight > current.height) {
|
|
8479
8504
|
var gap = hasTreemap ? 0 : 30;
|
|
@@ -9363,7 +9388,8 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9363
9388
|
*/
|
|
9364
9389
|
ChartInternal.prototype.setChartElements = function () {
|
|
9365
9390
|
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;
|
|
9391
|
+
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;
|
|
9392
|
+
// public
|
|
9367
9393
|
$$.api.$ = {
|
|
9368
9394
|
chart: chart,
|
|
9369
9395
|
svg: svg,
|
|
@@ -9378,6 +9404,7 @@ var ChartInternal = /** @class */ (function () {
|
|
|
9378
9404
|
bar: { bars: bars },
|
|
9379
9405
|
candlestick: candlestick,
|
|
9380
9406
|
line: { lines: lines, areas: areas },
|
|
9407
|
+
needle: needle,
|
|
9381
9408
|
text: { texts: texts }
|
|
9382
9409
|
};
|
|
9383
9410
|
};
|
|
@@ -10902,6 +10929,10 @@ var apiTooltip = { tooltip: tooltip };
|
|
|
10902
10929
|
* @property {d3.selection} $.svg Main svg element
|
|
10903
10930
|
* @property {d3.selection} $.defs Definition element
|
|
10904
10931
|
* @property {d3.selection} $.main Main grouping element
|
|
10932
|
+
* @property {d3.selection} $.needle Needle element
|
|
10933
|
+
* - **NOTE:**
|
|
10934
|
+
* - The element will have `bb-needle` as class name.
|
|
10935
|
+
* - Will provide speical helper `.updateHelper(value: number, updateConfig: boolean)` method to facilitate needle position update.
|
|
10905
10936
|
* @property {d3.selection} $.tooltip Tooltip element
|
|
10906
10937
|
* @property {d3.selection} $.legend Legend element
|
|
10907
10938
|
* @property {d3.selection} $.title Title element
|
|
@@ -10918,10 +10949,35 @@ var apiTooltip = { tooltip: tooltip };
|
|
|
10918
10949
|
* @property {d3.selection} $.text.texts Data label text elements
|
|
10919
10950
|
* @memberof Chart
|
|
10920
10951
|
* @example
|
|
10921
|
-
*
|
|
10952
|
+
* const chart = bb.generate({ ... });
|
|
10922
10953
|
*
|
|
10923
10954
|
* chart.$.chart; // wrapper element
|
|
10924
10955
|
* chart.$.line.circles; // all data point circle elements
|
|
10956
|
+
* @example
|
|
10957
|
+
* // Update arc needle position
|
|
10958
|
+
* const chart = bb.generate({
|
|
10959
|
+
* data: {
|
|
10960
|
+
* type: "donut"
|
|
10961
|
+
* },
|
|
10962
|
+
* arc: {
|
|
10963
|
+
* needle: {
|
|
10964
|
+
* show: true,
|
|
10965
|
+
* ...
|
|
10966
|
+
* }
|
|
10967
|
+
* }
|
|
10968
|
+
* });
|
|
10969
|
+
*
|
|
10970
|
+
* chart.$.needle.updateHelper(70); // update needle position to point value 70.
|
|
10971
|
+
*
|
|
10972
|
+
* // update needle position to point value 70 and the config value.
|
|
10973
|
+
* // NOTE: updating config value, will update needle pointer initial value too.
|
|
10974
|
+
* chart.$.needle.updateHelper(70, true);
|
|
10975
|
+
*
|
|
10976
|
+
* // update needle point position every 1 second
|
|
10977
|
+
* let i = 0;
|
|
10978
|
+
* setInterval(() => {
|
|
10979
|
+
* chart.$.needle.updateHelper(i += 10);
|
|
10980
|
+
* }, 1000)
|
|
10925
10981
|
*/
|
|
10926
10982
|
/**
|
|
10927
10983
|
* Plugin instance array
|
|
@@ -16735,7 +16791,7 @@ var shapeArc = {
|
|
|
16735
16791
|
}
|
|
16736
16792
|
return len * Math.PI;
|
|
16737
16793
|
},
|
|
16738
|
-
|
|
16794
|
+
getGaugeStartAngle: function () {
|
|
16739
16795
|
var $$ = this;
|
|
16740
16796
|
var config = $$.config;
|
|
16741
16797
|
var isFullCircle = config.gauge_fullCircle;
|
|
@@ -16762,7 +16818,7 @@ var shapeArc = {
|
|
|
16762
16818
|
if (!config) {
|
|
16763
16819
|
return null;
|
|
16764
16820
|
}
|
|
16765
|
-
var gStart = $$.
|
|
16821
|
+
var gStart = $$.getGaugeStartAngle();
|
|
16766
16822
|
var radius = config.gauge_fullCircle ? $$.getArcLength() : gStart * -2;
|
|
16767
16823
|
if (d.data && $$.isGaugeType(d.data) && !$$.hasMultiArcGauge()) {
|
|
16768
16824
|
var min = config.gauge_min, max = config.gauge_max;
|
|
@@ -16776,7 +16832,8 @@ var shapeArc = {
|
|
|
16776
16832
|
}
|
|
16777
16833
|
pie($$.filterTargetsToShow())
|
|
16778
16834
|
.forEach(function (t, i) {
|
|
16779
|
-
|
|
16835
|
+
var _a;
|
|
16836
|
+
if (!found && t.data.id === ((_a = d.data) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
16780
16837
|
found = true;
|
|
16781
16838
|
d = t;
|
|
16782
16839
|
d.index = i;
|
|
@@ -17014,11 +17071,6 @@ var shapeArc = {
|
|
|
17014
17071
|
});
|
|
17015
17072
|
return isFunction(format) ? format.bind($$.api) : format;
|
|
17016
17073
|
},
|
|
17017
|
-
getArcTitle: function () {
|
|
17018
|
-
var $$ = this;
|
|
17019
|
-
var type = ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge");
|
|
17020
|
-
return type ? $$.config["".concat(type, "_title")] : "";
|
|
17021
|
-
},
|
|
17022
17074
|
updateTargetsForArc: function (targets) {
|
|
17023
17075
|
var $$ = this;
|
|
17024
17076
|
var $el = $$.$el;
|
|
@@ -17057,20 +17109,55 @@ var shapeArc = {
|
|
|
17057
17109
|
},
|
|
17058
17110
|
/**
|
|
17059
17111
|
* Set arc title text
|
|
17112
|
+
* @param {string} str Title text
|
|
17060
17113
|
* @private
|
|
17061
17114
|
*/
|
|
17062
|
-
setArcTitle: function () {
|
|
17115
|
+
setArcTitle: function (str) {
|
|
17063
17116
|
var $$ = this;
|
|
17064
|
-
var title = $$.getArcTitle();
|
|
17117
|
+
var title = str || $$.getArcTitle();
|
|
17065
17118
|
var hasGauge = $$.hasType("gauge");
|
|
17066
17119
|
if (title) {
|
|
17067
|
-
var
|
|
17068
|
-
|
|
17069
|
-
|
|
17120
|
+
var className = hasGauge ? $GAUGE.chartArcsGaugeTitle : $ARC.chartArcsTitle;
|
|
17121
|
+
var text = $$.$el.arcs.select(".".concat(className));
|
|
17122
|
+
if (text.empty()) {
|
|
17123
|
+
text = $$.$el.arcs.append("text")
|
|
17124
|
+
.attr("class", className)
|
|
17125
|
+
.style("text-anchor", "middle");
|
|
17126
|
+
}
|
|
17070
17127
|
hasGauge && text.attr("dy", "-0.3em");
|
|
17071
17128
|
setTextValue(text, title, hasGauge ? undefined : [-0.6, 1.35], true);
|
|
17072
17129
|
}
|
|
17073
17130
|
},
|
|
17131
|
+
/**
|
|
17132
|
+
* Return arc title text
|
|
17133
|
+
* @returns {string} Arc title text
|
|
17134
|
+
* @private
|
|
17135
|
+
*/
|
|
17136
|
+
getArcTitle: function () {
|
|
17137
|
+
var $$ = this;
|
|
17138
|
+
var type = ($$.hasType("donut") && "donut") || ($$.hasType("gauge") && "gauge");
|
|
17139
|
+
return type ? $$.config["".concat(type, "_title")] : "";
|
|
17140
|
+
},
|
|
17141
|
+
/**
|
|
17142
|
+
* Get arc title text with needle value
|
|
17143
|
+
* @returns {string|boolean} When title contains needle template string will return processed string, otherwise false
|
|
17144
|
+
* @private
|
|
17145
|
+
*/
|
|
17146
|
+
getArcTitleWithNeedleValue: function () {
|
|
17147
|
+
var $$ = this;
|
|
17148
|
+
var config = $$.config, state = $$.state;
|
|
17149
|
+
var title = $$.getArcTitle();
|
|
17150
|
+
if (title && $$.config.arc_needle_show && /{=[A-Z_]+}/.test(title)) {
|
|
17151
|
+
var value = state.current.needle;
|
|
17152
|
+
if (!isNumber(value)) {
|
|
17153
|
+
value = config.arc_needle_value;
|
|
17154
|
+
}
|
|
17155
|
+
return tplProcess(title, {
|
|
17156
|
+
NEEDLE_VALUE: isNumber(value) ? value : 0
|
|
17157
|
+
});
|
|
17158
|
+
}
|
|
17159
|
+
return false;
|
|
17160
|
+
},
|
|
17074
17161
|
redrawArc: function (duration, durationForExit, withTransform) {
|
|
17075
17162
|
var $$ = this;
|
|
17076
17163
|
var config = $$.config, state = $$.state, main = $$.$el.main;
|
|
@@ -17158,8 +17245,101 @@ var shapeArc = {
|
|
|
17158
17245
|
hasInteraction && $$.bindArcEvent(mainArc);
|
|
17159
17246
|
$$.hasType("polar") && $$.redrawPolar();
|
|
17160
17247
|
$$.hasType("gauge") && $$.redrawBackgroundArcs();
|
|
17248
|
+
config.arc_needle_show && $$.redrawNeedle();
|
|
17161
17249
|
$$.redrawArcText(duration);
|
|
17162
17250
|
},
|
|
17251
|
+
/**
|
|
17252
|
+
* Update needle element
|
|
17253
|
+
* @private
|
|
17254
|
+
*/
|
|
17255
|
+
redrawNeedle: function () {
|
|
17256
|
+
var $$ = this;
|
|
17257
|
+
var $el = $$.$el, config = $$.config, _a = $$.state, hiddenTargetIds = _a.hiddenTargetIds, radius = _a.radius;
|
|
17258
|
+
var length = (radius - 1) / 100 * config.arc_needle_length;
|
|
17259
|
+
var hasDataToShow = hiddenTargetIds.length !== $$.data.targets.length;
|
|
17260
|
+
var needle = $$.$el.arcs.select(".".concat($ARC.needle));
|
|
17261
|
+
// needle options
|
|
17262
|
+
var pathFn = config.arc_needle_path;
|
|
17263
|
+
var baseWidth = config.arc_needle_bottom_width / 2;
|
|
17264
|
+
var topWidth = config.arc_needle_top_width / 2;
|
|
17265
|
+
var topRx = config.arc_needle_top_rx;
|
|
17266
|
+
var topRy = config.arc_needle_top_ry;
|
|
17267
|
+
var bottomLen = config.arc_needle_bottom_len;
|
|
17268
|
+
var bottomRx = config.arc_needle_bottom_rx;
|
|
17269
|
+
var bottomRy = config.arc_needle_bottom_ry;
|
|
17270
|
+
var needleAngle = $$.getNeedleAngle();
|
|
17271
|
+
var updateNeedleValue = function () {
|
|
17272
|
+
var title = $$.getArcTitleWithNeedleValue();
|
|
17273
|
+
title && $$.setArcTitle(title);
|
|
17274
|
+
};
|
|
17275
|
+
updateNeedleValue();
|
|
17276
|
+
if (needle.empty()) {
|
|
17277
|
+
needle = $el.arcs
|
|
17278
|
+
.append("path")
|
|
17279
|
+
.classed($ARC.needle, true);
|
|
17280
|
+
$el.needle = needle;
|
|
17281
|
+
/**
|
|
17282
|
+
* Function to be exposed as public to facilitate updating needle
|
|
17283
|
+
* @param {number} v Value to be updated
|
|
17284
|
+
* @param {boolean} updateConfig Weather update config's value
|
|
17285
|
+
* @private
|
|
17286
|
+
*/
|
|
17287
|
+
$el.needle.updateHelper = function (v, updateConfig) {
|
|
17288
|
+
if (updateConfig === void 0) { updateConfig = false; }
|
|
17289
|
+
if ($el.needle.style("display") !== "none") {
|
|
17290
|
+
$$.$T($el.needle)
|
|
17291
|
+
.style("transform", "rotate(".concat($$.getNeedleAngle(v), "deg)"))
|
|
17292
|
+
.call(endall, function () {
|
|
17293
|
+
updateConfig && (config.arc_needle_value = v);
|
|
17294
|
+
updateNeedleValue();
|
|
17295
|
+
});
|
|
17296
|
+
}
|
|
17297
|
+
};
|
|
17298
|
+
}
|
|
17299
|
+
if (hasDataToShow) {
|
|
17300
|
+
var path = isFunction(pathFn) ?
|
|
17301
|
+
pathFn.call($$, length) :
|
|
17302
|
+
"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");
|
|
17303
|
+
$$.$T(needle)
|
|
17304
|
+
.attr("d", path)
|
|
17305
|
+
.style("fill", config.arc_needle_color)
|
|
17306
|
+
.style("display", null)
|
|
17307
|
+
.style("transform", "rotate(".concat(needleAngle, "deg)"));
|
|
17308
|
+
}
|
|
17309
|
+
else {
|
|
17310
|
+
needle.style("display", "none");
|
|
17311
|
+
}
|
|
17312
|
+
},
|
|
17313
|
+
/**
|
|
17314
|
+
* Get needle angle value relative given value
|
|
17315
|
+
* @param {number} v Value to be calculated angle
|
|
17316
|
+
* @returns {number} angle value
|
|
17317
|
+
* @private
|
|
17318
|
+
*/
|
|
17319
|
+
getNeedleAngle: function (v) {
|
|
17320
|
+
var $$ = this;
|
|
17321
|
+
var config = $$.config, state = $$.state;
|
|
17322
|
+
var arcLength = $$.getArcLength();
|
|
17323
|
+
var hasGauge = $$.hasType("gauge");
|
|
17324
|
+
var total = $$.getTotalDataSum(true);
|
|
17325
|
+
var value = isDefined(v) ? v : config.arc_needle_value;
|
|
17326
|
+
var startingAngle = config["".concat(config.data_type, "_startingAngle")] || 0;
|
|
17327
|
+
var radian = 0;
|
|
17328
|
+
if (!isNumber(value)) {
|
|
17329
|
+
value = hasGauge && $$.data.targets.length === 1 ? total : 0;
|
|
17330
|
+
}
|
|
17331
|
+
state.current.needle = value;
|
|
17332
|
+
if (hasGauge) {
|
|
17333
|
+
startingAngle = $$.getGaugeStartAngle();
|
|
17334
|
+
var radius = config.gauge_fullCircle ? arcLength : startingAngle * -2;
|
|
17335
|
+
var min = config.gauge_min, max = config.gauge_max;
|
|
17336
|
+
radian = radius * ((value - min) / (max - min));
|
|
17337
|
+
}
|
|
17338
|
+
else {
|
|
17339
|
+
radian = arcLength * (value / total);
|
|
17340
|
+
}
|
|
17341
|
+
return (startingAngle + radian) * (180 / Math.PI);
|
|
17342
|
+
},
|
|
17163
17343
|
redrawBackgroundArcs: function () {
|
|
17164
17344
|
var $$ = this;
|
|
17165
17345
|
var config = $$.config, state = $$.state;
|
|
@@ -17167,7 +17347,7 @@ var shapeArc = {
|
|
|
17167
17347
|
var isFullCircle = config.gauge_fullCircle;
|
|
17168
17348
|
var showEmptyTextLabel = $$.filterTargetsToShow($$.data.targets).length === 0 &&
|
|
17169
17349
|
!!config.data_empty_label_text;
|
|
17170
|
-
var startAngle = $$.
|
|
17350
|
+
var startAngle = $$.getGaugeStartAngle();
|
|
17171
17351
|
var endAngle = isFullCircle ? startAngle + $$.getArcLength() : startAngle * -1;
|
|
17172
17352
|
var backgroundArc = $$.$el.arcs.select("".concat(hasMultiArcGauge ? "g" : "", ".").concat($ARC.chartArcsBackground));
|
|
17173
17353
|
if (hasMultiArcGauge) {
|
|
@@ -20039,9 +20219,31 @@ var optArc = {
|
|
|
20039
20219
|
* - **NOTE:**
|
|
20040
20220
|
* - Corner radius can't surpass the `(outerRadius - innerRadius) /2` of indicated shape.
|
|
20041
20221
|
* @property {number} [arc.cornerRadius.ratio=0] Set ratio relative of outer radius.
|
|
20222
|
+
* @property {object} [arc.needle] Set needle options.
|
|
20223
|
+
* @property {boolean} [arc.needle.show=false] Show or hide needle.
|
|
20224
|
+
* @property {string} [arc.needle.color] Set needle filled color.
|
|
20225
|
+
* @property {Function} [arc.needle.path] Set custom needle path function.
|
|
20226
|
+
* - **NOTE:**
|
|
20227
|
+
* - The path should be starting from 0,0 (which is center) to top center coordinate.
|
|
20228
|
+
* - The function will receive, `length`{number} parameter which indicating the needle length in pixel relative to radius.
|
|
20229
|
+
* @property {number} [arc.needle.value] Set needle value.
|
|
20230
|
+
* - **NOTE:**
|
|
20231
|
+
* - For single gauge chart, needle will point the data value by default, otherwise will point 0(zero).
|
|
20232
|
+
* @property {number} [arc.needle.length=100] Set needle length in percentages relative to radius.
|
|
20233
|
+
* @property {object} [arc.needle.top] Set needle top options.
|
|
20234
|
+
* @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).
|
|
20235
|
+
* @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).
|
|
20236
|
+
* @property {number} [arc.needle.top.width=0] Set needle top width in pixel.
|
|
20237
|
+
* @property {object} [arc.needle.bottom] Set needle bottom options.
|
|
20238
|
+
* @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).
|
|
20239
|
+
* @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).
|
|
20240
|
+
* @property {number} [arc.needle.bottom.width=15] Set needle bottom width in pixel.
|
|
20241
|
+
* @property {number} [arc.needle.bottom.len=0] Set needle bottom length in pixel. Setting this value, will make bottom larger starting from center.
|
|
20042
20242
|
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutCornerRadius)
|
|
20043
20243
|
* @see [Demo: Gauge corner radius](https://naver.github.io/billboard.js/demo/#GaugeChartOptions.GaugeCornerRadius)
|
|
20044
20244
|
* @see [Demo: Donut corner radius](https://naver.github.io/billboard.js/demo/#PieChartOptions.CornerRadius)
|
|
20245
|
+
* @see [Demo: Donut needle](https://naver.github.io/billboard.js/demo/#DonutChartOptions.DonutNeedle)
|
|
20246
|
+
* @see [Demo: Gauge needle](https://naver.github.io/billboard.js/demo/##GaugeChartOptions.GaugeNeedle)
|
|
20045
20247
|
* @example
|
|
20046
20248
|
* arc: {
|
|
20047
20249
|
* cornerRadius: 12,
|
|
@@ -20060,11 +20262,61 @@ var optArc = {
|
|
|
20060
20262
|
* // set ratio relative of outer radius
|
|
20061
20263
|
* cornerRadius: {
|
|
20062
20264
|
* ratio: 0.5
|
|
20265
|
+
* },
|
|
20266
|
+
*
|
|
20267
|
+
* needle: {
|
|
20268
|
+
* show: true,
|
|
20269
|
+
* color: "red", // any valid CSS color
|
|
20270
|
+
* path: function(length) {
|
|
20271
|
+
* const len = length - 20;
|
|
20272
|
+
*
|
|
20273
|
+
* // will return upper arrow shape path
|
|
20274
|
+
* // Note: The path should begun from '0,0' coordinate to top center.
|
|
20275
|
+
* const path = `M 0 -${len + 20}
|
|
20276
|
+
* L -12 -${len}
|
|
20277
|
+
* L -5 -${len}
|
|
20278
|
+
* L -5 0
|
|
20279
|
+
* A 1 1 0 0 0 5 0
|
|
20280
|
+
* L 5 -${len}
|
|
20281
|
+
* L 12 -${len} Z`;
|
|
20282
|
+
*
|
|
20283
|
+
* return path;
|
|
20284
|
+
* },
|
|
20285
|
+
* value: 40, // will make needle to point value 40.
|
|
20286
|
+
* length: 80, // needle length in percentages relative to radius.
|
|
20287
|
+
*
|
|
20288
|
+
* top: {
|
|
20289
|
+
* // rx and ry are the two radii of the ellipse;
|
|
20290
|
+
* // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
|
|
20291
|
+
* rx: 1,
|
|
20292
|
+
* ry: 1,
|
|
20293
|
+
* width: 5
|
|
20294
|
+
* },
|
|
20295
|
+
* bottom: {
|
|
20296
|
+
* // rx and ry are the two radii of the ellipse;
|
|
20297
|
+
* // https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#elliptical_arc_curve
|
|
20298
|
+
* rx: 1,
|
|
20299
|
+
* ry: 1,
|
|
20300
|
+
* width: 10
|
|
20301
|
+
* len: 10
|
|
20302
|
+
* }
|
|
20063
20303
|
* }
|
|
20064
20304
|
* }
|
|
20065
20305
|
*/
|
|
20066
20306
|
arc_cornerRadius: 0,
|
|
20067
|
-
arc_cornerRadius_ratio: 0
|
|
20307
|
+
arc_cornerRadius_ratio: 0,
|
|
20308
|
+
arc_needle_show: false,
|
|
20309
|
+
arc_needle_color: undefined,
|
|
20310
|
+
arc_needle_value: undefined,
|
|
20311
|
+
arc_needle_path: undefined,
|
|
20312
|
+
arc_needle_length: 100,
|
|
20313
|
+
arc_needle_top_rx: 0,
|
|
20314
|
+
arc_needle_top_ry: 0,
|
|
20315
|
+
arc_needle_top_width: 0,
|
|
20316
|
+
arc_needle_bottom_rx: 1,
|
|
20317
|
+
arc_needle_bottom_ry: 1,
|
|
20318
|
+
arc_needle_bottom_width: 15,
|
|
20319
|
+
arc_needle_bottom_len: 0
|
|
20068
20320
|
};
|
|
20069
20321
|
|
|
20070
20322
|
/**
|
|
@@ -20090,6 +20342,8 @@ var optDonut = {
|
|
|
20090
20342
|
* @property {number} [donut.expand.duration=50] Set expand transition time in ms.
|
|
20091
20343
|
* @property {number} [donut.width] Set width of donut chart.
|
|
20092
20344
|
* @property {string} [donut.title=""] Set title of donut chart. Use `\n` character for line break.
|
|
20345
|
+
* - **NOTE:**
|
|
20346
|
+
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
20093
20347
|
* @property {number} [donut.padAngle=0] Set padding between data.
|
|
20094
20348
|
* @property {number} [donut.startingAngle=0] Set starting angle where data draws.
|
|
20095
20349
|
* @example
|
|
@@ -20132,6 +20386,9 @@ var optDonut = {
|
|
|
20132
20386
|
* startingAngle: 1,
|
|
20133
20387
|
* title: "Donut Title"
|
|
20134
20388
|
*
|
|
20389
|
+
* // when 'arc.needle.show=true' is set, can show current needle value.
|
|
20390
|
+
* title: "Needle value:\n{=NEEDLE_VALUE}",
|
|
20391
|
+
*
|
|
20135
20392
|
* // title with line break
|
|
20136
20393
|
* title: "Title1\nTitle2"
|
|
20137
20394
|
* }
|
|
@@ -20197,6 +20454,8 @@ var optGauge = {
|
|
|
20197
20454
|
* - 'arcLength < -100' defaults to -100
|
|
20198
20455
|
* - 'arcLength > 100' defaults to 100
|
|
20199
20456
|
* @property {string} [gauge.title=""] Set title of gauge chart. Use `\n` character for line break.
|
|
20457
|
+
* - **NOTE:**
|
|
20458
|
+
* - When `arc.needle.show=true` is set, special template `{=NEEDLE_VALUE}` can be used inside the title text to show current needle value.
|
|
20200
20459
|
* @property {string} [gauge.units] Set units of the gauge.
|
|
20201
20460
|
* @property {number} [gauge.width] Set width of gauge chart.
|
|
20202
20461
|
* @property {string} [gauge.type="single"] Set type of gauge to be displayed.<br><br>
|
|
@@ -20243,6 +20502,10 @@ var optGauge = {
|
|
|
20243
20502
|
* max: 200,
|
|
20244
20503
|
* type: "single" // or 'multi'
|
|
20245
20504
|
* title: "Title Text",
|
|
20505
|
+
*
|
|
20506
|
+
* // when 'arc.needle.show=true' is set, can show current needle value.
|
|
20507
|
+
* title: "Needle value:\n{=NEEDLE_VALUE}",
|
|
20508
|
+
*
|
|
20246
20509
|
* units: "%",
|
|
20247
20510
|
* width: 10,
|
|
20248
20511
|
* startingAngle: -1 * Math.PI / 2,
|
|
@@ -22280,7 +22543,7 @@ var zoomModule = function () {
|
|
|
22280
22543
|
var defaults = {};
|
|
22281
22544
|
/**
|
|
22282
22545
|
* @namespace bb
|
|
22283
|
-
* @version 3.
|
|
22546
|
+
* @version 3.9.0-next.1
|
|
22284
22547
|
*/
|
|
22285
22548
|
var bb = {
|
|
22286
22549
|
/**
|
|
@@ -22290,7 +22553,7 @@ var bb = {
|
|
|
22290
22553
|
* bb.version; // "1.0.0"
|
|
22291
22554
|
* @memberof bb
|
|
22292
22555
|
*/
|
|
22293
|
-
version: "3.
|
|
22556
|
+
version: "3.9.0-next.1",
|
|
22294
22557
|
/**
|
|
22295
22558
|
* Generate chart
|
|
22296
22559
|
* - **NOTE:** Bear in mind for the possiblity of ***throwing an error***, during the generation when:
|
|
@@ -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.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -104,7 +104,7 @@ var Plugin = /** @class */ (function () {
|
|
|
104
104
|
delete _this[key];
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
|
-
Plugin.version = "3.
|
|
107
|
+
Plugin.version = "3.9.0-next.1";
|
|
108
108
|
return Plugin;
|
|
109
109
|
}());
|
|
110
110
|
var Plugin$1 = Plugin;
|
|
@@ -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.1
|
|
9
9
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
@@ -86,7 +86,8 @@ var $ARC = {
|
|
|
86
86
|
chartArc: "bb-chart-arc",
|
|
87
87
|
chartArcs: "bb-chart-arcs",
|
|
88
88
|
chartArcsBackground: "bb-chart-arcs-background",
|
|
89
|
-
chartArcsTitle: "bb-chart-arcs-title"
|
|
89
|
+
chartArcsTitle: "bb-chart-arcs-title",
|
|
90
|
+
needle: "bb-needle"
|
|
90
91
|
};
|
|
91
92
|
var $AREA = {
|
|
92
93
|
area: "bb-area",
|
|
@@ -278,7 +279,7 @@ var Plugin = /** @class */ (function () {
|
|
|
278
279
|
delete _this[key];
|
|
279
280
|
});
|
|
280
281
|
};
|
|
281
|
-
Plugin.version = "3.
|
|
282
|
+
Plugin.version = "3.9.0-next.1";
|
|
282
283
|
return Plugin;
|
|
283
284
|
}());
|
|
284
285
|
var Plugin$1 = Plugin;
|