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

Function _restyle

src/plot_api/plot_api.js:1374–1690  ·  view source on GitHub ↗
(gd, aobj, traces)

Source from the content-addressed store, hash-verified

1372}
1373
1374function _restyle(gd, aobj, traces) {
1375 var fullLayout = gd._fullLayout;
1376 var fullData = gd._fullData;
1377 var data = gd.data;
1378 var guiEditFlag = fullLayout._guiEditing;
1379 var layoutNP = makeNP(fullLayout._preGUI, guiEditFlag);
1380 var eventData = Lib.extendDeepAll({}, aobj);
1381 var i;
1382
1383 // initialize flags
1384 var flags = editTypes.traceFlags();
1385
1386 // copies of the change (and previous values of anything affected)
1387 // for the undo / redo queue
1388 var redoit = {};
1389 var undoit = {};
1390 var axlist;
1391
1392 // make a new empty vals array for undoit
1393 function a0() {
1394 return traces.map(function () {
1395 return undefined;
1396 });
1397 }
1398
1399 // for autoranging multiple axes
1400 function addToAxlist(axid) {
1401 var axName = Axes.id2name(axid);
1402 if (axlist.indexOf(axName) === -1) axlist.push(axName);
1403 }
1404
1405 function autorangeAttr(axName) {
1406 return 'LAYOUT' + axName + '.autorange';
1407 }
1408
1409 function rangeAttr(axName) {
1410 return 'LAYOUT' + axName + '.range';
1411 }
1412
1413 function getFullTrace(traceIndex) {
1414 // usually fullData maps 1:1 onto data, but with groupby transforms
1415 // the fullData index can be greater. Take the *first* matching trace.
1416 for (var j = traceIndex; j < fullData.length; j++) {
1417 if (fullData[j]._input === data[traceIndex]) return fullData[j];
1418 }
1419 // should never get here - and if we *do* it should cause an error
1420 // later on undefined fullTrace is passed to nestedProperty.
1421 }
1422
1423 // for attrs that interact (like scales & autoscales), save the
1424 // old vals before making the change
1425 // val=undefined will not set a value, just record what the value was.
1426 // val=null will delete the attribute
1427 // attr can be an array to set several at once (all to the same val)
1428 function doextra(attr, val, i) {
1429 if (Array.isArray(attr)) {
1430 attr.forEach(function (a) {
1431 doextra(a, val, i);

Callers 2

restyleFunction · 0.70
updateFunction · 0.70

Calls 8

makeNPFunction · 0.85
arrayBinsFunction · 0.85
allBinsFunction · 0.85
undefinedToNullFunction · 0.85
a0Function · 0.85
getFullTraceFunction · 0.85
doextraFunction · 0.85
addToAxlistFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…