Prometheus: Fixes issue where legend name was replaced with name Value in stat & gauge panels (#35863) (#35905)

(cherry picked from commit 22203fd4df)

Co-authored-by: Torkel Ödegaard <torkel@grafana.org>
This commit is contained in:
Grot (@grafanabot)
2021-06-18 09:19:26 +01:00
committed by GitHub
co-authored by Torkel Ödegaard
parent 3805f72b6a
commit 9ab2fd5ec9
2 changed files with 31 additions and 1 deletions
@@ -411,6 +411,36 @@ describe('FieldDisplay', () => {
expect(result[1].display.title).toEqual('Norway Oslo');
expect(result[1].display.text).toEqual('20');
});
it('When showing all values for field with displayNameFromDS', () => {
const options = createDisplayOptions({
reduceOptions: {
values: true,
calcs: [],
},
fieldConfig: { overrides: [], defaults: {} },
data: [
toDataFrame({
fields: [
{
name: 'Time',
values: [1],
},
{
name: 'Value',
values: [10],
config: {
displayNameFromDS: 'NewName',
},
},
],
}),
],
});
const result = getFieldDisplayValues(options);
expect(result[0].display.title).toEqual('NewName');
});
});
});
@@ -274,7 +274,7 @@ function getSmartDisplayNameForRow(
}
if (otherNumericFields || parts.length === 0) {
parts.push(getFieldDisplayName(field));
parts.push(getFieldDisplayName(field, frame));
}
return parts.join(' ');