diff --git a/CHANGELOG.md b/CHANGELOG.md index e7e6df626a5..90a158907f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ - [Issue #877](https://github.com/grafana/grafana/issues/877). Graph: Smart auto decimal precision when using scaled unit formats - [Issue #850](https://github.com/grafana/grafana/issues/850). Graph: Shared tooltip that shows multiple series & crosshair line, thx @toni-moreno +**Fixes** +- [Issue #925](https://github.com/grafana/grafana/issues/925). Graph: bar width calculation fix for some edge cases (bars would render on top of each other) + ======= # 1.8.1 (2014-09-30) diff --git a/src/app/components/timeSeries.js b/src/app/components/timeSeries.js index ab8b9e89041..79032fd69dd 100644 --- a/src/app/components/timeSeries.js +++ b/src/app/components/timeSeries.js @@ -63,8 +63,10 @@ function (_, kbn) { this.yaxis = this.info.yaxis; this.stats.total = 0; - this.stats.max = -212312321312; - this.stats.min = 212312321312; + this.stats.max = Number.MIN_VALUE; + this.stats.min = Number.MAX_VALUE; + this.stats.avg = null; + this.stats.current = null; var ignoreNulls = fillStyle === 'connected'; var nullAsZero = fillStyle === 'null as zero'; @@ -97,10 +99,13 @@ function (_, kbn) { result.push([currentTime * 1000, currentValue]); } - if (result.length >= 2) { - this.stats.timeStep = result[1][0] - result[0][0]; + if (this.datapoints.length >= 2) { + this.stats.timeStep = (this.datapoints[1][1] - this.datapoints[0][1]) * 1000; } + if (this.stats.max === Number.MIN_VALUE) { this.stats.max = null; } + if (this.stats.min === Number.MAX_VALUE) { this.stats.min = null; } + if (result.length) { this.stats.avg = (this.stats.total / result.length); this.stats.current = result[result.length-1][1]; diff --git a/src/app/directives/grafanaGraph.js b/src/app/directives/grafanaGraph.js index 635a287dfa3..e0f6c5fecef 100755 --- a/src/app/directives/grafanaGraph.js +++ b/src/app/directives/grafanaGraph.js @@ -185,7 +185,10 @@ function (angular, $, kbn, moment, _, GraphTooltip) { } if (data.length && data[0].stats.timeStep) { + console.log('timeStep', data[0].stats.timeStep); + console.log('timeStep2', data[1].stats.timeStep); options.series.bars.barWidth = data[0].stats.timeStep / 1.5; + console.log('barWidth', data[1].stats.timeStep); } addTimeAxis(options);