Class: Heatmap

PD.SVG. Heatmap

Generates a 2D rectangular heatmap in a canvas beneath an SVG element.


new Heatmap(config)

Creates a new 2D rectangular heatmap instance.

Parameters:
Name Type Description
config object

A configuration object.

Properties of config:
Name Type Argument Description
svgId SVGElement | string

The SVG element to use, or the DOM ID of an SVG element.

canvasId HTMLCanvasElement | string

The CANVAS element to use, or the DOM ID of a CANVAS element.

sunpos PD.SolarPosition <optional>

An optional solar position calculator to use.

Author:
  • drajmarsh
Throws:

Throws an error if provided with an invalid svgId element or id.

Type
Error

Members


:CanvasElement

canvasElem

The canvas element to render the heatmap to.

Type
  • CanvasElement

:number

id

A unique identifier for this sun-path.

Type
  • number

:boolean

isSVGHeatmap <readonly>

A flag identifying this object as a rectangular heatmap chart.

Type
  • boolean

:SVGElement

svgElem

The SVG element to render the diagram to.

Type
  • SVGElement

:number

xCells

The number of heatmap cells in the X axis (1 to 16384).

Type
  • number

:number

yCells

The number of heatmap cells in the Y axis (1 to 16384).

Type
  • number

Methods


colorScaleCallback( [callback])

Get/set the callback function used for the color scale.

Parameters:
Name Type Argument Description
callback function <optional>

When provided, this sets the new callback function.

Returns:

Returns the current callback function.

Type
function

height( [height])

Get/set the overall height of the chart, in pixels.

Parameters:
Name Type Argument Description
height number <optional>

When provided, this sets the new chart height in pixels.

Returns:

Returns the current chart height in pixels.

Type
number

paddingBottom( [pixels])

Get/set the inset on the bottom side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the bottom side.

Returns:

Returns the current bottom padding in pixels.

Type
number

paddingLeft( [pixels])

Get/set the inset on the left side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the left side.

Returns:

Returns the current left padding in pixels.

Type
number

paddingRight( [pixels])

Get/set the inset on the right side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the right side.

Returns:

Returns the current right padding in pixels.

Type
number

paddingTop( [pixels])

Get/set the inset on the top side of the chart.

Parameters:
Name Type Argument Description
pixels number <optional>

When provided, this sets the number of pixels the chart axis is indented from the parent container edge on the top side.

Returns:

Returns the current top padding in pixels.

Type
number

selectAction( [action])

Get/set the action to take when interactively selecting.

Parameters:
Name Type Argument Description
action number <optional>

When provided, specifies the action to take when selecting.

Returns:

Returns the current select action.

Type
number

set(config [, update])

Sets one or more properties of the heatmap and updates it.

Parameters:
Name Type Argument Default Description
config number

A configuration object.

update boolean <optional>
true

Whether or not to update the chart if changed.

Returns:

Returns true if anything changed, otherwise false.

Type
boolean

show(state)

Shows or hides the chart based on given state.

Parameters:
Name Type Description
state boolean

Use true to show, false to hide.

Returns:

Returns this chart instance to support method chaining.

Type
object

subTitle( [subtitle])

Get/set the chart sub-title displayed in the header above the chart.

Parameters:
Name Type Argument Description
subtitle string <optional>

When provided, this sets the new sub-title for the chart.

Returns:

Returns the current chart sub-title.

Type
string

throttledRescale( [ms])

Get/set the timer value for throttling calls to the rescale() method.

This basically means that multiple calls to the rescale() method that occur within the specified number of milliseconds will be amalgamated to a single call that occurs at the end of that period.

Parameters:
Name Type Argument Description
ms number <optional>

When provided, this sets the throttling time, in milliseconds. Any value less than 5ms effectively turns off throttling.

Returns:

Returns the current throttling time in milliseconds.

Type
number

title( [title])

Get/set the chart title displayed in the header above the chart.

Parameters:
Name Type Argument Description
title string <optional>

When provided, this sets the new title for the chart.

Returns:

Returns the current chart title.

Type
string

titleSeparation( [fraction])

Get/set the title/sub-title separation as a fraction pf the chart width.

Parameters:
Name Type Argument Description
fraction number <optional>

When provided, this sets the fraction of chart width to separate titles by (0 to 1).

Returns:

Returns the current separation value.

Type
number

units( [units])

Get/set the chart units displayed in the header above the chart.

Parameters:
Name Type Argument Description
units string <optional>

When provided, this sets the new units for the chart.

Returns:

Returns the current chart units.

Type
string

update( [forceUpdateSky])

Performs a complete update of the diagram.

This method updates the diagram to reflect the current date, time and location.

Parameters:
Name Type Argument Description
forceUpdateSky boolean <optional>

When true, forces the sky distribution to update.

Returns:

Returns this heat map instance to support method chaining.

Type
PD.SVG.Heatmap

width( [width])

Get/set the overall width of the chart.

Parameters:
Name Type Argument Description
width number <optional>

When provided, this sets the new chart width in pixels.

Returns:

Returns the current width in pixels.

Type
number