8000 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 several 3d mode bar jasmine tests,
 - these will only run locally at the moment as
   and until #241
   is resolved.
  • Loading branch information
etpinard committed Feb 16, 2016
commit bc90474b7f9c3ba2eee4ee24ef574750e025771c
23 changes: 23 additions & 0 deletions test/jasmine/assets/modebar_button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

var d3 = require('d3');

var modeBarButtons = require('@src/components/modebar/buttons');


module.exports = function selectButton(modeBar, name) {
var button = d3.select(modeBar.element)
.select('[data-title="' + modeBarButtons[name].title + '"]')
.node();

button.click = function() {
var ev = new window.MouseEvent('click');
button.dispatchEvent(ev);
};

button.isActive = function() {
return d3.select(button).classed('active');
};

return button;
};
170 changes: 170 additions & 0 deletions test/jasmine/tests/gl_plot_interact_test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
var d3 = require('d3');

var Plotly = require('@lib/index');
var Plots = require('@src/plots/plots');
var Lib = require('@src/lib');

var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var selectButton = require('../assets/modebar_button');

/*
* WebGL interaction test cases fail on the CircleCI
Expand Down Expand Up @@ -43,4 +46,171 @@ describe('Test plot structure', function() {
});
});

describe('gl3d modebar click handlers', function() {
var gd, modeBar;

beforeEach(function(done) {
var mockData = [{
type: 'scatter3d'
}, {
type: 'surface', scene: 'scene2'
}];

var mockLayout = {
scene: { camera: { eye: { x: 0.1, y: 0.1, z: 1 }}},
scene2: { camera: { eye: { x: 2.5, y: 2.5, z: 2.5 }}}
};

gd = createGraphDiv();
Plotly.plot(gd, mockData, mockLayout).then(function() {
modeBar = gd._fullLayout._modeBar;
done();
});
});

function assertScenes(cont, attr, val) {
var sceneIds = Plots.getSubplotIds(cont, 'gl3d');

sceneIds.forEach(function(sceneId) {
var thisVal = Lib.nestedProperty(cont[sceneId], attr).get();
expect(thisVal).toEqual(val);
});
}

describe('button zoom3d', function() {
it('should updates the scene dragmode and dragmode button', function() {
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
buttonZoom3d = selectButton(modeBar, 'zoom3d');

assertScenes(gd._fullLayout, 'dragmode', 'turntable');
expect(buttonTurntable.isActive()).toBe(true);
expect(buttonZoom3d.isActive()).toBe(false);

buttonZoom3d.click();
assertScenes(gd.layout, 'dragmode', 'zoom');
expect(gd.layout.dragmode).toBe(undefined);
expect(gd._fullLayout.dragmode).toBe('zoom');
expect(buttonTurntable.isActive()).toBe(false);
expect(buttonZoom3d.isActive()).toBe(true);

buttonTurntable.click();
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
expect(buttonTurntable.isActive()).toBe(true);
expect(buttonZoom3d.isActive()).toBe(false);
});
});

describe('button pan3d', function() {
it('should updates the scene dragmode and dragmode button', function() {
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
buttonPan3d = selectButton(modeBar, 'pan3d');

assertScenes(gd._fullLayout, 'dragmode', 'turntable');
expect(buttonTurntable.isActive()).toBe(true);
expect(buttonPan3d.isActive()).toBe(false);

buttonPan3d.click();
assertScenes(gd.layout, 'dragmode', 'pan');
expect(gd.layout.dragmode).toBe(undefined);
expect(gd._fullLayout.dragmode).toBe('zoom');
expect(buttonTurntable.isActive()).toBe(false);
expect(buttonPan3d.isActive()).toBe(true);

buttonTurntable.click();
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
expect(buttonTurntable.isActive()).toBe(true);
expect(buttonPan3d.isActive()).toBe(false);
});
});

describe('button orbitRotation', function() {
it('should updates the scene dragmode and dragmode button', function() {
var buttonTurntable = selectButton(modeBar, 'tableRotation'),
buttonOrbit = selectButton(modeBar, 'orbitRotation');

assertScenes(gd._fullLayout, 'dragmode', 'turntable');
expect(buttonTurntable.isActive()).toBe(true);
expect(buttonOrbit.isActive()).toBe(false);

buttonOrbit.click();
assertScenes(gd.layout, 'dragmode', 'orbit');
expect(gd.layout.dragmode).toBe(undefined);
expect(gd._fullLayout.dragmode).toBe('zoom');
expect(buttonTurntable.isActive()).toBe(false);
expect(buttonOrbit.isActive()).toBe(true);

buttonTurntable.click();
assertScenes(gd._fullLayout, 'dragmode', 'turntable');
expect(buttonTurntable.isActive()).toBe(true);
expect(buttonOrbit.isActive()).toBe(false);
});
});

describe('buttons resetCameraDefault3d and resetCameraLastSave3d', function() {
// changes in scene objects are not instantaneous
var DELAY = 1000;

it('should update the scene camera', function(done) {
var sceneLayout = gd._fullLayout.scene,
sceneLayout2 = gd._fullLayout.scene2,
scene = sceneLayout._scene,
scene2 = sceneLayout2._scene;

expect(sceneLayout.camera.eye)
.toEqual({x: 0.1, y: 0.1, z: 1});
expect(sceneLayout2.camera.eye)
.toEqual({x: 2.5, y: 2.5, z: 2.5});

selectButton(modeBar, 'resetCameraDefault3d').click();
setTimeout(function() {
expect(sceneLayout.camera.eye)
.toEqual({x: 0.1, y: 0.1, z: 1}, 'does not change the layout objects');
expect(scene.camera.eye)
.toEqual([1.2500000000000002, 1.25, 1.25]);
expect(sceneLayout2.camera.eye)
.toEqual({x: 2.5, y: 2.5, z: 2.5}, 'does not change the layout objects');
expect(scene2.camera.eye)
.toEqual([1.2500000000000002, 1.25, 1.25]);

selectButton(modeBar, 'resetCameraLastSave3d').click();
setTimeout(function() {
expect(sceneLayout.camera.eye)
.toEqual({x: 0.1, y: 0.1, z: 1}, 'does not change the layout objects');
expect(scene.camera.eye)
.toEqual([ 0.10000000000000016, 0.10000000000000016, 1]);
expect(sceneLayout2.camera.eye)
.toEqual({x: 2.5, y: 2.5, z: 2.5}, 'does not change the layout objects');
expect(scene2.camera.eye)
.toEqual([2.500000000000001, 2.5000000000000004, 2.5000000000000004]);

done();
}, DELAY);
}, DELAY);
});
});

describe('button hoverClosest3d', function() {
it('should update the scene hovermode and spikes', function() {
var buttonHover = selectButton(modeBar, 'hoverClosest3d');

assertScenes(gd._fullLayout, 'hovermode', 'closest');
expect(buttonHover.isActive()).toBe(true);

buttonHover.click();
assertScenes(gd._fullLayout, 'hovermode', false);
assertScenes(gd._fullLayout, 'xaxis.showspikes', false);
assertScenes(gd._fullLayout, 'yaxis.showspikes', false);
assertScenes(gd._fullLayout, 'zaxis.showspikes', false);
expect(buttonHover.isActive()).toBe(false);

buttonHover.click();
assertScenes(gd._fullLayout, 'hovermode', 'closest');
assertScenes(gd._fullLayout, 'xaxis.showspikes', true);
assertScenes(gd._fullLayout, 'yaxis.showspikes', true);
assertScenes(gd._fullLayout, 'zaxis.showspikes', true);
expect(buttonHover.isActive()).toBe(true);
});
});

});
});
0