mirror of
https://github.com/nasa/openmct.git
synced 2025-06-17 22:58:14 +00:00
[Plot] Normalize number of digits
Use consistent number of digits for displayed plot values, to avoid unreadable plot legends due to fix for #778
This commit is contained in:
@ -26,6 +26,8 @@ define(
|
|||||||
function () {
|
function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var DIGITS = 3;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps a `TelemetryFormatter` to provide formats for domain and
|
* Wraps a `TelemetryFormatter` to provide formats for domain and
|
||||||
* range values; provides a single place to track domain/range
|
* range values; provides a single place to track domain/range
|
||||||
@ -63,6 +65,10 @@ define(
|
|||||||
};
|
};
|
||||||
|
|
||||||
PlotTelemetryFormatter.prototype.formatRangeValue = function (value) {
|
PlotTelemetryFormatter.prototype.formatRangeValue = function (value) {
|
||||||
|
if (typeof value === 'number') {
|
||||||
|
return value.toFixed(DIGITS);
|
||||||
|
}
|
||||||
|
|
||||||
return this.telemetryFormatter
|
return this.telemetryFormatter
|
||||||
.formatRangeValue(value, this.rangeFormat);
|
.formatRangeValue(value, this.rangeFormat);
|
||||||
};
|
};
|
||||||
|
@ -55,14 +55,17 @@ define(
|
|||||||
.toHaveBeenCalledWith(12321, domainFormat);
|
.toHaveBeenCalledWith(12321, domainFormat);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes format in formatRangeValue calls", function () {
|
it("includes format in formatRangeValue calls for strings", function () {
|
||||||
mockFormatter.formatRangeValue.andReturn("formatted!");
|
mockFormatter.formatRangeValue.andReturn("formatted!");
|
||||||
expect(formatter.formatRangeValue(12321))
|
expect(formatter.formatRangeValue('foo'))
|
||||||
.toEqual("formatted!");
|
.toEqual("formatted!");
|
||||||
expect(mockFormatter.formatRangeValue)
|
expect(mockFormatter.formatRangeValue)
|
||||||
.toHaveBeenCalledWith(12321, rangeFormat);
|
.toHaveBeenCalledWith('foo', rangeFormat);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("formats numeric values with three fixed digits", function () {
|
||||||
|
expect(formatter.formatRangeValue(10)).toEqual("10.000");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user