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:
Ryan McKinley
2019-04-10 01:19:44 -07:00
committed by Torkel Ödegaard
parent 06dfbb382b
commit 5e7f7e658d
6 changed files with 81 additions and 40 deletions

View File

@@ -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;
};