Reset canvas on button click

Hi,
I want to reset (i.e. remove every thing that is on canvas )my canvas on click of a button
Here is my code :

document.getElementById("reset-canvas").onclick=function(event){
  event.preventDefault();
  nodeDataArray=[];
  linkDataArray=[];
}

But it doesn’t remove the shapes that are drawn on the canvas.How can i do this?
Thanks in advance.

There won’t be any effect when setting two global variables that have nothing to do with any diagram.

Try pretending to load an empty model:

     myDiagram.model = new go.GraphLinksModel();

Or call:

    myDiagram.clear();

The latter might remove stuff that you want to keep.

Thanks,It worked for me.