Skip to content

Axes ref cleanup #1431

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 10 commits into from
Mar 2, 2017
41 changes: 28 additions & 13 deletions src/plots/cartesian/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,18 +115,34 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {

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

var axLayoutIn, axLayoutOut;
var axName, axLayoutIn, axLayoutOut;

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

axesList.forEach(function(axName) {
var axLetter = axName.charAt(0);
function getCounterAxes(axLetter) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as promised in #1261 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

There are still two maps and a filter 🐎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 5eb6202

var list = {x: yaList, y: xaList}[axLetter];

return list.map(axisIds.name2id);
}

function getOverlayableAxes(axLetter, axName) {
var list = {x: xaList, y: yaList}[axLetter];

return list.filter(function(axName2) {
return axName2 !== axName && !(layoutIn[axName2] || {}).overlaying;
})
.map(axisIds.name2id);
}

for(i = 0; i < axesList.length; i++) {
axName = axesList[i];
axLayoutIn = layoutIn[axName] || {};
axLayoutOut = {};

var axLetter = axName.charAt(0);

var defaultOptions = {
letter: axLetter,
font: layoutOut.font,
Expand All @@ -142,10 +158,8 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {

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)
counterAxes: getCounterAxes(axLetter),
overlayableAxes: getOverlayableAxes(axLetter, axName)
};

handlePositionDefaults(axLayoutIn, axLayoutOut, coerce, positioningOptions);
Expand All @@ -157,14 +171,14 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
if(!layoutIn[axName] && axLayoutIn.type !== '-') {
layoutIn[axName] = {type: axLayoutIn.type};
}

});
}

// quick second pass for range slider and selector defaults
var rangeSliderDefaults = Registry.getComponentMethod('rangeslider', 'handleDefaults'),
rangeSelectorDefaults = Registry.getComponentMethod('rangeselector', 'handleDefaults');

xaList.forEach(function(axName) {
for(i = 0; i < xaList.length; i++) {
axName = xaList[i];
axLayoutIn = layoutIn[axName];
axLayoutOut = layoutOut[axName];

Expand All @@ -181,9 +195,10 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
}

coerce('fixedrange');
});
}

yaList.forEach(function(axName) {
for(i = 0; i < yaList.length; i++) {
axName = yaList[i];
axLayoutIn = layoutIn[axName];
axLayoutOut = layoutOut[axName];

Expand All @@ -196,5 +211,5 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
);

coerce('fixedrange', fixedRangeDflt);
});
}
};
8 changes: 8 additions & 0 deletions test/jasmine/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ function func(config) {
// See CONTRIBUTING.md for additional notes on reporting.
func.defaultConfig.logLevel = config.LOG_INFO;

// without this, console logs in the plotly.js code don't print to
// the terminal since karma v1.5.0
//
// See https://github.com/karma-runner/karma/commit/89a7a1c#commitcomment-21009216
func.defaultConfig.browserConsoleLogOptions = {
level: 'log'
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh awesome - that'll be super helpful.


config.set(func.defaultConfig);
}

Expand Down