init the function to insert chart