Skip to content

Commit 869d472

Browse files
Merge pull request #3970 from plotly/toolpanel-js-menubuttons
Toolpanel js menubuttons
2 parents 24cc7ef + 9b4c0e7 commit 869d472

File tree

2 files changed

+21
-27
lines changed
  • shelly/plotlyjs/static/plotlyjs/src
  • test-dashboard/toolpanel-dashboard

2 files changed

+21
-27
lines changed

shelly/plotlyjs/static/plotlyjs/src/graph_obj.js

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -361,32 +361,6 @@ plots.addLinks = function(gd) {
361361
spacespan.text((toolspan.text() && sourcespan.text()) ? ' - ' : '');
362362
};
363363

364-
/**
365-
* Add or modify a margin requst object by name. Margins in pixels.
366-
*
367-
* This allows us to have multiple modules request space in the plot without
368-
* conflicts. For example:
369-
*
370-
* adjustReservedMargins(gd, 'themeBar', {left: 200})
371-
*
372-
* ... will idempotent-ly set the left margin to 200 for themeBar.
373-
*
374-
* @param gd
375-
* @param {String} marginName
376-
* @param {Object} margins
377-
* @returns {Object}
378-
*/
379-
plots.adjustReservedMargins = function (gd, marginName, margins) {
380-
var margin;
381-
gd._boundingBoxMargins = gd._boundingBoxMargins || {};
382-
gd._boundingBoxMargins[marginName] = {};
383-
['left', 'right', 'top', 'bottom'].forEach(function(key) {
384-
margin = margins[key] || 0;
385-
gd._boundingBoxMargins[marginName][key] = margin;
386-
});
387-
return gd._boundingBoxMargins;
388-
};
389-
390364
// note that now this function is only adding the brand in
391365
// iframes and 3rd-party apps
392366
function positionPlayWithData(gd, container){

test-dashboard/toolpanel-dashboard/ui.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,38 @@ function createPlot (divId) {
5050
};
5151

5252
var data = [trace1, trace2];
53+
var toolPanel;
5354

5455
Plotly.newPlot(divId, data);
5556

56-
graphDiv.toolPanel = new ToolPanel(Plotly, graphDiv, {
57+
graphDiv.toolPanel = toolPanel = new ToolPanel(Plotly, graphDiv, {
5758
standalone: true,
5859
popoverContainer: containerDiv
5960
});
6061

62+
window.toolPanel = graphDiv.toolPanel;
63+
6164
graphDiv.toolPanel.makeMenu({
6265
toolMenuContainer: toolDiv
6366
});
6467

68+
toolPanel.createMenuMultiButton([
69+
{
70+
labelContent: 'Undo',
71+
iconClass: 'icon-rotate-left',
72+
handler: toolPanel.undo
73+
},
74+
{
75+
labelContent: 'Redo',
76+
iconClass: 'icon-rotate-right',
77+
handler: toolPanel.redo
78+
}
79+
]);
80+
81+
toolPanel.createMenuSpacer();
82+
83+
toolPanel.createMenuButtons(toolPanel.getPanelButtonSpecs());
84+
6585
divs.push(graphDiv, toolDiv);
6686

6787
}

0 commit comments

Comments
 (0)