Skip to content

Honor fixedrange: false in y-axes anchored to xaxis with range slider #1261

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 4 commits into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 1 addition & 9 deletions src/components/rangeslider/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Lib = require('../../lib');
var attributes = require('./attributes');


module.exports = function handleDefaults(layoutIn, layoutOut, axName, counterAxes) {
module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
if(!layoutIn[axName].rangeslider) return;

// not super proud of this (maybe store _ in axis object instead
Expand Down Expand Up @@ -47,14 +47,6 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName, counterAxe
axOut._needsExpand = true;
}

if(containerOut.visible) {
counterAxes.forEach(function(ax) {
var opposing = layoutOut[ax] || {};
opposing.fixedrange = true;
layoutOut[ax] = opposing;
});
}

// to map back range slider (auto) range
containerOut._input = containerIn;
};
2 changes: 0 additions & 2 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
coerce('range');
containerOut.cleanRange();

coerce('fixedrange');

handleTickValueDefaults(containerIn, containerOut, coerce, axType);
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
Expand Down
92 changes: 59 additions & 33 deletions src/plots/cartesian/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,33 +115,39 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {

var bgColor = Color.combine(plot_bgcolor, layoutOut.paper_bgcolor);

var axLayoutIn, axLayoutOut;

function coerce(attr, dflt) {
return Lib.coerce(axLayoutIn, axLayoutOut, layoutAttributes, attr, dflt);
}

axesList.forEach(function(axName) {
var axLetter = axName.charAt(0),
axLayoutIn = layoutIn[axName] || {},
axLayoutOut = {},
defaultOptions = {
letter: axLetter,
font: layoutOut.font,
outerTicks: outerTicks[axName],
showGrid: !noGrids[axName],
name: axName,
data: fullData,
bgColor: bgColor,
calendar: layoutOut.calendar
},
positioningOptions = {
letter: axLetter,
counterAxes: {x: yaList, y: xaList}[axLetter].map(axisIds.name2id),
overlayableAxes: {x: xaList, y: yaList}[axLetter].filter(function(axName2) {
return axName2 !== axName && !(layoutIn[axName2] || {}).overlaying;
}).map(axisIds.name2id)
};

function coerce(attr, dflt) {
return Lib.coerce(axLayoutIn, axLayoutOut, layoutAttributes, attr, dflt);
}
var axLetter = axName.charAt(0);

axLayoutIn = layoutIn[axName] || {};
axLayoutOut = {};

var defaultOptions = {
letter: axLetter,
font: layoutOut.font,
outerTicks: outerTicks[axName],
showGrid: !noGrids[axName],
name: axName,
data: fullData,
bgColor: bgColor,
calendar: layoutOut.calendar
};

handleAxisDefaults(axLayoutIn, axLayoutOut, coerce, defaultOptions, layoutOut);

var positioningOptions = {
letter: axLetter,
counterAxes: {x: yaList, y: xaList}[axLetter].map(axisIds.name2id),
overlayableAxes: {x: xaList, y: yaList}[axLetter].filter(function(axName2) {
return axName2 !== axName && !(layoutIn[axName2] || {}).overlaying;
}).map(axisIds.name2id)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't suppose you want to use this opportunity to 🔪 these map and filter calls? And the (x|y)alist.forEach calls below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. That would be nice!

I want to clean up a few artefacts from the old axes.js module (which would help out @rreusser for carpets). Namely those annoying ._gd refs and get rid of the circular dependency between axes.js and plots.js. I'll make sure to remove those map / filter in that PR!

};

handlePositionDefaults(axLayoutIn, axLayoutOut, coerce, positioningOptions);

layoutOut[axName] = axLayoutOut;
Expand All @@ -158,17 +164,37 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
var rangeSliderDefaults = Registry.getComponentMethod('rangeslider', 'handleDefaults'),
rangeSelectorDefaults = Registry.getComponentMethod('rangeselector', 'handleDefaults');

axesList.forEach(function(axName) {
var axLetter = axName.charAt(0),
axLayoutIn = layoutIn[axName],
axLayoutOut = layoutOut[axName],
counterAxes = {x: yaList, y: xaList}[axLetter];
xaList.forEach(function(axName) {
axLayoutIn = layoutIn[axName];
axLayoutOut = layoutOut[axName];

rangeSliderDefaults(layoutIn, layoutOut, axName, counterAxes);
rangeSliderDefaults(layoutIn, layoutOut, axName);

if(axLetter === 'x' && axLayoutOut.type === 'date') {
rangeSelectorDefaults(axLayoutIn, axLayoutOut, layoutOut, counterAxes,
axLayoutOut.calendar);
if(axLayoutOut.type === 'date') {
rangeSelectorDefaults(
axLayoutIn,
axLayoutOut,
layoutOut,
yaList,
axLayoutOut.calendar
);
}

coerce('fixedrange');
});

yaList.forEach(function(axName) {
axLayoutIn = layoutIn[axName];
axLayoutOut = layoutOut[axName];

var anchoredAxis = layoutOut[axisIds.id2name(axLayoutOut.anchor)];

var fixedRangeDflt = (
anchoredAxis &&
anchoredAxis.rangeslider &&
anchoredAxis.rangeslider.visible
);

coerce('fixedrange', fixedRangeDflt);
});
};
1 change: 0 additions & 1 deletion src/plots/gl3d/layout/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ module.exports = {
autorange: axesAttrs.autorange,
rangemode: axesAttrs.rangemode,
range: axesAttrs.range,
fixedrange: axesAttrs.fixedrange,
// ticks
tickmode: axesAttrs.tickmode,
nticks: axesAttrs.nticks,
Expand Down
Loading