@@ -63,7 +63,7 @@ function Channel(data, {scale, type, value}) {
6363// This allows transforms to behave equivalently to channels.
6464export function valueof ( data , value , type ) {
6565 const array = type === undefined ? Array : type ;
66- return typeof value === "string" ? array . from ( data , field ( value ) )
66+ return typeof value === "string" ? isColumnar ( data ) ? data . column ( value ) : array . from ( data , field ( value ) )
6767 : typeof value === "function" ? array . from ( data , value )
6868 : typeof value === "number" || value instanceof Date ? array . from ( data , constant ( value ) )
6969 : value && typeof value . transform === "function" ? arrayify ( value . transform ( data ) , type )
@@ -133,7 +133,7 @@ export function keyword(input, name, allowed) {
133133// the specified data is null or undefined, returns the value as-is.
134134export function arrayify ( data , type ) {
135135 return data == null ? data : ( type === undefined
136- ? ( data instanceof Array || data instanceof TypedArray ) ? data : Array . from ( data )
136+ ? ( data instanceof Array || data instanceof TypedArray || isColumnar ( data ) ) ? data : Array . from ( data )
137137 : ( data instanceof type ? data : type . from ( data ) ) ) ;
138138}
139139
@@ -180,7 +180,7 @@ export function titleGroup(L) {
180180
181181// Returns a Uint32Array with elements [0, 1, 2, … data.length - 1].
182182export function range ( data ) {
183- return Uint32Array . from ( data , indexOf ) ;
183+ return Uint32Array . from ( data . length ? { length : data . length } : data , indexOf ) ;
184184}
185185
186186// Returns an array [values[index[0]], values[index[1]], …].
@@ -340,3 +340,7 @@ export function isTemporal(values) {
340340 return value instanceof Date ;
341341 }
342342}
343+
344+ function isColumnar ( data ) {
345+ return typeof data . column === "function" ;
346+ }
0 commit comments