Skip to content

Commit 58fa991

Browse files
added scatterplot points on top of contour plot
1 parent 4b9bbfd commit 58fa991

File tree

1 file changed

+61
-52
lines changed

1 file changed

+61
-52
lines changed

src/components/densityPlot/index.js

Lines changed: 61 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -309,58 +309,67 @@ class DensityPlot extends Component {
309309
))}
310310
</g>
311311
)}
312-
{plotType === "scatterplot" &&
313-
dataPoints
314-
.sort((a, b) => {
315-
// Selected points come last (on top)
316-
if (a.uid === selectedId) return 1;
317-
if (b.uid === selectedId) return -1;
318-
// Then sort by oncogenicity
319-
const oncogenicityOrder = d3.ascending(
320-
a.oncogenicity || false,
321-
b.oncogenicity || false
322-
);
323-
// If oncogenicity is same, sort by color
324-
return (
325-
oncogenicityOrder ||
326-
d3.ascending(a[colorVariable], b[colorVariable])
327-
);
328-
})
329-
.map((d, i) => (
330-
<path
331-
key={d.uid}
332-
id={d.uid}
333-
transform={`translate(${[
334-
xScale(d[xVariable]),
335-
yScale(d[yVariable]),
336-
]})`}
337-
d={
338-
d.oncogenicity
339-
? d3.symbol(d3.symbolStar, 100)()
340-
: d3.symbol(d3.symbolCircle, 50)()
341-
}
342-
opacity={visible && id === i ? 1 : 1}
343-
fill={color(d[colorVariable])}
344-
stroke={
345-
selectedId === d.uid || (visible && id === i)
346-
? "#ff7f0e"
347-
: "lightgray"
348-
}
349-
strokeWidth={
350-
selectedId === d.uid || (visible && id === i)
351-
? 3
352-
: d.oncogenicity
353-
? 1
354-
: 0.5
355-
}
356-
onMouseEnter={(e) => this.handleMouseEnter(e, d, i)}
357-
onMouseOut={(e) => this.handleMouseOut(e, d)}
358-
onClick={() =>
359-
handlePointClicked ? handlePointClicked(d) : null
360-
}
361-
cursor={handlePointClicked ? "pointer" : "default"}
362-
/>
363-
))}
312+
{dataPoints
313+
.sort((a, b) => {
314+
// Selected points come last (on top)
315+
if (a.uid === selectedId) return 1;
316+
if (b.uid === selectedId) return -1;
317+
// Then sort by oncogenicity
318+
const oncogenicityOrder = d3.ascending(
319+
a.oncogenicity || false,
320+
b.oncogenicity || false
321+
);
322+
// If oncogenicity is same, sort by color
323+
return (
324+
oncogenicityOrder ||
325+
d3.ascending(a[colorVariable], b[colorVariable])
326+
);
327+
})
328+
.map((d, i) => (
329+
<path
330+
key={d.uid}
331+
id={d.uid}
332+
transform={`translate(${[
333+
xScale(d[xVariable]),
334+
yScale(d[yVariable]),
335+
]})`}
336+
d={
337+
plotType === "contourplot"
338+
? d3.symbol(d3.symbolCircle, 10)()
339+
: d.oncogenicity
340+
? d3.symbol(d3.symbolStar, 100)()
341+
: d3.symbol(d3.symbolCircle, 50)()
342+
}
343+
opacity={visible && id === i ? 1 : 1}
344+
fill={
345+
plotType === "contourplot"
346+
? "#333"
347+
: color(d[colorVariable])
348+
}
349+
stroke={
350+
plotType === "contourplot"
351+
? "lightgray"
352+
: selectedId === d.uid || (visible && id === i)
353+
? "#ff7f0e"
354+
: "lightgray"
355+
}
356+
strokeWidth={
357+
plotType === "contourplot"
358+
? 0.33
359+
: selectedId === d.uid || (visible && id === i)
360+
? 3
361+
: d.oncogenicity
362+
? 1
363+
: 0.5
364+
}
365+
onMouseEnter={(e) => this.handleMouseEnter(e, d, i)}
366+
onMouseOut={(e) => this.handleMouseOut(e, d)}
367+
onClick={() =>
368+
handlePointClicked ? handlePointClicked(d) : null
369+
}
370+
cursor={handlePointClicked ? "pointer" : "default"}
371+
/>
372+
))}
364373
</g>
365374
<g
366375
className="axis--y y-axis-container"

0 commit comments

Comments
 (0)