Skip to content

Commit

Permalink
Merge pull request #976 from porink0424/feat/checkbox-all-in-parallel…
Browse files Browse the repository at this point in the history
…-coordinate

Add "Check All" toggle button in `ParallelCoordinate`
  • Loading branch information
c-bata authored Oct 2, 2024
2 parents 61a0f67 + 2045fee commit 81fa76b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tslib/react/src/components/PlotParallelCoordinate.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Checkbox,
Divider,
FormControlLabel,
FormGroup,
Grid,
Expand Down Expand Up @@ -243,6 +244,16 @@ const useTargets = (
const searchSpace = useMergedUnionSearchSpace(study?.union_search_space)
const [targets2] = useParamTargets(searchSpace)
const [checked, setChecked] = useState<boolean[]>([true])
const [checkedAll, setCheckedAll] = useState<boolean>(true)

const toggleCheckedAll = () => {
if (checkedAll) {
setChecked(checked.map(() => false))
} else {
setChecked(checked.map(() => true))
}
setCheckedAll((prevCheckedAll) => !prevCheckedAll)
}

const allTargets = [...targets1, ...targets2]
useEffect(() => {
Expand Down Expand Up @@ -276,6 +287,17 @@ const useTargets = (

const renderCheckBoxes = (): ReactNode => (
<FormGroup>
<FormControlLabel
control={
<Checkbox
checked={checkedAll}
onChange={toggleCheckedAll}
name="checkedAll"
/>
}
label="Check All"
/>
<Divider />
{allTargets.map((t, i) => {
const key = t.toLabel(study?.metric_names)
return (
Expand Down

0 comments on commit 81fa76b

Please sign in to comment.