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
10f226c4
Unverified
Commit
10f226c4
authored
Nov 11, 2020
by
Torkel Ödegaard
Committed by
GitHub
Nov 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StatPanels: Fixes auto min max when latest value is zero (#28982)
parent
b5379c53
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
12 deletions
+34
-12
packages/grafana-data/src/field/fieldOverrides.test.ts
+24
-2
packages/grafana-data/src/field/fieldOverrides.ts
+10
-10
No files found.
packages/grafana-data/src/field/fieldOverrides.test.ts
View file @
10f226c4
...
...
@@ -98,8 +98,30 @@ describe('Global MinMax', () => {
});
const
{
min
,
max
}
=
findNumericFieldMinMax
([
frame
]);
expect
(
min
).
toBeNull
();
expect
(
max
).
toBeNull
();
expect
(
min
).
toBe
(
Number
.
MIN_VALUE
);
expect
(
max
).
toBe
(
Number
.
MAX_VALUE
);
});
});
describe
(
'when value values are zeo'
,
()
=>
{
it
(
'then global min max should be correct'
,
()
=>
{
const
frame
=
toDataFrame
({
fields
:
[
{
name
:
'Time'
,
type
:
FieldType
.
time
,
values
:
[
1
,
2
]
},
{
name
:
'Value'
,
type
:
FieldType
.
number
,
values
:
[
1
,
2
]
},
],
});
const
frame2
=
toDataFrame
({
fields
:
[
{
name
:
'Time'
,
type
:
FieldType
.
time
,
values
:
[
1
,
2
]
},
{
name
:
'Value'
,
type
:
FieldType
.
number
,
values
:
[
0
,
0
]
},
],
});
const
{
min
,
max
}
=
findNumericFieldMinMax
([
frame
,
frame2
]);
expect
(
min
).
toBe
(
0
);
expect
(
max
).
toBe
(
2
);
});
});
});
...
...
packages/grafana-data/src/field/fieldOverrides.ts
View file @
10f226c4
...
...
@@ -58,25 +58,25 @@ export function findNumericFieldMinMax(data: DataFrame[]): GlobalMinMax {
const
statsMin
=
stats
[
ReducerID
.
min
];
const
statsMax
=
stats
[
ReducerID
.
max
];
if
(
!
statsM
in
)
{
if
(
statsMin
!==
undefined
&&
statsMin
!==
null
&&
statsMin
<
m
in
)
{
min
=
statsMin
;
}
if
(
!
statsMax
)
{
max
=
statsMax
;
}
if
(
statsMin
&&
statsMin
<
min
)
{
min
=
statsMin
;
}
if
(
statsMax
&&
statsMax
>
max
)
{
if
(
statsMax
!==
undefined
&&
statsMax
!==
null
&&
statsMax
>
max
)
{
max
=
statsMax
;
}
}
}
}
if
(
min
===
Number
.
MAX_VALUE
)
{
min
=
Number
.
MIN_VALUE
;
}
if
(
max
===
Number
.
MIN_VALUE
)
{
max
=
Number
.
MAX_VALUE
;
}
return
{
min
,
max
};
}
...
...
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