mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 01:23:32 -06:00
BarChart: fix stale colorByField being used in value mappings (#54820)
This commit is contained in:
parent
b193eaed6e
commit
75de42fba7
@ -4,6 +4,7 @@ import {
|
||||
CartesianCoords2D,
|
||||
compareDataFrameStructures,
|
||||
DataFrame,
|
||||
Field,
|
||||
getFieldDisplayName,
|
||||
PanelProps,
|
||||
TimeRange,
|
||||
@ -97,9 +98,13 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({
|
||||
};
|
||||
|
||||
const frame0Ref = useRef<DataFrame>();
|
||||
const colorByFieldRef = useRef<Field>();
|
||||
|
||||
const info = useMemo(() => prepareBarChartDisplayValues(data?.series, theme, options), [data, theme, options]);
|
||||
const chartDisplay = 'viz' in info ? info : null;
|
||||
|
||||
colorByFieldRef.current = chartDisplay?.colorByField;
|
||||
|
||||
const structureRef = useRef(10000);
|
||||
|
||||
useMemo(() => {
|
||||
@ -226,7 +231,7 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({
|
||||
const disp = colorByField.display!;
|
||||
fillOpacity = (colorByField.config.custom.fillOpacity ?? 100) / 100;
|
||||
// gradientMode? ignore?
|
||||
getColor = (seriesIdx: number, valueIdx: number) => disp(colorByField.values.get(valueIdx)).color!;
|
||||
getColor = (seriesIdx: number, valueIdx: number) => disp(colorByFieldRef.current?.values.get(valueIdx)).color!;
|
||||
}
|
||||
|
||||
const prepConfig = (alignedFrame: DataFrame, allFrames: DataFrame[], getTimeRange: () => TimeRange) => {
|
||||
|
Loading…
Reference in New Issue
Block a user