Debbie,
After going through your code it seems like you have not instantiated the chart Object. Instantiating the chart Object before rendering it should work fine in your case. Please take a look at this documentation page for further information.
___________
Indranil Deo,
Team CanvasJS