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
08f587a0
Unverified
Commit
08f587a0
authored
Mar 06, 2018
by
Carl Bergquist
Committed by
GitHub
Mar 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10838 from ilgizar/7107_right_y_axis
Thresholds for Right Y axis
parents
bc22c116
425586f6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
9 deletions
+71
-9
public/app/plugins/panel/graph/specs/threshold_manager_specs.ts
+38
-1
public/app/plugins/panel/graph/threshold_manager.ts
+22
-8
public/app/plugins/panel/graph/thresholds_form.ts
+11
-0
No files found.
public/app/plugins/panel/graph/specs/threshold_manager_specs.ts
View file @
08f587a0
import
{
describe
,
it
,
expect
}
from
'../../../../../test/lib/common'
;
import
{
describe
,
it
,
expect
}
from
'../../../../../test/lib/common'
;
import
angular
from
'angular'
;
import
TimeSeries
from
'app/core/time_series2'
;
import
{
ThresholdManager
}
from
'../threshold_manager'
;
import
{
ThresholdManager
}
from
'../threshold_manager'
;
describe
(
'ThresholdManager'
,
function
()
{
describe
(
'ThresholdManager'
,
function
()
{
...
@@ -15,9 +17,13 @@ describe('ThresholdManager', function() {
...
@@ -15,9 +17,13 @@ describe('ThresholdManager', function() {
panelCtrl
:
{},
panelCtrl
:
{},
};
};
ctx
.
setup
=
function
(
thresholds
)
{
ctx
.
setup
=
function
(
thresholds
,
data
)
{
ctx
.
panel
.
thresholds
=
thresholds
;
ctx
.
panel
.
thresholds
=
thresholds
;
var
manager
=
new
ThresholdManager
(
ctx
.
panelCtrl
);
var
manager
=
new
ThresholdManager
(
ctx
.
panelCtrl
);
if
(
data
!==
undefined
)
{
var
element
=
angular
.
element
(
'<div grafana-graph><div>'
);
manager
.
prepare
(
element
,
data
);
}
manager
.
addFlotOptions
(
ctx
.
options
,
ctx
.
panel
);
manager
.
addFlotOptions
(
ctx
.
options
,
ctx
.
panel
);
};
};
...
@@ -101,5 +107,36 @@ describe('ThresholdManager', function() {
...
@@ -101,5 +107,36 @@ describe('ThresholdManager', function() {
expect
(
markings
[
1
].
yaxis
.
to
).
to
.
be
(
-
Infinity
);
expect
(
markings
[
1
].
yaxis
.
to
).
to
.
be
(
-
Infinity
);
});
});
});
});
plotOptionsScenario
(
'for threshold on two Y axes'
,
ctx
=>
{
var
data
=
new
Array
(
2
);
data
[
0
]
=
new
TimeSeries
({
datapoints
:
[[
0
,
1
],
[
300
,
2
]],
alias
:
'left'
,
});
data
[
0
].
yaxis
=
1
;
data
[
1
]
=
new
TimeSeries
({
datapoints
:
[[
0
,
1
],
[
300
,
2
]],
alias
:
'right'
,
});
data
[
1
].
yaxis
=
2
;
ctx
.
setup
(
[
{
op
:
'gt'
,
value
:
100
,
line
:
true
,
colorMode
:
'critical'
},
{
op
:
'gt'
,
value
:
200
,
line
:
true
,
colorMode
:
'critical'
,
yaxis
:
'right'
},
],
data
);
it
(
'should add first threshold for left axis'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
0
].
yaxis
.
from
).
to
.
be
(
100
);
});
it
(
'should add second threshold for right axis'
,
function
()
{
var
markings
=
ctx
.
options
.
grid
.
markings
;
expect
(
markings
[
1
].
y2axis
.
from
).
to
.
be
(
200
);
});
});
});
});
});
});
public/app/plugins/panel/graph/threshold_manager.ts
View file @
08f587a0
...
@@ -222,16 +222,30 @@ export class ThresholdManager {
...
@@ -222,16 +222,30 @@ export class ThresholdManager {
// fill
// fill
if
(
threshold
.
fill
)
{
if
(
threshold
.
fill
)
{
options
.
grid
.
markings
.
push
({
if
(
threshold
.
yaxis
===
'right'
&&
this
.
hasSecondYAxis
)
{
yaxis
:
{
from
:
threshold
.
value
,
to
:
limit
},
options
.
grid
.
markings
.
push
({
color
:
fillColor
,
y2axis
:
{
from
:
threshold
.
value
,
to
:
limit
},
});
color
:
fillColor
,
});
}
else
{
options
.
grid
.
markings
.
push
({
yaxis
:
{
from
:
threshold
.
value
,
to
:
limit
},
color
:
fillColor
,
});
}
}
}
if
(
threshold
.
line
)
{
if
(
threshold
.
line
)
{
options
.
grid
.
markings
.
push
({
if
(
threshold
.
yaxis
===
'right'
&&
this
.
hasSecondYAxis
)
{
yaxis
:
{
from
:
threshold
.
value
,
to
:
threshold
.
value
},
options
.
grid
.
markings
.
push
({
color
:
lineColor
,
y2axis
:
{
from
:
threshold
.
value
,
to
:
threshold
.
value
},
});
color
:
lineColor
,
});
}
else
{
options
.
grid
.
markings
.
push
({
yaxis
:
{
from
:
threshold
.
value
,
to
:
threshold
.
value
},
color
:
lineColor
,
});
}
}
}
}
}
}
}
...
...
public/app/plugins/panel/graph/thresholds_form.ts
View file @
08f587a0
...
@@ -29,6 +29,7 @@ export class ThresholdFormCtrl {
...
@@ -29,6 +29,7 @@ export class ThresholdFormCtrl {
op
:
'gt'
,
op
:
'gt'
,
fill
:
true
,
fill
:
true
,
line
:
true
,
line
:
true
,
yaxis
:
'left'
,
});
});
this
.
panelCtrl
.
render
();
this
.
panelCtrl
.
render
();
}
}
...
@@ -110,6 +111,16 @@ var template = `
...
@@ -110,6 +111,16 @@ var template = `
</div>
</div>
<div class="gf-form">
<div class="gf-form">
<label class="gf-form-label">Y-Axis</label>
<div class="gf-form-select-wrapper">
<select class="gf-form-input" ng-model="threshold.yaxis"
ng-init="threshold.yaxis = threshold.yaxis === 'left' || threshold.yaxis === 'right' ? threshold.yaxis : 'left'"
ng-options="f for f in ['left', 'right']" ng-change="ctrl.render()" ng-disabled="ctrl.disabled">
</select>
</div>
</div>
<div class="gf-form">
<label class="gf-form-label">
<label class="gf-form-label">
<a class="pointer" ng-click="ctrl.removeThreshold($index)" ng-disabled="ctrl.disabled">
<a class="pointer" ng-click="ctrl.removeThreshold($index)" ng-disabled="ctrl.disabled">
<i class="fa fa-trash"></i>
<i class="fa fa-trash"></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