- Are you frustrated with the Spotfire Text Area?
- Do you find all the different languages that can be implemented in Text Areas confusing?
If you answered yes, then this post is for you. Many of my blog post ideas come from questions I had as a new or developing Spotfire user. I distinctly remember getting frustrated enough with the Text Area GUI to decide to learn HTML. It’s been a long journey that is not at all over. However, now that I have worked with Text Areas and code for a while, it is time to write a post explaining the different languages and ways that code can be implemented.
First, I want to share my evolution as a Text Area user. You might be able to relate to it…(this is me after taking the Advanced Configurations course from TIBCO)…
The Text Area Struggle is Real
…oh hey look, these buttons are handy…and I can add pictures!
…man, these buttons don’t do what I want all the time. Maybe I’ll learn a bit of HTML and see if I can’t make this better.
…HTML is great!! This is so much better. Wait, what’s CSS? Is this actually easier?
…I’m getting my CSS and HTML confused…DAMN!!!
…jQuery looks easier
…NOTHING WORKS! !#&@^#@)@_#$%
…and now that we upgraded and everything I wrote is broken.
…but it does get easier.
List of Languages
There are five languages that can be used in Spotfire Text Areas.
I started to get a better handle on Text Areas when I realized that Spotfire page or Text Area is like a mini web page. And what language are web pages built in? HTML! Actually, Spotfire is using a web browser called Chromium under the hood. Thus, Spotfire displays are basically a custom version of Chrome.
Most people edit Text Areas by right-clicking and selecting Edit Text Area. This editor is a GUI (graphical user interface) that creates HTML. You can see that HTML by selecting Edit HTML instead of Edit Text Area. This is what it looks like.
Sometimes the GUI gets it right, but a lot of times it doesn’t, as you well know. The best example I can give of the GUI not getting it right copy and paste from Microsoft Word. That is ALWAYS a disaster. I’m sure you have tried it because the Spotfire Text Areas don’t have spell check. Don’t do it. Just work on your HTML. You can do a lot with a little. TRUST ME.
So, to even begin to address the shortcomings of the GUI, you need to learn a little bit of HTML. I’m tempted to throw some basics out there, but that would make this post unbearably long. I’ll save it for another time. I will recommend checking out W3Schools and this HTML template on the Exchange. I built it, and I’ll admit it needs a bit of updating but it’s a good starting place.
Next, let’s talk about CSS, which stands for Cascading Style Sheets. CSS codes how HTML elements appear in web pages/Text Areas. It is efficient. For example, rather than adding attributes to HTML tags, use CSS in a <style> tag. The CSS will apply to the entire web page/Text area. If you code strictly in HTML, you will have to add attributes to all your tags. There is no limit to how much style you can create. Do a little or do a lot. For example, you can style borders, padding, margins, alignment, fonts, formats, etc. This is precisely what I am doing in the screenshot below.
That might have been a little bit overwhelming, but take a look at this blog for a simpler example. The post describes how to use CSS to style Spotfire buttons, rather than formatting each and every button. (You’re welcome!)
Lastly, we have IronPython. IronPython is the .NET version of Python. Python is better known in data science circles than web programming circles, but it still important in Text Areas. In Spotfire, IronPython scripts use buttons to trigger them, or they can be set up to execute when the value of a document property changes. Here is an example. In this case, I have an input document property that will contain a stock ticker symbol. Then, I use an IronPython script to call an API to return the value and a chart. The button triggers the call to the API, using the document property.
Guest Spotfire blogger residing in Whitefish, MT. Working for SM Energy’s Advanced Analytics and Emerging Technology team!