how to get the specific format in crossfilter.js i.e distinct of distinct count -


this format of data:

[{city:"bhopal",id: 1},{city:"bhopal",id: 2},{city:"delhi",id: 3},{city:"delhi",id:3}] 

here have delhi repeated twice same id.

now need distinct count of city id distinct i.e :

[key:"bhopal",value:2, key:"delhi",value:1] 

where value count

got answer using reductio , crossfilter.

var payments = crossfilter([   {city: "bhopal", id: 1},{city: "bhopal", id: 2},{city: "delhi", id: 3},{city: "delhi", id: 3} ]); var dim = payments.dimension(function(d) { return d.city; }); var group = dim.group(); var reducer = reductio()     .exception(function(d) { return d.id; })     .exceptioncount(true); reducer(group); console.log(group.top(infinity)); 

output: [ { key: 'bhopal', value: { exceptioncount: 2 },{ key: 'delhi', value: { exceptioncount: 2 }]


Comments

Popular posts from this blog

php - trouble displaying mysqli database results in correct order -

depending on nth recurrence of job in control M -

sql server - Cannot query correctly (MSSQL - PHP - JSON) -