Skip to content

Commit

Permalink
fix: displayer crash when cursor come over 1d trace in 2d mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Aug 27, 2021
1 parent 31302a2 commit e8080a9
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/component/2d/tools/XYLabelPointer.tsx
Expand Up @@ -24,8 +24,16 @@ const style: CSSProperties = {
function XYLabelPointer({ layout, data1D }) {
const position = useContext(MouseContext);
const { step } = useContext(BrushContext);
const { margin, width, height, xDomain, yDomain, yDomains, activeTab } =
useChartData();
const {
margin,
width,
height,
xDomain,
yDomain,
yDomains,
activeTab,
activeSpectrum,
} = useChartData();

const trackID =
position &&
Expand All @@ -38,7 +46,7 @@ function XYLabelPointer({ layout, data1D }) {
const [formatX, formatY] = useFormatNumberByNucleus(nucleuses);

const scaleX = useMemo(() => {
if (!data1D || data1D.length === 0) {
if (!activeSpectrum || !data1D || data1D.length === 0) {
return get2DXScale({ width, margin, xDomain });
}

Expand All @@ -53,10 +61,19 @@ function XYLabelPointer({ layout, data1D }) {
default:
return null;
}
}, [data1D, height, margin, trackID, width, xDomain, yDomain]);
}, [
activeSpectrum,
data1D,
height,
margin,
trackID,
width,
xDomain,
yDomain,
]);

const scaleY = useMemo(() => {
if (!data1D || data1D.length === 0) {
if (!activeSpectrum || !data1D || data1D.length === 0) {
return get2DYScale({ height, margin, yDomain });
}

Expand All @@ -77,7 +94,7 @@ function XYLabelPointer({ layout, data1D }) {
default:
return null;
}
}, [data1D, height, margin, trackID, yDomain, yDomains]);
}, [activeSpectrum, data1D, height, margin, trackID, yDomain, yDomains]);

if (
step === 'brushing' ||
Expand Down

0 comments on commit e8080a9

Please sign in to comment.