def METHOD_NAME(self, d: Datapoint) -> int:
    mag = self.magnitude(d)
    if self.logarithmicY and mag == 0:
        return self.topMargin - self.dim.height
    if math.isfinite(mag):
        if self.logarithmicY:
            span = math.log(self.maxValue) - math.log(self.minValue)
            return self.topMargin + int(
                (math.log(self.maxValue) - math.log(mag))
                / span
                * self.dim.height
            )
        return self.topMargin + int(
            (self.maxValue - mag) / self.span * self.dim.height
        )
    return self.topMargin