Skip to content

Commit 3016e83

Browse files
committed
allow symbol accessors
1 parent b3d25bd commit 3016e83

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/lib/helpers/resolve.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ export function toChannelOption(
5353
return isDataRecord(channel)
5454
? (channel as ChannelOptions)
5555
: {
56-
value: channel,
57-
scale:
58-
(!isPositionScale && !isOpacityScale && typeof channel === 'number') ||
59-
typeof channel === 'undefined'
60-
? null
61-
: CHANNEL_SCALE[name],
62-
channel: null
63-
};
56+
value: channel,
57+
scale:
58+
(!isPositionScale && !isOpacityScale && typeof channel === 'number') ||
59+
typeof channel === 'undefined'
60+
? null
61+
: CHANNEL_SCALE[name],
62+
channel: null
63+
};
6464
}
6565

6666
export function resolveChannel(
@@ -95,7 +95,7 @@ function resolve(
9595
// so we're passing the original value to accessor functions instead of our wrapped record
9696
return accessor(datum.___orig___ != null ? datum.___orig___ : datum);
9797
// use accessor string
98-
if (typeof accessor === 'string' && datum[accessor] !== undefined) return datum[accessor];
98+
if ((typeof accessor === 'string' || typeof accessor === 'symbol') && datum[accessor] !== undefined) return datum[accessor];
9999
// fallback to channel name as accessor
100100
if (accessor === null && datum[channel] !== undefined) return datum[channel];
101101
return isRawValue(accessor) ? accessor : null;
@@ -110,10 +110,10 @@ function resolve(
110110
return typeof accessor === 'function'
111111
? accessor(datum)
112112
: accessor !== null && isRawValue(accessor)
113-
? accessor
114-
: !Array.isArray(datum) && (scale === 'x' || scale === 'y')
115-
? datum
116-
: null;
113+
? accessor
114+
: !Array.isArray(datum) && (scale === 'x' || scale === 'y')
115+
? datum
116+
: null;
117117
}
118118
}
119119

src/lib/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export type ScaledChannelName =
9393

9494
export type ChannelName = ScaledChannelName | 'z' | 'sort' | 'filter' | 'interval';
9595

96-
export type RawValue = number | Date | boolean | string;
96+
export type RawValue = number | Date | boolean | string | symbol;
9797

9898
export type ScaleOptions = {
9999
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy