@@ -314,7 +314,7 @@ proto.updateBaseLayers = function(fullLayout, geoLayout) {
314314 } else if ( isLineLayer ( d ) || isFillLayer ( d ) ) {
315315 path . datum ( topojsonFeature ( topojson , topojson . objects [ d ] ) ) ;
316316 } else if ( isAxisLayer ( d ) ) {
317- path . datum ( makeGraticule ( d , geoLayout ) )
317+ path . datum ( makeGraticule ( d , geoLayout , fullLayout ) )
318318 . call ( Color . stroke , geoLayout [ d ] . gridcolor )
319319 . call ( Drawing . dashLine , '' , geoLayout [ d ] . gridwidth ) ;
320320 }
@@ -660,20 +660,58 @@ function getProjection(geoLayout) {
660660 return projection ;
661661}
662662
663- function makeGraticule ( axisName , geoLayout ) {
664- var axisLayout = geoLayout [ axisName ] ;
665- var dtick = axisLayout . dtick ;
663+ function makeGraticule ( axisName , geoLayout , fullLayout ) {
664+ // equivalent to the d3 "ε"
665+ var epsilon = 1e-6 ;
666+ // same as the geoGraticule default
667+ var precision = 2.5 ;
668+
669+ var axLayout = geoLayout [ axisName ] ;
666670 var scopeDefaults = constants . scopeDefaults [ geoLayout . scope ] ;
667- var lonaxisRange = scopeDefaults . lonaxisRange ;
668- var lataxisRange = scopeDefaults . lataxisRange ;
669- var step = axisName === 'lonaxis' ? [ dtick ] : [ 0 , dtick ] ;
670-
671- return d3 . geo . graticule ( )
672- . extent ( [
673- [ lonaxisRange [ 0 ] , lataxisRange [ 0 ] ] ,
674- [ lonaxisRange [ 1 ] , lataxisRange [ 1 ] ]
675- ] )
676- . step ( step ) ;
671+ var rng ;
672+ var oppRng ;
673+ var coordFn ;
674+
675+ if ( axisName === 'lonaxis' ) {
676+ rng = scopeDefaults . lonaxisRange ;
677+ oppRng = scopeDefaults . lataxisRange ;
678+ coordFn = function ( v , l ) { return [ v , l ] ; } ;
679+ } else if ( axisName === 'lataxis' ) {
680+ rng = scopeDefaults . lataxisRange ;
681+ oppRng = scopeDefaults . lonaxisRange ;
682+ coordFn = function ( v , l ) { return [ l , v ] ; } ;
683+ }
684+
685+ var dummyAx = {
686+ type : 'linear' ,
687+ range : [ rng [ 0 ] , rng [ 1 ] - epsilon ] ,
688+ tick0 : axLayout . tick0 ,
689+ dtick : axLayout . dtick
690+ } ;
691+
692+ Axes . setConvert ( dummyAx , fullLayout ) ;
693+ var vals = Axes . calcTicks ( dummyAx ) ;
694+
695+ // remove duplicate on antimeridian
696+ if ( ! geoLayout . isScoped && axisName === 'lonaxis' ) {
697+ vals . pop ( ) ;
698+ }
699+
700+ var len = vals . length ;
701+ var coords = new Array ( len ) ;
702+
703+ for ( var i = 0 ; i < len ; i ++ ) {
704+ var v = vals [ i ] . x ;
705+ var line = coords [ i ] = [ ] ;
706+ for ( var l = oppRng [ 0 ] ; l < oppRng [ 1 ] + precision ; l += precision ) {
707+ line . push ( coordFn ( v , l ) ) ;
708+ }
709+ }
710+
711+ return {
712+ type : 'MultiLineString' ,
713+ coordinates : coords
714+ } ;
677715}
678716
679717// Returns polygon GeoJSON corresponding to lon/lat range box
0 commit comments