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

Function computeDataBindings

src/plots/command.js:328–400  ·  view source on GitHub ↗
(gd, args)

Source from the content-addressed store, hash-verified

326}
327
328function computeDataBindings(gd, args) {
329 var traces, astr, val, aobj;
330 var bindings = [];
331
332 // Logic copied from Plotly.restyle:
333 astr = args[0];
334 val = args[1];
335 traces = args[2];
336 aobj = {};
337 if(typeof astr === 'string') {
338 aobj[astr] = val;
339 } else if(Lib.isPlainObject(astr)) {
340 // the 3-arg form
341 aobj = astr;
342
343 if(traces === undefined) {
344 traces = val;
345 }
346 } else {
347 return bindings;
348 }
349
350 if(traces === undefined) {
351 // Explicitly assign this to null instead of undefined:
352 traces = null;
353 }
354
355 crawl(aobj, function(path, attrName, _attr) {
356 var thisTraces;
357 var attr;
358
359 if(Array.isArray(_attr)) {
360 attr = _attr.slice();
361
362 var nAttr = Math.min(attr.length, gd.data.length);
363 if(traces) {
364 nAttr = Math.min(nAttr, traces.length);
365 }
366 thisTraces = [];
367 for(var j = 0; j < nAttr; j++) {
368 thisTraces[j] = traces ? traces[j] : j;
369 }
370 } else {
371 attr = _attr;
372 thisTraces = traces ? traces.slice() : null;
373 }
374
375 // Convert [7] to just 7 when traces is null:
376 if(thisTraces === null) {
377 if(Array.isArray(attr)) {
378 attr = attr[0];
379 }
380 } else if(Array.isArray(thisTraces)) {
381 if(!Array.isArray(attr)) {
382 var tmp = attr;
383 attr = [];
384 for(var i = 0; i < thisTraces.length; i++) {
385 attr[i] = tmp;

Callers 1

command.jsFile · 0.85

Calls 1

crawlFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…