onPaint method
Draws segment in series bounds.
Implementation
@override
void onPaint(Canvas canvas) {
_setSegmentProperties();
final SeriesRendererDetails seriesRendererDetails =
SeriesHelper.getSeriesRendererDetails(
_segmentProperties.seriesRenderer);
if (_segmentProperties.series.animationDuration > 0 == true &&
seriesRendererDetails
.stateProperties.renderingDetails.isLegendToggled ==
false) {
if (seriesRendererDetails
.stateProperties.renderingDetails.widgetNeedUpdate ==
false ||
seriesRendererDetails.reAnimate == true) {
if (_isTransposed) {
_lowX = _segmentProperties.lowPoint.x;
_highX = _segmentProperties.highPoint.x;
_centerX = _highX + ((_lowX - _highX) / 2);
_highX = _centerX + ((_centerX - _highX).abs() * animationFactor);
_lowX = _centerX - ((_lowX - _centerX).abs() * animationFactor);
canvas.drawLine(Offset(_lowX, _segmentProperties.lowPoint.y),
Offset(_highX, _segmentProperties.highPoint.y), strokePaint!);
} else {
_centerY = _segmentProperties.high +
((_segmentProperties.low - _segmentProperties.high) / 2);
_highY = _centerY -
((_centerY - _segmentProperties.high) * animationFactor);
_lowY = _centerY +
((_segmentProperties.low - _centerY) * animationFactor);
canvas.drawLine(Offset(_segmentProperties.lowPoint.x, _highY),
Offset(_segmentProperties.highPoint.x, _lowY), strokePaint!);
}
} else {
_currentSegment =
seriesRendererDetails.segments[currentSegmentIndex!] as HiloSegment;
final SeriesRendererDetails? oldSeriesDetails =
_currentSegment._segmentProperties.oldSeriesRenderer != null
? SeriesHelper.getSeriesRendererDetails(
_currentSegment._segmentProperties.oldSeriesRenderer!)
: null;
_oldSegment = seriesRendererDetails.reAnimate == false &&
(oldSeriesDetails != null &&
oldSeriesDetails.segments.isNotEmpty == true &&
oldSeriesDetails.segments[0] is HiloSegment &&
oldSeriesDetails.segments.length - 1 >=
currentSegmentIndex! ==
true)
? oldSeriesDetails.segments[currentSegmentIndex!] as HiloSegment?
: null;
animateHiloSeres(
_isTransposed,
_segmentProperties.lowPoint,
_segmentProperties.highPoint,
_oldSegment?._segmentProperties.lowPoint,
_oldSegment?._segmentProperties.highPoint,
animationFactor,
strokePaint!,
canvas,
_segmentProperties.seriesRenderer);
}
} else {
if (seriesRendererDetails.dashArray![0] != 0 &&
seriesRendererDetails.dashArray![1] != 0) {
_segmentProperties.path = Path();
_segmentProperties.path
.moveTo(_segmentProperties.lowPoint.x, _segmentProperties.high);
_segmentProperties.path
.lineTo(_segmentProperties.highPoint.x, _segmentProperties.low);
drawDashedLine(canvas, seriesRendererDetails.dashArray!, strokePaint!,
_segmentProperties.path);
} else {
canvas.drawLine(
Offset(_segmentProperties.lowPoint.x, _segmentProperties.high),
Offset(_segmentProperties.highPoint.x, _segmentProperties.low),
strokePaint!);
}
}
}