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
4b0df606
Commit
4b0df606
authored
Jan 29, 2019
by
Peter Holmberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
magic number solution
parent
142ebc75
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
packages/grafana-ui/src/components/Gauge/Gauge.test.tsx
+3
-3
packages/grafana-ui/src/components/Gauge/Gauge.tsx
+4
-5
No files found.
packages/grafana-ui/src/components/Gauge/Gauge.test.tsx
View file @
4b0df606
...
@@ -116,7 +116,7 @@ describe('Format value', () => {
...
@@ -116,7 +116,7 @@ describe('Format value', () => {
const
result
=
instance
.
formatValue
(
value
);
const
result
=
instance
.
formatValue
(
value
);
expect
(
result
).
toEqual
(
'
6.0
'
);
expect
(
result
).
toEqual
(
'
6.0
'
);
});
});
it
(
'should return formatted value if there are no matching value mappings'
,
()
=>
{
it
(
'should return formatted value if there are no matching value mappings'
,
()
=>
{
...
@@ -129,7 +129,7 @@ describe('Format value', () => {
...
@@ -129,7 +129,7 @@ describe('Format value', () => {
const
result
=
instance
.
formatValue
(
value
);
const
result
=
instance
.
formatValue
(
value
);
expect
(
result
).
toEqual
(
'
10.0
'
);
expect
(
result
).
toEqual
(
'
10.0
'
);
});
});
it
(
'should return mapped value if there are matching value mappings'
,
()
=>
{
it
(
'should return mapped value if there are matching value mappings'
,
()
=>
{
...
@@ -142,6 +142,6 @@ describe('Format value', () => {
...
@@ -142,6 +142,6 @@ describe('Format value', () => {
const
result
=
instance
.
formatValue
(
value
);
const
result
=
instance
.
formatValue
(
value
);
expect
(
result
).
toEqual
(
'
1-20
'
);
expect
(
result
).
toEqual
(
'
1-20
'
);
});
});
});
});
packages/grafana-ui/src/components/Gauge/Gauge.tsx
View file @
4b0df606
...
@@ -61,7 +61,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -61,7 +61,7 @@ export class Gauge extends PureComponent<Props> {
if
(
valueMappings
.
length
>
0
)
{
if
(
valueMappings
.
length
>
0
)
{
const
valueMappedValue
=
getMappedValue
(
valueMappings
,
value
);
const
valueMappedValue
=
getMappedValue
(
valueMappings
,
value
);
if
(
valueMappedValue
)
{
if
(
valueMappedValue
)
{
return
`
${
prefix
}
${
valueMappedValue
.
text
}
${
suffix
}
`
;
return
`
${
prefix
&&
prefix
+
' '
}${
valueMappedValue
.
text
}${
suffix
&&
' '
+
suffix
}
`
;
}
}
}
}
...
@@ -147,9 +147,8 @@ export class Gauge extends PureComponent<Props> {
...
@@ -147,9 +147,8 @@ export class Gauge extends PureComponent<Props> {
const
gaugeWidthReduceRatio
=
showThresholdLabels
?
1.5
:
1
;
const
gaugeWidthReduceRatio
=
showThresholdLabels
?
1.5
:
1
;
const
gaugeWidth
=
Math
.
min
(
dimension
/
6
,
60
)
/
gaugeWidthReduceRatio
;
const
gaugeWidth
=
Math
.
min
(
dimension
/
6
,
60
)
/
gaugeWidthReduceRatio
;
const
thresholdMarkersWidth
=
gaugeWidth
/
5
;
const
thresholdMarkersWidth
=
gaugeWidth
/
5
;
const
fontSize
=
Math
.
ceil
(
const
fontSize
=
Math
.
min
(
dimension
/
5
,
100
)
*
(
formattedValue
!==
null
?
this
.
getFontScale
(
formattedValue
.
length
)
:
1
)
Math
.
min
(
dimension
/
5
,
100
)
*
(
formattedValue
!==
null
?
this
.
getFontScale
(
formattedValue
.
length
)
:
1
);
);
const
thresholdLabelFontSize
=
fontSize
/
2.5
;
const
thresholdLabelFontSize
=
fontSize
/
2.5
;
const
options
=
{
const
options
=
{
...
@@ -180,7 +179,7 @@ export class Gauge extends PureComponent<Props> {
...
@@ -180,7 +179,7 @@ export class Gauge extends PureComponent<Props> {
value
:
{
value
:
{
color
:
this
.
getFontColor
(
value
),
color
:
this
.
getFontColor
(
value
),
formatter
:
()
=>
{
formatter
:
()
=>
{
return
this
.
formatValue
(
value
)
;
return
formattedValue
;
},
},
font
:
{
size
:
fontSize
,
family
:
'"Helvetica Neue", Helvetica, Arial, sans-serif'
},
font
:
{
size
:
fontSize
,
family
:
'"Helvetica Neue", Helvetica, Arial, sans-serif'
},
},
},
...
...
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