Node / Charts · guide
Comparison chart (two panels)
Current Apexify.js 6.0.0 documentation for Comparison chart (two panels).
Renders two standalone charts into one PNG — chart1 and chart2 each call the same engines as createChart (createPieChart, createBarChart, …). Sub-chart buffers are uniformly scaled and centered inside their cells (contain — aspect preserved, letterboxed).
Implementation: createComparisonChart in lib-next/chart/impl/comparisonchart.ts.
Top-level (ComparisonChartOptions)
| Field | Default | Role |
|---|---|---|
dimensions.width | 2400 | Outer canvas width. |
dimensions.height | 1200 | Outer canvas height. |
dimensions.padding | top ~100, others ~60 | Outer margins around title + chart strip. |
layout | sideBySide | sideBySide | topBottom. |
spacing | 40 | Gap between cells (horizontal or vertical). |
appearance | — | ChartAppearanceExtended painted once on the outer canvas; merged into each child options.appearance when panels omit colours (mergeInheritedChartAppearance). |
generalTitle | optional | Banner heading spanning full width (text required when present). |
chart1, chart2 | required | ComparisonChartConfig each. |
Panel config (ComparisonChartConfig)
| Field | Role |
|---|---|
type | ComparisonChartType — pie, bar, horizontalBar, line, scatter, radar, polarArea, donut. |
data | Correct union for type (PieSlice[], BarChartData[], LineSeries[], …). |
options | Matching PieChartOptions, BarChartOptions, LineChartOptions, … |
title | Optional panel subtitle merged into options.labels.title ( text plus styling fields). |
barType | When type === 'bar', overrides BarChartOptions.type (standard, grouped, stacked, lollipop, waterfall). |
lineStyle, lineSmoothness | When type === 'line', applied to LineSeries missing lineStyle / smoothness. |
donut panels
Use type: 'donut'. Renderer maps to createPieChart and forces PieChartOptions.type = 'donut'. Put donutInnerRadius etc. inside options like a normal pie chart.
Layout maths
sideBySide: each cell width (availableWidth - spacing) / 2, full availableHeight.
topBottom: full availableWidth, cell height (availableHeight - spacing) / 2.
generalTitle reserves fontSize + 40 px below padding.top.
Cell sizing & padding
Each panel receives dimensions.width/height replaced by computed cell size. Inner padding is paddingForCell(...) — scales your requested padding (~850 px reference) so margins stay sane inside small cells.
Charts render native PNG size ≈ cell size, then drawChartImageContain fits without distortion.
Legend forwarding
Pie panels forward PieChartOptions.legends. Cartesian panels forward legend only when legend.entries is non-empty — supply entries explicitly when you need a legend inside comparison cells.
Example — sideBySide donut vs grouped bar
Example — topBottom lines with propagated lineStyle
Scenes
Use SceneLayer type: 'chartComparison' with the same options object (x, y, width, height, opacity placement fields per scene.ts).
Types
ComparisonChartOptions, ComparisonChartConfig, ComparisonLayout, ComparisonChartType live in lib-next/chart/impl/comparisonchart.ts (re-exported through apexify.js chart surface).