mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(graph panel): more progress on graph panel and non time series data support
This commit is contained in:
@@ -170,7 +170,6 @@ function (_, $, coreModule) {
|
|||||||
},
|
},
|
||||||
link: {
|
link: {
|
||||||
pre: function postLink($scope, elem, attrs) {
|
pre: function postLink($scope, elem, attrs) {
|
||||||
var cachedOptions;
|
|
||||||
|
|
||||||
$scope.valueToSegment = function(value) {
|
$scope.valueToSegment = function(value) {
|
||||||
var option = _.find($scope.options, {value: value});
|
var option = _.find($scope.options, {value: value});
|
||||||
@@ -190,20 +189,13 @@ function (_, $, coreModule) {
|
|||||||
});
|
});
|
||||||
return $q.when(optionSegments);
|
return $q.when(optionSegments);
|
||||||
} else {
|
} else {
|
||||||
return $scope.getOptions().then(function(options) {
|
return $scope.getOptions();
|
||||||
cachedOptions = options;
|
|
||||||
return _.map(options, function(option) {
|
|
||||||
return uiSegmentSrv.newSegment({value: option.text});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.onSegmentChange = function() {
|
$scope.onSegmentChange = function() {
|
||||||
var options = $scope.options || cachedOptions;
|
if ($scope.options) {
|
||||||
|
var option = _.find($scope.options, {text: $scope.segment.value});
|
||||||
if (options) {
|
|
||||||
var option = _.find(options, {text: $scope.segment.value});
|
|
||||||
if (option && option.value !== $scope.property) {
|
if (option && option.value !== $scope.property) {
|
||||||
$scope.property = option.value;
|
$scope.property = option.value;
|
||||||
} else if (attrs.custom !== 'false') {
|
} else if (attrs.custom !== 'false') {
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ export class AxesEditorCtrl {
|
|||||||
this.xAxisModes = {
|
this.xAxisModes = {
|
||||||
'Time': 'time',
|
'Time': 'time',
|
||||||
'Series': 'series',
|
'Series': 'series',
|
||||||
'Table': 'table',
|
'Custom': 'custom'
|
||||||
'Json': 'json'
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.xAxisStatOptions = [
|
this.xAxisStatOptions = [
|
||||||
@@ -55,12 +54,21 @@ export class AxesEditorCtrl {
|
|||||||
xAxisOptionChanged() {
|
xAxisOptionChanged() {
|
||||||
switch (this.panel.xaxis.mode) {
|
switch (this.panel.xaxis.mode) {
|
||||||
case 'time': {
|
case 'time': {
|
||||||
|
this.panel.bars = false;
|
||||||
|
this.panel.lines = true;
|
||||||
|
this.panel.points = false;
|
||||||
|
this.panel.legend.show = true;
|
||||||
this.panel.tooltip.shared = true;
|
this.panel.tooltip.shared = true;
|
||||||
this.panel.xaxis.values = [];
|
this.panel.xaxis.values = [];
|
||||||
this.panelCtrl.onDataReceived(this.panelCtrl.dataList);
|
this.panelCtrl.onDataReceived(this.panelCtrl.dataList);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'series': {
|
case 'series': {
|
||||||
|
this.panel.bars = true;
|
||||||
|
this.panel.lines = false;
|
||||||
|
this.panel.points = false;
|
||||||
|
this.panel.stack = false;
|
||||||
|
this.panel.legend.show = false;
|
||||||
this.panel.tooltip.shared = false;
|
this.panel.tooltip.shared = false;
|
||||||
this.panelCtrl.processor.validateXAxisSeriesValue();
|
this.panelCtrl.processor.validateXAxisSeriesValue();
|
||||||
this.panelCtrl.onDataReceived(this.panelCtrl.dataList);
|
this.panelCtrl.onDataReceived(this.panelCtrl.dataList);
|
||||||
|
|||||||
@@ -11,20 +11,26 @@ export class DataProcessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getSeriesList(options) {
|
getSeriesList(options) {
|
||||||
|
if (!options.dataList || options.dataList.length === 0) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto detect xaxis mode
|
||||||
|
var firstItem;
|
||||||
|
if (options.dataList && options.dataList.length > 0) {
|
||||||
|
firstItem = options.dataList[0];
|
||||||
|
if (firstItem.type === 'docs') {
|
||||||
|
this.panel.xaxis.mode = 'custom';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (this.panel.xaxis.mode) {
|
switch (this.panel.xaxis.mode) {
|
||||||
case 'series':
|
case 'series':
|
||||||
case 'time': {
|
case 'time': {
|
||||||
return options.dataList.map(this.timeSeriesHandler.bind(this));
|
return options.dataList.map(this.timeSeriesHandler.bind(this));
|
||||||
}
|
}
|
||||||
case 'table': {
|
case 'custom': {
|
||||||
// Table panel uses only first enabled target, so we can use dataList[0]
|
return this.customHandler(firstItem);
|
||||||
// dataList.splice(1, dataList.length - 1);
|
|
||||||
// dataHandler = this.tableHandler;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'json': {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,6 +62,11 @@ export class DataProcessor {
|
|||||||
return this.seriesHandler(seriesData, index, datapoints, alias);
|
return this.seriesHandler(seriesData, index, datapoints, alias);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
customHandler(dataItem) {
|
||||||
|
console.log('custom', dataItem);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
tableHandler(seriesData, index) {
|
tableHandler(seriesData, index) {
|
||||||
var xColumnIndex = Number(this.panel.xaxis.columnIndex);
|
var xColumnIndex = Number(this.panel.xaxis.columnIndex);
|
||||||
var valueColumnIndex = Number(this.panel.xaxis.valueColumnIndex);
|
var valueColumnIndex = Number(this.panel.xaxis.valueColumnIndex);
|
||||||
|
|||||||
@@ -262,9 +262,6 @@ function (angular, $, moment, _, kbn, GraphTooltip, thresholdManExports) {
|
|||||||
if (data.length) {
|
if (data.length) {
|
||||||
options.series.bars.barWidth = 0.7;
|
options.series.bars.barWidth = 0.7;
|
||||||
options.series.bars.align = 'center';
|
options.series.bars.align = 'center';
|
||||||
options.series.bars.show = true;
|
|
||||||
options.series.points.show = false;
|
|
||||||
options.series.lines.show = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addXSeriesAxis(options);
|
addXSeriesAxis(options);
|
||||||
|
|||||||
Reference in New Issue
Block a user