1
我有一列是,我要使用dc.jsdc.js:设置范畴条形图X轴与宽域
我在仪表盘上的X轴设置的种类变量CSV知道我可以设定的设定x轴,因为这(从这个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
然而,是没有什么办法可取代a
,b
和c
与捕获所有的此可变?我的专栏有20个不同的类别,我不想用手输入。我的代码如下(列是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();
从dc.js 2.0起,序号域自动计算。 – Gordon
根本不需要调用'.domain()'。 – Gordon