drawRangeAnnotation method

  1. @visibleForTesting
void drawRangeAnnotation(
  1. CanvasWrapper canvasWrapper,
  2. PaintHolder<D> holder
)

Implementation

@visibleForTesting
void drawRangeAnnotation(CanvasWrapper canvasWrapper, PaintHolder<D> holder) {
  final data = holder.data;
  final viewSize = canvasWrapper.size;

  if (data.rangeAnnotations.verticalRangeAnnotations.isNotEmpty) {
    for (final annotation in data.rangeAnnotations.verticalRangeAnnotations) {
      final from = Offset(getPixelX(annotation.x1, viewSize, holder), 0);
      final to = Offset(
        getPixelX(annotation.x2, viewSize, holder),
        viewSize.height,
      );

      final rect = Rect.fromPoints(from, to);

      _rangeAnnotationPaint.color = annotation.color;

      canvasWrapper.drawRect(rect, _rangeAnnotationPaint);
    }
  }

  if (data.rangeAnnotations.horizontalRangeAnnotations.isNotEmpty) {
    for (final annotation
        in data.rangeAnnotations.horizontalRangeAnnotations) {
      final from = Offset(0, getPixelY(annotation.y1, viewSize, holder));
      final to = Offset(
        viewSize.width,
        getPixelY(annotation.y2, viewSize, holder),
      );

      final rect = Rect.fromPoints(from, to);

      _rangeAnnotationPaint.color = annotation.color;

      canvasWrapper.drawRect(rect, _rangeAnnotationPaint);
    }
  }
}