I am playing around with crossfilter.js
, see and /.
Supposedly the library is very good at handling data swiftly. So to test it I first create an array of random numbers, a big one, with one million rows.
function create_random_json(){
result = []
for (var i = 1000000 - 1; i >= 0; i--) {
result.push( { 'a': Math.random() , 'b' : Math.random() * 5 } )
}
return result
}
json_array = create_random_json()
df = crossfilter( json_array )
So far so good, but then when I try to do some basic crossfilter things, things go terribly wrong.
df.dimension( function(d){ return d.total; });
RangeError: Maximum call stack size exceeded
I've read that this error can be caused by NaN
values but all the values that I have generated are obviously floats, so I am assuming something else is causing the trouble. Any hints?
I am playing around with crossfilter.js
, see https://github./square/crossfilter/wiki/API-Reference and http://square.github.io/crossfilter/.
Supposedly the library is very good at handling data swiftly. So to test it I first create an array of random numbers, a big one, with one million rows.
function create_random_json(){
result = []
for (var i = 1000000 - 1; i >= 0; i--) {
result.push( { 'a': Math.random() , 'b' : Math.random() * 5 } )
}
return result
}
json_array = create_random_json()
df = crossfilter( json_array )
So far so good, but then when I try to do some basic crossfilter things, things go terribly wrong.
df.dimension( function(d){ return d.total; });
RangeError: Maximum call stack size exceeded
I've read that this error can be caused by NaN
values but all the values that I have generated are obviously floats, so I am assuming something else is causing the trouble. Any hints?
- 1 Where is the "total" property supposed to e from? The sample code in the Crossfilter documentation involves objects that have a "total" property; your objects do not. – Pointy Commented Sep 5, 2013 at 15:10
-
1
Also please consider using semicolons and
var
declarations :) – Pointy Commented Sep 5, 2013 at 15:13 -
Looks like I blindly copied the docs. I didnt see that
total
was a property ofd
, not a function. – cantdutchthis Commented Sep 5, 2013 at 15:20
1 Answer
Reset to default 9I think you need to actually pute a total:
df.dimension(function(o) { return o.a + o.b; });
The function you're passing to .dimension()
is returning undefined
, since none of the rows of your dataset have a "total" property.