Sales report: dynamic columns and charts
Monthly sales by region and product (Finnish locale, A4 landscape, about 6 pages). Page 1 opens with two charts above the table; a product-mix donut and the notes follow the table onto the last page. The month columns are decided by the data: the table uses "columnsFrom": "report.columns", so a report for January–March has 3 month columns and one for January–October has 10, with no template change.
liuska render -t examples/sales-report/template.json -d examples/sales-report/data.json -o sales.pdf
Things to look at:
header: logo image, title and period bound from data, a rule.footer:Page {{page}} of {{pages}}.- KPI strip with
currency:"EUR"andpercent:1filters, formatted forfi-FI(7 916 400,47 €). - The KPI strip repeats on every page:
kpiBoxand the six KPI texts are children of one group,kpis, with"repeat": "all". The children's coordinates are relative to the group (x: 30, y: 84), sokpiTotalis atx: 12, y: 17rather than42, 101. On page 1 the strip sits under the header as before. On pages 2 and later it is drawn at the same place, and the table continues below it,repeatGap(8 pt) under the strip, instead of at the top of the body area. See docs/templates.md, "Repeating elements". - Combo chart
revByMonth: bars for this year's revenue, a line for last year ("kind": "line"on the series), and the margin % as a second line on the right axis ("axis": "right",axes.y2withpercent:0ticks). Data:report.byMonth, one row per month; the monthly revenues add up to the table total. Months are ISO dates ("2026-01-01") named bycategory.format: "date:\"Jan\"", which givestammi,helmi, … in fi-FI. The series labels are bindings ("{{report.year}}","{{report.previousYear}}"), so the legend follows the data. - Horizontal bar chart
revByRegion("horizontal": true,dataLabels), fromreport.byRegion, sorted largest first in the data. - The table's top is anchored under
revByMonth, so it starts 12 pt under the charts. Charts are fixed boxes and never paginate. - Donut
productMix("dataLabels": "percent": each slice shows its share) is anchored under the table, so it moves to wherever the table ends. The notes title is anchored to the donut's top edge, so the donut and the notes always land on the same page. If the donut does not fit under the last row, it moves to the top of the next page and the notes go with it. report.columnsindata.jsonsets each column'skey,header,width(82,"*",46),alignandformat(number:0).totalsfills the label column and the row-total column. Month totals are not listed, because their keys aren't known until the data arrives (see docs/templates.md, "Totals with dynamic columns").