Skip to Main Content
Spotfire Ideas Portal

Need ability to show or hide visualization based on button click (API Availability)

The requirement is to show or hide visualizations (charts) in the spotfire report based on the button click. At present there is not APIs that we can leverage to achieve this functionality. Raising this idea to consider including this API for future releases of Spotfire.

  • Attach files
      Drop here to upload
    • Guest
      Reply
      |
      Jan 16, 2019

      I started such a script (below) that doesn't hide but removes confidential visuals. I got caught up in re-adding visuals part. I suspect it could be done through bookmarks or undo functions. Also, in this example, since charts are removed, it resizes all the other visuals which makes for an ugly export :(

       

      # Import namespaces
      from Spotfire.Dxp.Framework.ApplicationModel import ApplicationThread
      from Spotfire.Dxp.Application.Export import PdfExportSettings
      from Spotfire.Dxp.Application.Export import ExportScope
      from Spotfire.Dxp.Application.Export import PageOrientation
      from Spotfire.Dxp.Application.Export import PaperSize
      from Spotfire.Dxp.Application.Export import ExportScope
      from Spotfire.Dxp.Application.Visuals import VisualContent, AxisRange
      
      
      #---------------------------------------------------------------------
      # REMOVE SPECIFIC VISUALIZATION(S)
      #---------------------------------------------------------------------
      for vis in Application.Document.ActivePageReference.Visuals:
      	if  "CONFIDENTIAL" in vis.Title:
      		Application.Document.ActivePageReference.Visuals.Remove(vis)
      
      #---------------------------------------------------------------------
      # EXPORT TO PDF
      #---------------------------------------------------------------------
      
      # Declaring the function which will run async
      def g(app,fileName,pdfexpsettings):
         def f():      
      	  app.Document.Export(pdfexpsettings,fileName)
         return f
      
      # Set the file name
      fileName = "C:\\datafiles\\testfile.pdf"
      pdfexpsettings = PdfExportSettings()
      pdfexpsettings.Scope = ExportScope.ActivePage
      pdfexpsettings.PageOrientation = PageOrientation.Landscape
      pdfexpsettings.IncludePageTitles = False
      pdfexpsettings.IncludeVisualizationTitles = False
      pdfexpsettings.IncludeVisualizationDescriptions = False
      pdfexpsettings.PaperSize = PaperSize.A4
      pdfexpsettings.PageOrientation = PageOrientation.Landscape
      
      # Executing the function on the application thread, and Save the document back to the Library
      Application.GetService[ApplicationThread]().InvokeAsynchronously(g(Application, fileName,pdfexpsettings))
      
      # Note:
      # The function g is necessary because the script's scope is cleared after execution,
      # and therefore Application (or anything else defined in this scope) will not be available
      # when the code invokes on the application thread.
    • Guest
      Reply
      |
      Jan 16, 2019

      This would be useful when printing a page with "confidential" information. A print script could be written that hides confidential charts, prints, then un-hides those charts

    • Guest
      Reply
      |
      Nov 3, 2018

      I need this as well.