Rewrite of the graph as a Angularjs services