Question might be easy but I'm quite stuck with it.
I have a chartjs
options object. There is a callback function within it.
I need to use some component's variable in that function (this.period
).
Is something like this possible ?
Component code:
@Input() period: string;
public lineChartOptions: any = {
responsive: true,
// maintainAspectRatio: false
scales: {
xAxes: [{
ticks: {
max: 10,
callback: (function(value, index, values) {
this.wrapperXAxisCallback(value, index, values)
})
}
}],
}
};
wrapperXAxisCallback(value, index, values) {
switch (this.period) {
case '24hr':
..... break;
case 'week':
..... break;
}
}