BarChart: fix single numeric field regression (#31703)

This commit is contained in:
Leon Sorokin 2021-03-04 14:27:14 -06:00 committed by GitHub
parent c15d1f498a
commit c64c0b0725
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,21 +48,14 @@ export const BarChartPanel: React.FunctionComponent<Props> = ({
}
const firstFrame = data.series[0];
if (!firstFrame.fields.find((f) => f.type === FieldType.string)) {
if (!firstFrame.fields.some((f) => f.type === FieldType.string)) {
return (
<div className="panel-empty">
<p>Bar charts requires a string field</p>
</div>
);
}
if (
firstFrame.fields.reduce((acc, f) => {
if (f.type === FieldType.number) {
return acc + 1;
}
return acc;
}, 0) < 2
) {
if (!firstFrame.fields.some((f) => f.type === FieldType.number)) {
return (
<div className="panel-empty">
<p>No numeric fields found</p>