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
Show file tree
Hide file tree
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
Next Next commit
Add the format picker to the nbagg save toolbar
  • Loading branch information
blink1073 committed Jan 12, 2015
commit 5bb7711602079e900438f5938226e63dc9a0202c
8 changes: 2 additions & 6 deletions lib/matplotlib/backends/web_backend/mpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,8 @@ mpl.figure.prototype.key_event = function(event, name) {

mpl.figure.prototype.toolbar_button_onclick = function(name) {
if (name == 'download') {
if (this.format_dropdown) {
var format_dropdown = this.format_dropdown;
var format = format_dropdown.options[format_dropdown.selectedIndex].value;
} else {
format = 'png';
}
var format_dropdown = this.format_dropdown;
var format = format_dropdown.options[format_dropdown.selectedIndex].value;
this.ondownload(this, format);
} else {
this.send_message("toolbar_button", {name: name});
Expand Down
15 changes: 15 additions & 0 deletions lib/matplotlib/backends/web_backend/nbagg_mpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ 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