time series - d3.js and nvd3.js how to show graph for number of clicks on a website -


i want give user flexibility choose datetime range , see graph of number clicks during period. range 1 year, 6 month, 1 month, 1 week , 1 day or last 6 hours... @ point of time there 1 click. so, dataset :

time                           click 2012-01-01 01:00:00             1 2012-01-01 02:00:00             1 2012-01-01 03:10:00             1 2012-01-01 03:20:01             1 2012-06-02 11:00:00             1 2012-12-01 01:00:00             1 2013-05-01 12:00:00             1     

the graph should able adjust it's x-axis per data available it. example if checking days data should show hh:00 range , if looking week data should mon-tue-wed range.

my sample code looks this:

 `chart.xaxis.showmaxmin(false).tickformat(function(d) { return d3.time.format('%x')(new date(d)) });   chart.yaxis.tickformat(d3.format(',.2f'));   d3.select('#chart1 svg')     .datum(jsondata)       .call(chart);` 

how handle aggregation of data point? have provide data set aggregation or chart can providing function.


update


i tried rollup , found gives aggregation data now.

rollup = d3.nest().key(function(d) {           return (new date(+d[0])).getmonth();        }).rollup(function(d) {         return d3.sum(d, function(e) { return +e[1]; });       }).entries(jsondatavalues)     .map(function(d) {data.push([d.key,d.values])}); 

it aggregates data on basis of month. needs modified more flexible adjusted given range (may domain friend here ?)


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

How can I fetch data from a web server in an android application? -

jquery - How can I dynamically add a browser tab? -