score:1

You need to convert your data to the required period - just skip every third value or sum the next three values. Example of implementation:

function convertDataToQuarterly(dataSet) {
    var quarterlyData = [];
    var isCategoriesData = isNaN(dataSet[0]);

    dataSet.forEach(function(dataEl, index) {
        if ((index + 1) % 3 === 0) {
            quarterlyData.push(dataEl);

            if (!isCategoriesData) {
                quarterlyData[quarterlyData.length - 1] += dataSet[index - 1] + dataSet[index - 2];
            }
        }
    });

    return quarterlyData;
}

Live demo: https://jsfiddle.net/BlackLabel/wav86bm5/


Related Query

More Query from same tag