From 71a9bf0203c02a29a77bc3e60749837ee9e62b38 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Wed, 15 Sep 2021 14:42:58 -0400 Subject: [PATCH] BarChart: Fix legend and tooltip colors off by 1 after data refresh (#39234) (#39252) (cherry picked from commit fb091de2c7c819118d49f1ec3d6dbabbaff2c360) Co-authored-by: Leon Sorokin --- public/app/plugins/panel/barchart/utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/app/plugins/panel/barchart/utils.ts b/public/app/plugins/panel/barchart/utils.ts index 973bac8ac38..64db72fc036 100644 --- a/public/app/plugins/panel/barchart/utils.ts +++ b/public/app/plugins/panel/barchart/utils.ts @@ -253,10 +253,16 @@ export function prepareGraphableFrames( }; } + let seriesIndex = 0; + for (let frame of series) { const fields: Field[] = []; for (const field of frame.fields) { if (field.type === FieldType.number) { + field.state = field.state ?? {}; + + field.state.seriesIndex = seriesIndex++; + let copy = { ...field, config: {