Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (50 sloc) 1.595 kB
3338a4f @substack a package.json and a readme all up in this thing
authored
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
47 heat.addPoint(x, y, radius=heat.radius || 20)
48 ---------------------------------------------
49
50 Add a point to the heatmap with a `radius`.
51
b349727 @substack notes about .scale
authored
52 heat.scale(x, y)
53 ----------------
54
55 Scale the canvas by the coefficients `x` and `y`.
56
57 If `y` is undefined, scale both x and y by the first parameter, `x`.
58
3338a4f @substack a package.json and a readme all up in this thing
authored
59 heat.draw()
60 -----------
61
62 Render all the points onto the canvas element.
63
64 heat.canvas
65 -----------
66
67 The HTML Canvas element.
68
2a72dfe @isaacs fix canvas link typo
isaacs authored
69 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
70 node you can `heat.canvas.buffer()` to get a Buffer with a PNG file all up in it.
71
72 install
73 =======
74
75 With [npm](http://npmjs.org), just do:
76
77 npm install heatmap
Something went wrong with that request. Please try again.