Skip to content

Commit fe0d8bb

Browse files
committed
add geo.proto.updateFx method:
- propatet hovermode update into geo using updateFx - port relayout shortcut from modebar to Plotly.relayout - make toogle hover mode bar using stock Plotly.relayout
1 parent 986e8b0 commit fe0d8bb

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/components/modebar/buttons.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ modeBarButtons.hoverClosestGeo = {
447447
toggle: true,
448448
icon: Icons.tooltip_basic,
449449
gravity: 'ne',
450-
click: handleGeo
450+
click: toggleHover
451451
};
452452

453453
function handleGeo(gd, ev) {
@@ -468,7 +468,6 @@ function handleGeo(gd, ev) {
468468
geo.render();
469469
}
470470
else if(attr === 'reset') geo.zoomReset();
471-
else if(attr === 'hovermode') geo.showHover = !geo.showHover;
472471
}
473472
}
474473

src/plot_api/plot_api.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -2336,9 +2336,9 @@ Plotly.relayout = function relayout(gd, astr, val) {
23362336

23372337
// this is decoupled enough it doesn't need async regardless
23382338
if(domodebar) {
2339+
var subplotIds;
23392340
manageModeBar(gd);
23402341

2341-
var subplotIds;
23422342
subplotIds = Plots.getSubplotIds(fullLayout, 'gl3d');
23432343
for(i = 0; i < subplotIds.length; i++) {
23442344
scene = fullLayout[subplotIds[i]]._scene;
@@ -2350,6 +2350,12 @@ Plotly.relayout = function relayout(gd, astr, val) {
23502350
scene = fullLayout._plots[subplotIds[i]]._scene2d;
23512351
scene.updateFx(fullLayout);
23522352
}
2353+
2354+
subplotIds = Plots.getSubplotIds(fullLayout, 'geo');
2355+
for(i = 0; i < subplotIds.length; i++) {
2356+
var geo = fullLayout[subplotIds[i]]._geo;
2357+
geo.updateFx(fullLayout.hovermode);
2358+
}
23532359
}
23542360
}
23552361

src/plots/geo/geo.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function Geo(options, fullLayout) {
3939
// a subset of https://github.com/d3/d3-geo-projection
4040
addProjectionsToD3();
4141

42-
this.showHover = (fullLayout.hovermode === 'closest');
4342
this.hoverContainer = null;
4443

4544
this.topojsonName = null;
@@ -56,6 +55,7 @@ function Geo(options, fullLayout) {
5655
this.zoomReset = null;
5756

5857
this.makeFramework();
58+
this.updateFx(fullLayout.hovermode);
5959
}
6060

6161
module.exports = Geo;
@@ -174,6 +174,15 @@ proto.onceTopojsonIsLoaded = function(geoData, geoLayout) {
174174
this.render();
175175
};
176176

177+
proto.updateFx = function(hovermode) {
178+
this.showHover = (hovermode !== false);
179+
180+
// TODO should more strict, any layout.hovermode other
181+
// then false will make all geo subplot display hover text.
182+
// Instead each geo should have its own geo.hovermode
183+
// to control hover visibility independently of other subplots.
184+
};
185+
177186
proto.makeProjection = function(geoLayout) {
178187
var projLayout = geoLayout.projection,
179188
projType = projLayout.type,

0 commit comments

Comments
 (0)