Skip to content

Commit 4babccb

Browse files
committed
make append buttons to add step more readable
1 parent 05a1b4f commit 4babccb

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/components/modebar/manage.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,27 +93,14 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
9393
groups.push(out);
9494
}
9595

96-
function appendButtonsToAdd(groups) {
97-
if(buttonsToAdd.length) {
98-
if(Array.isArray(buttonsToAdd[0])) {
99-
for(var i = 0; i < buttonsToAdd.length; i++) {
100-
groups.push(buttonsToAdd[i]);
101-
}
102-
}
103-
else groups.push(buttonsToAdd);
104-
}
105-
106-
return groups;
107-
}
108-
10996
// buttons common to all plot types
11097
addGroup(['toImage', 'sendDataToCloud']);
11198

11299
// graphs with more than one plot types get 'union buttons'
113100
// which reset the view or toggle hover labels across all subplots.
114101
if((hasCartesian || hasGL2D || hasPie) + hasGeo + hasGL3D > 1) {
115102
addGroup(['resetViews', 'toggleHover']);
116-
return appendButtonsToAdd(groups);
103+
return appendButtonsToGroups(groups, buttonsToAdd);
117104
}
118105

119106
if(hasGL3D) {
@@ -156,7 +143,7 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) {
156143
addGroup(['hoverClosestPie']);
157144
}
158145

159-
return appendButtonsToAdd(groups);
146+
return appendButtonsToGroups(groups, buttonsToAdd);
160147
}
161148

162149
function areAllAxesFixed(fullLayout) {
@@ -199,6 +186,19 @@ function isSelectable(fullData) {
199186
return selectable;
200187
}
201188

189+
function appendButtonsToGroups(groups, buttons) {
190+
if(buttons.length) {
191+
if(Array.isArray(buttons[0])) {
192+
for(var i = 0; i < buttons.length; i++) {
193+
groups.push(buttons[i]);
194+
}
195+
}
196+
else groups.push(buttons);
197+
}
198+
199+
return groups;
200+
}
201+
202202
// fill in custom buttons referring to default mode bar buttons
203203
function fillCustomButton(customButtons) {
204204
for(var i = 0; i < customButtons.length; i++) {

0 commit comments

Comments
 (0)