Skip to content
Get started
Menu
Get started

Chart layout

Choose the chart from the customer’s question. These are customer-facing spending summaries, not an operational dashboard.

Your app loads the data, chooses the ChartState, and supplies every amount, headline, delta and verdict.

Spending headline, weekly bars and method totals in a phone viewport.Spending headline, weekly bars and method totals in a phone viewport.
Spending in context
Spending headline, weekly bars and method totals in a phone viewport at 200 percent text.
200% text

The full-screen phone captures show one viewport. Transaction rows and, at 200% text, part of the method breakdown continue below it.

Question Component Watch out for
Going up or down? Line A zoomed axis emphasizes change, so read the tick labels.
How much each? Bar Starts at zero; small differences may disappear.
Breakdown of a total? Meter One snapshot, up to five categories.
Quick trend? Sparkline No precise values or axes.

The container owns height: 180 for compact plots, 320 for featured plots. Meter charts use intrinsic height. Show the host headline first. On a history screen the list comes first and the spending summary follows it; the gallery specimen “In context: spending above history” shows the chart module itself. At most three plots belong in one row, each around 200px or wider; stack them on phones.

Row(children: [
Expanded(child: ChartModule(
title: 'Weekly spending',
state: ChartState.ready,
headline: const Money.idr(1080000),
headlineCaption: 'Settled',
chart: PaymentBarChart(points: weeklyPoints),
)),
const SizedBox(width: 16),
Expanded(child: ChartModule(
title: 'Trend',
state: ChartState.ready,
chart: PaymentLineChart(points: weeklyPoints),
)),
]);

Choose loading before error, error before empty, then ready. ChartModule keeps the plot height stable across these states; the headline is outside the plot. Error and empty messages scroll at large text so the retry action remains reachable.

Line and bar charts show one exact value at rest: the latest settled period is selected, with a guide line up to a label above the plot (“29 Okt · Rp420.000”). Tap or drag to read another period. The y-axis gutter grows with its scaled labels, so “Rp600K” never touches the plot at 200%. Above 1.5× text the module caps the plot at ChartModule.compactHeight, so the rows under a chart stay on the first screen of a small phone.

Pending uses dashed/outlined marks. Unknown uses dotted/hatched marks. Missing data leaves a gap. Only settled values enter the generated lowest/highest/latest summary. Headlines are host-provided Money values; the kit never computes totals. The meter legend formats the selected unit: money, percent or number.

Give periods short labels and qualify a headline as settled when needed. Keep currencies consistent. Use compact formatting for axes only, never a payment confirmation.

The chart summary announces the same latest amount the label shows, so nothing depends on selection. At narrow widths, fewer visual axis labels preserve space. Supply a complete semanticLabel when your host needs additional context.

ChartModule

class ChartModule extends StatelessWidget · lib/src/charts/charts.dart

A chart section with stable loading, empty and error states.

ParameterTypeDefaultDescription
title:requiredString—Title.
state:requiredChartState—State.
chart:Widget?—Chart.
headline:Money?—Host-provided amount. The kit never computes a headline total.
headlineCaption:String?—Headline Caption.
showHeadline:booltrueShow Headline.
delta:String?—Delta.
deltaTone:StatusToneStatusTone.neutralDelta Tone.
height:double?compactHeightHeight.
emptyTitle:String?—Empty Title.
emptyMessage:String?—Empty Message.
errorMessage:String?—Error Message.
onRetry:FutureOr<void> Function()?—On Retry.
trailing:Widget?—Trailing.

ChartState

enum ChartState · lib/src/charts/chart_models.dart

Host-owned chart loading state.

ValueDescription
loadingFetch in progress.
readyData available.
emptyNo data available.
errorFetch failed.

ChartPoint

class ChartPoint · lib/src/charts/chart_models.dart

One period reading, with missing values distinct from zero.

ParameterTypeDefaultDescription
label:requiredString—Visible period or category label.
value:Money?—Null is missing data, never zero.
status:ChartPointStatusChartPointStatus.settledSettlement state; never encoded by a series color.
spokenLabel:String?—Optional expanded period name for spoken summaries.
measure:num?—Host-computed quantity; null is missing data.

ChartPointStatus

enum ChartPointStatus · lib/src/charts/chart_models.dart

Settlement state of a reading.

ValueDescription
settledConfirmed reading.
pendingAwaiting confirmation.
unknownNot yet confirmed.

MeterSegment

class MeterSegment · lib/src/charts/chart_models.dart

One non-negative category in a meter.

ParameterTypeDefaultDescription
label:requiredString—Visible period or category label.
value:Money?—Money reading when using currency units.
status:ChartPointStatusChartPointStatus.settledSettlement state; never encoded by a series color.
measure:num?—Host-computed non-negative quantity.

The headline region derives from the scaled amount line, caption line and section gap. Named series share period labels and one scale:

PaymentLineChart(series: const [
PaymentChartSeries(label: 'This month', points: [
ChartPoint(label: 'Week 1', value: Money.idr(350000)),
]),
PaymentChartSeries(label: 'Last month', points: [
ChartPoint(label: 'Week 1', value: Money.idr(280000)),
]),
]);