Skip to content

Add Save Tool to NbAgg Figure [backport to 1.4.x] #3974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 12, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove format dropdown since png is the only format working
  • Loading branch information
blink1073 committed Jan 12, 2015
commit f170d4ca958d1d0e28fd8d71211125150a24012e
23 changes: 6 additions & 17 deletions lib/matplotlib/backends/web_backend/nbagg_mpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ mpl.mpl_figure_comm = function(comm, msg) {
var ws_proxy = comm_websocket_adapter(comm)

function ondownload(figure, format) {
var canvasData = figure.canvas.toDataURL("image/" + format);
window.open(canvasData);
window.open(figure.imageObj.src);
}

var fig = new mpl.figure(id, ws_proxy,
Expand Down Expand Up @@ -113,21 +112,6 @@ mpl.figure.prototype._init_toolbar = function() {
nav_element.append(button);
}

var fmt_picker_span = $('<span/>');

var fmt_picker = $('<select width="75" style="width: 75px; margin-top: 10px"</select>');
fmt_picker.addClass('mpl-toolbar-optionui-widget ui-widget-content');
fmt_picker_span.append(fmt_picker);
nav_element.append(fmt_picker_span);
this.format_dropdown = fmt_picker[0];

for (var ind in mpl.extensions) {
var fmt = mpl.extensions[ind];
var option = $(
'<option/>', {selected: fmt === mpl.default_extension}).html(fmt);
fmt_picker.append(option)
}

// Add the status bar.
var status_bar = $('<span class="mpl-message" style="text-align:right; float: right;"/>');
nav_element.append(status_bar);
Expand Down Expand Up @@ -162,6 +146,11 @@ mpl.figure.prototype._canvas_extra_style = function(el){
}


mpl.figure.prototype.handle_save = function(fig, msg) {
fig.ondownload(fig, null);
}


mpl.find_output_cell = function(html_output) {
// Return the cell and output element which can be found *uniquely* in the notebook.
// Note - this is a bit hacky, but it is done because the "notebook_saving.Notebook"
Expand Down