Single bar stacked chart in DC
I am trying to populate a single column stacked bar chart. It is just a sum of one value stacked over the other ie the sum of 'LB' experiments stacked over the 'Random' experiments.
Since I need to give a dimension value to the chart I have assumed a Dim variable with 1 as its value for both lb and random.
I am getting the above described data using the following code:
d3.csv("file:///D:/Optus/LARS T&L/Dashboard/html/dummy2.csv",function(error, experiments) {
var ndx = crossfilter(experiments),
rDim = ndx.dimension(function(d) {return d.Dim;});
var lb = rDim.group().reduceSum(function(d){return d.LBRandom=="LB"?d.Contacted:0;});
var ran = rDim.group().reduceSum(function(d){return d.LBRandom=="Random"?d.Contacted:0;});
Although when I am trying to plot this data, the browser only displays the the axis and no data is plotted:
Code for plotting:
chart
.width(768)
.height(480)
.x(d3.scale.ordinal())
.y(d3.scale.linear().domain([0,200000]))
.brushOn(false)
.dimension(rDim)
.group(lb)
.stack(ran)
.render();
});
Can anyone help me out with this? It's my 1st day working with d3, dc & crossfilters libraries. Thanks!
链接地址: http://www.djcxy.com/p/32718.html下一篇: 直流单杆堆积图