Преглед изворни кода

fix(graph): fixed issue with bar width when used in series override, fixes #6528

Torkel Ödegaard пре 9 година
родитељ
комит
71eb0f3278
3 измењених фајлова са 16 додато и 10 уклоњено
  1. 7 2
      CHANGELOG.md
  2. 7 4
      public/app/core/time_series2.ts
  3. 2 4
      public/app/plugins/panel/graph/graph.ts

+ 7 - 2
CHANGELOG.md

@@ -1,4 +1,9 @@
-# 4.0-pre (unreleased)
+# 4.0-beta2 (unrelased)
+
+### Bugfixes
+* **Graph Panel**: Bar width if bars was only used in series override, [#6528](https://github.com/grafana/grafana/issues/6528)
+
+# 4.0-beta1 (2016-11-09)
 
 ### Enhancements
 * **Login**: Adds option to disable username/password logins, closes [#4674](https://github.com/grafana/grafana/issues/4674)
@@ -24,7 +29,7 @@
 * **SystemD**: Change systemd description, closes [#5971](https://github.com/grafana/grafana/pull/5971)
 * **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)
 
-### Bugfixes
+### Bug fixes
 * **Table Panel**: Fixed problem when switching to Mixed datasource in metrics tab, fixes [#5999](https://github.com/grafana/grafana/pull/5999)
 * **Playlist**: Fixed problem with play order not matching order defined in playlist, fixes [#5467](https://github.com/grafana/grafana/pull/5467)
 * **Graph panel**: Fixed problem with auto decimals on y axis when datamin=datamax, fixes [#6070](https://github.com/grafana/grafana/pull/6070)

+ 7 - 4
public/app/core/time_series2.ts

@@ -102,6 +102,7 @@ export default class TimeSeries {
     this.stats.min = Number.MAX_VALUE;
     this.stats.avg = null;
     this.stats.current = null;
+    this.stats.timeStep = Number.MAX_VALUE;
     this.allIsNull = true;
     this.allIsZero = true;
 
@@ -110,6 +111,7 @@ export default class TimeSeries {
     var currentTime;
     var currentValue;
     var nonNulls = 0;
+    var previousTime;
 
     for (var i = 0; i < this.datapoints.length; i++) {
       currentValue = this.datapoints[i][0];
@@ -117,12 +119,13 @@ export default class TimeSeries {
 
       // Due to missing values we could have different timeStep all along the series
       // so we have to find the minimum one (could occur with aggregators such as ZimSum)
-      if (i>0) {
-        var previousTime = this.datapoints[i-1][1];
-        if (!this.stats.timeStep || currentTime - previousTime < this.stats.timeStep) {
-          this.stats.timeStep = currentTime - previousTime;
+      if (previousTime !== undefined) {
+        let timeStep = currentTime - previousTime;
+        if (timeStep < this.stats.timeStep) {
+          this.stats.timeStep = timeStep;
         }
       }
+      previousTime = currentTime;
 
       if (currentValue === null) {
         if (ignoreNulls) { continue; }

+ 2 - 4
public/app/plugins/panel/graph/graph.ts

@@ -186,7 +186,7 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
       // Series could have different timeSteps,
       // let's find the smallest one so that bars are correctly rendered.
       function getMinTimeStepOfSeries(data) {
-        var min = 100000000000;
+        var min = Number.MAX_VALUE;
 
         for (let i = 0; i < data.length; i++) {
           if (!data[i].stats.timeStep) {
@@ -297,9 +297,7 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
             break;
           }
           default: {
-            if (panel.bars) {
-              options.series.bars.barWidth = getMinTimeStepOfSeries(data) / 1.5;
-            }
+            options.series.bars.barWidth = getMinTimeStepOfSeries(data) / 1.5;
             addTimeAxis(options);
             break;
           }