Heat.js - Documentation - Public Functions

Below is a list of all the public API functions that can be called from a Heat.js service.

Download Now

v3.1.0 - 2nd Apr 2024
Functions

Manage Dates:

addDates( elementId, dates, [triggerRefresh] ):

Adds an array of dates for a specific element ID, and refreshes the UI (if specified). If the dates already exist, their values are increased by one.
Fires: onAdd
Parameter: elementId: string - The Heat.js element ID that should show the new date.
Parameter: dates: Date[] - The dates to add.
Parameter: [type]: string - The trend type (defaults to "Unknown").
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

addDate( elementId, date, [triggerRefresh] ):

Adds a date for a specific element ID, and refreshes the UI (if specified). If the date already exists, its value is increased by one.
Fires: onAdd
Parameter: elementId: string - The Heat.js element ID that should show the new date.
Parameter: date: Date - The date to add.
Parameter: [type]: string - The trend type (defaults to "Unknown").
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

updateDate( elementId, date, count, [triggerRefresh] ):

Updates a date for a specific element ID, and refreshes the UI (if specified).
Fires: onUpdate
Parameter: elementId: string - The Heat.js element ID that should show the updated date.
Parameter: date: Date - The date to update.
Parameter: count: number - The count that should be shown.
Parameter: [type]: string - The trend type (defaults to "Unknown").
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

removeDates( elementId, dates, [triggerRefresh] ):

Removes an array of dates for a specific element ID, and refreshes the UI (if specified). If the dates already exist, their values are decreased by one.
Fires: onRemove
Parameter: elementId: string - The Heat.js element ID that should show the updated date.
Parameter: dates: Date[] - The dates to remove.
Parameter: [type]: string - The trend type (defaults to "Unknown").
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

removeDate( elementId, date, [triggerRefresh] ):

Removes a date for a specific element ID, and refreshes the UI (if specified). If the date already exists, its value is decreased by one.
Fires: onRemove
Parameter: elementId: string - The Heat.js element ID that should show the updated date.
Parameter: date: Date - The date to remove.
Parameter: [type]: string - The trend type (defaults to "Unknown").
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

clearDate( elementId, date, [triggerRefresh] ):

Clears a date for a specific element ID, and refreshes the UI (if specified).
Fires: onClear
Parameter: elementId: string - The Heat.js element ID that should show the updated date.
Parameter: date: Date - The date to clear.
Parameter: [type]: string - The trend type (defaults to "Unknown").
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

resetAll( [triggerRefresh] ):

Removes all the dates for all the elements, and refreshes the UI (if specified).
Fires: onReset
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

reset( elementId, [triggerRefresh] ):

Removes all the dates for a specific element ID, and refreshes the UI (if specified).
Fires: onReset
Parameter: elementId: string - The Heat.js element ID that should be updated.
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

export( elementId, exportType ):

Exports all the data for a specific element ID.
Fires: onExport
Parameter: elementId: string - The Heat.js element ID whose data should be exported.
Parameter: [exportType]: string - The export type to use (defaults to "csv", also accepts "json", "xml", and "txt").
Returns: Object - The Heat.js class instance.


Manage Instances:

refresh( elementId ):

Refreshes a Heat.js instance.
Fires: onRefresh
Parameter: elementId: string - The Heat.js element ID that should be refreshed.
Returns: Object - The Heat.js class instance.

refreshAll():

Refreshes all of the rendered Heat.js instances.
Fires: onRefresh
Returns: Object - The Heat.js class instance.

setYear( elementId, year ):

Sets the year to be displayed.
Fires: onSetYear
Parameter: elementId: string - The Heat.js element ID that should be updated.
Parameter: year: number - The year that should be shown.
Returns: Object - The Heat.js class instance.

setYearToHighest( elementId ):

Sets the year to the highest year available.
Fires: onSetYear
Parameter: elementId: string - The Heat.js element ID that should be updated.
Returns: Object - The Heat.js class instance.

setYearToLowest( elementId ):

Sets the year to the lowest year available.
Fires: onSetYear
Parameter: elementId: string - The Heat.js element ID that should be updated.
Returns: Object - The Heat.js class instance.

moveToPreviousYear( elementId ):

Moves the year back one.
Fires: onBackYear
Parameter: elementId: string - The Heat.js element ID that should be updated.
Returns: Object - The Heat.js class instance.

moveToNextYear( elementId ):

Moves the year forward one.
Fires: onNextYear
Parameter: elementId: string - The Heat.js element ID that should be updated.
Returns: Object - The Heat.js class instance.

moveToCurrentYear( elementId ):

Moves to the current year.
Fires: onSetYear
Parameter: elementId: string - The Heat.js element ID that should be updated.
Returns: Object - The Heat.js class instance.

getYear( elementId ):

Gets the year currently being displayed.
Parameter: elementId: string - The Heat.js element ID.
Returns: Object - The year being displayed (or null).

render( element, options ):

Renders a new map on a element using the options specified.
Parameter: element: Object - The element to convert to a heat map.
Parameter: options: Object - The options to use (refer to "Binding Options" documentation for properties).
Returns: Object - The Heat.js class instance.

renderAll():

Finds all new map elements and renders them.
Returns: Object - The Heat.js class instance.

switchView( elementId, viewName ):

Switches the view on an element to either Map, Chart, or Statistics.
Fires: onViewSwitch
Parameter: elementId: string - The Heat.js element ID.
Parameter: viewName: string - The name of the view to switch to (either "map", "chart", or "statistics").
Returns: Object - The Heat.js class instance.

switchType( elementId, type ):

Switches the selected trend type on an element.
Fires: onTypeSwitch
Parameter: elementId: string - The Heat.js element ID.
Parameter: type: string - The name of the type to switch to.
Returns: Object - The Heat.js class instance.

updateOptions( elementId, newOptions ):

Updates the original binding options for an element and refreshes it.
Fires: onRefresh
Parameter: elementId: string - The Heat.js element ID.
Parameter: newOptions: Object - The new options to want to apply to the element.
Returns: Object - The Heat.js class instance.

Destroying:

destroy( elementId ):

Reverts an element to its original state (without render attributes).
Fires: onDestroy
Parameter: elementId: string - The Heat.js element ID to destroy.
Returns: Object - The Heat.js class instance.

destroyAll():

Reverts all rendered elements to their original state (without render attributes).
Fires: onDestroy
Returns: Object - The Heat.js class instance.

Configuration:

setConfiguration( newConfiguration, [triggerRefresh] ):

Sets the specific configuration options that should be used.
Fires: onRefresh
Parameter: newConfiguration: Object - All the configuration options that should be set (refer to "Configuration Options" documentation for properties).
Parameter: [triggerRefresh]: boolean - States if the UI for each element should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

Additional Data:

getIds():

Returns an array of element IDs that have been rendered.
Returns: string[] - The element IDs that have been rendered.

getVersion():

Returns the version of Heat.js.
Returns: string - The version number.