Ordinal Scale Bug?

1,096 views
Skip to first unread message

Miles McCrocklin

unread,
Apr 16, 2012, 2:56:29 PM4/16/12
to d3...@googlegroups.com
Reading the documentation, it implies that a specific domain is optional for d3.scale.ordinal(). 

However given this scale:

    var y = d3.scale.ordinal().rangeBands([0, h], .2);

y("anything") = undefined:



however when I do this:

function pullIdArray(data) {
    var s = {};
    data.forEach(function(d) { s[d._id] = true; });
    var ret = [];
    for (var k in s) {console.log(k); ret.push(k);}
    return ret;
}

var y = d3.scale.ordinal().domain(pullIdArray(data)).rangeBands([0, h], .2);

I get actual numerical values.

Can anyone tell me why this is?


Mike Bostock

unread,
Apr 16, 2012, 3:13:15 PM4/16/12
to d3...@googlegroups.com
A domain is required for rangeBands and rangePoints; otherwise, it
doesn't know how many bands or points to create.

Mike

Reply all
Reply to author
Forward
0 new messages