StateTimeline: Fix use of hidden fields in data links (#95095)
* Use hideFrom in GraphNG to hide fields if value is defined. Remove other filtering from timeline chart * make hidefrom logic more robust * remove unneeded decoupling, filter fields when there are no links * add omitHideFromViz prop to GraphNG * Add more to comment on property --------- Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
@@ -52,6 +52,14 @@ export interface GraphNGProps extends Themeable2 {
|
||||
dataLinkPostProcessor?: DataLinkPostProcessor;
|
||||
cursorSync?: DashboardCursorSync;
|
||||
|
||||
// Remove fields that are hidden from the visualization before rendering
|
||||
// The fields will still be available for other things like data links
|
||||
// this is a temporary hack that only works when:
|
||||
// 1. renderLegend (above) does not render <PlotLegend>
|
||||
// 2. does not have legend series toggle
|
||||
// 3. passes through all fields required for link/action gen (including those with hideFrom.viz)
|
||||
omitHideFromViz?: boolean;
|
||||
|
||||
/**
|
||||
* needed for propsToDiff to re-init the plot & config
|
||||
* this is a generic approach to plot re-init, without having to specify which panel-level options
|
||||
@@ -175,6 +183,15 @@ export class GraphNG extends Component<GraphNGProps, GraphNGState> {
|
||||
};
|
||||
}
|
||||
|
||||
if (props.omitHideFromViz) {
|
||||
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) {
|
||||
|
||||
@@ -86,6 +86,7 @@ export class TimelineChart extends Component<TimelineProps> {
|
||||
prepConfig={this.prepConfig}
|
||||
propsToDiff={propsToDiff}
|
||||
renderLegend={this.renderLegend}
|
||||
omitHideFromViz={true}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -375,9 +375,6 @@ export function prepareTimelineFields(
|
||||
|
||||
const fields: Field[] = [];
|
||||
for (let field of frame.fields) {
|
||||
if (field.config.custom?.hideFrom?.viz) {
|
||||
continue;
|
||||
}
|
||||
switch (field.type) {
|
||||
case FieldType.time:
|
||||
isTimeseries = true;
|
||||
|
||||
Reference in New Issue
Block a user