Skip to content

A tiny JavaScript library for drawing heatmaps with Canvas, support overlap with globalCompositeOperation param

License

Notifications You must be signed in to change notification settings

sxhuan/simpleheat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simpleheat

A super-tiny JavaScript library for drawing heatmaps with Canvas base https://github.com/mourner/simpleheat. Inspired by heatmap.js, but with focus on simplicity and performance.

Powers Leaflet.heat, a heatmap plugin for Leaflet.

Demo: http://mourner.github.io/simpleheat/demo

simpleheat("canvas")
  .data(data)
  .draw();

Reference

Constructor

// create a simpleheat object given an id or canvas reference
var heat = simpleheat(canvas);

Data

// set data of [[x, y, value], ...] format
heat.data(data);

// set max data value (1 by default)
heat.max(max);

// add a data point
heat.add(point);

// clear data
heat.clear();

Appearance

// set point radius and blur radius (25 and 15 by default)
heat.radius(r, r2);

// set gradient colors as {<stop>: '<color>'}, e.g. {0.4: 'blue', 0.65: 'lime', 1: 'red'}
heat.gradient(grad);

// call in case Canvas size changed
heat.resize();

Rendering

// draw the heatmap with optional minimum point opacity (0.05 by default), null by default for globalCompositeOperation
// you can specify globalCompositeOperation by yourself, like 'xor' heat.draw(minOpacity, 'xor');
heat.draw(minOpacity, null);

About

A tiny JavaScript library for drawing heatmaps with Canvas, support overlap with globalCompositeOperation param

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%