Jump to content
  • IronPython Show/Hide items


    This code is interacting with the Spotfire API to manipulate a bar chart visualization show/hide properties.
    from Spotfire.Dxp.Application.Visuals import BarChart
    barChart = vis.As[BarChart]()
    
    #get filter rules
    gotFilerRules,filterRuleCollection  = barChart.TryGetFilterRules()
    
    #delete all filter rules
    if gotFilerRules:
    	for filterRule in filterRuleCollection:
    		filterRuleCollection.Remove(filterRule)
    		#print filterRule.DisplayName, filterRule.Expression
    
    #add a filter rule collection to show top 5 axis values
    #filterRuleCollection.AddTopNRule("THEN [Y.FinalValue]",5,True) 

    filterRule.thumb.gif.e6feff1a597da7b120578c24cd65473e.gif

    Explanation

    from Spotfire.Dxp.Application.Visuals import BarChart: This line is importing the BarChart class from the Spotfire API. This class represents a bar chart visualization in Spotfire.

    barChart = vis.As[BarChart](): This line is casting the vis object to a BarChart. The vis object is assumed to be a visualization object in Spotfire, but it's not defined in this code snippet.

    gotFilerRules,filterRuleCollection = barChart.TryGetFilterRules(): This line is calling the TryGetFilterRules method of the barChart object. This method is expected to return a boolean indicating whether the operation was successful (gotFilterRules), and a collection of filter rules applied to the bar chart (filterRuleCollection).

    The if gotFilerRules: block is executed if TryGetFilterRules was successful. Inside this block, it iterates over each filter rule in filterRuleCollection and removes it. This effectively removes all filter rules from the bar chart.

    The last line, which is commented out, would add a new filter rule to the filterRuleCollection if uncommented. This filter rule would show the top 5 values of the Y.FinalValue axis.


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...