Skip to content

Commit e8ebcb2

Browse files
committed
sub in d3-idomatic update pattern
1 parent f32d425 commit e8ebcb2

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

src/traces/choropleth/plot.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,14 @@ plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
6565
baseLayersOverChoropleth = constants.baseLayersOverChoropleth,
6666
layerName;
6767

68-
// TODO move to more d3-idiomatic pattern (that's work on replot)
69-
// N.B. html('') does not work in IE11
70-
gChoropleth.selectAll('*').remove();
71-
gBaseLayerOverChoropleth.selectAll('*').remove();
72-
7368
var gChoroplethTraces = gChoropleth
74-
.selectAll('g.trace.scatter')
69+
.selectAll('g.trace.choropleth')
7570
.data(choroplethData);
7671

7772
gChoroplethTraces.enter().append('g')
78-
.attr('class', 'trace choropleth');
73+
.attr('class', 'trace choropleth');
74+
75+
gChoroplethTraces.exit().remove();
7976

8077
gChoroplethTraces
8178
.each(function(trace) {
@@ -117,6 +114,8 @@ plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
117114
});
118115

119116
// some baselayers are drawn over choropleth
117+
gBaseLayerOverChoropleth.selectAll('*').remove();
118+
120119
for(var i = 0; i < baseLayersOverChoropleth.length; i++) {
121120
layerName = baseLayersOverChoropleth[i];
122121
gBaseLayer.select('g.' + layerName).remove();

src/traces/scattergeo/plot.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,14 @@ function makeLineGeoJSON(trace) {
116116
}
117117

118118
plotScatterGeo.plot = function(geo, scattergeoData) {
119-
var gScatterGeo = geo.framework.select('g.scattergeolayer'),
120-
121-
// TODO move to more d3-idiomatic pattern (that's work on replot)
122-
// N.B. html('') does not work in IE11
123-
gScatterGeo.selectAll('*').remove();
124-
125-
var gScatterGeoTraces = gScatterGeo
126-
.selectAll('g.trace.scatter')
119+
var gScatterGeoTraces = geo.framework.select('.scattergeolayer')
120+
.selectAll('g.trace.scattergeo')
127121
.data(scattergeoData);
128122

129123
gScatterGeoTraces.enter().append('g')
130-
.attr('class', 'trace scattergeo');
124+
.attr('class', 'trace scattergeo');
125+
126+
gScatterGeoTraces.exit().remove();
131127

132128
// TODO add hover - how?
133129
gScatterGeoTraces

0 commit comments

Comments
 (0)