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

Cartesian subplot updates using data joins #946

Merged
merged 17 commits into from
Oct 6, 2016
Merged
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
4 changes: 2 additions & 2 deletions test/jasmine/tests/plots_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Test Plots', function() {
}];

var oldFullLayout = {
_plots: { xy: {} },
_plots: { xy: { plot: {} } },
xaxis: { c2p: function() {} },
yaxis: { _m: 20 },
scene: { _scene: {} },
Expand Down Expand Up @@ -54,7 +54,7 @@ describe('Test Plots', function() {
expect(gd._fullData[1].z).toBe(newData[1].z);
expect(gd._fullData[1]._empties).toBe(oldFullData[1]._empties);
expect(gd._fullLayout.scene._scene).toBe(oldFullLayout.scene._scene);
expect(gd._fullLayout._plots).toBe(oldFullLayout._plots);
expect(gd._fullLayout._plots.plot).toBe(oldFullLayout._plots.plot);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

_plots is no longer relinked in Plots.supplyDefaults as

newFullLayout._plots = oldFullLayout._plots

but as

    var oldSubplots = oldFullLayout._plots || {},
        newSubplots = newFullLayout._plots = {};

    var ids = Plotly.Axes.getSubplots(mockGd);

    for(var i = 0; i < ids.length; i++) {
        var id = ids[i],
            oldSubplot = oldSubplots[id],
            plotinfo;

        if(oldSubplot) {
            plotinfo = newSubplots[id] = oldSubplot;
        }
        else {
            plotinfo = newSubplots[id] = {};
            plotinfo.id = id;
        }

        plotinfo.x = getAxisFunc(id, 'x');
        plotinfo.y = getAxisFunc(id, 'y');
        plotinfo.xaxis = plotinfo.x();
        plotinfo.yaxis = plotinfo.y();
    }

cc @rreusser

Copy link
Contributor

Choose a reason for hiding this comment

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

So it looks like it reconstructs a new _plots object with the same contents vs. just transferring it? Is that what makes the join work correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it looks like it reconstructs a new _plots object with the same contents vs. just transferring it?

Correct. Thanks for the headsup. Maybe we could do better.

Is that what makes the join work correctly?

I don't think reconstructing _plots is necessary to make the joins work correctly.

expect(gd._fullLayout.annotations[0]._min).toBe(oldFullLayout.annotations[0]._min);
expect(gd._fullLayout.annotations[1]._max).toBe(oldFullLayout.annotations[1]._max);
expect(gd._fullLayout.someFunc).toBe(oldFullLayout.someFunc);
Expand Down