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

Function getTraceAttributes

src/plot_api/plot_schema.js:387–464  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

385}
386
387function getTraceAttributes(type) {
388 var _module, basePlotModule;
389
390 _module = Registry.modules[type]._module,
391 basePlotModule = _module.basePlotModule;
392
393 var attributes = {};
394
395 // make 'type' the first attribute in the object
396 attributes.type = null;
397
398 var copyBaseAttributes = extendDeepAll({}, baseAttributes);
399 var copyModuleAttributes = extendDeepAll({}, _module.attributes);
400
401 // prune global-level trace attributes that are already defined in a trace
402 exports.crawl(copyModuleAttributes, function(attr, attrName, attrs, level, fullAttrString) {
403 nestedProperty(copyBaseAttributes, fullAttrString).set(undefined);
404 // Prune undefined attributes
405 if(attr === undefined) nestedProperty(copyModuleAttributes, fullAttrString).set(undefined);
406 });
407
408 // base attributes (same for all trace types)
409 extendDeepAll(attributes, copyBaseAttributes);
410
411 // prune-out base attributes based on trace module categories
412 if(Registry.traceIs(type, 'noOpacity')) {
413 delete attributes.opacity;
414 }
415 if(!Registry.traceIs(type, 'showLegend')) {
416 delete attributes.showlegend;
417 delete attributes.legendgroup;
418 }
419 if(Registry.traceIs(type, 'noHover')) {
420 delete attributes.hoverinfo;
421 delete attributes.hoverlabel;
422 }
423 if(!_module.selectPoints) {
424 delete attributes.selectedpoints;
425 }
426
427 // module attributes
428 extendDeepAll(attributes, copyModuleAttributes);
429
430 // subplot attributes
431 if(basePlotModule.attributes) {
432 extendDeepAll(attributes, basePlotModule.attributes);
433 }
434
435 // 'type' gets overwritten by baseAttributes; reset it here
436 attributes.type = type;
437
438 var out = {
439 meta: _module.meta || {},
440 categories: _module.categories || {},
441 animatable: Boolean(_module.animatable),
442 type: type,
443 attributes: formatAttributes(attributes),
444 };

Callers 1

plot_schema.jsFile · 0.85

Calls 1

formatAttributesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…