MCPcopy Create free account
hub / github.com/plotly/plotly.js / getLayoutAttributes

Function getLayoutAttributes

src/plot_api/plot_schema.js:466–529  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

464}
465
466function getLayoutAttributes() {
467 var layoutAttributes = {};
468 var key, _module;
469
470 // global layout attributes
471 extendDeepAll(layoutAttributes, baseLayoutAttributes);
472
473 // add base plot module layout attributes
474 for(key in Registry.subplotsRegistry) {
475 _module = Registry.subplotsRegistry[key];
476
477 if(!_module.layoutAttributes) continue;
478
479 if(Array.isArray(_module.attr)) {
480 for(var i = 0; i < _module.attr.length; i++) {
481 handleBasePlotModule(layoutAttributes, _module, _module.attr[i]);
482 }
483 } else {
484 var astr = _module.attr === 'subplot' ? _module.name : _module.attr;
485 handleBasePlotModule(layoutAttributes, _module, astr);
486 }
487 }
488
489 // add registered components layout attributes
490 for(key in Registry.componentsRegistry) {
491 _module = Registry.componentsRegistry[key];
492 var schema = _module.schema;
493
494 if(schema && (schema.subplots || schema.layout)) {
495 /*
496 * Components with defined schema have already been merged in at register time
497 * but a few components define attributes that apply only to xaxis
498 * not yaxis (rangeselector, rangeslider) - delete from y schema.
499 * Note that the input attributes for xaxis/yaxis are the same object
500 * so it's not possible to only add them to xaxis from the start.
501 * If we ever have such asymmetry the other way, or anywhere else,
502 * we will need to extend both this code and mergeComponentAttrsToSubplot
503 * (which will not find yaxis only for example)
504 */
505 var subplots = schema.subplots;
506 if(subplots && subplots.xaxis && !subplots.yaxis) {
507 for(var xkey in subplots.xaxis) {
508 delete layoutAttributes.yaxis[xkey];
509 }
510 }
511
512 /*
513 * Also some attributes e.g. shift & autoshift only implemented on the yaxis
514 * at the moment. Remove them from the xaxis.
515 */
516 delete layoutAttributes.xaxis.shift;
517 delete layoutAttributes.xaxis.autoshift;
518 } else if(_module.name === 'colorscale') {
519 extendDeepAll(layoutAttributes, _module.layoutAttributes);
520 } else if(_module.layoutAttributes) {
521 // older style without schema need to be explicitly merged in now
522 insertAttrs(layoutAttributes, _module.layoutAttributes, _module.name);
523 }

Callers 1

plot_schema.jsFile · 0.85

Calls 3

handleBasePlotModuleFunction · 0.85
insertAttrsFunction · 0.85
formatAttributesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…