@@ -5,38 +5,78 @@ const HoveredRoiTooltip = ({
55} : {
66 xPosition : number
77 yPosition : number
8- rois : Array < { index : number , roiUid : string , attributes : Array < { name : string , value : string } > } >
8+ rois : Array < { index : number , roiUid : string , attributes : Array < { name : string , value : string } > , seriesDescription ?: string } >
99} ) : JSX . Element => {
10+ // Always group ROIs by series description
11+ const groupedRois = rois . reduce < { [ key : string ] : typeof rois } > ( ( acc , roi ) => {
12+ const seriesDesc = ( roi . seriesDescription !== null && roi . seriesDescription !== undefined && roi . seriesDescription !== '' ) ? roi . seriesDescription : 'Unknown Series'
13+ if ( acc [ seriesDesc ] === undefined ) {
14+ acc [ seriesDesc ] = [ ]
15+ }
16+ acc [ seriesDesc ] . push ( roi )
17+ return acc
18+ } , { } )
19+
20+ const baseStyle : React . CSSProperties = {
21+ position : 'fixed' ,
22+ top : `${ yPosition } px` ,
23+ left : `${ xPosition } px` ,
24+ backgroundColor : 'rgba(230, 230, 230, 0.95)' ,
25+ padding : '10px' ,
26+ fontWeight : 'bold' ,
27+ pointerEvents : 'none' ,
28+ borderRadius : '4px' ,
29+ boxShadow : '0 2px 8px rgba(0, 0, 0, 0.15)' ,
30+ zIndex : 10000
31+ }
32+
1033 return (
1134 < div
1235 style = { {
13- position : 'fixed' ,
14- top : `${ yPosition } px` ,
15- left : `${ xPosition } px` ,
16- backgroundColor : 'rgba(230, 230, 230, 0.65)' ,
17- minWidth : '150px' ,
18- minHeight : '60px' ,
19- padding : '20px' ,
20- fontWeight : 'bold' ,
21- pointerEvents : 'none'
36+ ...baseStyle ,
37+ minWidth : '200px' ,
38+ maxWidth : '400px'
2239 } }
2340 >
24- { rois . map ( ( roi , i ) => {
25- const attributes = roi . attributes
26- return (
27- < div key = { roi . roiUid } >
28- < span > ROI { roi . index } </ span >
29- { attributes . map ( ( attr ) => {
41+ { Object . entries ( groupedRois ) . map ( ( [ seriesDesc , seriesRois ] , seriesIndex ) => (
42+ < div key = { seriesDesc } style = { { marginBottom : seriesIndex > 0 ? '12px' : '0' } } >
43+ { seriesIndex > 0 && (
44+ < hr style = { { margin : '10px 0' , border : 'none' , borderTop : '1px solid rgba(0, 0, 0, 0.2)' } } />
45+ ) }
46+ < div style = { { fontSize : '13px' , fontWeight : 'bold' , color : 'rgba(0, 0, 0, 0.8)' , marginBottom : '8px' , paddingBottom : '4px' , borderBottom : '1px solid rgba(0, 0, 0, 0.15)' } } >
47+ { seriesDesc }
48+ </ div >
49+ < div style = { { marginLeft : '4px' } } >
50+ { seriesRois . map ( ( roi : { index : number , roiUid : string , attributes : Array < { name : string , value : string } > , seriesDescription ?: string } , roiIndex : number ) => {
51+ const annotationGroupLabelAttr = roi . attributes . find ( ( attr : { name : string , value : string } ) => attr . name === 'Annotation Group Label' )
52+ const otherAttributes = roi . attributes . filter (
53+ ( attr : { name : string , value : string } ) => attr . name !== 'Series Description' && attr . name !== 'Annotation Group Label'
54+ )
3055 return (
31- < div key = { attr . name + roi . roiUid } >
32- { attr . name } : < span style = { { fontWeight : 500 } } > { attr . value } </ span >
56+ < div key = { roi . roiUid } style = { { marginBottom : roiIndex < seriesRois . length - 1 ? '6px' : '0' , fontSize : '12px' } } >
57+ < div style = { { fontWeight : 'bold' } } >
58+ ROI { roi . index }
59+ { ( annotationGroupLabelAttr != null ) && (
60+ < span style = { { fontWeight : 500 , marginLeft : '6px' , color : 'rgba(0, 0, 0, 0.7)' } } >
61+ - { annotationGroupLabelAttr . value }
62+ </ span >
63+ ) }
64+ </ div >
65+ { otherAttributes . length > 0 && (
66+ < div style = { { marginLeft : '12px' , fontSize : '11px' , color : 'rgba(0, 0, 0, 0.8)' , marginTop : '2px' } } >
67+ { otherAttributes . map ( ( attr : { name : string , value : string } ) => (
68+ < div key = { String ( attr . name ) + '-' + String ( roi . roiUid ) } >
69+ { attr . name } : < span style = { { fontWeight : 500 } } > { attr . value } </ span >
70+ </ div >
71+ ) ) }
72+ </ div >
73+ ) }
3374 </ div >
3475 )
3576 } ) }
3677 </ div >
37-
38- )
39- } ) }
78+ </ div >
79+ ) ) }
4080 </ div >
4181 )
4282}
0 commit comments