diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b68728cb44..090af032f30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - [Issue #850](https://github.com/grafana/grafana/issues/850). Graph: Shared tooltip that shows multiple series & crosshair line, thx @toni-moreno - [Issue #940](https://github.com/grafana/grafana/issues/940). Graph: New series style override option "Fill below to", useful to visualize max & min as a shadow for the mean - [Issue #1030](https://github.com/grafana/grafana/issues/1030). Graph: Legend table display/look changed, now includes column headers for min/max/avg, and full width (unless on right side) +- [Issue #861](https://github.com/grafana/grafana/issues/861). Graph: Export graph time series data as csv file **New Panels** - [Issue #951](https://github.com/grafana/grafana/issues/951). SingleStat: New singlestat panel diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 567e7c78f23..ecef4bd164e 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -459,6 +459,17 @@ function($, _, moment) { .replace(/ +/g,'-'); }; + kbn.exportSeriesListToCsv = function(seriesList) { + var text = 'Series;Time;Value\n'; + _.each(seriesList, function(series) { + _.each(series.datapoints, function(dp) { + text += series.alias + ';' + new Date(dp[1]).toISOString() + ';' + dp[0] + '\n'; + }); + }); + var blob = new Blob([text], { type: "text/csv;charset=utf-8" }); + window.saveAs(blob, 'grafana_data_export.csv'); + }; + kbn.stringToJsRegex = function(str) { if (str[0] !== '/') { return new RegExp(str); diff --git a/src/app/panels/graph/module.js b/src/app/panels/graph/module.js index 9e4ee0fd336..90b6957b8b5 100644 --- a/src/app/panels/graph/module.js +++ b/src/app/panels/graph/module.js @@ -30,6 +30,7 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.panelMeta.addEditorTab('Axes & Grid', 'app/panels/graph/axisEditor.html'); $scope.panelMeta.addEditorTab('Display Styles', 'app/panels/graph/styleEditor.html'); + $scope.panelMeta.addExtendedMenuItem('Export CSV', '', 'exportCsv()'); $scope.panelMeta.addExtendedMenuItem('Toggle legend', '', 'toggleLegend()'); // Set and populate defaults @@ -283,6 +284,10 @@ function (angular, app, $, _, kbn, moment, TimeSeries, PanelMeta) { $scope.get_data(); }; + $scope.exportCsv = function() { + kbn.exportSeriesListToCsv($scope.seriesList); + }; + panelSrv.init($scope); });