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

ZERO circular dependency #2429

Merged
merged 17 commits into from
Mar 2, 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
32 changes: 22 additions & 10 deletions src/plots/grid.js → src/components/grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@

'use strict';

var Lib = require('../lib');
var domainAttrs = require('./domain').attributes;
var counterRegex = require('../lib/regex').counter;
var cartesianIdRegex = require('./cartesian/constants').idRegex;
var Lib = require('../../lib');
var counterRegex = require('../../lib/regex').counter;
var domainAttrs = require('../../plots/domain').attributes;
var cartesianIdRegex = require('../../plots/cartesian/constants').idRegex;


var gridAttrs = exports.attributes = {
var gridAttrs = {
rows: {
valType: 'integer',
min: 1,
Expand Down Expand Up @@ -168,7 +167,7 @@ var gridAttrs = exports.attributes = {

// the shape of the grid - this needs to be done BEFORE supplyDataDefaults
// so that non-subplot traces can place themselves in the grid
exports.sizeDefaults = function(layoutIn, layoutOut) {
function sizeDefaults(layoutIn, layoutOut) {
var gridIn = layoutIn.grid;
if(!gridIn) return;

Expand Down Expand Up @@ -211,7 +210,7 @@ exports.sizeDefaults = function(layoutIn, layoutOut) {
x: fillGridPositions('x', coerce, hasSubplotGrid ? 0.2 : 0.1, columns),
y: fillGridPositions('y', coerce, hasSubplotGrid ? 0.3 : 0.1, rows, reversed)
};
};
}

// coerce x or y sizing attributes and return an array of domains for this direction
function fillGridPositions(axLetter, coerce, dfltGap, len, reversed) {
Expand All @@ -232,7 +231,7 @@ function fillGridPositions(axLetter, coerce, dfltGap, len, reversed) {

// the (cartesian) contents of the grid - this needs to happen AFTER supplyDataDefaults
// so that we know what cartesian subplots are available
exports.contentDefaults = function(layoutIn, layoutOut) {
function contentDefaults(layoutIn, layoutOut) {
var gridOut = layoutOut.grid;
// make sure we got to the end of handleGridSizing
if(!gridOut || !gridOut._domains) return;
Expand Down Expand Up @@ -368,7 +367,7 @@ exports.contentDefaults = function(layoutIn, layoutOut) {
}
}
}
};
}

function fillGridAxes(axesIn, axesAllowed, len, axisMap, axLetter) {
var out = new Array(len);
Expand Down Expand Up @@ -397,3 +396,16 @@ function fillGridAxes(axesIn, axesAllowed, len, axisMap, axLetter) {

return out;
}

module.exports = {
moduleType: 'component',
name: 'grid',

schema: {
layout: {grid: gridAttrs}
},

layoutAttributes: gridAttrs,
sizeDefaults: sizeDefaults,
contentDefaults: contentDefaults
};
3 changes: 2 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ exports.register([
require('./components/updatemenus'),
require('./components/sliders'),
require('./components/rangeslider'),
require('./components/rangeselector')
require('./components/rangeselector'),
require('./components/grid'),
]);

// locales en and en-US are required for default behavior
Expand Down
4 changes: 1 addition & 3 deletions src/plots/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

var fontAttrs = require('./font_attributes');
var colorAttrs = require('../components/color/attributes');
var gridAttrs = require('./grid').attributes;

var globalFont = fontAttrs({
editType: 'calc',
Expand Down Expand Up @@ -196,6 +195,5 @@ module.exports = {
'being treated as immutable, thus any data array with a',
'different identity from its predecessor contains new data.'
].join(' ')
},
grid: gridAttrs
}
};
2 changes: 1 addition & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var axisIDs = require('../plots/cartesian/axis_ids');
var Lib = require('../lib');
var _ = Lib._;
var Color = require('../components/color');
var Grid = require('../components/grid');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do you want to go the last inch here and turn Grid.method into Registry.getComponentMethod? Then grid becomes an optional component, right?

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 -> 9246fda

var BADNUM = require('../constants/numerical').BADNUM;
var Grid = require('./grid');

var plots = module.exports = {};

Expand Down