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
7b9b34c6
Commit
7b9b34c6
authored
Mar 29, 2018
by
Patrick O'Carroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrated graph_tooltip to ts
parent
65f7c5f0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
27 deletions
+27
-27
public/app/plugins/panel/graph/graph_tooltip.ts
+24
-25
public/app/plugins/panel/graph/specs/tooltip_specs.ts
+3
-2
No files found.
public/app/plugins/panel/graph/graph_tooltip.ts
View file @
7b9b34c6
import
$
from
'jquery'
;
import
{
appEvents
}
from
'app/core/core'
;
//var appEvents = appEvents;
export
default
function
GraphTooltip
(
elem
,
dashboard
,
scope
,
getSeriesFn
)
{
let
self
=
this
;
let
ctrl
=
scope
.
ctrl
;
...
...
@@ -15,10 +13,11 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
};
this
.
findHoverIndexFromDataPoints
=
function
(
posX
,
series
,
last
)
{
var
ps
=
series
.
datapoints
.
pointsize
;
var
initial
=
last
*
ps
;
var
len
=
series
.
datapoints
.
points
.
length
;
for
(
var
j
=
initial
;
j
<
len
;
j
+=
ps
)
{
let
ps
=
series
.
datapoints
.
pointsize
;
let
initial
=
last
*
ps
;
let
len
=
series
.
datapoints
.
points
.
length
;
let
j
;
for
(
j
=
initial
;
j
<
len
;
j
+=
ps
)
{
// Special case of a non stepped line, highlight the very last point just before a null point
if
(
(
!
series
.
lines
.
steps
&&
series
.
datapoints
.
points
[
initial
]
!=
null
&&
series
.
datapoints
.
points
[
j
]
==
null
)
||
...
...
@@ -32,9 +31,9 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
};
this
.
findHoverIndexFromData
=
function
(
posX
,
series
)
{
var
lower
=
0
;
var
upper
=
series
.
data
.
length
-
1
;
var
middle
;
let
lower
=
0
;
let
upper
=
series
.
data
.
length
-
1
;
let
middle
;
while
(
true
)
{
if
(
lower
>
upper
)
{
return
Math
.
max
(
upper
,
0
);
...
...
@@ -58,14 +57,14 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
};
this
.
getMultiSeriesPlotHoverInfo
=
function
(
seriesList
,
pos
)
{
var
value
,
i
,
series
,
hoverIndex
,
hoverDistance
,
pointTime
,
yaxis
;
let
value
,
i
,
series
,
hoverIndex
,
hoverDistance
,
pointTime
,
yaxis
;
// 3 sub-arrays, 1st for hidden series, 2nd for left yaxis, 3rd for right yaxis.
var
results
:
any
=
[[],
[],
[]];
let
results
:
any
=
[[],
[],
[]];
//now we know the current X (j) position for X and Y values
var
last_value
=
0
;
//needed for stacked values
let
last_value
=
0
;
//needed for stacked values
var
minDistance
,
minTime
;
let
minDistance
,
minTime
;
for
(
i
=
0
;
i
<
seriesList
.
length
;
i
++
)
{
series
=
seriesList
[
i
];
...
...
@@ -145,7 +144,7 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
elem
.
mouseleave
(
function
()
{
if
(
panel
.
tooltip
.
shared
)
{
var
plot
=
elem
.
data
().
plot
;
let
plot
=
elem
.
data
().
plot
;
if
(
plot
)
{
$tooltip
.
detach
();
plot
.
unhighlight
();
...
...
@@ -173,25 +172,25 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
};
this
.
show
=
function
(
pos
,
item
)
{
var
plot
=
elem
.
data
().
plot
;
var
plotData
=
plot
.
getData
();
var
xAxes
=
plot
.
getXAxes
();
var
xMode
=
xAxes
[
0
].
options
.
mode
;
var
seriesList
=
getSeriesFn
();
var
allSeriesMode
=
panel
.
tooltip
.
shared
;
var
group
,
value
,
absoluteTime
,
hoverInfo
,
i
,
series
,
seriesHtml
,
tooltipFormat
;
let
plot
=
elem
.
data
().
plot
;
let
plotData
=
plot
.
getData
();
let
xAxes
=
plot
.
getXAxes
();
let
xMode
=
xAxes
[
0
].
options
.
mode
;
let
seriesList
=
getSeriesFn
();
let
allSeriesMode
=
panel
.
tooltip
.
shared
;
let
group
,
value
,
absoluteTime
,
hoverInfo
,
i
,
series
,
seriesHtml
,
tooltipFormat
;
// if panelRelY is defined another panel wants us to show a tooltip
// get pageX from position on x axis and pageY from relative position in original panel
if
(
pos
.
panelRelY
)
{
var
pointOffset
=
plot
.
pointOffset
({
x
:
pos
.
x
});
let
pointOffset
=
plot
.
pointOffset
({
x
:
pos
.
x
});
if
(
Number
.
isNaN
(
pointOffset
.
left
)
||
pointOffset
.
left
<
0
||
pointOffset
.
left
>
elem
.
width
())
{
self
.
clear
(
plot
);
return
;
}
pos
.
pageX
=
elem
.
offset
().
left
+
pointOffset
.
left
;
pos
.
pageY
=
elem
.
offset
().
top
+
elem
.
height
()
*
pos
.
panelRelY
;
var
isVisible
=
let
isVisible
=
pos
.
pageY
>=
$
(
window
).
scrollTop
()
&&
pos
.
pageY
<=
$
(
window
).
innerHeight
()
+
$
(
window
).
scrollTop
();
if
(
!
isVisible
)
{
self
.
clear
(
plot
);
...
...
@@ -219,7 +218,7 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
if
(
allSeriesMode
)
{
plot
.
unhighlight
();
var
seriesHoverInfo
=
self
.
getMultiSeriesPlotHoverInfo
(
plotData
,
pos
);
let
seriesHoverInfo
=
self
.
getMultiSeriesPlotHoverInfo
(
plotData
,
pos
);
seriesHtml
=
''
;
...
...
@@ -244,7 +243,7 @@ export default function GraphTooltip(elem, dashboard, scope, getSeriesFn) {
continue
;
}
var
highlightClass
=
''
;
let
highlightClass
=
''
;
if
(
item
&&
hoverInfo
.
index
===
item
.
seriesIndex
)
{
highlightClass
=
'graph-tooltip-list-item--highlight'
;
}
...
...
public/app/plugins/panel/graph/specs/tooltip_specs.ts
View file @
7b9b34c6
...
...
@@ -11,6 +11,7 @@ var scope = {
var
elem
=
$
(
'<div></div>'
);
var
dashboard
=
{};
var
getSeriesFn
;
function
describeSharedTooltip
(
desc
,
fn
)
{
var
ctx
:
any
=
{};
...
...
@@ -30,7 +31,7 @@ function describeSharedTooltip(desc, fn) {
describe
(
desc
,
function
()
{
beforeEach
(
function
()
{
ctx
.
setupFn
();
var
tooltip
=
new
GraphTooltip
(
elem
,
dashboard
,
scope
);
var
tooltip
=
new
GraphTooltip
(
elem
,
dashboard
,
scope
,
getSeriesFn
);
ctx
.
results
=
tooltip
.
getMultiSeriesPlotHoverInfo
(
ctx
.
data
,
ctx
.
pos
);
});
...
...
@@ -39,7 +40,7 @@ function describeSharedTooltip(desc, fn) {
}
describe
(
'findHoverIndexFromData'
,
function
()
{
var
tooltip
=
new
GraphTooltip
(
elem
,
dashboard
,
scope
);
var
tooltip
=
new
GraphTooltip
(
elem
,
dashboard
,
scope
,
getSeriesFn
);
var
series
=
{
data
:
[[
100
,
0
],
[
101
,
0
],
[
102
,
0
],
[
103
,
0
],
[
104
,
0
],
[
105
,
0
],
[
106
,
0
],
[
107
,
0
]],
};
...
...
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