From 8a0d5aa38d6bb2c8591be10ecdd10a1466120a5f Mon Sep 17 00:00:00 2001 From: Utkarsh Bhatnagar Date: Mon, 23 May 2016 11:58:21 -0700 Subject: [PATCH] [Bug Fix] #5136 (#5142) --- public/app/core/time_series2.ts | 4 ++-- .../panel/graph/specs/graph_ctrl_specs.ts | 18 +++++++++--------- public/test/core/time_series_specs.js | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index cbceff7afd8..dfae26fb48b 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -173,8 +173,8 @@ 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 (this.datapoints[i][1] !== null) { + var timestamp = this.datapoints[i][1].toString(); if (timestamp.length === 13 && (timestamp % 1000) !== 0) { return true; } diff --git a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts index dfce4031772..d00c90ae6a1 100644 --- a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts @@ -22,8 +22,8 @@ describe('GraphCtrl', function() { describe('msResolution with second resolution timestamps', function() { beforeEach(function() { var data = [ - { target: 'test.cpu1', datapoints: [[1234567890, 45], [1234567899, 60]]}, - { target: 'test.cpu2', datapoints: [[1236547890, 55], [1234456709, 90]]} + { target: 'test.cpu1', datapoints: [[45, 1234567890], [60, 1234567899]]}, + { target: 'test.cpu2', datapoints: [[55, 1236547890], [90, 1234456709]]} ]; ctx.ctrl.panel.tooltip.msResolution = false; ctx.ctrl.onDataReceived(data); @@ -37,8 +37,8 @@ describe('GraphCtrl', function() { describe('msResolution with millisecond resolution timestamps', function() { beforeEach(function() { var data = [ - { target: 'test.cpu1', datapoints: [[1234567890000, 45], [1234567899000, 60]]}, - { target: 'test.cpu2', datapoints: [[1236547890001, 55], [1234456709000, 90]]} + { target: 'test.cpu1', datapoints: [[45, 1234567890000], [60, 1234567899000]]}, + { target: 'test.cpu2', datapoints: [[55, 1236547890001], [90, 1234456709000]]} ]; ctx.ctrl.panel.tooltip.msResolution = false; ctx.ctrl.onDataReceived(data); @@ -52,8 +52,8 @@ describe('GraphCtrl', function() { describe('msResolution with millisecond resolution timestamps but with trailing zeroes', function() { beforeEach(function() { var data = [ - { target: 'test.cpu1', datapoints: [[1234567890000, 45], [1234567899000, 60]]}, - { target: 'test.cpu2', datapoints: [[1236547890000, 55], [1234456709000, 90]]} + { target: 'test.cpu1', datapoints: [[45, 1234567890000], [60, 1234567899000]]}, + { target: 'test.cpu2', datapoints: [[55, 1236547890000], [90, 1234456709000]]} ]; ctx.ctrl.panel.tooltip.msResolution = false; ctx.ctrl.onDataReceived(data); @@ -67,9 +67,9 @@ describe('GraphCtrl', function() { describe('msResolution with millisecond resolution timestamps in one of the series', function() { beforeEach(function() { var data = [ - { target: 'test.cpu1', datapoints: [[1234567890000, 45], [1234567899000, 60]]}, - { target: 'test.cpu2', datapoints: [[1236547890010, 55], [1234456709000, 90]]}, - { target: 'test.cpu3', datapoints: [[1236547890000, 65], [1234456709000, 120]]} + { target: 'test.cpu1', datapoints: [[45, 1234567890000], [60, 1234567899000]]}, + { target: 'test.cpu2', datapoints: [[55, 1236547890010], [90, 1234456709000]]}, + { target: 'test.cpu3', datapoints: [[65, 1236547890000], [120, 1234456709000]]} ]; ctx.ctrl.panel.tooltip.msResolution = false; ctx.ctrl.onDataReceived(data); diff --git a/public/test/core/time_series_specs.js b/public/test/core/time_series_specs.js index 9d273c86b94..034e872e2f1 100644 --- a/public/test/core/time_series_specs.js +++ b/public/test/core/time_series_specs.js @@ -56,7 +56,7 @@ define([ }); }); - describe('can detect if serie contains ms precision', function() { + describe('can detect if series contains ms precision', function() { var fakedata; beforeEach(function() { @@ -64,13 +64,13 @@ define([ }); it('missing datapoint with ms precision', function() { - fakedata.datapoints[0] = [1234567890000, 1337]; + fakedata.datapoints[0] = [1337, 1234567890000]; series = new TimeSeries(fakedata); expect(series.isMsResolutionNeeded()).to.be(false); }); it('contains datapoint with ms precision', function() { - fakedata.datapoints[0] = [1236547890001, 1337]; + fakedata.datapoints[0] = [1337, 1236547890001]; series = new TimeSeries(fakedata); expect(series.isMsResolutionNeeded()).to.be(true); });