Skip to content

Commit

Permalink
BarChart: Fix value mappings (#60066)
Browse files Browse the repository at this point in the history
(cherry picked from commit 8317bf5)
  • Loading branch information
leeoniya authored and grafanabot committed Dec 9, 2022
1 parent 4270f44 commit 4aa93d0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion public/app/plugins/panel/barchart/BarChartPanel.tsx
Expand Up @@ -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) {
Expand Down

0 comments on commit 4aa93d0

Please sign in to comment.