transformValues method
Transforms the x and y values to screen coordinates.
Implementation
@override
void transformValues() {
if (x.isNaN || top.isNaN || bottom.isNaN || high.isNaN || low.isNaN) {
segmentRect = null;
_oldSegmentRect = null;
_oldPoints.clear();
points.clear();
return;
}
points.clear();
final PointToPixelCallback transformX = series.pointToPixelX;
final PointToPixelCallback transformY = series.pointToPixelY;
final num left = x + series.sbsInfo.minimum;
final num right = x + series.sbsInfo.maximum;
final double centerX = (right + left) / 2;
final double centerY = (low + high) / 2;
final double x1 = transformX(left, top);
final double y1 = transformY(left, top);
final double x2 = transformX(right, bottom);
final double y2 = transformY(right, bottom);
segmentRect = Rect.fromLTRB(x1, y1, x2, y2);
_oldSegmentRect ??= Rect.fromLTRB(
series.pointToPixelX(left, centerY),
series.pointToPixelY(left, centerY),
series.pointToPixelX(right, centerY),
series.pointToPixelY(right, centerY),
);
_isSameValue = top == bottom;
if (_isSameValue) {
points.add(Offset(x1, y1));
points.add(Offset(x2, y2));
if (series.showIndicationForSameValues) {
final double x = transformX(centerX, centerY);
final double y = transformY(centerX, centerY);
if (series.isTransposed) {
points.add(Offset(x - 2, y));
points.add(Offset(x + 2, y));
} else {
points.add(Offset(x, y - 2));
points.add(Offset(x, y + 2));
}
}
segmentRect = Rect.fromPoints(points[0], points[1]);
} else {
points.add(Offset(transformX(centerX, high), transformY(centerX, high)));
points.add(Offset(transformX(centerX, top), transformY(centerX, top)));
points.add(Offset(transformX(centerX, low), transformY(centerX, low)));
points.add(
Offset(transformX(centerX, bottom), transformY(centerX, bottom)));
if (_oldPoints.isEmpty) {
final Offset point =
Offset(transformX(centerX, centerY), transformY(centerX, centerY));
_oldPoints.add(point);
_oldPoints.add(point);
_oldPoints.add(point);
_oldPoints.add(point);
}
}
}