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
bcf88f61
Unverified
Commit
bcf88f61
authored
Jan 14, 2019
by
Torkel Ödegaard
Committed by
GitHub
Jan 14, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14867 from grafana/value-format-fixes2
Updated singlestat to use new value format function signature
parents
b1f5a232
37c5ced0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
26 deletions
+32
-26
packages/grafana-ui/src/utils/valueFormats/categories.ts
+24
-24
public/app/plugins/panel/singlestat/module.ts
+8
-2
No files found.
packages/grafana-ui/src/utils/valueFormats/categories.ts
View file @
bcf88f61
...
...
@@ -22,7 +22,7 @@ import { binarySIPrefix, currency, decimalSIPrefix } from './symbolFormatters';
export
const
getCategories
=
():
ValueFormatCategory
[]
=>
[
{
name
:
'
none
'
,
name
:
'
Misc
'
,
formats
:
[
{
name
:
'none'
,
id
:
'none'
,
fn
:
toFixed
},
{
...
...
@@ -41,7 +41,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
a
cceleration'
,
name
:
'
A
cceleration'
,
formats
:
[
{
name
:
'Meters/sec²'
,
id
:
'accMS2'
,
fn
:
toFixedUnit
(
'm/sec²'
)
},
{
name
:
'Feet/sec²'
,
id
:
'accFS2'
,
fn
:
toFixedUnit
(
'f/sec²'
)
},
...
...
@@ -49,7 +49,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
a
ngle'
,
name
:
'
A
ngle'
,
formats
:
[
{
name
:
'Degrees (°)'
,
id
:
'degree'
,
fn
:
toFixedUnit
(
'°'
)
},
{
name
:
'Radians'
,
id
:
'radian'
,
fn
:
toFixedUnit
(
'rad'
)
},
...
...
@@ -57,7 +57,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
a
rea'
,
name
:
'
A
rea'
,
formats
:
[
{
name
:
'Square Meters (m²)'
,
id
:
'areaM2'
,
fn
:
toFixedUnit
(
'm²'
)
},
{
name
:
'Square Feet (ft²)'
,
id
:
'areaF2'
,
fn
:
toFixedUnit
(
'ft²'
)
},
...
...
@@ -65,7 +65,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
computation throughput
'
,
name
:
'
Computation
'
,
formats
:
[
{
name
:
'FLOP/s'
,
id
:
'flops'
,
fn
:
decimalSIPrefix
(
'FLOP/s'
)
},
{
name
:
'MFLOP/s'
,
id
:
'mflops'
,
fn
:
decimalSIPrefix
(
'FLOP/s'
,
2
)
},
...
...
@@ -76,7 +76,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
c
oncentration'
,
name
:
'
C
oncentration'
,
formats
:
[
{
name
:
'parts-per-million (ppm)'
,
id
:
'ppm'
,
fn
:
toFixedUnit
(
'ppm'
)
},
{
name
:
'parts-per-billion (ppb)'
,
id
:
'conppb'
,
fn
:
toFixedUnit
(
'ppb'
)
},
...
...
@@ -93,7 +93,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
c
urrency'
,
name
:
'
C
urrency'
,
formats
:
[
{
name
:
'Dollars ($)'
,
id
:
'currencyUSD'
,
fn
:
currency
(
'$'
)
},
{
name
:
'Pounds (£)'
,
id
:
'currencyGBP'
,
fn
:
currency
(
'£'
)
},
...
...
@@ -113,7 +113,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
d
ata (IEC)'
,
name
:
'
D
ata (IEC)'
,
formats
:
[
{
name
:
'bits'
,
id
:
'bits'
,
fn
:
binarySIPrefix
(
'b'
)
},
{
name
:
'bytes'
,
id
:
'bytes'
,
fn
:
binarySIPrefix
(
'B'
)
},
...
...
@@ -123,7 +123,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
d
ata (Metric)'
,
name
:
'
D
ata (Metric)'
,
formats
:
[
{
name
:
'bits'
,
id
:
'decbits'
,
fn
:
decimalSIPrefix
(
'd'
)
},
{
name
:
'bytes'
,
id
:
'decbytes'
,
fn
:
decimalSIPrefix
(
'B'
)
},
...
...
@@ -133,7 +133,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
data r
ate'
,
name
:
'
Data R
ate'
,
formats
:
[
{
name
:
'packets/sec'
,
id
:
'pps'
,
fn
:
decimalSIPrefix
(
'pps'
)
},
{
name
:
'bits/sec'
,
id
:
'bps'
,
fn
:
decimalSIPrefix
(
'bps'
)
},
...
...
@@ -147,7 +147,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
date & t
ime'
,
name
:
'
Date & T
ime'
,
formats
:
[
{
name
:
'YYYY-MM-DD HH:mm:ss'
,
id
:
'dateTimeAsIso'
,
fn
:
dateTimeAsIso
},
{
name
:
'DD/MM/YYYY h:mm:ss a'
,
id
:
'dateTimeAsUS'
,
fn
:
dateTimeAsUS
},
...
...
@@ -155,7 +155,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
e
nergy'
,
name
:
'
E
nergy'
,
formats
:
[
{
name
:
'Watt (W)'
,
id
:
'watt'
,
fn
:
decimalSIPrefix
(
'W'
)
},
{
name
:
'Kilowatt (kW)'
,
id
:
'kwatt'
,
fn
:
decimalSIPrefix
(
'W'
,
1
)
},
...
...
@@ -182,7 +182,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
f
low'
,
name
:
'
F
low'
,
formats
:
[
{
name
:
'Gallons/min (gpm)'
,
id
:
'flowgpm'
,
fn
:
toFixedUnit
(
'gpm'
)
},
{
name
:
'Cubic meters/sec (cms)'
,
id
:
'flowcms'
,
fn
:
toFixedUnit
(
'cms'
)
},
...
...
@@ -194,7 +194,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
f
orce'
,
name
:
'
F
orce'
,
formats
:
[
{
name
:
'Newton-meters (Nm)'
,
id
:
'forceNm'
,
fn
:
decimalSIPrefix
(
'Nm'
)
},
{
name
:
'Kilonewton-meters (kNm)'
,
id
:
'forcekNm'
,
fn
:
decimalSIPrefix
(
'Nm'
,
1
)
},
...
...
@@ -203,7 +203,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
hash r
ate'
,
name
:
'
Hash R
ate'
,
formats
:
[
{
name
:
'hashes/sec'
,
id
:
'Hs'
,
fn
:
decimalSIPrefix
(
'H/s'
)
},
{
name
:
'kilohashes/sec'
,
id
:
'KHs'
,
fn
:
decimalSIPrefix
(
'H/s'
,
1
)
},
...
...
@@ -215,7 +215,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
m
ass'
,
name
:
'
M
ass'
,
formats
:
[
{
name
:
'milligram (mg)'
,
id
:
'massmg'
,
fn
:
decimalSIPrefix
(
'g'
,
-
1
)
},
{
name
:
'gram (g)'
,
id
:
'massg'
,
fn
:
decimalSIPrefix
(
'g'
)
},
...
...
@@ -234,7 +234,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
p
ressure'
,
name
:
'
P
ressure'
,
formats
:
[
{
name
:
'Millibars'
,
id
:
'pressurembar'
,
fn
:
decimalSIPrefix
(
'bar'
,
-
1
)
},
{
name
:
'Bars'
,
id
:
'pressurebar'
,
fn
:
decimalSIPrefix
(
'bar'
)
},
...
...
@@ -246,7 +246,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
r
adiation'
,
name
:
'
R
adiation'
,
formats
:
[
{
name
:
'Becquerel (Bq)'
,
id
:
'radbq'
,
fn
:
decimalSIPrefix
(
'Bq'
)
},
{
name
:
'curie (Ci)'
,
id
:
'radci'
,
fn
:
decimalSIPrefix
(
'Ci'
)
},
...
...
@@ -260,7 +260,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
t
emperature'
,
name
:
'
T
emperature'
,
formats
:
[
{
name
:
'Celsius (°C)'
,
id
:
'celsius'
,
fn
:
toFixedUnit
(
'°C'
)
},
{
name
:
'Farenheit (°F)'
,
id
:
'farenheit'
,
fn
:
toFixedUnit
(
'°F'
)
},
...
...
@@ -268,7 +268,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
t
ime'
,
name
:
'
T
ime'
,
formats
:
[
{
name
:
'Hertz (1/s)'
,
id
:
'hertz'
,
fn
:
decimalSIPrefix
(
'Hz'
)
},
{
name
:
'nanoseconds (ns)'
,
id
:
'ns'
,
fn
:
toNanoSeconds
},
...
...
@@ -287,7 +287,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
t
hroughput'
,
name
:
'
T
hroughput'
,
formats
:
[
{
name
:
'ops/sec (ops)'
,
id
:
'ops'
,
fn
:
simpleCountUnit
(
'ops'
)
},
{
name
:
'requests/sec (rps)'
,
id
:
'reqps'
,
fn
:
simpleCountUnit
(
'reqps'
)
},
...
...
@@ -300,7 +300,7 @@ export const getCategories = (): ValueFormatCategory[] => [
],
},
{
name
:
'
v
elocity'
,
name
:
'
V
elocity'
,
formats
:
[
{
name
:
'metres/second (m/s)'
,
id
:
'velocityms'
,
fn
:
toFixedUnit
(
'm/s'
)
},
{
name
:
'kilometers/hour (km/h)'
,
id
:
'velocitykmh'
,
fn
:
toFixedUnit
(
'km/h'
)
},
...
...
@@ -309,7 +309,7 @@ export const getCategories = (): ValueFormatCategory[] => [
]
},
{
name
:
'
v
olume'
,
name
:
'
V
olume'
,
formats
:
[
{
name
:
'millilitre (mL)'
,
id
:
'mlitre'
,
fn
:
decimalSIPrefix
(
'L'
,
-
1
)
},
{
name
:
'litre (L)'
,
id
:
'litre'
,
fn
:
decimalSIPrefix
(
'L'
)
},
...
...
@@ -318,5 +318,5 @@ export const getCategories = (): ValueFormatCategory[] => [
{
name
:
'cubic decimetre'
,
id
:
'dm3'
,
fn
:
toFixedUnit
(
'dm³'
)
},
{
name
:
'gallons'
,
id
:
'gallons'
,
fn
:
toFixedUnit
(
'gal'
)
},
],
}
,
}
];
public/app/plugins/panel/singlestat/module.ts
View file @
bcf88f61
...
...
@@ -312,14 +312,20 @@ class SingleStatCtrl extends MetricsPanelCtrl {
const
formatFunc
=
kbn
.
valueFormats
[
this
.
panel
.
format
];
data
.
value
=
lastPoint
[
1
];
data
.
valueRounded
=
data
.
value
;
data
.
valueFormatted
=
formatFunc
(
data
.
value
,
this
.
dashboard
.
isTimezoneUtc
());
data
.
valueFormatted
=
formatFunc
(
data
.
value
,
0
,
0
,
this
.
dashboard
.
isTimezoneUtc
());
}
else
{
data
.
value
=
this
.
series
[
0
].
stats
[
this
.
panel
.
valueName
];
data
.
flotpairs
=
this
.
series
[
0
].
flotpairs
;
const
decimalInfo
=
this
.
getDecimalsForValue
(
data
.
value
);
const
formatFunc
=
kbn
.
valueFormats
[
this
.
panel
.
format
];
data
.
valueFormatted
=
formatFunc
(
data
.
value
,
decimalInfo
.
decimals
,
decimalInfo
.
scaledDecimals
);
data
.
valueFormatted
=
formatFunc
(
data
.
value
,
decimalInfo
.
decimals
,
decimalInfo
.
scaledDecimals
,
this
.
dashboard
.
isTimezoneUtc
()
);
data
.
valueRounded
=
kbn
.
roundValue
(
data
.
value
,
decimalInfo
.
decimals
);
}
...
...
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