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
554d0103
Commit
554d0103
authored
Jan 17, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preparing move to ui/viz
parent
9dcf3d58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
packages/grafana-ui/src/types/panel.ts
+7
-0
public/app/viz/Gauge.tsx
+14
-6
No files found.
packages/grafana-ui/src/types/panel.ts
View file @
554d0103
...
@@ -66,3 +66,10 @@ export interface RangeMap extends BaseMap {
...
@@ -66,3 +66,10 @@ export interface RangeMap extends BaseMap {
from
:
string
;
from
:
string
;
to
:
string
;
to
:
string
;
}
}
export
type
Theme
=
'dark'
|
'light'
;
export
enum
Themes
{
Dark
=
'dark'
,
Light
=
'light'
,
}
public/app/viz/Gauge.tsx
View file @
554d0103
import
React
,
{
PureComponent
}
from
'react'
;
import
React
,
{
PureComponent
}
from
'react'
;
import
$
from
'jquery'
;
import
$
from
'jquery'
;
import
{
BasicGaugeColor
,
Threshold
,
TimeSeriesVMs
,
MappingType
,
ValueMapping
}
from
'@grafana/ui'
;
import
{
BasicGaugeColor
,
import
config
from
'../core/config'
;
Threshold
,
import
kbn
from
'../core/utils/kbn'
;
TimeSeriesVMs
,
MappingType
,
ValueMapping
,
getValueFormat
,
Theme
,
Themes
,
}
from
'@grafana/ui'
;
export
interface
Props
{
export
interface
Props
{
decimals
:
number
;
decimals
:
number
;
...
@@ -20,6 +26,7 @@ export interface Props {
...
@@ -20,6 +26,7 @@ export interface Props {
suffix
:
string
;
suffix
:
string
;
unit
:
string
;
unit
:
string
;
width
:
number
;
width
:
number
;
theme
?:
Theme
;
}
}
export
class
Gauge
extends
PureComponent
<
Props
>
{
export
class
Gauge
extends
PureComponent
<
Props
>
{
...
@@ -68,7 +75,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -68,7 +75,7 @@ export class Gauge extends PureComponent<Props> {
formatValue
(
value
)
{
formatValue
(
value
)
{
const
{
decimals
,
valueMappings
,
prefix
,
suffix
,
unit
}
=
this
.
props
;
const
{
decimals
,
valueMappings
,
prefix
,
suffix
,
unit
}
=
this
.
props
;
const
formatFunc
=
kbn
.
valueFormats
[
unit
]
;
const
formatFunc
=
getValueFormat
(
unit
)
;
const
formattedValue
=
formatFunc
(
value
,
decimals
);
const
formattedValue
=
formatFunc
(
value
,
decimals
);
if
(
valueMappings
.
length
>
0
)
{
if
(
valueMappings
.
length
>
0
)
{
...
@@ -116,6 +123,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -116,6 +123,7 @@ export class Gauge extends PureComponent<Props> {
width
,
width
,
height
,
height
,
stat
,
stat
,
theme
,
}
=
this
.
props
;
}
=
this
.
props
;
let
value
:
string
|
number
=
''
;
let
value
:
string
|
number
=
''
;
...
@@ -127,7 +135,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -127,7 +135,7 @@ export class Gauge extends PureComponent<Props> {
}
}
const
dimension
=
Math
.
min
(
width
,
height
*
1.3
);
const
dimension
=
Math
.
min
(
width
,
height
*
1.3
);
const
backgroundColor
=
config
.
bootData
.
user
.
lightTheme
?
'rgb(230,230,230)'
:
'rgb(38,38,38)'
;
const
backgroundColor
=
theme
===
Themes
.
Light
?
'rgb(230,230,230)'
:
'rgb(38,38,38)'
;
const
fontScale
=
parseInt
(
'80'
,
10
)
/
100
;
const
fontScale
=
parseInt
(
'80'
,
10
)
/
100
;
const
fontSize
=
Math
.
min
(
dimension
/
5
,
100
)
*
fontScale
;
const
fontSize
=
Math
.
min
(
dimension
/
5
,
100
)
*
fontScale
;
const
gaugeWidthReduceRatio
=
showThresholdLabels
?
1.5
:
1
;
const
gaugeWidthReduceRatio
=
showThresholdLabels
?
1.5
:
1
;
...
...
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