XY Chart: fix editor error with empty frame (no fields) (#30573) (#30577)

(cherry picked from commit 08312897c8)

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-01-24 08:59:39 -08:00
committed by GitHub
co-authored by Ryan McKinley
parent 5a07677422
commit 77e924295b
@@ -28,7 +28,7 @@ export const XYDimsEditor: FC<StandardEditorProps<XYDimensionConfig, any, Option
}
const frameNames = useMemo(() => {
if (context.data && context.data.length > 0) {
if (context?.data?.length) {
return context.data.map((f, idx) => ({
value: idx,
label: getFrameDisplayName(f, idx),
@@ -56,7 +56,7 @@ export const XYDimsEditor: FC<StandardEditorProps<XYDimensionConfig, any, Option
};
const frame = context.data ? context.data[value?.frame ?? 0] : undefined;
if (frame) {
const xName = getFieldDisplayName(dims.x, dims.frame, context.data);
const xName = dims.x ? getFieldDisplayName(dims.x, dims.frame, context.data) : undefined;
for (let field of frame.fields) {
if (isGraphable(field)) {
const name = getFieldDisplayName(field, frame, context.data);