I have a csv with a column that is a category variable that I want to set on the x Axis of a dashboard using dc.js
I know that I can set the set the x-axis as this (copied from this post)
.x(d3.scale.ordinal().domain(["", "a", "b", "c"])) // Need empty val to offset first value
.xUnits(dc.units.ordinal) // Tell Dc.js that we're using an ordinal x axis
However, is there any way I can replace the a
,b
, and c
with a variable that captures all of this? My column has 20 different categories and I don't want to type them out by hand. My code is below (the column is d.geo
)
var geoValue = ndx.dimension(function (d) {
return d.geo;
});
var geoGroup = geoValue.group();
geoChart
.width(960)
.height(150)
.margins({top: 10, right: 10, bottom: 20, left: 40})
.dimension(geoValue)
.group(geoGroup)
.transitionDuration(500)
.gap(10)
.x(d3.scale.ordinal().domain(SOLUTION GOES HERE))
.xUnits(dc.units.ordinal)
.elasticY(true)
.xAxis().tickFormat();