Przeglądaj źródła

Small changes to log scale handling, #452

Torkel Ödegaard 10 lat temu
rodzic
commit
a8363f02b8

+ 2 - 2
src/app/panels/graph/axisEditor.html

@@ -34,7 +34,7 @@
 					Scale type
 				</li>
 				<li>
-					<select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.leftScale" ng-options="v as k for (k, v) in scaleTypes" ng-change="render()"></select>
+					<select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.leftLogBase" ng-options="v as k for (k, v) in logScales" ng-change="render()"></select>
 				</li>
 				<li class="tight-form-item">
 					Label
@@ -79,7 +79,7 @@
 					Scale type
 				</li>
 				<li>
-					<select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.rightScale" ng-options="v as k for (k, v) in scaleTypes" ng-change="render()"></select>
+					<select class="input-small tight-form-input" style="width: 113px" ng-model="panel.grid.rightLogBase" ng-options="v as k for (k, v) in logScales" ng-change="render()"></select>
 				</li>
 				<li class="tight-form-item">
 					Label

+ 8 - 7
src/app/panels/graph/graph.js

@@ -351,7 +351,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
             show: scope.panel['y-axis'],
             min: scope.panel.grid.leftMin,
             index: 1,
-            scale: scope.panel.grid.leftScale,
+            logBase: scope.panel.grid.leftLogBase,
             max: scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.leftMax,
           };
 
@@ -360,7 +360,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
           if (_.findWhere(data, {yaxis: 2})) {
             var secondY = _.clone(defaults);
             secondY.index = 2,
-            secondY.scale = scope.panel.grid.rightScale;
+            secondY.logBase = scope.panel.grid.rightLogBase;
             secondY.position = 'right';
             secondY.min = scope.panel.grid.rightMin;
             secondY.max = scope.panel.percentage && scope.panel.stack ? 100 : scope.panel.grid.rightMax;
@@ -375,7 +375,7 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
         }
 
         function applyLogScale(axis, data) {
-          if (axis.scale !== 2) {
+          if (axis.logBase !== 10) {
             return;
           }
 
@@ -393,22 +393,23 @@ function (angular, $, kbn, moment, _, GraphTooltip) {
             }
 
             if (max === null) {
-              max = 10000000000;
+              max = Number.MAX_VALUE;
             }
           }
 
-          axis.ticks = [0, 1];
+          axis.min = axis.min !== null ? axis.min : 1;
+          axis.ticks = [1];
           var tick = 1;
 
           while (true) {
-            tick = tick*10;
+            tick = tick * axis.logBase;
             axis.ticks.push(tick);
             if (tick > max) {
               break;
             }
           }
 
-          axis.transform = function(v) { return Math.log(v+0.1); };
+          axis.transform = function(v) { return Math.log(v+0.001); };
           axis.inverseTransform  = function (v) { return Math.pow(10,v); };
         }
 

+ 3 - 3
src/app/panels/graph/module.js

@@ -53,12 +53,12 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
       y_formats    : ['short', 'short'],
       // grid options
       grid          : {
-        leftScale: 1,
+        leftLogBase: 1,
         leftMax: null,
         rightMax: null,
         leftMin: null,
         rightMin: null,
-        rightScale: 1,
+        rightLogBase: 1,
         threshold1: null,
         threshold2: null,
         threshold1Color: 'rgba(216, 200, 27, 0.27)',
@@ -116,7 +116,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) {
     _.defaults($scope.panel.grid, _d.grid);
     _.defaults($scope.panel.legend, _d.legend);
 
-    $scope.scaleTypes = {'linear': 1, 'log (base 10)': 2};
+    $scope.logScales = {'linear': 1, 'log (base 10)': 10};
 
     $scope.hiddenSeries = {};
     $scope.seriesList = [];

+ 0 - 4
src/css/less/tightform.less

@@ -5,10 +5,6 @@
   background: @grafanaTargetBackground;
   width: 100%;
 
-  .dropdown {
-    padding: 0; margin: 0;
-  }
-
   &:last-child, &.last {
     border-bottom: 1px solid @grafanaTargetBorder;
   }