Commit ad5f1c95 by Ryan McKinley Committed by GitHub

Graph: support setting field units (#26529)

parent 43ef052d
......@@ -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>
......
......@@ -305,6 +305,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;
}
......@@ -378,6 +379,7 @@ export const plugin = new PanelPlugin<GraphPanelOptions, GraphFieldConfig>(null)
.useFieldConfig({
standardOptions: [
FieldConfigProperty.DisplayName,
FieldConfigProperty.Unit,
FieldConfigProperty.Links, // previously saved as dataLinks on options
],
})
......
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