ThatThat's it - that's all the counting done.
$.when(queryData).done(function () { var NOT_GIVEN = '(Ikke oppgitt)';
$.when(queryData).done(function () {
var NOT_GIVEN = '(Ikke oppgitt)';
// group the data
var employeeCounts = this.data.reduce(function (memo, datum) {
var schoolName = datum.Master.lookupValue;
if(schoolName === NOT_GIVEN) {
schoolName = datum.Bachelor.lookupValue;
}
memo[schoolName] = memo[schoolName] || 0; // create the key if it doesn't exist
memo[schoolName]++;
}, {});
var chartData = Object.keys(employeeCounts).reduce(function (memo, name) {
if(name !== NOT_GIVEN) {
memo.push([name, employeeCounts[name]]);
}
return memo;
}, []);
// you may want to sort the counts, since they'll otherwise be pretty much random
// This one will sort the data by count in descending order
chartData.sort(function (a, b) { return b[1] - a[1]; });
// skipping the separate function here, since the function was hard-coupled
// to this code anyway
$('#container_skoler').highcharts({
series: [{
type: 'pie',
name: 'Skole',
data: chartData
}]
});
});