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

Function _doPlot

src/plot_api/plot_api.js:59–397  ·  view source on GitHub ↗

* Internal plot-creation function * * @param {string id or DOM element} gd * the id or DOM element of the graph container div * @param {array of objects} data * array of traces, containing the data and display information for each trace * @param {object} layout * object describ

(gd, data, layout, config)

Source from the content-addressed store, hash-verified

57 *
58 */
59function _doPlot(gd, data, layout, config) {
60 var frames;
61
62 gd = Lib.getGraphDiv(gd);
63
64 // Events.init is idempotent and bails early if gd has already been init'd
65 Events.init(gd);
66
67 if (Lib.isPlainObject(data)) {
68 var obj = data;
69 data = obj.data;
70 layout = obj.layout;
71 config = obj.config;
72 frames = obj.frames;
73 }
74
75 var okToPlot = Events.triggerHandler(gd, 'plotly_beforeplot', [data, layout, config]);
76 if (okToPlot === false) return Promise.reject();
77
78 // if there's no data or layout, and this isn't yet a plotly plot
79 // container, log a warning to help plotly.js users debug
80 if (!data && !layout && !Lib.isPlotDiv(gd)) {
81 Lib.warn('Calling _doPlot as if redrawing ' + "but this container doesn't yet have a plot.", gd);
82 }
83
84 function addFrames() {
85 if (frames) {
86 return exports.addFrames(gd, frames);
87 }
88 }
89
90 // transfer configuration options to gd until we move over to
91 // a more OO like model
92 setPlotContext(gd, config);
93
94 if (!layout) layout = {};
95
96 // hook class for plots main container (in case of plotly.js
97 // this won't be #embedded-graph or .js-tab-contents)
98 d3.select(gd).classed('js-plotly-plot', true);
99
100 // off-screen getBoundingClientRect testing space,
101 // in #js-plotly-tester (and stored as Drawing.tester)
102 // so we can share cached text across tabs
103 Drawing.makeTester();
104
105 // collect promises for any async actions during plotting
106 // any part of the plotting code can push to gd._promises, then
107 // before we move to the next step, we check that they're all
108 // complete, and empty out the promise list again.
109 if (!Array.isArray(gd._promises)) gd._promises = [];
110
111 var graphWasEmpty = (gd.data || []).length === 0 && Array.isArray(data);
112
113 // if there is already data on the graph, append the new data
114 // if you only want to redraw, pass a non-array for data
115 if (Array.isArray(data)) {
116 helpers.cleanData(data);

Callers

nothing calls this directly

Calls 4

setPlotContextFunction · 0.85
makePlotFrameworkFunction · 0.85
relayoutFunction · 0.85
emitAfterPlotFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…