Customer Banners (Ads) - SpiceUp. AX and SpotfireX Disclaimer

If you find this site useful and you want to support, buy me a coffee   to keep this site alive and without ads.

Get Image Layer dimensions on Map Visualization

 Just uncheck the marker layer or remove the Positioning markers (geocoding or coordinate columns) from the marker layer, go back to the image layer and hit the reset button


 Add autocomplete to an existing Spotfire input control (webplayer and cliente )


<div id="autocomplete"> 
<SpotfireControl id="spotfire_Input" />

<div id="autocomplete-data" hidden>
John Doe,Jane Smith,Robert Johnson,Michael Brown,Emily Davis,Sarah Miller,James Wilson,Patricia Moore,Richard Taylor,Linda Anderson

note: replace the autocomplete-csv-values with a uniqueConcatenate([column]) calculated value, but you can use as is to test the script


function setupAutocomplete(id){
    let currentFocus = -1;
    let isScriptTriggered = false;

    const autoCompleteDiv = document.getElementById(id);
    autoCompleteDiv.position = "relative";
    const spotfireInput = autoCompleteDiv.firstElementChild;
    const autocompleteInput = document.createElement('input'); = id + "Input"; = 'none';

    // Copy style from SpotfireControl to input
    for (let style in {
        if ( &&[style]) {
  [style] =[style];

    //popup for autocomplete items
    const popup = document.createElement('div'); = `${spotfireInput.offsetWidth}px`; = 'absolute'; = '100';
    popup.className = 'autocomplete-items'; = 'none';

    //observer for csv values as it comes from a calculated value
    const csvObserver = new MutationObserver(() => {
        csvValues = document.getElementById(id + '-data').innerText.split(',');

    csvObserver.observe(document.getElementById(id + '-data'), {
        childList: true,
        characterData: true,
        subtree: true

    let csvValues = document.getElementById(id + '-data').innerText.split(',');

    function toggleInputDisplay() { = ''; = 'none';
        spotfireInput.value = autocompleteInput.value;
        isScriptTriggered = true;
        isScriptTriggered = false;


    autocompleteInput.addEventListener('click', () => {
        autocompleteInput.value = "";

    autocompleteInput.addEventListener('input', () => {
        const inputValue = autocompleteInput.value;
        const filteredValues = csvValues.filter(name => name.toLowerCase().includes(inputValue.toLowerCase()));
        popup.innerHTML = '';

        filteredValues.forEach(value => {
            const div = document.createElement('div');
            div.className = "sf-element-dropdown-list-item";
            div.innerHTML = value.replace(new RegExp(inputValue, 'gi'), match => "<span class='highlight'>" + match + "</span>");

            // Copy style from src input to div
            for (var style in {
                if ( &&[style]) {
          [style] =[style];

            div.addEventListener('click', () => {
                autocompleteInput.value = value;
       = 'none';
                spotfireInput.value = value;
                currentFocus = -1;


        }); = filteredValues.length ? 'block' : 'none';

    autocompleteInput.addEventListener('keydown', (e) => {
        const divs = popup.getElementsByTagName('div');
        if (e.keyCode == 40) { // Down arrow
            if (currentFocus >= divs.length) currentFocus = 0;
        } else if (e.keyCode == 38) { // Up arrow
            if (currentFocus < 0) currentFocus = divs.length - 1;
        } else if (e.keyCode == 13) { // Enter
            if (currentFocus > -1) {
            } else {
                spotfireInput.value = autocompleteInput.value;
                isScriptTriggered = true;
                isScriptTriggered = false;
        } else if (e.keyCode == 27) { // Escape key
            isScriptTriggered = true;
            isScriptTriggered = false;

        for (let i = 0; i < divs.length; i++) {
        if (currentFocus > -1) {

    spotfireInput.addEventListener('focus', () => {
        if (isScriptTriggered) return;
        // When spotfireInput gets focus, hide it and show input = 'none'; = '';
        autocompleteInput.value = "";

    autocompleteInput.addEventListener('blur', () => {
        setTimeout(() => {
   = 'none';
        }, 200);

    const styleTag = `

        outline: none; 

        background-color: #fff;
        border:1px solid #c6c8cc;

        .autocomplete-items div:hover, 
        .autocomplete-items div.over {
        color: #FFFFFF !important;
        background-color: #7289F9;

        .highlight {
        font-weight: bold;
        text-decoration: underline;

    autoCompleteDiv.insertAdjacentHTML('afterEnd', styleTag)



Preventing zoom when scrolling with the mouse wheel on visuals with zoom sliders

Here is how to prevent zoom on visualization that have zoom sliders on to zoom when scrolling the page down using the mouse wheel


divsWithZoomSliders = [...document.querySelectorAll(".sf-element.sf-element-visual")].filter(div => div.querySelector(".sf-element-zoom-slider"));
divsToDisable = => div.querySelector(".sf-element.sf-element-canvas-visualization"));
divsToDisable.forEach(div => {div.firstChild.addEventListener('wheel', function(event) {event.preventDefault()}, { passive: true })});

Highlight Visual based on Document Property

 When a document property changes, it highlights a visual. This can be useful for data analysis to pay close attention to visuals that require focus


<pre id=docPropValues xhidden>

 "Indexed price charter":"<SpotfireControl id="5858b9bd6d344a98ba87c742af3d9f05" />", 
 "Top holders by percent held":"<SpotfireControl id="96f46c37e0ab4731a43124c827f3956f" />",
 "Historical data":"<SpotfireControl id="5302059ba4724d1f8e45c6a1b95bcfe6" />",
 "Calendar quarter estimates":"<SpotfireControl id="21331969168d4e2fb600d4ed1e0004be" />"


//finds visuals in which title contains visualTitle (use *= for contains, ^= starts with, $= ends with or = exact match)
elements = Array.from(document.querySelectorAll(".sf-element.sf-element-visual"));
function highlighVisual(visualTitle){

//set background for those visuals found
elementWithChild = elements.filter(element => element.querySelector(
[title*='"+visualTitle+"']") !== null); //<-- change here for search operator

element = document.querySelector('#docPropValues'); 

observer = new MutationObserver(_ => {
json = JSON.parse(element.innerText);

//reset visual backgrounds
.filter(([key, value]) => value === "True")
.map(([key, value]) => key)
.forEach(visualTitle => {highlighVisual(visualTitle)});

observer.observe(element, {
    childList: true,
    characterData: true,
    subtree: true

IronPython Show/Hide Items

from Spotfire.Dxp.Application.Visuals import BarChart
barChart = vis.As[BarChart]()

#get filter rules
gotFilerRules,filterRuleCollection  = barChart.TryGetFilterRules()

#delete all filter rules
if gotFilerRules:
for filterRule in filterRuleCollection:
#print filterRule.DisplayName, filterRule.Expression

#add a filter rule collection to show top 5 axis values
#filterRuleCollection.AddTopNRule("THEN [Y.FinalValue]",5,True) 

Create trellised visualizations based on marking

from Spotfire.Dxp.Application.Visuals import BarChart, VisualContent, VisualTypeIdentifiers, LabelOrientation, BarChartOrientation  

from Spotfire.Dxp.Application.Layout import LayoutDefinition

#script params
dataTable = Document.Data.Tables["Best predictors"]

#delete all barchart visuals
page = Document.ActivePageReference
for vis in page.Visuals:
if vis.TypeId == VisualTypeIdentifiers.BarChart:

#The last visual left should be the treemap
tm = next(iter(page.Visuals))

#create a barchart template
bc = Application.Document.ActivePageReference.Visuals.AddNew[BarChart]()
bc.Data.DataTableReference = dataTable
bc.Title = "${DataTable.DisplayName}"
bc.Legend.Visible= False
bc.YAxis.Expression = "Sum([p-value])"
bc.XAxis.Expression = "<[Case Name]>"
bc.Orientation = BarChartOrientation.Horizontal

#duplicate as many barcharts as selected sites from marking

siteNames = Document.Properties["markedSites"]
sites = [s.strip() for s in siteNames.split(',')]

#setup first barchart
firstSite = sites.pop()
bc.Title = firstSite
siteVisuals = [bc]

bc.Data.WhereClauseExpression = "[Site_No] = '"+firstSite+"'"

#create visuals
for site in sites:
vis = page.Visuals.AddDuplicate(bc.Visual)
vis.Title =site
bc = vis.As[BarChart]()
bc.Data.WhereClauseExpression = "[Site_No] = '"+site+"'"

#arrange visuals
#tm is the existing treemap and will take 10% of the screen
ld = LayoutDefinition()
ld.Add(tm, 10)

# Begin a stacked section for the second column at 70% of the screen

i = 0
for bc in siteVisuals:
    if i % 3 == 0:
        if i > 0: ld.EndSection()
    i += 1


To trigger this script when marking changes, create a bypass data function. The script definition is simply an 'x' and so is the input and output. Make sure it runs automatically. The script parameters for the 'x' input is "UniqueConcatenate([Explore_YieldData - Explore_YieldData].[Site])" limited by the blue Marking. The output is a document property called "markedSites" that must be setup to trigger the above script when its value changes.



<span id="color">
   <SpotfireControl id="Input Filed goes here" />


colorInput = document.querySelector("#color input")

Here is a use case on how to use it.
from Spotfire.Dxp.Application.Visuals import CombinationChart, CategoryKey
from System.Drawing import Color

# cast visual to combo chart
combinationChart = vis.As[CombinationChart]()

# get script parameters from doc props
category = CategoryKey("Banana") 

# get the color from the color picker doc prop
hcolor = Document.Properties["color"] #hexadecimal color
color = Color.FromArgb(int(hcolor[1:3], 16), int(hcolor[3:5], 16), int(hcolor[5:7], 16))

# change the color for the corresponding category

Change Series on Combination Chart

Each document property triggers the corresponding iron python script when the value changes

for the category doc prop: reads the combination chart color and series type from the selected category

from Spotfire.Dxp.Application.Visuals import CombinationChart, CategoryKey

#cast visual to combo chart
combinationChart = vis.As[CombinationChart]()
category = CategoryKey(Document.Properties["category"])

#get type
Document.Properties["type"]  = str(combinationChart.IndexedSeriesType[category])

#get color
import re
color = str(combinationChart.ColorAxis.Coloring.GetColorForCategory(category))
color = re.findall(r"\[([^\[\]]+)\]", color)[0]
Document.Properties["color"] = color.lower()

for the color doc prop: changes the color for the selected category

from Spotfire.Dxp.Application.Visuals import CombinationChart, CategoryKey
from System.Drawing import Color

#cast visual to combo chart
combinationChart = vis.As[CombinationChart]()

#get script parameters from doc props
category = CategoryKey(Document.Properties["category"]) #string representing a category from the series

color = Color.FromName(Document.Properties["color"]) #named color such as blue, green, magenta, beige...

#color = Color.FromArgb(255,0,0) #if you know the rgb values
#if hexadecimal color (hc) comes from a color picker (#FF0000)
#color = Color.FromArgb(int(hc[1:3], 16), int(hc[3:5], 16), int(hc[5:7], 16)) 

# change the color for the corresponding category

and for the type dropdown that changes the series type for the selected category:

from Spotfire.Dxp.Application.Visuals import CombinationChart, CombinationChartSeriesType, CategoryKey

#cast visual to combo chart
combinationChart = vis.As[CombinationChart]()

#get script parameters from doc props
category = CategoryKey(Document.Properties["category"])

#string representing a category from the series
type = CombinationChartSeriesType.Bar if Document.Properties["type"] == "Bar" else CombinationChartSeriesType.Line 

# change series type as Bar or line
combinationChart.IndexedSeriesType[category] = type

Reset Visible Filters

#1. Take the filter panel from the desired page in filter panel
#filterPanel = Document.Pages[1].FilterPanel
filterPanel = Document.ActivePageReference.FilterPanel

#1.1 Select the filtering scheme to use (optional)
#filterringScheme = Document.FilteringSchemes[Document.Data.Filterings["Filtering scheme"]]
#filterPanel.FilteringSchemeReference = filteringScheme 

#2. Reset only visible filters
for tableGroup in filterPanel.TableGroups:
   for filterHandle in tableGroup.FilterHandles:
      if filterHandle.Visible:

Sync zoom sliders

 sync the zoom sliders to the exact same range between different visuals.

The style attribute of the activeVisual tag hides the input visibility. It has an input property control that holds the visual title. This title is updated by the javascript that takes the last active visual on mouse over. This property control is then passed as a parameter for the sync.ip to take the last active visual as a reference.


<div style="position:fixed;left:-1000px" id="activeVisual">
   <SpotfireControl id="input button" />
<span id="syncBtn">
   <SpotfireControl id="replace with button to run sync.ip" />
 <SpotfireControl id="optional reset button that runs reset.ip" />


from Spotfire.Dxp.Application.Visuals import AxisRange, ScatterPlot

# We detect which visual is "active"
sourceVisualTitle = Document.Properties["activeVisualTitle"]

visX = None

# Iterate through all visuals on the active page
for visual in Document.ActivePageReference.Visuals:
    if visual.Title == sourceVisualTitle:
visX = visual

# We need to cast the visual script parameters visA, visB and visC to ScatterPlot object or whatever visual you are using in your analysis

scatterX = visX.As[ScatterPlot]()
scatterA = visA.As[ScatterPlot]()
scatterB = visB.As[ScatterPlot]()
scatterC = visC.As[ScatterPlot]()

# We create a reference to the Y axis ZoomRange from the first visual (A)
zoomXy = scatterX.YAxis.ZoomRange

# We need to create an AxisRange object based on visual X range settings for Y axis
axisRangeX = AxisRange(zoomXy.Low, zoomXy.High)

# Apply scatterA,B and C to the selected axisRange
scatterA.YAxis.ZoomRange = axisRangeX
scatterB.YAxis.ZoomRange = axisRangeX
scatterC.YAxis.ZoomRange = axisRangeX


from Spotfire.Dxp.Application.Visuals import AxisRange, ScatterPlot

# We need to cast the visual parameters visA, visB and visC to ScatterPlot object or whatever visual you are using in your analysis

scatterA = visA.As[ScatterPlot]()
scatterB = visB.As[ScatterPlot]()
scatterC = visC.As[ScatterPlot]()

#reset scatterA,B and C ranges


function getActiveVisual(){
 vis = document.querySelector(".sfpc-active .sf-element-visual-title").innerText.trim();
 inp = document.querySelector("#activeVisual input");
 inp.value = vis;

document.getElementById("syncBtn").onmouseover = getActiveVisual

Loop through pages


<span id="startButton" style="cursor:default">[Start]</span>
<span id="stopButton" style="cursor:pointer">[Stop]</span>


var pages = [0, 1, 3];   //◄ Select the pages you want to cycle through. 0 is the first one
var timeout = 10000;      //◄ Select the time in ms to delay between pages. 10000 is 10 seconds

//maintain a registry of interval in case multiple are triggered to stop them all at once with the stop button


function startCycle() {
(function cycle(){
page = tmp.shift();
if(!tmp.length) tmp=[...pages]
window.intervalIds.push(setTimeout(cycle, timeout));

function stopCycle() {
  console.log("Slideshow Ended")

function goToPage(x) {

// Hook html buttons to start and stop functions
document.getElementById("startButton").onclick = startCycle;
document.getElementById("stopButton").onclick = stopCycle;

List table columns

# Replace with the actual table name
table_name = "Data Table"  

# Get the table by name
table = Document.Data.Tables[table_name]

# Iterate through the columns and add their names to the list
for column in table.Columns:
print (column.Name)

# Iterate through all columns and add their column names and data types
for t in Document.Data.Tables:
   print t.Name
   for col in columnCollection:
      print "\t", col.Name, "(",col.Properties.DataType,")"

Update a multiple select list box

The List box (multiple select) Property Control holds an array of values. Understanding this makes it easy to update its values

Filter Property Control

Create Searchable dropdowns / autocomplete with the help of Filters to act as Input Controls 

The map is not driven by the filter, but an expression that contains a document property. The filter drives the Property Control

This recipe allows you to leaverage the power of filters to drive property controls to enhance the user experience of Spotfire. 


  • New filtering scheme
  • A filter from the new filtering scheme
  • A calculated Value
  • 1 Dropdown or Input property control
  • 1 Input field property control
  • html and javaScript


<div id="myInput" >
  <span class="ddown">
    ◄spotfire 'selection' input property control goes here►
    <span class='srchBtn'>⋯</span> 
  <span class="sfFltr"> ◄spotfire filter(s) goes here► 
    <span class='closeBtn'>✕</span> 
  <div class="sfCalcVal">◄spotfire calculated value from new filtering scheme goes heere►</div>
  <div class="sfInput">◄spotfire 'selection' input fileld control goes here► </div>


//script parameters
target = "myInput"

//node elements
container = document.getElementById(target);
dropdown = document.querySelector(".ddown");
filter = document.querySelector(".sfFltr");
searchButton= document.querySelector(".srchBtn");
closeButton = document.querySelector(".closeBtn");
selection = document.querySelector(".sfCalcVal");
sfInput = document.querySelector(".sfInput input");


    dropdown.hidden = true;
    filter.hidden = false;

//monitor selection when its value changes
observer = new MutationObserver(()=>{
  sfInput.value = selection.innerText;

observer.observe(selection, {childList: true,subtree: true});

//apply styling and attributes 
filter.hidden = true;
selection.hidden = true;
css = `<style>
.closeBtn, .srchBtn{

.sfFltr {position:fixed;z-index:1;}




  1. Open the Sales and Marketing analysis from the library/samples folder
    • Delete all but Sales performance and just keep the map
    • Limit the SalesAndMarketing map layer with expression:
      upper([Store Name]) ~= Upper("${selection}")

  2. Create a new filtering scheme called "filtersForPropertyControls" or something like that
    • you can do that by right clicking the filter panel and show the filtering scheme menu

  3. Change the [Store Name] filter type to use for the input property control as List Box Filter

  4. Make sure the "filtersForPropertyControls" filtering scheme IS NOT selected in the filters panel

  5. Add a Text area, edit in html and copy the html below 

  6. Create an input or dropdown property control linked to a new document property called "selection" from a Text area.  Place the control as the first child of the <span class="ddown"> element
    • if using a dropdown, make sure to select unique values from [Store Name] column

  7. Add the filters from the "filtersForPropertyControls" filtering scheme inside the <span class="sfFltr"> element

  8. Create a calculated value inside the <div class="sfCalcVal"> to get the first element from the filter and limit the data only from the "filtersForPropertyControls" filtering scheme
    • First([Store Name])
    • very important not to leave any spaces. For example:
      <div class="sfCalcVal"><SpotfireControl id="2d1..26cc" /></div>

  9. Insert an Input field property control inside the <div class="sfInput"> element and link it to the "selection" document property

  10. Save the text area and Insert the JavaScript below

IronPython Terminal

script to run ironPython scripts

import sys
from io import StringIO
code = Document.Properties["input"] 

capturer = StringIO()
sys.stdout = capturer

sys.stdout = sys.__stdout__
output = capturer.getvalue()
except Exception as e:
output = str(e)


script to run Python code via a data function

import sys
from io import StringIO
capturer = StringIO()
sys.stdout = capturer

sys.stdout = sys.__stdout__
output = capturer.getvalue()
except Exception as e:
output = str(e)


<SpotfireControl id="input field multiple lines property control" />
<SpotfireControl id="action control that runs the above script" />

<pre style="height:50%;background:blue;color:yellow;overflow:auto;padding:10px;border:3px inset">
<SpotfireControl id="output document property (Label)" /></pre>

Example code to list python packages on TIBCO Cloud spotfire from this termnal

import pandas as pd
import pkg_resources

installed_packages = pkg_resources.working_set
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
    for i in installed_packages])
package_list = [[r.split('==')[0],r.split('==')[1]] for r in installed_packages_list]

packages = pd.DataFrame(columns=["Package Name", "Package Version"])

idx = 0
for pkg in package_list:
    packages.loc[idx] = [pkg[0], pkg[1]]
    idx += 1


Note: if you put this code on a data function and you want to return a data table with the list of packages, then remove the last line and set the output parameter to point to the packages variable

Note: Please be careful running this script in production environments.

With great power comes great responsibiliy

Checkbox List Property Control


On a text area, create a multiple select list box property control and call it "myStringList" and another string input field property control and call it "transfer". The transfer document property should trigger the following script when it changes:

#update multiSelect
Document.Properties["myStringList"] = Document.Properties["transfer"].split(",")
Edit the text area html and wrap the controls with a tag element with id "myCheckboxList"


<div id="myChecboxList">
   <SpotfireControl id="'myStringList' muiltiple selection list box" />
   <SpotfireControl id="'transfer' input control " />


id = "myChecboxList" 

//get items from multiSelect
ph = document.getElementById(id);
items = ph.innerText.split("\n").filter(x=>x!="..."&&x.trim());

//get checked values from csv
target = ph.querySelector("input");  
checked = target.value.split(",").filter(x=>x!=""); 

//create checkboxes
   val = items[i];
   cb = document.createElement("input");
   cb.type ="checkbox";
   cb.value = val;
   tn = document.createTextNode(" "+val);
   br = document.createElement("br");
   [br,cb,tn].forEach(e => {ph.appendChild(e)});

   //check if checked
   cb.checked = checked.includes(val)
   console.log(val,checked,val in checked) 


  cb.onclick = () => {
    vals = [...document.querySelectorAll(`#${id} input[type='checkbox']`)]
    target.value = vals.filter(x => x.checked).map(x => x.checked ? x.value : null);

   //hide input"fixed""

   //hide multiselect"none"  

JavaScript Radial Icon Menu

itemsPerLayer = 1

itemsPerLayer = 4


<div class="iconMenu">
 <SpotfireControl id="spotfire action control link 1" />
 <SpotfireControl id="spotfire action control link 2" />
 <SpotfireControl id="spotfire action control link 3" />
 <SpotfireControl id="spotfire action control link 4" />
 <SpotfireControl id="spotfire action control link 5" />
 <SpotfireControl id="spotfire action control link 6" />

<img class="icons fa-solid fa-bolt,fa-solid fa-bolt-lightning,icon-graph,fa-solid fa-arrow-trend-up,fa-solid fa-check,fa-solid fa-house"/>


description:converts spotfire links to an iconic menu. Supports font awesome and simple-line-icons

<div class="iconMenu">
   <a>spotfire link 1</a>
   <a>spotfire link 2</a>
   <a>spotfire link 3</a>
<img class="icons icon-user,icon-fire,fa-solid fa-arrow-trend-up"


//script parameters
let spaceBetweenLayers = 40;
let itemsPerLayer = 5; //◄ set to 1 for horizontal menu

style = `
<link  rel="stylesheet" href=""></link>
<link rel="stylesheet" href=""/>

.iconMenu {
  position: fixed;
  width: 50px;
  height: 50px;

.iconMenu a {
    position: fixed;
    width: 20px;
    height: 20px;
    background-color: #ccc;
    border-radius: 50%;
    justify-content: center;
    transition-timing-function: cubic-bezier(0,0,0,1);
    transition-duration: .5s; 
    display: flex;
    justify-content: center;
    align-items: center;
text-decoration:none !important;
    /*look and feel*/
    background: #1f83f2;
    box-shadow: 5px 5px 7px rgba(0, 0, 0, 0.25), inset 2px 2px 5px rgba(255, 255, 255, 0.5), inset -3px
3px 5px rgba(0, 0, 0, 0.5);
    color:white !important; 

.iconMenu a:last-child{opacity:1}
.iconMenu a:hover{
    background: #8f18f8;


let timeOutPID=0;
let boxShadow = document.querySelector(".iconMenu a").style.boxShadow;

function hover() {
  let gap = spaceBetweenLayers;
  let elements = document.querySelectorAll(".iconMenu a");
  elements.forEach((e, i) => {
    if(i==elements.length-1) return;
    let angle = (100 / itemsPerLayer) * (i%itemsPerLayer);
    i%itemsPerLayer||(gap+=spaceBetweenLayers) = `rotate(${angle}deg) translate(${gap}px) rotate(-${angle}deg)`;;
    e.onmouseover = resetDelayClose;
    e.onmouseout = delayClose;

function close(){
  let elements = document.querySelectorAll(".iconMenu a");
  elements.forEach((e, i) => {
    if (i==elements.length-1) return; = `translate(0px)`;"unset";

function delayClose(){
  timeOutPID = setTimeout(close,1234)

function resetDelayClose(){
  timeOutPID && clearTimeout(timeOutPID);

document.querySelector(".iconMenu a:last-child").onmouseover = hover;
document.querySelector(".iconMenu a:last-child").onmouseout = delayClose; 

//setup icons on links
icons = document.querySelector(".icons").classList.value.split(",")
icons[0] = icons[0].replace("icons ","");

document.querySelectorAll(".iconMenu a").forEach((e,i)=>{
  e.className = icons[i];
  e.title = e.innerText;


Add Autocomplete to an existing Spotfire input control (only webplayer)

Step 1

. Create a calcualted colum with the input data. For example:

"<option value=""" & [Holders] & """>" as [options] 

Step 2. Edit the html of a Text Area and Create an Input Property Control and wrap it with an identified tag. Example:

<a id="myTickers"><SpotfireControl id="60e360db89924916ab4790b20e85d339" /></a>

Step 3. Create a Calculated Value that concatenates the unique values of the calculated column in step 1:


Step 4. Wrap the Calcualted Value with an iddentified hidden tag. The id is the same as the id from step2 + "-data" sufix.  For example:

<a id="myTickers-data" hidden ><SpotfireControl Calculated Value Dynamic Item goes here /></a>

Step 5: Add the following javascript

//Note: only works on webplayer 
//<a id="autocompleteElement"><input /></a>
//<a id="autocompleteElement-data" hidden >uno,dos,tres,cuatro</a>   

function setupAutocomplete(id) {
  const autocomplete = document.querySelector("#"+id+" input");
  const datalist = document.createElement("datalist");"-datalist";
  const data = document.getElementById(id+"-data");

  const setData = () => {
    datalist.innerHTML = '';
    data.innerText.split(',').forEach(item => {
      let option = document.createElement('option');
      option.value = item;

  //run setData as soon as the calculated value changes
  const mutationObserver = new MutationObserver(setData);
  mutationObserver.observe(data, {subtree: true, childList: true} );
  setData(); // populate the datalist initially


Step 6: Save the analysis to the library and open it on web player because autocomplete does not work on the client.

Here is how everything looks together:

Spotfire Confirmation Dialogs

These funcitons are not officially supported by TIBCO and might change from one version to the other. Use of them at your own risk


okClick = function(x){alert("mee too!")}
noClick = function(x){alert("too bad")} 
xClick = function(x){alert("why cancel?")}

Spotfire.ConfirmDialog.showYesNoCancelDialog("Hello","do you like this",okClick,noClick,xClick)//last two areguments are optional



Spotifre.ConfirmDialog methods:

? are optional unknown arguments

To explore other function, open the console on developer tools and type Spotfire

Here are some more Spotfire API snippets

progress = Spotfire.Progress.createProgressOverlay(); 
progress.setText("Loading, please wait"); 

This ones can be useful to detect the user agent:


Explore the JavaScript Spotfire object properties and methods by searching for keywords

function traversePropertiesAndFunctions(obj, keyword, path = []) {
  for (let prop in obj) {
    if (obj.hasOwnProperty(prop)) {
      const currentPath = [...path, prop];

      if (typeof obj[prop] === 'function') {
        if (prop.toLowerCase().includes(keyword.toLowerCase())) {
          console.log(`Found function: ${currentPath.join('.')}`);
      } else if (typeof obj[prop] === 'object') {
        traversePropertiesAndFunctions(obj[prop], keyword, currentPath);
      } else if (typeof obj[prop] === 'string') {
        if (prop.toLowerCase().includes(keyword.toLowerCase())) {
          console.log(`Found property: ${currentPath.join('.')}`);

// Example usage
traversePropertiesAndFunctions(Spotfire, 'page');

Create a JavaScript programatically from IronPython

Create a Script

# Creates a JavasSript and adds it to the applicaiton document
from Spotfire.Dxp.Application.Scripting import ScriptDefinition, ScriptParameterCollection 
from Spotfire.Dxp.Application.Scripting.ScriptLanguage import JavaScript

#this is the JavaScript code we want to create
jsCode = '''
   function world(){

# 1. Creates the script
# 1.1 Define parameters (none in this example)
scriptParams = ScriptParameterCollection([])

# 1.2 Define the script with title, description, code, language, params and perform in transaction (not applies to JS)
scriptDef = ScriptDefinition.Create("myJavaScript","hello world",jsCode, JavaScript, scriptParams, False)

# 2. Adds the script to the application document

List available scripts

# list available scripts and their coding language
scripts = Application.Document.ScriptManager.GetScripts()
for script in scripts:
   print script.Name, " ► ",script.Language.Language

# Get a specific script
script = Application.Document.ScriptManager.TryGetScript("myJavaScript" )
   print "script found!:", script[1].Name, script[1].Language.Language
   print "script not found. Check the script name and try again"

Read the code from a script
script = Application.Document.ScriptManager.TryGetScript("renderImage")[1]
print (script.ScriptCode)

Attach a script form IronPyton to a text area

# Attach a script from IronPyton to a text area
# Attached and existing JavasSript from the Applicatin Document to a text area
from Spotfire.Dxp.Application.Scripting import HtmlTextAreaScript

# Get the script from the Document
script = Application.Document.ScriptManager.TryGetScript("myJavaScript" )[1]

# Prepare the script for the text area
htmlScript = HtmlTextAreaScript(script,{}) 

# Attach the script to the TextArea. ta is a TextArea Visualization script parameter
from Spotfire.Dxp.Application.Visuals import HtmlTextArea
vis = ta.As[HtmlTextArea]()