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
882a9881
Commit
882a9881
authored
Oct 15, 2015
by
Greg Look
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add currency units from #1910.
parent
0b3e33e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
0 deletions
+27
-0
public/app/components/kbn.js
+23
-0
public/test/specs/kbn-format-specs.js
+4
-0
No files found.
public/app/components/kbn.js
View file @
882a9881
...
...
@@ -298,6 +298,18 @@ function($, _) {
return
kbn
.
formatBuilders
.
scaledUnits
(
1024
,
units
);
};
// Currency formatter for prefixing a symbol onto a number. Supports scaling
// up to the trillions.
kbn
.
formatBuilders
.
currency
=
function
(
symbol
)
{
var
units
=
[
''
,
'K'
,
'M'
,
'B'
,
'T'
];
var
scaler
=
kbn
.
formatBuilders
.
scaledUnits
(
1000
,
units
);
return
function
(
size
,
decimals
,
scaledDecimals
)
{
if
(
size
===
null
)
{
return
""
;
}
var
scaled
=
scaler
(
size
,
decimals
,
scaledDecimals
);
return
symbol
+
scaled
;
};
};
///// VALUE FORMATS /////
// Dimensionless Units
...
...
@@ -316,6 +328,10 @@ function($, _) {
return
kbn
.
toFixed
(
100
*
size
,
decimals
)
+
'%'
;
};
// Currencies
kbn
.
valueFormats
.
currencyUSD
=
kbn
.
formatBuilders
.
currency
(
'$'
);
kbn
.
valueFormats
.
currencyGBP
=
kbn
.
formatBuilders
.
currency
(
'£'
);
// Data
kbn
.
valueFormats
.
bits
=
kbn
.
formatBuilders
.
binarySIPrefix
(
'b'
);
kbn
.
valueFormats
.
bytes
=
kbn
.
formatBuilders
.
binarySIPrefix
(
'B'
);
...
...
@@ -472,6 +488,13 @@ function($, _) {
]
},
{
text
:
'currency'
,
submenu
:
[
{
text
:
'Dollars ($)'
,
value
:
'currencyUSD'
},
{
text
:
'Pounds (£)'
,
value
:
'currencyGBP'
},
]
},
{
text
:
'time'
,
submenu
:
[
{
text
:
'Hertz (1/s)'
,
value
:
'hertz'
},
...
...
public/test/specs/kbn-format-specs.js
View file @
882a9881
...
...
@@ -53,6 +53,10 @@ define([
describeValueFormat
(
'percentunit'
,
0.278
,
0
,
1
,
'27.8%'
);
describeValueFormat
(
'percentunit'
,
1.0
,
0
,
0
,
'100%'
);
describeValueFormat
(
'currencyUSD'
,
7.42
,
10000
,
2
,
'$7.42'
);
describeValueFormat
(
'currencyUSD'
,
1532.82
,
1000
,
1
,
'$1.53K'
);
describeValueFormat
(
'currencyUSD'
,
18520408.7
,
10000000
,
0
,
'$19M'
);
describeValueFormat
(
'bytes'
,
-
1.57
e
+
308
,
-
1.57
e
+
308
,
2
,
'NA'
);
describeValueFormat
(
'ns'
,
25
,
1
,
0
,
'25 ns'
);
...
...
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