onPaint method

  1. @override
void onPaint(
  1. Canvas canvas
)
override

Draws segment in series bounds.

Implementation

@override
void onPaint(Canvas canvas) {
  final SegmentProperties segmentProperties =
      SegmentHelper.getSegmentProperties(this);
  final WaterfallSeries<dynamic, dynamic> series =
      segmentProperties.series as WaterfallSeries<dynamic, dynamic>;
  CartesianChartPoint<dynamic> oldPaint;
  final Path linePath = Path();

  if (fillPaint != null) {
    (series.animationDuration > 0 &&
            segmentProperties
                    .stateProperties.renderingDetails.isLegendToggled ==
                false)
        ? animateRangeColumn(
            canvas,
            SeriesHelper.getSeriesRendererDetails(
                segmentProperties.seriesRenderer),
            fillPaint!,
            segmentRect,
            segmentProperties.oldPoint != null
                ? segmentProperties.oldPoint!.region
                : segmentProperties.oldRegion,
            animationFactor)
        : canvas.drawRRect(segmentRect, fillPaint!);
  }
  if (strokePaint != null) {
    final SeriesRendererDetails seriesRendererDetails =
        SeriesHelper.getSeriesRendererDetails(
            segmentProperties.seriesRenderer);
    (seriesRendererDetails.dashArray![0] != 0 &&
            seriesRendererDetails.dashArray![1] != 0)
        ? drawDashedLine(canvas, seriesRendererDetails.dashArray!,
            strokePaint!, segmentProperties.path)
        : (series.animationDuration > 0 &&
                segmentProperties
                        .stateProperties.renderingDetails.isLegendToggled ==
                    false)
            ? animateRangeColumn(
                canvas,
                SeriesHelper.getSeriesRendererDetails(
                    segmentProperties.seriesRenderer),
                strokePaint!,
                segmentRect,
                segmentProperties.oldPoint != null
                    ? segmentProperties.oldPoint!.region
                    : segmentProperties.oldRegion,
                animationFactor)
            : canvas.drawRRect(segmentRect, strokePaint!);
  }
  if (connectorLineStrokePaint != null &&
      segmentProperties.currentPoint!.overallDataPointIndex! > 0 == true) {
    oldPaint = SeriesHelper.getSeriesRendererDetails(
                segmentProperties.seriesRenderer)
            .dataPoints[
        segmentProperties.currentPoint!.overallDataPointIndex! - 1];
    _x1 = oldPaint.endValueRightPoint!.x;
    _y1 = oldPaint.endValueRightPoint!.y;
    if (segmentProperties.currentPoint!.isTotalSum! == true ||
        segmentProperties.currentPoint!.isIntermediateSum! == true) {
      _x2 = segmentProperties.currentPoint!.endValueLeftPoint!.x;
      _y2 = segmentProperties.currentPoint!.endValueLeftPoint!.y;
    } else {
      _x2 = segmentProperties.currentPoint!.originValueLeftPoint!.x;
      _y2 = segmentProperties.currentPoint!.originValueLeftPoint!.y;
    }
    if (series.animationDuration <= 0 ||
        animationFactor >=
            segmentProperties.stateProperties.seriesDurationFactor) {
      if (series.connectorLineSettings.dashArray![0] != 0 &&
          series.connectorLineSettings.dashArray![1] != 0) {
        linePath.moveTo(_x1, _y1);
        linePath.lineTo(_x2, _y2);
        drawDashedLine(canvas, series.connectorLineSettings.dashArray!,
            connectorLineStrokePaint!, linePath);
      } else {
        canvas.drawLine(
            Offset(_x1, _y1), Offset(_x2, _y2), connectorLineStrokePaint!);
      }
    }
  }
}