I bet you were getting NullPointerExceptions? (Please note that it I'd helpful to provide your exact error message when posting a question!)
Assuming that is so, the most likely problem is that you need to wait until after the Canvas object has been created and assigned to whatever @FXML instance variable field you used for it, before you can call the method to get the GraphicsContext2D object for it.
Specifically, you'll want to get the graphics from the canvas in the special
@FXML
private void initialize() { ...
method.
Another possible mistake would be not having the Canvas's fxid exactly match the name of the @FXML field, which could also leave the Canvas object null, even within the initialize method.