BarChartData constructor

BarChartData({
  1. List<BarChartGroupData>? barGroups,
  2. double? groupsSpace,
  3. BarChartAlignment? alignment,
  4. FlTitlesData? titlesData,
  5. BarTouchData? barTouchData,
  6. double? maxY,
  7. double? minY,
  8. double? baselineY,
  9. FlGridData? gridData,
  10. FlBorderData? borderData,
  11. RangeAnnotations? rangeAnnotations,
  12. Color? backgroundColor,
  13. ExtraLinesData? extraLinesData,
})

BarChart draws some barGroups and aligns them using alignment, if alignment is BarChartAlignment.center, you can define groupsSpace to apply space between them.

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 minX, and maxY values.

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 barTouchData to customize touch behaviors and responses.

Horizontal lines are drawn with extraLinesData. Vertical lines will not be painted if received. Please see issue #1149 (https://github.com/imaNNeo/fl_chart/issues/1149) for vertical lines.

Implementation

BarChartData({
  List<BarChartGroupData>? barGroups,
  double? groupsSpace,
  BarChartAlignment? alignment,
  FlTitlesData? titlesData,
  BarTouchData? barTouchData,
  double? maxY,
  double? minY,
  super.baselineY,
  FlGridData? gridData,
  super.borderData,
  RangeAnnotations? rangeAnnotations,
  super.backgroundColor,
  ExtraLinesData? extraLinesData,
})  : barGroups = barGroups ?? const [],
      groupsSpace = groupsSpace ?? 16,
      alignment = alignment ?? BarChartAlignment.spaceEvenly,
      barTouchData = barTouchData ?? BarTouchData(),
      super(
        titlesData: titlesData ??
            const FlTitlesData(
              topTitles: AxisTitles(),
            ),
        gridData: gridData ?? const FlGridData(),
        rangeAnnotations: rangeAnnotations ?? const RangeAnnotations(),
        touchData: barTouchData ?? BarTouchData(),
        extraLinesData: extraLinesData ?? const ExtraLinesData(),
        minX: 0,
        maxX: 1,
        maxY: maxY ?? double.nan,
        minY: minY ?? double.nan,
      );