Heatmap: use the standard unit picker component (#26751)

This commit is contained in:
Ryan McKinley 2020-08-03 09:01:38 -07:00 committed by GitHub
parent df11cdad62
commit a532f463c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 13 deletions

View File

@ -1,8 +1,6 @@
import kbn from 'app/core/utils/kbn';
export class AxesEditorCtrl { export class AxesEditorCtrl {
panel: any; panel: any;
panelCtrl: any; panelCtrl: any;
unitFormats: any;
logScales: any; logScales: any;
dataFormats: any; dataFormats: any;
yBucketBoundModes: any; yBucketBoundModes: any;
@ -12,7 +10,6 @@ export class AxesEditorCtrl {
$scope.editor = this; $scope.editor = this;
this.panelCtrl = $scope.ctrl; this.panelCtrl = $scope.ctrl;
this.panel = this.panelCtrl.panel; this.panel = this.panelCtrl.panel;
this.unitFormats = kbn.getUnitFormats();
this.logScales = { this.logScales = {
linear: 1, linear: 1,
@ -35,10 +32,10 @@ export class AxesEditorCtrl {
}; };
} }
setUnitFormat(subItem: any) { setUnitFormat = (unit: string) => {
this.panel.yAxis.format = subItem.value; this.panel.yAxis.format = unit;
this.panelCtrl.render(); this.panelCtrl.render();
} };
} }
/** @ngInject */ /** @ngInject */

View File

@ -3,11 +3,7 @@
<h5 class="section-heading">Y Axis</h5> <h5 class="section-heading">Y Axis</h5>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-8">Unit</label> <label class="gf-form-label width-8">Unit</label>
<div class="gf-form-dropdown-typeahead width-12" <unit-picker onChange="editor.setUnitFormat" value="ctrl.panel.yAxis.format" class="width-12"></unit-picker>
ng-model="ctrl.panel.yAxis.format"
dropdown-typeahead2="editor.unitFormats"
dropdown-typeahead-on-select="editor.setUnitFormat($subItem)">
</div>
</div> </div>
<div ng-if="ctrl.panel.dataFormat == 'timeseries'"> <div ng-if="ctrl.panel.dataFormat == 'timeseries'">
<div class="gf-form"> <div class="gf-form">
@ -51,7 +47,7 @@
<h5 class="section-heading">Buckets</h5> <h5 class="section-heading">Buckets</h5>
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-5">Y Axis</label> <label class="gf-form-label width-4">Y Axis</label>
</div> </div>
<div class="gf-form" ng-show="ctrl.panel.yAxis.logBase === 1"> <div class="gf-form" ng-show="ctrl.panel.yAxis.logBase === 1">
<label class="gf-form-label width-5">Buckets</label> <label class="gf-form-label width-5">Buckets</label>
@ -78,7 +74,7 @@
</div> </div>
<div class="gf-form-inline"> <div class="gf-form-inline">
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-5">X Axis</label> <label class="gf-form-label width-4">X Axis</label>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<label class="gf-form-label width-5">Buckets</label> <label class="gf-form-label width-5">Buckets</label>