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
af4f3f62
Commit
af4f3f62
authored
Sep 29, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merged yaxis_precision branch, #877, updated changelog
parents
eaa899e9
cc31a12b
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
48 additions
and
75 deletions
+48
-75
CHANGELOG.md
+1
-0
src/app/components/kbn.js
+0
-0
src/app/components/timeSeries.js
+9
-9
src/app/directives/grafanaGraph.js
+17
-2
src/test/specs/kbn-format-specs.js
+19
-64
src/vendor/jquery/jquery.flot.js
+2
-0
No files found.
CHANGELOG.md
View file @
af4f3f62
# 1.9.0 (unreleased)
-
[
Issue #877
](
https://github.com/grafana/grafana/issues/877
)
. Graph: Smart auto decimal precision when using scaled unit formats
# 1.8.1 (unreleased)
...
...
src/app/components/kbn.js
View file @
af4f3f62
This diff is collapsed.
Click to expand it.
src/app/components/timeSeries.js
View file @
af4f3f62
...
...
@@ -54,7 +54,7 @@ function (_, kbn) {
}
};
TimeSeries
.
prototype
.
getFlotPairs
=
function
(
fillStyle
,
yFormats
)
{
TimeSeries
.
prototype
.
getFlotPairs
=
function
(
fillStyle
)
{
var
result
=
[];
this
.
color
=
this
.
info
.
color
;
...
...
@@ -100,21 +100,21 @@ function (_, kbn) {
}
if
(
result
.
length
)
{
this
.
info
.
avg
=
(
this
.
info
.
total
/
result
.
length
);
this
.
info
.
current
=
result
[
result
.
length
-
1
][
1
];
var
formater
=
kbn
.
getFormatFunction
(
yFormats
[
this
.
yaxis
-
1
],
2
);
this
.
info
.
avg
=
this
.
info
.
avg
!=
null
?
formater
(
this
.
info
.
avg
)
:
null
;
this
.
info
.
current
=
this
.
info
.
current
!=
null
?
formater
(
this
.
info
.
current
)
:
null
;
this
.
info
.
min
=
this
.
info
.
min
!=
null
?
formater
(
this
.
info
.
min
)
:
null
;
this
.
info
.
max
=
this
.
info
.
max
!=
null
?
formater
(
this
.
info
.
max
)
:
null
;
this
.
info
.
total
=
this
.
info
.
total
!=
null
?
formater
(
this
.
info
.
total
)
:
null
;
}
return
result
;
};
TimeSeries
.
prototype
.
updateLegendValues
=
function
(
formater
,
decimals
,
scaledDecimals
)
{
this
.
info
.
avg
=
this
.
info
.
avg
!=
null
?
formater
(
this
.
info
.
avg
,
decimals
,
scaledDecimals
)
:
null
;
this
.
info
.
current
=
this
.
info
.
current
!=
null
?
formater
(
this
.
info
.
current
,
decimals
,
scaledDecimals
)
:
null
;
this
.
info
.
min
=
this
.
info
.
min
!=
null
?
formater
(
this
.
info
.
min
,
decimals
,
scaledDecimals
)
:
null
;
this
.
info
.
max
=
this
.
info
.
max
!=
null
?
formater
(
this
.
info
.
max
,
decimals
,
scaledDecimals
)
:
null
;
this
.
info
.
total
=
this
.
info
.
total
!=
null
?
formater
(
this
.
info
.
total
,
decimals
,
scaledDecimals
)
:
null
;
};
return
TimeSeries
;
});
src/app/directives/grafanaGraph.js
View file @
af4f3f62
...
...
@@ -80,6 +80,18 @@ function (angular, $, kbn, moment, _) {
}
}
function
updateLegendValues
(
plot
)
{
var
yaxis
=
plot
.
getYAxes
();
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
var
series
=
data
[
i
];
var
axis
=
yaxis
[
series
.
yaxis
-
1
];
var
formater
=
kbn
.
valueFormats
[
scope
.
panel
.
y_formats
[
series
.
yaxis
-
1
]];
series
.
updateLegendValues
(
formater
,
axis
.
tickDecimals
,
axis
.
scaledDecimals
);
}
}
// Function for rendering panel
function
render_panel
()
{
if
(
shouldAbortRender
())
{
...
...
@@ -91,6 +103,7 @@ function (angular, $, kbn, moment, _) {
// Populate element
var
options
=
{
hooks
:
{
draw
:
[
updateLegendValues
]
},
legend
:
{
show
:
false
},
series
:
{
stackpercent
:
panel
.
stack
?
panel
.
percentage
:
false
,
...
...
@@ -299,7 +312,9 @@ function (angular, $, kbn, moment, _) {
}
function
configureAxisMode
(
axis
,
format
)
{
axis
.
tickFormatter
=
kbn
.
getFormatFunction
(
format
,
1
);
axis
.
tickFormatter
=
function
(
val
,
axis
)
{
return
kbn
.
valueFormats
[
format
](
val
,
axis
.
tickDecimals
,
axis
.
scaledDecimals
);
};
}
function
time_format
(
interval
,
ticks
,
min
,
max
)
{
...
...
@@ -349,7 +364,7 @@ function (angular, $, kbn, moment, _) {
value
=
item
.
datapoint
[
1
];
}
value
=
kbn
.
getFormatFunction
(
format
,
2
)(
value
,
item
.
series
.
yaxi
s
);
value
=
kbn
.
valueFormats
[
format
](
value
,
item
.
series
.
yaxis
.
tickDecimal
s
);
timestamp
=
dashboard
.
formatDate
(
item
.
datapoint
[
0
]);
$tooltip
.
html
(
group
+
value
+
" @ "
+
timestamp
).
place_tt
(
pos
.
pageX
,
pos
.
pageY
);
...
...
src/test/specs/kbn-format-specs.js
View file @
af4f3f62
...
...
@@ -3,76 +3,31 @@ define([
],
function
(
kbn
)
{
'use strict'
;
describe
(
'millisecond formating'
,
function
(
)
{
function
describeValueFormat
(
desc
,
value
,
tickSize
,
tickDecimals
,
result
)
{
it
(
'should translate 4378634603 as 1.67 years'
,
function
()
{
var
str
=
kbn
.
msFormat
(
4378634603
,
2
);
expect
(
str
).
to
.
be
(
'50.68 day'
);
describe
(
'value format: '
+
desc
,
function
()
{
it
(
'should translate '
+
value
+
' as '
+
result
,
function
()
{
var
scaledDecimals
=
tickDecimals
-
Math
.
floor
(
Math
.
log
(
tickSize
)
/
Math
.
LN10
);
var
str
=
kbn
.
valueFormats
[
desc
](
value
,
tickDecimals
,
scaledDecimals
);
expect
(
str
).
to
.
be
(
result
);
});
});
it
(
'should translate 3654454 as 1.02 hour'
,
function
()
{
var
str
=
kbn
.
msFormat
(
3654454
,
2
);
expect
(
str
).
to
.
be
(
'1.02 hour'
);
});
it
(
'should not downscale when value is zero'
,
function
()
{
var
str
=
kbn
.
msFormat
(
0
,
2
);
expect
(
str
).
to
.
be
(
'0.00 ms'
);
});
it
(
'should translate 365445 as 6.09 min'
,
function
()
{
var
str
=
kbn
.
msFormat
(
365445
,
2
);
expect
(
str
).
to
.
be
(
'6.09 min'
);
});
});
describe
(
'high negative exponent, issue #696'
,
function
()
{
it
(
'should ignore decimal correction if exponent'
,
function
()
{
var
str
=
kbn
.
getFormatFunction
(
''
)(
2.75
e
-
10
,
{
tickDecimals
:
12
});
expect
(
str
).
to
.
be
(
'2.75e-10'
);
});
it
(
'should format 0 correctly'
,
function
()
{
var
str
=
kbn
.
getFormatFunction
(
''
)(
0.0
,
{
tickDecimals
:
12
});
expect
(
str
).
to
.
be
(
'0'
);
});
});
}
describe
(
'none format tests'
,
function
()
{
it
(
'should translate 2 as 2.0000 if axis decimals is 4'
,
function
()
{
var
str
=
kbn
.
getFormatFunction
(
''
)(
2
,
{
tickDecimals
:
4
});
expect
(
str
).
to
.
be
(
'2.0000'
);
});
});
describe
(
'nanosecond formatting'
,
function
()
{
it
(
'should translate 25 to 25 ns'
,
function
()
{
var
str
=
kbn
.
nanosFormat
(
25
,
2
);
expect
(
str
).
to
.
be
(
"25 ns"
);
});
it
(
'should translate 2558 to 2.56 µs'
,
function
()
{
var
str
=
kbn
.
nanosFormat
(
2558
,
2
);
expect
(
str
).
to
.
be
(
"2.56 µs"
);
});
describeValueFormat
(
'ms'
,
0.0024
,
0.0005
,
4
,
'0.0024 ms'
);
describeValueFormat
(
'ms'
,
100
,
1
,
0
,
'100 ms'
);
describeValueFormat
(
'ms'
,
1250
,
10
,
0
,
'1.25 s'
);
describeValueFormat
(
'ms'
,
1250
,
300
,
0
,
'1.3 s'
);
describeValueFormat
(
'ms'
,
65150
,
10000
,
0
,
'1.1 min'
);
describeValueFormat
(
'ms'
,
6515000
,
1500000
,
0
,
'1.8 hour'
);
describeValueFormat
(
'ms'
,
651500000
,
150000000
,
0
,
'8 day'
);
it
(
'should translate 2558000 to 2.56 ms'
,
function
()
{
var
str
=
kbn
.
nanosFormat
(
2558000
,
2
);
expect
(
str
).
to
.
be
(
"2.56 ms"
);
});
it
(
'should translate 2019962000 to 2.02 s'
,
function
()
{
var
str
=
kbn
.
nanosFormat
(
2049962000
,
2
);
expect
(
str
).
to
.
be
(
"2.05 s"
);
});
describeValueFormat
(
'none'
,
2.75
e
-
10
,
0
,
10
,
'3e-10'
);
describeValueFormat
(
'none'
,
0
,
0
,
2
,
'0'
);
it
(
'should translate 95199620000 to 1.59 m'
,
function
()
{
var
str
=
kbn
.
nanosFormat
(
95199620000
,
2
);
expect
(
str
).
to
.
be
(
"1.59 m"
);
});
});
describeValueFormat
(
'ns'
,
25
,
1
,
0
,
'25 ns'
);
describeValueFormat
(
'ns'
,
2558
,
50
,
0
,
'2.56 µs'
);
describe
(
'calculateInterval'
,
function
()
{
it
(
'1h 100 resultion'
,
function
()
{
...
...
src/vendor/jquery/jquery.flot.js
View file @
af4f3f62
...
...
@@ -1728,6 +1728,8 @@ Licensed under the MIT license.
axis
.
delta
=
delta
;
axis
.
tickDecimals
=
Math
.
max
(
0
,
maxDec
!=
null
?
maxDec
:
dec
);
axis
.
tickSize
=
opts
.
tickSize
||
size
;
// grafana addition
axis
.
scaledDecimals
=
axis
.
tickDecimals
-
Math
.
floor
(
Math
.
log
(
axis
.
tickSize
)
/
Math
.
LN10
);
// Time mode was moved to a plug-in in 0.8, and since so many people use it
// we'll add an especially friendly reminder to make sure they included it.
...
...
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