Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a1b9e7b

Browse filesBrowse files
committed
Show pan/zoom toggle istate in nbAgg/webagg toolbars.
This uses the 'active' Bootstrap style on nbagg, and colorizes the image to tab:blue on webagg.
1 parent 60f8369 commit a1b9e7b
Copy full SHA for a1b9e7b

File tree

Expand file treeCollapse file tree

3 files changed

+26
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+26
-0
lines changed
Open diff view settings
Collapse file

‎lib/matplotlib/backends/backend_webagg_core.py‎

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_webagg_core.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,14 @@ def save_figure(self, *args):
398398
"""Save the current figure"""
399399
self.canvas.send_event('save')
400400

401+
def pan(self):
402+
super().pan()
403+
self.canvas.send_event('navigate_mode', mode=self._active)
404+
405+
def zoom(self):
406+
super().zoom()
407+
self.canvas.send_event('navigate_mode', mode=self._active)
408+
401409
def set_history_buttons(self):
402410
can_backward = self._nav_stack._pos > 0
403411
can_forward = self._nav_stack._pos < len(self._nav_stack._elements) - 1
Collapse file

‎lib/matplotlib/backends/web_backend/css/mpl.css‎

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/web_backend/css/mpl.css
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
filter: contrast(0%);
3535
}
3636

37+
.mpl-widget.active img {
38+
/* Convert black to tab:blue, approximately */
39+
filter: invert(34%) sepia(97%) saturate(468%) hue-rotate(162deg) brightness(96%) contrast(91%);
40+
}
41+
3742
button.mpl-widget:focus,
3843
button.mpl-widget:hover {
3944
background-color: #ddd;
Collapse file

‎lib/matplotlib/backends/web_backend/js/mpl.js‎

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/web_backend/js/mpl.js
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,19 @@ mpl.figure.prototype.handle_history_buttons = function (fig, msg) {
436436
}
437437
};
438438

439+
mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {
440+
if (msg['mode'] === 'PAN') {
441+
fig.buttons['Pan'].classList.add('active');
442+
fig.buttons['Zoom'].classList.remove('active');
443+
} else if (msg['mode'] === 'ZOOM') {
444+
fig.buttons['Pan'].classList.remove('active');
445+
fig.buttons['Zoom'].classList.add('active');
446+
} else {
447+
fig.buttons['Pan'].classList.remove('active');
448+
fig.buttons['Zoom'].classList.remove('active');
449+
}
450+
};
451+
439452
mpl.figure.prototype.updated_canvas_event = function () {
440453
// Called whenever the canvas gets updated.
441454
this.send_message('ack', {});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.