Move graph function into to sparc.js