setup ajax function for graphs