ngx-charts
ngx-charts copied to clipboard
Angular Universal server rendering error: Cannot read property 'width' of undefined
Describe the bug When using ngx-charts with Angular Universal I'm getting an error while server rendering is happening
ERROR TypeError: Cannot read property 'width' of undefined
at LineChartComponent_Template
ngx-charts version 14.0.0
Additional context Angular version "@angular/core": "~9.1.3"
<ngx-charts-line-chart [scheme]="colorScheme" [legend]="legend" [showXAxisLabel]="showXAxisLabel"
[legendTitle]="'legend'|translate" [legendPosition]="'below'" [showYAxisLabel]="showYAxisLabel"
[showXAxisLabel]="showYAxisLabel" [xAxis]="xAxis" [yAxis]="yAxis" [yAxisLabel]="'logs' | translate"
[xAxisLabel]="'time' | translate" [timeline]="false" [results]="logChartData">
</ngx-charts-line-chart>
legend: boolean = true;
showLabels: boolean = true;
animations: boolean = true;
xAxis: boolean = true;
yAxis: boolean = true;
showYAxisLabel: boolean = true;
showXAxisLabel: boolean = true;
timeline: boolean = true;
I had the same problem running the production build, but not in the develpment build. It seems that it's not working without the view property as it says in the documentation. You have to pass a value to it, if you pass an empty array it will default to [700, 300]
Probably your logChartData isn't an array. Example of inputs can be found there I think this issue may be closed.