Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

BarChart: Fix value mappings #60066

Merged
merged 2 commits into from Dec 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Copy link
Contributor Author

@leeoniya leeoniya Dec 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was on the previous line, until Prettier "fixed" it 馃檮

this is here because we currently have an issue with schema gen which exports enums only as types, so the values cannot be used as RHS. @sdboyer is on it, but we can probably just land it like this, since that can take more time and we'll want this fix to land in the next patch release.

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃槵 that sucks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, this is already fixed in #55769 - i'm just loathe to pull it out and inevitably create a merge conflict there when it's already so close

i'll do it if that PR doesn't land by next week though

return Object.values(m.options).some((result) => result.color != null);
}
return m.options.result.color != null;
})
);
});

if (hasPerBarColor) {
Expand Down