Tip of the Week

September 2010 - Posts

  • Analysis Specific Help for Files viewed in the Web Player

    In an earlier post, we discussed how to add instructions into an Analysis File which was meant to be viewed via the Spotfire Professional or Enterprise Player clients.  In this post, we will learn how to do the same thing , but for use in files viewed via the Web Player.


    By using Spotfire’s SDK, you can add custom help files to the platform. However, these help files are available all the time, no matter which Analysis File you are using. There is a need for a analysis specific help system to aide your consumers as they use the file.  This can be achieved by adding a Help button inside a Text Area, which will launch a HTML file displaying instructions and help for users.  This also serves as an added benefit of reducing the amount of text required inside a file itself, so that more real estate can be used for visualizations.

    To start, as the author of the file, you will need to use Spotfire Professional, and with your Analysis File open, add a Text Area.  Then go into edit mode (either by right clicking and selecting ‘Edit Text Area’ or by clicking on the pen in the top right of the Text Area).  You will then choose to add a Script Control.

    In the Script Control, you will add the following code:

    from Spotfire.Dxp.Application.Visuals import HtmlTextArea
    from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers
    from System.Text import StringBuilder

    from Spotfire.Dxp.Application.Visuals import HtmlTextArea
    from Spotfire.Dxp.Application.Visuals import VisualTypeIdentifiers
    from System.Text import StringBuilder

    sb = StringBuilder()

    sb.AppendLine("<script type='text/javascript'>")
    sb.AppendLine("function openWin() {")
    sb.AppendLine("window.open('http://spotfire.tibco.com/community','mywindow','width=400,height=200')")
    sb.AppendLine("}")
    sb.AppendLine("</script>")
    sb.AppendLine("<BODY>")
    sb.AppendLine("<INPUT type='button' value='Launch Help'onClick='openWin()'> ")

    textArea = Document.ActivePageReference.Visuals.AddNew[HtmlTextArea]()
    textArea.AutoConfigure()
    textArea.HtmlContent = sb.ToString()

     

     
    Once you have created the script you can click ‘OK’ to close the Edit Script Dialog. You can then execute your script, and it will create a new Text Area with a button in it called ‘Launch Help’.

     


    You can later remove the original Text Area you used to create the Script.  When this file is opened in the Web Player, the ‘Launch Help’ button will open up a new window with your desired contents (you will want to replace the URL in the script above with the URL to your help instructions).

    In this example, we just reference a web site using a URL, but we could reference a .chm help file or  include the instructions built into the document as properties and dynamically build the contents for the dialog as we did in the earlier post.

  • Using Background Images in a Map Chart

    Last week we discussed how to use ESRI Shape Files in Map Charts.  This week we will stay with the Map theme, but learn how to use Images as backgrounds inside a Map Chart, instead of ESRI Shape Files. These background images can be useful for a variety of things, not just traditional maps, but also maps of the human body, maps of a wafer chip, etc… We can add this just as a typical background image, but what we really want is to be able to place markers ontop of specific points on the background image, similar to what we can do with a Shape file.   To do this, assuming you do not have coordinates built into your data table, you will need to utilize tags inside Spotfire to map the points in your data to sections on your background image.

     

    Assume we have an image of the Boston subway system loaded as a background image in a Map Chart, as shown below.

     

     
    And we have a data table which has an entry every time someone uses a ticket at one of the subway stations.


     

     

    We will need to map the coordinates of each Station so that we can place the markers ontop of the correct location in the background image.

    To do this, we will first need to create a data table with two columns, X, and Y, to act as a data grid. For example, the subway image is rather detailed, so our data grid is 100 x 50.   I wrote a JavaScript file with a couple of loops to output a csv file which I could import into Spotfire for the Data Grid.
     
     
    Then we update the Map Chart Properties to use the Data Table we just added (the Data Grid) for markers, and set the Columns used to X and Y as shown in the following image:




     
    We also need to click on the “Position Settings…” button and confirm the position setting based off our data grid, in this case its 100 x 50.
    Then, while still in the Map Chart Properties dialog, goto the Shape section and  update the shape definition of the markers to be a the cross shown below. In addition reduce the size of the markers as well.
     

     

     

    When you are done, close the Map Chart Properties and you should see something similar to the following:

     

    The data grid is overlayed ontop of the subway map.  We will then want to mark records in the data grid over the various subway stations.  In order to do this, we will need to create a new Tag collection and create a new Tag for each Station we want to map.


     


    Once this is done, we can  mark records of for each Station, and assign those marked records to the appropriate Tag.
    After you have accomplished this for all the stations on the map, filter out the ‘untagged’ values and export the data table.

    Then you can use “Insert > Columns from External Data” to merge in the X and Y columns from the exported data into the data table containing the popularity of each station.

    Finally, go back into the Map Chart Properties dialog, and update the data table used to be the one with the raw data for the popularity of each station. Make sure you use the same position settings as you did with the Data Grid.  The end result is shown below, where you have values marked ontop of the background image in the correct location.
     

     

     

    As we mentioned before, this is not limited to traditional maps.
     
     

    If you are interested in learning more about Maps or other visualization types in TIBCO Spotfire, please consider taking our Essentials training courses.

    Thanks for Christof Gaenzler for the concept behind this tip of the week.

     

  • Using ESRI Shape Files in Map Charts

    Many Spotfire users have little or no knowledge of ESRI or ‘Shape’ files which are used in TIBCO Spotfire. The good news is that, since version 3.0,  Spotfire natively understands this file format. When you load the shape files , just like you would load a text file, you will be able to view the underlying data table, as shown below:


     
    This example above uses US zip (postal) codes and the shapes down the left hand side are the sub-regions which relate to each zip code. However, by default, these are usually too small to see. The visualization above is just a standard Spotfire Table, so you can change the height of the rows like this, by modifying the Table Properties:

     

     

     
    These views should help you to understand the structure of a simple Shape/ESRI file. The important point to note is that these files contain location information inside the data table: they are not simply images like JPEG or GIF, but are more powerful than that.

    Once you have the file loaded, you can also relate them to other data tables.  In the example below, there are two map views, one at a high level showing one color for the whole of Europe, and another map which has one color for each of the following countries: UK, Germany, Italy and Spain.

    Here are the map regions:

     

     

    And here is the simplified data we want to plot. The ‘values’ could be oil well sizes, lab results, financial status or anything else…
     

     

    To get this example to work,  you then need to make a copy of the data table shown above. The first Map Chart will be linked on the Continent column, and the other will be linked to the Map Chart based off the Country column.

    Below is the final output showing the two Map Charts. 

     



  • Conditionally displaying comments on a plot

    There are times when you may want to conditionally label points on a graph.  For example, let’s say you have sales data, and a small percentage of these records have a comment.  You may want to display the comment as a label on a chart, and display no label for the records with no comments.

    The first step to implement this is to create a calculated column which will output ‘yes’ if you have a comment for that row , otherwise ‘no’.  Assuming our comment column is called ‘Comments’, the expression is shown below:




    Next, we should update our plot to show a label by the 'Comments' column and only show labels for marked records.

     



    Once this is done, we now need to create two bookmarks: one with all the comment records marked and another with none marked.  

    The easiest way to do this is to create a Cross Table which displays just the ‘Comment Flag’ column we created earlier on the vertical axis and ‘Row Count’ on the bottom axis.

     



    Next, mark the ‘yes’ row in the Cross Table and then click the ‘Capture Bookmark’ icon in the toolbar and save the bookmark as ‘Show Comments’.  Then unmark all records and click ‘Capture Bookmark’ this time saving the bookmark as ‘Hide Comments’.

    The last step is to open up a Text Area and add two Action Control buttons. The first is called ‘Show Comments’ and will include the Marking selection from the ‘Show Comments’ bookmark and the second is called ‘Hide Comments’ and will include the Marking selection from the ‘Hide Comments’ bookmark.

     


     

    NOTE: The reason we create the calculated column and display the cross table is so that it is easier to mark all records with comments so we can bookmark it. You can always show the comments in a table chart as well and mark them that way, so that no calculated column has to be created.

    You can then delete the Cross Table, and the finished product will have two buttons to show and hide the comments as labels on the given chart.

     

Syndication

Other Spotfire Blogs

Spotfire's interactive information visualization and analytic solutions give users a remarkable experience for quickly and easily querying data and reporting results for superior business intelligence. From portfolio management and customer retention programs to key processes such as CRM, marketing, research, bioinformatics, yield and asset management and design for manufacturing, enterprises around the world rely on Spotfire's business analytics software to improve operational performance.

©Copyright 2000-2011 TIBCO Software Inc | Privacy Policy | Terms of Use I Blog I Contact Us I Content Center