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

Function getButtonGroups

src/components/modebar/manage.js:64–272  ·  view source on GitHub ↗
(gd)

Source from the content-addressed store, hash-verified

62
63// logic behind which buttons are displayed by default
64function getButtonGroups(gd) {
65 var fullLayout = gd._fullLayout;
66 var fullData = gd._fullData;
67 var context = gd._context;
68
69 function match(name, B) {
70 if(typeof B === 'string') {
71 if(B.toLowerCase() === name.toLowerCase()) return true;
72 } else {
73 var v0 = B.name;
74 var v1 = (B._cat || B.name);
75
76 if(v0 === name || v1 === name.toLowerCase()) return true;
77 }
78 return false;
79 }
80
81 var layoutAdd = fullLayout.modebar.add;
82 if(typeof layoutAdd === 'string') layoutAdd = [layoutAdd];
83
84 var layoutRemove = fullLayout.modebar.remove;
85 if(typeof layoutRemove === 'string') layoutRemove = [layoutRemove];
86
87 var buttonsToAdd = context.modeBarButtonsToAdd.concat(
88 layoutAdd.filter(function(e) {
89 for(var i = 0; i < context.modeBarButtonsToRemove.length; i++) {
90 if(match(e, context.modeBarButtonsToRemove[i])) return false;
91 }
92 return true;
93 })
94 );
95
96 var buttonsToRemove = context.modeBarButtonsToRemove.concat(
97 layoutRemove.filter(function(e) {
98 for(var i = 0; i < context.modeBarButtonsToAdd.length; i++) {
99 if(match(e, context.modeBarButtonsToAdd[i])) return false;
100 }
101 return true;
102 })
103 );
104
105 var hasCartesian = fullLayout._has('cartesian');
106 var hasGL3D = fullLayout._has('gl3d');
107 var hasGeo = fullLayout._has('geo');
108 var hasPie = fullLayout._has('pie');
109 var hasFunnelarea = fullLayout._has('funnelarea');
110 var hasTernary = fullLayout._has('ternary');
111 var hasMapbox = fullLayout._has('mapbox');
112 var hasMap = fullLayout._has('map');
113 var hasPolar = fullLayout._has('polar');
114 var hasSmith = fullLayout._has('smith');
115 var hasSankey = fullLayout._has('sankey');
116 var allAxesFixed = areAllAxesFixed(fullLayout);
117 var hasUnifiedHoverLabel = isUnifiedHover(fullLayout.hovermode);
118
119 var groups = [];
120
121 function addGroup(newGroup) {

Callers 1

manage.jsFile · 0.85

Calls 7

matchFunction · 0.85
areAllAxesFixedFunction · 0.85
addGroupFunction · 0.85
hasNoHoverFunction · 0.85
isSelectableFunction · 0.85
enableHoverFunction · 0.85
appendButtonsToGroupsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…