Jump to content
  • Add and/or Remove Tooltips in a Barchart Visualisation in Spotfire using IronPython


    The script walks through all pages and all visualizations on each page, and if it finds the correctly named visualization, there is a row to remove a tooltip, and also it adds a tooltip called MaxYear.

    Introduction

    The script walks through all pages and all visualizations on each page, and if it finds the correctly named visualization, there is a row to remove a tooltip, and also it adds a tooltip called MaxYear.

    The name of the example visualization/Bar Chart in this script match one of the sample visualization that is installed in Spotfire. The example analysis is called "Introduction to Spotfire" and you need to add this script.

    Code Sample

    # Copyright © 2019. TIBCO Software Inc. Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Application.Visuals import BarChart
    
    addThis="Max([Year]) as MaxYear"
    
    for page in Document.Pages:
      print (page.Title)
      for vis in page.Visuals: 
        print ('-' + vis.Title + '('+ vis.TypeId.Name +')')
        if (vis.Title == "Largest 10 Countries by Population"):
          v=vis.As[BarChart]()
          for tip in v.Details.Items:
            print  "ToolTip - " + tip.DisplayName + " is -" + str(tip.Visible)
            if (tip.DisplayName=="Year"):
              print ("Year found")
              #v.Details.Items.Remove(tip)
          print (addThis)
          v.Details.Items.AddExpression(addThis)
     

    References

    License:  TIBCO BSD-Style License

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


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...