I'm trying to use d3.scale.ordinal()
. I am having an issue where the function only returns the minimum and maximum scale values.
I am trying to use d3.map() to construct the domain. Then I use an xScale function on the same value
My data looks like this:
key,to_state,value,type
Populate,District of Columbia,836,Populate
Populate,Maryland,1938,Populate
Populate,New Jersey,836,Populate
Populate,Pennsylvania,939,Populate
Populate,New York,3455,Populate
My scale function looks like this:
xScale = d3.scale.ordinal()
.domain(d3.map(thedata, function(d){console.log(d.to_state); return d.to_state;}))
.range([0, w - marginleft - marginright]);
My map selection looks like this. The Y and height values are all being calculated properly. Just the X is giving me trouble.
var thechart = chart.selectAll("div")
.data(thedata)
.enter()
console.log(xScale("New Jersey") + " " + xScale("Pennsylvania"));
thechart.append("rect").attr("x", function(d, i) {
return xScale(d.to_state) + marginleft;
})