+ {x.toPrecision(8)}, {y.toPrecision(8)} +
+ ); + }; - const aux = []; + const dd = createDisplayData( + props.xasData, + showTrans, + showFluor, + showRefer, + useNorm, + [ + darken(theme.palette.primary.dark, 0.3), + darken(theme.palette.success.light, 0.3), + darken(theme.palette.secondary.dark, 0.3), + ] + ); - let ydataLabel = ""; + const filteredComparison: XASData[] = props.comparisonFiles.filter( + (f) => f.id != props.xasData?.id + ); - const hideAll = !showTrans && !showFluor && !showRefer; + const ddcompare: DisplayData[] = filteredComparison + .map((f, i) => { + return createDisplayData(f, showTrans, showFluor, showRefer, useNorm, [ + lighten(theme.palette.primary.dark, i * 0.3), + lighten(theme.palette.success.light, i * 0.3), + lighten(theme.palette.secondary.dark, i * 0.3), + ]); + }) + .flat(); - if (xasdata != null && !hideAll) { - xdata = ndarray(xasdata.energy, [xasdata.energy.length]); - - let primaryFound = false; - - if (showTrans && xasdata.mutrans) { - primaryFound = true; - - ydata = useNorm - ? pre_edge(xasdata.energy, xasdata.mutrans) - : ndarray(xasdata.mutrans, [xasdata.mutrans.length]); - - ydataLabel = "Transmission"; - } - - if (showFluor && xasdata.mufluor) { - const fdata = useNorm - ? pre_edge(xasdata.energy, xasdata.mufluor) - : ndarray(xasdata.mufluor, [xasdata.mufluor.length]); - if (!primaryFound) { - primaryFound = true; - ydata = fdata; - ydataLabel = "Fluorescence"; - } else { - aux.push({ label: "Fluorescence", array: fdata }); - } - } - - if (showRefer && xasdata.murefer) { - const rdata = useNorm - ? pre_edge(xasdata.energy, xasdata.murefer) - : ndarray(xasdata.murefer, [xasdata.murefer.length]); - if (!primaryFound) { - primaryFound = true; - ydata = rdata; - ydataLabel = "Reference"; - } else { - aux.push({ label: "Reference", array: rdata }); - } - } - } + dd.push(...ddcompare); + + const domain: Domain | undefined = getCombinedDomain( + dd.map((a) => getDomain(a.y)) + ); + const xdomain: Domain | undefined = getCombinedDomain( + dd.map((a) => getDomain(a.x)) + ); + + const abscissaConfig: AxisConfig = { + visDomain: xdomain ?? [0, 1], + showGrid: true, + isIndexAxis: false, + label: "Energy (eV)", + }; + + const ordinateConfig: AxisConfig = { + visDomain: domain ?? [0, 1], + showGrid: true, + isIndexAxis: false, + label: useNorm ? "mu(E) (norm)" : "mu(E)", + }; + + const legendColor = theme.palette.action.hover; const toolbarstyle = { "--h5w-toolbar--bgColor": theme.palette.action.hover, @@ -140,10 +235,6 @@ function XASChart(props: { xasData: XASData | null }) { ], } as React.CSSProperties; - const domain = getCombinedDomain( - [getDomain(ydata)].concat(aux.map((a) => getDomain(a.array))) - ); - return (