Skip to content

Commit 74f289c

Browse files
committed
Merge pull request #206 from nasa/open150b
[Plot] Ignore empty lines
2 parents 4ec243c + 29bdc9d commit 74f289c

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

platform/features/plot/src/elements/PlotUpdater.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ define(
159159

160160
// Update dimensions and origin based on extrema of plots
161161
PlotUpdater.prototype.updateBounds = function () {
162-
var bufferArray = this.bufferArray,
162+
var bufferArray = this.bufferArray.filter(function (lineBuffer) {
163+
return lineBuffer.getLength() > 0; // Ignore empty lines
164+
}),
163165
priorDomainOrigin = this.origin[0],
164166
priorDomainDimensions = this.dimensions[0];
165167

platform/features/plot/test/elements/PlotUpdaterSpec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,38 @@ define(
202202
expect(updater.getDimensions()[1]).toBeGreaterThan(20);
203203
});
204204

205+
describe("when no data is initially available", function () {
206+
beforeEach(function () {
207+
testDomainValues = {};
208+
testRangeValues = {};
209+
updater = new PlotUpdater(
210+
mockSubscription,
211+
testDomain,
212+
testRange,
213+
1350 // Smaller max size for easier testing
214+
);
215+
});
216+
217+
it("has no line data", function () {
218+
// Either no lines, or empty lines are fine
219+
expect(updater.getLineBuffers().map(function (lineBuffer) {
220+
return lineBuffer.getLength();
221+
}).reduce(function (a, b) {
222+
return a + b;
223+
}, 0)).toEqual(0);
224+
});
225+
226+
it("determines initial domain bounds from first available data", function () {
227+
testDomainValues.a = 123;
228+
testRangeValues.a = 456;
229+
updater.update();
230+
expect(updater.getOrigin()[0]).toEqual(jasmine.any(Number));
231+
expect(updater.getOrigin()[1]).toEqual(jasmine.any(Number));
232+
expect(isNaN(updater.getOrigin()[0])).toBeFalsy();
233+
expect(isNaN(updater.getOrigin()[1])).toBeFalsy();
234+
});
235+
});
236+
205237
});
206238
}
207239
);

0 commit comments

Comments
 (0)