Skip to content

Commit

Permalink
set various layout components via template
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Mar 23, 2020
1 parent 5f8b280 commit 96e3590
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/components/annotations/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var attributes = require('./attributes');

module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
handleArrayContainerDefaults(layoutIn, layoutOut, {
fromTemplate: (layoutOut._template || {}).annotations,
name: 'annotations',
handleItemDefaults: handleAnnotationDefaults
});
Expand Down
1 change: 1 addition & 0 deletions src/components/annotations3d/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ var attributes = require('./attributes');

module.exports = function handleDefaults(sceneLayoutIn, sceneLayoutOut, opts) {
handleArrayContainerDefaults(sceneLayoutIn, sceneLayoutOut, {
fromTemplate: (sceneLayoutOut._template || {}).annotations,
name: 'annotations',
handleItemDefaults: handleAnnotationDefaults,
fullLayout: opts.fullLayout
Expand Down
9 changes: 5 additions & 4 deletions src/components/grid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,12 @@ function getAxes(layout, grid, axLetter) {
// the shape of the grid - this needs to be done BEFORE supplyDataDefaults
// so that non-subplot traces can place themselves in the grid
function sizeDefaults(layoutIn, layoutOut) {
var gridIn = layoutIn.grid || {};
var xAxes = getAxes(layoutOut, gridIn, 'x');
var yAxes = getAxes(layoutOut, gridIn, 'y');
var gridIn = layoutIn.grid || ((layoutIn.template || {}).layout || {}).grid;
var xAxes = getAxes(layoutOut, gridIn || {}, 'x');
var yAxes = getAxes(layoutOut, gridIn || {}, 'y');

if(!layoutIn.grid && !xAxes && !yAxes) return;
if(!gridIn && !xAxes && !yAxes) return;
if(!gridIn) gridIn = {};

var hasSubplotGrid = Array.isArray(gridIn.subplots) && Array.isArray(gridIn.subplots[0]);
var hasXaxes = Array.isArray(xAxes);
Expand Down
1 change: 1 addition & 0 deletions src/components/images/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var name = 'images';

module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
var opts = {
fromTemplate: (layoutOut._template || {}).images,
name: name,
handleItemDefaults: imageDefaults
};
Expand Down
1 change: 1 addition & 0 deletions src/components/rangeselector/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = function handleDefaults(containerIn, containerOut, layout, coun
}

var buttons = handleArrayContainerDefaults(selectorIn, selectorOut, {
fromTemplate: (selectorOut._template || {}).buttons,
name: 'buttons',
handleItemDefaults: buttonDefaults,
calendar: calendar
Expand Down
1 change: 1 addition & 0 deletions src/components/shapes/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var helpers = require('./helpers');

module.exports = function supplyLayoutDefaults(layoutIn, layoutOut) {
handleArrayContainerDefaults(layoutIn, layoutOut, {
fromTemplate: (layoutOut._template || {}).shapes,
name: 'shapes',
handleItemDefaults: handleShapeDefaults
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/sliders/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var stepAttrs = attributes.steps;

module.exports = function slidersDefaults(layoutIn, layoutOut) {
handleArrayContainerDefaults(layoutIn, layoutOut, {
fromTemplate: (layoutOut._template || {}).sliders,
name: name,
handleItemDefaults: sliderDefaults
});
Expand All @@ -31,6 +32,7 @@ function sliderDefaults(sliderIn, sliderOut, layoutOut) {
}

var steps = handleArrayContainerDefaults(sliderIn, sliderOut, {
fromTemplate: (layoutOut._template || {}).steps,
name: 'steps',
handleItemDefaults: stepDefaults
});
Expand Down
2 changes: 2 additions & 0 deletions src/components/updatemenus/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var buttonAttrs = attributes.buttons;

module.exports = function updateMenusDefaults(layoutIn, layoutOut) {
var opts = {
fromTemplate: (layoutOut._template || {}).updatemenus,
name: name,
handleItemDefaults: menuDefaults
};
Expand All @@ -33,6 +34,7 @@ function menuDefaults(menuIn, menuOut, layoutOut) {
}

var buttons = handleArrayContainerDefaults(menuIn, menuOut, {
fromTemplate: (layoutOut._template || {}).buttons,
name: 'buttons',
handleItemDefaults: buttonDefaults
});
Expand Down
1 change: 1 addition & 0 deletions src/plots/mapbox/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function handleDefaults(containerIn, containerOut, coerce, opts) {
coerce('pitch');

handleArrayContainerDefaults(containerIn, containerOut, {
fromTemplate: (containerOut._template || {}).layers,
name: 'layers',
handleItemDefaults: handleLayerDefaults
});
Expand Down

0 comments on commit 96e3590

Please sign in to comment.