[Solved] Summarize data in array of objects by common date [closed]


Try this function

function mapData(data) {

    let result = [];

    data.forEach(element => {
        let t = element.time + 9200;

        let substr = t.toString().substr(0, 8);
        if(!result[substr])
            result[substr] = 0;
        result[substr] += element.count;
    });

    let returnResult = [];

    result.forEach((element, index) =>
        returnResult.push({
            time: index,
            count: element
        })
    );
    return returnResult;
}

2

solved Summarize data in array of objects by common date [closed]