Returns a
heatmapInstance.
Use h337.create to create heatmap instances. A Heatmap can be customized with the configObject.
The configObject parameter is required.
Possible configuration properties:
- container (DOMNode) *required*
A DOM node where the heatmap canvas should be appended (heatmap will adapt to the node's size)
- backgroundColor (string) *optional*
A background color string in form of hexcode, color name, or rgb(a)
- gradient (object) *optional*
An object that represents the gradient (syntax: number string [0,1] : color string), check out the example
- radius (number) *optional*
The radius each datapoint will have (if not specified on the datapoint itself)
- opacity (number) [0,1] *optional* default = .6
A global opacity for the whole heatmap. This overrides maxOpacity and minOpacity if set!
- maxOpacity (number) [0,1] *optional*
The maximal opacity the highest value in the heatmap will have. (will be overridden if opacity set)
- minOpacity(number) [0,1] *optional*
The minimum opacity the lowest value in the heatmap will have (will be overridden if opacity set)
- onExtremaChange function callback
Pass a callback to receive extrema change updates. Useful for DOM legends.
- blur (number) [0,1] *optional* default = 0.85
The blur factor that will be applied to all datapoints. The higher the blur factor is, the smoother the gradients will be
- xField (string) *optional* default = "x"
The property name of your x coordinate in a datapoint
- yField (string) *optional* default = "y"
The property name of your y coordinate in a datapoint
- valueField (string) *optional* default = "value"
The property name of your y coordinate in a datapoint
Example configurations
Simple configuration with standard gradient
// create configuration object
var config = {
container: document.getElementById('heatmapContainer'),
radius: 10,
maxOpacity: .5,
minOpacity: 0,
blur: .75
};
// create heatmap with configuration
var heatmapInstance = h337.create(config);
Custom gradient configuration
// create configuration object
var config = {
container: document.getElementById('heatmapContainer'),
radius: 10,
maxOpacity: .5,
minOpacity: 0,
blur: .75,
gradient: {
// enter n keys between 0 and 1 here
// for gradient color customization
'.5': 'blue',
'.8': 'red',
'.95': 'white'
}
};
var heatmapInstance = h337.create(config);