Unify appendGraph and renderGraph into setupGraph