Skip to content

Commit 2045fee

Browse files
committed
Add "Check All" toggle button
1 parent 61a0f67 commit 2045fee

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tslib/react/src/components/PlotParallelCoordinate.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {
22
Checkbox,
3+
Divider,
34
FormControlLabel,
45
FormGroup,
56
Grid,
@@ -243,6 +244,16 @@ const useTargets = (
243244
const searchSpace = useMergedUnionSearchSpace(study?.union_search_space)
244245
const [targets2] = useParamTargets(searchSpace)
245246
const [checked, setChecked] = useState<boolean[]>([true])
247+
const [checkedAll, setCheckedAll] = useState<boolean>(true)
248+
249+
const toggleCheckedAll = () => {
250+
if (checkedAll) {
251+
setChecked(checked.map(() => false))
252+
} else {
253+
setChecked(checked.map(() => true))
254+
}
255+
setCheckedAll((prevCheckedAll) => !prevCheckedAll)
256+
}
246257

247258
const allTargets = [...targets1, ...targets2]
248259
useEffect(() => {
@@ -276,6 +287,17 @@ const useTargets = (
276287

277288
const renderCheckBoxes = (): ReactNode => (
278289
<FormGroup>
290+
<FormControlLabel
291+
control={
292+
<Checkbox
293+
checked={checkedAll}
294+
onChange={toggleCheckedAll}
295+
name="checkedAll"
296+
/>
297+
}
298+
label="Check All"
299+
/>
300+
<Divider />
279301
{allTargets.map((t, i) => {
280302
const key = t.toLabel(study?.metric_names)
281303
return (

0 commit comments

Comments
 (0)