Given the following Dates:
var b = [
{Date:'Jan 2016', steel:10.98},
{Date:'Feb 2016', steel:5.67},
{Date:'Jan 2016', steel:3.14},
{Date:'Feb 2016', steel:2.14},
{Date:'Mar 2016', steel:12.14}
]
I want to calculate both sum and cumulative average with respect to the dates shown above.
My desired output is:
Sum ->
[{"Date": "Jan 2016","val": 14.12},
{"date": "Feb 2016","val": 7.81},
{"date": "Mar 2016","val": 12.14}]
Cumulative Average ->
[{"Date": "Jan 2016","val": 7.06 },
{"date": "Feb 2016","val": 5.48},
{"date": "Mar 2016","val": 6.814}]