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
707d1884
Commit
707d1884
authored
Mar 15, 2019
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bar gauge styling tweaks
parent
09eddd16
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
12 deletions
+45
-12
packages/grafana-ui/src/components/BarGauge/BarGauge.tsx
+45
-12
No files found.
packages/grafana-ui/src/components/BarGauge/BarGauge.tsx
View file @
707d1884
...
...
@@ -149,7 +149,7 @@ export class BarGauge extends PureComponent<Props> {
);
}
getCellColor
(
positionValue
:
TimeSeriesValue
):
string
{
getCellColor
(
positionValue
:
TimeSeriesValue
):
CellColors
{
const
{
thresholds
,
theme
,
value
}
=
this
.
props
;
const
activeThreshold
=
getThresholdForValue
(
thresholds
,
positionValue
);
...
...
@@ -158,17 +158,33 @@ export class BarGauge extends PureComponent<Props> {
// if we are past real value the cell is not "on"
if
(
value
===
null
||
(
positionValue
!==
null
&&
positionValue
>
value
))
{
return
tinycolor
(
color
)
return
{
background
:
tinycolor
(
color
)
.
setAlpha
(
0.15
)
.
toRgbString
();
.
toRgbString
(),
border
:
'transparent'
,
isLit
:
false
,
};
}
else
{
return
tinycolor
(
color
)
.
setAlpha
(
0.7
)
.
toRgbString
();
return
{
background
:
tinycolor
(
color
)
.
setAlpha
(
0.85
)
.
toRgbString
(),
backgroundShade
:
tinycolor
(
color
)
.
setAlpha
(
0.55
)
.
toRgbString
(),
border
:
tinycolor
(
color
)
.
setAlpha
(
0.9
)
.
toRgbString
(),
isLit
:
true
,
};
}
}
return
'gray'
;
return
{
background
:
'gray'
,
border
:
'gray'
,
};
}
renderLcdMode
(
valueFormatted
:
string
,
valuePercent
:
number
):
ReactNode
{
...
...
@@ -176,8 +192,8 @@ export class BarGauge extends PureComponent<Props> {
const
valueRange
=
maxValue
-
minValue
;
const
maxSize
=
this
.
size
*
BAR_SIZE_RATIO
;
const
cellSpacing
=
4
;
const
cellCount
=
30
;
const
cellSpacing
=
5
;
const
cellCount
=
25
;
const
cellSize
=
(
maxSize
-
cellSpacing
*
cellCount
)
/
cellCount
;
const
colors
=
this
.
getValueColors
();
const
valueStyles
=
this
.
getValueStyles
(
valueFormatted
,
colors
.
value
,
this
.
size
-
maxSize
);
...
...
@@ -191,9 +207,11 @@ export class BarGauge extends PureComponent<Props> {
if
(
orientation
===
VizOrientation
.
Horizontal
)
{
containerStyles
.
flexDirection
=
'row'
;
containerStyles
.
alignItems
=
'center'
;
valueStyles
.
marginLeft
=
'20px'
;
}
else
{
containerStyles
.
flexDirection
=
'column-reverse'
;
containerStyles
.
alignItems
=
'center'
;
valueStyles
.
marginBottom
=
'20px'
;
}
const
cells
:
JSX
.
Element
[]
=
[];
...
...
@@ -202,18 +220,26 @@ export class BarGauge extends PureComponent<Props> {
const
currentValue
=
(
valueRange
/
cellCount
)
*
i
;
const
cellColor
=
this
.
getCellColor
(
currentValue
);
const
cellStyles
:
CSSProperties
=
{
backgroundColor
:
cellColor
,
borderRadius
:
'2px'
,
};
if
(
cellColor
.
isLit
)
{
cellStyles
.
boxShadow
=
`0 0 4px
${
cellColor
.
border
}
`
;
// cellStyles.border = `1px solid ${cellColor.border}`;
// cellStyles.background = `${cellColor.backgroundShade}`;
cellStyles
.
backgroundImage
=
`radial-gradient(
${
cellColor
.
background
}
10%,
${
cellColor
.
backgroundShade
}
)`
;
}
else
{
cellStyles
.
backgroundColor
=
cellColor
.
background
;
}
if
(
orientation
===
VizOrientation
.
Horizontal
)
{
cellStyles
.
width
=
`
${
cellSize
}
px`
;
cellStyles
.
height
=
`
${
height
}
px`
;
cellStyles
.
marginRight
=
'4px'
;
cellStyles
.
marginRight
=
`
${
cellSpacing
}
px`
;
}
else
{
cellStyles
.
height
=
`
${
cellSize
}
px`
;
cellStyles
.
width
=
`
${
width
}
px`
;
cellStyles
.
marginTop
=
'4px'
;
cellStyles
.
marginTop
=
`
${
cellSpacing
}
px`
;
}
cells
.
push
(<
div
style=
{
cellStyles
}
/>);
...
...
@@ -235,3 +261,10 @@ interface BarColors {
bar
:
string
;
border
:
string
;
}
interface
CellColors
{
background
:
string
;
backgroundShade
?:
string
;
border
:
string
;
isLit
?:
boolean
;
}
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