Commit c74eda20 by Torkel Ödegaard

Graph: fix for legend values min & max, avg & current when series only has null values, Closes #923

parent c6cb01aa
......@@ -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)
......
......@@ -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];
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment