From 344e99e069a583fbd185cc434cdb03bd7d9a1934 Mon Sep 17 00:00:00 2001 From: Leon Sorokin Date: Mon, 23 Oct 2023 15:01:46 -0500 Subject: [PATCH] VizLegend: Omit sectionRight when no right axis exists (#76923) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Torkel Ödegaard --- .../components/VizLegend/VizLegendList.tsx | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx b/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx index 8bba52a7f37..8a30511c012 100644 --- a/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx +++ b/packages/grafana-ui/src/components/VizLegend/VizLegendList.tsx @@ -56,26 +56,25 @@ export const VizLegendList = ({ } case 'bottom': default: { + const leftItems = items.filter((item) => item.yAxis === 1); + const rightItems = items.filter((item) => item.yAxis !== 1); + const renderItem = (item: VizLegendItem, index: number) => { return {itemRenderer!(item, index)}; }; return (
-
- item.yAxis === 1)} - renderItem={renderItem} - getItemKey={getItemKey} - /> -
-
- item.yAxis !== 1)} - renderItem={renderItem} - getItemKey={getItemKey} - /> -
+ {leftItems.length > 0 && ( +
+ +
+ )} + {rightItems.length > 0 && ( +
+ +
+ )}
); }