Skip to content
Get started
Menu
Get started

Line chart

PaymentLineChart shows direction across ordered periods, with gaps for missing amounts.

Spending over time with labelled values and comparison periods.Spending over time with labelled values and comparison periods.
Line chart
Spending over time with labelled values and comparison periods at 200 percent text.
200% text
example/lib/screens/gallery_charts.dart
PaymentLineChart(points: points);

Use onSelectionChanged to receive each new selected period index and null on return to rest. On touch, a scrub reports null when the finger lifts. The index addresses points or the series’ shared periods. Repeated events within one period do not notify or rebuild. New periods reset selection silently. The kit plays no haptics; add them in your callback if you want them.

import 'package:flutter/services.dart';
PaymentLineChart(
points: points,
onSelectionChanged: (i) {
if (i != null) HapticFeedback.selectionClick();
},
);

Variants: one to three series, money, percentage, number.

Settled marks are solid, pending marks are outlined or dashed, and unknown marks are hatched or dotted. A null point is a gap, never zero. Use one currency per chart. Bar and meter amounts must be non-negative; line charts accept negative amounts.

Use named series with identical period labels and ordering. Line and bar charts accept up to three series; sparklines accept two. Series use an accent ramp and distinct dash patterns, never status tones. All series share a scale. showLegend controls the legend for multiple series.

axis and grid each take x, y, both or none. Colors come from named PaymentChartSeries. unit is money, percent or number.

Use a line for direction, bars for period comparisons, a meter for category proportions and a sparkline beside a KPI. Percent and number units read measure; money reads value. A measure of 45 means 45 percent. Missing readings remain gaps.

The latest settled period is selected when the chart appears. One label in a fixed band above the plot gives its exact amount, such as “29 Okt · Rp420.000” in tabular figures, and a guide line runs from the point or bar top up to that label. Tap a period to select it, and tap it again to return to the latest. Drag across the plot to scrub: the label follows your finger and returns to the latest when you lift it. With a mouse, hover selects and moving away returns to the latest. The band never changes height, so nothing below the chart moves. A multi-series chart gives each series one line, “29 Okt · Bulan ini · Rp420.000”. When any period’s series name and value don’t fit on one line, as at 200% text on a phone or for a pending period’s longer value, every series shows its name with the value under it. The name wraps to at most two lines, then ends in an ellipsis; a realistic name fits in two. Inside ChartModule the plot area grows by those extra lines, so the plot keeps its height. With inspectable: false the label still shows the latest value and the chart takes no gestures. Series of 12 points or fewer draw a small ring on every settled point; longer series ring the last point. There is no permanent label on every point: those collide at 200% text and in Indonesian.

Line chart at rest with the latest point selected and its exact amount above the plot.
At rest

Sparklines can opt into inspectable, giving a 48 dp target. Press and hold to read a value. Meter onSegmentPressed activates full-width legend rows; the painted bar takes no taps.

Breaking: MeterSegment.color is removed. Use the semantic category ramp. MeterSegment.value is optional; supply measure for numeric units. Point value and chart points are optional when using measures or series.

PaymentChartSeries

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

Named points sharing the same periods with the other series.

ParameterTypeDefaultDescription
label:requiredString—Legend and spoken name.
points:requiredList<ChartPoint>—One point per period.

PaymentChartAxis

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

Axes to label or grid.

ValueDescription
xHorizontal axis.
yVertical axis.
bothBoth axes.
noneNeither axis.

PaymentChartUnit

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

How a chart reads its values.

ValueDescription
moneyCurrency amounts.
percentHost-computed percentages, where 45 means 45 percent.
numberPlain counts or quantities.

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.

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.

Parameters: points, series, zeroBased, inspectable, axis, grid, showLegend, unit, semanticLabel, onSelectionChanged.

Situation Variant / composition Payment example
Spending over time one series Use an explicitly labeled timeline; add series only for a real comparison.

Use Bar chart for month-versus-month categories.

A missing value leaves a gap. Settled, pending and unknown readings keep distinct line or mark patterns; none is inferred from another reading.

Do: Use an explicitly labeled timeline; add series only for a real comparison.

Don’t: Hide missing data by inserting zero.

Use short period labels and a clear title. Explain what is settled in the headline caption. The host supplies the headline; the kit never adds plotted values to produce a customer total.

A single generated summary announces settled lowest, highest and latest amounts plus pending, unknown and missing counts. Supply semanticLabel for a host-authored equivalent. The value label is supplemental: the summary already announces the latest amount, and selection has no keyboard focus target. Status is conveyed by shape and words as well as color.

PaymentLineChart

class PaymentLineChart extends StatefulWidget · lib/src/charts/charts.dart

Trends across periods, with gaps for missing readings.

ParameterTypeDefaultDescription
points:List<ChartPoint>const []Single-series points; leave empty when providing series.
series:List<PaymentChartSeries>const []Named series with matching period labels; at most three.
unit:PaymentChartUnitPaymentChartUnit.moneyWhich reading to display and announce.
axis:PaymentChartAxisPaymentChartAxis.bothAxes whose labels are visible.
grid:PaymentChartAxisPaymentChartAxis.yAxes whose grid rules are visible.
showLegend:booltrueWhether to show the series legend.
zeroBased:boolfalseWhether the scale includes zero.
inspectable:booltrueWhether pointer gestures select a reading.
semanticLabel:String?—Host-authored replacement for the generated summary.
onSelectionChanged:ValueChanged<int?>?—Called with the index of the period a person's tap, drag or hover selects, and with null when the chart returns to rest. The index addresses points, or the periods all series share. Not called when new points or series reset the selection. Use it to play a selection haptic (D73); the kit plays none. On touch, a drag returns to rest when the finger lifts, and a second tap on the same period clears it.
  • Chart layout for height, state and headline composition.
  • Money for precise and compact amounts.