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
ee58a6ee
Commit
ee58a6ee
authored
Jan 19, 2017
by
Axel Pirek
Committed by
Axel Pirek
Jan 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up tooltip value retrieval
parent
a2e6408b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
8 deletions
+39
-8
public/app/plugins/panel/graph/graph_tooltip.js
+14
-5
public/app/plugins/panel/graph/specs/tooltip_specs.ts
+25
-3
No files found.
public/app/plugins/panel/graph/graph_tooltip.js
View file @
ee58a6ee
...
...
@@ -34,13 +34,22 @@ function ($, core) {
};
this
.
findHoverIndexFromData
=
function
(
posX
,
series
)
{
var
len
=
series
.
data
.
length
;
for
(
var
j
=
0
;
j
<
len
;
j
++
)
{
if
(
series
.
data
[
j
][
0
]
>
posX
)
{
return
Math
.
max
(
j
-
1
,
0
);
var
lower
=
0
;
var
upper
=
series
.
data
.
length
-
1
;
var
middle
;
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
{
//if (series.data[middle][0] > posX) {
upper
=
middle
-
1
;
}
}
return
j
-
1
;
};
this
.
renderAndShow
=
function
(
absoluteTime
,
innerHtml
,
pos
,
xMode
)
{
...
...
public/app/plugins/panel/graph/specs/tooltip_specs.ts
View file @
ee58a6ee
...
...
@@ -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
)
{
ctx
.
setup
(
function
()
{
ctx
.
data
=
[
...
...
@@ -168,6 +193,3 @@ describeSharedTooltip("steppedLine false, stack true, individual true", function
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