Retrieving values in crossfilter.dimension

user203617 picture user203617 · Feb 24, 2014 · Viewed 8k times · Source

Hi I'm a newbie in JS and Crossfilter. I'm using crossfilter with my data (.csv file) and retrieved distinct values in a column using

var scoreDim = ppr.dimension(function (d) {
    return d.score;
});

Also I could get the counts for each value using

var scoreDimGroup = scoreDim.group().reduceCount();

I could use dc.js to plot the chart and the result looks correct. But how do I retrieve the values in scoreDim and scoreDimGroup so that I can use it for further processing in my code. When I look at the object using a debugger, I could see a bunch of functions but could not see the actual values contained in the objects.

enter image description here

Answer

Ethan Jewett picture Ethan Jewett · Feb 24, 2014
scoreDim.top(Infinity)

will retrieve the records.

scoreDimGroup.top(Infinity)

will retrieve the groups (key-value pairs of the dimension value and the count).

Generally, this kind of thing is covered well in the Crossfilter API documentation.