mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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 #6894
This commit is contained in:
@@ -88,7 +88,7 @@ export class KeybindingSrv {
|
||||
// });
|
||||
|
||||
this.bind('mod+o', () => {
|
||||
dashboard.sharedCrosshair = !dashboard.sharedCrosshair;
|
||||
dashboard.graphTooltip = (dashboard.graphTooltip + 1) % 3;
|
||||
appEvents.emit('graph-hover-clear');
|
||||
scope.broadcastRefresh();
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ export class DashboardModel {
|
||||
style: any;
|
||||
timezone: any;
|
||||
editable: any;
|
||||
sharedCrosshair: any;
|
||||
graphTooltip: any;
|
||||
rows: DashboardRow[];
|
||||
time: any;
|
||||
timepicker: any;
|
||||
@@ -51,7 +51,7 @@ export class DashboardModel {
|
||||
this.style = data.style || "dark";
|
||||
this.timezone = data.timezone || '';
|
||||
this.editable = data.editable !== false;
|
||||
this.sharedCrosshair = data.sharedCrosshair || false;
|
||||
this.graphTooltip = data.graphTooltip || false;
|
||||
this.hideControls = data.hideControls || false;
|
||||
this.time = data.time || { from: 'now-6h', to: 'now' };
|
||||
this.timepicker = data.timepicker || {};
|
||||
@@ -267,6 +267,18 @@ export class DashboardModel {
|
||||
}
|
||||
}
|
||||
|
||||
cycleGraphTooltip() {
|
||||
this.graphTooltip = (this.graphTooltip + 1) % 3;
|
||||
}
|
||||
|
||||
sharedTooltipModeEnabled() {
|
||||
return this.graphTooltip !== 0;
|
||||
}
|
||||
|
||||
sharedCrosshairModeOnly() {
|
||||
return this.graphTooltip === 1;
|
||||
}
|
||||
|
||||
getRelativeTime(date) {
|
||||
date = moment.isMoment(date) ? date : moment(date);
|
||||
|
||||
@@ -297,7 +309,7 @@ export class DashboardModel {
|
||||
var i, j, k;
|
||||
var oldVersion = this.schemaVersion;
|
||||
var panelUpgrades = [];
|
||||
this.schemaVersion = 13;
|
||||
this.schemaVersion = 14;
|
||||
|
||||
if (oldVersion === this.schemaVersion) {
|
||||
return;
|
||||
@@ -602,6 +614,10 @@ export class DashboardModel {
|
||||
});
|
||||
}
|
||||
|
||||
if (oldVersion < 14) {
|
||||
this.graphTooltip = old.sharedCrosshair ? 1 : 0;
|
||||
}
|
||||
|
||||
if (panelUpgrades.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -61,12 +61,21 @@
|
||||
checked="dashboard.hideControls"
|
||||
label-class="width-11">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Shared Tooltip"
|
||||
tooltip="Shared Tooltip on all graphs. Shortcut: CTRL+O or CMD+O"
|
||||
checked="dashboard.sharedCrosshair"
|
||||
label-class="width-11">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h5 class="section-heading">Panel Options</h5>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-11">
|
||||
Graph Tooltip
|
||||
<info-popover mode="right-normal">
|
||||
Cycle between options using Shortcut: CTRL+O or CMD+O
|
||||
</info-popover>
|
||||
</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ coreModule.directive('grafanaGraph', function($rootScope, timeSrv) {
|
||||
// global events
|
||||
appEvents.on('graph-hover', function(evt) {
|
||||
// ignore other graph hover events if shared tooltip is disabled
|
||||
if (!dashboard.sharedCrosshair) {
|
||||
if (!dashboard.sharedTooltipModeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,6 +179,11 @@ function ($, core) {
|
||||
pos.pageY = elem.offset().top + elem.height() * pos.panelRelY;
|
||||
plot.setCrosshair(pos);
|
||||
allSeriesMode = true;
|
||||
|
||||
if (dashboard.sharedCrosshairModeOnly()) {
|
||||
// if only crosshair mode we are done
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (seriesList.length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user