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
d6eaaf3a
Commit
d6eaaf3a
authored
Feb 23, 2017
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: minor refactoring
parent
68bb417d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
40 deletions
+46
-40
public/app/plugins/panel/graph/module.ts
+18
-7
public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
+6
-6
public/app/plugins/panel/graph/template.ts
+2
-11
public/test/core/time_series_specs.js
+20
-16
No files found.
public/app/plugins/panel/graph/module.ts
View file @
d6eaaf3a
...
...
@@ -26,8 +26,7 @@ class GraphCtrl extends MetricsPanelCtrl {
alertState
:
any
;
annotationsPromise
:
any
;
datapointsCount
:
number
;
datapointsOutside
:
boolean
;
dataWarning
:
any
;
colors
:
any
=
[];
subTabIndex
:
number
;
processor
:
DataProcessor
;
...
...
@@ -178,14 +177,26 @@ class GraphCtrl extends MetricsPanelCtrl {
this
.
dataList
=
dataList
;
this
.
seriesList
=
this
.
processor
.
getSeriesList
({
dataList
:
dataList
,
range
:
this
.
range
});
this
.
datapointsCount
=
this
.
seriesList
.
reduce
((
prev
,
series
)
=>
{
this
.
dataWarning
=
null
;
const
datapointsCount
=
this
.
seriesList
.
reduce
((
prev
,
series
)
=>
{
return
prev
+
series
.
datapoints
.
length
;
},
0
);
this
.
datapointsOutside
=
false
;
for
(
let
series
of
this
.
seriesList
)
{
if
(
series
.
isOutsideRange
)
{
this
.
datapointsOutside
=
true
;
if
(
datapointsCount
===
0
)
{
this
.
dataWarning
=
{
title
:
'No data points'
,
tip
:
'No datapoints returned from data query'
};
}
else
{
for
(
let
series
of
this
.
seriesList
)
{
if
(
series
.
isOutsideRange
)
{
this
.
dataWarning
=
{
title
:
'Data points outside time range'
,
tip
:
'Can be caused by timezone mismatch or missing time filter in query'
,
};
break
;
}
}
}
...
...
public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
View file @
d6eaaf3a
...
...
@@ -35,7 +35,7 @@ describe('GraphCtrl', function() {
});
it
(
'should set datapointsOutside'
,
function
()
{
expect
(
ctx
.
ctrl
.
data
pointsOutside
).
to
.
be
(
true
);
expect
(
ctx
.
ctrl
.
data
Warning
.
title
).
to
.
be
(
'Data points outside time range'
);
});
});
...
...
@@ -55,21 +55,21 @@ describe('GraphCtrl', function() {
});
it
(
'should set datapointsOutside'
,
function
()
{
expect
(
ctx
.
ctrl
.
data
pointsOutside
).
to
.
be
(
false
);
expect
(
ctx
.
ctrl
.
data
Warning
).
to
.
be
(
null
);
});
});
describe
(
'datapointsCount given 2 series'
,
function
()
{
beforeEach
(
function
()
{
var
data
=
[
{
target
:
'test.cpu1'
,
datapoints
:
[
[
45
,
1234567890
],
[
60
,
1234567899
]
]},
{
target
:
'test.cpu2'
,
datapoints
:
[
[
45
,
1234567890
]
]},
{
target
:
'test.cpu1'
,
datapoints
:
[]},
{
target
:
'test.cpu2'
,
datapoints
:
[]},
];
ctx
.
ctrl
.
onDataReceived
(
data
);
});
it
(
'should set datapointsCount
to sum of datapoints
'
,
function
()
{
expect
(
ctx
.
ctrl
.
data
pointsCount
).
to
.
be
(
3
);
it
(
'should set datapointsCount
warning
'
,
function
()
{
expect
(
ctx
.
ctrl
.
data
Warning
.
title
).
to
.
be
(
'No data points'
);
});
});
...
...
public/app/plugins/panel/graph/template.ts
View file @
d6eaaf3a
...
...
@@ -2,17 +2,8 @@ var template = `
<div class="graph-wrapper" ng-class="{'graph-legend-rightside': ctrl.panel.legend.rightSide}">
<div class="graph-canvas-wrapper">
<div class="datapoints-warning" ng-show="ctrl.datapointsCount===0">
<span class="small" >
No datapoints <tip>No datapoints returned from metric query</tip>
</span>
</div>
<div class="datapoints-warning" ng-show="ctrl.datapointsOutside">
<span class="small">
Datapoints outside time range
<tip>Can be caused by timezone mismatch between browser and graphite server</tip>
</span>
<div class="datapoints-warning" ng-if="ctrl.dataWarning">
<span class="small" bs-tooltip="ctrl.dataWarning.tip">{{ctrl.dataWarning.title}}</span>
</div>
<div grafana-graph class="histogram-chart" ng-dblclick="ctrl.zoomOut()">
...
...
public/test/core/time_series_specs.js
View file @
d6eaaf3a
...
...
@@ -6,12 +6,16 @@ define([
describe
(
"TimeSeries"
,
function
()
{
var
points
,
series
;
var
yAxisFormats
=
[
'short'
,
'ms'
];
var
testData
=
{
alias
:
'test'
,
datapoints
:
[
[
1
,
2
],[
null
,
3
],[
10
,
4
],[
8
,
5
]
]
};
var
testData
;
beforeEach
(
function
()
{
testData
=
{
alias
:
'test'
,
datapoints
:
[
[
1
,
2
],[
null
,
3
],[
10
,
4
],[
8
,
5
]
]
};
});
describe
(
'when getting flot pairs'
,
function
()
{
it
(
'with connected style, should ignore nulls'
,
function
()
{
...
...
@@ -51,40 +55,40 @@ define([
it
(
'the delta value should account for nulls'
,
function
()
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],[
3
,
3
],[
null
,
4
],[
10
,
5
],[
15
,
6
]]
});
datapoints
:
[[
1
,
2
],[
3
,
3
],[
null
,
4
],[
10
,
5
],[
15
,
6
]]
});
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
delta
).
to
.
be
(
14
);
});
it
(
'the delta value should account for nulls on first'
,
function
()
{
series
=
new
TimeSeries
({
datapoints
:
[[
null
,
2
],[
1
,
3
],[
10
,
4
],[
15
,
5
]]
});
datapoints
:
[[
null
,
2
],[
1
,
3
],[
10
,
4
],[
15
,
5
]]
});
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
delta
).
to
.
be
(
14
);
});
it
(
'the delta value should account for nulls on last'
,
function
()
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],[
5
,
3
],[
10
,
4
],[
null
,
5
]]
});
datapoints
:
[[
1
,
2
],[
5
,
3
],[
10
,
4
],[
null
,
5
]]
});
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
delta
).
to
.
be
(
9
);
});
it
(
'the delta value should account for resets'
,
function
()
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],[
5
,
3
],[
10
,
4
],[
0
,
5
],[
10
,
6
]]
});
datapoints
:
[[
1
,
2
],[
5
,
3
],[
10
,
4
],[
0
,
5
],[
10
,
6
]]
});
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
delta
).
to
.
be
(
19
);
});
it
(
'the delta value should account for resets on last'
,
function
()
{
series
=
new
TimeSeries
({
datapoints
:
[[
1
,
2
],[
2
,
3
],[
10
,
4
],[
8
,
5
]]
});
datapoints
:
[[
1
,
2
],[
2
,
3
],[
10
,
4
],[
8
,
5
]]
});
series
.
getFlotPairs
(
'null'
,
yAxisFormats
);
expect
(
series
.
stats
.
delta
).
to
.
be
(
17
);
});
...
...
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