Skip to content

Commit

Permalink
fix: do not raise an error if no 1D trace spectra are found
Browse files Browse the repository at this point in the history
close #2643
  • Loading branch information
hamed-musallam committed Aug 24, 2023
1 parent 81d4388 commit ac56101
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/component/2d/Viewer2D.tsx
Expand Up @@ -15,7 +15,6 @@ import { useChartData } from '../context/ChartContext';
import { useDispatch } from '../context/DispatchContext';
import Spinner from '../loader/Spinner';
import { options } from '../toolbar/ToolTypes';
import { assert } from '../utility/assert';

import Chart2D from './Chart2D';
import FooterBanner from './FooterBanner';
Expand Down Expand Up @@ -45,14 +44,14 @@ function Viewer2D({ emptyText = undefined }: Viewer2DProps) {

const spectrumData: any[] = useMemo(() => {
const nuclei = activeTab.split(',');

return nuclei.map((nucleus) => {
const spectra = activeSpectra[nucleus];
if (spectra?.length === 1) {
const id = spectra[0].id;
const spectrum = data.find(
(datum) => datum.id === id && !datum.info.isFid,
);
assert(spectrum, `Spectrum with id ${id} not found`);
return spectrum;
}
return null;
Expand Down Expand Up @@ -191,9 +190,7 @@ function Viewer2D({ emptyText = undefined }: Viewer2DProps) {
)}

<CrossLinePointer />
{spectrumData && (
<XYLabelPointer data1D={spectrumData} layout={DIMENSION} />
)}
<XYLabelPointer data1D={spectrumData} layout={DIMENSION} />

<BrushXY
brushType={BRUSH_TYPE.XY}
Expand All @@ -215,9 +212,7 @@ function Viewer2D({ emptyText = undefined }: Viewer2DProps) {
/>
)}
</>
{spectrumData && (
<FooterBanner data1D={spectrumData} layout={DIMENSION} />
)}
<FooterBanner data1D={spectrumData} layout={DIMENSION} />

<Chart2D spectra={spectrumData} />
</MouseTracker>
Expand Down

0 comments on commit ac56101

Please sign in to comment.