mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
[Plot] Expand range to give margin for points
Expand range to give some margin for points near the edge, WTD-1406.
This commit is contained in:
parent
fa8095d5bc
commit
397a545482
@ -31,6 +31,7 @@ define(
|
||||
'use strict';
|
||||
|
||||
var MAX_POINTS = 86400,
|
||||
PADDING_RATIO = 0.10, // Padding percentage for top & bottom
|
||||
INITIAL_SIZE = 675; // 1/128 of MAX_POINTS
|
||||
|
||||
/**
|
||||
@ -135,6 +136,16 @@ define(
|
||||
return extrema[0];
|
||||
}
|
||||
|
||||
// Expand range slightly so points near edges are visible
|
||||
function expandRange() {
|
||||
var padding = PADDING_RATIO * dimensions[1],
|
||||
top;
|
||||
padding = Math.max(padding, 1.0);
|
||||
top = Math.ceil(origin[1] + dimensions[1] + padding / 2);
|
||||
origin[1] = Math.floor(origin[1] - padding / 2);
|
||||
dimensions[1] = top - origin[1];
|
||||
}
|
||||
|
||||
// Update dimensions and origin based on extrema of plots
|
||||
function updateBounds() {
|
||||
if (bufferArray.length > 0) {
|
||||
@ -147,11 +158,13 @@ define(
|
||||
}).reduce(reduceExtrema);
|
||||
|
||||
// Calculate best-fit dimensions
|
||||
dimensions = (rangeExtrema[0] === rangeExtrema[1]) ?
|
||||
[dimensionsOf(domainExtrema), 2.0 ] :
|
||||
[dimensionsOf(domainExtrema), dimensionsOf(rangeExtrema)];
|
||||
dimensions =
|
||||
[dimensionsOf(domainExtrema), dimensionsOf(rangeExtrema)];
|
||||
origin = [originOf(domainExtrema), originOf(rangeExtrema)];
|
||||
|
||||
// Enforce some minimum visible area
|
||||
expandRange();
|
||||
|
||||
// ...then enforce a fixed duration if needed
|
||||
if (fixedDuration !== undefined) {
|
||||
origin[0] = origin[0] + dimensions[0] - fixedDuration;
|
||||
|
@ -187,7 +187,21 @@ define(
|
||||
expect(updater.getDomainOffset()).toBeDefined();
|
||||
});
|
||||
|
||||
it("provides some margin for the range", function () {
|
||||
var mockObject = mockSubscription.getTelemetryObjects()[0];
|
||||
|
||||
mockSeries.getPointCount.andReturn(3);
|
||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
||||
return 1000 + i * 1000;
|
||||
});
|
||||
mockSeries.getRangeValue.andCallFake(function (i) {
|
||||
return 10 + i; // 10, 20, 30
|
||||
});
|
||||
updater.addHistorical(mockObject, mockSeries);
|
||||
expect(updater.getOrigin()[1]).toBeLessThan(10);
|
||||
expect(updater.getDimensions()[1]).toBeGreaterThan(20);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user