XYChart: Ensure color scale is field-local and synced with data updates (#70480)

This commit is contained in:
Leon Sorokin 2023-06-21 16:23:52 -05:00 committed by GitHub
parent bc3d704909
commit 3007e3b209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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);