[v9.3.x] BarChart: Fix value mappings (#60122)

BarChart: Fix value mappings (#60066)

(cherry picked from commit 8317bf5def)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-12-09 12:29:34 -06:00
committed by GitHub
co-authored by Leon Sorokin
parent 4270f44664
commit 30ee2bedf2
@@ -242,7 +242,17 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({
f.config.custom?.gradientMode === GraphGradientMode.Scheme &&
f.config.color?.mode === FieldColorModeId.Thresholds;
return fromThresholds || f.config.mappings?.some((m) => m.options.result.color != null);
return (
fromThresholds ||
f.config.mappings?.some((m) => {
// ValueToText mappings have a different format, where all of them are grouped into an object keyed by value
if (m.type === 'value') {
// === MappingType.ValueToText
return Object.values(m.options).some((result) => result.color != null);
}
return m.options.result.color != null;
})
);
});
if (hasPerBarColor) {