Sfoglia il codice sorgente

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

bergquist 9 anni fa
parent
commit
98e756e278
2 ha cambiato i file con 25 aggiunte e 5 eliminazioni
  1. 5 3
      public/app/core/time_series2.ts
  2. 20 2
      public/test/core/time_series_specs.js

+ 5 - 3
public/app/core/time_series2.ts

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

+ 20 - 2
public/test/core/time_series_specs.js

@@ -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([
       });
 
     });
-
   });
-
 });