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.

Add a selection feedback story, with mock feedback brushes.
  • Loading branch information
eatyourgreens committed Jan 18, 2024
1 parent 21c81db commit 108df7e
Show file tree
Hide file tree
Showing 4 changed files with 111 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 @@ -323,3 +323,83 @@ SelectedXRanges.store = mockStore({
subject: superWaspSubject,
workflow: dataSelectionWorkflow
})

export function SelectionFeedback() {
const [task] = SelectedXRanges.store.workflowSteps.findTasksByType('dataVisAnnotation')
SelectedXRanges.store.classifications.addAnnotation(task, [
{
tool: 0,
toolType: 'graph2dRangeX',
x: 98,
width: 6,
zoomLevelOnCreation: 0
},
{
tool: 0,
toolType: 'graph2dRangeX',
x: 110,
width: 6,
zoomLevelOnCreation: 0
},
{
tool: 1,
toolType: 'graph2dRangeX',
x: 116,
width: 4,
zoomLevelOnCreation: 0
}
])
const feedbackBrushes = [
{
id: 1,
minX: 95,
maxX: 101
},
{
id: 2,
minX: 107,
maxX: 113
},
{
id: 3,
minX: 114,
maxX: 118
},
{
id: 'simulated_rule',
minX: 90,
maxX: 102,
success: true
},
{
id: 'simulated_rule',
minX: 124,
maxX: 134,
success: false
}
]

return (
<ViewerContext store={SelectedXRanges.store}>
<Box direction='row' height='medium' width='large'>
<JSONDataViewer
disabled
experimentalSelectionTool
feedbackBrushes={feedbackBrushes}
zoomConfiguration={{
direction: 'x',
minZoom: 1,
maxZoom: 10,
zoomInValue: 1.2,
zoomOutValue: 0.8
}}
/>
<ImageToolbar width='4rem' />
</Box>
</ViewerContext>
)
}
SelectedXRanges.store = mockStore({
subject: superWaspSubject,
workflow: dataSelectionWorkflow
})
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 108df7e

Please sign in to comment.