LineChart class
A customizable and animated line chart widget for Flutter.
The LineChart class allows you to plot multiple data series with options for custom tooltips and smooth animations when data points are added or removed.
Example usage:
LineChart(
elements: [
ChartGridLines(isVertical: false, count: 5),
ChartAxisLabels(
isVertical: true, count: 5, labelBuilder: (value) => value.toStringAsFixed(2),
),
ChartAxisLabels(
isVertical: false, count: 5, labelBuilder: (value) => value.toStringAsFixed(2),
),
ChartDataSeries(
data: [ChartData(x: 1.0, y: 2.0)],
color: Colors.blue,
),
ChartDataSeries(
data: [ChartData(x: 1.0, y: 4.0)],
color: Colors.red,
lineType: LineType.bezier,
),
],
tooltipBuilder: (context, dataPoints, dataColors) {
return YourTooltipWidget(
dataPoints: dataPoints,
dataColors: dataColors,
);
},
backgroundColor: Colors.white,
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- LineChart
Constructors
-
LineChart({required List<
ChartElement> elements, Widget tooltipBuilder(BuildContext, List<ChartData> , List<Color> )?, Duration animationDuration = const Duration(milliseconds: 500), ChartExtent domainExtent = const ChartExtent.tight(), ChartExtent rangeExtent = const ChartExtent(), Color backgroundColor = Colors.black, EdgeInsets padding = const EdgeInsets.all(32), MarkerSelectionStrategy? markerSelectionStrategy, Key? key}) -
Creates a LineChart widget.
const
Properties
- animationDuration → Duration
-
The duration of the animation when the chart updates.
final
- backgroundColor → Color
-
The background color of the chart.
final
- domainExtent → ChartExtent
-
The extent of the domain (x-axis) of the chart.
final
-
elements
→ List<
ChartElement> -
The list of elements to be rendered in the chart.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- markerSelectionStrategy → MarkerSelectionStrategy?
-
The strategy to use for selecting markers on the chart.
final
- padding → EdgeInsets
-
The padding around the chart to accommodate labels and other elements.
final
- rangeExtent → ChartExtent
-
The extent of the range (y-axis) of the chart.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
tooltipBuilder
→ Widget Function(BuildContext, List<
ChartData> , List<Color> )? -
A builder function to create custom tooltips for data points.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _LineChartState -
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