Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 8 additions & 13 deletions lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,20 +319,15 @@ class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2):
None: None
}

def _init_toolbar(self):
# Use the standard toolbar items + download button
toolitems = (
backend_bases.NavigationToolbar2.toolitems +
(('Download', 'Download plot', 'download', 'download'),)
)

NavigationToolbar2WebAgg.toolitems = \
tuple(
(text, tooltip_text, self._jquery_icon_classes[image_file],
name_of_method)
for text, tooltip_text, image_file, name_of_method
in toolitems if image_file in self._jquery_icon_classes)

# Use the standard toolbar items + download button
toolitems = [(text, tooltip_text, _jquery_icon_classes[image_file], name_of_method)
for text, tooltip_text, image_file, name_of_method
in (backend_bases.NavigationToolbar2.toolitems +
(('Download', 'Download plot', 'download', 'download'),))
if image_file in _jquery_icon_classes]

def _init_toolbar(self):
self.message = ''
self.cursor = 0

Expand Down
14 changes: 4 additions & 10 deletions lib/matplotlib/backends/web_backend/mpl.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Put everything inside the mpl namespace */
var mpl = {};
/* Put everything inside the global mpl namespace */
window.mpl = {};


mpl.get_websocket_type = function() {
Expand Down Expand Up @@ -56,21 +56,15 @@ mpl.figure = function(figure_id, websocket, ondownload, parent_element) {

this.waiting = false;

onopen_creator = function(fig) {
return function () {
this.ws.onopen = function () {
fig.send_message("supports_binary", {value: fig.supports_binary});
fig.send_message("refresh", {});
}
};
this.ws.onopen = onopen_creator(fig);

onload_creator = function(fig) {
return function() {
this.imageObj.onload = function() {
fig.context.drawImage(fig.imageObj, 0, 0);
fig.waiting = false;
};
};
this.imageObj.onload = onload_creator(fig);

this.imageObj.onunload = function() {
this.ws.close();
Expand Down