Skip to content
Apexify.jsDocs
Apexify.js version v5.4.5

Node / Charts · guide

Combo chart (bars + lines)

Current Apexify.js 6.0.0 documentation for Combo chart (bars + lines).

apexify.jsRuntime: nodeCURRENTSince 6.0.0

One Cartesian canvas combining bars (primary / left Y-axis) with lines (default secondary / right Y-axis).

SOURCEtypescript
typescript
Studio
const buf = await painter.createComboChart(options);

Implementation: createComboChart in lib-next/chart/impl/combochart.ts — types ComboChartOptions, ComboLineSeries, ComboBarsType, ComboChartOpacity.


When to use combo vs comparison

ApproachUse when
createComboChartBars and lines share one plot region, aligned X, dual Y scales (e.g. revenue bars + margin % line).
createComparisonChartTwo independent charts (maybe different types) in two cells.

Required inputs

FieldTypeNotes
barsBarChartData[]Same rows as createChart('bar', …): label, xStart/xEnd, value or values segments.
linesComboLineSeries[]Extends LineSeries (impl/linechart.ts) with yAxis?: 'primary' | 'secondary' (default secondary) and optional opacity.

Bar modes (barsType)

ComboBarsType: standard (default) · grouped · stacked.

ModeNeedsScaling
standardBarChartData.value per categoryColumn heights from value.
groupedvalues: BarSegment[] per rowSide-by-side segments (barStyle.groupSpacing default 10).
stackedvaluesSummed stack height drives primary Y max.

Axes (axes)

KeyRole
axes.xAxisConfig — labels, range, values, tick toggles (same type as line chart).
axes.yPrimary (left) scale for bars — tick colour may inherit first bar colour when color omitted.
axes.ySecondarySecondary (right) scale for lines — colour may inherit **first line using yAxis: 'secondary'.

Force ComboLineSeries.yAxis: 'primary' when a line must align with bar magnitudes.


Opacity (opacity)

ComboChartOpacity multiplies globalAlpha while drawing layers:

bars, lines, grid, primaryAxis, secondaryAxis, xAxis, chartTitle, legend, barLabels, valueLabels, pointLabels.


Legend & labels

legend matches cartesian charts (fit, stretch, maxWidth, entries, textStyle, …) — see Shared appearance.

labels blocks:

BlockRole
titleChart heading (textStyle, gradients).
barLabelDefaultsshow, fontSize, defaultPosition.
valueLabelDefaultsColumn value chips.
pointLabelDefaultsLine point captions (position: top/bottom/left/right).

Grid & bar styling

grid: show, color, width.

barStyle: minWidth, groupSpacing, opacity, shadow, stroke — defaults merged before per-bar overrides.

secondaryYAxis: show?: boolean — defaults on when any line uses secondary.


Dimensions & width heuristic

Combo recomputes canvas width from X span when categories justify it (comboResponsiveWidth). For dashboards with fixed slots, set dimensions.width explicitly (same guidance as vertical bar charts).


Example — bars + secondary trend line

SOURCEtypescript
typescript
Studio
await painter.createComboChart({  dimensions: { width: 920, height: 520 },  barsType: 'standard',  bars: [    { label: 'Jan', value: 120, xStart: 0, xEnd: 1, color: '#6366f1' },    { label: 'Feb', value: 160, xStart: 1, xEnd: 2, color: '#818cf8' },    { label: 'Mar', value: 140, xStart: 2, xEnd: 3, color: '#a5b4fc' },  ],  lines: [    {      label: 'Margin %',      yAxis: 'secondary',      color: '#f97316',      lineWidth: 3,      marker: { type: 'circle', size: 8, show: true },      data: [        { x: 0.5, y: 18 },        { x: 1.5, y: 22 },        { x: 2.5, y: 19 },      ],    },  ],  axes: {    x: { label: 'Month', range: { min: 0, max: 3 } },    y: { label: 'Revenue (k)', range: { min: 0, max: 200 } },    ySecondary: { label: 'Margin %', range: { min: 0, max: 30 } },  },  grid: { show: true, color: '#e2e8f0' },  legend: { position: 'top', fontSize: 13 },  labels: {    title: { text: 'Revenue vs margin', fontSize: 22 },  },});

Example — grouped bars + primary-aligned line

SOURCEtypescript
typescript
Studio
await painter.createComboChart({  dimensions: { width: 960, height: 540 },  barsType: 'grouped',  bars: [    {      label: 'East',      xStart: 0,      xEnd: 1,      values: [        { value: 40, color: '#38bdf8' },        { value: 55, color: '#34d399' },      ],    },    {      label: 'West',      xStart: 1,      xEnd: 2,      values: [        { value: 48, color: '#38bdf8' },        { value: 42, color: '#34d399' },      ],    },  ],  lines: [    {      label: 'Total goal',      yAxis: 'primary',      lineStyle: 'dashed',      color: '#94a3b8',      data: [        { x: 0.5, y: 95 },        { x: 1.5, y: 95 },      ],    },  ],  axes: {    x: { range: { min: 0, max: 2 } },    y: { label: 'Units', range: { min: 0, max: 120 } },  },  legend: {    entries: [      { label: 'SKU A', color: '#38bdf8' },      { label: 'SKU B', color: '#34d399' },      { label: 'Total goal', color: '#94a3b8' },    ],  },});

Next steps