d3.js - Time format not working in dc.js LineChart -


i have following parsing code of time in h:m:s format

            var iso8601format=d3.time.format("%y-%m-%dt%h:%m:%sz");             var hoursandminsformat=d3.time.format("%h:%m:%s");              e.time=hoursandminsformat(iso8601format.parse(e.time));  

i have json file reading @ different times different sensors. sample data is=

[ {"id":1,"time":"2015-03-29t20:32:24z"}, {"id":2,"time":"2015-03-29t20:32:24z"}, {"id":3,"time":"2015-03-29t20:32:24z"}, {"id":1,"time":"2015-03-29t20:33:24z"}, {"id":2,"time":"2015-03-29t20:33:24z"}, {"id":3,"time":"2015-03-29t20:33:24z"}, ] 

i going plot dc.js rowchart there time in minutes in x axis , frequency in y axis. using following code this. returning nans.

var freqchart= dc.linechart("#chart1"); var countbytime=ndx.dimension(function (d) {return d.time; }); var freqbytimegroup = countbytime.group().reducecount(); 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;})])).xunits(d3.time.minutes).yaxislabel("frequency").xaxislabel('time').elasticx(true) 

how can solve problem? here jsfiddle that's not working

hurray got solution. here code

   var data=[     {"id":20,"time":"2015-03-29t20:32:24z","speed":20},     {"id":21,"time":"2015-03-29t20:32:24z","speed":15},     {"id":22,"time":"2015-03-29t20:32:24z","speed":16},     {"id":23,"time":"2015-03-29t20:33:25z","speed":14},     {"id":20,"time":"2015-03-29t20:33:26z","speed":20},     {"id":21,"time":"2015-03-29t20:34:24z","speed":10},     {"id":22,"time":"2015-03-29t20:34:24z","speed":15},     {"id":23,"time":"2015-03-29t20:35:24z","speed":15}, ]     // datset larger many detector. sample         var dateformat=d3.time.format("%h:%m:%s").parse;         var iso8601format=d3.time.format("%y-%m-%dt%h:%m:%sz");         var hoursandminsformat=d3.time.format("%h:%m:%s");      data.foreach(function(d) {         d.time=d.time.substring(11,19);         d.time=dateformat(d.time);     }); 

here working jsfiddle


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -