Skip to content

Commit b4d8044

Browse files
committed
hide modebar select2d & lasso2d buttons for boxes w/o 'all' boxpoints
1 parent f228a5e commit b4d8044

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

src/components/modebar/manage.js

+4
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ function isSelectable(fullData) {
179179
if(scatterSubTypes.hasMarkers(trace) || scatterSubTypes.hasText(trace)) {
180180
selectable = true;
181181
}
182+
} else if(Registry.traceIs(trace, 'box')) {
183+
if(trace.boxpoints === 'all') {
184+
selectable = true;
185+
}
182186
}
183187
// assume that in general if the trace module has selectPoints,
184188
// then it's selectable. Scatter is an exception to this because it must

test/jasmine/tests/modebar_test.js

+28-5
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ describe('ModeBar', function() {
154154
});
155155

156156
describe('manageModeBar', function() {
157-
158157
function getButtons(list) {
159158
for(var i = 0; i < list.length; i++) {
160159
for(var j = 0; j < list[i].length; j++) {
@@ -174,9 +173,9 @@ describe('ModeBar', function() {
174173
});
175174

176175
expect(modeBar.hasButtons(buttons)).toBe(true, 'modeBar.hasButtons');
177-
expect(countGroups(modeBar)).toEqual(expectedGroupCount, 'correct group count');
178-
expect(countButtons(modeBar)).toEqual(expectedButtonCount, 'correct button count');
179-
expect(countLogo(modeBar)).toEqual(1, 'correct logo count');
176+
expect(countGroups(modeBar)).toBe(expectedGroupCount, 'correct group count');
177+
expect(countButtons(modeBar)).toBe(expectedButtonCount, 'correct button count');
178+
expect(countLogo(modeBar)).toBe(1, 'correct logo count');
180179
}
181180

182181
it('creates mode bar (unselectable cartesian version)', function() {
@@ -197,7 +196,7 @@ describe('ModeBar', function() {
197196
checkButtons(modeBar, buttons, 1);
198197
});
199198

200-
it('creates mode bar (selectable cartesian version)', function() {
199+
it('creates mode bar (selectable scatter version)', function() {
201200
var buttons = getButtons([
202201
['toImage', 'sendDataToCloud'],
203202
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
@@ -221,6 +220,30 @@ describe('ModeBar', function() {
221220
checkButtons(modeBar, buttons, 1);
222221
});
223222

223+
it('creates mode bar (selectable box version)', function() {
224+
var buttons = getButtons([
225+
['toImage', 'sendDataToCloud'],
226+
['zoom2d', 'pan2d', 'select2d', 'lasso2d'],
227+
['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d'],
228+
['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']
229+
]);
230+
231+
var gd = getMockGraphInfo();
232+
gd._fullLayout._basePlotModules = [{ name: 'cartesian' }];
233+
gd._fullLayout.xaxis = {fixedrange: false};
234+
gd._fullData = [{
235+
type: 'box',
236+
visible: true,
237+
boxpoints: 'all',
238+
_module: {selectPoints: true}
239+
}];
240+
241+
manageModeBar(gd);
242+
var modeBar = gd._fullLayout._modeBar;
243+
244+
checkButtons(modeBar, buttons, 1);
245+
});
246+
224247
it('creates mode bar (cartesian fixed-axes version)', function() {
225248
var buttons = getButtons([
226249
['toImage', 'sendDataToCloud'],

0 commit comments

Comments
 (0)