Skip to content

Commit

Permalink
Singlestat: Use decimal override when manually specified (#16451)
Browse files Browse the repository at this point in the history
Fixes #16373

(cherry picked from commit b46b84f)
  • Loading branch information
torkelo committed Apr 9, 2019
1 parent a2236de commit be84bff
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions public/app/plugins/panel/singlestat/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ class SingleStatCtrl extends MetricsPanelCtrl {
data.value = 0;
data.valueRounded = 0;
} else {
const decimalInfo = getDecimalsForValue(data.value);
const decimalInfo = getDecimalsForValue(data.value, this.panel.decimals);
const formatFunc = getValueFormat(this.panel.format);

data.valueFormatted = formatFunc(
datapoint[this.panel.tableColumn],
decimalInfo.decimals,
decimalInfo.scaledDecimals
);
data.valueRounded = kbn.roundValue(data.value, this.panel.decimals || 0);
data.valueRounded = kbn.roundValue(data.value, decimalInfo.decimals);
}

this.setValueMapping(data);
Expand Down Expand Up @@ -279,17 +279,15 @@ class SingleStatCtrl extends MetricsPanelCtrl {
data.value = this.series[0].stats[this.panel.valueName];
data.flotpairs = this.series[0].flotpairs;

let decimals = this.panel.decimals;
let scaledDecimals = 0;
const decimalInfo = getDecimalsForValue(data.value, this.panel.decimals);

if (!this.panel.decimals) {
const decimalInfo = getDecimalsForValue(data.value);
decimals = decimalInfo.decimals;
scaledDecimals = decimalInfo.scaledDecimals;
}

data.valueFormatted = formatFunc(data.value, decimals, scaledDecimals, this.dashboard.isTimezoneUtc());
data.valueRounded = kbn.roundValue(data.value, decimals);
data.valueFormatted = formatFunc(
data.value,
decimalInfo.decimals,
decimalInfo.scaledDecimals,
this.dashboard.isTimezoneUtc()
);
data.valueRounded = kbn.roundValue(data.value, decimalInfo.decimals);
}

// Add $__name variable for using in prefix or postfix
Expand Down

0 comments on commit be84bff

Please sign in to comment.