Graph: support setting field units (#26529)
(cherry picked from commit ad5f1c953b)
This commit is contained in:
committed by
Leonard Gram
parent
758c47e13f
commit
e44acff11c
@@ -13,7 +13,10 @@
|
||||
|
||||
<div ng-if="yaxis.show">
|
||||
<div class="gf-form gf-form--grow">
|
||||
<label class="gf-form-label width-6">Unit</label>
|
||||
<label class="gf-form-label width-6">
|
||||
Unit
|
||||
<info-popover mode="right-normal">The default unit used when not defined by the datasource or in the Fields or Overrides configuration.</info-popover>
|
||||
</label>
|
||||
<unit-picker onChange="ctrl.setUnitFormat(yaxis)" value="yaxis.format" class="flex-grow-1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -306,6 +306,7 @@ export class GraphCtrl extends MetricsPanelCtrl {
|
||||
for (const series of this.seriesList) {
|
||||
series.applySeriesOverrides(this.panel.seriesOverrides);
|
||||
|
||||
// Always use the configured field unit
|
||||
if (series.unit) {
|
||||
this.panel.yaxes[series.yaxis - 1].format = series.unit;
|
||||
}
|
||||
@@ -379,6 +380,7 @@ export const plugin = new PanelPlugin<GraphPanelOptions, GraphFieldConfig>(null)
|
||||
.useFieldConfig({
|
||||
standardOptions: [
|
||||
FieldConfigProperty.DisplayName,
|
||||
FieldConfigProperty.Unit,
|
||||
FieldConfigProperty.Links, // previously saved as dataLinks on options
|
||||
],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user