Jump to content
  • Test Utility Example for the Spotfire® JavaScript API


    Introduction

    The Spotfire® JavaScript API can be used to embed a Spotfire analysis into a web page and to integrate Spotfire with other web applications.

    This example is a test utility that can used to learn how the JavaScript API works by setting parameters and inspecting results from function calls. The example is configured to use a Spotfire analysis file in the Spotfire Cloud gallery, but can easily be reconfigured to use any Spotfire analysis file.

    javascriptapitest_2.thumb.png.b3763aa554a9150825f80491e2a158a0.png

     

    Prerequisites

    Download and extract the attached JavaScriptAPITest zip file.

    • JavaScriptAPITest.html

      The html file creating the placeholders for analysis content. Add this html to your web server, or add it to the SDK along with the other mashup examples: Examples\Extensions\ SpotfireDeveloper. WebAutomationExample\. The file is reconfigured to get the JavaScript API from Spotfire Cloud. If you use another Spotfire Server, the script tag should be changed accordingly.

      <script type="text/javascript" src="https://spotfire-next.cloud.tibco.com/spotfire/wp/GetJavaScriptApi.ashx?Versi... "></script>
       
    • JavaScriptAPITest.js

      The JavaScript file. Add this to the same location as JavaScriptAPITest.html. The Spotfire Server and analysis file is specified in two constants. If you want to test the example on another analysis file, the constants needs to be modified.

      var c_serverUrl = "https://spotfire-next.cloud.tibco.com/spotfire/wp/";
      var c_analysisPath = "/Samples/Analyzing Stock Performance";
       

    Run the Example

    The example consists of three panels (HTML DIV elements):

    • The application panel that contains the loaded Spotfire analysis.
    • The control panel with input fields and buttons to trigger different API calls.
    • The console panel where the result from an API call is printed out.

    Below is a walkthrough of the different sections in the control panel and what API calls is supported in the example, with links to the corresponding documentation in the JavaScript API reference.

    Properties

    The Properties section includes API calls to get and set document properties and other metadata. There are two input fields for property name and property values (comma separated). A property expects either a single value or an array of values. For this, there are two buttons to set a property value in the control panel.

    The following API calls on the Document class are used in this section:

    Pages

    The Pages section includes API calls to get all pages in the analysis and to get and set active page. There is an input field to enter a page name.

    The following API calls on the Document class are used in this section:

    Data

    The Data section includes API calls to retrieve information on data tables and data columns. There is an input field to enter column name in active data table.

    The following API calls on the DataDataTable and DataColumn classes are used in this section:

    Marking

    The Marking section includes API calls to retreive marking names and marked records for columns specified in an input field. For simplicity, the example code assumes that there is a default marking in the analysis called "Marking".

    The following API calls on the Marking class are used in this section:

    Filtering

    The Filtering section includes API calls to set filter values and to retrieve metadata and data from filtered columns. It also includes retrieving filtering scheme information and the ability to reset filters. There are two input fields, one for filter column and one for filter values (comma separated). For simplicity, the example code assumes that there is a default filtering scheme in the analysis called "Filtering Scheme".

    The following API calls on the Filtering and FilteringScheme class are used in this section:

    Bookmarks

    The Bookmarks section includes API calls to apply a bookmark and to retrieve a list of bookmarks available in the analysis.

    The following API calls on the Document class are used in this section: 

    javascriptapitest_4.zip


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...