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
7c5ef2c7
Commit
7c5ef2c7
authored
Jan 25, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'connection-reset-shared_tooltip'
parents
23eab81c
28f890e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
10 deletions
+47
-10
public/app/plugins/panel/graph/graph_tooltip.js
+22
-7
public/app/plugins/panel/graph/specs/tooltip_specs.ts
+25
-3
No files found.
public/app/plugins/panel/graph/graph_tooltip.js
View file @
7c5ef2c7
...
@@ -34,13 +34,22 @@ function ($, core) {
...
@@ -34,13 +34,22 @@ function ($, core) {
};
};
this
.
findHoverIndexFromData
=
function
(
posX
,
series
)
{
this
.
findHoverIndexFromData
=
function
(
posX
,
series
)
{
var
len
=
series
.
data
.
length
;
var
lower
=
0
;
for
(
var
j
=
0
;
j
<
len
;
j
++
)
{
var
upper
=
series
.
data
.
length
-
1
;
if
(
series
.
data
[
j
][
0
]
>
posX
)
{
var
middle
;
return
Math
.
max
(
j
-
1
,
0
);
while
(
true
)
{
if
(
lower
>
upper
)
{
return
Math
.
max
(
upper
,
0
);
}
middle
=
Math
.
floor
((
lower
+
upper
)
/
2
);
if
(
series
.
data
[
middle
][
0
]
===
posX
)
{
return
middle
;
}
else
if
(
series
.
data
[
middle
][
0
]
<
posX
)
{
lower
=
middle
+
1
;
}
else
{
upper
=
middle
-
1
;
}
}
}
}
return
j
-
1
;
};
};
this
.
renderAndShow
=
function
(
absoluteTime
,
innerHtml
,
pos
,
xMode
)
{
this
.
renderAndShow
=
function
(
absoluteTime
,
innerHtml
,
pos
,
xMode
)
{
...
@@ -156,6 +165,7 @@ function ($, core) {
...
@@ -156,6 +165,7 @@ function ($, core) {
this
.
clear
=
function
(
plot
)
{
this
.
clear
=
function
(
plot
)
{
$tooltip
.
detach
();
$tooltip
.
detach
();
plot
.
clearCrosshair
();
plot
.
clearCrosshair
();
plot
.
unhighlight
();
};
};
this
.
show
=
function
(
pos
,
item
)
{
this
.
show
=
function
(
pos
,
item
)
{
...
@@ -171,12 +181,17 @@ function ($, core) {
...
@@ -171,12 +181,17 @@ function ($, core) {
// get pageX from position on x axis and pageY from relative position in original panel
// get pageX from position on x axis and pageY from relative position in original panel
if
(
pos
.
panelRelY
)
{
if
(
pos
.
panelRelY
)
{
var
pointOffset
=
plot
.
pointOffset
({
x
:
pos
.
x
});
var
pointOffset
=
plot
.
pointOffset
({
x
:
pos
.
x
});
if
(
Number
.
isNaN
(
pointOffset
.
left
)
||
pointOffset
.
left
<
0
)
{
if
(
Number
.
isNaN
(
pointOffset
.
left
)
||
pointOffset
.
left
<
0
||
pointOffset
.
left
>
elem
.
width
()
)
{
$tooltip
.
detach
(
);
self
.
clear
(
plot
);
return
;
return
;
}
}
pos
.
pageX
=
elem
.
offset
().
left
+
pointOffset
.
left
;
pos
.
pageX
=
elem
.
offset
().
left
+
pointOffset
.
left
;
pos
.
pageY
=
elem
.
offset
().
top
+
elem
.
height
()
*
pos
.
panelRelY
;
pos
.
pageY
=
elem
.
offset
().
top
+
elem
.
height
()
*
pos
.
panelRelY
;
var
isVisible
=
pos
.
pageY
>=
$
(
window
).
scrollTop
()
&&
pos
.
pageY
<=
$
(
window
).
innerHeight
()
+
$
(
window
).
scrollTop
();
if
(
!
isVisible
)
{
self
.
clear
(
plot
);
return
;
}
plot
.
setCrosshair
(
pos
);
plot
.
setCrosshair
(
pos
);
allSeriesMode
=
true
;
allSeriesMode
=
true
;
...
...
public/app/plugins/panel/graph/specs/tooltip_specs.ts
View file @
7c5ef2c7
...
@@ -40,6 +40,31 @@ function describeSharedTooltip(desc, fn) {
...
@@ -40,6 +40,31 @@ function describeSharedTooltip(desc, fn) {
});
});
}
}
describe
(
"findHoverIndexFromData"
,
function
()
{
var
tooltip
=
new
GraphTooltip
(
elem
,
dashboard
,
scope
);
var
series
=
{
data
:
[[
100
,
0
],
[
101
,
0
],
[
102
,
0
],
[
103
,
0
],
[
104
,
0
],
[
105
,
0
],
[
106
,
0
],
[
107
,
0
]]
};
it
(
"should return 0 if posX out of lower bounds"
,
function
()
{
var
posX
=
99
;
expect
(
tooltip
.
findHoverIndexFromData
(
posX
,
series
)).
to
.
be
(
0
);
});
it
(
"should return n - 1 if posX out of upper bounds"
,
function
()
{
var
posX
=
108
;
expect
(
tooltip
.
findHoverIndexFromData
(
posX
,
series
)).
to
.
be
(
series
.
data
.
length
-
1
);
});
it
(
"should return i if posX in series"
,
function
()
{
var
posX
=
104
;
expect
(
tooltip
.
findHoverIndexFromData
(
posX
,
series
)).
to
.
be
(
4
);
});
it
(
"should return i if posX not in series and i + 1 > posX"
,
function
()
{
var
posX
=
104.9
;
expect
(
tooltip
.
findHoverIndexFromData
(
posX
,
series
)).
to
.
be
(
4
);
});
});
describeSharedTooltip
(
"steppedLine false, stack false"
,
function
(
ctx
)
{
describeSharedTooltip
(
"steppedLine false, stack false"
,
function
(
ctx
)
{
ctx
.
setup
(
function
()
{
ctx
.
setup
(
function
()
{
ctx
.
data
=
[
ctx
.
data
=
[
...
@@ -168,6 +193,3 @@ describeSharedTooltip("steppedLine false, stack true, individual true", function
...
@@ -168,6 +193,3 @@ describeSharedTooltip("steppedLine false, stack true, individual true", function
expect
(
ctx
.
results
[
1
].
value
).
to
.
be
(
2
);
expect
(
ctx
.
results
[
1
].
value
).
to
.
be
(
2
);
});
});
});
});
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