Adding actions performed when clicking on visualization items
Actions can be defined so that something happens when you click a dynamic item in a graphical table or a text area, or when clicking a tile in a KPI chart. The actions can open Spotfire tools that work on the range of filtered or marked data, apply bookmarks, or navigate to a certain page or visualization in the analysis; the same things that are available for action controls in a text area. It is also possible to add your own custom actions using scripts, or to refresh data function calculations.
About this task
Before you begin
Procedure
Configure details visualization
Below is an example of what you can do by setting up an IronPython script action on two dynamic items of the type calculated value in a graphical table.

Another visualization, a line chart, has been configured to show either the sum of sales or the sum of cost for the marked state in the graphical table over the time, thus displaying the details behind the total sum for each state. In contrast to a standard details visualization controlled by the marking, this visualization will show different data depending on which cell you click on; clicking in the Sales column will show the sales for that state and clicking in the Cost column will show the cost.

- From the visualization properties, open the Calculated Value Settings dialog for the first column, "Sales", (on the Axes page) and go to the Actions section.
- Select Perform action on click.
- Click Settings.
- Click Script.
- Click .
- In the New Script dialog, type a Script name (for example, "Configure details visualization").
- Type a Description (for example, "Configures a visualization to show details of a graphical table cell.")
- Copy the script below and
paste it into the
Script field.
Note: The example script assumes that a column called "State" is available in the data table.
- Next to Script parameters, click Add.
- In the
Add Script Parameter dialog, type the
Name
detailsVis
, as expected by the script. - Let the Type be a Visualization and select the line chart to use as the details visualization from the list.
- Click OK in all dialogs to close them.
- Add the defined script to the other column as well, to be able to show either Sales or Cost details in the line chart.
# This script is intended to be run as an action on a
# Calculated Value miniature visualization in a graphical
# table.
#
# It expects one Visualization argument, detailsVis, and
# it configures the specified visualization to show details
# for the clicked cell.
#
# When executed as an action in a graphical table,
# the variable Context is bound to an instance of
# MiniatureVisualizationActionContext (see API documentation).
from Spotfire.Dxp.Application.Visuals import VisualContent
# This script assumes that the row axis of the Graphical Table
# is configured with one column: State.
#
# Get the miniature visualization and the value of the row
# axis hierarchy (the state column) for the clicked cell:
clickedMiniVis = Context.Visualization
state = Context.HierarchyPathValues[0]
# Get the content of the visual that shall be configured to
# show details. Use the most general type so that the script
# works for all VisualContent classes that have a Y-axis
# property. This works well for a Line Chart, for instance.
vc = detailsVis.As[VisualContent]()
# Configure the Title and YAxis of the details visualization:
vc.YAxis.Expression = clickedMiniVis.ValueAxis.Expression
detailsVis.Title = clickedMiniVis.Title + " for " + state
# Limit the data of the details visualization to only use
# data for the selected state:
vc.Data.WhereClauseExpression = "State = \"" + state + "\""