@@ -6,7 +6,7 @@ import {Dimensions} from "./dimensions.js";
66import { Legends , exposeLegends } from "./legends.js" ;
77import { arrayify , isDomainSort , isScaleOptions , keyword , map , range , second , where , yes } from "./options.js" ;
88import { Scales , ScaleFunctions , autoScaleRange , exposeScales } from "./scales.js" ;
9- import { registry as scaleRegistry } from "./scales/index.js" ;
9+ import { position , registry as scaleRegistry } from "./scales/index.js" ;
1010import { applyInlineStyles , maybeClassName , maybeClip , styles } from "./style.js" ;
1111import { basic , initializer } from "./transforms/basic.js" ;
1212import { maybeInterval } from "./transforms/interval.js" ;
@@ -113,6 +113,7 @@ export function plot(options = {}) {
113113
114114 // Reconstruct scales if new scaled channels were created during reinitialization.
115115 if ( newByScale . size ) {
116+ for ( const key of newByScale ) if ( scaleRegistry . get ( key ) === position ) throw new Error ( `initializers cannot declare position scales: ${ key } ` ) ;
116117 const newScaleDescriptors = Scales ( addScaleChannels ( new Map ( ) , stateByMark , key => newByScale . has ( key ) ) , options ) ;
117118 const newScales = ScaleFunctions ( newScaleDescriptors ) ;
118119 Object . assign ( scaleDescriptors , newScaleDescriptors ) ;
@@ -346,8 +347,7 @@ function inferChannelScale(channels) {
346347 switch ( name ) {
347348 case "fill" : case "stroke" : scale = "color" ; break ;
348349 case "fillOpacity" : case "strokeOpacity" : case "opacity" : scale = "opacity" ; break ;
349- case "r" : case "length" : case "symbol" : scale = name ; break ;
350- default : scale = null ;
350+ default : scale = scaleRegistry . has ( name ) ? name : null ; break ;
351351 }
352352 channel . scale = scale ;
353353 }
0 commit comments