htmlangularngx-charts

How to prevent Error: <rect> attribute x: Expected length, "NaN" occurs when declaring empty chart


I want to declare an empty line chart or clear the line chart data by simply emptying the chart data array. With this line of code in typescript:

<!--HTML-->
<ngx-charts-line-chart ...
    [results]="multi">
</ngx-charts-line-chart>

//typescript
this.multi =[];

However Error: <rect> attribute x: Expected length, "NaN". occurred before I push data(or let say renew the data array with actual data inside) into the declared empty array or after I empty the data inside the data array.

Is there any way to make this error disappear? Thanks in advance.


Solution

  • Yes I have find a work around in typescript. Declare the object like this works in my case.

    multi:any[]=[];