SmoothLineChart class

Animated line chart with touch tooltips, optional reference lines, gradient fill and configurable formatters.

SmoothLineChart(
  points: [
    [ChartPair(0, 0), ChartPair(1, 120), ChartPair(2, 80)],
  ],
  color: Colors.teal,
  yLabelFormatter: (v) => '\$${v.toStringAsFixed(0)}',
)
Inheritance

Constructors

SmoothLineChart({Key? key, required List<List<ChartPair>> points, Color? color, List<Color> colors = const [], bool isCurved = false, DateTime? endDate, double? verticalLineAt, double? horizontalLineAt, bool enableTouch = true, bool keepHorizontalLineInView = false, double amountBefore = 0, bool removeZeroEntries = false, bool cumulativeMode = false, String yLabelFormatter(double value)?, String xLabelFormatter(DateTime date)?, String tooltipFormatter(DateTime date, double value)?, bool showTooltipForAllLines = false, String lineTooltipLabelBuilder(int lineIndex)?, Duration animationDuration = const Duration(milliseconds: 2000), Curve animationCurve = Curves.fastLinearToSlowEaseIn})
const

Properties

amountBefore double
Starting y value before the first point (used to initialise the min/max bounds during the entrance animation).
final
animationCurve Curve
Entrance animation curve for chart reveal.
final
animationDuration Duration
Entrance animation duration for chart bounds and rendered lines.
final
color Color?
Primary line color. Defaults to ColorScheme.primary.
final
colors List<Color>
Per-line colors (overrides color when provided).
final
cumulativeMode bool
Show running total instead of per-day values.
final
enableTouch bool
final
endDate DateTime?
Reference date for the rightmost data point label.
final
hashCode int
The hash code for this object.
no setterinherited
horizontalLineAt double?
Draws a dashed horizontal line at this y value.
final
isCurved bool
final
keepHorizontalLineInView bool
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
lineTooltipLabelBuilder String Function(int lineIndex)?
Optional label builder used in multi-line tooltips. Defaults to "Line 1", "Line 2", ...
final
points List<List<ChartPair>>
One inner list = one line on the chart.
final
removeZeroEntries bool
Drop points where y == 0 (non-cumulative: skip, cumulative: flatten).
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showTooltipForAllLines bool
When true, shows one tooltip row per visible line at touched x. When false, only the first line tooltip is shown.
final
tooltipFormatter String Function(DateTime date, double value)?
Format the tooltip text. Defaults to "date + newline + value". Receives (date, value).
final
verticalLineAt double?
Draws a dashed vertical line at this x offset from the right.
final
xLabelFormatter String Function(DateTime date)?
Format a date label on the x-axis. Defaults to "Mar 15" style.
final
yLabelFormatter String Function(double value)?
Format a y-axis value. Defaults to compact number formatting.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited