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
145901c0
Unverified
Commit
145901c0
authored
Nov 11, 2020
by
Torkel Ödegaard
Committed by
GitHub
Nov 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Thresholds: Fixes color assigned to null values (#29010)
* Thresholds: Fixes color assigned to null values * Updates
parent
ab078133
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
packages/grafana-data/src/field/displayProcessor.test.ts
+23
-3
packages/grafana-data/src/field/displayProcessor.ts
+1
-1
packages/grafana-data/src/field/scale.ts
+6
-1
No files found.
packages/grafana-data/src/field/displayProcessor.test.ts
View file @
145901c0
...
...
@@ -16,9 +16,8 @@ function getDisplayProcessorFromConfig(config: FieldConfig) {
function
assertSame
(
input
:
any
,
processors
:
DisplayProcessor
[],
match
:
DisplayValue
)
{
processors
.
forEach
(
processor
=>
{
const
value
=
processor
(
input
);
expect
(
value
.
text
).
toEqual
(
match
.
text
);
if
(
match
.
hasOwnProperty
(
'numeric'
))
{
expect
(
value
.
numeric
).
toEqual
(
match
.
numeric
);
for
(
const
key
of
Object
.
keys
(
match
))
{
expect
((
value
as
any
)[
key
]).
toEqual
((
match
as
any
)[
key
]);
}
});
}
...
...
@@ -89,6 +88,27 @@ describe('Process simple display values', () => {
});
});
describe
(
'Process null values'
,
()
=>
{
const
processors
=
[
getDisplayProcessorFromConfig
({
min
:
0
,
max
:
100
,
thresholds
:
{
mode
:
ThresholdsMode
.
Absolute
,
steps
:
[
{
value
:
-
Infinity
,
color
:
'#000'
},
{
value
:
0
,
color
:
'#100'
},
{
value
:
100
,
color
:
'#200'
},
],
},
}),
];
it
(
'Null should get -Infinity (base) color'
,
()
=>
{
assertSame
(
null
,
processors
,
{
text
:
''
,
numeric
:
NaN
,
color
:
'#000'
});
});
});
describe
(
'Format value'
,
()
=>
{
it
(
'should return if value isNaN'
,
()
=>
{
const
valueMappings
:
ValueMapping
[]
=
[];
...
...
packages/grafana-data/src/field/displayProcessor.ts
View file @
145901c0
...
...
@@ -115,7 +115,7 @@ export function getDisplayProcessor(options?: DisplayProcessorOptions): DisplayP
}
}
return
{
text
,
numeric
,
prefix
,
suffix
,
...
scaleFunc
(
0
)
};
return
{
text
,
numeric
,
prefix
,
suffix
,
...
scaleFunc
(
-
Infinity
)
};
};
}
...
...
packages/grafana-data/src/field/scale.ts
View file @
145901c0
...
...
@@ -18,7 +18,12 @@ export function getScaleCalculator(field: Field, theme: GrafanaTheme): ScaleCalc
const
info
=
getMinMaxAndDelta
(
field
);
return
(
value
:
number
)
=>
{
const
percent
=
(
value
-
info
.
min
!
)
/
info
.
delta
;
let
percent
=
0
;
if
(
value
!==
-
Infinity
)
{
percent
=
(
value
-
info
.
min
!
)
/
info
.
delta
;
}
const
threshold
=
getActiveThresholdForValue
(
field
,
value
,
percent
);
return
{
...
...
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