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
931ad9e9
Commit
931ad9e9
authored
Dec 09, 2013
by
Rashid Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved data off scope
parent
85bfed67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
src/app/panels/histogram/module.js
+25
-24
No files found.
src/app/panels/histogram/module.js
View file @
931ad9e9
...
@@ -242,9 +242,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -242,9 +242,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
$scope
.
init
=
function
()
{
$scope
.
init
=
function
()
{
// Hide view options by default
// Hide view options by default
$scope
.
options
=
false
;
$scope
.
options
=
false
;
$scope
.
$on
(
'refresh'
,
function
(){
$scope
.
get_data
();
});
// Always show the query if an alias isn't set. Users can set an alias if the query is too
// Always show the query if an alias isn't set. Users can set an alias if the query is too
// long
// long
...
@@ -303,7 +300,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -303,7 +300,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
* @param {number} query_id The id of the query, generated on the first run and passed back when
* @param {number} query_id The id of the query, generated on the first run and passed back when
* this call is made recursively for more segments
* this call is made recursively for more segments
*/
*/
$scope
.
get_data
=
function
(
segment
,
query_id
)
{
$scope
.
get_data
=
function
(
data
,
segment
,
query_id
)
{
var
var
_range
,
_range
,
_interval
,
_interval
,
...
@@ -380,12 +377,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -380,12 +377,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
results
=
request
.
doSearch
();
results
=
request
.
doSearch
();
// Populate scope when we have results
// Populate scope when we have results
results
.
then
(
function
(
results
)
{
return
results
.
then
(
function
(
results
)
{
$scope
.
panelMeta
.
loading
=
false
;
$scope
.
panelMeta
.
loading
=
false
;
if
(
segment
===
0
)
{
if
(
segment
===
0
)
{
$scope
.
hits
=
0
;
$scope
.
hits
=
0
;
$scope
.
data
=
[];
data
=
[];
$scope
.
annotations
=
[];
$scope
.
annotations
=
[];
query_id
=
$scope
.
query_id
=
new
Date
().
getTime
();
query_id
=
$scope
.
query_id
=
new
Date
().
getTime
();
}
}
...
@@ -407,7 +403,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -407,7 +403,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
var
query_results
=
results
.
facets
[
q
.
id
];
var
query_results
=
results
.
facets
[
q
.
id
];
// we need to initialize the data variable on the first run,
// we need to initialize the data variable on the first run,
// and when we are working on the first segment of the data.
// and when we are working on the first segment of the data.
if
(
_
.
isUndefined
(
$scope
.
data
[
i
])
||
segment
===
0
)
{
if
(
_
.
isUndefined
(
data
[
i
])
||
segment
===
0
)
{
var
tsOpts
=
{
var
tsOpts
=
{
interval
:
_interval
,
interval
:
_interval
,
start_date
:
_range
&&
_range
.
from
,
start_date
:
_range
&&
_range
.
from
,
...
@@ -417,8 +413,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -417,8 +413,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
time_series
=
new
timeSeries
.
ZeroFilled
(
tsOpts
);
time_series
=
new
timeSeries
.
ZeroFilled
(
tsOpts
);
hits
=
0
;
hits
=
0
;
}
else
{
}
else
{
time_series
=
$scope
.
data
[
i
].
time_series
;
time_series
=
data
[
i
].
time_series
;
hits
=
$scope
.
data
[
i
].
hits
;
hits
=
data
[
i
].
hits
;
}
}
// push each entry into the time series, while incrementing counters
// push each entry into the time series, while incrementing counters
...
@@ -427,7 +423,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -427,7 +423,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
hits
+=
entry
.
count
;
// The series level hits counter
hits
+=
entry
.
count
;
// The series level hits counter
$scope
.
hits
+=
entry
.
count
;
// Entire dataset level hits counter
$scope
.
hits
+=
entry
.
count
;
// Entire dataset level hits counter
});
});
$scope
.
data
[
i
]
=
{
data
[
i
]
=
{
info
:
q
,
info
:
q
,
time_series
:
time_series
,
time_series
:
time_series
,
hits
:
hits
hits
:
hits
...
@@ -461,11 +457,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -461,11 +457,11 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
}
}
// Tell the histogram directive to render.
// Tell the histogram directive to render.
$scope
.
$emit
(
'render'
);
$scope
.
$emit
(
'render'
,
data
);
// If we still have segments left, get them
// If we still have segments left, get them
if
(
segment
<
dashboard
.
indices
.
length
-
1
)
{
if
(
segment
<
dashboard
.
indices
.
length
-
1
)
{
$scope
.
get_data
(
segment
+
1
,
query_id
);
$scope
.
get_data
(
data
,
segment
+
1
,
query_id
);
}
}
}
}
});
});
...
@@ -527,15 +523,20 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -527,15 +523,20 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
restrict
:
'A'
,
restrict
:
'A'
,
template
:
'<div></div>'
,
template
:
'<div></div>'
,
link
:
function
(
scope
,
elem
)
{
link
:
function
(
scope
,
elem
)
{
var
data
;
scope
.
$on
(
'refresh'
,
function
(){
scope
.
get_data
();
});
// Receive render events
// Receive render events
scope
.
$on
(
'render'
,
function
(){
scope
.
$on
(
'render'
,
function
(
event
,
data
){
render_panel
();
render_panel
(
data
);
});
});
// Re-render if the window is resized
// Re-render if the window is resized
angular
.
element
(
window
).
bind
(
'resize'
,
function
(){
angular
.
element
(
window
).
bind
(
'resize'
,
function
(){
render_panel
();
render_panel
(
data
);
});
});
var
scale
=
function
(
series
,
factor
)
{
var
scale
=
function
(
series
,
factor
)
{
...
@@ -563,13 +564,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -563,13 +564,13 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
};
};
// Function for rendering panel
// Function for rendering panel
function
render_panel
()
{
function
render_panel
(
data
)
{
// IE doesn't work without this
// IE doesn't work without this
elem
.
css
({
height
:
scope
.
panel
.
height
||
scope
.
row
.
height
});
elem
.
css
({
height
:
scope
.
panel
.
height
||
scope
.
row
.
height
});
// Populate from the query service
// Populate from the query service
try
{
try
{
_
.
each
(
scope
.
data
,
function
(
series
)
{
_
.
each
(
data
,
function
(
series
)
{
series
.
label
=
series
.
info
.
alias
;
series
.
label
=
series
.
info
.
alias
;
series
.
color
=
series
.
info
.
color
;
series
.
color
=
series
.
info
.
color
;
});
});
...
@@ -668,8 +669,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -668,8 +669,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
// when rendering stacked bars, we need to ensure each point that has data is zero-filled
// when rendering stacked bars, we need to ensure each point that has data is zero-filled
// so that the stacking happens in the proper order
// so that the stacking happens in the proper order
var
required_times
=
[];
var
required_times
=
[];
if
(
scope
.
data
.
length
>
1
)
{
if
(
data
.
length
>
1
)
{
required_times
=
Array
.
prototype
.
concat
.
apply
([],
_
.
map
(
scope
.
data
,
function
(
query
)
{
required_times
=
Array
.
prototype
.
concat
.
apply
([],
_
.
map
(
data
,
function
(
query
)
{
return
query
.
time_series
.
getOrderedTimes
();
return
query
.
time_series
.
getOrderedTimes
();
}));
}));
required_times
=
_
.
uniq
(
required_times
.
sort
(
function
(
a
,
b
)
{
required_times
=
_
.
uniq
(
required_times
.
sort
(
function
(
a
,
b
)
{
...
@@ -679,8 +680,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -679,8 +680,8 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
}
}
for
(
var
i
=
0
;
i
<
scope
.
data
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
var
_d
=
scope
.
data
[
i
].
time_series
.
getFlotPairs
(
required_times
);
var
_d
=
data
[
i
].
time_series
.
getFlotPairs
(
required_times
);
if
(
scope
.
panel
.
derivative
)
{
if
(
scope
.
panel
.
derivative
)
{
_d
=
derivative
(
_d
);
_d
=
derivative
(
_d
);
}
}
...
@@ -690,10 +691,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
...
@@ -690,10 +691,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
if
(
scope
.
panel
.
scaleSeconds
)
{
if
(
scope
.
panel
.
scaleSeconds
)
{
_d
=
scaleSeconds
(
_d
,
scope
.
panel
.
interval
);
_d
=
scaleSeconds
(
_d
,
scope
.
panel
.
interval
);
}
}
scope
.
data
[
i
].
data
=
_d
;
data
[
i
].
data
=
_d
;
}
}
scope
.
plot
=
$
.
plot
(
elem
,
scope
.
data
,
options
);
scope
.
plot
=
$
.
plot
(
elem
,
data
,
options
);
}
catch
(
e
)
{
}
catch
(
e
)
{
// Nothing to do here
// Nothing to do here
...
...
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