最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

d3.js - Crossfilter javascript Maximum call stack size exceeded, no Nan - Stack Overflow

programmeradmin5浏览0评论

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?

Share Improve this question asked Sep 5, 2013 at 15:07 cantdutchthiscantdutchthis 34.7k17 gold badges77 silver badges116 bronze badges 3
  • 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 of d, not a function. – cantdutchthis Commented Sep 5, 2013 at 15:20
Add a ment  | 

1 Answer 1

Reset to default 9

I 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.

发布评论

评论列表(0)

  1. 暂无评论