added checks to see if chart divs are present before trying to use them