Remove charts from a page

Description: Remove charts from a page.
Assumptions: An optional 'myPage' page type script parameter.
Warning: Backup Spotfire files before removing visualizations.

#Pick one of the following Page reference options:
#myPage = Application.Document.Pages[0]            #Page index method
#myPage = Application.Document.ActivePageReference #Active page method
#myPage as a page type script parameter            #Script parameter method

#Remove charts from a page
for myVis in myPage.Visuals:
  if (myVis.Title== "New Bar Chart"):
    myPage.Visuals.Remove(myVis)