Procházet zdrojové kódy

Changed the way this feature was activated. And changed tolltip.

ilgizar před 7 roky
rodič
revize
1588295375

+ 8 - 3
public/app/plugins/panel/graph/axes_editor.html

@@ -31,9 +31,14 @@
 				</div>
 			</div>
 
-			<div class="gf-form" ng-show="$index === 1">
-				<label class="gf-form-label width-6">Y-Align</label>
-				<input type="text" class="gf-form-input width-5" placeholder="none" empty-to-null bs-tooltip="'Align values for two Y-axes'" ng-model="yaxis.align" ng-change="ctrl.render()" ng-model-onblur>
+			<div class="gf-form-inline" ng-show="$index === 1">
+				<div class="gf-form">
+					<gf-form-switch class="gf-form" label="Align" tooltip="Align two Y-axes by {{yaxis.alignment ? yaxis.align || 0 : 'value'}}" label-class="width-6" switch-class="width-5" checked="yaxis.alignment" on-change="ctrl.render()"></gf-form-switch>
+				</div>
+				<div class="gf-form" ng-show="yaxis.alignment">
+					<label class="gf-form-label width-6">Value</label>
+					<input type="number" class="gf-form-input width-5" placeholder="0" ng-model="yaxis.align" ng-change="ctrl.render()" ng-model-onblur ng-init="yaxis.align = yaxis.align || 0">
+				</div>
 			</div>
 
 		<div ng-if="yaxis.show">

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

@@ -158,8 +158,9 @@ function graphDirective(timeSrv, popoverSrv, contextSrv) {
 
       function processRangeHook(plot) {
         var yaxis = plot.getYAxes();
-        if (yaxis.length > 1 && 'align' in panel.yaxes[1] && panel.yaxes[1].align !== null) {
-          alignYLevel(yaxis, parseFloat(panel.yaxes[1].align));
+        if (yaxis.length > 1 && panel.yaxes[1].alignment) {
+          var align = panel.yaxes[1].align || 0;
+          alignYLevel(yaxis, parseFloat(align));
         }
       }
 

+ 2 - 1
public/app/plugins/panel/graph/module.ts

@@ -46,7 +46,8 @@ class GraphCtrl extends MetricsPanelCtrl {
         min: null,
         max: null,
         format: 'short',
-        align: null,
+        alignment: false,
+        align: 0,
       },
     ],
     xaxis: {