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
230f018c
Commit
230f018c
authored
Mar 20, 2018
by
ilgizar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added validation of input parameters.
parent
bd3d17ab
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
public/app/plugins/panel/graph/align_yaxes.ts
+12
-0
public/app/plugins/panel/graph/specs/align_yaxes.jest.ts
+11
-0
No files found.
public/app/plugins/panel/graph/align_yaxes.ts
View file @
230f018c
...
...
@@ -6,6 +6,10 @@ import _ from 'lodash';
* @param align Y level
*/
export
function
alignYLevel
(
yaxis
,
alignLevel
)
{
if
(
isNaN
(
alignLevel
)
||
!
checkCorrectAxis
(
yaxis
))
{
return
;
}
var
[
yLeft
,
yRight
]
=
yaxis
;
moveLevelToZero
(
yLeft
,
yRight
,
alignLevel
);
...
...
@@ -92,6 +96,14 @@ function restoreLevelFromZero(yLeft, yRight, alignLevel) {
}
}
function
checkCorrectAxis
(
axis
)
{
return
axis
.
length
===
2
&&
checkCorrectAxes
(
axis
[
0
])
&&
checkCorrectAxes
(
axis
[
1
]);
}
function
checkCorrectAxes
(
axes
)
{
return
'min'
in
axes
&&
'max'
in
axes
;
}
function
checkOneSide
(
yLeft
,
yRight
)
{
// on the one hand with respect to zero
return
(
yLeft
.
min
>=
0
&&
yRight
.
min
>=
0
)
||
(
yLeft
.
max
<=
0
&&
yRight
.
max
<=
0
);
...
...
public/app/plugins/panel/graph/specs/align_yaxes.jest.ts
View file @
230f018c
...
...
@@ -197,4 +197,15 @@ describe('Graph Y axes aligner', function() {
expect
(
yaxes
).
toMatchObject
(
expected
);
});
});
describe
(
'on level not number value'
,
()
=>
{
it
(
'Should ignore without errors'
,
()
=>
{
alignY
=
'q'
;
yaxes
=
[{
min
:
5
,
max
:
10
},
{
min
:
2
,
max
:
4
}];
expected
=
[{
min
:
5
,
max
:
10
},
{
min
:
2
,
max
:
4
}];
alignYLevel
(
yaxes
,
alignY
);
expect
(
yaxes
).
toMatchObject
(
expected
);
});
});
});
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