Jump to content
  • How add different "Show/Hide Item" rules to visualizations using IronPython in Spotfire®


    In a visualization, you got the option to Show/Hide Items by rules. This is set in the Show/Hide settings in the Property menu. This article describes how to control those settings from Python. They are called "FilterRules" in the API.

    Introduction

    In a visualization, you got the option to Show/Hide Items by rules. This is set in the Show/Hide settings in the Property menu. This article describes how to control those settings from Python. They are called "FilterRules" in the API.

    The API that controls the different rules, "FilterRules", 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 to the visualization and also provides the methods to add all supported rule types. All comparison values are instantiated from the ConditionValue class.

    Code sample

    Example of a simple "Greater Than".

    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)
     

    References

    License: TIBCO BSD-Style License

    Back to IronPython Scripting in TIBCO Spotfire Examples:  https://community.spotfire.com/s/article/IronPython-Scripting-in-Spotfire

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...