StateTimeline: Support hideFrom field config (#68586)

pull/68601/head
Ryan McKinley 2 years ago committed by GitHub
parent 160e207e47
commit 2e7b77a94a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .yarn/sdks/prettier/package.json
  2. 20
      public/app/core/components/TimelineChart/utils.ts
  3. 2
      public/app/plugins/panel/state-timeline/module.tsx
  4. 2
      public/app/plugins/panel/status-history/module.tsx

@ -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…
Cancel
Save