mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Singlestat-v2/Gauge: Show title when repeating (#16477)
* show title in singlestat2 * show title in gauge * use CSS class for emotion * use emotion not scss
This commit is contained in:
committed by
Torkel Ödegaard
parent
06dfbb382b
commit
5e7f7e658d
@@ -55,10 +55,10 @@ export class SingleStatPanel extends PureComponent<PanelProps<SingleStatOptions>
|
||||
const timeColumn = sparkline.show ? getFirstTimeField(series) : -1;
|
||||
|
||||
for (let i = 0; i < series.fields.length; i++) {
|
||||
const column = series.fields[i];
|
||||
const field = series.fields[i];
|
||||
|
||||
// Show all fields that are not 'time'
|
||||
if (column.type === FieldType.number) {
|
||||
if (field.type === FieldType.number) {
|
||||
const stats = calculateStats({
|
||||
series,
|
||||
fieldIndex: i,
|
||||
@@ -69,6 +69,7 @@ export class SingleStatPanel extends PureComponent<PanelProps<SingleStatOptions>
|
||||
const v: SingleStatDisplay = {
|
||||
value: display(stats[stat]),
|
||||
};
|
||||
v.value.title = replaceVariables(field.name);
|
||||
|
||||
const color = v.value.color;
|
||||
if (!colorValue) {
|
||||
@@ -121,6 +122,11 @@ export class SingleStatPanel extends PureComponent<PanelProps<SingleStatOptions>
|
||||
}
|
||||
}
|
||||
|
||||
// Don't show a title if there is only one item
|
||||
if (values.length === 1) {
|
||||
values[0].value.title = null;
|
||||
}
|
||||
|
||||
return values;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user