From 77f6449db9768190d3b6f847d14a1d24153f91b9 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 1 Mar 2016 00:20:34 -0800 Subject: [PATCH 1/4] Added millisecond detection in series --- public/app/core/time_series2.ts | 10 ++++++++++ public/app/plugins/panel/graph/graph_tooltip.js | 12 +++++++++--- public/app/plugins/panel/graph/module.ts | 3 +++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index ef2e6b9c8b2..abc2a7f5436 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -168,4 +168,14 @@ export default class TimeSeries { formatValue(value) { return this.valueFormater(value, this.decimals, this.scaledDecimals); } + + isMsResolutionNeeded() { + for (var j = 0; j'; diff --git a/public/app/plugins/panel/graph/module.ts b/public/app/plugins/panel/graph/module.ts index 357da9b6877..bf89648b717 100644 --- a/public/app/plugins/panel/graph/module.ts +++ b/public/app/plugins/panel/graph/module.ts @@ -69,6 +69,7 @@ var panelDefaults = { tooltip : { value_type: 'cumulative', shared: true, + msResolution: false, }, // time overrides timeFrom: null, @@ -200,6 +201,8 @@ class GraphCtrl extends MetricsPanelCtrl { } this.datapointsCount += datapoints.length; + + this.panel.tooltip.msResolution = this.panel.tooltip.msResolution || series.isMsResolutionNeeded(); } return series; From 8bc63e902991f732162266303a41a2b786b2db13 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 1 Mar 2016 01:09:14 -0800 Subject: [PATCH 2/4] Added spec tests for millisecond resolution --- public/app/core/time_series2.ts | 4 +- .../panel/graph/specs/graph_ctrl_specs.ts | 55 +++++++++++++++++++ public/test/specs/dashboardSrv-specs.js | 22 ++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index abc2a7f5436..f198be73a37 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -170,8 +170,8 @@ export default class TimeSeries { } isMsResolutionNeeded() { - for (var j = 0; j Date: Tue, 1 Mar 2016 01:15:29 -0800 Subject: [PATCH 3/4] Added some more test for sanity --- .../panel/graph/specs/graph_ctrl_specs.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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 bcd22f00cf8..e46459e2249 100644 --- a/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts +++ b/public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts @@ -98,4 +98,23 @@ describe('GraphCtrl', function() { }); }); + describe('msResolution with millisecond resolution timestamps in one of the series', function() { + beforeEach(function() { + ctx.datasource.query = sinon.stub().returns(ctx.$q.when({ + 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]]} + ] + })); + ctx.ctrl.panel.tooltip.msResolution = false; + ctx.ctrl.refreshData(ctx.datasource); + ctx.scope.$digest(); + }); + + it('should show millisecond resolution tooltip', function() { + expect(ctx.ctrl.panel.tooltip.msResolution).to.be(true); + }); + }); + }); From 75541b9cf07ca2686a857801cc2805e309b7b5c1 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 1 Mar 2016 01:27:14 -0800 Subject: [PATCH 4/4] Optimized msResolution func performation --- public/app/core/time_series2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/app/core/time_series2.ts b/public/app/core/time_series2.ts index f198be73a37..fef4efdd373 100644 --- a/public/app/core/time_series2.ts +++ b/public/app/core/time_series2.ts @@ -172,7 +172,7 @@ export default class TimeSeries { isMsResolutionNeeded() { for (var i = 0; i