Skip to content
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

scattergl visible restyle fix #2442

Merged
merged 6 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
16 changes: 16 additions & 0 deletions src/traces/scattergl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,22 @@ function sceneUpdate(gd, subplot) {
if(!subplot._scene) {
scene = subplot._scene = Lib.extendFlat({}, reset, first);

// apply new option to all regl components (used on drag)
scene.update = function update(opt) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @dfcreative you were right! scene.update is still used on drag. Added spy+assertion below to 🔏 this thing down.

var opts = new Array(scene.count);
for(var i = 0; i < scene.count; i++) {
opts[i] = opt;
}

if(scene.fill2d) scene.fill2d.update(opts);
if(scene.scatter2d) scene.scatter2d.update(opts);
if(scene.line2d) scene.line2d.update(opts);
if(scene.error2d) scene.error2d.update(opts.concat(opts));
if(scene.select2d) scene.select2d.update(opts);

scene.draw();
};

// draw traces in proper order
scene.draw = function draw() {
var i;
Expand Down
6 changes: 6 additions & 0 deletions test/jasmine/tests/gl2d_plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,16 @@ describe('@gl Test gl2d plots', function() {
gd.on('plotly_relayout', relayoutCallback);
})
.then(function() {
var scene = gd._fullLayout._plots.xy._scene;
spyOn(scene, 'draw');

// Drag scene along the X axis
return mouseTo([200, 200], [220, 200]);
})
.then(function() {
var scene = gd._fullLayout._plots.xy._scene;
expect(scene.draw).toHaveBeenCalledTimes(3);

expect(gd.layout.xaxis.autorange).toBe(false);
expect(gd.layout.yaxis.autorange).toBe(false);
expect(gd.layout.xaxis.range).toBeCloseToArray(newX, precision);
Expand Down