[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 3007e3b209)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
grafana-delivery-bot[bot]
2023-06-22 00:33:38 +03:00
committed by GitHub
co-authored by Leon Sorokin
parent f5404286be
commit c87b7233b8
+10 -8
View File
@@ -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);