LineChart class
A scrollable line chart widget with smooth animations and extensive customization options.
LineChart displays one or more data series as lines on a chart with horizontal scrolling capability. It supports smooth animations, custom styling, and various data visualization features.
Example:
LineChart(
data: LineChartData(
labels: [
ChartLabel(label: 'Jan'),
ChartLabel(label: 'Feb'),
ChartLabel(label: 'Mar'),
],
lines: [
ChartLine(
label: 'Revenue',
color: Colors.blue,
strokeWidth: 2.0,
points: [
DataPoint(labelIndex: 0, value: 1000),
DataPoint(labelIndex: 1, value: 1500),
DataPoint(labelIndex: 2, value: 1200),
],
),
],
),
visibleLabels: 3,
smooth: true,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- LineChart
Constructors
- LineChart({Key? key, required LineChartData data, int visibleLabels = 3, int? initialIndex, SelectedPointerStyle? selectedPointerStyle, GridLinesStyle? gridLinesStyle, LineLabelStyle? lineLabelStyle, DataMarkerStyle? dataMarkerStyle, ZeroLineStyle zeroLineStyle = const ZeroLineStyle(), XAxisStyle xAxisStyle = const XAxisStyle(), XAxisLabelStyle xAxisLabelStyle = const XAxisLabelStyle(), YAxisStyle yAxisStyle = const YAxisStyle(), LabelTransformer labelTransformer = defaultLabelTransformer, MissingDataBehavior missingDataBehavior = MissingDataBehavior.zero, YAxisAnimationConfig yAxisAnimationConfig = YAxisAnimationConfig.smooth, ScrollPhysicsConfig scrollPhysicsConfig = ScrollPhysicsConfig.smooth, OnVisibleRangeChanged? onVisibleRangeChanged, OnSelectedChanged? onSelectedChanged, bool smooth = false, bool selectOnTap = false})
-
const
Properties
- data → LineChartData
-
The data to display in the chart.
final
- dataMarkerStyle → DataMarkerStyle?
-
Style for the data point markers.
final
- gridLinesStyle → GridLinesStyle?
-
Style for the vertical grid lines.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- initialIndex → int?
-
Initial index to display when the chart loads.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- labelTransformer → LabelTransformer
-
Function to transform numeric values to strings for line labels.
Defaults to defaultLabelTransformer.
final
- lineLabelStyle → LineLabelStyle?
-
Style for the data value labels displayed on the chart.
final
- missingDataBehavior → MissingDataBehavior
-
How to handle missing data points. Defaults to MissingDataBehavior.zero.
final
- onSelectedChanged → OnSelectedChanged?
-
Callback when the selected data point changes.
final
- onVisibleRangeChanged → OnVisibleRangeChanged?
-
Callback when the visible range of data points changes.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollPhysicsConfig → ScrollPhysicsConfig
-
Configuration for scroll snap physics.
final
- selectedPointerStyle → SelectedPointerStyle?
-
Style for the selected pointer vertical line.
final
- selectOnTap → bool
-
final
- smooth → bool
-
Whether to draw smooth curves between points. Defaults to false.
final
- visibleLabels → int
-
Number of data points visible at once. Defaults to 3.
final
- xAxisLabelStyle → XAxisLabelStyle
-
Style for the X-axis labels.
final
- xAxisStyle → XAxisStyle
-
Style for the X-axis line.
final
- yAxisAnimationConfig → YAxisAnimationConfig
-
Configuration for Y-axis range animations.
final
- yAxisStyle → YAxisStyle
-
final
- zeroLineStyle → ZeroLineStyle
-
Style for the zero line (horizontal line at y=0).
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< LineChart> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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