Remove an existing page

Description: Remove an existing page.
Assumptions: An optional 'myPage' page type script parameter.
Warning: Backup Spotfire files before removing pages.

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

#Remove an existing page
Application.Document.Pages.Remove(myPage) #Removes myPage
#Application.Document.Pages.RemoveAt(6)   #Removes the 7th page

Add a bar chart to a page

Description: Add a bar chart to a page.
Assumptions: An optional 'myPage' page type script parameter.

from Spotfire.Dxp.Application.Visuals import BarChart

#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

#Add a chart to a page
myVis = myPage.Visuals.AddNew[BarChart]()
myVis.Data.DataTableReference = Document.Data.Tables["MyDataTable"]
myVis.Title = "New Bar Chart"

Show all visualizations on a page

Description: Show all visualizations on a specific page.
Assumptions: An optional 'myPage' page type script parameter.

#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

#Loop through all visualizations on a page
for myVis in myPage.Visuals:
  print "Vis Name: " + myVis.Title
  print "Vis ID: " + myVis.Id.ToString()

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)

Duplicate a page

Description: Duplicate an existing page.
Assumptions: An optional 'myPage' page type script parameter.

#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

#Duplicate an existing page
Application.Document.Pages.AddDuplicate(myPage)

Switch active page

Description: Switch the active page.
Assumptions: An optional 'myPage' page type script parameter.

#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

#Switch the visible page
Application.Document.ActivePageReference = myPage

Remove all bar chars from a page

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

from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers

#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 all bar charts from a page
for myVis in myPage.Visuals:
  if (myVis.TypeId == VisualTypeIdentifiers.BarChart):
    myPage.Visuals.Remove(myVis)

Add a page

Description: Add a new page. The new page will become the active page.

myPage = Application.Document.Pages.AddNew("My New Page") #AddNew(string) method
#myPage = Application.Document.Pages.AddNew()             #AddNew() method