Skip to content

Commit e72a60b

Browse files
committed
feat(graph): shared graph tooltip is not a select option with 3 options, normal, shared crosshair & shared tooltip, CTRL+O or CMD+O cycles option, closes grafana#6894
1 parent baec2bb commit e72a60b

File tree

6 files changed

+43
-13
lines changed

6 files changed

+43
-13
lines changed

docs/sources/reference/dashboard.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ When a user creates a new dashboard, a new dashboard JSON object is initialized
3333
"timezone": "browser",
3434
"editable": true,
3535
"hideControls": false,
36-
"sharedCrosshair": false,
36+
"graphTooltip": 1,
3737
"rows": [],
3838
"time": {
3939
"from": "now-6h",
@@ -65,7 +65,7 @@ Each field in the dashboard JSON is explained below with its usage:
6565
| **timezone** | timezone of dashboard, i.e. `utc` or `browser` |
6666
| **editable** | whether a dashboard is editable or not |
6767
| **hideControls** | whether row controls on the left in green are hidden or not |
68-
| **sharedCrosshair** | TODO |
68+
| **graphTooltip** | TODO |
6969
| **rows** | row metadata, see [rows section](/docs/sources/reference/dashboard.md/#rows) for details |
7070
| **time** | time range for dashboard, i.e. last 6 hours, last 7 days, etc |
7171
| **timepicker** | timepicker metadata, see [timepicker section](/docs/sources/reference/dashboard.md/#timepicker) for details |

public/app/core/services/keybindingSrv.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class KeybindingSrv {
8888
// });
8989

9090
this.bind('mod+o', () => {
91-
dashboard.sharedCrosshair = !dashboard.sharedCrosshair;
91+
dashboard.graphTooltip = (dashboard.graphTooltip + 1) % 3;
9292
appEvents.emit('graph-hover-clear');
9393
scope.broadcastRefresh();
9494
});

public/app/features/dashboard/model.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class DashboardModel {
1818
style: any;
1919
timezone: any;
2020
editable: any;
21-
sharedCrosshair: any;
21+
graphTooltip: any;
2222
rows: DashboardRow[];
2323
time: any;
2424
timepicker: any;
@@ -51,7 +51,7 @@ export class DashboardModel {
5151
this.style = data.style || "dark";
5252
this.timezone = data.timezone || '';
5353
this.editable = data.editable !== false;
54-
this.sharedCrosshair = data.sharedCrosshair || false;
54+
this.graphTooltip = data.graphTooltip || false;
5555
this.hideControls = data.hideControls || false;
5656
this.time = data.time || { from: 'now-6h', to: 'now' };
5757
this.timepicker = data.timepicker || {};
@@ -267,6 +267,18 @@ export class DashboardModel {
267267
}
268268
}
269269

270+
cycleGraphTooltip() {
271+
this.graphTooltip = (this.graphTooltip + 1) % 3;
272+
}
273+
274+
sharedTooltipModeEnabled() {
275+
return this.graphTooltip !== 0;
276+
}
277+
278+
sharedCrosshairModeOnly() {
279+
return this.graphTooltip === 1;
280+
}
281+
270282
getRelativeTime(date) {
271283
date = moment.isMoment(date) ? date : moment(date);
272284

@@ -297,7 +309,7 @@ export class DashboardModel {
297309
var i, j, k;
298310
var oldVersion = this.schemaVersion;
299311
var panelUpgrades = [];
300-
this.schemaVersion = 13;
312+
this.schemaVersion = 14;
301313

302314
if (oldVersion === this.schemaVersion) {
303315
return;
@@ -602,6 +614,10 @@ export class DashboardModel {
602614
});
603615
}
604616

617+
if (oldVersion < 14) {
618+
this.graphTooltip = old.sharedCrosshair ? 1 : 0;
619+
}
620+
605621
if (panelUpgrades.length === 0) {
606622
return;
607623
}

public/app/features/dashboard/partials/settings.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,21 @@ <h5 class="section-heading">Toggles</h5>
6161
checked="dashboard.hideControls"
6262
label-class="width-11">
6363
</gf-form-switch>
64-
<gf-form-switch class="gf-form"
65-
label="Shared Tooltip"
66-
tooltip="Shared Tooltip on all graphs. Shortcut: CTRL+O or CMD+O"
67-
checked="dashboard.sharedCrosshair"
68-
label-class="width-11">
69-
</gf-form-switch>
64+
</div>
65+
</div>
66+
67+
<div class="section">
68+
<h5 class="section-heading">Panel Options</h5>
69+
<div class="gf-form">
70+
<label class="gf-form-label width-11">
71+
Graph Tooltip
72+
<info-popover mode="right-normal">
73+
Cycle between options using Shortcut: CTRL+O or CMD+O
74+
</info-popover>
75+
</label>
76+
<div class="gf-form-select-wrapper">
77+
<select ng-model="dashboard.graphTooltip" class='gf-form-input' ng-options="f.value as f.text for f in [{value: 0, text: 'Default'}, {value: 1, text: 'Shared crosshair'},{value: 2, text: 'Shared Tooltip'}]"></select>
78+
</div>
7079
</div>
7180
</div>
7281

public/app/plugins/panel/graph/graph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
6161
// global events
6262
appEvents.on('graph-hover', function(evt) {
6363
// ignore other graph hover events if shared tooltip is disabled
64-
if (!dashboard.sharedCrosshair) {
64+
if (!dashboard.sharedTooltipModeEnabled()) {
6565
return;
6666
}
6767

public/app/plugins/panel/graph/graph_tooltip.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ function ($, core) {
179179
pos.pageY = elem.offset().top + elem.height() * pos.panelRelY;
180180
plot.setCrosshair(pos);
181181
allSeriesMode = true;
182+
183+
if (dashboard.sharedCrosshairModeOnly()) {
184+
// if only crosshair mode we are done
185+
return;
186+
}
182187
}
183188

184189
if (seriesList.length === 0) {

0 commit comments

Comments
 (0)