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
fd8561ac
Commit
fd8561ac
authored
Jul 01, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added missing file from last commit
parent
e1e6ba36
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
src/app/services/influxdb/influxSeries.js
+70
-0
No files found.
src/app/services/influxdb/influxSeries.js
0 → 100644
View file @
fd8561ac
define
([
'underscore'
,
],
function
(
_
)
{
'use strict'
;
function
InfluxSeries
(
options
)
{
this
.
seriesList
=
options
.
seriesList
;
this
.
alias
=
options
.
alias
;
this
.
groupByField
=
options
.
groupByField
;
}
var
p
=
InfluxSeries
.
prototype
;
p
.
getTimeSeries
=
function
()
{
var
output
=
[];
var
self
=
this
;
_
.
each
(
self
.
seriesList
,
function
(
series
)
{
var
seriesName
;
var
timeCol
=
series
.
columns
.
indexOf
(
'time'
);
var
valueCol
=
1
;
var
groupByCol
=
-
1
;
if
(
self
.
groupByField
)
{
groupByCol
=
series
.
columns
.
indexOf
(
self
.
groupByField
);
}
// find value column
_
.
each
(
series
.
columns
,
function
(
column
,
index
)
{
if
(
column
!==
'time'
&&
column
!==
'sequence_number'
&&
column
!==
self
.
groupByField
)
{
valueCol
=
index
;
}
});
var
groups
=
{};
if
(
self
.
groupByField
)
{
groups
=
_
.
groupBy
(
series
.
points
,
function
(
point
)
{
return
point
[
groupByCol
];
});
}
else
{
groups
[
series
.
columns
[
valueCol
]]
=
series
.
points
;
}
_
.
each
(
groups
,
function
(
groupPoints
,
key
)
{
var
datapoints
=
[];
for
(
var
i
=
0
;
i
<
groupPoints
.
length
;
i
++
)
{
var
metricValue
=
isNaN
(
groupPoints
[
i
][
valueCol
])
?
null
:
groupPoints
[
i
][
valueCol
];
datapoints
[
i
]
=
[
metricValue
,
groupPoints
[
i
][
timeCol
]];
}
seriesName
=
self
.
alias
?
self
.
alias
:
(
series
.
name
+
'.'
+
key
);
// if mulitple groups append key to alias
if
(
self
.
alias
&&
self
.
groupByField
)
{
seriesName
+=
key
;
}
output
.
push
({
target
:
seriesName
,
datapoints
:
datapoints
});
});
});
return
output
;
};
return
InfluxSeries
;
});
\ No newline at end of file
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