@@ -125,15 +125,15 @@ export class Tip extends Mark {
125125 if ( ! defined ( value ) && channel . scale == null ) continue ;
126126 const color = channel . scale === "color" ? channels [ key ] [ i ] : undefined ;
127127 if ( key === "x2" && "x1" in sources ) {
128- yield [ formatLabel ( scales , channel ) ?? "x" , formatPair ( sources . x1 , channel , i ) ] ;
128+ yield [ formatLabel ( scales , channel , "x" ) , formatPair ( sources . x1 , channel , i ) ] ;
129129 } else if ( key === "y2" && "y1" in sources ) {
130- yield [ formatLabel ( scales , channel ) ?? "y" , formatPair ( sources . y1 , channel , i ) ] ;
130+ yield [ formatLabel ( scales , channel , "y" ) , formatPair ( sources . y1 , channel , i ) ] ;
131131 } else {
132- yield [ formatLabel ( scales , channel ) ?? key , formatDefault ( value ) , color ] ;
132+ yield [ formatLabel ( scales , channel , key ) , formatDefault ( value ) , color ] ;
133133 }
134134 }
135- if ( index . fi != null && fx ) yield [ fx . label ?? "fx" , formatFx ( index . fx ) ] ;
136- if ( index . fi != null && fy ) yield [ fy . label ?? "fy" , formatFy ( index . fy ) ] ;
135+ if ( index . fi != null && fx ) yield [ String ( fx . label ?? "fx" ) , formatFx ( index . fx ) ] ;
136+ if ( index . fi != null && fy ) yield [ String ( fy . label ?? "fy" ) , formatFy ( index . fy ) ] ;
137137 }
138138
139139 // We don’t call applyChannelStyles because we only use the channels to
@@ -159,7 +159,10 @@ export class Tip extends Mark {
159159 this . setAttribute ( "fill-opacity" , 1 ) ;
160160 this . setAttribute ( "stroke" , "none" ) ;
161161 // iteratively render each channel value
162+ const names = new Set ( ) ;
162163 for ( const [ name , value , color ] of format ( sources , i ) ) {
164+ if ( name && names . has ( name ) ) continue ;
165+ else names . add ( name ) ;
163166 renderLine ( that , name , value , color ) ;
164167 }
165168 } )
@@ -316,6 +319,6 @@ function formatPair(c1, c2, i) {
316319 : `${ formatDefault ( c1 . value [ i ] ) } –${ formatDefault ( c2 . value [ i ] ) } ` ;
317320}
318321
319- function formatLabel ( scales , c ) {
320- return scales [ c . scale ] ?. label ?? c ?. label ;
322+ function formatLabel ( scales , c , defaultLabel ) {
323+ return String ( scales [ c . scale ] ?. label ?? c ?. label ?? defaultLabel ) ;
321324}
0 commit comments