Skip to content

Commit 22b11d7

Browse files
committed
feat(graph panel): changed to PR grafana#4493 and other polish, removed the relative time from graph tooltip, did not think it worked that well
1 parent 0342442 commit 22b11d7

File tree

5 files changed

+19
-26
lines changed

5 files changed

+19
-26
lines changed

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ function ($) {
3333
return j - 1;
3434
};
3535

36-
this.showTooltip = function(absoluteTime, relativeTime, innerHtml, pos) {
37-
var body = '<div class="graph-tooltip small"><div class="graph-tooltip-time">'+ absoluteTime +
38-
' <span class="tone-down">(' + relativeTime + ')</span></div> ';
36+
this.showTooltip = function(absoluteTime, innerHtml, pos) {
37+
var body = '<div class="graph-tooltip small"><div class="graph-tooltip-time">'+ absoluteTime + '</div> ';
3938
body += innerHtml + '</div>';
4039
$tooltip.html(body).place_tt(pos.pageX + 20, pos.pageY);
4140
};
@@ -109,7 +108,7 @@ function ($) {
109108
var plot = elem.data().plot;
110109
var plotData = plot.getData();
111110
var seriesList = getSeriesFn();
112-
var group, value, absoluteTime, relativeTime, hoverInfo, i, series, seriesHtml, tooltipFormat;
111+
var group, value, absoluteTime, hoverInfo, i, series, seriesHtml, tooltipFormat;
113112

114113
if (panel.tooltip.msResolution) {
115114
tooltipFormat = 'YYYY-MM-DD HH:mm:ss.SSS';
@@ -132,7 +131,6 @@ function ($) {
132131

133132
seriesHtml = '';
134133

135-
relativeTime = dashboard.getRelativeTime(seriesHoverInfo.time);
136134
absoluteTime = dashboard.formatDate(seriesHoverInfo.time, tooltipFormat);
137135

138136
for (i = 0; i < seriesHoverInfo.length; i++) {
@@ -142,22 +140,22 @@ function ($) {
142140
continue;
143141
}
144142

145-
var highlightStyle = '';
143+
var highlightClass = '';
146144
if (item && i === item.seriesIndex) {
147-
highlightStyle = ' style="font-weight: bold;"';
145+
highlightClass = 'graph-tooltip-list-item--highlight';
148146
}
149147

150148
series = seriesList[i];
151149

152150
value = series.formatValue(hoverInfo.value);
153151

154-
seriesHtml += '<div class="graph-tooltip-list-item"><div class="graph-tooltip-series-name"' + highlightStyle + '>';
152+
seriesHtml += '<div class="graph-tooltip-list-item ' + highlightClass + '"><div class="graph-tooltip-series-name">';
155153
seriesHtml += '<i class="fa fa-minus" style="color:' + series.color +';"></i> ' + series.label + ':</div>';
156154
seriesHtml += '<div class="graph-tooltip-value">' + value + '</div></div>';
157155
plot.highlight(i, hoverInfo.hoverIndex);
158156
}
159157

160-
self.showTooltip(absoluteTime, relativeTime, seriesHtml, pos);
158+
self.showTooltip(absoluteTime, seriesHtml, pos);
161159
}
162160
// single series tooltip
163161
else if (item) {
@@ -174,12 +172,11 @@ function ($) {
174172

175173
value = series.formatValue(value);
176174

177-
relativeTime = dashboard.getRelativeTime(item.datapoint[0]);
178175
absoluteTime = dashboard.formatDate(item.datapoint[0], tooltipFormat);
179176

180177
group += '<div class="graph-tooltip-value">' + value + '</div>';
181178

182-
self.showTooltip(absoluteTime, relativeTime, group, pos);
179+
self.showTooltip(absoluteTime, group, pos);
183180
}
184181
// no hit
185182
else {

public/sass/_variables.dark.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ $brand-primary: $orange;
3939
$brand-success: $green;
4040
$brand-warning: $brand-primary;
4141
$brand-danger: $red;
42+
$brand-text-highlight: #f7941d;
4243

4344
// Status colors
4445
// -------------------------
@@ -242,8 +243,8 @@ $infoBackground: $blue-dark;
242243

243244
// Tooltips and popovers
244245
// -------------------------
245-
$tooltipColor: $white;
246-
$tooltipBackground: rgb(58, 57, 57);
246+
$tooltipColor: $text-color;
247+
$tooltipBackground: $dark-4;
247248
$tooltipArrowWidth: 5px;
248249
$tooltipArrowColor: $tooltipBackground;
249250
$tooltipLinkColor: $link-color;

public/sass/_variables.light.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ $brand-primary: $orange;
4444
$brand-success: $green;
4545
$brand-warning: $orange;
4646
$brand-danger: $red;
47+
$brand-text-highlight: #f7941d;
4748

4849
// Status colors
4950
// -------------------------

public/sass/components/_panel_graph.scss

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,27 +237,28 @@
237237

238238
.graph-tooltip-time {
239239
text-align: center;
240-
font-weight: $font-weight-semi-bold;
241240
position: relative;
242241
top: -3px;
243-
}
244-
245-
.tone-down {
246-
opacity: 0.7;
242+
padding: 0.2rem;
247243
}
248244

249245
.graph-tooltip-list-item {
250246
display: table-row;
247+
248+
&--highlight {
249+
color: $brand-text-highlight;
250+
}
251251
}
252252

253253
.graph-tooltip-series-name {
254254
display: table-cell;
255+
padding: 0.15rem;
255256
}
256257

257258
.graph-tooltip-value {
258259
display: table-cell;
259260
font-weight: bold;
260-
padding-left: 10px;
261+
padding-left: 15px;
261262
text-align: right;
262263
}
263264
}

public/sass/components/_tooltip.scss

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@
8888
}
8989
}
9090

91-
.grafana-tooltip hr {
92-
padding: 2px;
93-
color: #c8c8c8;
94-
margin: 0px;
95-
border-bottom: 0px solid #c8c8c8;
96-
}
97-
9891
.grafana-tip {
9992
padding-left: 5px;
10093
}

0 commit comments

Comments
 (0)