@elbargho,
You need to create chart-container dynamically before creating the chart. Please take a look at this updated JSFiddle.
We suggest you to post queries related to Charts in Chart Support Forum. Considering this as duplicate of creating a chart on button click instead of on window.load. Hence closing the same.
—
Vishwas R
Team CanvasJS