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
202c1362
Commit
202c1362
authored
Aug 02, 2019
by
Torkel Ödegaard
Committed by
Ryan McKinley
Aug 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FieldDisplay: Return field defaults when there are no data (#18357)
parent
7e89a93b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletions
+31
-1
packages/grafana-ui/src/utils/fieldDisplay.test.ts
+26
-0
packages/grafana-ui/src/utils/fieldDisplay.ts
+5
-1
No files found.
packages/grafana-ui/src/utils/fieldDisplay.test.ts
View file @
202c1362
...
...
@@ -135,4 +135,30 @@ describe('FieldDisplay', () => {
expect
(
field
.
thresholds
!
.
length
).
toEqual
(
2
);
expect
(
field
.
thresholds
!
[
0
].
value
).
toBe
(
-
Infinity
);
});
it
(
'Should return field thresholds when there is no data'
,
()
=>
{
const
options
:
GetFieldDisplayValuesOptions
=
{
data
:
[
{
name
:
'No data'
,
fields
:
[],
rows
:
[],
},
],
replaceVariables
:
(
value
:
string
)
=>
{
return
value
;
},
fieldOptions
:
{
calcs
:
[],
override
:
{},
defaults
:
{
thresholds
:
[{
color
:
'#F2495C'
,
value
:
50
}],
},
},
theme
:
getTheme
(
GrafanaThemeType
.
Dark
),
};
const
display
=
getFieldDisplayValues
(
options
);
expect
(
display
[
0
].
field
.
thresholds
!
.
length
).
toEqual
(
1
);
});
});
packages/grafana-ui/src/utils/fieldDisplay.ts
View file @
202c1362
...
...
@@ -182,7 +182,10 @@ export const getFieldDisplayValues = (options: GetFieldDisplayValuesOptions): Fi
if
(
values
.
length
===
0
)
{
values
.
push
({
field
:
{
name
:
'No Data'
},
field
:
{
...
defaults
,
name
:
'No Data'
,
},
display
:
{
numeric
:
0
,
text
:
'No data'
,
...
...
@@ -244,6 +247,7 @@ type PartialField = Partial<Field>;
export
function
getFieldProperties
(...
props
:
PartialField
[]):
Field
{
let
field
=
props
[
0
]
as
Field
;
for
(
let
i
=
1
;
i
<
props
.
length
;
i
++
)
{
field
=
applyFieldProperties
(
field
,
props
[
i
]);
}
...
...
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