From 20126dd157b07e04041306407d8f2bf6554050db Mon Sep 17 00:00:00 2001 From: hamed musallam Date: Wed, 28 Aug 2024 13:26:34 +0200 Subject: [PATCH] fix: show/hide the spectra legend fields --- src/component/1d/SpectraLegends.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/component/1d/SpectraLegends.tsx b/src/component/1d/SpectraLegends.tsx index d3963a9870..bfc3ef10d3 100644 --- a/src/component/1d/SpectraLegends.tsx +++ b/src/component/1d/SpectraLegends.tsx @@ -61,6 +61,8 @@ function InnerSpectraLegends({ spectra, legendsFields, }: InnerSpectraLegendsProps) { + const visibleLegendsFields = legendsFields.filter((legend) => legend.visible); + return ( {spectra.map((spectrum, index) => ( @@ -72,10 +74,9 @@ function InnerSpectraLegends({ }} /> - {legendsFields.map((field) => { - const predefinedField = field as PredefinedLegendField; - - switch (predefinedField?.name) { + {visibleLegendsFields.map((field) => { + const { name } = field as PredefinedLegendField; + switch (name) { case 'intensity': return (