daedelus_j daedelus_j - 8 months ago 40
Javascript Question

Trying to render data d3 crossfilter dc.js BarChart. The chart is drawn, but it's empty

I must be doing something naive, but I can't get my data to render within the chart.

here's my example data:

var data = [
date: '02-12-2013',
val: 13,
date: '02-13-2013',
val: 6,

here's my code:

var cf = crossfilter(data);
var dim = cf.dimension(function(d){ return d.val });
var group = dim.group();
var barchart = dc.barChart('#container');

.margins({top: 10, right: 50, bottom: 30, left: 40})
.domain([new Date(data[0].date),
new Date(data[data.length-1].date)]))

What am I missing here? Here's the screenshot of the chart:

Here's the screenshot of the chart


Try to use date as your dimension:

var dim = cf.dimension(function(d){ return d.date });

For bar chart your dimension usually is what needs to be matched with your X axis scale.