The problem here almost certainly stems from the original form of the answer, which was simply:
posted the answer in the main question itself
There's multiple problems with that; the answer isn't an answer and the question isn't the place the post the answer.
The comment on the post (denoting it doesn't provide an answer) was placed before the post was edited, however, the moderator deletion did happen after the edit. As I don't know what the mod tools look like I don't know if the moderator would have seen that revision at the time they reviewed it.
As for what should be done, the post (as it stood when you posted), needed an edit, as the content was:
jsonData.Chart(c=>c.entryTime,c=>c.cumulativegains, Util.SeriesType.Line).Dump(); will enable plotting it as line chart from json.
The code should be in a code fence. As a result you should edit the post, to make it presentable, and then raise a custom mod flag explaining the problem, and that you feel that the post is now a good answer and should be undeleted.
Zoe has now done all that, so the problem is resolved, but in the future, a Custom Moderator flag (for posts deleted by a moderator), is what is needed. If it's not mod deleted, as a user with >=20k reputation, you can simply cast an undelete vote.