Added undefined checking to chart.