File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -109,6 +109,9 @@ export interface Channel {
109
109
*/
110
110
filter ?: ( ( value : any ) => boolean ) | null ;
111
111
112
+ /** Whether to apply the scale’s transform, if any; defaults to true. */
113
+ transform ?: boolean ;
114
+
112
115
/**
113
116
* An internal hint to affect the default construction of scales. For example,
114
117
* the dot mark uses a channel hint to affect the default range of the
Original file line number Diff line number Diff line change @@ -385,20 +385,20 @@ function applyScaleTransforms(channels, options) {
385
385
return channels ;
386
386
}
387
387
388
- // Note: mutates channel.value to apply the scale transform, if any.
388
+ // Note: mutates channel.value to apply the scale transform, if any. Also sets
389
+ // channel.transform to false to prevent duplicate transform application.
389
390
function applyScaleTransform ( channel , options ) {
390
- const { scale} = channel ;
391
- if ( scale == null || channel . transformed ) return ;
391
+ const { scale, transform : t = true } = channel ;
392
+ if ( scale == null || ! t ) return ;
392
393
const {
393
394
type,
394
395
percent,
395
396
interval,
396
397
transform = percent ? ( x ) => x * 100 : maybeIntervalTransform ( interval , type )
397
398
} = options [ scale ] ?? { } ;
398
- if ( transform != null ) {
399
- channel . value = map ( channel . value , transform ) ;
400
- channel . transformed = true ;
401
- }
399
+ if ( transform == null ) return ;
400
+ channel . value = map ( channel . value , transform ) ;
401
+ channel . transform = false ;
402
402
}
403
403
404
404
// An initializer may generate channels without knowing how the downstream mark
You can’t perform that action at this time.
0 commit comments