Skip to content
Newer
Older
100644 83 lines (53 sloc) 1.61 KB
3338a4f @substack a package.json and a readme all up in this thing
authored Jul 29, 2011
1 heatmap
2 =======
3
4 Heatmaps for node.js and the browser, groovy!
5
6 ![groovy heatmap, man](http://substack.net/images/heatmap.png)
7
8 example
9 =======
10
11 blob.js
12 -------
13
14 ````javascript
15 var heatmap = require('heatmap');
16
17 var heat = heatmap(500, 500, { radius : 30 });
18 for (var i = 0; i < 5000; i++) {
19 var rho = Math.random() * 2 * Math.PI;
20 var z = Math.pow(Math.random(), 2) * 200;
21
22 var x = 250 + Math.cos(rho) * z;
23 var y = 250 + Math.sin(rho) * z;
24
25 heat.addPoint(x, y);
26 }
27 heat.draw();
28
29 var fs = require('fs');
30 fs.writeFileSync('blob.png', heat.canvas.toBuffer());
31 ````
32
33 methods
34 =======
35
36 var heatmap = require('heatmap');
37
38 var heat = heatmap(...)
39 -----------------------
40
41 Create a new heatmap from an existing canvas element, a numeric width and
42 height, or an option object with canvas or width and height fields.
43
44 Optionally, you can set the `opts.radius` and `opts.threshold` to control the
45 rendering a little.
46
c1800ff @substack docs, bump for addPoint params weight
authored Aug 27, 2011
47 heat.addPoint(x, y, params)
48 ---------------------------
3338a4f @substack a package.json and a readme all up in this thing
authored Jul 29, 2011
49
50 Add a point to the heatmap with a `radius`.
51
c1800ff @substack docs, bump for addPoint params weight
authored Aug 27, 2011
52 `params` can have:
53
54 * radius, defaults to heat.radius || 20
55 * weight, defaults to 0.1
56
b349727 @substack notes about .scale
authored Aug 27, 2011
57 heat.scale(x, y)
58 ----------------
59
60 Scale the canvas by the coefficients `x` and `y`.
61
62 If `y` is undefined, scale both x and y by the first parameter, `x`.
63
3338a4f @substack a package.json and a readme all up in this thing
authored Jul 29, 2011
64 heat.draw()
65 -----------
66
67 Render all the points onto the canvas element.
68
69 heat.canvas
70 -----------
71
72 The HTML Canvas element.
73
2a72dfe @isaacs fix canvas link typo
isaacs authored Jul 29, 2011
74 Protip: with the [canvas module](https://github.com/LearnBoost/node-canvas) for
3338a4f @substack a package.json and a readme all up in this thing
authored Jul 29, 2011
75 node you can `heat.canvas.buffer()` to get a Buffer with a PNG file all up in it.
76
77 install
78 =======
79
80 With [npm](http://npmjs.org), just do:
81
82 npm install heatmap
Something went wrong with that request. Please try again.