du.widgets.heatmap

Module implementing a heat map. A heat map displays a density of a variable in two dimensional space.

Requires: d3@v4 du.Widget

HeatMap

du.widgets.heatmap.HeatMap(name[, parent])

The heat map widget class.
argtypedescription
namestringIdentifier of the widget.
parentobjectParent element to append widget to. If not specified, widget is appended to body. optional

grid

du.widgets.heatmap.HeatMap.grid(size)

Sets the grid size to compute heat map on. Default is [40, 40].
argtypedescription
sizenumber[]Array of numbers containing the horizontal and vertical size of the grid..
returndescription
du.widgets.heatmap.HeatMapReference to the current HeatMap.

smooth

du.widgets.heatmap.HeatMap.smooth(on)

Enables smoothing (i.e., anti-aliasing) between cells. Default is false.
argtypedescription
onbooleanWhether to turn on smoothing.
returndescription
du.widgets.heatmap.HeatMapReference to the current HeatMap.

background

du.widgets.heatmap.HeatMap.background(options)

Adds an image to the background of the heat map. Note that the image is scaled up to fit the heat map. Default is empty.
argtypedescription
optionsObjectObject containing the background options. The following properties are supported:
  • path: Path to the image file.
  • opacity: Background opacity. Default is 1.
returndescription
du.widgets.heatmap.HeatMapReference to the current HeatMap.

opacity

du.widgets.heatmap.HeatMap.opacity(level)

Sets the opacity of the heat map. Useful when background image is used. Default is 1.
argtypedescription
levelnumberOpacity level to set.
returndescription
du.widgets.heatmap.HeatMapReference to the current HeatMap.

zScale

du.widgets.heatmap.HeatMap.zScale(scale)

Sets the scale for the density color map. Default is the identity function.
argtypedescription
scalefunctionScale function to apply for the color mapping. Must map the interval [0, 1] to [0, 1].
returndescription
du.widgets.heatmap.HeatMapReference to the current HeatMap.

data

du.widgets.heatmap.HeatMap.data(data)

Binds data to the heat map. Expected data format: array of objects containing the x, y coordinates of the data points and a value denoting the weight of the data point. If value is missing, it is assumed to be 1.
argtypedescription
dataArrayData to plot.
returndescription
du.widgets.heatmap.HeatMapReference to the current HeatMap.