Skip to content

Commit 84a7c06

Browse files
committed
clean up ModeBar API:
- rm !(this instanceof ModeBar) code path - rename 'config' arg --> 'opts' to not be mistaken with the buttons config
1 parent f247698 commit 84a7c06

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/components/modebar/index.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,16 @@ var modebarConfig = require('./modebar_config');
1616
/**
1717
* UI controller for interactive plots
1818
* @Class
19-
* @Param {object} config
20-
* @Param {object} config.buttons nested arrays of grouped buttons to initialize
21-
* @Param {object} config.container container div to append modebar
22-
* @Param {object} config.Plotly main plotly namespace module
23-
* @Param {object} config.graphInfo primary plot object containing data and layout
19+
* @Param {object} opts
20+
* @Param {object} opts.buttons nested arrays of grouped buttons to initialize
21+
* @Param {object} opts.container container div to append modebar
22+
* @Param {object} opts.graphInfo primary plot object containing data and layout
2423
*/
25-
function ModeBar (config) {
26-
27-
if (!(this instanceof ModeBar)) return new ModeBar();
28-
24+
function ModeBar(opts) {
2925
var _this = this;
3026

3127
this._snapshotInProgress = false;
32-
this.graphInfo = config.graphInfo;
28+
this.graphInfo = opts.graphInfo;
3329
this.element = document.createElement('div');
3430

3531
if(this.graphInfo._context.displayModeBar === 'hover') {
@@ -38,7 +34,7 @@ function ModeBar (config) {
3834
this.element.className = 'modebar';
3935
}
4036

41-
this.buttons = config.buttons;
37+
this.buttons = opts.buttons;
4238
this.buttonElements = [];
4339

4440
this.buttons.forEach( function (buttonGroup) {
@@ -64,7 +60,7 @@ function ModeBar (config) {
6460
this.element.appendChild(this.getLogo());
6561
}
6662

67-
config.container.appendChild(this.element);
63+
opts.container.appendChild(this.element);
6864

6965
this.updateActiveButton();
7066
}
@@ -493,9 +489,7 @@ proto.toImage = function() {
493489

494490
proto.sendDataToCloud = function() {
495491
var gd = this.graphInfo;
496-
Plotly.Plots.sendDataToCloud(gd)
497-
};
498-
492+
Plotly.Plots.sendDataToCloud(gd);
499493
};
500494

501495
module.exports = ModeBar;

src/plots/cartesian/graph_interact.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,6 @@ fx.modeBar = function(gd){
12871287
var modebar = new Plotly.ModeBar({
12881288
buttons: buttons,
12891289
container: fullLayout._paperdiv.node(),
1290-
Plotly: Plotly,
12911290
graphInfo: gd
12921291
});
12931292

0 commit comments

Comments
 (0)