Skip to content

Commit 3beb45f

Browse files
committed
transform instead of transformed
1 parent 6d61898 commit 3beb45f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/channel.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export interface Channel {
109109
*/
110110
filter?: ((value: any) => boolean) | null;
111111

112+
/** Whether to apply the scale’s transform, if any; defaults to true. */
113+
transform?: boolean;
114+
112115
/**
113116
* An internal hint to affect the default construction of scales. For example,
114117
* the dot mark uses a channel hint to affect the default range of the

src/plot.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,20 +385,20 @@ function applyScaleTransforms(channels, options) {
385385
return channels;
386386
}
387387

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.
389390
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;
392393
const {
393394
type,
394395
percent,
395396
interval,
396397
transform = percent ? (x) => x * 100 : maybeIntervalTransform(interval, type)
397398
} = 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;
402402
}
403403

404404
// An initializer may generate channels without knowing how the downstream mark

0 commit comments

Comments
 (0)