diff --git a/packages/grafana-data/src/field/fieldState.ts b/packages/grafana-data/src/field/fieldState.ts index 4750e4b77e0..3ddaebbda63 100644 --- a/packages/grafana-data/src/field/fieldState.ts +++ b/packages/grafana-data/src/field/fieldState.ts @@ -101,16 +101,7 @@ export function decoupleHideFromState(frames: DataFrame[], fieldConfig: FieldCon }; // original with perm overrides - if (field.config.custom !== undefined) { - field.config.custom.hideFrom = hideFrom; - } else { - field.config = { - ...field.config, - custom: { - hideFrom: hideFrom, - }, - }; - } + field.config.custom.hideFrom = hideFrom; }); }); } diff --git a/public/app/core/components/GraphNG/GraphNG.tsx b/public/app/core/components/GraphNG/GraphNG.tsx index 9bccb792e44..63d71bdb395 100644 --- a/public/app/core/components/GraphNG/GraphNG.tsx +++ b/public/app/core/components/GraphNG/GraphNG.tsx @@ -167,12 +167,17 @@ export class GraphNG extends Component { // filter join field and fields.y alignedFrameFinal = { ...alignedFrame, - fields: alignedFrame.fields - .filter((field, i) => i === 0 || fields.y(field, alignedFrame, [alignedFrame])) - .filter((field) => field.config.custom?.hideFrom?.viz !== true), + fields: alignedFrame.fields.filter((field, i) => i === 0 || fields.y(field, alignedFrame, [alignedFrame])), }; } + const nonHiddenFields = alignedFrameFinal.fields.filter((field) => field.config.custom?.hideFrom?.viz !== true); + alignedFrameFinal = { + ...alignedFrameFinal, + fields: nonHiddenFields, + length: nonHiddenFields.length, + }; + let config = this.state?.config; if (withConfig) { diff --git a/public/app/core/components/TimelineChart/utils.test.ts b/public/app/core/components/TimelineChart/utils.test.ts index de4b2080acb..a3c181ef42b 100644 --- a/public/app/core/components/TimelineChart/utils.test.ts +++ b/public/app/core/components/TimelineChart/utils.test.ts @@ -8,7 +8,6 @@ import { DataFrame, fieldMatchers, FieldMatcherID, - FieldConfigSource, } from '@grafana/data'; import { LegendDisplayMode, VizLegendOptions } from '@grafana/schema'; @@ -34,12 +33,6 @@ describe('prepare timeline graph', () => { to: dateTime(3), }, }; - - const fieldConfig: FieldConfigSource = { - defaults: {}, - overrides: [], - }; - it('errors with no time fields', () => { const frames = [ toDataFrame({ @@ -49,7 +42,7 @@ describe('prepare timeline graph', () => { ], }), ]; - const info = prepareTimelineFields(frames, true, timeRange, theme, fieldConfig); + const info = prepareTimelineFields(frames, true, timeRange, theme); expect(info.warn).toEqual('Data does not have a time field'); }); @@ -62,7 +55,7 @@ describe('prepare timeline graph', () => { ], }), ]; - const info = prepareTimelineFields(frames, true, timeRange, theme, fieldConfig); + const info = prepareTimelineFields(frames, true, timeRange, theme); expect(info.warn).toEqual('No graphable fields'); }); @@ -75,7 +68,7 @@ describe('prepare timeline graph', () => { ], }), ]; - const info = prepareTimelineFields(frames, true, timeRange, theme, fieldConfig); + const info = prepareTimelineFields(frames, true, timeRange, theme); expect(info.warn).toBeUndefined(); const out = info.frames![0]; @@ -104,7 +97,7 @@ describe('prepare timeline graph', () => { ], }), ]; - const result = prepareTimelineFields(frames, true, timeRange, theme, fieldConfig); + const result = prepareTimelineFields(frames, true, timeRange, theme); expect(result.frames?.[0].fields[0].values).toEqual([1, 2, 3, 4]); }); @@ -161,7 +154,7 @@ describe('prepare timeline graph', () => { }), ]; - const info = prepareTimelineFields(frames, true, timeRange2, theme, fieldConfig); + const info = prepareTimelineFields(frames, true, timeRange2, theme); let joined = preparePlotFrame( info.frames!, @@ -252,7 +245,7 @@ describe('prepare timeline graph', () => { }), ]; - const info = prepareTimelineFields(frames, true, timeRange2, theme, fieldConfig); + const info = prepareTimelineFields(frames, true, timeRange2, theme); let joined = preparePlotFrame( info.frames!, diff --git a/public/app/core/components/TimelineChart/utils.ts b/public/app/core/components/TimelineChart/utils.ts index d29735703e2..0057b21331d 100644 --- a/public/app/core/components/TimelineChart/utils.ts +++ b/public/app/core/components/TimelineChart/utils.ts @@ -18,9 +18,7 @@ import { outerJoinDataFrames, ValueMapping, ThresholdsConfig, - FieldConfigSource, } from '@grafana/data'; -import { decoupleHideFromState } from '@grafana/data/src/field/fieldState'; import { maybeSortFrame, NULL_RETAIN } from '@grafana/data/src/transformations/transformers/joinDataFrames'; import { applyNullInsertThreshold } from '@grafana/data/src/transformations/transformers/nulls/nullInsertThreshold'; import { nullToValue } from '@grafana/data/src/transformations/transformers/nulls/nullToValue'; @@ -298,15 +296,13 @@ export function prepareTimelineFields( series: DataFrame[] | undefined, mergeValues: boolean, timeRange: TimeRange, - theme: GrafanaTheme2, - fieldConfig: FieldConfigSource + theme: GrafanaTheme2 ): { frames?: DataFrame[]; warn?: string } { if (!series?.length) { return { warn: 'No data in response' }; } cacheFieldDisplayNames(series); - decoupleHideFromState(series, fieldConfig); let hasTimeseries = false; const frames: DataFrame[] = []; diff --git a/public/app/plugins/panel/state-timeline/StateTimelinePanel.tsx b/public/app/plugins/panel/state-timeline/StateTimelinePanel.tsx index c76ca6bcbfd..df2df2c811c 100644 --- a/public/app/plugins/panel/state-timeline/StateTimelinePanel.tsx +++ b/public/app/plugins/panel/state-timeline/StateTimelinePanel.tsx @@ -104,7 +104,6 @@ export const StateTimelinePanel = ({ height, replaceVariables, onChangeTimeRange, - fieldConfig, }: TimelinePanelProps) => { const theme = useTheme2(); @@ -114,8 +113,8 @@ export const StateTimelinePanel = ({ const cursorSync = sync?.() ?? DashboardCursorSync.Off; const { frames, warn } = useMemo( - () => prepareTimelineFields(data.series, options.mergeValues ?? true, timeRange, theme, fieldConfig), - [data.series, options.mergeValues, timeRange, theme, fieldConfig] + () => prepareTimelineFields(data.series, options.mergeValues ?? true, timeRange, theme), + [data.series, options.mergeValues, timeRange, theme] ); const { paginatedFrames, paginationRev, paginationElement, paginationHeight } = usePagination( diff --git a/public/app/plugins/panel/status-history/StatusHistoryPanel.tsx b/public/app/plugins/panel/status-history/StatusHistoryPanel.tsx index 33f0b30fdae..5f09c96ca52 100644 --- a/public/app/plugins/panel/status-history/StatusHistoryPanel.tsx +++ b/public/app/plugins/panel/status-history/StatusHistoryPanel.tsx @@ -31,7 +31,6 @@ export const StatusHistoryPanel = ({ height, replaceVariables, onChangeTimeRange, - fieldConfig, }: TimelinePanelProps) => { const theme = useTheme2(); @@ -43,8 +42,8 @@ export const StatusHistoryPanel = ({ const enableAnnotationCreation = Boolean(canAddAnnotations && canAddAnnotations()); const { frames, warn } = useMemo( - () => prepareTimelineFields(data.series, false, timeRange, theme, fieldConfig), - [data.series, timeRange, theme, fieldConfig] + () => prepareTimelineFields(data.series, false, timeRange, theme), + [data.series, timeRange, theme] ); const legendItems = useMemo(