d3.js - dc.js linechart not showing anything -
d3.js - dc.js linechart not showing anything -
i using dc.linechart generate line chart show frequenct vs time. next code
var freqchart=dc.linechart("#chart1"); var ndx=crossfilter(data); var countbytime=ndx.dimension(function (d) { homecoming d.time; }); var dateformat=d3.time.format("%m-%d-%y"); var freqbytimegroup = countbytime.group() .reducecount(function(d) { homecoming d.time; }); freqchart.width(400).height(200).transitionduration(500) .dimension(countbytime).group(freqbytimegroup) .elasticy(true).x( d3.time.scale().domain([d3.min(data,function(d){return d.time}),d3.max(data,function(d){return d.time})])).on("filtered", onfilt).yaxislabel("frequency").xaxislabel('time'); but getting next blank thing without graph. why can't view graph. sort of alter needed in graph. wan show total events in particular time period. there many detectors giving response @ same time. want show count of these detectors @ particular time.
i made number of changes fiddle , got work.
here fork: http://jsfiddle.net/gordonwoodhull/6e67uzfn/11/
some of changes made:
fixed dates, had invalid syntax. (made own because wasn't sure meant there.) make pass on info parse dates usingdateformat.parse() call chart.render() removed argument group.reducecount(), not take arguments (probably clue looking for) phone call .xunits(d3.time.days) - phone call required dc.js knows ticks create on x axis. you want match granularity of xunits granularity utilize date bins. specify bin granularity when define dimension or group, e.g. if want bin days,
var countbytime = data.dimension(function(d) { homecoming d3.time.day(d.time); }); otherwise utilize exact time values, downwards millisecond , might not bin @ all.
hope helps!
d3.js dc.js crossfilter
Comments
Post a Comment