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
4892d3f5
Commit
4892d3f5
authored
Jan 03, 2019
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing issue with value color being wrong
parent
3e873a25
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
6 deletions
+63
-6
public/app/viz/Gauge.test.tsx
+55
-0
public/app/viz/Gauge.tsx
+8
-6
No files found.
public/app/viz/Gauge.test.tsx
0 → 100644
View file @
4892d3f5
import
React
from
'react'
;
import
{
shallow
}
from
'enzyme'
;
import
{
Gauge
,
Props
}
from
'./Gauge'
;
import
{
BasicGaugeColor
}
from
'../types'
;
import
{
TimeSeriesVMs
}
from
'@grafana/ui'
;
jest
.
mock
(
'jquery'
,
()
=>
({
plot
:
jest
.
fn
(),
}));
const
setup
=
(
propOverrides
?:
object
)
=>
{
const
props
:
Props
=
{
baseColor
:
BasicGaugeColor
.
Green
,
maxValue
:
100
,
mappings
:
[],
minValue
:
0
,
prefix
:
''
,
showThresholdMarkers
:
true
,
showThresholdLabels
:
false
,
suffix
:
''
,
thresholds
:
[],
unit
:
'none'
,
stat
:
'avg'
,
height
:
300
,
width
:
300
,
timeSeries
:
{}
as
TimeSeriesVMs
,
decimals
:
0
,
};
Object
.
assign
(
props
,
propOverrides
);
const
wrapper
=
shallow
(<
Gauge
{
...
props
}
/>);
const
instance
=
wrapper
.
instance
()
as
Gauge
;
return
{
instance
,
wrapper
,
};
};
describe
(
'Get font color'
,
()
=>
{
it
(
'should get base color if no threshold'
,
()
=>
{
const
{
instance
}
=
setup
();
expect
(
instance
.
getFontColor
(
40
)).
toEqual
(
BasicGaugeColor
.
Green
);
});
it
(
'should be f2f2f2'
,
()
=>
{
const
{
instance
}
=
setup
({
thresholds
:
[{
value
:
59
,
color
:
'#f2f2f2'
}],
});
expect
(
instance
.
getFontColor
(
58
)).
toEqual
(
'#f2f2f2'
);
});
});
public/app/viz/Gauge.tsx
View file @
4892d3f5
...
...
@@ -5,7 +5,7 @@ import { TimeSeriesVMs } from '@grafana/ui';
import
config
from
'../core/config'
;
import
kbn
from
'../core/utils/kbn'
;
interface
Props
{
export
interface
Props
{
baseColor
:
string
;
decimals
:
number
;
height
:
number
;
...
...
@@ -96,12 +96,14 @@ export class Gauge extends PureComponent<Props> {
getFontColor
(
value
)
{
const
{
baseColor
,
maxValue
,
thresholds
}
=
this
.
props
;
const
atThreshold
=
thresholds
.
filter
(
threshold
=>
value
<=
threshold
.
value
);
if
(
thresholds
.
length
>
0
)
{
const
atThreshold
=
thresholds
.
filter
(
threshold
=>
value
<=
threshold
.
value
);
if
(
atThreshold
.
length
>
0
)
{
return
atThreshold
[
0
].
color
;
}
else
if
(
value
<=
maxValue
)
{
return
BasicGaugeColor
.
Red
;
if
(
atThreshold
.
length
>
0
)
{
return
atThreshold
[
0
].
color
;
}
else
if
(
value
<=
maxValue
)
{
return
BasicGaugeColor
.
Red
;
}
}
return
baseColor
;
...
...
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