Tooltip

These IronPython scripts below show how to modify any of the Bar Chart visualization settings found on the Tooltip tab of the Bar Chart Properties dialog box in the Spotfire user interface.
Note

In each of the scripts below, it is assumed that the MyVis variable references the targeted visualization. See here for more information about referencing visualizations.

Hide the Default Tooltip Values:

By default, Spotfire includes a few built-in tooltip values for each visualization type. These default tooltip values cannot be edited or deleted, only hidden. It’s often useful to hide these before adding any custom tooltip values in your scripts.

The loop shown in this script should be run before adding any new tooltip values, so that only the default tooltip values will be hidden.

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()

# Hide all tooltip values
for t in myVis.Details.Items:
    t.Visible = False

Add a New Tooltip Value:

The script below shows how to add new tooltip values, either at a specific position in the tooltip value list, or at the last position. It also shows how to insert a tooltip value configured to show as an image from a URL, which is equivalent in the user interface to clicking the “Add…” button and selecting “Image from URL” from the “Show as:” dropdown.

from Spotfire.Dxp.Application.Visuals import *
from Spotfire.Dxp.Application.Visuals.ValueRenderers import *

myVis = myVis.As[Visualization]()


# Insert tooltip at a specific position
# 0 is first position, 1 is 2nd position, 2 is 3rd position, etc.
# Display name can be set with "[custom expression] as [display name]" syntax as below
myVis.Details.Items.InsertExpression(0, "SUM([Column A]) as [A]")  # 1st position
myVis.Details.Items.InsertExpression(1, "SUM([Column B]) as [B]")  # 2nd position


# Insert a tooltip at the last position
# Display name can be set with "[custom expression] as [display name]" syntax as below
myVis.Details.Items.AddExpression("SUM([Column C]) as [C]");


# Insert a tooltip as Image from URL:
tooltipItem = myVis.Details.Items.AddExpression("First([Image URL Column]) as [Pic]");
tooltipSettings = tooltipItem.SetValueRenderer(ValueRendererTypeIdentifiers.ImageFromUrlRenderer)
# The URL template is a string where {$} will be replaced by a data value
tooltipSettings.UrlTemplate = "{$}.com"
# Set the tooltip image size in pixels.  Allowed values are 1 to 1600. (This is a slider in the UI)
tooltipItem.ImageSize = 150

Change the Tooltip Format:

This script shows how to set the “Tooltip format” option shown at the bottom of the tooltip tab in the user interface.

from Spotfire.Dxp.Application.Visuals import *

myVis = myVis.As[Visualization]()

# Select "Value names and values":
myVis.Details.DisplayMode = DetailsDisplayMode.ColumnNames
# OR
# Select "Visualization properties and values":
myVis.Details.DisplayMode = DetailsDisplayMode.PropertyNames
Welcome!

The purpose of this website is to provide a comprehensive, accurate, and efficient IronPython reference for Spotfire developers.