31 August, 2017

Spotfire Internals

SBDF and STDF Reader

SBDF and STDF Reader

Spotfire can read table data from different type of files.

But there are two native Spotfire formats:

  • STDF (Spotfire Text Data File) format
  • SBDF (Spotfire Binary Data File) format

Both supported by the Rocket Table

Rocket Table is a lightweight table viewer for files in SAS7BDAT, SBDF, STDF and CSV formats. It supports sime nice features like: filtering, sorting, highlighting. It is cross-platform and minimalistic.

So if you have *.sbdf or *.stdf files, but don't have Spotfire, you are able to read these files using this application.

Rocket Table

See more about Spotfire on GitHub

Xantorohara, 2017-08-31, Spotfire

Create, get, remove datatable relations in Spotfire using Python

Create, get, remove datatable relations in Spotfire using Python

Imagine you have a data table with countries:

Country code Country name
HKG Hong Kong
ISR Israel
MYS Malaysia

And data table with languages related to these countries:

Country code Language Percentage
HKG Canton Chinese 88.7
HKG Chiu chau 1.4
HKG English 2.2
HKG Fukien 1.9
HKG Hakka 1.6
ISR Arabic 18.0
ISR Hebrew 63.1
ISR Russian 8.9
MYS Chinese 9.0
MYS Dusun 1.1
MYS English 1.6
MYS Iban 2.8
MYS Malay 58.4
MYS Tamil 3.9

Where "Country code" is the common field.

You would like to create link between these tables. It is possible to create relation manually in Spotfire, but for some reason you need to create it automatically via Python script.

Create relation between tables

def add_relation(table1, table2, link_expression):
    Document.Data.Relations.Add(
        Document.Data.Tables[table1],
        Document.Data.Tables[table2],
        link_expression)

Usage:

add_relation("country", "lang", "[lang].[Country code]=[country].[Country code]")

Now you are able to select country in the "country" table and all related languages from the "lang" table will also be selected.

Like here:

Spotfire linked tables

Get relation expression

def get_relation(table1, table2):
    return Document.Data.Relations.FindRelation(
        Document.Data.Tables[table1],
        Document.Data.Tables[table2])

Usage:

print(get_relation("country", "lang").Expression)
# [lang].[Country code]=[country].[Country code]

Delete relation

def del_relation(table1, table2):
    relation = Document.Data.Relations.FindRelation(
        Document.Data.Tables[table1],
        Document.Data.Tables[table2])
    if relation:
        Document.Data.Relations.Remove(relation)

Usage:

del_relation("country", "lang")

See more about Spotfire on GitHub

Xantorohara, 2017-08-31, Spotfire 7.8.0

30 August, 2017

Check that Spotfire document has a Visualization on a Page using Python

Check that Spotfire document has a Visualization on a Page using Python

Just use this simple Python function:

def has_visualization(page_name, vis_name):
    for page in Document.Pages:
        if page.Title == page_name:
            for vis in page.Visuals:
                if vis.Title == vis_name:
                    return True

Try it:

print(has_visualization("SomePage", "SomeChart")) # True
print(has_visualization("SomePage", "ChartNotExists")) # None

Spotfire Visualization

See more about Spotfire on GitHub

Xantorohara, 2017-08-30, Spotfire 7.8.0

Check that Spotfire document has a Page using Python

Check that Spotfire document has a Page using Python

Just use this simple Python function:

def has_page(page_name):
    for page in Document.Pages:
        if page.Title == page_name:
            return True

Try it:

print(has_page("Page")) # True
print(has_page("Page (2)")) # True
print(has_page("SomePage")) # True
print(has_page("PageNotExists")) # None

Spotfire Pages

See more about Spotfire on GitHub

Xantorohara, 2017-08-30, Spotfire 7.8.0

Show URLs in Spotfire Table

Show URLs in Spotfire Table

Spotfire uses auto-detection to set URL renderer for a table column. So, if all values in a column start with "http://" or "https://" it sets URL renderer.

Like here:

Spotfire table with URLs

Moreover, it is possible to set URL renderer for columns in which the values do not look like URLs. But these values can be used as parameters for URLs.

Like here in the "Param Links" column:

Spotfire table parameterized URLs

The only step you need is to specify URL with a placeholder:

Spotfire URL renderer settings

via "Table Properties->Columns"

Spotfire column properties

Don't forget to choose "Link" as a "Renderer".

See more about Spotfire on GitHub

Xantorohara, 2017-08-30, Spotfire 7.8.0

29 August, 2017

Show images in Spotfire Table

Show images in Spotfire Table

Imagine that you have a table like this:

Service Name Service Id
Slack slackhq
Travis CI travis-ci
Zenhubio zenhubio
Atom atom

And you would like to see icon images in the "Service Id" column.

You know there is a storage with images, with URLs like this:

https://assets-cdn.github.com/images/modules/site/integrators/${Service Id}.png

So, actually these images should be used instead of appropriate "Service Ids":

https://assets-cdn.github.com/images/modules/site/integrators/slackhq.png
https://assets-cdn.github.com/images/modules/site/integrators/travis-ci.png
https://assets-cdn.github.com/images/modules/site/integrators/zenhubio.png
https://assets-cdn.github.com/images/modules/site/integrators/atom.png

It is easy to achieve it in the Spotfire:

  • Open "Table Properties" -> "Columns"
  • Select column
  • Set "Renderer" type as "Image from URL"
  • Click "Settings..." and put your URL with {$} as a placeholder

Spotfire screenshot

Now you have pretty images in Spotfire Table

See more on GitHub

Xantorohara, 2017-08-29, Spotfire 7.8.0