fix(tooltip): msdetection can now handle null data points

This commit is contained in:
bergquist 2016-03-01 14:10:09 +01:00
parent b6ac0860c6
commit 98e756e278
2 changed files with 25 additions and 5 deletions

View File

@ -171,11 +171,13 @@ export default class TimeSeries {
isMsResolutionNeeded() {
for (var i = 0; i<this.datapoints.length; i++) {
if (this.datapoints[i][0] !== null) {
var timestamp = this.datapoints[i][0].toString();
if (timestamp.length === 13 && (timestamp % 1000) !== 0) {
return true;
}
}
}
return false;
}
}

View File

@ -56,6 +56,26 @@ define([
});
});
describe('can detect if serie contains ms precision', function() {
var fakedata;
beforeEach(function() {
fakedata = testData;
});
it('missing datapoint with ms precision', function() {
fakedata.datapoints[0] = [1234567890000, 1337];
series = new TimeSeries(fakedata);
expect(series.isMsResolutionNeeded()).to.be(false);
});
it('contains datapoint with ms precision', function() {
fakedata.datapoints[0] = [1236547890001, 1337];
series = new TimeSeries(fakedata);
expect(series.isMsResolutionNeeded()).to.be(true);
});
});
describe('series overrides', function() {
var series;
beforeEach(function() {
@ -148,7 +168,5 @@ define([
});
});
});
});