Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abdce19

Browse files
committed
lib.filterVisible
1 parent 9ec6d8f commit abdce19

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

src/lib/filter_visible.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2012-2016, Plotly, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
10+
'use strict';
11+
12+
module.exports = function filterVisible(dataIn) {
13+
var dataOut = [];
14+
15+
for(var i = 0; i < dataIn.length; i++) {
16+
var trace = dataIn[i];
17+
18+
if(trace.visible === true) dataOut.push(trace);
19+
}
20+
21+
return dataOut;
22+
};

src/plots/geo/geo.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ var Color = require('../../components/color');
1717
var Drawing = require('../../components/drawing');
1818
var Axes = require('../../plots/cartesian/axes');
1919

20+
var filterVisible = require('../../lib/filter_visible');
21+
2022
var addProjectionsToD3 = require('./projections');
2123
var createGeoScale = require('./set_scale');
2224
var createGeoZoom = require('./zoom');
@@ -139,20 +141,6 @@ proto.plot = function(geoData, fullLayout, promises) {
139141
// to avoid making multiple request while streaming
140142
};
141143

142-
// filter out non-visible trace
143-
// geo plot routine use the classic join/enter/exit pattern to update traces
144-
function filterData(dataIn) {
145-
var dataOut = [];
146-
147-
for(var i = 0; i < dataIn.length; i++) {
148-
var trace = dataIn[i];
149-
150-
if(trace.visible === true) dataOut.push(trace);
151-
}
152-
153-
return dataOut;
154-
}
155-
156144
proto.onceTopojsonIsLoaded = function(geoData, geoLayout) {
157145
var i;
158146

@@ -190,7 +178,7 @@ proto.onceTopojsonIsLoaded = function(geoData, geoLayout) {
190178
var moduleData = traceHash[moduleNames[i]];
191179
var _module = moduleData[0]._module;
192180

193-
_module.plot(this, filterData(moduleData), geoLayout);
181+
_module.plot(this, filterVisible(moduleData), geoLayout);
194182
}
195183

196184
this.traceHash = traceHash;

0 commit comments

Comments
 (0)