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
493fdbc1
Commit
493fdbc1
authored
Aug 28, 2013
by
spenceralger
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #438 from spenceralger/zero-filled-ts
Zero filled ts
parents
dfd5f1ba
eb0ee1cd
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
12 deletions
+24
-12
panels/histogram/module.js
+24
-12
No files found.
panels/histogram/module.js
View file @
493fdbc1
...
@@ -391,7 +391,7 @@ angular.module('kibana.histogram', [])
...
@@ -391,7 +391,7 @@ angular.module('kibana.histogram', [])
// 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
.
panel
.
bars
&&
stack
)
{
if
(
scope
.
data
.
length
>
1
)
{
required_times
=
_
.
uniq
(
Array
.
prototype
.
concat
.
apply
([],
_
.
map
(
scope
.
data
,
function
(
query
)
{
required_times
=
_
.
uniq
(
Array
.
prototype
.
concat
.
apply
([],
_
.
map
(
scope
.
data
,
function
(
query
)
{
return
query
.
time_series
.
getOrderedTimes
();
return
query
.
time_series
.
getOrderedTimes
();
})).
sort
(),
true
);
})).
sort
(),
true
);
...
@@ -457,6 +457,10 @@ angular.module('kibana.histogram', [])
...
@@ -457,6 +457,10 @@ angular.module('kibana.histogram', [])
return
parseInt
(
val
,
10
);
return
parseInt
(
val
,
10
);
}
}
function
getDatesTime
(
date
)
{
return
Math
.
floor
(
date
.
getTime
()
/
1000
)
*
1000
;
}
/**
/**
* Certain graphs require 0 entries to be specified for them to render
* Certain graphs require 0 entries to be specified for them to render
* properly (like the line graph). So with this we will caluclate all of
* properly (like the line graph). So with this we will caluclate all of
...
@@ -474,7 +478,7 @@ angular.module('kibana.histogram', [])
...
@@ -474,7 +478,7 @@ angular.module('kibana.histogram', [])
* the series.
* the series.
*/
*/
this
.
ZeroFilled
=
function
(
opts
)
{
this
.
ZeroFilled
=
function
(
opts
)
{
this
.
opts
=
_
.
defaults
(
opts
,
{
opts
=
_
.
defaults
(
opts
,
{
interval
:
'10m'
,
interval
:
'10m'
,
start_date
:
null
,
start_date
:
null
,
end_date
:
null
,
end_date
:
null
,
...
@@ -486,13 +490,9 @@ angular.module('kibana.histogram', [])
...
@@ -486,13 +490,9 @@ angular.module('kibana.histogram', [])
// will keep all values here, keyed by their time
// will keep all values here, keyed by their time
this
.
_data
=
{};
this
.
_data
=
{};
this
.
start_time
=
opts
.
start_date
&&
getDatesTime
(
opts
.
start_date
);
if
(
opts
.
start_date
)
{
this
.
end_time
=
opts
.
end_date
&&
getDatesTime
(
opts
.
end_date
);
this
.
addValue
(
opts
.
start_date
,
null
);
this
.
opts
=
opts
;
}
if
(
opts
.
end_date
)
{
this
.
addValue
(
opts
.
end_date
,
null
);
}
};
};
/**
/**
...
@@ -502,7 +502,7 @@ angular.module('kibana.histogram', [])
...
@@ -502,7 +502,7 @@ angular.module('kibana.histogram', [])
*/
*/
this
.
ZeroFilled
.
prototype
.
addValue
=
function
(
time
,
value
)
{
this
.
ZeroFilled
.
prototype
.
addValue
=
function
(
time
,
value
)
{
if
(
time
instanceof
Date
)
{
if
(
time
instanceof
Date
)
{
time
=
Math
.
floor
(
time
.
getTime
()
/
1000
)
*
1000
;
time
=
getDatesTime
(
time
)
;
}
else
{
}
else
{
time
=
base10Int
(
time
);
time
=
base10Int
(
time
);
}
}
...
@@ -536,7 +536,8 @@ angular.module('kibana.histogram', [])
...
@@ -536,7 +536,8 @@ angular.module('kibana.histogram', [])
this
.
ZeroFilled
.
prototype
.
getFlotPairs
=
function
(
required_times
)
{
this
.
ZeroFilled
.
prototype
.
getFlotPairs
=
function
(
required_times
)
{
var
times
=
this
.
getOrderedTimes
(
required_times
),
var
times
=
this
.
getOrderedTimes
(
required_times
),
strategy
,
strategy
,
pairs
;
pairs
,
pairs_empty
;
if
(
this
.
opts
.
fill_style
===
'all'
)
{
if
(
this
.
opts
.
fill_style
===
'all'
)
{
strategy
=
this
.
_getAllFlotPairs
;
strategy
=
this
.
_getAllFlotPairs
;
...
@@ -544,12 +545,23 @@ angular.module('kibana.histogram', [])
...
@@ -544,12 +545,23 @@ angular.module('kibana.histogram', [])
strategy
=
this
.
_getMinFlotPairs
;
strategy
=
this
.
_getMinFlotPairs
;
}
}
return
_
.
reduce
(
pairs
=
_
.
reduce
(
times
,
// what
times
,
// what
strategy
,
// how
strategy
,
// how
[],
// where
[],
// where
this
// context
this
// context
);
);
// if the start and end of the pairs are inside either the start or end time,
// add those times to the series with null values so the graph will stretch to contain them.
if
(
this
.
start_time
&&
(
pairs
.
length
===
0
||
pairs
[
0
][
0
]
>
this
.
start_time
))
{
pairs
.
unshift
([
this
.
start_time
,
null
]);
}
if
(
this
.
end_time
&&
(
pairs
.
length
===
0
||
pairs
[
pairs
.
length
-
1
][
0
]
<
this
.
end_time
))
{
pairs
.
push
([
this
.
end_time
,
null
]);
}
return
pairs
;
};
};
/**
/**
...
...
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