LineChart.fromData constructor

LineChart.fromData({
  1. Key? key,
  2. required List<double> data,
  3. List<String> labels = const [],
  4. Color? color,
  5. bool showArea = true,
  6. bool showDots = true,
  7. bool showGrid = true,
  8. double height = 200,
  9. bool animate = true,
  10. double strokeWidth = 2.5,
})

Convenience constructor — accepts a plain List<double> and converts each value to a ChartPoint using its index as the x coordinate.

Implementation

factory LineChart.fromData({
  Key? key,
  required List<double> data,
  List<String> labels = const [],
  Color? color,
  bool showArea = true,
  bool showDots = true,
  bool showGrid = true,
  double height = 200,
  bool animate = true,
  double strokeWidth = 2.5,
}) =>
    LineChart(
      key: key,
      points: <ChartPoint>[
        for (int i = 0; i < data.length; i++)
          ChartPoint(i.toDouble(), data[i]),
      ],
      labels: labels,
      color: color,
      showArea: showArea,
      showDots: showDots,
      showGrid: showGrid,
      height: height,
      animate: animate,
      strokeWidth: strokeWidth,
    );