Toolforge Docs
DocsBlock OutputscomboChart

comboChart

Combine bar and line charts to visualize multiple data series with different representations.

Usage

Combo chart

const chart = block.comboChart({
  title: 'Revenue vs Growth Rate',
  data: [
    { month: 'Jan', revenue: 4000, growth: 12 },
    { month: 'Feb', revenue: 3000, growth: -8 },
    { month: 'Mar', revenue: 5000, growth: 25 },
  ],
  index: 'month',
  barSeries: {
    categories: ['revenue'],
    colors: ['blue'],
  },
  lineSeries: {
    categories: ['growth'],
    colors: ['emerald'],
  },
})

Props

PropDescriptionTypeRequiredDefault
titleChart title displayed above the chartstringNoundefined
descriptionDescription text below the titlestringNoundefined
dataArray of data objects to visualizeT[]Yes
indexKey of the data object for the x-axiskeyof TYes
barSeriesConfiguration for the bar seriesBarSeriesConfigYes
lineSeriesConfiguration for the line seriesLineSeriesConfigYes
xAxisLabelLabel for the x-axisstringNoundefined
showXAxisWhether to display the x-axisbooleanNotrue
showGridLinesWhether to display grid linesbooleanNotrue
showTooltipWhether to display tooltips on hoverbooleanNotrue
showLegendWhether to display the legendbooleanNotrue
startEndOnlyShow only start and end labels on x-axisbooleanNofalse
intervalTypeX-axis tick placement logic'equidistantPreserveStart' | 'preserveStartEnd'No'equidistantPreserveStart'

BarSeriesConfig

PropDescriptionTypeRequiredDefault
categoriesKeys of the data object for bar values(keyof T)[]Yes
colorsColors for the bar seriesChartColor[]No['blue']
yAxisLabelLabel for the bar y-axisstringNoundefined
showYAxisWhether to display the bar y-axisbooleanNotrue
stackTypeHow bars are stacked'default' | 'stacked'No'default'
valueFormatFormat configuration for bar valuesValueFormatNoundefined

LineSeriesConfig

PropDescriptionTypeRequiredDefault
categoriesKeys of the data object for line values(keyof T)[]Yes
colorsColors for the line seriesChartColor[]No['blue']
yAxisLabelLabel for the line y-axisstringNoundefined
showYAxisWhether to display the line y-axisbooleanNotrue
valueFormatFormat configuration for line valuesValueFormatNoundefined

Returns

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

Examples

Revenue with growth percentage

Combo chart

return block.comboChart({
  title: 'Monthly Performance',
  data: performanceData,
  index: 'month',
  barSeries: {
    categories: ['revenue'],
    colors: ['blue'],
    yAxisLabel: 'Revenue ($)',
    valueFormat: { type: 'currency', currency: 'USD' },
  },
  lineSeries: {
    categories: ['growthRate'],
    colors: ['emerald'],
    yAxisLabel: 'Growth (%)',
    valueFormat: { type: 'percentage' },
  },
})

Stacked bars with trend line

Stacked bars with trend line

return block.comboChart({
  title: 'Sales Analysis',
  data: salesData,
  index: 'quarter',
  barSeries: {
    categories: ['online', 'retail'],
    colors: ['blue', 'violet'],
    stackType: 'stacked',
  },
  lineSeries: {
    categories: ['target'],
    colors: ['amber'],
  },
})

Multiple lines with bars

Multiple lines with bars

return block.comboChart({
  title: 'Website Metrics',
  data: metricsData,
  index: 'week',
  barSeries: {
    categories: ['pageViews'],
    colors: ['gray'],
  },
  lineSeries: {
    categories: ['bounceRate', 'conversionRate'],
    colors: ['red', 'emerald'],
    valueFormat: { type: 'percentage' },
  },
})

On this page