@@ -43,7 +43,6 @@ export class Tip extends Mark {
43
43
lineWidth = 20 ,
44
44
frameAnchor,
45
45
format,
46
- source, // TODO a better way to detect channels that will be derived?
47
46
textAnchor = "start" ,
48
47
textOverflow,
49
48
textPadding = 8 ,
@@ -84,7 +83,7 @@ export class Tip extends Mark {
84
83
for ( const key in defaults ) if ( key in this . channels ) this [ key ] = defaults [ key ] ; // apply default even if channel
85
84
this . splitLines = splitter ( this ) ;
86
85
this . clipLine = clipper ( this ) ;
87
- this . format = maybeTipFormat ( this . channels , source ?. channels , format ) ;
86
+ this . format = maybeTipFormat ( this . channels , format ) ;
88
87
}
89
88
render ( index , scales , values , dimensions , context ) {
90
89
const mark = this ;
@@ -320,14 +319,14 @@ function getSources({channels}) {
320
319
}
321
320
322
321
// Note: mutates channels!
323
- function maybeTipFormat ( channels , sourceChannels , format ) {
322
+ function maybeTipFormat ( channels , format ) {
324
323
if ( format === undefined ) return ;
325
324
if ( typeof format === "function" ) {
326
325
return function ( i , index , channels , scales , { data} ) {
327
326
return format . call ( this , data [ i ] , i ) ;
328
327
} ;
329
328
}
330
- format = Array . from ( format , ( f ) => maybeTipFormatItem ( f , channels , sourceChannels ) ) ;
329
+ format = Array . from ( format , ( f ) => maybeTipFormatItem ( f , channels ) ) ;
331
330
return function * ( i , index , channels , scales , values ) {
332
331
for ( let { label, channel : key , format : formatValue } of format ) {
333
332
if ( label === undefined ) label = formatLabel ( scales , channels , key ) ;
@@ -339,22 +338,22 @@ function maybeTipFormat(channels, sourceChannels, format) {
339
338
} ;
340
339
} else {
341
340
if ( formatValue === undefined ) formatValue = formatDefault ;
342
- const value = values [ key ] [ i ] ;
343
- const scale = channels [ key ] . scale ;
341
+ const channel = channels [ key ] ;
342
+ const scale = channel . scale ;
344
343
yield {
345
344
label,
346
- value : formatValue ( value ) ,
347
- color : scale === "color" ? value : null ,
348
- opacity : scale === "opacity" ? value : null
345
+ value : formatValue ( channel . value [ i ] ) ,
346
+ color : scale === "color" ? values [ key ] [ i ] : null ,
347
+ opacity : scale === "opacity" ? values [ key ] [ i ] : null
349
348
} ;
350
349
}
351
350
}
352
351
} ;
353
352
}
354
353
355
354
// Note: mutates channels!
356
- function maybeTipFormatItem ( f , channels , sourceChannels ) {
357
- if ( typeof f === "string" ) f = channels [ f ] || sourceChannels ?. [ f ] ? { channel : f } : { value : f } ; // shorthand string
355
+ function maybeTipFormatItem ( f , channels ) {
356
+ if ( typeof f === "string" ) f = { channel : f } ; // shorthand channel name
358
357
f = maybeValue ( f ) ; // shorthand function, array, etc.
359
358
if ( typeof f . format === "string" ) f = { ...f , format : numberFormat ( f . format ) } ; // shorthand format; TODO dates
360
359
if ( f . value !== undefined ) f = { ...f , channel : deriveChannel ( channels , f ) } ; // shorthand channel
0 commit comments