Graphs now generate legends
Also did some minor formatting and code cleanup.
[#74536668]