transformValues method
Transforms the x and y values to screen coordinates.
Implementation
@override
void transformValues() {
if (x.isNaN || high.isNaN || low.isNaN || open.isNaN || close.isNaN) {
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 centerY = (low + high) / 2;
_isSameValue = high == low;
final double centerX = (right + left) / 2;
points.add(Offset(transformX(centerX, high), transformY(centerX, high)));
points.add(Offset(transformX(centerX, low), transformY(centerX, low)));
points.add(Offset(transformX(left, open), transformY(left, open)));
points.add(Offset(transformX(centerX, open), transformY(centerX, open)));
points.add(Offset(transformX(right, close), transformY(right, close)));
points.add(Offset(transformX(centerX, close), transformY(centerX, close)));
if (_isSameValue && 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));
}
}
if (_oldPoints.isEmpty) {
final Offset center =
Offset(transformX(centerX, centerY), transformY(centerX, centerY));
_oldPoints.add(center);
_oldPoints.add(center);
_oldPoints
.add(Offset(transformX(left, centerY), transformY(left, centerY)));
_oldPoints.add(center);
_oldPoints
.add(Offset(transformX(right, centerY), transformY(right, centerY)));
_oldPoints.add(center);
}
if (points.length > _oldPoints.length) {
_oldPoints.addAll(points.sublist(_oldPoints.length));
}
}