Jump to content

"limit data using markings" by python script


Raoul Blankertz

Recommended Posts

There are a number of ways to mark with IronPython, depending on what you are interacting with in the analysis file. The DataManager owns the Marking object. It controls the markings them selves (add/remove):

 

https://docs.tibco.com/pub/doc_remote/spotfire/7.0.0/doc/api/topic=html...

https://docs.tibco.com/pub/doc_remote/spotfire/7.0.0/doc/api/topic=html...

 

 

Here is an example marking on a Bar Chart:

 

from Spotfire.Dxp.Application.Visuals import *

from Spotfire.Dxp.Data import DataPropertyClass

 

p=Document.Data.Properties.GetProperty(DataPropertyClass.Document,"mymarkings").Value

marking = Document.Data.Markings[p]

 

for page in Application.Document.Pages:

for vis in page.Visuals:

if vis.Title == "Bar Chart":

vi = vis.As[barChart]()

m=vi.Data.MarkingReference

vi.Data.MarkingReference=marking

And you can clear all markings with something like:

 

#Import required libraries

from Spotfire.Dxp.Data import *

from Spotfire.Dxp.Application.Filters import *

 

def resetMarking():

# Loop through each data table

for dataTable in Document.Data.Tables:

# Navigate through each marking in a given data table

for marking in Document.Data.Markings:

# Unmark the selection

rows = RowSelection(IndexSet(dataTable.RowCount, False))

marking.SetSelection(rows, dataTable)

 

# Call the function

resetMarking()

Link to comment
Share on other sites

Yes indeed it is possible:

 

from Spotfire.Dxp import Data

from Spotfire.Dxp.Application.Visuals import *

 

for filtering in vis.As[VisualContent]().Data.Filterings:

print filtering.Name

vis.As[VisualContent]().Data.Filterings.Remove(filtering)

 

vis.As[VisualContent]().Data.Filterings.Add(Document.Data.Markings["Marking"])Note that this will also affect filtering selections. Each of the filtering objects will either be a DataMarkingSelection or a DataFilteringSelection object. You can get the type of the filtering like:

print filtering.GetType()

Hope this helps!

Andrew (TIBCO Data Science)

Link to comment
Share on other sites

  • 4 years later...

This has worked very well for me too, thank you. I can't figure out though, how to also deactivate the marking via ironpython script, anyone can help

 

I get that this "vis.As[VisualContent]().Data.Filterings.Remove(Document.Data.Markings["Marking"])"  will deactivate the marking just as .Add activates it, what I can't figure out is how to apply a conditional logic, i.e. how to check if "Marking" is active or not currently, so I can subsequently apply either .Add or .Remove. 

 

Thanks 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...