Product: TIBCO Spotfire®
How to programmatically add different "Show/Hide Item" rules to visualizations.
The API that controls the different rules is called "FilterRules" and can be found in supporting visualizations in the form of the TryGetFilterRules. This in turn returns the collection of filter rules that are currently added on the visualization and also provides the methods to add all supported rule types. All comparison values are instantiated from the ConditionValue class.
Example of a simple "Greater Than" filter follows.
from Spotfire.Dxp.Application.Visuals.ConditionalColoring import ConditionValue, RuleComparisonOperator as rco
from Spotfire.Dxp.Application.Visuals import BarChart, VisualTypeIdentifiers
barchart = None
for visual in Document.ActivePageReference.Visuals:
if visual.TypeId == VisualTypeIdentifiers.BarChart:
barchart = visual.As[BarChart]()
found, rules = barchart.TryGetFilterRules()
rules.AddThresholdRule('Avg([Life Expectancy at Birth (years)])', rco.Greater, ConditionValue.CreateLiteral(75) ,False)
The script code in this article is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the script in accordance with your implementation specifications that best suit your business requirements. Refer to the API reference(s) cited in this article for usage of the classes and methods used in the script.
hide/show items, items, hide, show, filter rules, filter, rules, condition, value, filterrulecollection