Skip to content
Advertisement

Removing NaN from date time returned in javascript

I am working on yii2. In my javascript, I have a formula through which I am getting some data. The data is then passed to chart and chart renders it.

JavaScript

The returned log is

JavaScript

The $dataPointskWh have

JavaScript

How can I remove NaN from date-time? I have looked into this issue but couldn’t find any solution.

Any help would be highly appreciated.

Advertisement

Answer

You can easily do it by mapping the label attribute and remove the last 3 characters

like this

JavaScript

Notice: it is recommended the first answer in case of that all objects have NaN at the end of line otherwise use the second solution

or by another way, you can replace NaN with "" like this one

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement