Merge branch 'ent-1365-graficas-gauge-no-muestran-umbrales-menores-a-1' into 'develop'

Fixed lower than 1 values on gauges

See merge request artica/pandorafms!974
This commit is contained in:
vgilc 2017-10-31 12:52:51 +01:00
commit 62b4ed9b2d
1 changed files with 17 additions and 9 deletions

View File

@ -1037,19 +1037,19 @@ function createGauges(data, width, height, font_size, no_data_image, font) {
label = label.replace(/(/g,'\('); label = label.replace(/(/g,'\(');
label = label.replace(/)/g,'\)'); label = label.replace(/)/g,'\)');
minimun_warning = parseFloat( data[key].min_warning ); minimun_warning = round_with_decimals(parseFloat( data[key].min_warning ));
maximun_warning = parseFloat( data[key].max_warning ); maximun_warning = round_with_decimals(parseFloat( data[key].max_warning ));
minimun_critical = parseFloat( data[key].min_critical ); minimun_critical = round_with_decimals(parseFloat( data[key].min_critical ));
maximun_critical = parseFloat( data[key].max_critical ); maximun_critical = round_with_decimals(parseFloat( data[key].max_critical ));
mininum = parseFloat(data[key].min); mininum = round_with_decimals(parseFloat(data[key].min));
maxinum = parseFloat(data[key].max); maxinum = round_with_decimals(parseFloat(data[key].max));
critical_inverse = parseInt(data[key].critical_inverse); critical_inverse = parseInt(data[key].critical_inverse);
warning_inverse = parseInt(data[key].warning_inverse); warning_inverse = parseInt(data[key].warning_inverse);
valor = parseFloat(data[key].value); valor = round_with_decimals(data[key].value);
if (isNaN(valor)) if (isNaN(valor))
valor = null; valor = null;
createGauge(nombre, label, valor, mininum, maxinum, createGauge(nombre, label, valor, mininum, maxinum,
@ -1281,7 +1281,7 @@ function Gauge(placeholderName, configuration, font)
{ {
var pointerContainer = this.body.select(".pointerContainer"); 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"); var pointer = pointerContainer.selectAll("path");
pointer.transition() pointer.transition()
@ -1494,6 +1494,14 @@ function print_phases_donut (recipient, phases) {
} }
} }
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);
}
function progress_bar_d3 (recipient, percentile, width, height, color, unit, label, label_color) { function progress_bar_d3 (recipient, percentile, width, height, color, unit, label, label_color) {
var startPercent = 0; var startPercent = 0;
var endPercent = parseInt(percentile) / 100; var endPercent = parseInt(percentile) / 100;