Toolforge Docs
DocsBlock OutputsheatmapChart

heatmapChart

Visualize matrix data with color-coded cells for pattern identification.

Usage

Heat map chart

const chart = block.heatmapChart({
  title: 'Activity by Day and Hour',
  data: [
    { hour: '9AM', monday: 45, tuesday: 32, wednesday: 67 },
    { hour: '10AM', monday: 78, tuesday: 56, wednesday: 89 },
    { hour: '11AM', monday: 92, tuesday: 88, wednesday: 76 },
  ],
  xAxis: 'hour',
  yAxis: ['monday', 'tuesday', 'wednesday'],
})

Props

PropDescriptionTypeRequiredDefault
titleChart title displayed above the chartstringNoundefined
descriptionDescription text below the titlestringNoundefined
dataArray of data objects to visualizeT[]Yes
xAxisKey of the data object for x-axis (columns)keyof TYes
yAxisKeys of the data object for y-axis (rows)(keyof T)[]Yes
colorScaleColor scale for mapping valuesColorScaleNo'Oranges'
xAxisLabelLabel for the x-axisstringNoundefined
yAxisLabelLabel for the y-axisstringNoundefined
showXAxisWhether to display the x-axisbooleanNotrue
showYAxisWhether to display the y-axisbooleanNotrue
showTooltipWhether to display tooltips on hoverbooleanNotrue
showLegendWhether to display the color legendbooleanNotrue
showValuesWhether to display values on cellsbooleanNofalse
valueFormatFormat configuration for valuesValueFormatNoundefined

Returns

Returns a HeatmapChartOutput object that can be returned from a handler or passed to io.message().

Color Scales

Predefined Color Scales

Tool Forge supports D3 color scales:

type PredefinedColorScales =
  | 'Blues'
  | 'Greens'
  | 'Oranges'
  | 'Reds'
  | 'Purples'
  | 'Greys'
  | 'BuGn'
  | 'BuPu'
  | 'GnBu'
  | 'OrRd'
  | 'PuBu'
  | 'PuRd'
  | 'RdPu'
  | 'YlGn'
  | 'YlGnBu'
  | 'YlOrBr'
  | 'YlOrRd'
  | 'BrBG'
  | 'PiYG'
  | 'PRGn'
  | 'PuOr'
  | 'RdBu'
  | 'RdGy'
  | 'RdYlBu'
  | 'RdYlGn'
  | 'Spectral'
  | 'Viridis'
  | 'Inferno'
  | 'Magma'
  | 'Plasma'
  | 'Cividis'
  | 'Turbo'
  | 'Warm'
  | 'Cool'
  | 'Rainbow'
  | 'Sinebow'

Custom Interpolated Scale

colorScale: {
  min: 'blue',
  max: 'red',
}

Examples

Weekly activity heatmap

Weekly activity heatmap

return block.heatmapChart({
  title: 'User Activity',
  description: 'Sessions by day and hour',
  data: activityData,
  xAxis: 'hour',
  yAxis: ['monday', 'tuesday', 'wednesday', 'thursday', 'friday'],
  colorScale: 'Blues',
  showValues: true,
})

Correlation matrix

Correlation matrix

return block.heatmapChart({
  title: 'Feature Correlation',
  data: correlationData,
  xAxis: 'feature',
  yAxis: ['featureA', 'featureB', 'featureC', 'featureD'],
  colorScale: 'RdBu',
  valueFormat: { type: 'number', decimals: 2 },
  showValues: true,
})

Custom color scale

Custom color scale

return block.heatmapChart({
  title: 'Temperature Map',
  data: temperatureData,
  xAxis: 'location',
  yAxis: ['jan', 'feb', 'mar', 'apr', 'may', 'jun'],
  colorScale: {
    min: 'blue',
    max: 'red',
  },
})

With axis labels

With axis labels

return block.heatmapChart({
  title: 'Sales Performance',
  data: salesData,
  xAxis: 'region',
  yAxis: ['q1', 'q2', 'q3', 'q4'],
  xAxisLabel: 'Region',
  yAxisLabel: 'Quarter',
  colorScale: 'Greens',
  valueFormat: { type: 'currency', currency: 'USD', notation: 'compact' },
})

On this page