onPaint method
Draws segment in series bounds.
Implementation
@override
void onPaint(Canvas canvas) {
if (_seriesRenderer._isSelectionEnable) {
final SelectionBehaviorRenderer? selectionBehaviorRenderer =
_seriesRenderer._selectionBehaviorRenderer;
selectionBehaviorRenderer?._selectionRenderer?._checkWithSelectionState(
_seriesRenderer._segments[currentSegmentIndex!],
_seriesRenderer._chart);
}
final Rect rect = _calculatePlotOffset(
_seriesRenderer._chartState!._chartAxis._axisClipRect,
Offset(_seriesRenderer._xAxisRenderer!._axis.plotOffset,
_seriesRenderer._yAxisRenderer!._axis.plotOffset));
/// Draw spline series
if (_series.animationDuration > 0 &&
!_seriesRenderer._reAnimate &&
_seriesRenderer._chartState!._widgetNeedUpdate &&
!_seriesRenderer._chartState!._isLegendToggled &&
_seriesRenderer._chartState!._oldSeriesRenderers.isNotEmpty &&
_oldSeries != null &&
_oldSeriesRenderer!._segments.isNotEmpty &&
_oldSeriesRenderer!._segments[0] is SplineSegment &&
_seriesRenderer._chartState!._oldSeriesRenderers.length - 1 >=
_seriesRenderer._segments[currentSegmentIndex!]._seriesIndex &&
_seriesRenderer._segments[currentSegmentIndex!]._oldSeriesRenderer!
._segments.isNotEmpty &&
_currentPoint!.isGap != true &&
_nextPoint!.isGap != true) {
_currentSegment =
_seriesRenderer._segments[currentSegmentIndex!] as SplineSegment;
_oldSegment = (_currentSegment._oldSeriesRenderer!._segments.length - 1 >=
currentSegmentIndex!)
? _currentSegment._oldSeriesRenderer!._segments[currentSegmentIndex!]
as SplineSegment?
: null;
_oldX1 = _oldSegment?._x1;
_oldY1 = _oldSegment?._y1;
_oldX2 = _oldSegment?._x2;
_oldY2 = _oldSegment?._y2;
_oldX3 = _oldSegment?.startControlX;
_oldY3 = _oldSegment?.startControlY;
_oldX4 = _oldSegment?.endControlX;
_oldY4 = _oldSegment?.endControlY;
if (_oldSegment != null &&
(_oldX1!.isNaN || _oldX2!.isNaN) &&
_seriesRenderer._chartState!._oldAxisRenderers.isNotEmpty) {
_ChartLocation _oldPoint;
_oldXAxisRenderer = _getOldAxisRenderer(_seriesRenderer._xAxisRenderer!,
_seriesRenderer._chartState!._oldAxisRenderers);
_oldYAxisRenderer = _getOldAxisRenderer(_seriesRenderer._yAxisRenderer!,
_seriesRenderer._chartState!._oldAxisRenderers);
if (_oldYAxisRenderer != null && _oldXAxisRenderer != null) {
_needAnimate = _oldYAxisRenderer!._visibleRange!.minimum !=
_seriesRenderer._yAxisRenderer!._visibleRange!.minimum ||
_oldYAxisRenderer!._visibleRange!.maximum !=
_seriesRenderer._yAxisRenderer!._visibleRange!.maximum ||
_oldXAxisRenderer!._visibleRange!.minimum !=
_seriesRenderer._xAxisRenderer!._visibleRange!.minimum ||
_oldXAxisRenderer!._visibleRange!.maximum !=
_seriesRenderer._xAxisRenderer!._visibleRange!.maximum;
}
if (_needAnimate) {
_oldPoint = _calculatePoint(
_currentPoint!.xValue,
_currentPoint!.yValue,
_oldXAxisRenderer!,
_oldYAxisRenderer!,
_seriesRenderer._chartState!._requireInvertedAxis,
_series,
rect);
_oldX1 = _oldPoint.x;
_oldY1 = _oldPoint.y;
_oldPoint = _calculatePoint(
_nextPoint!.xValue,
_nextPoint!.xValue,
_oldXAxisRenderer!,
_oldYAxisRenderer!,
_seriesRenderer._chartState!._requireInvertedAxis,
_series,
rect);
_oldX2 = _oldPoint.x;
_oldY2 = _oldPoint.y;
_oldPoint = _calculatePoint(
startControlX!,
startControlY!,
_oldXAxisRenderer!,
_oldYAxisRenderer!,
_seriesRenderer._chartState!._requireInvertedAxis,
_series,
rect);
_oldX3 = _oldPoint.x;
_oldY3 = _oldPoint.y;
_oldPoint = _calculatePoint(
endControlX!,
endControlY!,
_oldXAxisRenderer!,
_oldYAxisRenderer!,
_seriesRenderer._chartState!._requireInvertedAxis,
_series,
rect);
_oldX4 = _oldPoint.x;
_oldY4 = _oldPoint.y;
}
}
_animateLineTypeSeries(
canvas,
_seriesRenderer,
strokePaint!,
animationFactor,
_currentSegment._x1,
_currentSegment._y1,
_currentSegment._x2,
_currentSegment._y2,
_oldX1,
_oldY1,
_oldX2,
_oldY2,
_currentSegment.startControlX,
_currentSegment.startControlY,
_oldX3,
_oldY3,
_currentSegment.endControlX,
_currentSegment.endControlY,
_oldX4,
_oldY4,
);
} else {
final Path path = Path();
path.moveTo(_x1, _y1);
if (_currentPoint!.isGap != true && _nextPoint!.isGap != true) {
path.cubicTo(startControlX!, startControlY!, endControlX!, endControlY!,
_x2, _y2);
_drawDashedLine(canvas, _series.dashArray, strokePaint!, path);
}
}
}