@@ -125,15 +125,15 @@ export class Tip extends Mark {
125
125
if ( ! defined ( value ) && channel . scale == null ) continue ;
126
126
const color = channel . scale === "color" ? channels [ key ] [ i ] : undefined ;
127
127
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 ) ] ;
129
129
} 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 ) ] ;
131
131
} else {
132
- yield [ formatLabel ( scales , channel ) ?? key , formatDefault ( value ) , color ] ;
132
+ yield [ formatLabel ( scales , channel , key ) , formatDefault ( value ) , color ] ;
133
133
}
134
134
}
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 ) ] ;
137
137
}
138
138
139
139
// We don’t call applyChannelStyles because we only use the channels to
@@ -159,7 +159,10 @@ export class Tip extends Mark {
159
159
this . setAttribute ( "fill-opacity" , 1 ) ;
160
160
this . setAttribute ( "stroke" , "none" ) ;
161
161
// iteratively render each channel value
162
+ const names = new Set ( ) ;
162
163
for ( const [ name , value , color ] of format ( sources , i ) ) {
164
+ if ( name && names . has ( name ) ) continue ;
165
+ else names . add ( name ) ;
163
166
renderLine ( that , name , value , color ) ;
164
167
}
165
168
} )
@@ -316,6 +319,6 @@ function formatPair(c1, c2, i) {
316
319
: `${ formatDefault ( c1 . value [ i ] ) } –${ formatDefault ( c2 . value [ i ] ) } ` ;
317
320
}
318
321
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 ) ;
321
324
}
0 commit comments