mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
began work on adding support for native graphite png renderer support (#22)
This commit is contained in:
@@ -82,6 +82,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
|
||||
// Set and populate defaults
|
||||
var _d = {
|
||||
/** @scratch /panels/histogram/3
|
||||
* renderer:: sets client side (flot) or native graphite png renderer (png)
|
||||
*/
|
||||
renderer: 'flot',
|
||||
/** @scratch /panels/histogram/3
|
||||
* x-axis:: Show the x-axis
|
||||
*/
|
||||
@@ -240,10 +244,6 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
}
|
||||
};
|
||||
|
||||
$scope.typeAheadSource = function () {
|
||||
return ["test", "asd", "testing2"];
|
||||
};
|
||||
|
||||
$scope.remove_panel_from_row = function(row, panel) {
|
||||
if ($scope.fullscreen) {
|
||||
$rootScope.$emit('panel-fullscreen-exit');
|
||||
@@ -307,6 +307,7 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
var graphiteQuery = {
|
||||
range: filterSrv.timeRange(false),
|
||||
targets: $scope.panel.targets,
|
||||
renderer: $scope.panel.renderer,
|
||||
maxDataPoints: $scope.panel.span * 50
|
||||
};
|
||||
|
||||
@@ -319,6 +320,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
|
||||
$scope.receiveGraphiteData = function(results) {
|
||||
$scope.panelMeta.loading = false;
|
||||
if (_.isString(results)) {
|
||||
$scope.render(results);
|
||||
return;
|
||||
}
|
||||
|
||||
results = results.data;
|
||||
$scope.legend = [];
|
||||
@@ -474,5 +479,10 @@ function (angular, app, $, _, kbn, moment, timeSeries) {
|
||||
|
||||
});
|
||||
|
||||
|
||||
if (_.isString(data)) {
|
||||
elem.html('<img src="' + data + '"></img>');
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
|
||||
|
||||
<div class="editor-row">
|
||||
<div class="section">
|
||||
<h5>Chart Options</h5>
|
||||
<div class="editor-option">
|
||||
<label class="small">Renderer</label><select class="input-mini" ng-model="panel.renderer" ng-options="f for f in ['flot', 'png']" ng-change="get_data()"></select>
|
||||
</div>
|
||||
<div class="editor-option">
|
||||
<label class="small">Time correction</label>
|
||||
<select ng-model="panel.timezone" class='input-small' ng-options="f for f in ['browser','utc']"></select>
|
||||
|
||||
@@ -12,6 +12,7 @@ function (angular, _, $, config, kbn, moment) {
|
||||
var module = angular.module('kibana.services');
|
||||
|
||||
module.service('graphiteSrv', function($http, $q, filterSrv) {
|
||||
var graphiteRenderUrl = config.graphiteUrl + "/render";
|
||||
|
||||
this.query = function(options) {
|
||||
try {
|
||||
@@ -19,14 +20,19 @@ function (angular, _, $, config, kbn, moment) {
|
||||
from: this.translateTime(options.range.from),
|
||||
until: this.translateTime(options.range.to),
|
||||
targets: options.targets,
|
||||
renderer: options.renderer,
|
||||
maxDataPoints: options.maxDataPoints
|
||||
};
|
||||
|
||||
var params = buildGraphitePostParams(graphOptions);
|
||||
var params = buildGraphiteParams(graphOptions);
|
||||
|
||||
if (options.renderer === 'png') {
|
||||
return $q.when(graphiteRenderUrl + '?' + params.join('&'));
|
||||
}
|
||||
|
||||
return doGraphiteRequest({
|
||||
method: 'POST',
|
||||
url: config.graphiteUrl + '/render/',
|
||||
url: graphiteRenderUrl,
|
||||
data: params.join('&'),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
@@ -122,11 +128,13 @@ function (angular, _, $, config, kbn, moment) {
|
||||
return $http(options);
|
||||
}
|
||||
|
||||
function buildGraphitePostParams(options) {
|
||||
function buildGraphiteParams(options) {
|
||||
var clean_options = [];
|
||||
var graphite_options = ['target', 'targets', 'from', 'until', 'rawData', 'format', 'maxDataPoints'];
|
||||
|
||||
options['format'] = 'json';
|
||||
if (options.renderer === 'flot') {
|
||||
options['format'] = 'json';
|
||||
}
|
||||
|
||||
$.each(options, function (key, value) {
|
||||
if ($.inArray(key, graphite_options) === -1) {
|
||||
|
||||
Reference in New Issue
Block a user