BarChart: Fix value mappings (#60066)

This commit is contained in:
Leon Sorokin 2022-12-09 11:52:34 -06:00 committed by GitHub
parent 6f9ee7acf9
commit 8317bf5def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {