Built with blockbuilder.org
forked from anonymous's block: fresh block
| license: mit |
Built with blockbuilder.org
forked from anonymous's block: fresh block
| <!DOCTYPE html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.12/crossfilter.js"></script> | |
| <script src="http://dc-js.github.io/dc.js/js/d3.js"></script> | |
| <style> | |
| body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
| </style> | |
| </head> | |
| <body> | |
| <script> | |
| test_data = [{date: d3.time.format("%Y-%m-%dT%H:%M:%S+0100").parse("2014-11-24T12:00:00+0100").getTime(), cnt: 1}, | |
| {date: d3.time.format("%Y-%m-%dT%H:%M:%S+0100").parse("2014-11-24T11:00:00+0100").getTime(), cnt: 2}, | |
| {date: d3.time.format("%Y-%m-%dT%H:%M:%S+0100").parse("2014-11-24T12:00:00+0100").getTime(), cnt: 3}], | |
| test_ndx = crossfilter(test_data), | |
| test_dim = test_ndx.dimension(function(d) { return d.date; }), | |
| test_grp = test_dim.group(function(d) { return -new Date(d).getHours(); }); | |
| console.log(test_grp.all()) | |
| simp_grp = test_dim.group(); | |
| console.log(simp_grp.all().map(function(kv) { return new Date(kv.key)})) | |
| </script> | |
| </body> |