factored out graph rendering