@oneworld,
You can get the reference of the chart object outside of the window.onload() or any other function by either creating chart as a global variable, which is not a neat way to access the chart. Or you could pass the chart object as a parameter to the function that can access the chart as shown in this jsfiddle.
—
Suyash,
Team CanvasJS