MCPcopy Index your code
hub / github.com/plotly/plotly.js / setPlotContext

Function setPlotContext

src/plot_api/plot_api.js:426–526  ·  view source on GitHub ↗
(gd, config)

Source from the content-addressed store, hash-verified

424}
425
426function setPlotContext(gd, config) {
427 if (!gd._context) {
428 gd._context = Lib.extendDeep({}, dfltConfig);
429
430 // stash <base> href, used to make robust clipPath URLs
431 var base = d3.select('base');
432 gd._context._baseUrl = base.size() && base.attr('href') ? window.location.href.split('#')[0] : '';
433 }
434
435 var context = gd._context;
436
437 var i, keys, key;
438
439 if (config) {
440 keys = Object.keys(config);
441 for (i = 0; i < keys.length; i++) {
442 key = keys[i];
443 if (key === 'editable' || key === 'edits') continue;
444 if (key in context) {
445 if (key === 'setBackground' && config[key] === 'opaque') {
446 context[key] = opaqueSetBackground;
447 } else {
448 context[key] = config[key];
449 }
450 }
451 }
452
453 // now deal with editable and edits - first editable overrides
454 // everything, then edits refines
455 var editable = config.editable;
456 if (editable !== undefined) {
457 // we're not going to *use* context.editable, we're only going to
458 // use context.edits... but keep it for the record
459 context.editable = editable;
460
461 keys = Object.keys(context.edits);
462 for (i = 0; i < keys.length; i++) {
463 context.edits[keys[i]] = editable;
464 }
465 }
466 if (config.edits) {
467 keys = Object.keys(config.edits);
468 for (i = 0; i < keys.length; i++) {
469 key = keys[i];
470 if (key in context.edits) {
471 context.edits[key] = config.edits[key];
472 }
473 }
474 }
475
476 // not part of the user-facing config options
477 context._exportedPlot = config._exportedPlot;
478 }
479
480 // staticPlot forces a bunch of others:
481 if (context.staticPlot) {
482 context.editable = false;
483 context.edits = {};

Callers 2

_doPlotFunction · 0.85
reactFunction · 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…