Fixed lower than 1 values on gauges
This commit is contained in:
parent
8fa33a2401
commit
7379243946
|
@ -1037,18 +1037,18 @@ function createGauges(data, width, height, font_size, no_data_image, font) {
|
|||
label = label.replace(/(/g,'\(');
|
||||
label = label.replace(/)/g,'\)');
|
||||
|
||||
minimun_warning = Math.round(parseFloat( data[key].min_warning ),2);
|
||||
maximun_warning = Math.round(parseFloat( data[key].max_warning ),2);
|
||||
minimun_critical = Math.round(parseFloat( data[key].min_critical ),2);
|
||||
maximun_critical = Math.round(parseFloat( data[key].max_critical ),2);
|
||||
minimun_warning = round_with_decimals(parseFloat( data[key].min_warning ));
|
||||
maximun_warning = round_with_decimals(parseFloat( data[key].max_warning ));
|
||||
minimun_critical = round_with_decimals(parseFloat( data[key].min_critical ));
|
||||
maximun_critical = round_with_decimals(parseFloat( data[key].max_critical ));
|
||||
|
||||
mininum = Math.round(parseFloat(data[key].min),2);
|
||||
maxinum = Math.round(parseFloat(data[key].max),2);
|
||||
mininum = round_with_decimals(parseFloat(data[key].min));
|
||||
maxinum = round_with_decimals(parseFloat(data[key].max));
|
||||
|
||||
critical_inverse = parseInt(data[key].critical_inverse);
|
||||
warning_inverse = parseInt(data[key].warning_inverse);
|
||||
|
||||
valor = Math.round(parseFloat(data[key].value),2);
|
||||
valor = round_with_decimals(data[key].value);
|
||||
|
||||
if (isNaN(valor))
|
||||
valor = null;
|
||||
|
@ -1281,7 +1281,7 @@ function Gauge(placeholderName, configuration, font)
|
|||
{
|
||||
var pointerContainer = this.body.select(".pointerContainer");
|
||||
|
||||
pointerContainer.selectAll("text").text(Math.round(value));
|
||||
pointerContainer.selectAll("text").text(round_with_decimals(value));
|
||||
|
||||
var pointer = pointerContainer.selectAll("path");
|
||||
pointer.transition()
|
||||
|
@ -1493,3 +1493,11 @@ function print_phases_donut (recipient, phases) {
|
|||
.remove();
|
||||
}
|
||||
}
|
||||
|
||||
function round_with_decimals (value, multiplier = 1) {
|
||||
if ((value * multiplier) == 0) return 0;
|
||||
if ((value * multiplier) >= 1) {
|
||||
return Math.round(value * multiplier) / multiplier;
|
||||
}
|
||||
return round_with_decimals (value, multiplier * 10);
|
||||
}
|
Loading…
Reference in New Issue