VizTooltips: Fix series labels after zooming (#82985)

This commit is contained in:
Leon Sorokin 2024-02-17 00:38:13 -06:00 committed by GitHub
parent a02519895e
commit 94a274635b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 2 deletions

View File

@ -56,6 +56,11 @@ export interface JoinOptions {
*/
keepOriginIndices?: boolean;
/**
* @internal -- keep any pre-cached state.displayName
*/
keepDisplayNames?: boolean;
/**
* @internal -- Optionally specify a join mode (outer or inner)
*/
@ -223,8 +228,10 @@ export function joinDataFrames(options: JoinOptions): DataFrame | undefined {
for (const field of fields) {
a.push(field.values);
originalFields.push(field);
if (!options.keepDisplayNames) {
// clear field displayName state
delete field.state?.displayName;
}
// store frame field order for tabular data join
frameFieldsOrder.push(fieldsOrder);
fieldsOrder++;

View File

@ -110,6 +110,11 @@ export function preparePlotFrame(frames: DataFrame[], dimFields: XYFieldMatchers
joinBy: dimFields.x,
keep: dimFields.y,
keepOriginIndices: true,
// the join transformer force-deletes our state.displayName cache unless keepDisplayNames: true
// https://github.com/grafana/grafana/pull/31121
// https://github.com/grafana/grafana/pull/71806
keepDisplayNames: true,
});
if (alignedFrame) {

View File

@ -21,6 +21,7 @@ import {
getFieldConfigWithMinMax,
ThresholdsMode,
TimeRange,
cacheFieldDisplayNames,
} from '@grafana/data';
import { maybeSortFrame } from '@grafana/data/src/transformations/transformers/joinDataFrames';
import { applyNullInsertThreshold } from '@grafana/data/src/transformations/transformers/nulls/nullInsertThreshold';
@ -437,6 +438,9 @@ export function prepareTimelineFields(
if (!series?.length) {
return { warn: 'No data in response' };
}
cacheFieldDisplayNames(series);
let hasTimeseries = false;
const frames: DataFrame[] = [];

View File

@ -10,6 +10,7 @@ import {
isBooleanUnit,
SortedVector,
TimeRange,
cacheFieldDisplayNames,
} from '@grafana/data';
import { convertFieldType } from '@grafana/data/src/transformations/transformers/convertFieldType';
import { applyNullInsertThreshold } from '@grafana/data/src/transformations/transformers/nulls/nullInsertThreshold';
@ -82,6 +83,8 @@ export function prepareGraphableFields(
return null;
}
cacheFieldDisplayNames(series);
let useNumericX = xNumFieldIdx != null;
// Make sure the numeric x field is first in the frame