I am using ng2-charts. I have a date tab where I can choose today, week, month and particular dates. According to that my data varies in chart. My datas are working well according to date. But my chart is not responsive enough to plot the values corresponding to the dates.
Today View: https://ibb.co/bHDdwLG data[100,105,120],
Week View: https://ibb.co/SfWxyMr data[100,105,120,140]
If you see week's view, before completing value:140 graph cuts down it's not responsive it seems.
Code
TS
public lineChartOptions: any = {
responsive: true,
};
getabc(start?: moment.Moment, end?: moment.Moment) {
this.abcService.getabc(this.token, start, end).subscribe(
data => {
this.a = data.map(k => k.a);
this.date_time = data.map(k => k.datetime.toLocaleTimeString());
this.lineChartData = [
{ data: this.a, label: 'abc' }
]
this.lineChartLabels=this.date_time
console.log(this.a);
console.log(this.date_time); // I can get the values correctly
according to the date
}
);
}
HTML
<div style="display: block;" *ngIf="lineChartData.length > 0">
<canvas baseChart width="400" height="180" style="margin-
left:5%;margin-top: 5%;" [datasets]="lineChartData"
[labels]="lineChartLabels" [options]="lineChartOptions"
[colors]="lineChartColors" [legend]="lineChartLegend"
[chartType]="lineChartType" (chartHover)="chartHovered($event)"
(chartClick)="chartClicked($event)"></canvas>
</div>
</div>