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
d8929b1d
Commit
d8929b1d
authored
Feb 29, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/plopp/grafana
into plopp-master
parents
97c27668
14312d22
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
public/app/core/utils/file_export.ts
+35
-0
public/app/plugins/panel/graph/module.ts
+5
-0
No files found.
public/app/core/utils/file_export.ts
View file @
d8929b1d
...
...
@@ -14,6 +14,41 @@ export function exportSeriesListToCsv(seriesList) {
saveSaveBlob
(
text
,
'grafana_data_export.csv'
);
};
export
function
exportSeriesListToCsvColumns
(
seriesList
)
{
var
text
=
'Time;'
;
// add header
_
.
each
(
seriesList
,
function
(
series
)
{
text
+=
series
.
alias
+
';'
;
});
text
=
text
.
substring
(
0
,
text
.
length
-
1
);
text
+=
'
\
n'
;
// process data
var
dataArr
=
[[]];
var
sIndex
=
1
;
_
.
each
(
seriesList
,
function
(
series
)
{
var
cIndex
=
0
;
dataArr
.
push
([]);
_
.
each
(
series
.
datapoints
,
function
(
dp
)
{
dataArr
[
0
][
cIndex
]
=
new
Date
(
dp
[
1
]).
toISOString
();
dataArr
[
sIndex
][
cIndex
]
=
dp
[
0
];
cIndex
++
;
});
sIndex
++
;
});
// make text
for
(
var
i
=
0
;
i
<
dataArr
[
0
].
length
;
i
++
)
{
text
+=
dataArr
[
0
][
i
]
+
';'
;
for
(
var
j
=
1
;
j
<
dataArr
.
length
;
j
++
)
{
text
+=
dataArr
[
j
][
i
]
+
';'
;
}
text
=
text
.
substring
(
0
,
text
.
length
-
1
);
text
+=
'
\
n'
;
}
saveSaveBlob
(
text
,
'grafana_data_export.csv'
);
};
export
function
exportTableDataToCsv
(
table
)
{
var
text
=
''
;
// add header
...
...
public/app/plugins/panel/graph/module.ts
View file @
d8929b1d
...
...
@@ -126,6 +126,7 @@ class GraphCtrl extends MetricsPanelCtrl {
getExtendedMenu
()
{
var
menu
=
super
.
getExtendedMenu
();
menu
.
push
({
text
:
'Export CSV'
,
click
:
'ctrl.exportCsv()'
});
menu
.
push
({
text
:
'Export CSV (series2columns)'
,
click
:
'ctrl.exportCsvColumns()'
});
menu
.
push
({
text
:
'Toggle legend'
,
click
:
'ctrl.toggleLegend()'
});
return
menu
;
}
...
...
@@ -295,6 +296,10 @@ class GraphCtrl extends MetricsPanelCtrl {
exportCsv
()
{
fileExport
.
exportSeriesListToCsv
(
this
.
seriesList
);
}
exportCsvColumns
()
{
fileExport
.
exportSeriesListToCsvColumns
(
this
.
seriesList
);
}
}
export
{
GraphCtrl
,
GraphCtrl
as
PanelCtrl
}
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