我正在使用crossfilter和dc.js,我想做这样的事情:
因此,在创建维度和组之后:
var Time1 = ndx.dimension(function(d) { return d.Dep_Time1; }); var FlightsByTime1 = Time1.group();
我试图像这样画一个条形图:
var Time1Chart = dc.barChart("#Time1-chart");
这是它的定义:
Time1Chart
.height(160)
.transitionDuration(1000)
.dimension(Time1)
.group(FlightsByTime1)
.brushOn(true)
.margins({top: 10, right: 50, bottom: 30, left: 50})
.centerBar(false)
.gap(1)
.elasticY(true)
.x(d3.scale.ordinal().domain(Time1))
.xUnits(dc.units.ordinal)
.renderHorizontalGridLines(true)
.renderVerticalGridLines(true)
.ordering(function(d){return d.value;})
.yAxis().tickFormat(d3.format("f"));
我得到了这个结果:
The problems :
. 如您所见,在轴值中我有很多数据......:s
. 我没有刷子,尽管brushOn(true)
. 我想像示例中那样分割轴,2小时乘2小时
请谁能帮助我实现上述目标?
1 回答
1. 首先我们应该创建crossfilter实例 .
2. 然后我们应该创建维度 .
3. 然后我们应该对结果进行分组 .
4. 然后我们创建图表 .
5. 最后给出图表的定义