Skip to content

Commit 71eb0f3

Browse files
committed
fix(graph): fixed issue with bar width when used in series override, fixes grafana#6528
1 parent 6495ba1 commit 71eb0f3

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
# 4.0-pre (unreleased)
1+
# 4.0-beta2 (unrelased)
2+
3+
### Bugfixes
4+
* **Graph Panel**: Bar width if bars was only used in series override, [#6528](https://github.com/grafana/grafana/issues/6528)
5+
6+
# 4.0-beta1 (2016-11-09)
27

38
### Enhancements
49
* **Login**: Adds option to disable username/password logins, closes [#4674](https://github.com/grafana/grafana/issues/4674)
@@ -24,7 +29,7 @@
2429
* **SystemD**: Change systemd description, closes [#5971](https://github.com/grafana/grafana/pull/5971)
2530
* **lodash upgrade**: Upgraded lodash from 2.4.2 to 4.15.0, this contains a number of breaking changes that could effect plugins. closes [#6021](https://github.com/grafana/grafana/pull/6021)
2631

27-
### Bugfixes
32+
### Bug fixes
2833
* **Table Panel**: Fixed problem when switching to Mixed datasource in metrics tab, fixes [#5999](https://github.com/grafana/grafana/pull/5999)
2934
* **Playlist**: Fixed problem with play order not matching order defined in playlist, fixes [#5467](https://github.com/grafana/grafana/pull/5467)
3035
* **Graph panel**: Fixed problem with auto decimals on y axis when datamin=datamax, fixes [#6070](https://github.com/grafana/grafana/pull/6070)

public/app/core/time_series2.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default class TimeSeries {
102102
this.stats.min = Number.MAX_VALUE;
103103
this.stats.avg = null;
104104
this.stats.current = null;
105+
this.stats.timeStep = Number.MAX_VALUE;
105106
this.allIsNull = true;
106107
this.allIsZero = true;
107108

@@ -110,19 +111,21 @@ export default class TimeSeries {
110111
var currentTime;
111112
var currentValue;
112113
var nonNulls = 0;
114+
var previousTime;
113115

114116
for (var i = 0; i < this.datapoints.length; i++) {
115117
currentValue = this.datapoints[i][0];
116118
currentTime = this.datapoints[i][1];
117119

118120
// Due to missing values we could have different timeStep all along the series
119121
// so we have to find the minimum one (could occur with aggregators such as ZimSum)
120-
if (i>0) {
121-
var previousTime = this.datapoints[i-1][1];
122-
if (!this.stats.timeStep || currentTime - previousTime < this.stats.timeStep) {
123-
this.stats.timeStep = currentTime - previousTime;
122+
if (previousTime !== undefined) {
123+
let timeStep = currentTime - previousTime;
124+
if (timeStep < this.stats.timeStep) {
125+
this.stats.timeStep = timeStep;
124126
}
125127
}
128+
previousTime = currentTime;
126129

127130
if (currentValue === null) {
128131
if (ignoreNulls) { continue; }

public/app/plugins/panel/graph/graph.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
186186
// Series could have different timeSteps,
187187
// let's find the smallest one so that bars are correctly rendered.
188188
function getMinTimeStepOfSeries(data) {
189-
var min = 100000000000;
189+
var min = Number.MAX_VALUE;
190190

191191
for (let i = 0; i < data.length; i++) {
192192
if (!data[i].stats.timeStep) {
@@ -297,9 +297,7 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
297297
break;
298298
}
299299
default: {
300-
if (panel.bars) {
301-
options.series.bars.barWidth = getMinTimeStepOfSeries(data) / 1.5;
302-
}
300+
options.series.bars.barWidth = getMinTimeStepOfSeries(data) / 1.5;
303301
addTimeAxis(options);
304302
break;
305303
}

0 commit comments

Comments
 (0)