mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 10:50:04 +08:00
TimeSeries: Fix legend and tooltip colors changing after data refreshes (#63823)
This commit is contained in:
@ -128,12 +128,30 @@ export function prepareGraphableFields(
|
||||
}
|
||||
|
||||
if (frames.length) {
|
||||
setClassicPaletteIdxs(frames, theme);
|
||||
return frames;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const setClassicPaletteIdxs = (frames: DataFrame[], theme: GrafanaTheme2) => {
|
||||
let seriesIndex = 0;
|
||||
|
||||
frames.forEach((frame) => {
|
||||
frame.fields.forEach((field) => {
|
||||
// TODO: also add FieldType.enum type here after https://github.com/grafana/grafana/pull/60491
|
||||
if (field.type === FieldType.number || field.type === FieldType.boolean) {
|
||||
field.state = {
|
||||
...field.state,
|
||||
seriesIndex: seriesIndex++, // TODO: skip this for fields with custom renderers (e.g. Candlestick)?
|
||||
};
|
||||
field.display = getDisplayProcessor({ field, theme });
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export function getTimezones(timezones: string[] | undefined, defaultTimezone: string): string[] {
|
||||
if (!timezones || !timezones.length) {
|
||||
return [defaultTimezone];
|
||||
|
Reference in New Issue
Block a user