From 0aae78c6bd4a004543924e878f59401e0772569a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 8 Oct 2014 16:24:58 -0400 Subject: [PATCH 1/2] Graph: fix for bars not displaying, caused by change in recent commit, added unit test so it does not happen again --- src/app/components/timeSeries.js | 2 +- src/app/directives/grafanaGraph.js | 4 ++-- src/test/specs/grafanaGraph-specs.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app/components/timeSeries.js b/src/app/components/timeSeries.js index ce8b0b8da40..ab8b9e89041 100644 --- a/src/app/components/timeSeries.js +++ b/src/app/components/timeSeries.js @@ -97,7 +97,7 @@ function (_, kbn) { result.push([currentTime * 1000, currentValue]); } - if (result.length > 2) { + if (result.length >= 2) { this.stats.timeStep = result[1][0] - result[0][0]; } diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index 75aa0999e56..635a287dfa3 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -184,8 +184,8 @@ function (angular, $, kbn, moment, _, GraphTooltip) { } } - if (data.length && data[0].info.timeStep) { - options.series.bars.barWidth = data[0].info.timeStep / 1.5; + if (data.length && data[0].stats.timeStep) { + options.series.bars.barWidth = data[0].stats.timeStep / 1.5; } addTimeAxis(options); diff --git a/src/test/specs/grafanaGraph-specs.js b/src/test/specs/grafanaGraph-specs.js index c5659ba8825..ebd464c0c30 100644 --- a/src/test/specs/grafanaGraph-specs.js +++ b/src/test/specs/grafanaGraph-specs.js @@ -126,6 +126,20 @@ define([ }); }); + graphScenario('should use timeStep for barWidth', function(ctx) { + ctx.setup(function(scope, data) { + scope.panel.bars = true; + data[0] = new TimeSeries({ + datapoints: [[1,10],[2,20]], + info: { alias: 'series1', enable: true } + }); + }); + + it('should set barWidth', function() { + expect(ctx.plotOptions.series.bars.barWidth).to.be(10000/1.5); + }); + }); + graphScenario('series option overrides, fill & points', function(ctx) { ctx.setup(function(scope, data) { scope.panel.lines = true; From 920e5c93e1360efb6c1bd93ddc2a1ef35b2bcd5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 8 Oct 2014 17:00:07 -0400 Subject: [PATCH 2/2] Graph: tooltip fix for single series tooltip and right floated value being pushed down --- src/app/directives/grafanaGraph.tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/directives/grafanaGraph.tooltip.js b/src/app/directives/grafanaGraph.tooltip.js index 3e263a392de..aa5b2abfa42 100644 --- a/src/app/directives/grafanaGraph.tooltip.js +++ b/src/app/directives/grafanaGraph.tooltip.js @@ -161,7 +161,7 @@ function ($) { value = series.formatValue(value); timestamp = dashboard.formatDate(item.datapoint[0]); - group += ': ' + value + ''; + group += ': ' + value + '
'; self.showTooltip(timestamp, group, pos); }