[Plot] Ignore empty lines

Ignore empty lines (plot lines with no data) when determining
domain extrema; avoids failure to draw multiple plot lines in
a telemetry panel, nasa/openmctweb#150.
This commit is contained in:
Victor Woeltjen 2015-10-23 13:04:06 -07:00
parent 59f094763b
commit 29bdc9d574
2 changed files with 35 additions and 1 deletions

View File

@ -159,7 +159,9 @@ define(
// Update dimensions and origin based on extrema of plots // Update dimensions and origin based on extrema of plots
PlotUpdater.prototype.updateBounds = function () { PlotUpdater.prototype.updateBounds = function () {
var bufferArray = this.bufferArray, var bufferArray = this.bufferArray.filter(function (lineBuffer) {
return lineBuffer.getLength() > 0; // Ignore empty lines
}),
priorDomainOrigin = this.origin[0], priorDomainOrigin = this.origin[0],
priorDomainDimensions = this.dimensions[0]; priorDomainDimensions = this.dimensions[0];

View File

@ -202,6 +202,38 @@ define(
expect(updater.getDimensions()[1]).toBeGreaterThan(20); expect(updater.getDimensions()[1]).toBeGreaterThan(20);
}); });
describe("when no data is initially available", function () {
beforeEach(function () {
testDomainValues = {};
testRangeValues = {};
updater = new PlotUpdater(
mockSubscription,
testDomain,
testRange,
1350 // Smaller max size for easier testing
);
});
it("has no line data", function () {
// Either no lines, or empty lines are fine
expect(updater.getLineBuffers().map(function (lineBuffer) {
return lineBuffer.getLength();
}).reduce(function (a, b) {
return a + b;
}, 0)).toEqual(0);
});
it("determines initial domain bounds from first available data", function () {
testDomainValues.a = 123;
testRangeValues.a = 456;
updater.update();
expect(updater.getOrigin()[0]).toEqual(jasmine.any(Number));
expect(updater.getOrigin()[1]).toEqual(jasmine.any(Number));
expect(isNaN(updater.getOrigin()[0])).toBeFalsy();
expect(isNaN(updater.getOrigin()[1])).toBeFalsy();
});
});
}); });
} }
); );