screenToGraph method
Transforms a screen point to graph coordinates.
Converts a position in screen pixels to the corresponding position in the graph's coordinate space, accounting for pan and zoom.
Example:
final viewport = GraphViewport(x: 100, y: 50, zoom: 2.0);
final graphPos = viewport.screenToGraph(Offset(200, 150));
// Returns: Offset(50, 50) in graph coordinates
Implementation
Offset screenToGraph(Offset screenPoint) {
return Offset((screenPoint.dx - x) / zoom, (screenPoint.dy - y) / zoom);
}