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

Function applyUIRevisions

src/plot_api/plot_api.js:2423–2557  ·  view source on GitHub ↗
(data, layout, oldFullData, oldFullLayout)

Source from the content-addressed store, hash-verified

2421}
2422
2423function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
2424 var layoutPreGUI = oldFullLayout._preGUI;
2425 var key, revAttr, oldRev, newRev, match, preGUIVal, newNP, newVal, head, tail;
2426 var bothInheritAutorange = [];
2427 var newAutorangeIn = {};
2428 var newRangeAccepted = {};
2429 for (key in layoutPreGUI) {
2430 match = findUIPattern(key, layoutUIControlPatterns);
2431 if (match) {
2432 head = match.head;
2433 tail = match.tail;
2434 revAttr = match.attr || head + '.uirevision';
2435 oldRev = nestedProperty(oldFullLayout, revAttr).get();
2436 newRev = oldRev && getNewRev(revAttr, layout);
2437
2438 if (newRev && newRev === oldRev) {
2439 preGUIVal = layoutPreGUI[key];
2440 if (preGUIVal === null) preGUIVal = undefined;
2441 newNP = nestedProperty(layout, key);
2442 newVal = newNP.get();
2443
2444 if (valsMatch(newVal, preGUIVal)) {
2445 if (newVal === undefined && tail === 'autorange') {
2446 bothInheritAutorange.push(head);
2447 }
2448 newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get()));
2449 continue;
2450 } else if (tail === 'autorange' || tail.slice(0, 6) === 'range[') {
2451 // Special case for (auto)range since we push it back into the layout
2452 // so all null should be treated equivalently to autorange: true with any range
2453 var pre0 = layoutPreGUI[head + '.range[0]'];
2454 var pre1 = layoutPreGUI[head + '.range[1]'];
2455 var preAuto = layoutPreGUI[head + '.autorange'];
2456 if (preAuto || (preAuto === null && pre0 === null && pre1 === null)) {
2457 // Only read the input layout once and stash the result,
2458 // so we get it before we start modifying it
2459 if (!(head in newAutorangeIn)) {
2460 var newContainer = nestedProperty(layout, head).get();
2461 newAutorangeIn[head] =
2462 newContainer &&
2463 (newContainer.autorange ||
2464 (newContainer.autorange !== false &&
2465 (!newContainer.range || newContainer.range.length !== 2)));
2466 }
2467 if (newAutorangeIn[head]) {
2468 newNP.set(undefinedToNull(nestedProperty(oldFullLayout, key).get()));
2469 continue;
2470 }
2471 }
2472 }
2473 }
2474 } else {
2475 Lib.warn('unrecognized GUI edit: ' + key);
2476 }
2477 // if we got this far, the new value was accepted as the new starting
2478 // point (either because it changed or revision changed)
2479 // so remove it from _preGUI for next time.
2480 delete layoutPreGUI[key];

Callers 1

reactFunction · 0.85

Calls 6

findUIPatternFunction · 0.85
getNewRevFunction · 0.85
valsMatchFunction · 0.85
undefinedToNullFunction · 0.85
getFullTraceIndexFromUidFunction · 0.85
getTraceIndexFromUidFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…