Merge pull request #13768 from davewat/feat-toggle-legend-shortcut

Feat - keyboard shortcut to toggle legend
This commit is contained in:
Torkel Ödegaard 2018-10-23 16:06:32 +02:00 committed by GitHub
commit 15e1e41540
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -34,6 +34,7 @@ export class HelpCtrl {
{ keys: ['p', 's'], description: 'Open Panel Share Modal' },
{ keys: ['p', 'd'], description: 'Duplicate Panel' },
{ keys: ['p', 'r'], description: 'Remove Panel' },
{ keys: ['p', 'l'], description: 'Toggle panel legend' },
],
'Time Range': [
{ keys: ['t', 'z'], description: 'Zoom out time range' },

View File

@ -242,6 +242,18 @@ export class KeybindingSrv {
}
});
// toggle panel legend
this.bind('p l', () => {
if (dashboard.meta.focusPanelId) {
const panelInfo = dashboard.getPanelInfoById(dashboard.meta.focusPanelId);
if (panelInfo.panel.legend) {
const panelRef = dashboard.getPanelById(dashboard.meta.focusPanelId);
panelRef.legend.show = !panelRef.legend.show;
panelRef.refresh();
}
}
});
// collapse all rows
this.bind('d shift+c', () => {
dashboard.collapseRows();

View File

@ -147,7 +147,7 @@ class GraphCtrl extends MetricsPanelCtrl {
onInitPanelActions(actions) {
actions.push({ text: 'Export CSV', click: 'ctrl.exportCsv()' });
actions.push({ text: 'Toggle legend', click: 'ctrl.toggleLegend()' });
actions.push({ text: 'Toggle legend', click: 'ctrl.toggleLegend()', shortcut: 'p l' });
}
issueQueries(datasource) {