@@ -10,7 +10,8 @@ import {
1010 coerceDates
1111} from "./options.js" ;
1212import { orderof } from "./order.js" ;
13- import { createProjection , projectionAspectRatio } from "./projection.js" ;
13+ import { createDimensions } from "./dimensions.js" ;
14+ import { createProjection } from "./projection.js" ;
1415import { registry , color , position , radius , opacity , symbol , length } from "./scales/index.js" ;
1516import {
1617 createScaleLinear ,
@@ -527,24 +528,15 @@ export function scale(options = {}) {
527528 if ( ! registry . has ( key ) ) continue ; // ignore unknown properties
528529 if ( ! isScaleOptions ( options [ key ] ) ) continue ; // e.g., ignore {color: "red"}
529530 if ( scale !== undefined ) throw new Error ( "ambiguous scale definition; multiple scales found" ) ;
530- scale = key === "projection" ? scaleProjection ( options [ key ] ) : exposeScale ( normalizeScale ( key , options [ key ] ) ) ;
531+ scale = key === "projection" ? exposeProjection ( options [ key ] ) : exposeScale ( normalizeScale ( key , options [ key ] ) ) ;
531532 }
532533 if ( scale === undefined ) throw new Error ( "invalid scale definition; no scale found" ) ;
533534 return scale ;
534535}
535536
536- function scaleProjection ( {
537- width = 640 ,
538- height,
539- margin = 0 ,
540- marginTop = margin ,
541- marginRight = margin ,
542- marginBottom = margin ,
543- marginLeft = margin ,
544- ...projection
545- } ) {
546- if ( height === undefined ) height = width * projectionAspectRatio ( projection ) ;
547- const p = createProjection ( { projection} , { width, height, marginTop, marginRight, marginBottom, marginLeft} ) ;
537+ function exposeProjection ( { width, height, margin, marginTop, marginRight, marginBottom, marginLeft, ...projection } ) {
538+ const dimensions = createDimensions ( { } , [ ] , { projection, width, height, margin, marginTop, marginRight, marginBottom, marginLeft} ) ; // prettier-ignore
539+ const p = createProjection ( { projection} , dimensions ) ;
548540 if ( p === undefined ) throw new Error ( "invalid scale definition; unknown projection" ) ;
549541 return p ;
550542}
0 commit comments