Commit 4bdc3a58 by Daniel Lee

graph: fix y-axis decimalTick check. Fixes #9405

parent a7068d83
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-6">Decimals</label> <label class="gf-form-label width-6">Decimals</label>
<input type="number" class="gf-form-input max-width-20" placeholder="auto" bs-tooltip="'Override automatic decimal precision for y-axis'" data-placement="right" ng-model="yaxis.decimals" ng-change="ctrl.render()" ng-model-onblur> <input type="number" class="gf-form-input max-width-20" placeholder="auto" empty-to-null bs-tooltip="'Override automatic decimal precision for y-axis'" data-placement="right" ng-model="yaxis.decimals" ng-change="ctrl.render()" ng-model-onblur>
</div> </div>
<div class="gf-form"> <div class="gf-form">
......
...@@ -497,8 +497,8 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) { ...@@ -497,8 +497,8 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) {
show: panel.yaxes[0].show, show: panel.yaxes[0].show,
index: 1, index: 1,
logBase: panel.yaxes[0].logBase || 1, logBase: panel.yaxes[0].logBase || 1,
min: panel.yaxes[0].min ? _.toNumber(panel.yaxes[0].min) : null, min: parseNumber(panel.yaxes[0].min),
max: panel.yaxes[0].max ? _.toNumber(panel.yaxes[0].max) : null, max: parseNumber(panel.yaxes[0].max),
tickDecimals: panel.yaxes[0].decimals tickDecimals: panel.yaxes[0].decimals
}; };
...@@ -510,9 +510,9 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) { ...@@ -510,9 +510,9 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) {
secondY.show = panel.yaxes[1].show; secondY.show = panel.yaxes[1].show;
secondY.logBase = panel.yaxes[1].logBase || 1; secondY.logBase = panel.yaxes[1].logBase || 1;
secondY.position = 'right'; secondY.position = 'right';
secondY.min = panel.yaxes[1].min ? _.toNumber(panel.yaxes[1].min) : null; secondY.min = parseNumber(panel.yaxes[1].min);
secondY.max = panel.yaxes[1].max ? _.toNumber(panel.yaxes[1].max) : null; secondY.max = parseNumber(panel.yaxes[1].max);
secondY.tickDecimals = panel.yaxes[1].decimals !== null ? _.toNumber(panel.yaxes[1].decimals): null; secondY.tickDecimals = panel.yaxes[1].decimals;
options.yaxes.push(secondY); options.yaxes.push(secondY);
applyLogScale(options.yaxes[1], data); applyLogScale(options.yaxes[1], data);
...@@ -522,6 +522,14 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) { ...@@ -522,6 +522,14 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) {
configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? "percent" : panel.yaxes[0].format); configureAxisMode(options.yaxes[0], panel.percentage && panel.stack ? "percent" : panel.yaxes[0].format);
} }
function parseNumber(value: any) {
if (value === null || typeof value === 'undefined') {
return null;
}
return _.toNumber(value);
}
function applyLogScale(axis, data) { function applyLogScale(axis, data) {
if (axis.logBase === 1) { if (axis.logBase === 1) {
return; return;
......
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