paintSegments method

  1. @override
void paintSegments(
  1. PaintingContext context,
  2. Offset offset
)
inherited

Implementation

@override
void paintSegments(PaintingContext context, Offset offset) {
  if (parent != null && parent!.render != SeriesRender.normal) {
    return;
  }
  if (segments.isEmpty) {
    return;
  }

  if (canFindLinearVisibleIndexes) {
    if (visibleIndexes.isNotEmpty) {
      final int start = visibleIndexes[0];
      int end = visibleIndexes[1];
      final int segmentsCount = segments.length;
      // Internally added empty last segment for handling realtime data point
      // update as common. While rendering, ignored the last segment paint.
      final int lastIndex = segmentsCount - 1;
      if (end == lastIndex) {
        end = lastIndex - 1;
      }
      for (int i = start; i <= end && i > -1; i++) {
        if (i < segmentsCount) {
          final ChartSegment segment = segments[i];
          segment.animationFactor = segmentAnimationFactor;
          segment.onPaint(context.canvas);
        }
      }
    }
  } else {
    for (final int index in visibleIndexes) {
      final ChartSegment segment = segments[index];
      segment.animationFactor = segmentAnimationFactor;
      segment.onPaint(context.canvas);
    }
  }
}