@@ -135,9 +135,9 @@ export class Tip extends Mark {
135135 const value = channel . value [ i ] ;
136136 if ( ! defined ( value ) && channel . scale == null ) continue ;
137137 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 ) } ;
139139 } 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 ) } ;
141141 } else {
142142 const scale = channel . scale ;
143143 const line = { name : formatLabel ( scales , channel , key ) , value : formatDefault ( value ) } ;
@@ -334,6 +334,12 @@ function formatPair(c1, c2, i) {
334334 : `${ formatDefault ( c1 . value [ i ] ) } –${ formatDefault ( c2 . value [ i ] ) } ` ;
335335}
336336
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+
337343function formatLabel ( scales , c , defaultLabel ) {
338344 return String ( scales [ c . scale ] ?. label ?? c ?. label ?? defaultLabel ) ;
339345}
0 commit comments