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

Function layoutHeadAttr

src/plot_api/plot_schema.js:277–333  ·  view source on GitHub ↗
(fullLayout, head)

Source from the content-addressed store, hash-verified

275};
276
277function layoutHeadAttr(fullLayout, head) {
278 var i, key, _module, attributes;
279
280 // look for attributes of the subplot types used on the plot
281 var basePlotModules = fullLayout._basePlotModules;
282 if(basePlotModules) {
283 var out;
284 for(i = 0; i < basePlotModules.length; i++) {
285 _module = basePlotModules[i];
286 if(_module.attrRegex && _module.attrRegex.test(head)) {
287 // if a module defines overrides, these take precedence
288 // this is to allow different editTypes from svg cartesian
289 if(_module.layoutAttrOverrides) return _module.layoutAttrOverrides;
290
291 // otherwise take the first attributes we find
292 if(!out && _module.layoutAttributes) out = _module.layoutAttributes;
293 }
294
295 // a module can also override the behavior of base (and component) module layout attrs
296 var baseOverrides = _module.baseLayoutAttrOverrides;
297 if(baseOverrides && head in baseOverrides) return baseOverrides[head];
298 }
299 if(out) return out;
300 }
301
302 // look for layout attributes contributed by traces on the plot
303 var modules = fullLayout._modules;
304 if(modules) {
305 for(i = 0; i < modules.length; i++) {
306 attributes = modules[i].layoutAttributes;
307 if(attributes && head in attributes) {
308 return attributes[head];
309 }
310 }
311 }
312
313 /*
314 * Next look in components.
315 * Components that define a schema have already merged this into
316 * base and subplot attribute defs, so ignore these.
317 * Others (older style) all put all their attributes
318 * inside a container matching the module `name`
319 * eg `attributes` (array) or `legend` (object)
320 */
321 for(key in Registry.componentsRegistry) {
322 _module = Registry.componentsRegistry[key];
323 if(_module.name === 'colorscale' && head.indexOf('coloraxis') === 0) {
324 return _module.layoutAttributes[head];
325 } else if(!_module.schema && (head === _module.name)) {
326 return _module.layoutAttributes;
327 }
328 }
329
330 if(head in baseLayoutAttributes) return baseLayoutAttributes[head];
331
332 return false;
333}
334

Callers 1

plot_schema.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…