Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
af65a81d
Commit
af65a81d
authored
Oct 27, 2015
by
ubhatnagar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added relative time in tooltip
parent
03e2f25a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
public/app/panels/graph/graph.tooltip.js
+17
-11
No files found.
public/app/panels/graph/graph.tooltip.js
View file @
af65a81d
...
@@ -31,8 +31,13 @@ function ($) {
...
@@ -31,8 +31,13 @@ function ($) {
return
j
-
1
;
return
j
-
1
;
};
};
this
.
showTooltip
=
function
(
title
,
innerHtml
,
pos
)
{
this
.
showTooltip
=
function
(
absoluteTime
,
relativeTime
,
innerHtml
,
pos
)
{
var
body
=
'<div class="graph-tooltip small"><div class="graph-tooltip-time">'
+
title
+
'</div> '
;
var
body
;
if
(
typeof
relativeTime
===
'undefined'
)
{
body
=
'<div class="graph-tooltip small"><div class="graph-tooltip-time">'
+
absoluteTime
+
'</div> '
;
}
else
{
body
=
'<div class="graph-tooltip small"><div class="graph-tooltip-time">'
+
absoluteTime
+
'<br>('
+
relativeTime
+
')</div> '
;
}
body
+=
innerHtml
+
'</div>'
;
body
+=
innerHtml
+
'</div>'
;
$tooltip
.
html
(
body
).
place_tt
(
pos
.
pageX
+
20
,
pos
.
pageY
);
$tooltip
.
html
(
body
).
place_tt
(
pos
.
pageX
+
20
,
pos
.
pageY
);
};
};
...
@@ -101,7 +106,7 @@ function ($) {
...
@@ -101,7 +106,7 @@ function ($) {
var
plot
=
elem
.
data
().
plot
;
var
plot
=
elem
.
data
().
plot
;
var
plotData
=
plot
.
getData
();
var
plotData
=
plot
.
getData
();
var
seriesList
=
getSeriesFn
();
var
seriesList
=
getSeriesFn
();
var
group
,
value
,
timestamp
,
hoverInfo
,
i
,
series
,
seriesHtml
;
var
group
,
value
,
absoluteTime
,
relativeTime
,
hoverInfo
,
i
,
series
,
seriesHtml
;
if
(
dashboard
.
sharedCrosshair
){
if
(
dashboard
.
sharedCrosshair
){
scope
.
appEvent
(
'setCrosshair'
,
{
pos
:
pos
,
scope
:
scope
});
scope
.
appEvent
(
'setCrosshair'
,
{
pos
:
pos
,
scope
:
scope
});
...
@@ -117,12 +122,13 @@ function ($) {
...
@@ -117,12 +122,13 @@ function ($) {
var
seriesHoverInfo
=
self
.
getMultiSeriesPlotHoverInfo
(
plotData
,
pos
);
var
seriesHoverInfo
=
self
.
getMultiSeriesPlotHoverInfo
(
plotData
,
pos
);
seriesHtml
=
''
;
seriesHtml
=
''
;
if
(
scope
.
panel
.
tooltip
.
relativeTimestamp
)
{
if
(
scope
.
panel
.
tooltip
.
relativeTimestamp
)
{
timestamp
=
dashboard
.
formatRelativeDate
(
seriesHoverInfo
.
time
);
relativeTime
=
dashboard
.
formatRelativeDate
(
seriesHoverInfo
.
time
);
}
else
{
timestamp
=
dashboard
.
formatDate
(
seriesHoverInfo
.
time
);
}
}
absoluteTime
=
dashboard
.
formatDate
(
seriesHoverInfo
.
time
);
for
(
i
=
0
;
i
<
seriesHoverInfo
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
seriesHoverInfo
.
length
;
i
++
)
{
hoverInfo
=
seriesHoverInfo
[
i
];
hoverInfo
=
seriesHoverInfo
[
i
];
...
@@ -140,7 +146,7 @@ function ($) {
...
@@ -140,7 +146,7 @@ function ($) {
plot
.
highlight
(
i
,
hoverInfo
.
hoverIndex
);
plot
.
highlight
(
i
,
hoverInfo
.
hoverIndex
);
}
}
self
.
showTooltip
(
timestamp
,
seriesHtml
,
pos
);
self
.
showTooltip
(
absoluteTime
,
relativeTime
,
seriesHtml
,
pos
);
}
}
// single series tooltip
// single series tooltip
else
if
(
item
)
{
else
if
(
item
)
{
...
@@ -158,14 +164,14 @@ function ($) {
...
@@ -158,14 +164,14 @@ function ($) {
value
=
series
.
formatValue
(
value
);
value
=
series
.
formatValue
(
value
);
if
(
scope
.
panel
.
tooltip
.
relativeTimestamp
)
{
if
(
scope
.
panel
.
tooltip
.
relativeTimestamp
)
{
timestamp
=
dashboard
.
formatRelativeDate
(
item
.
datapoint
[
0
]);
relativeTime
=
dashboard
.
formatRelativeDate
(
item
.
datapoint
[
0
]);
}
else
{
timestamp
=
dashboard
.
formatDate
(
item
.
datapoint
[
0
]);
}
}
absoluteTime
=
dashboard
.
formatDate
(
item
.
datapoint
[
0
]);
group
+=
'<div class="graph-tooltip-value">'
+
value
+
'</div>'
;
group
+=
'<div class="graph-tooltip-value">'
+
value
+
'</div>'
;
self
.
showTooltip
(
timestamp
,
group
,
pos
);
self
.
showTooltip
Other
(
absoluteTime
,
relativeTime
,
group
,
pos
);
}
}
// no hit
// no hit
else
{
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment