Skip to content

Commit dacaa59

Browse files
authored
Merge pull request #6345 from plotly/choroplethmapbox-updateOnSelect
choroplethmapbox update on select
2 parents 71938c3 + 126e535 commit dacaa59

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

Diff for: draftlogs/6345_fix.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix `choroplethmapbox` selection when adding new traces on top [[#6345](https://github.com/plotly/plotly.js/pull/6345)]

Diff for: src/traces/choroplethmapbox/plot.js

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ var proto = ChoroplethMapbox.prototype;
2626

2727
proto.update = function(calcTrace) {
2828
this._update(convert(calcTrace));
29+
30+
// link ref for quick update during selections
31+
calcTrace[0].trace._glTrace = this;
2932
};
3033

3134
proto.updateOnSelect = function(calcTrace) {

Diff for: src/traces/scattermapbox/plot.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ proto.update = function update(calcTrace) {
130130
this.clusterEnabled = hasCluster;
131131
}
132132

133-
// link ref for quick update during selections
133+
// link ref for quick update during selections
134134
calcTrace[0].trace._glTrace = this;
135135
};
136136

Diff for: test/jasmine/tests/select_test.js

+62-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function _newPlot(gd, arg2, arg3, arg4) {
3030
if(!fig.layout) fig.layout = {};
3131
if(!fig.layout.newselection) fig.layout.newselection = {};
3232
fig.layout.newselection.mode = 'gradual';
33-
// complex ouline creation are mainly tested in "gradual" mode here
33+
// complex ouline creation are mainly tested in 'gradual' mode here
3434

3535
return Plotly.newPlot(gd, fig);
3636
}
@@ -3030,6 +3030,67 @@ describe('Test select box and lasso per trace:', function() {
30303030
.then(done, done.fail);
30313031
});
30323032
});
3033+
3034+
it('@gl should work on choroplethmapbox traces after adding a new trace on top:', function(done) {
3035+
var assertPoints = makeAssertPoints(['location', 'z']);
3036+
var assertRanges = makeAssertRanges('mapbox');
3037+
var assertLassoPoints = makeAssertLassoPoints('mapbox');
3038+
var assertSelectedPoints = makeAssertSelectedPoints();
3039+
3040+
var fig = Lib.extendDeep({}, require('@mocks/mapbox_choropleth0.json'));
3041+
3042+
fig.data[0].locations.push(null);
3043+
3044+
fig.layout.dragmode = 'select';
3045+
fig.config = {
3046+
mapboxAccessToken: require('@build/credentials.json').MAPBOX_ACCESS_TOKEN
3047+
};
3048+
addInvisible(fig);
3049+
3050+
var hasCssTransform = false;
3051+
3052+
_newPlot(gd, fig)
3053+
.then(function() {
3054+
// add a scatter points on top
3055+
fig.data[3] = {
3056+
type: 'scattermapbox',
3057+
marker: { size: 40 },
3058+
lon: [-70],
3059+
lat: [40]
3060+
};
3061+
3062+
return Plotly.react(gd, fig);
3063+
})
3064+
.then(function() {
3065+
return _run(hasCssTransform,
3066+
[[150, 150], [300, 300]],
3067+
function() {
3068+
assertPoints([['NY', 10]]);
3069+
assertRanges([[-83.38, 46.13], [-74.06, 39.29]]);
3070+
assertSelectedPoints({0: [0], 3: []});
3071+
},
3072+
null, BOXEVENTS, 'choroplethmapbox select'
3073+
);
3074+
})
3075+
.then(function() {
3076+
return Plotly.relayout(gd, 'dragmode', 'lasso');
3077+
})
3078+
.then(function() {
3079+
return _run(hasCssTransform,
3080+
[[300, 200], [300, 300], [400, 300], [400, 200], [300, 200]],
3081+
function() {
3082+
assertPoints([['MA', 20], []]);
3083+
assertSelectedPoints({0: [1], 3: [0]});
3084+
assertLassoPoints([
3085+
[-74.06, 43.936], [-74.06, 39.293], [-67.84, 39.293],
3086+
[-67.84, 43.936], [-74.06, 43.936]
3087+
]);
3088+
},
3089+
null, LASSOEVENTS, 'choroplethmapbox lasso'
3090+
);
3091+
})
3092+
.then(done, done.fail);
3093+
}, LONG_TIMEOUT_INTERVAL);
30333094
});
30343095

30353096
describe('Test that selections persist:', function() {

0 commit comments

Comments
 (0)