fixing issue with axis titles

This commit is contained in:
ppisljar 2017-01-25 14:38:05 +01:00
parent 5a499db34e
commit a2a2681390
2 changed files with 23 additions and 9 deletions

View file

@ -28,7 +28,11 @@ module.directive('vislibSeries', function ($parse, $compile) {
$scope.series = $scope.vis.params.seriesParams;
$scope.$watch(() => {
return $scope.vis.aggs.map(agg => {
return agg.params.field ? agg.makeLabel() : '';
try {
return agg.makeLabel();
} catch (e) {
return '';
}
}).join();
}, () => {
let serieCount = 0;
@ -65,6 +69,7 @@ module.directive('vislibSeries', function ($parse, $compile) {
$scope.changeValueAxis = (index) => {
const series = $scope.vis.params.seriesParams[index];
$scope.updateAxisTitle();
if (series.valueAxis === 'new') {
const axis = $scope.addValueAxis();
series.valueAxis = axis.id;

View file

@ -118,16 +118,13 @@ module.directive('vislibValueAxes', function ($parse, $compile) {
};
const lastAxisTitles = {};
$scope.$watch(() => {
return $scope.vis.aggs.map(agg => {
return agg.params.field ? agg.makeLabel() : '';
}).join();
}, () => {
$scope.vis.params.valueAxes.forEach((axis, i) => {
$scope.updateAxisTitle = function () {
$scope.vis.params.valueAxes.forEach((axis, axisNumber) => {
let label = '';
const isFirst = axisNumber === 0;
const matchingSeries = [];
$scope.vis.params.seriesParams.forEach(series => {
const isMatchingSeries = (i === 0 && !series.valueAxis) || (series.valueAxis === axis.id);
$scope.vis.params.seriesParams.forEach((series, i) => {
const isMatchingSeries = (isFirst && !series.valueAxis) || (series.valueAxis === axis.id);
if (isMatchingSeries) {
let seriesNumber = 0;
$scope.vis.aggs.forEach(agg => {
@ -146,6 +143,18 @@ module.directive('vislibValueAxes', function ($parse, $compile) {
axis.title.text = label;
}
});
};
$scope.$watch(() => {
return $scope.vis.aggs.map(agg => {
try {
return agg.makeLabel();
} catch (e) {
return '';
}
}).join();
}, () => {
$scope.updateAxisTitle();
});
}
};