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
39354249
Commit
39354249
authored
Mar 01, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'utkarshcmu-ms-detection'
parents
91ca5b6f
98e756e2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
5 deletions
+140
-5
public/app/core/time_series2.ts
+12
-0
public/app/plugins/panel/graph/graph_tooltip.js
+9
-3
public/app/plugins/panel/graph/module.ts
+3
-0
public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
+74
-0
public/test/core/time_series_specs.js
+20
-2
public/test/specs/dashboardSrv-specs.js
+22
-0
No files found.
public/app/core/time_series2.ts
View file @
39354249
...
...
@@ -168,4 +168,16 @@ export default class TimeSeries {
formatValue
(
value
)
{
return
this
.
valueFormater
(
value
,
this
.
decimals
,
this
.
scaledDecimals
);
}
isMsResolutionNeeded
()
{
for
(
var
i
=
0
;
i
<
this
.
datapoints
.
length
;
i
++
)
{
if
(
this
.
datapoints
[
i
][
0
]
!==
null
)
{
var
timestamp
=
this
.
datapoints
[
i
][
0
].
toString
();
if
(
timestamp
.
length
===
13
&&
(
timestamp
%
1000
)
!==
0
)
{
return
true
;
}
}
}
return
false
;
}
}
public/app/plugins/panel/graph/graph_tooltip.js
View file @
39354249
...
...
@@ -109,7 +109,13 @@ function ($) {
var
plot
=
elem
.
data
().
plot
;
var
plotData
=
plot
.
getData
();
var
seriesList
=
getSeriesFn
();
var
group
,
value
,
absoluteTime
,
relativeTime
,
hoverInfo
,
i
,
series
,
seriesHtml
;
var
group
,
value
,
absoluteTime
,
relativeTime
,
hoverInfo
,
i
,
series
,
seriesHtml
,
tooltipFormat
;
if
(
panel
.
tooltip
.
msResolution
)
{
tooltipFormat
=
'YYYY-MM-DD HH:mm:ss.SSS'
;
}
else
{
tooltipFormat
=
'YYYY-MM-DD HH:mm:ss'
;
}
if
(
dashboard
.
sharedCrosshair
)
{
ctrl
.
publishAppEvent
(
'setCrosshair'
,
{
pos
:
pos
,
scope
:
scope
});
...
...
@@ -127,7 +133,7 @@ function ($) {
seriesHtml
=
''
;
relativeTime
=
dashboard
.
getRelativeTime
(
seriesHoverInfo
.
time
);
absoluteTime
=
dashboard
.
formatDate
(
seriesHoverInfo
.
time
);
absoluteTime
=
dashboard
.
formatDate
(
seriesHoverInfo
.
time
,
tooltipFormat
);
for
(
i
=
0
;
i
<
seriesHoverInfo
.
length
;
i
++
)
{
hoverInfo
=
seriesHoverInfo
[
i
];
...
...
@@ -164,7 +170,7 @@ function ($) {
value
=
series
.
formatValue
(
value
);
relativeTime
=
dashboard
.
getRelativeTime
(
item
.
datapoint
[
0
]);
absoluteTime
=
dashboard
.
formatDate
(
item
.
datapoint
[
0
]);
absoluteTime
=
dashboard
.
formatDate
(
item
.
datapoint
[
0
]
,
tooltipFormat
);
group
+=
'<div class="graph-tooltip-value">'
+
value
+
'</div>'
;
...
...
public/app/plugins/panel/graph/module.ts
View file @
39354249
...
...
@@ -69,6 +69,7 @@ var panelDefaults = {
tooltip
:
{
value_type
:
'cumulative'
,
shared
:
true
,
msResolution
:
false
,
},
// time overrides
timeFrom
:
null
,
...
...
@@ -200,6 +201,8 @@ class GraphCtrl extends MetricsPanelCtrl {
}
this
.
datapointsCount
+=
datapoints
.
length
;
this
.
panel
.
tooltip
.
msResolution
=
this
.
panel
.
tooltip
.
msResolution
||
series
.
isMsResolutionNeeded
();
}
return
series
;
...
...
public/app/plugins/panel/graph/specs/graph_ctrl_specs.ts
View file @
39354249
...
...
@@ -43,4 +43,78 @@ describe('GraphCtrl', function() {
});
});
describe
(
'msResolution with second resolution timestamps'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
datasource
.
query
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
({
data
:
[
{
target
:
'test.cpu1'
,
datapoints
:
[[
1234567890
,
45
],
[
1234567899
,
60
]]},
{
target
:
'test.cpu2'
,
datapoints
:
[[
1236547890
,
55
],
[
1234456709
,
90
]]}
]
}));
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
=
false
;
ctx
.
ctrl
.
refreshData
(
ctx
.
datasource
);
ctx
.
scope
.
$digest
();
});
it
(
'should not show millisecond resolution tooltip'
,
function
()
{
expect
(
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
).
to
.
be
(
false
);
});
});
describe
(
'msResolution with millisecond resolution timestamps'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
datasource
.
query
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
({
data
:
[
{
target
:
'test.cpu1'
,
datapoints
:
[[
1234567890000
,
45
],
[
1234567899000
,
60
]]},
{
target
:
'test.cpu2'
,
datapoints
:
[[
1236547890001
,
55
],
[
1234456709000
,
90
]]}
]
}));
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
=
false
;
ctx
.
ctrl
.
refreshData
(
ctx
.
datasource
);
ctx
.
scope
.
$digest
();
});
it
(
'should show millisecond resolution tooltip'
,
function
()
{
expect
(
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
).
to
.
be
(
true
);
});
});
describe
(
'msResolution with millisecond resolution timestamps but with trailing zeroes'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
datasource
.
query
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
({
data
:
[
{
target
:
'test.cpu1'
,
datapoints
:
[[
1234567890000
,
45
],
[
1234567899000
,
60
]]},
{
target
:
'test.cpu2'
,
datapoints
:
[[
1236547890000
,
55
],
[
1234456709000
,
90
]]}
]
}));
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
=
false
;
ctx
.
ctrl
.
refreshData
(
ctx
.
datasource
);
ctx
.
scope
.
$digest
();
});
it
(
'should not show millisecond resolution tooltip'
,
function
()
{
expect
(
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
).
to
.
be
(
false
);
});
});
describe
(
'msResolution with millisecond resolution timestamps in one of the series'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
datasource
.
query
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
({
data
:
[
{
target
:
'test.cpu1'
,
datapoints
:
[[
1234567890000
,
45
],
[
1234567899000
,
60
]]},
{
target
:
'test.cpu2'
,
datapoints
:
[[
1236547890010
,
55
],
[
1234456709000
,
90
]]},
{
target
:
'test.cpu3'
,
datapoints
:
[[
1236547890000
,
65
],
[
1234456709000
,
120
]]}
]
}));
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
=
false
;
ctx
.
ctrl
.
refreshData
(
ctx
.
datasource
);
ctx
.
scope
.
$digest
();
});
it
(
'should show millisecond resolution tooltip'
,
function
()
{
expect
(
ctx
.
ctrl
.
panel
.
tooltip
.
msResolution
).
to
.
be
(
true
);
});
});
});
public/test/core/time_series_specs.js
View file @
39354249
...
...
@@ -56,6 +56,26 @@ define([
});
});
describe
(
'can detect if serie contains ms precision'
,
function
()
{
var
fakedata
;
beforeEach
(
function
()
{
fakedata
=
testData
;
});
it
(
'missing datapoint with ms precision'
,
function
()
{
fakedata
.
datapoints
[
0
]
=
[
1234567890000
,
1337
];
series
=
new
TimeSeries
(
fakedata
);
expect
(
series
.
isMsResolutionNeeded
()).
to
.
be
(
false
);
});
it
(
'contains datapoint with ms precision'
,
function
()
{
fakedata
.
datapoints
[
0
]
=
[
1236547890001
,
1337
];
series
=
new
TimeSeries
(
fakedata
);
expect
(
series
.
isMsResolutionNeeded
()).
to
.
be
(
true
);
});
});
describe
(
'series overrides'
,
function
()
{
var
series
;
beforeEach
(
function
()
{
...
...
@@ -148,7 +168,5 @@ define([
});
});
});
});
public/test/specs/dashboardSrv-specs.js
View file @
39354249
...
...
@@ -323,5 +323,27 @@ define([
});
});
describe
(
'Formatting epoch timestamp when timezone is set as utc'
,
function
()
{
var
dashboard
;
beforeEach
(
function
()
{
dashboard
=
_dashboardSrv
.
create
({
timezone
:
'utc'
,
});
});
it
(
'Should format timestamp with second resolution by default'
,
function
()
{
expect
(
dashboard
.
formatDate
(
1234567890000
)).
to
.
be
(
'2009-02-13 23:31:30'
);
});
it
(
'Should format timestamp with second resolution even if second format is passed as parameter'
,
function
()
{
expect
(
dashboard
.
formatDate
(
1234567890007
,
'YYYY-MM-DD HH:mm:ss'
)).
to
.
be
(
'2009-02-13 23:31:30'
);
});
it
(
'Should format timestamp with millisecond resolution if format is passed as parameter'
,
function
()
{
expect
(
dashboard
.
formatDate
(
1234567890007
,
'YYYY-MM-DD HH:mm:ss.SSS'
)).
to
.
be
(
'2009-02-13 23:31:30.007'
);
});
});
});
});
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