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
7e1bf0e7
Unverified
Commit
7e1bf0e7
authored
May 04, 2020
by
Ryan McKinley
Committed by
GitHub
May 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gauge: apply decimal limits to gauge min/max labels (#24192)
* limit label size * fix tests
parent
4a5434bf
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
6 deletions
+12
-6
packages/grafana-ui/src/components/Gauge/Gauge.test.tsx
+2
-2
packages/grafana-ui/src/components/Gauge/Gauge.tsx
+10
-4
No files found.
packages/grafana-ui/src/components/Gauge/Gauge.test.tsx
View file @
7e1bf0e7
...
...
@@ -48,7 +48,7 @@ describe('Get thresholds formatted', () => {
thresholds
:
{
mode
:
ThresholdsMode
.
Absolute
,
steps
:
[{
value
:
-
Infinity
,
color
:
'#7EB26D'
}]
},
});
expect
(
instance
.
getFormattedThresholds
()).
toEqual
([
expect
(
instance
.
getFormattedThresholds
(
2
)).
toEqual
([
{
value
:
0
,
color
:
'#7EB26D'
},
{
value
:
100
,
color
:
'#7EB26D'
},
]);
...
...
@@ -66,7 +66,7 @@ describe('Get thresholds formatted', () => {
},
});
expect
(
instance
.
getFormattedThresholds
()).
toEqual
([
expect
(
instance
.
getFormattedThresholds
(
2
)).
toEqual
([
{
value
:
0
,
color
:
'#7EB26D'
},
{
value
:
50
,
color
:
'#7EB26D'
},
{
value
:
75
,
color
:
'#EAB839'
},
...
...
packages/grafana-ui/src/components/Gauge/Gauge.tsx
View file @
7e1bf0e7
...
...
@@ -52,7 +52,7 @@ export class Gauge extends PureComponent<Props> {
this
.
draw
();
}
getFormattedThresholds
():
Threshold
[]
{
getFormattedThresholds
(
decimals
:
number
):
Threshold
[]
{
const
{
field
,
theme
}
=
this
.
props
;
const
thresholds
=
field
.
thresholds
??
Gauge
.
defaultProps
.
field
?.
thresholds
!
;
const
isPercent
=
thresholds
.
mode
===
ThresholdsMode
.
Percentage
;
...
...
@@ -67,7 +67,7 @@ export class Gauge extends PureComponent<Props> {
const
first
=
getActiveThreshold
(
min
,
steps
);
const
last
=
getActiveThreshold
(
max
,
steps
);
const
formatted
:
Threshold
[]
=
[];
formatted
.
push
({
value
:
min
,
color
:
getColorFromHexRgbOrName
(
first
.
color
,
theme
.
type
)
});
formatted
.
push
({
value
:
+
min
.
toFixed
(
decimals
)
,
color
:
getColorFromHexRgbOrName
(
first
.
color
,
theme
.
type
)
});
let
skip
=
true
;
for
(
let
i
=
0
;
i
<
steps
.
length
;
i
++
)
{
const
step
=
steps
[
i
];
...
...
@@ -83,7 +83,7 @@ export class Gauge extends PureComponent<Props> {
break
;
}
}
formatted
.
push
({
value
:
max
,
color
:
getColorFromHexRgbOrName
(
last
.
color
,
theme
.
type
)
});
formatted
.
push
({
value
:
+
max
.
toFixed
(
decimals
)
,
color
:
getColorFromHexRgbOrName
(
last
.
color
,
theme
.
type
)
});
return
formatted
;
}
...
...
@@ -129,6 +129,12 @@ export class Gauge extends PureComponent<Props> {
}
}
const
decimals
=
field
.
decimals
===
undefined
?
2
:
field
.
decimals
!
;
if
(
showThresholdMarkers
)
{
min
=
+
min
.
toFixed
(
decimals
);
max
=
+
max
.
toFixed
(
decimals
);
}
const
options
:
any
=
{
series
:
{
gauges
:
{
...
...
@@ -145,7 +151,7 @@ export class Gauge extends PureComponent<Props> {
layout
:
{
margin
:
0
,
thresholdWidth
:
0
,
vMargin
:
0
},
cell
:
{
border
:
{
width
:
0
}
},
threshold
:
{
values
:
this
.
getFormattedThresholds
(),
values
:
this
.
getFormattedThresholds
(
decimals
),
label
:
{
show
:
showThresholdLabels
,
margin
:
thresholdMarkersWidth
+
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