File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -77,14 +77,18 @@ export function Projection(
7777 const [ [ x0 , y0 ] , [ x1 , y1 ] ] = geoPath ( projection ) . bounds ( domain ) ;
7878 const k = Math . min ( dx / ( x1 - x0 ) , dy / ( y1 - y0 ) ) ;
7979 if ( k > 0 ) {
80- tx -= ( k * ( x0 + x1 ) - dx ) / 2 ;
81- ty -= ( k * ( y0 + y1 ) - dy ) / 2 ;
82- const { stream : affine } = geoTransform ( {
83- point ( x , y ) {
84- this . stream . point ( x * k + tx , y * k + ty ) ;
85- }
86- } ) ;
87- return { stream : ( s ) => projection . stream ( affine ( s ) ) } ;
80+ const cx = ( k * ( x0 + x1 ) - dx ) / 2 ;
81+ const cy = ( k * ( y0 + y1 ) - dy ) / 2 ;
82+ if ( isFinite ( cx + cy ) ) {
83+ tx -= cx ;
84+ ty -= cy ;
85+ const { stream : affine } = geoTransform ( {
86+ point ( x , y ) {
87+ this . stream . point ( x * k + tx , y * k + ty ) ;
88+ }
89+ } ) ;
90+ return { stream : ( s ) => projection . stream ( affine ( s ) ) } ;
91+ }
8892 }
8993 warn ( `The projection could not be fit to the specified domain. Using the default scale.` ) ;
9094 }
You can’t perform that action at this time.
0 commit comments