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
09e79384
Commit
09e79384
authored
Aug 03, 2019
by
Ryan McKinley
Committed by
Torkel Ödegaard
Aug 03, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gauge/BarGauge: Support decimals for min/max toFloatOrUndefined (#18368)
parent
202c1362
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
5 deletions
+13
-5
packages/grafana-data/src/utils/string.ts
+8
-0
packages/grafana-ui/src/components/SingleStatShared/FieldPropertiesEditor.tsx
+5
-5
No files found.
packages/grafana-data/src/utils/string.ts
View file @
09e79384
...
...
@@ -55,3 +55,11 @@ export function toIntegerOrUndefined(value: string): number | undefined {
const
v
=
parseInt
(
value
,
10
);
return
isNaN
(
v
)
?
undefined
:
v
;
}
export
function
toFloatOrUndefined
(
value
:
string
):
number
|
undefined
{
if
(
!
value
)
{
return
undefined
;
}
const
v
=
parseFloat
(
value
);
return
isNaN
(
v
)
?
undefined
:
v
;
}
packages/grafana-ui/src/components/SingleStatShared/FieldPropertiesEditor.tsx
View file @
09e79384
...
...
@@ -7,7 +7,7 @@ import { FormLabel } from '../FormLabel/FormLabel';
import
{
UnitPicker
}
from
'../UnitPicker/UnitPicker'
;
// Types
import
{
toIntegerOrUndefined
,
Field
,
SelectableValue
}
from
'@grafana/data'
;
import
{
toIntegerOrUndefined
,
Field
,
SelectableValue
,
toFloatOrUndefined
,
toNumberString
}
from
'@grafana/data'
;
import
{
VAR_SERIES_NAME
,
VAR_FIELD_NAME
,
VAR_CALC
,
VAR_CELL_PREFIX
}
from
'../../utils/fieldDisplay'
;
...
...
@@ -25,8 +25,8 @@ export const FieldPropertiesEditor: React.FC<Props> = ({ value, onChange, showMi
const
[
decimals
,
setDecimals
]
=
useState
(
value
.
decimals
!==
undefined
&&
value
.
decimals
!==
null
?
value
.
decimals
.
toString
()
:
''
);
const
[
min
,
setMin
]
=
useState
(
value
.
min
!==
undefined
&&
value
.
min
!==
null
?
value
.
min
.
toString
()
:
''
);
const
[
max
,
setMax
]
=
useState
(
value
.
max
!==
undefined
&&
value
.
max
!==
null
?
value
.
max
.
toString
()
:
''
);
const
[
min
,
setMin
]
=
useState
(
toNumberString
(
value
.
min
)
);
const
[
max
,
setMax
]
=
useState
(
toNumberString
(
value
.
max
)
);
const
onTitleChange
=
(
event
:
ChangeEvent
<
HTMLInputElement
>
)
=>
{
onChange
({
...
value
,
title
:
event
.
target
.
value
});
...
...
@@ -61,8 +61,8 @@ export const FieldPropertiesEditor: React.FC<Props> = ({ value, onChange, showMi
onChange
({
...
value
,
decimals
:
toIntegerOrUndefined
(
decimals
),
min
:
to
Integer
OrUndefined
(
min
),
max
:
to
Integer
OrUndefined
(
max
),
min
:
to
Float
OrUndefined
(
min
),
max
:
to
Float
OrUndefined
(
max
),
});
},
[
min
,
max
,
decimals
]);
...
...
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