@dpanscik,
It seems like you are using a different variable name for chart object. Replacing it with the proper variable name should work fine in your case.
If you are still facing the issue, kindly create a JSFiddle reproducing the issue you are facing and share it with us so that we can reproduce the issue at our end, understand the scenario better and help you out.
—-
Manoj Mohan
Team CanvasJS