@@ -22,7 +22,7 @@ import {
22
22
TrialData ,
23
23
valueFormatter ,
24
24
} from "@/types/global" ;
25
- import { useEffect , useState } from "react" ;
25
+ import { useEffect , useRef , useState } from "react" ;
26
26
import { CustomItemTooltip } from "@/components/benchmarks/CustomItemTooltip" ;
27
27
import type { NextPageWithBreadcrumbs } from "@/pages/_app" ;
28
28
import { useBreadcrumbsContext } from "@/components/design_system/breadcrumbs/BreadcrumbsContext" ;
@@ -32,6 +32,22 @@ import { Typography, Card, CardContent, Stack } from "@mui/material";
32
32
const ViewBenchmarkPage : NextPageWithBreadcrumbs = ( ) => {
33
33
const { setBreadcrumbs } = useBreadcrumbsContext ( ) ;
34
34
const router = useRouter ( ) ;
35
+ const ref = useRef < HTMLDivElement > ( null ) ;
36
+ const [ width , setWidth ] = useState ( 0 ) ;
37
+
38
+ function handleResize ( ) {
39
+ if ( ref . current ) {
40
+ setWidth ( ref . current . offsetWidth ) ;
41
+ }
42
+ }
43
+
44
+ useEffect ( ( ) => {
45
+ handleResize ( ) ;
46
+ window . addEventListener ( "resize" , handleResize ) ;
47
+ return ( ) => {
48
+ window . removeEventListener ( "resize" , handleResize ) ;
49
+ } ;
50
+ } , [ ] ) ;
35
51
36
52
const benchmark_id = router . query ?. benchmark_id as string ;
37
53
@@ -163,7 +179,7 @@ const ViewBenchmarkPage: NextPageWithBreadcrumbs = () => {
163
179
< Typography variant = "h1" > Viewing Data for [Student name]</ Typography >
164
180
165
181
< Card >
166
- < CardContent >
182
+ < CardContent ref = { ref } >
167
183
{ benchmark ?. trials . map ( ( trial ) => (
168
184
< div key = { trial . trial_data_id } > { trial . notes } </ div >
169
185
) ) }
@@ -214,7 +230,7 @@ const ViewBenchmarkPage: NextPageWithBreadcrumbs = () => {
214
230
valueFormatter ( v as BulkPoint | SoloPoint ) ,
215
231
} ,
216
232
] }
217
- width = { 500 }
233
+ width = { Math . min ( 720 , width ) }
218
234
height = { 300 }
219
235
>
220
236
< LinePlot />
0 commit comments