Overview
With IronPython scripts it is possible to configure and automate a lot of different aspects of a Spotfire® analysis and add behaviors to it without creating and deploying extensions. IronPython scripts can access the capabilities available in the Spotfire Analyst API.
IronPython scripts can be added to several places in a Spotfire analysis. Scripts can be executed from action controls in the Text Area, from the Graphical Table or the KPI Chart or be triggered by Document Property changes.
To create an analyses containing IronPython scripts, the analyst needs the Author Scripts license function. Scripts in analysis files that are shared via the library by licensed script authors are considered as trusted. For security reasons you should always examine and approve a script that is not listed as trusted before executing it.
The Spotfire add-in mechanism for C# Extensions, which enables developers to extend the Spotfire feature set, is designed for the developers with access to a full-fledged development environment. Scripting does not replace this framework. It rather supplements the heavy-lifting programming with a light-weight option to configure Spotfire and extend its behaviors, a convenient and powerful means to solve simple as well as complex tasks. Many of the script examples below are applicable also when creating custom tools and other extensions as embedded IronPython scripts or converted to C#.
Tutorials
- IronPython automation (video 6:21)
- Trigger IronPython on initial load (video 4:32)
- Check box and radio button property controls (video 5:49)
- Auto resize displays for different devices (video 9:20)
- Show Top 5 values in charts using Spotfire rules and IronPython (video 5:53)
- How to choose between using IronPython scripting and creating a C# Extension when developing for Spotfire®
- How to develop IronPython scripts and their limitations
- Use IronPython scripts in the Text Area
- Use IronPython scripts in the KPI Chart or the Graphical Table
- Use IronPython scripts with Document Properties
- Use IronPython scripts with Application Profiler
- Create complex user Interfaces using property controls and IronPython scripts
- Execute any IronPython script from the JavaScript API
- Spotfire Analyst User's Guide
- How to deploy custom python modules
- How to use an external editor to edit IronPython scripts - with autocomplete and syntax checking
- Debugging IronPython Scripts in Spotfire®
See Also
- Running IronPython Scripts on Opening the Analysis, and Filter and Marking changes, using DateTime Datafunction (Download Extension).
- Fitting a model using Python and TERR
- Use the Data Table Source View API to read and modify the operations and transformations of a data table in an analysis
- C# API examples
- Spotfire® Developer - Summary of New and Changed Features
- Unofficial IronPython script and tutorial collections (not affiliated with or supported by Spotfire):
Examples
Data:
- Change join type
- Set custom sort order
- Apply custom sort order from another column
- Invoke a pre-defined data function
- Export data
- Convert json data to csv format
- Create, execute, and save a Spotfire data function
- Add a data table with a pivot transformation
- Pass value to an input parameter of a data function
- Add new data table based on existing data table in analysis
- Manage data table relations
- Create data table based on filtered rows of another data table
- Calculate cross table sums
- Get aggregated data
- Load an in-memory csv file
- Add rows with zero
- Insert columns to existing data table with custom column match
- Change a calculated column expression
- Add a hierarchy column to a data table
- Retrieve column values
- Check if a data table is linked or embedded
- Check if there are empty values in a column
- Import and parse data from web service
- Read binary values in a column and save as image
- Write to MS Access database
- Export data table to a string
- Perform calculations on DateTime objects
- Using .net System.Data.SqlClient module for database writeback
- Replace specific values in data table Columns
- Limit a data table, perform an aggregation and save the value to a document property
- Refresh or reload data
- Read column values
- Import multiple Excel spreadsheets
- Export Table/Cross Table visualization data to SBDF file in Spotfire library
- Export Table/Cross Table visualization data in csv file
- Replace exisiting table with SBDF file from library
- Add data table relations
- Remove columns using wild card characters
- Combine row selections to get filtered rows
- Replace a transformation in DataTable
- Change column formatting
- Write/Export CrossTable data to a MemoryStream and creating a TextFileDataSource from the same
- Working with cells in Table visualization
- Read data from webservice and save to data table
- Replace File Data Source
- Limit number of rows to Export
- Adding calculated column
- Appending rows to table, creating new column to keep track of the origin of the data
- Setting custom date format
- Embed data tables
- Set key columns for a given data table
- Remove calculated columns from a data table
- Writeback to database
- List and change column properties
- Sort a column from a given data table
- Add a new column property
- Reload individual data operations
- Retrieve data table source information
- Delete all rows from a data table
- Create default Information Model
- Remove marked rows from a table
- Remove (or keep) rows based on cell data from a column
- How to install ODAC
- Add parameterized information link data table
- Add stored procedure information link data table
- Check if data table is On demand
- Using Data Table Hierarchy to Iterate over Values in Column
- Replace InformationLink data source using source view
- Add an Unpivot Transformation
- Write back using ODBC driver
- Get values of the input parameters of the Data Function
- Create DataRelationships calculation
- Add a Data Table based on Information Link with Prompts
- Find Data Table Dependencies in Document Visualizations
- List tables and columns
Visualizations:
- Find all columns and expressions used in visualizations
- Configure coloring schemes via column properties
- Select columns to display in a Table visualization via Property Control
- Create and configure a KPI chart
- Sort a Bar Chart visualization
- Set Stack mode in Bar Chart visualizations
- Toggle the axis selectors on/off in a visualization
- Convert one visualization into another
- Reset zoomslider
- Reset X-axis Zoom Slider manually
- Maximize/restore a visualization
- Set/get scale axis range for a visualization
- Change current format for a visualization
- Toggle Table plot property 'Allow table data export in Spotfire web clients'
- Export visualization as an image
- Export analysis to PDF
- Get visual type
- Bar chart colouring
- For each visual
- For each visual output column
- Change visual data table
- Configure JSViz GroupBy Columns
- Read marked values in a Treemap and write them to a document property
- Toggle subtotals in Cross Table
- Set colors and save color scheme to library
- Apply color schemes stored in the document or library
- Get subsets of a visualization
- Working with tooltips
- Sort Graphical Table visualization
- Toggle visualization
- Toggle details items in tooltip of different visualizations
- Toggle show/hide Item rules for a visualization
- Dynamically hide and show controls in the Text Area
- How to use miniature visualization action scripts
- Save a document color scheme with a MemoryStream in the dashboard
- Change the appearance of a visualization
- Working with lines & curves
- Using trellis option in a visualization
- Adding horizontal line in a visualization
- Enabling multiple IndividualFittingModes of lines & curves in a visualization
- Adding straight line fit in a visualization
- Get list of all the lines & curves of a visualization
- Working with Scatter Plot size property
- Loop through pages and visualizations
- How to add different show/hide Item rules to visualizations
- Change sparkline color on Graphical Table
- Add new page and new visualization
- Add columns to coloring scheme groups
- Edit column renderer options in Table visualization
- Rename calculated column in a Graphical Table
- Apply coloring scheme from one visualization to another
- Remove columns in a Graphical Table, add a sparkline column and an icon column
- Sort Cross Table visualization
- Update the cell values of a Cross Table dynamically based on the value selected from a Property Control
- Style the Cross Table cell height/column header height
- Add/edit color rule for the newly added Calculated Value column in Graphical Table
- Render image from an URL on X-axis
- Set individual scales formatting for Line Chart
- Setting limit data expression in a visualization
- Using Visual.RenderSync API to export visualization
- Add statistical measures to a summary table
- Add a line from column values to a visualization
- Dynamically change images in Text Area
- Apply a document color scheme to a Heat Map visualization
- How to apply a format the Y axis of any given visualization
- Configure a visualization when no data is marked in the master visualization
- Toggle a visualization
- Read tile name of a KPI Chart visualization on click
- Merge colors from different color schemes
- Find WMS layers in Map Chart
- Add Remove Tooltip in a BarChart
- Define Custom Name for Axis Selectors expression
- Get/Set breakpioints of a Continuous Color Rule
- Set axis range when using Dual Scales
- Set the Color Mode to Gradient and specify the Breakpoints with specific colors for a Bar Chart Visualization
- Change the Color of a series in a Combination Chart Visualization
- Add or deletes the filter Rules from a visualization show/Hide properties section
Filtering and Marking:
- Checkbox Hierarchy filters - which values are checked?
- Read and modify checked values in CheckBox filter
- Apply multi-select values from a property control to a filter
- Reset all markings
- Limit data shown in visualization using markings
- Select all values from a given document property control
- Retrieve data marking selection
- Setting hierarchical filters
- Setting a specific filter
- Show/hide the Filter Panel
- Passing filter value in visualization title
- Use regular expression with a filter
- Reset all filters for all filtering schemes
- Update a multiselect list box property control on filter selections
- Uncheck all checked values in CheckBox filter
- Iterate over filtered rows
- Change filtering in related data tables
- Show/hide filters
- Dock filter panel in different regions (left/right/bottom)
- Change filter type
- List the modified filters for the current page
- Tag marked rows
- Filter to marked rows
- Add filter to filter group
- Collapse all the filter groups and filters
- Use markings from multiple tables to limit data
- Mark a visualization based on unmarked rows from another visualization
- Reset marking for all active page visualizations
- Set a Date range filter
- Set markings to a specific color
- Rename the filter group/subgroups
- Set range filter to the next low/high value
- Label only the marked data
- Progressively filter data for each column value
- Reset the filters of an active data table
- Remove filters from subgroups in filter panel
- Mark all filtered rows
- Set search expression for Listbox filter
- Remove unreferenced markings
- Remove unreferenced filterings
- Check if value exists in ListBox filter and apply value
- Set FilteringScheme for current page
- Remove All and None options from filters
User Interface & Layout:
- Set the layout of the visualizations on a page
- Move each visualization to a separate page
- Read the screen size of the current user's device
- Turn on a custom panel in Consumer/Business Author
- Use the Data Panel
- Show/hide the Data Panel
- Show/hide curves in a Line Chart
- Toggle the Bookmarks Panel
- Fetch the Bookmark URI
- Toggle the legend section of a visualization
- Add, apply and remove a bookmark
- Read the active pages of all other views (i.e. windows) and set the last occurrence on the active view
- Configure the URL of Web Page Panel/Collaboration Panel
- Load an image from file and display via a Document Property
- Remove page
- Navigate to pages by name
- Check Scrollbar position
- Mark rows based on document property value
- Show or Hide Pages for Consumer users in the Viewing Mode
- Dynamic Dashboard Layout
- Trigger IronPython Script with Marking and create visualizations in trellis mode layout
- Create Mastheads across all pages
Maps:
- Zoom to a pre-defined map location
- Zoom to data in any map
- Configure MapChart to marker shape to use pies
- Change image layer extents
- Toggle map label visibility
- Toggle map layer visibility
- Toggle map auto zoom
- Toggle map controls visibility
- Set a projection for a map layer
- Add WMS layer in a Map Chart
Document:
- Save the document to a file
- Save file locally or to library
- Adding Document Properties
- Configure an IronPython script to run automatically when a Document Property changes
- Retrieve dxp file/library path
- List all the Document Properties of an analysis
- Iterate over all the Document Properties
- Retrieve URL's of library item
- Render a page as a Image
- Embed data and save a dashboard locally or on server using Automation Services
- Retrieve the custom format string of Number data type column
- Get/Set custom property for a library item
- Find what data table is used by each visualization
- Find what visualizations are referencing each data table
Integration:
- Communicate findings to a third party component by the click of one button
- Sending an email via Outlook
- Call web service or retrieve URL
- Call web service using httpwebrequest and parse returned json
- Call a REST web service over HTTPS with authentication
- List or retrieve data from AWS S3
- Send an email
Miscellaneous:
- Progress bar and cancellation option
- Troubleshoot the exception thrown when executing a IronPython script with the error: Attempt take snapshot on application thread in state 'Executing'
- Import custom libraries and extensions from a local directory
- Execute a custom tool
- Perform an action after data table refresh completion
- Troubleshoot the error message: Script requires more arguments than supplied
- Deploy custom Python modules
- Use IronPython to retrieve Holt-Winters forecast
- Create a new folder in the Spotfire Library
- Cancel background tasks
- Call script
- Loop through bookmarks and print filter settings to text area
- Fetch logged in username
- Execute an IronPython script with multiple input parameters from within another IronPython script
- Open a url in Spotfire Web Player
- Determine the client type (Analyst or Web Player) the user is running
- Trigger a python script on report load via a JavaScript
- Using CredentialsService
- Add R functions into Spotfire expression language
- Retrieve all Python/Javascripts from a Spotfire dashboard
- Disable left and right handles of a Range filter using JavaScript
- How to import an external Python module using IronPython script into Spotfire® without deploying to the Spotfire® server.
- Assign list to a document property
- How to create and set a new Document Property
- Verify Server URL(s) and Connection to Server
- How to fetch the logged in Spotfire and Windows Usernames
- Fetch the information about the logged in user in Spotfire
- Introducing the Script Management APIs
Disclaimer:
The script code in these articles is only a sample to be used as a reference. It is not intended to be used "As Is" in a Production environment. Always test in a Development environment. Make modifications to the script per your implementation specifications that suit best your business requirements. Refer to the API reference for the usage of the classes and methods used in the scripts. All scripts on this page are covered by this license (Download from Resources)
tibco_community_script_license_2017.pdf
Recommended Comments
There are no comments to display.