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
8262a8de
Commit
8262a8de
authored
Jun 30, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #545 from Akeru/fix-format
Fix formatting negative values
parents
406286b9
6346f835
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
32 deletions
+32
-32
src/app/components/kbn.js
+32
-32
No files found.
src/app/components/kbn.js
View file @
8262a8de
...
@@ -26,52 +26,52 @@ function($, _, moment) {
...
@@ -26,52 +26,52 @@ function($, _, moment) {
kbn
.
round_interval
=
function
(
interval
)
{
kbn
.
round_interval
=
function
(
interval
)
{
switch
(
true
)
{
switch
(
true
)
{
// 0.5s
// 0.5s
case
(
interval
<=
500
):
case
(
Math
.
abs
(
interval
)
<=
500
):
return
100
;
// 0.1s
return
100
;
// 0.1s
// 5s
// 5s
case
(
interval
<=
5000
):
case
(
Math
.
abs
(
interval
)
<=
5000
):
return
1000
;
// 1s
return
1000
;
// 1s
// 7.5s
// 7.5s
case
(
interval
<=
7500
):
case
(
Math
.
abs
(
interval
)
<=
7500
):
return
5000
;
// 5s
return
5000
;
// 5s
// 15s
// 15s
case
(
interval
<=
15000
):
case
(
Math
.
abs
(
interval
)
<=
15000
):
return
10000
;
// 10s
return
10000
;
// 10s
// 45s
// 45s
case
(
interval
<=
45000
):
case
(
Math
.
abs
(
interval
)
<=
45000
):
return
30000
;
// 30s
return
30000
;
// 30s
// 3m
// 3m
case
(
interval
<=
180000
):
case
(
Math
.
abs
(
interval
)
<=
180000
):
return
60000
;
// 1m
return
60000
;
// 1m
// 9m
// 9m
case
(
interval
<=
450000
):
case
(
Math
.
abs
(
interval
)
<=
450000
):
return
300000
;
// 5m
return
300000
;
// 5m
// 20m
// 20m
case
(
interval
<=
1200000
):
case
(
Math
.
abs
(
interval
)
<=
1200000
):
return
600000
;
// 10m
return
600000
;
// 10m
// 45m
// 45m
case
(
interval
<=
2700000
):
case
(
Math
.
abs
(
interval
)
<=
2700000
):
return
1800000
;
// 30m
return
1800000
;
// 30m
// 2h
// 2h
case
(
interval
<=
7200000
):
case
(
Math
.
abs
(
interval
)
<=
7200000
):
return
3600000
;
// 1h
return
3600000
;
// 1h
// 6h
// 6h
case
(
interval
<=
21600000
):
case
(
Math
.
abs
(
interval
)
<=
21600000
):
return
10800000
;
// 3h
return
10800000
;
// 3h
// 24h
// 24h
case
(
interval
<=
86400000
):
case
(
Math
.
abs
(
interval
)
<=
86400000
):
return
43200000
;
// 12h
return
43200000
;
// 12h
// 48h
// 48h
case
(
interval
<=
172800000
):
case
(
Math
.
abs
(
interval
)
<=
172800000
):
return
86400000
;
// 24h
return
86400000
;
// 24h
// 1w
// 1w
case
(
interval
<=
604800000
):
case
(
Math
.
abs
(
interval
)
<=
604800000
):
return
86400000
;
// 24h
return
86400000
;
// 24h
// 3w
// 3w
case
(
interval
<=
1814400000
):
case
(
Math
.
abs
(
interval
)
<=
1814400000
):
return
604800000
;
// 1w
return
604800000
;
// 1w
// 2y
// 2y
case
(
interval
<
3628800000
):
case
(
Math
.
abs
(
interval
)
<
3628800000
):
return
2592000000
;
// 30d
return
2592000000
;
// 30d
default
:
default
:
return
31536000000
;
// 1y
return
31536000000
;
// 1y
...
@@ -481,23 +481,23 @@ function($, _, moment) {
...
@@ -481,23 +481,23 @@ function($, _, moment) {
};
};
kbn
.
msFormat
=
function
(
size
,
decimals
)
{
kbn
.
msFormat
=
function
(
size
,
decimals
)
{
if
(
size
<
1000
)
{
if
(
Math
.
abs
(
size
)
<
1000
)
{
return
size
.
toFixed
(
0
)
+
" ms"
;
return
size
.
toFixed
(
0
)
+
" ms"
;
}
}
// Less than 1 min
// Less than 1 min
else
if
(
size
<
60000
)
{
else
if
(
Math
.
abs
(
size
)
<
60000
)
{
return
(
size
/
1000
).
toFixed
(
decimals
)
+
" s"
;
return
(
size
/
1000
).
toFixed
(
decimals
)
+
" s"
;
}
}
// Less than 1 hour, devide in minutes
// Less than 1 hour, devide in minutes
else
if
(
size
<
3600000
)
{
else
if
(
Math
.
abs
(
size
)
<
3600000
)
{
return
(
size
/
60000
).
toFixed
(
decimals
)
+
" min"
;
return
(
size
/
60000
).
toFixed
(
decimals
)
+
" min"
;
}
}
// Less than one day, devide in hours
// Less than one day, devide in hours
else
if
(
size
<
86400000
)
{
else
if
(
Math
.
abs
(
size
)
<
86400000
)
{
return
(
size
/
3600000
).
toFixed
(
decimals
)
+
" hour"
;
return
(
size
/
3600000
).
toFixed
(
decimals
)
+
" hour"
;
}
}
// Less than one year, devide in days
// Less than one year, devide in days
else
if
(
size
<
31536000000
)
{
else
if
(
Math
.
abs
(
size
)
<
31536000000
)
{
return
(
size
/
86400000
).
toFixed
(
decimals
)
+
" day"
;
return
(
size
/
86400000
).
toFixed
(
decimals
)
+
" day"
;
}
}
...
@@ -506,23 +506,23 @@ function($, _, moment) {
...
@@ -506,23 +506,23 @@ function($, _, moment) {
kbn
.
sFormat
=
function
(
size
,
decimals
)
{
kbn
.
sFormat
=
function
(
size
,
decimals
)
{
// Less than 10 min, use seconds
// Less than 10 min, use seconds
if
(
size
<
600
)
{
if
(
Math
.
abs
(
size
)
<
600
)
{
return
size
.
toFixed
(
decimals
)
+
" s"
;
return
size
.
toFixed
(
decimals
)
+
" s"
;
}
}
// Less than 1 hour, devide in minutes
// Less than 1 hour, devide in minutes
else
if
(
size
<
3600
)
{
else
if
(
Math
.
abs
(
size
)
<
3600
)
{
return
(
size
/
60
).
toFixed
(
decimals
)
+
" min"
;
return
(
size
/
60
).
toFixed
(
decimals
)
+
" min"
;
}
}
// Less than one day, devide in hours
// Less than one day, devide in hours
else
if
(
size
<
86400
)
{
else
if
(
Math
.
abs
(
size
)
<
86400
)
{
return
(
size
/
3600
).
toFixed
(
decimals
)
+
" hour"
;
return
(
size
/
3600
).
toFixed
(
decimals
)
+
" hour"
;
}
}
// Less than one week, devide in days
// Less than one week, devide in days
else
if
(
size
<
604800
)
{
else
if
(
Math
.
abs
(
size
)
<
604800
)
{
return
(
size
/
86400
).
toFixed
(
decimals
)
+
" day"
;
return
(
size
/
86400
).
toFixed
(
decimals
)
+
" day"
;
}
}
// Less than one year, devide in week
// Less than one year, devide in week
else
if
(
size
<
31536000
)
{
else
if
(
Math
.
abs
(
size
)
<
31536000
)
{
return
(
size
/
604800
).
toFixed
(
decimals
)
+
" week"
;
return
(
size
/
604800
).
toFixed
(
decimals
)
+
" week"
;
}
}
...
@@ -530,10 +530,10 @@ function($, _, moment) {
...
@@ -530,10 +530,10 @@ function($, _, moment) {
};
};
kbn
.
microsFormat
=
function
(
size
,
decimals
)
{
kbn
.
microsFormat
=
function
(
size
,
decimals
)
{
if
(
size
<
1000
)
{
if
(
Math
.
abs
(
size
)
<
1000
)
{
return
size
.
toFixed
(
0
)
+
" µs"
;
return
size
.
toFixed
(
0
)
+
" µs"
;
}
}
else
if
(
size
<
1000000
)
{
else
if
(
Math
.
abs
(
size
)
<
1000000
)
{
return
(
size
/
1000
).
toFixed
(
decimals
)
+
" ms"
;
return
(
size
/
1000
).
toFixed
(
decimals
)
+
" ms"
;
}
}
else
{
else
{
...
@@ -542,16 +542,16 @@ function($, _, moment) {
...
@@ -542,16 +542,16 @@ function($, _, moment) {
};
};
kbn
.
nanosFormat
=
function
(
size
,
decimals
)
{
kbn
.
nanosFormat
=
function
(
size
,
decimals
)
{
if
(
size
<
1000
)
{
if
(
Math
.
abs
(
size
)
<
1000
)
{
return
size
.
toFixed
(
0
)
+
" ns"
;
return
size
.
toFixed
(
0
)
+
" ns"
;
}
}
else
if
(
size
<
1000000
)
{
else
if
(
Math
.
abs
(
size
)
<
1000000
)
{
return
(
size
/
1000
).
toFixed
(
decimals
)
+
" µs"
;
return
(
size
/
1000
).
toFixed
(
decimals
)
+
" µs"
;
}
}
else
if
(
size
<
1000000000
)
{
else
if
(
Math
.
abs
(
size
)
<
1000000000
)
{
return
(
size
/
1000000
).
toFixed
(
decimals
)
+
" ms"
;
return
(
size
/
1000000
).
toFixed
(
decimals
)
+
" ms"
;
}
}
else
if
(
size
<
60000000000
){
else
if
(
Math
.
abs
(
size
)
<
60000000000
){
return
(
size
/
1000000000
).
toFixed
(
decimals
)
+
" s"
;
return
(
size
/
1000000000
).
toFixed
(
decimals
)
+
" s"
;
}
}
else
{
else
{
...
...
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