@@ -17,8 +17,6 @@ var Color = require('../../components/color');
1717var Drawing = require ( '../../components/drawing' ) ;
1818var Axes = require ( '../../plots/cartesian/axes' ) ;
1919
20- var filterVisible = require ( '../../lib/filter_visible' ) ;
21-
2220var addProjectionsToD3 = require ( './projections' ) ;
2321var createGeoScale = require ( './set_scale' ) ;
2422var createGeoZoom = require ( './zoom' ) ;
@@ -29,6 +27,9 @@ var xmlnsNamespaces = require('../../constants/xmlns_namespaces');
2927var topojsonUtils = require ( '../../lib/topojson_utils' ) ;
3028var topojsonFeature = require ( 'topojson' ) . feature ;
3129
30+ // add a few projection types to d3.geo
31+ addProjectionsToD3 ( d3 ) ;
32+
3233
3334function Geo ( options , fullLayout ) {
3435
@@ -37,9 +38,6 @@ function Geo(options, fullLayout) {
3738 this . container = options . container ;
3839 this . topojsonURL = options . topojsonURL ;
3940
40- // add a few projection types to d3.geo
41- addProjectionsToD3 ( d3 ) ;
42-
4341 this . hoverContainer = null ;
4442
4543 this . topojsonName = null ;
@@ -65,7 +63,7 @@ module.exports = Geo;
6563
6664var proto = Geo . prototype ;
6765
68- proto . plot = function ( geoData , fullLayout , promises ) {
66+ proto . plot = function ( geoCalcData , fullLayout , promises ) {
6967 var _this = this ,
7068 geoLayout = fullLayout [ _this . id ] ,
7169 graphSize = fullLayout . _size ;
@@ -97,7 +95,7 @@ proto.plot = function(geoData, fullLayout, promises) {
9795
9896 if ( PlotlyGeoAssets . topojson [ _this . topojsonName ] !== undefined ) {
9997 _this . topojson = PlotlyGeoAssets . topojson [ _this . topojsonName ] ;
100- _this . onceTopojsonIsLoaded ( geoData , geoLayout ) ;
98+ _this . onceTopojsonIsLoaded ( geoCalcData , geoLayout ) ;
10199 }
102100 else {
103101 topojsonPath = topojsonUtils . getTopojsonPath (
@@ -128,31 +126,32 @@ proto.plot = function(geoData, fullLayout, promises) {
128126 _this . topojson = topojson ;
129127 PlotlyGeoAssets . topojson [ _this . topojsonName ] = topojson ;
130128
131- _this . onceTopojsonIsLoaded ( geoData , geoLayout ) ;
129+ _this . onceTopojsonIsLoaded ( geoCalcData , geoLayout ) ;
132130 resolve ( ) ;
133131 } ) ;
134132 } ) ) ;
135133 }
136134 }
137- else _this . onceTopojsonIsLoaded ( geoData , geoLayout ) ;
135+ else _this . onceTopojsonIsLoaded ( geoCalcData , geoLayout ) ;
138136
139137 // TODO handle topojson-is-loading case
140138 // to avoid making multiple request while streaming
141139} ;
142140
143- proto . onceTopojsonIsLoaded = function ( geoData , geoLayout ) {
141+ proto . onceTopojsonIsLoaded = function ( geoCalcData , geoLayout ) {
144142 var i ;
145143
146144 this . drawLayout ( geoLayout ) ;
147145
148146 var traceHashOld = this . traceHash ;
149147 var traceHash = { } ;
150148
151- for ( i = 0 ; i < geoData . length ; i ++ ) {
152- var trace = geoData [ i ] ;
149+ for ( i = 0 ; i < geoCalcData . length ; i ++ ) {
150+ var calcData = geoCalcData [ i ] ,
151+ trace = calcData [ 0 ] . trace ;
153152
154153 traceHash [ trace . type ] = traceHash [ trace . type ] || [ ] ;
155- traceHash [ trace . type ] . push ( trace ) ;
154+ traceHash [ trace . type ] . push ( calcData ) ;
156155 }
157156
158157 var moduleNamesOld = Object . keys ( traceHashOld ) ;
@@ -165,26 +164,41 @@ proto.onceTopojsonIsLoaded = function(geoData, geoLayout) {
165164 var moduleName = moduleNamesOld [ i ] ;
166165
167166 if ( moduleNames . indexOf ( moduleName ) === - 1 ) {
168- var fakeModule = traceHashOld [ moduleName ] [ 0 ] ;
169- fakeModule . visible = false ;
170- traceHash [ moduleName ] = [ fakeModule ] ;
167+ var fakeCalcTrace = traceHashOld [ moduleName ] [ 0 ] ,
168+ fakeTrace = fakeCalcTrace [ 0 ] . trace ;
169+
170+ fakeTrace . visible = false ;
171+ traceHash [ moduleName ] = [ fakeCalcTrace ] ;
171172 }
172173 }
173174
174175 moduleNames = Object . keys ( traceHash ) ;
175176
176177 for ( i = 0 ; i < moduleNames . length ; i ++ ) {
177- var moduleData = traceHash [ moduleNames [ i ] ] ;
178- var _module = moduleData [ 0 ] . _module ;
178+ var moduleCalcData = traceHash [ moduleNames [ i ] ] ,
179+ _module = moduleCalcData [ 0 ] [ 0 ] . trace . _module ;
179180
180- _module . plot ( this , filterVisible ( moduleData ) , geoLayout ) ;
181+ _module . plot ( this , filterVisible ( moduleCalcData ) , geoLayout ) ;
181182 }
182183
183184 this . traceHash = traceHash ;
184185
185186 this . render ( ) ;
186187} ;
187188
189+ function filterVisible ( calcDataIn ) {
190+ var calcDataOut = [ ] ;
191+
192+ for ( var i = 0 ; i < calcDataIn . length ; i ++ ) {
193+ var calcTrace = calcDataIn [ i ] ,
194+ trace = calcTrace [ 0 ] . trace ;
195+
196+ if ( trace . visible === true ) calcDataOut . push ( calcTrace ) ;
197+ }
198+
199+ return calcDataOut ;
200+ }
201+
188202proto . updateFx = function ( hovermode ) {
189203 this . showHover = ( hovermode !== false ) ;
190204
0 commit comments