试图弄清楚dc.js散点图,并为我构建初始数据而陷入困境我认为
var data = [
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 8},
{ category: 'A', processVersion: 7},
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 7},
{ category: 'A', processVersion: 6},
{ category: 'A', processVersion: 7},
{ category: 'B', processVersion: 6},
{ category: 'B', processVersion: 8},
{ category: 'B', processVersion: 8},
{ category: 'B', processVersion: 7},
{ category: 'B', processVersion: 8}
];
var cf = crossfilter(data);
var dim = cf.dimension(function(d){ return [d.category, d.processVersion]; });
var grp = dim.group();
var scatterChart = dc.scatterPlot("#scatter-chart");
scatterChart
.width(500)
.height(300)
.margins({
top: 10,
right: 20,
bottom: 30,
left: 40
})
.dimension(dim)
.group(grp)
.x(d3.scale.linear().domain[0, 10]) // for each process version
.y(d3.scale.linear().domain[0, 10]) // want count of records where categorys are like
.renderHorizontalGridLines(true)
.renderVerticalGridLines(true)
.symbolSize(30)
.highlightedSize(8)
scatterchart.render();
我想要的是将y作为每个给定服务版本(x轴)共享给定类别的记录的计数。所以我尝试将计数函数放入初始的dimesion数组,或者先处理数据,这似乎是不必要的,因为我猜在crossfilter中有一个正确的方法可以做到这一点?组结果应该有一个键= [5,3,“A”]我认为[0]是processVersion,[1]是计数等。
感谢您的帮助。