Skip to content

Commit

Permalink
Data selection feedback for scatter plots
Browse files Browse the repository at this point in the history
Add `feedbackBrushes`, from PH-TESS, to the scatter plot viewer's `Selections` component. Show a green bar for each success, a red bar for each failure.

Disable the subject viewer so that annotations can't be edited in the feedback popup.
  • Loading branch information
eatyourgreens committed Jan 17, 2024
1 parent 21c81db commit 13666da
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function Graph2dRangeFeedback() {

return (
<JSONDataViewer
disabled
subject={subject}
feedback={feedback}
feedbackBrushes={[...annotationBrushes, ...ruleBrushes]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ const TRANSFORM_MATRIX = {
translateY: 0
}



export default function ScatterPlot({
axisColor = '',
backgroundColor = '',
Expand All @@ -57,6 +55,7 @@ export default function ScatterPlot({
dataPointSize = 25,
disabled = false,
experimentalSelectionTool = false,
feedbackBrushes = [],
highlightedSeries,
initialSelections = [],
interactionMode = 'annotate',
Expand Down Expand Up @@ -191,6 +190,7 @@ export default function ScatterPlot({
{children}
{experimentalSelectionTool && <Selections
disabled={disabled || interactionMode !== 'annotate'}
feedbackBrushes={feedbackBrushes}
height={plotHeight}
margin={margin}
transformMatrix={transformMatrix}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const DEFAULT_HANDLER = () => true

function Selections({
disabled = false,
feedbackBrushes=[],
height,
margin,
transformMatrix = TRANSFORM_MATRIX,
Expand Down Expand Up @@ -203,6 +204,27 @@ function Selections({
eventRoot?.current.focus()
}

function FeedbackBrush({ feedbackBrush }) {
const width = feedbackBrush.maxX - feedbackBrush.minX
const x = feedbackBrush.minX + width / 2
let fill = 'transparent'
if (feedbackBrush.success === true) {
fill = 'green'
}
if (feedbackBrush.success === false) {
fill = 'red'
}
return (
<Selection
disabled
selection={{ x, width }}
fill={fill}
height={height}
xScale={xScale}
/>
)
}

return (
<g
ref={eventRoot}
Expand Down Expand Up @@ -251,6 +273,12 @@ function Selections({
stroke={colors['dark-3']}
/>
))}
{feedbackBrushes?.map(feedbackBrush => (
<FeedbackBrush
key={feedbackBrush.minX}
feedbackBrush={feedbackBrush}
/>
))}
</g>
)
}
Expand Down

0 comments on commit 13666da

Please sign in to comment.