onPaint method

  1. @override
void onPaint(
  1. PaintingContext context,
  2. Offset offset,
  3. SfChartThemeData chartThemeData,
  4. ThemeData themeData,
)

Called to customize each behaviors with given context at the given offset.

Implementation

@override
void onPaint(PaintingContext context, Offset offset,
    SfChartThemeData chartThemeData, ThemeData themeData) {
  final RenderBehaviorArea? parent = parentBox as RenderBehaviorArea?;
  if (parent == null) {
    return;
  }
  final RenderCartesianAxes? cartesianAxes = parent.cartesianAxes;
  if (cartesianAxes == null) {
    return;
  }
  if (_zoomingRect != Rect.zero && _rectPath != null) {
    Color? fillColor = selectionRectColor;
    if (fillColor != null &&
        fillColor != Colors.transparent &&
        fillColor.opacity == 1) {
      fillColor = fillColor.withOpacity(0.3);
    }
    final Paint fillPaint = Paint()
      ..color =
          (fillColor ?? cartesianAxes.chartThemeData.selectionRectColor)!
      ..style = PaintingStyle.fill;
    context.canvas.drawRect(_zoomingRect, fillPaint);
    final Paint strokePaint = Paint()
      ..isAntiAlias = true
      ..color = (selectionRectBorderColor ??
          cartesianAxes.chartThemeData.selectionRectBorderColor)!
      ..strokeWidth = selectionRectBorderWidth
      ..style = PaintingStyle.stroke;

    if (strokePaint.color != Colors.transparent &&
        strokePaint.strokeWidth > 0) {
      final List<double> dashArray = <double>[5, 5];
      drawDashes(context.canvas, dashArray, strokePaint, path: _rectPath);
    }

    final Offset plotAreaOffset =
        (parent.parentData! as BoxParentData).offset;
    // Selection zooming tooltip rendering
    _drawTooltipConnector(
        cartesianAxes,
        parent,
        _zoomingRect.topLeft,
        _zoomingRect.bottomRight,
        context.canvas,
        parent.paintBounds,
        plotAreaOffset);
  }
}