From c87b7233b860d811b619c9f8e1e12a8a4e486684 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Thu, 22 Jun 2023 00:33:38 +0300 Subject: [PATCH] [v10.0.x] XYChart: Ensure color scale is field-local and synced with data updates (#70481) XYChart: Ensure color scale is field-local and synced with data updates (#70480) (cherry picked from commit 3007e3b209b04a16afb9069676a73c3eab050b77) Co-authored-by: Leon Sorokin --- public/app/plugins/panel/xychart/scatter.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/public/app/plugins/panel/xychart/scatter.ts b/public/app/plugins/panel/xychart/scatter.ts index 83f371507e8..aad9fe1d599 100644 --- a/public/app/plugins/panel/xychart/scatter.ts +++ b/public/app/plugins/panel/xychart/scatter.ts @@ -115,18 +115,20 @@ function getScatterSeries( if (dims.pointColorIndex) { const f = frames[frameIndex].fields[dims.pointColorIndex]; if (f) { - const disp = - f.display ?? - getDisplayProcessor({ - field: f, - theme: config.theme2, - }); pointColorMode = getFieldColorModeForField(y); if (pointColorMode.isByValue) { const index = dims.pointColorIndex; pointColor = (frame: DataFrame) => { - // Yes we can improve this later - return frame.fields[index].values.map((v) => disp(v).color!); + const field = frame.fields[index]; + + if (field.state?.range) { + // this forces local min/max recalc, rather than using global min/max from field.state + field.state.range = undefined; + } + + field.display = getDisplayProcessor({ field, theme: config.theme2 }); + + return field.values.map((v) => field.display!(v).color!); // slow! }; } else { seriesColor = pointColorMode.getCalculator(f, config.theme2)(f.values[0], 1);