Skip to content

Commit

Permalink
fix: be more resilient with invalid types
Browse files Browse the repository at this point in the history
`dlv` doesn't support `undefined` as a key.
  • Loading branch information
targos committed Feb 25, 2025
1 parent 176c5bb commit cb369fc
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/component/panels/multipleAnalysisPanel/AnalysisChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,21 @@ export function getPlotDataAsString(
for (const col of spectraPanelPreferences.columns) {
if (col.visible && 'jpath' in col) {
const jpath = (col as JpathTableColumn)?.jpath;
const value = dlv(spectrum, jpath, `null`);
const value = jpath ? dlv(spectrum, jpath, 'null') : 'null';
cellsValues.push(value);
}
}

const x = xData ? xData[spectrum.id] : dlv(spectrum, xPathKeys, index);
const y = yData ? yData[spectrum.id] : dlv(spectrum, yPathKeys, index);
const x = xData
? xData[spectrum.id]
: xPathKeys
? dlv(spectrum, xPathKeys, index)
: index;
const y = yData
? yData[spectrum.id]
: yPathKeys
? dlv(spectrum, yPathKeys, index)
: index;

cellsValues.push(x, y);

Expand Down Expand Up @@ -161,8 +169,16 @@ function usePlotData(
plotOption,
);
return spectra.map((spectrum, index) => {
const x = xData ? xData[spectrum.id] : dlv(spectrum, xPathKeys, index);
const y = yData ? yData[spectrum.id] : dlv(spectrum, yPathKeys, index);
const x = xData
? xData[spectrum.id]
: xPathKeys
? dlv(spectrum, xPathKeys, index)
: index;
const y = yData
? yData[spectrum.id]
: yPathKeys
? dlv(spectrum, yPathKeys, index)
: index;
return {
x,
y,
Expand Down

0 comments on commit cb369fc

Please sign in to comment.