transformValues method

  1. @override
void transformValues()
override

Transforms the x and y values to screen coordinates.

Implementation

@override
void transformValues() {
  if (xValue.isNaN || high.isNaN || low.isNaN) {
    return;
  }

  points.clear();

  final PointToPixelCallback transformX = series.pointToPixelX;
  final PointToPixelCallback transformY = series.pointToPixelY;

  final double centerY = (low + high) / 2;
  if (high == low) {
    if (series.showIndicationForSameValues) {
      if (series.isTransposed) {
        points.add(
            Offset(transformX(xValue, high) - 2, transformY(xValue, high)));
        points.add(
            Offset(transformX(xValue, low) + 2, transformY(xValue, low)));
      } else {
        points.add(
            Offset(transformX(xValue, high), transformY(xValue, high) - 2));
        points.add(
            Offset(transformX(xValue, low), transformY(xValue, low) + 2));
      }
    }
  } else {
    points.add(Offset(transformX(xValue, high), transformY(xValue, high)));
    points.add(Offset(transformX(xValue, low), transformY(xValue, low)));
  }

  if (_oldPoints.isEmpty) {
    final Offset center =
        Offset(transformX(xValue, centerY), transformY(xValue, centerY));
    _oldPoints.addAll(<Offset>[center, center]);
  }

  if (points.length > _oldPoints.length) {
    _oldPoints.addAll(points.sublist(_oldPoints.length));
  }
}