mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
StateTimeline: Support hideFrom field config (#68586)
This commit is contained in:
parent
160e207e47
commit
2e7b77a94a
2
.yarn/sdks/prettier/package.json
vendored
2
.yarn/sdks/prettier/package.json
vendored
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "prettier",
|
||||
"version": "2.8.1-sdk",
|
||||
"version": "2.8.4-sdk",
|
||||
"main": "./index.js",
|
||||
"type": "commonjs"
|
||||
}
|
||||
|
@ -444,6 +444,9 @@ export function prepareTimelineFields(
|
||||
|
||||
const fields: Field[] = [];
|
||||
for (let field of nullToValue(nulledFrame).fields) {
|
||||
if (field.config.custom?.hideFrom?.viz) {
|
||||
continue;
|
||||
}
|
||||
switch (field.type) {
|
||||
case FieldType.time:
|
||||
isTimeseries = true;
|
||||
@ -558,6 +561,7 @@ export function getFieldLegendItem(fields: Field[], theme: GrafanaTheme2): VizLe
|
||||
const thresholds = fieldConfig.thresholds;
|
||||
|
||||
// If thresholds are enabled show each step in the legend
|
||||
// This ignores the hide from legend since the range is valid
|
||||
if (colorMode === FieldColorModeId.Thresholds && thresholds?.steps && thresholds.steps.length > 1) {
|
||||
return getThresholdItems(fieldConfig, theme);
|
||||
}
|
||||
@ -567,15 +571,17 @@ export function getFieldLegendItem(fields: Field[], theme: GrafanaTheme2): VizLe
|
||||
return undefined; // eventually a color bar
|
||||
}
|
||||
|
||||
let stateColors: Map<string, string | undefined> = new Map();
|
||||
const stateColors: Map<string, string | undefined> = new Map();
|
||||
|
||||
fields.forEach((field) => {
|
||||
field.values.forEach((v) => {
|
||||
let state = field.display!(v);
|
||||
if (state.color) {
|
||||
stateColors.set(state.text, state.color!);
|
||||
}
|
||||
});
|
||||
if (!field.config.custom?.hideFrom?.legend) {
|
||||
field.values.forEach((v) => {
|
||||
let state = field.display!(v);
|
||||
if (state.color) {
|
||||
stateColors.set(state.text, state.color!);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
stateColors.forEach((color, label) => {
|
||||
|
@ -60,6 +60,8 @@ export const plugin = new PanelPlugin<Options, FieldConfig>(StateTimelinePanel)
|
||||
shouldApply: (f) => f.type !== FieldType.time,
|
||||
process: identityOverrideProcessor,
|
||||
});
|
||||
|
||||
commonOptionsBuilder.addHideFrom(builder);
|
||||
},
|
||||
})
|
||||
.setPanelOptions((builder) => {
|
||||
|
@ -40,6 +40,8 @@ export const plugin = new PanelPlugin<Options, FieldConfig>(StatusHistoryPanel)
|
||||
step: 1,
|
||||
},
|
||||
});
|
||||
|
||||
commonOptionsBuilder.addHideFrom(builder);
|
||||
},
|
||||
})
|
||||
.setPanelOptions((builder) => {
|
||||
|
Loading…
Reference in New Issue
Block a user