mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
Merge pull request #997 from Alfresco/dev-mvitale-788-fix-labels
Fix xAxes labels
This commit is contained in:
commit
903c313615
@ -76,6 +76,8 @@ export class BarChart extends Chart {
|
||||
labels: string[] = [];
|
||||
datasets: any[] = [];
|
||||
data: any[] = [];
|
||||
xAxisType: string;
|
||||
yAxisType: string;
|
||||
options: any = {
|
||||
scales: {
|
||||
yAxes: [{
|
||||
@ -83,6 +85,9 @@ export class BarChart extends Chart {
|
||||
beginAtZero: true,
|
||||
stepSize: 1
|
||||
}
|
||||
}],
|
||||
xAxes: [{
|
||||
ticks: {}
|
||||
}]
|
||||
}
|
||||
};
|
||||
@ -91,6 +96,9 @@ export class BarChart extends Chart {
|
||||
super(obj);
|
||||
this.title = obj && obj.title || null;
|
||||
this.titleKey = obj && obj.titleKey || null;
|
||||
this.xAxisType = obj && obj.xAxisType || null;
|
||||
this.yAxisType = obj && obj.yAxisType || null;
|
||||
this.options.scales.xAxes[0].ticks.callback = this.xAxisTickFormatFunction(this.xAxisType);
|
||||
obj.values.forEach((params: any) => {
|
||||
let dataValue = [];
|
||||
params.values.forEach((info: any) => {
|
||||
@ -108,6 +116,18 @@ export class BarChart extends Chart {
|
||||
});
|
||||
}
|
||||
|
||||
xAxisTickFormatFunction = function (xAxisType) {
|
||||
return function (value) {
|
||||
if ('date_day' === xAxisType) {
|
||||
return moment(new Date(value)).format('DD');
|
||||
} else if ('date_month' === xAxisType) {
|
||||
return moment(new Date(value)).format('MMMM');
|
||||
} else if ('date_year' === xAxisType) {
|
||||
return moment(new Date(value)).format('YYYY');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
hasDatasets() {
|
||||
return this.datasets && this.datasets.length > 0 ? true : false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user