use*_*082 3 javascript d3.js dc.js
我有以下数据.
任何可能我可以创建一个使用dc.js?
有人可以帮助我使用dc js创建直方图吗?
在整个论坛上搜索但除了这篇文章之外无法获得有用的东西.
日期:
numbers 1 10 1 20 35 24 26 35 12 32 35 10 1 2 32 35 36 12
最近2天被困在这里.
请帮忙.
http://jsfiddle.net/djmartin_umich/NmWP8/

1)首先加载您的数据.在这种情况下,我直接加载它,但您可能想要使用d3.csv(如https://github.com/dc-js/dc.js/blob/master/web/examples/bar中的示例所示). HTML).
var experiments = [
1,
10,
1,
//other data points
20];
Run Code Online (Sandbox Code Playgroud)
2)接下来创建交叉过滤器维度和组.
var ndx = crossfilter(experiments),
typeDimension = ndx.dimension(function (d) {
return d;
}),
typeGroup = typeDimension.group().reduceCount();
Run Code Online (Sandbox Code Playgroud)
3)设置图表
var barChart = dc.barChart("#barChart");
barChart
.width(768)
.height(480)
.x(d3.scale.linear().domain([0,40]))
.brushOn(false)
.dimension(typeDimension)
.group(typeGroup);
Run Code Online (Sandbox Code Playgroud)
4)渲染你的图表
dc.renderAll();
Run Code Online (Sandbox Code Playgroud)