Putting it All Together – Part II


Last week we saw an example of an Analytic Application, leveraging many components of the TIBCO Spotfire platform. This solution was deployed via the Web Player and integrated inside a Web site (our User Community site).

This week we will follow the creation of another live dashboard, but go one step further with our integration inside a Web site , using Spotfire as a component of a larger site.

In this example, we allow the user to enter any stock symbol, and then retrieve the stock's closing prices and volumes for the past 1000 days, including the current day.


Data Access
To access the stock data, we are using Yahoo Finance.  In order to link the data in and also make it available from the Web Player, we are actually using a Data Function. In this case, S+ will download the data from Yahoo Finance to the S+ working directory, and then will import it to S+ and pass it back to Spotfire for display.  The code for the Data Function is shown below:

yahooFinanceURL = paste("http://ichart.finance.yahoo.com/table.csv?s=", tickerSymbol, sep="")
tickerSymbolCSV = paste(tickerSymbol, "csv", sep=".")
download.file(yahooFinanceURL, destfile=tickerSymbolCSV)
stockQuotes = importData(tickerSymbolCSV)


The Data Function takes in one input parameter, which is a stock ticker. This ticker is passed in as a property.  In last week’s post, we exposed the property using a Property Control built into a Text Area in Spotfire. In this example, we expose the property using a HTML form outside of Spotfire, and pass it in using the Web Player APIs.



The default symbol is TIBCOs (TIBX), and the Data Table is saved as linked, so the latest data will be loaded every time when the file is launched.

The Data Function is setup so that every time the property value is changed, it re-executes.  This way, when a user wants to change which stock to display, they just update the form with the new symbol and click the ‘Update Data’ button.

Visualize the Data
Spotfire displays a Combination Chart (new in version 3.1) which uses multiple ranges to show both the Closing price and Volume per day. A table is also displayed showing more information, like the daily high and close prices.


 

 

Since this is Spotfire, we can go in much more depth in our visualizations and analysis, but for now we will stick with these two visualizations. We can expand on this in future tips.

Filtering Values
Using a combination of calculated columns and Property Controls (which were discussed in an earlier tip), we are able to display a Slider control, which allows the user to display stock data for only the specified number of previous days. For example, if the user selects 25, it will only show data for the previous 25 days:

 

Deploying the Application
As mentioned earlier, in this example, we want to highlight Spotfire as a component of another application. We have the two visualizations and the Slider control, but they are embedded in a Web site and being controlled by the same Web site.  To show this point even more, you can see the Headlines section of the Web site to the right of the Spotfire component. This headlines section displays the latest financial news for the selected ticker symbol, but has nothing to do with Spotfire directly. When the user updates the ticker symbol in the Web site, both Spotfire and the Headlines section update accordingly.


Want to see this web component in action? Visit http://spotfire.tibco.com/community/Downloads/stockData.html
 

What’s Next
In a future tip, we will expand this example to add a live portfolio analysis, showing details about your current portfolio. After viewing the portfolio as a whole, you can select stocks to drill down into more detail on with further analysis files.  All of this will be done via an external Web page similar to the one here.

In another future tip, we will take our dashboard to the next step and make it a Social BI dashboard , but allowing users to save state and comments on the analysis to share with others.