@@ -135,9 +135,9 @@ export class Tip extends Mark {
135
135
const value = channel . value [ i ] ;
136
136
if ( ! defined ( value ) && channel . scale == null ) continue ;
137
137
if ( key === "x2" && "x1" in sources ) {
138
- yield { name : formatLabel ( scales , channel , "x" ) , value : formatPair ( sources . x1 , channel , i ) } ;
138
+ yield { name : formatPairLabel ( scales , sources . x1 , channel , "x" ) , value : formatPair ( sources . x1 , channel , i ) } ;
139
139
} else if ( key === "y2" && "y1" in sources ) {
140
- yield { name : formatLabel ( scales , channel , "y" ) , value : formatPair ( sources . y1 , channel , i ) } ;
140
+ yield { name : formatPairLabel ( scales , sources . y1 , channel , "y" ) , value : formatPair ( sources . y1 , channel , i ) } ;
141
141
} else {
142
142
const scale = channel . scale ;
143
143
const line = { name : formatLabel ( scales , channel , key ) , value : formatDefault ( value ) } ;
@@ -334,6 +334,12 @@ function formatPair(c1, c2, i) {
334
334
: `${ formatDefault ( c1 . value [ i ] ) } –${ formatDefault ( c2 . value [ i ] ) } ` ;
335
335
}
336
336
337
+ function formatPairLabel ( scales , c1 , c2 , defaultLabel ) {
338
+ const l1 = formatLabel ( scales , c1 , defaultLabel ) ;
339
+ const l2 = formatLabel ( scales , c2 , defaultLabel ) ;
340
+ return l1 === l2 ? l1 : `${ l1 } –${ l2 } ` ;
341
+ }
342
+
337
343
function formatLabel ( scales , c , defaultLabel ) {
338
344
return String ( scales [ c . scale ] ?. label ?? c ?. label ?? defaultLabel ) ;
339
345
}
0 commit comments