LineChartData constructor

LineChartData({
  1. List<LineChartBarData> lineBarsData = const [],
  2. List<BetweenBarsData> betweenBarsData = const [],
  3. FlTitlesData titlesData = const FlTitlesData(),
  4. ExtraLinesData? extraLinesData = const ExtraLinesData(),
  5. LineTouchData lineTouchData = const LineTouchData(),
  6. List<ShowingTooltipIndicators> showingTooltipIndicators = const [],
  7. FlGridData? gridData = const FlGridData(),
  8. FlBorderData? borderData,
  9. RangeAnnotations? rangeAnnotations = const RangeAnnotations(),
  10. double? minX,
  11. double? maxX,
  12. double? baselineX,
  13. double? minY,
  14. double? maxY,
  15. double? baselineY,
  16. FlClipData? clipData = const FlClipData.none(),
  17. Color? backgroundColor,
})

LineChart draws some lines in various shapes and overlaps them. lines are defined in lineBarsData, sometimes you need to fill space between two bars with a color or gradient, you can use betweenBarsData to achieve that.

It draws some titles on left, top, right, bottom sides per each axis number, you can modify titlesData to have your custom titles, also you can define the axis title (one text per axis) for each side using axisTitleData, you can restrict the y axis using minY and maxY value, and restrict x axis using minX and maxX.

It draws a color as a background behind everything you can set it using backgroundColor, then a grid over it, you can customize it using gridData, and it draws 4 borders around your chart, you can customize it using borderData.

You can annotate some regions with a highlight color using rangeAnnotations.

You can modify lineTouchData to customize touch behaviors and responses.

you can show some tooltipIndicators (a popup with an information) on top of each LineChartBarData.spots using showingTooltipIndicators, just put line indicator number and spots indices you want to show it on top of them.

LineChart draws some horizontal or vertical lines on above or below of everything, they are useful in some scenarios, for example you can show average line, you can fill extraLinesData property to have your extra lines.

clipData forces the LineChart to draw lines inside the chart bounding box.

Implementation

LineChartData({
  this.lineBarsData = const [],
  this.betweenBarsData = const [],
  super.titlesData = const FlTitlesData(),
  super.extraLinesData = const ExtraLinesData(),
  this.lineTouchData = const LineTouchData(),
  this.showingTooltipIndicators = const [],
  super.gridData = const FlGridData(),
  super.borderData,
  super.rangeAnnotations = const RangeAnnotations(),
  double? minX,
  double? maxX,
  super.baselineX,
  double? minY,
  double? maxY,
  super.baselineY,
  super.clipData = const FlClipData.none(),
  super.backgroundColor,
}) : super(
        touchData: lineTouchData,
        minX: minX ?? double.nan,
        maxX: maxX ?? double.nan,
        minY: minY ?? double.nan,
        maxY: maxY ?? double.nan,
      );