source: Dev/branches/jQueryUI/client/d3/test/layout/test-histogram.js @ 249

Last change on this file since 249 was 249, checked in by hendrikvanantwerpen, 13 years ago

This one's for Subversion, because it's so close...

First widget (stripped down sequencer).
Seperated client and server code in two direcotry trees.

File size: 947 bytes
Line 
1require("./../../lib/env-js/envjs/node");
2require("./../../d3");
3require("./../../d3.layout");
4
5var format = d3.format(".2f");
6
7var histogram = d3.layout.histogram().frequency(true);
8console.log("frequency(true):");
9console.log("  0,0,0,1,2,2 -> " + log(histogram([0,0,0,1,2,2])));
10console.log("");
11
12var histogram = d3.layout.histogram().frequency(false);
13console.log("frequency(false):");
14console.log("  0,0,0,1,2,2 -> " + log(histogram([0,0,0,1,2,2])));
15console.log("");
16
17var histogram = d3.layout.histogram().bins(2);
18console.log("bins(4):");
19console.log("  0,0,0,1,2,2 -> " + log(histogram([0,0,0,1,2,2])));
20console.log("");
21
22var histogram = d3.layout.histogram().bins([0,1,2,3]);
23console.log("bins(0,1,2,3):");
24console.log("  0,0,0,1,2,2 -> " + log(histogram([0,0,0,1,2,2])));
25console.log("");
26
27function log(bins) {
28  return bins.map(function(bin) { return format(bin.x) + "-" + format(bin.x + bin.dx) + ":" + format(bin.y); }).join(", ");
29}
Note: See TracBrowser for help on using the repository browser.