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;
double centerY = (top + bottom) / 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) {
segmentRect = Rect.fromPoints(Offset(x1, y1), Offset(x2, y2));
}
if (series.showIndicationForSameValues && high == low) {
centerY = (high + low) / 2;
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, y));
points.add(Offset(x + 2, y));
points.add(Offset(x, y));
} else {
points.add(Offset(x, y - 2));
points.add(Offset(x, y));
points.add(Offset(x, y + 2));
points.add(Offset(x, y));
}
} 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);
}
}