Commit 40e6317b by Torkel Ödegaard

feat(graph): refactoring

parent acfde82c
...@@ -30,7 +30,7 @@ export class AxesEditorCtrl { ...@@ -30,7 +30,7 @@ export class AxesEditorCtrl {
this.xAxisModes = { this.xAxisModes = {
'Time': 'time', 'Time': 'time',
'Series': 'series', 'Series': 'series',
'Data field': 'field', // 'Data field': 'field',
}; };
this.xAxisStatOptions = [ this.xAxisStatOptions = [
......
...@@ -68,6 +68,7 @@ export class DataProcessor { ...@@ -68,6 +68,7 @@ export class DataProcessor {
this.panel.stack = false; this.panel.stack = false;
this.panel.legend.show = false; this.panel.legend.show = false;
this.panel.tooltip.shared = false; this.panel.tooltip.shared = false;
this.panel.xaxis.values = ['total'];
break; break;
} }
} }
......
...@@ -236,24 +236,10 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) { ...@@ -236,24 +236,10 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
} }
}; };
for (var i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
var series = data[i]; var series = data[i];
series.data = series.getFlotPairs(series.nullPointMode || panel.nullPointMode); series.data = series.getFlotPairs(series.nullPointMode || panel.nullPointMode);
if (panel.xaxis.mode === 'series') {
series.data = [[i + 1, series.stats[panel.xaxis.values[0]]]];
} else if (panel.xaxis.mode === 'table' || panel.xaxis.mode === 'elastic') {
series.data = [];
for (var j = 0; j < series.datapoints.length; j++) {
var dataIndex = i * series.datapoints.length + j;
series.datapoints[j];
series.data.push([
dataIndex + 1,
series.datapoints[j][0]
]);
}
}
// if hidden remove points and disable stack // if hidden remove points and disable stack
if (ctrl.hiddenSeries[series.alias]) { if (ctrl.hiddenSeries[series.alias]) {
series.data = []; series.data = [];
...@@ -265,6 +251,12 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) { ...@@ -265,6 +251,12 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
case 'series': { case 'series': {
options.series.bars.barWidth = 0.7; options.series.bars.barWidth = 0.7;
options.series.bars.align = 'center'; options.series.bars.align = 'center';
for (let i = 0; i < data.length; i++) {
var series = data[i];
series.data = [[i + 1, series.stats[panel.xaxis.values[0]]]];
}
addXSeriesAxis(options); addXSeriesAxis(options);
break; break;
} }
...@@ -483,7 +475,7 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) { ...@@ -483,7 +475,7 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
var defaults = { var defaults = {
position: 'left', position: 'left',
show: panel.yaxes[0].show, show: panel.yaxes[0].show,
// min: panel.yaxes[0].min, min: panel.yaxes[0].min,
index: 1, index: 1,
logBase: panel.yaxes[0].logBase || 1, logBase: panel.yaxes[0].logBase || 1,
max: panel.percentage && panel.stack ? 100 : panel.yaxes[0].max, max: panel.percentage && panel.stack ? 100 : panel.yaxes[0].max,
...@@ -494,11 +486,11 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) { ...@@ -494,11 +486,11 @@ module.directive('grafanaGraph', function($rootScope, timeSrv) {
if (_.find(data, {yaxis: 2})) { if (_.find(data, {yaxis: 2})) {
var secondY = _.clone(defaults); var secondY = _.clone(defaults);
secondY.index = 2, secondY.index = 2;
secondY.show = panel.yaxes[1].show; secondY.show = panel.yaxes[1].show;
secondY.logBase = panel.yaxes[1].logBase || 1, secondY.logBase = panel.yaxes[1].logBase || 1;
secondY.position = 'right'; secondY.position = 'right';
// secondY.min = panel.yaxes[1].min; secondY.min = panel.yaxes[1].min;
secondY.max = panel.percentage && panel.stack ? 100 : panel.yaxes[1].max; secondY.max = panel.percentage && panel.stack ? 100 : panel.yaxes[1].max;
// autoscaleSpanOverride(panel.yaxes[1], data[1], secondY); // autoscaleSpanOverride(panel.yaxes[1], data[1], secondY);
options.yaxes.push(secondY); options.yaxes.push(secondY);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment