updated code and example for graph js