Accepted answer

countBy could be used instead of groupBy:

var techArray = [
    { project: 'Project1', tech: 'Java'},
    { project: 'Project2', tech: 'Excel'},
    { project: 'Project3', tech: 'SAS'},
    { project: 'Project4', tech: 'Java'},

var counts = _.countBy(techArray,'tech');

This will return an object with the tech as properties and their value as the count:

{ Java: 2, Excel: 1, SAS: 1 }

To get the data in the form for highcharts use map instead of each:

var data =, function(value, key){
    return {
        name: key,
        y: value


This should work

var techArray = [['Project1','Java'], ['Project2', 'excel'], ['Project3', 'Java']];

var chartData = [];
var techData = _.groupBy(techArray, function(item) {
    return item[1];
_.each(techData, function(value, key) {
    var techCount = value.length;
        name: key,
        y: techCount

_.groupBy needs to either get a property name, or a function that returns the value being grouped. There is no tech property of an array, so you cant group by it. But, as our techArray is an array of tuples, we can pass a function _.groupBy that returns the value that we want to groupBy, namely the second item in each tuple.

chartData now looks like this:

    name: 'Java',
    y: 2
}, {
    name: 'excel',
    y: 1

Related Query

More Query from same tag