@@ -26,7 +26,10 @@ const TooltipContents = forwardRef<HTMLDivElement, Props>(
2626 | undefined
2727 const source = feature . get ( 'source' )
2828 const summary = feature . get ( 'summary' )
29- const obj = Object . fromEntries ( model . sources . map ( ent => [ ent . name , ent ] ) )
29+ const obj = Object . fromEntries (
30+ ( model . sources || [ ] ) . map ( ent => [ ent . source , ent ] ) ,
31+ )
32+ const obj2 = obj [ source ]
3033
3134 return (
3235 < div ref = { ref } >
@@ -42,26 +45,32 @@ const TooltipContents = forwardRef<HTMLDivElement, Props>(
4245 </ tr >
4346 </ thead >
4447 < tbody >
45- { Object . entries ( sources ) . map ( ( [ source , data ] ) => (
46- < tr key = { source } >
47- < td >
48- < div
49- style = { {
50- width : 16 ,
51- height : 16 ,
52- background : obj [ source ] ! . color ,
53- } }
54- > </ div >
55- </ td >
56- < td > { source } </ td >
57- < td > { toP ( data . score ) } </ td >
58- </ tr >
59- ) ) }
48+ { Object . entries ( sources ) . map ( ( [ source , data ] ) => {
49+ const sourceInfo = obj [ source ]
50+ console . log ( { sourceInfo, sources } )
51+ return (
52+ < tr key = { source } >
53+ < td >
54+ { sourceInfo && (
55+ < div
56+ style = { {
57+ width : 16 ,
58+ height : 16 ,
59+ background : sourceInfo . color ,
60+ } }
61+ > </ div >
62+ ) }
63+ </ td >
64+ < td > { sourceInfo ?. name || source } </ td >
65+ < td > { toP ( data . score ) } </ td >
66+ </ tr >
67+ )
68+ } ) }
6069 </ tbody >
6170 </ table >
6271 ) : (
6372 < span >
64- { source } { ' ' }
73+ { obj2 ?. name || source } { ' ' }
6574 { summary
6675 ? `min:${ toP ( feature . get ( 'minScore' ) ) } avg:${ toP (
6776 feature . get ( 'score' ) ,
@@ -76,18 +85,17 @@ const TooltipContents = forwardRef<HTMLDivElement, Props>(
7685
7786type Coord = [ number , number ]
7887
79- const WiggleTooltip = observer (
80- ( props : {
81- model : { featureUnderMouse : Feature ; sources : Source [ ] ; rowHeight : number }
82- height : number
83- offsetMouseCoord : Coord
84- clientMouseCoord : Coord
85- clientRect ?: DOMRect
86- TooltipContents ?: TooltipContentsComponent
87- } ) => {
88- return < Tooltip useClientY TooltipContents = { TooltipContents } { ...props } />
89- } ,
90- )
88+ const WiggleTooltip = observer ( function ( props : {
89+ model : { featureUnderMouse : Feature ; sources : Source [ ] ; rowHeight : number }
90+ height : number
91+ offsetMouseCoord : Coord
92+ clientMouseCoord : Coord
93+ clientRect ?: DOMRect
94+ TooltipContents ?: TooltipContentsComponent
95+ } ) {
96+ return < Tooltip useClientY TooltipContents = { TooltipContents } { ...props } />
97+ } )
98+
9199export default WiggleTooltip
92100
93101export { default as Tooltip } from '../../Tooltip'
0 commit comments