After implementing the code snippet provided below, I successfully managed to group objects from my existing dataset using Underscore JS. The grouped data is displayed in distinct groups as depicted by the output:
{Group1: Array[10], Group2: Array[13], Group3: Array[16], Group4: Array[21], Group5: Array[38]}
//To create categories based on assigned groups
var groupedData = _.groupBy(results, function (d) {
return d.groups;
});
console.log(groupedData);
However, my primary aim now is to transform this structure into a JSON array similar to the following format:
var myData = [["Group1", 10], ["Group2",13], ["Group3",16], ["Group4",21], ["Group5",38]];
I am seeking advice on how I can modify my code to achieve this desired outcome.
Your assistance would be greatly appreciated. Thank you.