Jump to content
  • How to use the DataPanel using IronPython in Spotfire®


    This article contains a script for how to use the DataPanel using IronPython in Spotfire®

    Back to main IronPython scripting page

    Introduction

    When the DataPanel was introduced in TIBCO Spotfire® the API was only partially introduced. Using scripting we can still manipulate the panel and its sub components.

    Since the script (IronPython) does not use typed variables it does not require the access to the private classes when assigning a reference to the DataPanel. This is not possible in the C# extensions since we have to provide a container for the reference of the same type. This is prevented since these classes are internal only.

    Example code to set the DataPanel table

    # Copyright © 2017. TIBCO Software Inc.  Licensed under TIBCO BSD-style license.
    
    from Spotfire.Dxp.Application import PanelTypeIdentifiers
    table = Document.Data.Tables['World Bank Data']
    found, panel = Document.ActivePageReference.Panels.TryGetPanel(PanelTypeIdentifiers.DataPanel)
    if found:
    	try:
            # None or null in this case represents the 'All' tables
    		panel.SelectedTable = None
    	except:
            # Handle the error that we have only one table
    		print 'Only a single table in the analysis!'
     

    Workaround for C#

    Since we cannot create a object of the DataPanel type in C# we need to invoke the code using a script from the extension code.

    // Seralize the script code to a string.
    string scriptText = "from Spotfire.Dxp.Application import PanelTypeIdentifiers\n..."
    
    // Use the ScriptManager to execute the code. The "doc" reference represents the Document node provided by the extension.
    doc.ScriptManager.ExecuteScript(scriptText);
     

    References

    License:  TIBCO BSD-Style License

     

     


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...