Bar Chart 2 decimals

I made a bar chart with this data. And I would like to have the value CUMULWATT with only 2 decimals.
Here is my code, but it doesn't work ..

Edit Function Node

var m = {};
m.labels = ; = ;
m.series = ["Euros"];
var arrayLength = msg.payload.length;
for (var i = 0; i < arrayLength; i++) {
return {payload:[m],topic:msg.topic};

Thank you

I understand that value.toFixed(2) will give you a string. As you want to get a number probably you have to convert the result to float again. Something like
parseFloat(value.toFixed(2)). I can´t test right now though.

You would be converting the length of the array you just pushed to. As push will return the array length.

The toFixed needs to be inside the push ( ). Would probably be better to use Math.round()

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.