10000 Subplot mode bars by etpinard · Pull Request #258 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Subplot mode bars #258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Feb 17, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
089b335
factor out isSelectable routine
etpinard Feb 11, 2016
fcdf05a
generalize is-active modebar update,
etpinard Feb 11, 2016
91ce34f
make dragmode and hovermode attribute of each scenes:
etpinard Feb 11, 2016
74e7e33
add fx and gl3d defaults tests
etpinard Feb 11, 2016
760bda3
don't show 3d hover labels when scene.hovermode is false
etpinard Feb 11, 2016
1180a8f
make 3d drag modebar button update scene.dragmode,
etpinard Feb 16, 2016
9010006
make camera modebar button update camera via fullLayou.scene?,
etpinard Feb 16, 2016
11189ae
make hover button extend current scene layout,
etpinard Feb 16, 2016
524ce13
use camera spec of own scene to init the camera,
etpinard Feb 16, 2016
9354fb3
rename scene.proto.handleDragmode --> scene.proto.updateFx
etpinard Feb 16, 2016
48d5957
lint
etpinard Feb 16, 2016
bc90474
add several 3d mode bar jasmine tests,
etpinard Feb 16, 2016
986e8b0
make modebar button assest abstraction more robust
etpinard Feb 16, 2016
fe0d8bb
add geo.proto.updateFx method:
etpinard Feb 16, 2016
0c5cf56
add multi-plot-type graphs mode bar button logic:
etpinard Feb 16, 2016
266caf0
generalize toggleHover mode bar button handler,
etpinard Feb 16, 2016
790bc73
add cartesian, geo and pie mode bar click handler tests
etpinard Feb 16, 2016
05a1b4f
bump down precision for circleCI
etpinard Feb 16, 2016
4babccb
make append buttons to add step more readable
etpinard Feb 17, 2016
9f3d14e
store previous scene state in button obj,
etpinard Feb 17, 2016
da5ea21
:cow2:
etpinard Feb 17, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add multi-plot-type graphs mode bar button logic:
- graphs with more than one plot types get 'union buttons'
  which reset the view or toggle hover labels across all subplots.
  • Loading branch information
etpinard committed Feb 16, 2016
commit 0c5cf5633cac8aecae0850871e4c05c6c39fb8cd
39 changes: 39 additions & 0 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,42 @@ function toggleHover(gd) {

Plotly.relayout(gd, 'hovermode', newHover);
}

// buttons when more then one plot types are present

modeBarButtons.toggleHover = {
name: 'toggleHover',
title: 'Toggle show closest data on hover',
attr: 'hovermode',
val: null,
toggle: true,
icon: Icons.tooltip_basic,
gravity: 'ne',
click: function(gd, ev) {
toggleHover(gd);

// the 3d hovermode update must come
// last so that layout.hovermode update does not
// override scene?.hovermode?.layout.
handleHover3d(gd, ev);
}
};

modeBarButtons.resetViews = {
name: 'resetViews',
title: 'Reset views',
icon: Icons.home,
click: function(gd, ev) {
var button = ev.currentTarget;

button.setAttribute('data-attr', 'zoom');
button.setAttribute('data-val', 'reset');
handleCartesian(gd, ev);

button.setAttribute('data-attr', 'resetLastSave');
handleCamera3d(gd, ev);

// N.B handleCamera3d also triggers a replot for
// geo subplots.
}
};
18 changes: 14 additions & 4 deletions src/components/modebar/manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
// buttons common to all plot types
addGroup(['toImage', 'sendDataToCloud']);

// graphs with more than one plot types get 'union buttons'
// which reset the view or toggle hover labels across all subplots.
if((hasCartesian || hasGL2D || hasPie) + hasGeo + hasGL3D > 1) {
addGroup(['resetViews', 'toggleHover']);
return appendButtonsToAdd(groups);
}

if(hasGL3D) {
addGroup(['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation']);
addGroup(['resetCameraDefault3d', 'resetCameraLastSave3d']);
Expand Down Expand Up @@ -136,13 +143,16 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
addGroup(['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']);
}

if(hasCartesian) {
addGroup(['hoverClosestCartesian', 'hoverCompareCartesian']);
if(hasCartesian && hasPie) {
addGroup(['toggleHover']);
}
if(hasGL2D) {
else if(hasGL2D) {
addGroup(['hoverClosestGl2d']);
}
if(hasPie) {
else if(hasCartesian) {
addGroup(['hoverClosestCartesian', 'hoverCompareCartesian']);
}
else if(hasPie) {
addGroup(['hoverClosestPie']);
}

Expand Down
10000
89 changes: 87 additions & 2 deletions test/jasmine/tests/modebar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ describe('ModeBar', function() {
gd._fullLayout._hasCartesian = true;
gd._fullLayout.xaxis = {fixedrange: false};
gd._fullData = [{
type:'scatter',
type: 'scatter',
visible: true,
mode:'markers',
mode: 'markers',
_module: {selectPoints: true}
}];

Expand Down Expand Up @@ -295,6 +295,91 @@ describe('ModeBar', function() {
checkButtons(modeBar, buttons, 1);
});

it('creates mode bar (cartesian + gl3d version)', function() {
var buttons = getButtons([
['toImage', 'sendDataToCloud'],
['resetViews', 'toggleHover']
]);

var gd = getMockGraphInfo();
gd._fullLayout._hasCartesian = true;
gd._fullLayout._hasGL3D = true;
gd._fullLayout._hasGeo = false;
gd._fullLayout._hasGL2D = false;
gd._fullLayout._hasPie = false;

manageModeBar(gd);
var modeBar = gd._fullLayout._modeBar;

checkButtons(modeBar, buttons, 1);
});

it('creates mode bar (cartesian + geo version)', function() {
var buttons = getButtons([
['toImage', 'sendDataToCloud'],
['resetViews', 'toggleHover']
]);

var gd = getMockGraphInfo();
gd._fullLayout._hasCartesian = true;
gd._fullLayout._hasGL3D = false;
gd._fullLayout._hasGeo = true;
gd._fullLayout._hasGL2D = false;
gd._fullLayout._hasPie = false;

manageModeBar(gd);
var modeBar = gd._fullLayout._modeBar;

checkButtons(modeBar, buttons, 1);
});

it('creates mode bar (cartesian + pie version)', function() {
var buttons = getButtons([
['toImage', 'sendDataToCloud'],
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
['toggleHover']
]);

var gd = getMockGraphInfo();
gd._fullLayout._hasCartesian = true;
gd._fullData = [{
type: 'scatter',
visible: true,
mode: 'markers',
_module: {selectPoints: true}
}];
gd._fullLayout.xaxis = {fixedrange: false};
gd._fullLayout._hasGL3D = false;
gd._fullLayout._hasGeo = false;
gd._fullLayout._hasGL2D = false;
gd._fullLayout._hasPie = true;

manageModeBar(gd);
var modeBar = gd._fullLayout._modeBar;

checkButtons(modeBar, buttons, 1);
});

it('creates mode bar (gl3d + geo version)', function() {
var buttons = getButtons([
['toImage', 'sendDataToCloud'],
['resetViews', 'toggleHover']
]);

var gd = getMockGraphInfo();
gd._fullLayout._hasCartesian = false;
gd._fullLayout._hasGL3D = true;
gd._fullLayout._hasGeo = true;
gd._fullLayout._hasGL2D = false;
gd._fullLayout._hasPie = false;

manageModeBar(gd);
var modeBar = gd._fullLayout._modeBar;

checkButtons(modeBar, buttons, 1);
});

it('throws an error if modeBarButtonsToRemove isn\'t an array', function() {
var gd = getMockGraphInfo();
gd._context.modeBarButtonsToRemove = 'not gonna work';
Expand Down
0