generateBelowBarPath method

  1. @visibleForTesting
Path generateBelowBarPath(
  1. Size viewSize,
  2. LineChartBarData barData,
  3. Path barPath,
  4. List<AFlSpot> barSpots,
  5. PaintHolder<LineChartData> holder, {
  6. bool fillCompletely = false,
})

it generates below area path using a copy of barPath, if cutOffY is provided by the BarAreaData, it cut the area to the provided cutOffY value, if fillCompletely is true, the cutOffY will be ignored, and a completely filled path will return,

Implementation

@visibleForTesting
Path generateBelowBarPath(
  Size viewSize,
  LineChartBarData barData,
  Path barPath,
  List<AFlSpot> barSpots,
  PaintHolder<LineChartData> holder, {
  bool fillCompletely = false,
}) {
  final belowBarPath = Path.from(barPath);

  /// Line To Bottom Right
  var x = getPixelX(barSpots[barSpots.length - 1].x, viewSize, holder);
  double y;
  if (!fillCompletely && barData.belowBarData.applyCutOffY) {
    y = getPixelY(barData.belowBarData.cutOffY, viewSize, holder);
  } else {
    y = viewSize.height;
  }
  belowBarPath.lineTo(x, y);

  /// Line To Bottom Left
  x = getPixelX(barSpots[0].x, viewSize, holder);
  if (!fillCompletely && barData.belowBarData.applyCutOffY) {
    y = getPixelY(barData.belowBarData.cutOffY, viewSize, holder);
  } else {
    y = viewSize.height;
  }
  belowBarPath.lineTo(x, y);

  /// Line To Top Left
  x = getPixelX(barSpots[0].x, viewSize, holder);
  y = getPixelY(barSpots[0].y, viewSize, holder);
  belowBarPath
    ..lineTo(x, y)
    ..close();

  return belowBarPath;
}