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()
if found:
rules.AddThresholdRule('Avg([Life Expectancy at Birth (years)])', rco.Greater, ConditionValue.CreateLiteral(75) ,False)
---
Disclaimer:
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.
https://docs.tibco.com/pub/doc_remote/spotfire/7.0.1/doc/api/?
topic=html/AllMembers_T_Spotfire_Dxp_Application_Visuals_FilterRuleCollection.htm
https://docs.tibco.com/pub/doc_remote/spotfire/7.0.1/doc/api/?
topic=html/M_Spotfire_Dxp_Application_Visuals_FilterRuleCollection_AddThresholdRule.htm
https://docs.tibco.com/pub/doc_remote/spotfire/7.0.1/doc/api/?
topic=html/AllMembers_T_Spotfire_Dxp_Application_Visuals_ConditionalColoring_ConditionValue.htm
https://docs.tibco.com/pub/doc_remote/spotfire/7.0.1/doc/api/?
topic=html/T_Spotfire_Dxp_Application_Visuals_ConditionalColoring_RuleComparisonOperator.htm
hide/show items, items, hide, show, filter rules, filter, rules, condition, value, filterrulecollection
Comments
0 comments
Article is closed for comments.