Browse Source

Update flot-widget.js

pull/526/head
Igor Kulikov 9 years ago
committed by GitHub
parent
commit
ec6b926219
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      ui/src/app/widget/lib/flot-widget.js

27
ui/src/app/widget/lib/flot-widget.js

@ -238,23 +238,22 @@ export default class TbFlot {
if (this.ticksFormatterFunction) { if (this.ticksFormatterFunction) {
return this.ticksFormatterFunction(value); return this.ticksFormatterFunction(value);
} }
if (angular.isNumber(this.tickDecimals)) {
var factor = this.tickDecimals ? Math.pow(10, this.tickDecimals) : 1, var factor = this.tickDecimals ? Math.pow(10, this.tickDecimals) : 1,
formatted = "" + Math.round(value * factor) / factor; formatted = "" + Math.round(value * factor) / factor;
if (this.tickDecimals != null) { if (this.tickDecimals != null) {
var decimal = formatted.indexOf("."), var decimal = formatted.indexOf("."),
precision = decimal === -1 ? 0 : formatted.length - decimal - 1; precision = decimal === -1 ? 0 : formatted.length - decimal - 1;
if (precision < this.tickDecimals) { if (precision < this.tickDecimals) {
value = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision); formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision);
}
} }
} }
if (this.tickUnits) { if (this.tickUnits) {
value = value + ' ' + this.tickUnits; formatted += ' ' + this.tickUnits;
} }
return value; return formatted;
}; };
this.yaxis.tickFormatter = ctx.yAxisTickFormatter; this.yaxis.tickFormatter = ctx.yAxisTickFormatter;
@ -1445,4 +1444,4 @@ export default class TbFlot {
} }
} }
/* eslint-enable angular/angularelement */ /* eslint-enable angular/angularelement */

Loading…
Cancel
Save