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

Function findMainSubplot

src/plots/plots.js:972–1006  ·  view source on GitHub ↗
(ax, fullLayout)

Source from the content-addressed store, hash-verified

970};
971
972function findMainSubplot(ax, fullLayout) {
973 var mockGd = {_fullLayout: fullLayout};
974
975 var isX = ax._id.charAt(0) === 'x';
976 var anchorAx = ax._mainAxis._anchorAxis;
977 var mainSubplotID = '';
978 var nextBestMainSubplotID = '';
979 var anchorID = '';
980
981 // First try the main ID with the anchor
982 if(anchorAx) {
983 anchorID = anchorAx._mainAxis._id;
984 mainSubplotID = isX ? (ax._id + anchorID) : (anchorID + ax._id);
985 }
986
987 // Then look for a subplot with the counteraxis overlaying the anchor
988 // If that fails just use the first subplot including this axis
989 if(!mainSubplotID || !fullLayout._plots[mainSubplotID]) {
990 mainSubplotID = '';
991
992 var counterIDs = ax._counterAxes;
993 for(var j = 0; j < counterIDs.length; j++) {
994 var counterPart = counterIDs[j];
995 var id = isX ? (ax._id + counterPart) : (counterPart + ax._id);
996 if(!nextBestMainSubplotID) nextBestMainSubplotID = id;
997 var counterAx = axisIDs.getFromId(mockGd, counterPart);
998 if(anchorID && counterAx.overlaying === anchorID) {
999 mainSubplotID = id;
1000 break;
1001 }
1002 }
1003 }
1004
1005 return mainSubplotID || nextBestMainSubplotID;
1006}
1007
1008// This function clears any trace attributes with valType: color and
1009// no set dflt filed in the plot schema. This is needed because groupby (which

Callers 1

plots.jsFile · 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…