Merge pull request #1032 from Alfresco/dev-mvitale-792

Custom reports
This commit is contained in:
Mario Romano 2016-11-10 22:31:53 +00:00 committed by GitHub
commit 1c80f89e93
3 changed files with 22 additions and 16 deletions

View File

@ -134,7 +134,11 @@ export class AnalyticsReportParametersComponent implements OnInit, OnChanges {
this.reportParamsSub = this.analyticsService.getReportParams(reportId).subscribe( this.reportParamsSub = this.analyticsService.getReportParams(reportId).subscribe(
(res: ReportParametersModel) => { (res: ReportParametersModel) => {
this.reportParameters = res; this.reportParameters = res;
this.onSuccessReportParams.emit(res); if (this.reportParameters.hasParameters()) {
this.onSuccessReportParams.emit(res);
} else {
this.onSuccess.emit();
}
}, },
(err: any) => { (err: any) => {
console.log(err); console.log(err);

View File

@ -106,23 +106,25 @@ export class BarChart extends Chart {
this.yAxisType = obj && obj.yAxisType || null; this.yAxisType = obj && obj.yAxisType || null;
this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType); this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType);
this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType); this.options.scales.yAxes[0].ticks.callback = this.yAxisTickFormatFunction(this.yAxisType);
obj.values.forEach((params: any) => { if (obj.values) {
let dataValue = []; obj.values.forEach((params: any) => {
params.values.forEach((info: any) => { let dataValue = [];
info.forEach((value: any, index: any) => { params.values.forEach((info: any) => {
if (index % 2 === 0) { info.forEach((value: any, index: any) => {
if (!this.labels.includes(value)) { if (index % 2 === 0) {
this.labels.push(value); if (!this.labels.includes(value)) {
this.labels.push(value);
}
} else {
dataValue.push(value);
} }
} else { });
dataValue.push(value);
}
}); });
if (dataValue && dataValue.length > 0) {
this.datasets.push({data: dataValue, label: params.key});
}
}); });
if (dataValue && dataValue.length > 0) { }
this.datasets.push({data: dataValue, label: params.key});
}
});
} }
xAxisTickFormatFunction = function (xAxisType) { xAxisTickFormatFunction = function (xAxisType) {

View File

@ -38,7 +38,7 @@ export class ReportParametersModel {
} }
hasParameters() { hasParameters() {
return (this.definition && this.definition.parameters) ? true : false; return (this.definition && this.definition.parameters && this.definition.parameters.length > 0) ? true : false;
} }
} }