Skip to content

Implementing matching axes #3506

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 23 commits into from
Feb 18, 2019
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6813865
mv handleConstraintDefaults into constraints.js file
etpinard Jan 24, 2019
6f2bb78
first cut at static `ax.matches` behavior
etpinard Jan 23, 2019
5ddbf2a
some linting & commenting in dragbox.js
etpinard Feb 1, 2019
c60424b
first cut at zoom/pan/scroll `ax.matches` behavior
etpinard Feb 1, 2019
13007e0
add doScroll wrapper for dragbox tests
etpinard Jan 31, 2019
e962e96
mv dragbox tests calling makePlot to own describe block
etpinard Jan 31, 2019
ca1de5d
DRY-up drag-start/assert/drag-end tests
etpinard Jan 31, 2019
3b314fe
add toBeWithinArray custom jasmine matcher
etpinard Feb 1, 2019
6621419
add mucho matching axes dragbox tests
etpinard Jan 29, 2019
9118505
align autobinning of histogram traces on matching axes
etpinard Jan 28, 2019
d9c2d4e
link ax._categories & ax._categoriesMap to same ref for matching axes
etpinard Jan 28, 2019
c290adf
add axis.matches boolean to splom dims
etpinard Feb 1, 2019
ef256db
generalize "update matched ax rng" logic
etpinard Feb 1, 2019
9f2fad1
disallow constraining AND matching range
etpinard Feb 1, 2019
8c09944
add "matches" + "scaleanchor" mock
etpinard Feb 1, 2019
c5f9e74
fix partial ax-range relayout calls for matching axes
etpinard Feb 1, 2019
d0581e2
fix typo (ax.setScale has no arg)
etpinard Feb 5, 2019
6b34ae3
use ax._matchGroup to improve matching axes relayout perf
etpinard Feb 5, 2019
99a9edb
allow fixedrange subplots to scaleanchor with `constrain:domain`
etpinard Feb 6, 2019
91431ec
drop *scaleanchor* constraints for axes under *matches* constraint
etpinard Feb 12, 2019
70b10ff
add safe-guard in dragbox.js
etpinard Feb 18, 2019
772efe5
add info about matching axis type in attr description
etpinard Feb 18, 2019
1713c83
fix typo
etpinard Feb 18, 2019
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
43 changes: 33 additions & 10 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1932,22 +1932,34 @@ exports.relayout = relayout;
// Optimization mostly for large splom traces where
// Plots.supplyDefaults can take > 100ms
function axRangeSupplyDefaultsByPass(gd, flags, specs) {
var k;
var fullLayout = gd._fullLayout;

if(!flags.axrange) return false;

for(k in flags) {
for(var k in flags) {
if(k !== 'axrange' && flags[k]) return false;
}

for(k in specs.rangesAltered) {
var axName = Axes.id2name(k);
for(var axId in specs.rangesAltered) {
var axName = Axes.id2name(axId);
var axIn = gd.layout[axName];
var axOut = gd._fullLayout[axName];
var axOut = fullLayout[axName];
axOut.autorange = axIn.autorange;
axOut.range = axIn.range.slice();
axOut.cleanRange();

if(axOut._matchGroup) {
for(var axId2 in axOut._matchGroup) {
if(axId2 !== axId) {
var ax2 = fullLayout[Axes.id2name(axId2)];
ax2.autorange = axOut.autorange;
ax2.range = axOut.range.slice();
ax2._input.range = axOut.range.slice();
}
}
}
}

return true;
}

Expand All @@ -1957,14 +1969,25 @@ function addAxRangeSequence(seq, rangesAltered) {
// executed after drawData
var drawAxes = rangesAltered ?
function(gd) {
var opts = {skipTitle: true};
var axIds = [];
var skipTitle = true;

for(var id in rangesAltered) {
if(Axes.getFromId(gd, id).automargin) {
opts = {};
break;
var ax = Axes.getFromId(gd, id);
axIds.push(id);

if(ax._matchGroup) {
for(var id2 in ax._matchGroup) {
if(!rangesAltered[id2]) {
axIds.push(id2);
}
}
}

if(ax.automargin) skipTitle = false;
}
return Axes.draw(gd, Object.keys(rangesAltered), opts);

return Axes.draw(gd, axIds, {skipTitle: skipTitle});
} :
function(gd) {
return Axes.draw(gd, 'redraw');
Expand Down
38 changes: 35 additions & 3 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,17 +697,49 @@ exports.redrawReglTraces = function(gd) {
};

exports.doAutoRangeAndConstraints = function(gd) {
var fullLayout = gd._fullLayout;
var axList = Axes.list(gd, '', true);
var matchGroups = fullLayout._axisMatchGroups || [];
var ax;

for(var i = 0; i < axList.length; i++) {
var ax = axList[i];
ax = axList[i];
cleanAxisConstraints(gd, ax);
// in case margins changed, update scale
ax.setScale();
doAutoRange(gd, ax);
}

enforceAxisConstraints(gd);

groupLoop:
for(var j = 0; j < matchGroups.length; j++) {
var group = matchGroups[j];
var rng = null;
var id;

for(id in group) {
ax = Axes.getFromId(gd, id);
if(ax.autorange === false) continue groupLoop;

if(rng) {
if(rng[0] < rng[1]) {
rng[0] = Math.min(rng[0], ax.range[0]);
rng[1] = Math.max(rng[1], ax.range[1]);
} else {
rng[0] = Math.max(rng[0], ax.range[0]);
rng[1] = Math.min(rng[1], ax.range[1]);
}
} else {
rng = ax.range;
}
}

for(id in group) {
ax = Axes.getFromId(gd, id);
ax.range = rng.slice();
ax._input.range = rng.slice();
ax.setScale();
}
}
};

// An initial paint must be completed before these components can be
Expand Down
2 changes: 2 additions & 0 deletions src/plots/cartesian/autorange.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ function concatExtremes(gd, ax) {
}

function doAutoRange(gd, ax) {
ax.setScale();

if(ax.autorange) {
ax.range = getAutoRange(gd, ax);

Expand Down
152 changes: 0 additions & 152 deletions src/plots/cartesian/constraint_defaults.js

This file was deleted.

Loading