Documentation

This page documents the functionality of Heat.js, including its parameters, usage examples, and expected outputs. It serves as a reference for developers to implement and troubleshoot effectively.

Public API Functions

Explore this comprehensive list of all public API functions available in a Heat.js. Use these methods to integrate, customize, and extend your map functionality.

Example

const activeView = $heat.getActiveView( "heat-map" );

Manage Dates

addType( elementId, type, [triggerRefresh] )

Adds a new empty trend type.
Fires: onAddType
Parameter: elementId: string - The Heat.js element ID that should show the new trend type.
Parameter: type: string - The trend type.
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

removeType( elementId, type, [triggerRefresh] )

Removes an existing trend type.
Fires: onRemoveType
Parameter: elementId: string - The Heat.js element ID that should remove the existing trend type.
Parameter: type: string - The trend type.
Parameter: [triggerRefresh]: boolean - States if the UI for the element ID should be refreshed (defaults to true).
Returns: Object - The Heat.js class instance.

addDates( elementId, dates, [type], [triggerRefresh] )

Adds an array of dates for a specific element ID, and refreshes the UI (if specified). If the date already exists, its value is increased by one.
Fires: onAddDate
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, [type], [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: onAddDate
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, [type], [triggerRefresh] )

Updates a date for a specific element ID, and refreshes the UI (if specified).
Fires: onUpdateDate
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, [type], [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: onRemoveDate
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, [type], [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: onRemoveDate
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, [type], [triggerRefresh] )

Clears a date for a specific element ID, and refreshes the UI (if specified).
Fires: onClearDate
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.

Import/Export

import( elementId, [files] )

Imports data from an array of file objects (or opens the import dialog if files are not supplied).
Fires: onImport
Parameter: elementId: string - The Heat.js element ID whose data should be updated.
Parameter: [files]: Object - The file objects that the data should be imported from.
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 "json", also accepts "csv", "xml", "txt", "md", "html", "tsv", "yaml", and "toml").
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 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, bindingOptions )

Renders a new map on an element using the binding options specified.
Parameter: element: Object - The element to convert to a heat map.
Parameter: bindingOptions: Object - The binding options to use (see here 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", "line", "chart", "days", "months", or "color-ranges").
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.

updateBindingOptions( elementId, bindingOptions )

Updates the original binding options for an element and refreshes it.
Fires: onRefresh
Fires: onBindingOptionsUpdate
Parameter: elementId: string - The Heat.js element ID.
Parameter: bindingOptions: Object - The binding options to use (see here for properties).
Returns: Object - The Heat.js class instance.

getActiveView( elementId )

Gets the active view being displayed.
Parameter: elementId: string - The Heat.js element ID.
Returns: Object - The view being displayed.

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( configurationOptions, [triggerRefresh] )

Sets the specific configuration options that should be used.
Fires: onRefresh
Parameter: configurationOptions: Object - All the configuration options that should be set (see here 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.

setLocale( configurationTextOptions, [triggerRefresh] )

Sets the specific configuration options that should be used.
Fires: onRefresh
Parameter: configurationTextOptions: Object - All the configuration text options that should be set (see here 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.