example code for generating graph from an JSON api