HamsterHuey
HamsterHuey

Reputation: 1243

Dc.js lineChart not displaying crossfiltered data

I've been beating my head over this but for the life of me cannot understand why my dc.js lineChart is not displaying data from the crossfiltered data object. I am essentially trying to copy-paste verbatim, the d3noob book example of dc.js that you can find in a working format here:

https://bl.ocks.org/d3noob/raw/6077996/

However, when I try copy-pasting this exact same source code on my local server or on blockbuilder, the lineChart is blank and does not display any data. You can find my current attempt here:

http://bl.ocks.org/anonymous/9d225b361c740256376e04bbbc6f4e47

I even made sure to include the exact javascript libraries and css that d3noob used in his book example (that works) to ensure that this wasn't some compatibility issue with newer versions of some of the libraries, but that did not make any difference. I'd appreciate any help!

Upvotes: 2

Views: 64

Answers (1)

HamsterHuey
HamsterHuey

Reputation: 1243

Well, I seem to have figured out how to fix it. It appears that the data file I downloaded has a different date range of data from the one that d3noob has posted on his block. If I replace the hard-coded domain for the timeChart from this:

.x(d3.time.scale().domain([new Date(2013, 6, 18), new Date(2013, 6, 24)]))

to this:

.x(d3.time.scale().domain([new Date(2013, 7, 9), new Date(2013, 7, 18)]))

Things start to work. Of course, the correct thing to do is this to avoid hard-coding anything to begin with by using this:

.x(d3.time.scale().domain(d3.extent(data, function(d) { return d.dtg; })))

Upvotes: 2

Related Questions