Tip of the Week

  • Setting Document Properties and Executing Scripts when an Analysis opens

    By using the ‘History Arrows’ navigation option, which is available starting in 4.0, it is possible to setup a page so that Scripts and Document Properties are loaded before the user starts the analysis process. 

    First, when you setup the analysis file, change the page navigation to ‘History Arrows’.

    Then, make sure the first page in the analysis includes some information about the analysis file along with an Action Control.   This Action Control can be attached to a Script which can do any of the following tasks:

    • Preset some Document Properties before the users goes into the rest of the analysis
    • Execute additional Scripts that should be executed before the user goes into the rest of the analysis
    • Set the page navigation mode back to ‘tabs’ or ‘step-by-step’ if desired
    • Redirect the user to the next page in the analysis

    Let’s assume we have a data set that looks at expense reports. These reports are filed using USD, GBP, EUR , and CAD currency. However, to analyze properly, we would like to convert everything to USD.  It may make sense that you want to convert the rates using the rates for the day the expenses were incurred, but let’s assume you want to load in the current rates at the time you are loading the analysis.   In a previous tip, we explained how to set the exchange rates up as Document properties.  


    Those properties are still using static values. What we would like to do is trigger the update of those properties using the current exchange rates.  To do this, we can use the following Script, which pulls the rates down from openexchangerates.org, and then updates the Document Properties with those values.

    from System.Net import WebClient
    from System.Collections.Generic import Dictionary
    from System.IO import StreamReader
    from System.Web.Script.Serialization import JavaScriptSerializer

    # get the data from openexchangerates
    url = 'http://openexchangerates.org/latest.json'
    wc = WebClient()
    wc.Headers.Add('Content-Type', 'application/x-www-form-urlencoded')
    requestData= wc.OpenRead(url)
    reader = StreamReader (requestData);
    response = reader.ReadToEnd()

    #Parse the results to get the exchange rates
    js = JavaScriptSerializer()
    exchangeRateDict = js.Deserialize(response,object)
    gbpRate = float(exchangeRateDict["rates"]["GBP"])
    eurRate = float(exchangeRateDict["rates"]["EUR"])
    cadRate = float(exchangeRateDict["rates"]["CAD"])

    #Set the Document Properties in the Spotfire file with the current rates
    Document.Properties["PoundConversion"] = gbpRate
    Document.Properties["EuroConversion"] = eurRate
    Document.Properties["CADconversion"] = cadRate

    In addition, using a previous tip, we can execute additional scripts from within this script  to perform any additional actions we want.

    Finally, if you want to set the page navigation back away from ‘history arrows’, you can by using the following code in your script:

    Document.Pages.NavigationMode = 0

    With 0 setting the navigation to ‘tabs’ and 1 setting the navigation to ‘links’. You can also redirect the user to the next page in the analysis:

    Document.ActivePageReference = Document.Pages[1]

    Now when the file is opened in the Web Player, the user can only view the first page in the analysis and must click on the ‘Click here to start’ button.

     

     

    Clicking on this Action Control  will trigger the Script discussed above, which will then update the exchange rates, change the navigation to tabbed, and then redirect the user to page 2 to start the analysis.


     

    If you are intersted in learning more about Script Controls, please consider taking our SP232 Script Controls course. The course was just recently updated, and now includes over 50 separate scripts used for demos or exercises. If you are intersted in registering for this online course, or learning more, please click here.

  • Adding a Filter Control into a Text Area

    Many times authors will want to allow a user to filter out values in a given column, but they do not want to expose the Filter Panel, as it can add confusion and complexity for a consumer. The workaround has been to use a Property Control to provide this capability from within a Text Area. This solution had a series of unwanted side effects if it was not setup properly.

    In 4.0, we now have the ability to embed a Filter for a specific Column directly into a Text Area.  This also allows authors to make efficient use of space and hide the Filter Panel. In addition, all the controls for a consumer are located in the same place, making it easier for them to control the dashboard.

    To add a Filter to the Text Area, select the new ‘Filter Control’ icon from the edit Ribbon inside a Text Area.

     

    You are then presented with a dialog box which allows you to specify which filtering scheme to use and then which filter you wish to add to the Text Area.

     

     

    Once you do that, the Filter Control will show up in the Text Area.

     

    While in Edit mode for the Text Area you can move the Filter around.  You cannot alter the Filter Text (ie. List Box, Radio Button, Checkbox, etc…) however.

     

    The Filter is a copy of the Filter instance from the Panel, so if you want to update the Filter Type, you need to do it from within the Filter Panel inside Spotfire Professional. That will then automatically update the Filter Type from within the Text Area.

    The use of the Filter should be identical to the Filter in the Filter Panel, with a few minor exceptions. When dragging a range slider in the Filter Panel, the visualizations are updated immediately while the dragging is still going on. The Text Area version will only update the visualizations when the dragging is finished.

    Interested in learning more about the new features of TIBCO Spotfire for version 4.0? If so, attend our live training webinar on February 29th. Click here for details.


  • Guiding the User Through an Analysis Without Showing all Pages Available

    When setting up an analysis file, there are times when you want the consumer to be guided through the analysis
    and not be distracted by the different pages available to click through. In version 4.0, this can be accomplished
    by setting the Page Navigation mode to ‘None’.



    Once you do this, you will then need to use an Action Control or Script Control to navigate between pages.

    NOTE: Users inside Spotfire Professional can simply switch the Page Navigation mode, but consumers using
    the Web Player will be forced to use the mode saved for the given Analysis file.

    Below is an example of an Action Control being configured in a Text Area to go to the ‘Solutions 1’ page when it
    is executed.



    In addition to Action Controls, you can also use Script Controls to redirect users. You also have the ability with,
    with Script Controls, to leverage the APIs to perform various tasks and do additional checks. For example, if your
    workflow requires you to mark some data on the first page before proceeding, you can have the script check if
    there is any data marked. If there is the user is navigated to the correct page and if there is not, you can output a
    message via a Label Property Control to the user that they need to mark data to continue. Another possible
    example using Script Controls for navigation could be that the script checks the value of a document property or
    similar which is previously set, and based off that value, it navigates the user to the appropriate page. This will
    allow the creation of branched analysis files which are less confusing for users to navigate.

    In addition to Action Controls and Script Controls, the page navigation will also work from the ‘Actions’ capability
    of a Graphical Table. We will discuss Actions in a Graphical Table in a future tip. Currently, Actions are only
    supported inside the Graphical Table and not other Visualizations.

    Another related new feature in version 4.0 is the concept of historical navigation. This is a method using back and
    forward arrows, available on the navigation toolbar, to go back to previous pages to support exploration.

    The navigation is specific to the user logged in and the history only is valid for the user’s session. To start with
    the back and forward arrow buttons are disabled when the analysis is first loaded.



    As the user traverses the Analysis file, the back and forward buttons become enabled.



    In 4.0 the historical navigation buttons exist as a separate navigation mode that is always enabled in addition to
    one of the other navigation modes (Tiled, Step-by-Step, or None). If an author wants to setup a purely historical
    navigation mode, then they should set the Page navigation option to None.

  • Executing Scripts within other Scripts

    There are some situations where you will want to execute a script from within another script. This could be to combine multiple scripts into one single action call (from a button, link, or image inside a Text Area), or it could be to enable the execution of various scripts based off some logic checks inside a master script.


    The following script will execute another script (name ‘secondScript’ that already exists and is stored inside the same Spotfire Analysis file):

    from System.Collections.Generic import Dictionary
    from Spotfire.Dxp.Application.Scripting import ScriptDefinition
    import clr
    scriptDef = clr.Reference[ScriptDefinition]()
    #The ExecuteScript method takes in the script code as a string parameter, so we must look the script up and output its code using the ScriptCode property
    Document.ScriptManager.TryGetScript("secondScript", scriptDef)
    params = Dictionary[str, object]()
    Document.ScriptManager.ExecuteScript(scriptDef.ScriptCode, params)

    The code above assumes that the script, secondScript, has no parameters being passed into it. Let’s assume that we have another script, called thirdScript, which takes in one string parameter, named “phrase”. We will need to update our code to pass in that parameter, as shown below:

    from System.Collections.Generic import Dictionary
    from Spotfire.Dxp.Application.Scripting import ScriptDefinition
    import clr
    scriptDef = clr.Reference[ScriptDefinition]()
    Document.ScriptManager.TryGetScript("thirdScript", scriptDef)
    paramDict = {"phrase":"Hey there"}
    params = Dictionary[str, object](paramDict)
    Document.ScriptManager.ExecuteScript(scriptDef.ScriptCode, params)

     

  • Information At a Glance with Graphics Tables

    Many managers and consumers need methods to quickly see the state of their business, including Key Performance Indictors (KPI). In addition, they may need to quickly spot changes in these values over time and also whether the values are trending up or down.
    This can be done in TIBCO Spotfire 4.0 using the new Graphical Table visualization.


    Graphical Tables are a new visualization provided in TIBCO Spotfire 4.0 which is designed to provide information at a glance. The Graphics Table is a table-based visualization that has a categorical row axis which defines the rows and a collection of 'miniature Visualizations' that defines the columns of the table. Supported miniature visualizations are Sparklines, Icons, and Calculated Values.


    To see this in action, let’s assume we are managing a weight loss program which measures the participants’ weights over time. Below shows the data in a Line Chart:





    Now let’s see what we can do with the new Graphical Table.

     

    First we need to add the ‘Participant’ column to the Row’s Axis.


     
    Then on the Columns’ Axis, we start by adding a Sparkline.


     
    The Sparkline can be configured by clicking on the ‘Settings’ button with the Sparkline column highlighted. In our example, we put Months on the X-Axis and then we put the Sum(Weight in kg) expression on the Y-Axis.



     
    The resulting Sparkline column is shown below:


     



    Next we may want to display whether or not participants in the study are trending up or down, or whether there has been no change.


    We can add another miniature visualization into the Graphical Table using the ’Icon’ option:


     

    To specify which Icons show up, we can use unique values in a column, or an expression. In this case, we will need to use a custom expression.  We will enter the following expression in the ’Calculate icons using’ field.

    (ValueForMin([Date],[Weight in kg]) - ValueForMax([Date],[Weight in kg]))


    We will then add rules, which are similar to the conditional coloring rules, to set specific icons  and colors for Greater than 0, Equal to 0, and Less than 0.


     



     
    Next we may want to display each participant’s percent change. For this, we will use the ‘Calculated Value’ option.



     

    After we add the Calculated Value, we can set the value’s expression using the ‘Settings’ button.  The expression used is :


    (ValueForMin([Date],[Weight in kg]) - ValueForMax([Date],[Weight in kg])) / ValueForMin([Date],[Weight in kg])

    Finally, we can then set the formatting for this to be a Percentage. We will also add a Rule to set the color all values that are Less than 0 to be red.




     

  • Limiting Data to Display in Visualizations in TIBCO Spotfire 4.0

    There are often scenarios where you will need to limit the data to display in a given visualization.  In most of the approaches, the solution is to filter data. However, this filtering is not directly tied to a visualization.  Rather, it is tied  to a  Filtering Scheme, which affects an entire page or pages.  In TIBCO Spotfire 4.0, there are two new features that allow you to easily filter data in a specific visualization, without affecting the data to display in other visualizations.

    Suppose we are looking at sales across four regions: East, Central, and West.  For each location, you may want to show a visualization like the following:


     
    If you trellis, you can show a the data split by region, but you do not get the ideal user interface you are looking for.


     
    You can setup Filtering Schemes for each region:


     
    But you are not able to see your information at a glance on the same page as you can only apply one Filtering Scheme per page.

    There are a couple options in Spotfire 4.0 which allow you to display the visualizations for each region on the same page.

    First, you can now apply a Filtering Scheme to a specific visualization (as opposed to just a page).

    In the properties dialog of the visualization, in the ‘Data’ section, you can choose which Filtering Scheme(s) to apply specific to that visualization.


     
    You can also select the ‘Use the current filtering from the page’ option so the visualization will update with the Filter Panel interactions as well (or you can uncheck all checkboxes for limiting data, and create a visualization that does not get affected by filtering changes at all).

    With this we can now create 3 duplicate visualizations, each with the setting to only display data from the East, West, and Central Filtering Schemes respectively. 
     

     

    However, this does still require us to manually create 3 Filtering Schemes: East, Central, and APJ, and then, set the correct filtering for each scheme.  So, the second option for setting this up is to use the new ‘Limit data using Expression’ feature that is built into each visualization.


     
    This allows you to create an expression which evaluates to True or False, to limit what data is being shown. In our example we want to use an expression like the following:


    if ([Region] = “East” , True, False)
     
    This will limit the data shown in the visualization to be data where the ‘Region’ is East, and will not show any other data.


     

  • Creating Property Control Groups that do not automatically update Expressions and Calculations

    In certain scenarios, there is a requirement to have multiple Property Controls that drive a given analysis file. The values behind these Property Controls will all be used in a series of expressions and calculations.  However, the way these expressions and calculations works means that they will be recalculated each time the property values change.  This is OK in some situations, but in many scenarios you want to trigger the update after all Property Control values have been updated (or at least allow the user to define when to update).

    This can be accomplished by making two sets of properties: the first set will be attached to the Property Controls in the User Interface and the second will be attached to the expressions and calculations. We then use a Script Control to allow the user to click on a button, and pass the values from the UI properties to the properties which are driving the expression. This would create a flow similar to a user filling out and submitting a form on a Web page. Once the Script is executed, the expressions and calculations are updated. 

    To highlight this use case, we will use the Spotfire Educational Services online Training Needs Assessment calculator.  This calculator can be found at  http://spottrain.tibco.com/SpotfireWeb/ViewAnalysis.aspx?file=kevin/TNA

    The calculator uses a series of Property Controls to query the user about the number of users they have for each role. 

        

    We then use a calculation which takes into account all the values from the first page to calculate the total number of passports a customer should purchase to cover their training needs. 

    The expression used for the calculation is shown below:

    case [Role]
    when "Administrator" then ([Pathway Days]*${
    intNbrAdminsUI})
    when "DBA" then ([Pathway Days]*${i
    ntNbrDbasUI})
    when "Developer Basic" then ([Pathway Days]*${intNbrBasicDevsUI})
    when "Developer Advanced" then ([Pathway Days]*${intNbrAdvDevsUI})
    when "Analyst" then if ("${nbrNeedExpressions}"="Yes",(([Pathway Days]+1)*${intNbrAnalystsUI}), (([Pathway Days])*${intNbrAnalystsUI}))
    when "Author" then ([Pathway Days]*${intNbrAuthorsUI})
    when "Business User" then ([Pathway Days]*${intNbrConsumersUI})
    else 0
    end

    All of the variables in the expression above, like ${intNbrAdminsUI}, are attached to the Property Controls on the first page.  The output is then displayed on the second page:

    .
        

    In this scenario, the expression will re-calculate everytime a user changes a value in one of the Property Controls on the first page. If this was an analysis with a lot of data, this could become inefficient.   A similar issue would happen if the values from the Property Control were not being used in an expression, rather they were being passed to a Data Function to perform calculations outside Spotfire.

     

    One solution to have the expression or function only update once is to have the expression use a separate set of properties than what are exposed via the Property Controls.  We then add a Script Control, and have the script go through the properties used in the expression and update them with the values from the properties used in the Property Controls.  The script we used to do this for the Needs Assessment example is shown below:


    Document.Properties["intNbrAdminsExpr"] = Document.Properties["intNbrAdminsUI"]
    Document.Properties["intNbrDbasExpr"] = Document.Properties["intNbrDbasUI"]
    Document.Properties["intNbrConsumersExpr"] = Document.Properties["intNbrConsumersUI"]
    Document.Properties["intNbrAnalystsExpr"] = Document.Properties["intNbrAnalystsUI"]
    Document.Properties["intNbrAuthorsExpr"] = Document.Properties["intNbrAuthorsUI"]
    Document.Properties["intNbrBasicDevsExpr"] = Document.Properties["intNbrBasicDevsUI"]
    Document.Properties["intNbrAdvDevsExpr"] = Document.Properties["intNbrAdvDevsUI"]

  • Displaying Property Controls inside HTML Tables

    In previous tips, we have discussed how you can add HTML directly into a Text Area.  To take this one step further, you may want to take Property Controls that you have already created and then add them into a HTML table or CSS positioning element to provide a more exact and better looking layout.  This tip will explain how that can be accomplished.

    First, you should start by building the Property Controls which you wish to use.  This can include any combinations of the built-in Property Controls and Action Controls.

     
    Then, using what you learned in the previous tip we mentioned, you will need to retrieve the HTML code that was generated for this Text Area, using a Script Control.


    from Spotfire.Dxp.Application.Visuals import HtmlTextArea
    vis = ta.As[HtmlTextArea]()
    Document.Properties["display"] = vis.HtmlContent

    This will store the HTML Content in a input field (multiple line) Property Control:

     


     

    Once you have the HTML content, you can now update it as you see fit: adding Tables, DIV tags, and styles. When you have the HTML content rewritten , you can now re-apply it back to the original text area.

    This is done using another script, which takes the same input field Property Control as input and then rights the code back into the original Text Area to be rendered.

    from Spotfire.Dxp.Application.Visuals import HtmlTextArea
    vis = ta.As[HtmlTextArea]()
    vis.HtmlContent = Document.Properties["display"]


     

    Once you do this, you will see the output includes the Property Controls inside an HTML table.

     

    Intersted in learning more about Property Controls and other authoring features? Sign up for our Authoring Bootcamp. Sessions in both EMEA and North America are scheduled to start this week.

  • Formatting Values in Tooltips

    In this tip we will discuss how to update the formatting on a Visualization's tooltips. Assume  we have a Bar Chart which displays the sum of sales for each year in our data table.

    What if we then want to change the y-axis to show the Percentage of Total Sales for each year. This would require changing the y-axis to a custom expression using the OVER function:

    Sum([Sales]) / Sum([Sales]) OVER (All([Axis.X]))


     


    The formatting will still stay as a currency type (as that is what it was when we started), so we will need to update the formatting to percentage on the y-axis:


     

    That will fix the formatting on the axis and the Bar Chart labels, but will not update the tooltip:
     


    To update the tooltip, we will have to add another tooltip entry with a custom expression:


    Concatenate((Sum([Sales]) / Sum([Sales]) OVER (All([Axis.X]))) * 100," %")

     

    In this expressoin we take the original expression, multiply it by 100 to get to a percentage and then actually output a string with is that resulting value concatendated with a % character.

    In addition, we will have to update the original ‘Sales’ column data type from ‘Currency’ to ‘Number’. When this is done, you will see the tooltip (shown below), will be updated with the proper formatting.

     

     
    To learn more about TIBCO Spotfire Professional features, watch our newly updated TIBCO Spotfire Professional Jumpstart. This is a free eLearning course which covers the breadth of capabilities available in TIBCO Spotfire. Follow the link below to watch and when prompted, login as a guest.

    http://spottrain.tibco.com/sln/course/view.php?id=85

  • Dynamically Updating Fixed Values in a Drop-down list Property Control

    There are some situations where you will want to have a Drop-down list Property Control display fixed values. This is easily accomplished by using the ‘Fixed values’ option for setting the property value, and then entering your fixed values and their display names.

     

    In other situations, you may want those fixed values to update depending on certain conditions.  It could be that you only want to show some of them at any given point in time, or it could be that you want the values to completely change based off some other logic in your analysis file.  This can also be accomplished. It does require more work, but does not necessarily require a Script Control. We will learn how to do this in this tip.  NOTE: If you want the Property Control values to update dynamically but show values in a column (as opposed to fixed values), this can be accomplished another way. Please see this tip for how to do that. 


    Let’s assume for this example you will want to update fixed values displayed in one Property Control based off a selection in another Property Control. The first Property Control will display the following fixed values:


          “All time”, “Year”, “Quarter” and “Month”

    We then want to create a second Property Control. In that Property Control, the values should also be fixed values, but if the first Property Control has “All time” selected, the second Property Control should show all possible values. If the first Property Control  has “Year” selected, the second Property Control should show “Year”,”Quarter”, and “Month”. If the first Property Control has “Quarter” selected, the second Property Control should show “Quarter” and “Month”. Finally, if the first Property Control has “Month” selected, the second Property Control should only show “Month”. This type of scenario is good when you are trying to do complex calculations, like Year over Year or Year over Month, when only certain combinations are valid.

    To setup this second Property Control, we need to first create a calculated column. Ideally we would do this in a new data table, but it can be in the existing data table. Call the column PropertyControlValues, and use the following calculation, assuming ${dd1} is the name of the Property attached to your first Property Control you just created.

    Case when "${dd1}" = "All time" and RowId() = 1 then "All Time"
    when "${dd1}" = "All time" and RowId() = 2 then "Year"
    when "${dd1}" = "All time" and RowId() = 3 then "Quarter"
    when "${dd1}" = "All time" and RowId() = 4 then "Month"
    when "${dd1}" = "Year" and RowId() = 1 then "Year"
    when "${dd1}" = "Year" and RowId() = 2 then "Quarter"
    when "${dd1}" = "Year" and RowId() = 3 then "Month"
    when "${dd1}" = "Quarter" and RowId() = 2 then "Quarter"
    when "${dd1}" = "Quarter" and RowId() = 3 then "Month"
    when "${dd1}" = "Month" and RowId() = 3 then "Month"
    else
    null
    end

    When this is created, the calculated column will update when the Property Control is updated.
     

    Then you can create another Drop-down list Property Control. This one should display values using the ‘Unique values in column’ option and point to the calculated column that we just created.
    The end result is that the second Property Control will only display values that are valid based off the first Property Control.
     

    As another example suppose as part of our Guided Analysis, we want to update some attributes like what unit of measurement to use.  By changing the unit of measurement, we will have to apply a calculation to all our relevant data.  Suppose you have many different attributes you need to measure, like Temperature, Weight, Time, Distance, etc…  Rather than creating a unique drop down combination for each, you can use the approach in this tip to create one group of drop downs and then update the values accordingly.

    In the image below, the user has selected to update the temperature, so the second property control shows both ‘Fahrenheit’ and ‘Celsius’. 


     
    If the user has selected to update the weight, the second Property Control will show ‘Kilograms’ and ‘Pounds’.


    The expression used for this calculated column, assuming the first Property Control is called “whichMeasurement” is:

    Case when "${whichMeasurement}" = "temperature" and RowId() = 1 then "Celsius"
    when "${whichMeasurement}" = "temperature" and RowId() = 2 then "Fahrenheit"
    when "${whichMeasurement}" = "weight" and RowId() = 1 then "Pounds"
    when "${whichMeasurement}" = "weight" and RowId() = 2 then "Kilograms"
    else
    null
    end

    For more information on using Property Controls and other advanced techniques such as these, please consider registering for our Author Bootcamp

  • Displaying Images in a Label Property Control

    In last week’s post, we learned how to create custom Property Controls in the form of Radio Buttons and Checkboxes.  As it turns out, this solution works well using the Web Player from Internet Explorer, but the wingdings fonts do not display as they should in Firefox or Chrome.  To correct this, and to learn another nice feature, we will replace the wingding fonts with a graphic in the Label Property Control.  

    This can be accomplished out of the box using a Data Function, but that requires S+ or R and the TIBCO Spotfire Statistics Server. If you do not have those, or you just want to use something more lightweight, a script can be used. The code below can be used in a script control. It will take an image, specified via a  URL, and will place it in a Binary Document Property.  
     

    from System.Drawing import Image
    from System import Uri
    from System.Net import HttpWebRequest
    from Spotfire.Dxp.Data  import BinaryLargeObject

    uri = Uri("http://spotfire.tibco.com/community/Downloads/radioOn.png")
    request = HttpWebRequest.Create(uri)
    response = request.GetResponse()
    stream = response.GetResponseStream()
    blob = BinaryLargeObject.Create(stream)
    Document.Properties["testImage"] = blob

    If you then attach this Binary Property to a Label Property Control, the image will appear, and will work in the Web Player as well in all supported browsers. To see the same example as last week updated to work using this new approach, take a look at: http://spottrain.tibco.com/SpotfireWeb/ViewAnalysis.aspx?file=/kevin/TNA

    This opens the door for a new set of features, where you can rotate through images based off some logic. This can lead to a custom-traffic light visualization, Radio Button and Checkbox Property Controls, and other solutions where you need to rotate or display different images based off of data.

  • Creating Radio Button and Checkbox Property Controls

    This is the first post after the Tip of the Week blog’s summer hiatus.  We are back now and will start out with a series of tips related to using Text Areas to create Guided Analysis files. In this first tip back we will discuss how to create new Property Control types (radio buttons and check boxes) using a combination of Document Properties, Labels, and Scripts. While these are not truly built-in Property Controls, they do work and function properly.


    In this first example we will look at building a radio button. The first thing we need to do is create two new Document Properties. One will store the value of a radio button checked and one will store the value of a radio button unchecked.  The easiest way to accomplish this is to use the Wingdings 2 font and the following symbols as the values for the property: and .

     

    NOTE: you will not see the symbol right away when you enter it in the value section, this is OK.


    After you add the property for the radio button checked, add a similar one called radioUnchecked which shows the symbol of an unchecked radio button.


    The next step occurs in the Text Area where you want to use the radio buttons. In the location where you want each radio button displayed, you should add a Label Property Control.  In our example we will display two radio buttons in the group. One with the value yes, and one with the value no.  Each one will be on its own line, one after the other.  The screen shot below shows the Label Property Control we will add for the 'Yes' part of the radio group. The Label Property Control is attached to a new Document Property, called radioYes, which is of type string. We can leave the default value empty or we can use the unchecked radio symbol from before, :


    We then add another Label on the following line in the Text Area which will show the 'No' part of the radio button group.


     
    Finally we will add a script next to each label. For the first script, it will go next to the label for the 'Yes' part, and will display as a link with the display name ‘Yes’. The code is shown below:

    Document.Properties["radioYes"] = Document.Properties["radioChecked"]
    Document.Properties["radioNo"] = Document.Properties["radioUnchecked"]

    What this is doing is setting the  radioYes property (which is attached to the 'Yes' button’s Label) to be equal to the radioChecked property (which is where the radio checked symbol is stored). Then the code sets the radioNo property (which is attached to the 'No' button’s Label) to be equal to the radioUnchecked document property (which is where the radio unchecked symbol is stored).


     
    We can then add a second script with the display name No next to the No label.
     


    When this is all done, you have a working radio button group in your Text Area.


      
    Want to see it in action? Try it in our Training Needs Assessment Application at http://spottrain.tibco.com/SpotfireWeb/ViewAnalysis.aspx?file=kevin/TNA


    Using a similar approach, you can also create a checkbox group:


     

     

  • Insert As Text vs Insert As Value

    The concept of Document Properties has existed in TIBCO Spotfire for quite some time.  In version 3.1, the concept of properties was extended and included the ability to expose controls  to allow consumers to change property values.  When this update happened, Spotfire continued to support the old mechanism for adding properties into expressions as well as supported a newer , pre-processor approach.

    The default mechanism, from version 3.1 and later,  for adding properties into an expression is to use the ‘Insert Properties’ button. This will add the property using a pre-processor variable. This will get replaced with the value of the property before the expression is interpreted. 

     

    In addition, there is a right-click menu over the properties pane which allows you the choice to ‘Insert as Value’ or ‘Insert as Text’. The ‘Insert as Text’ is the same as the default ‘Insert Properties’ button.

    The older method for adding a property into an expression is still supported also. This done using the ‘Insert as Value’ method.

     

    This approach is not a pre-processor, rather a function used to insert the property value.

    Why would you want to use this older approach? There are a few situations, specifically when you need to use a specific data type.   We will provide an example below.

    Suppose we want to have a set of property controls that will allow a consumer to specify a minimum data and a maximum date and then have a Spotfire visualization update to only show values within that date range. (I realize this can easily be done with a range filter, but suppose you want to hide the filter panel and expose this capabilities via a property control)?


     
    We will use a technique we introduced in an earlier tip, to have a calculated column update based off the Property control values and then filter the visualization.  To set this up , we have the following expression in our calculated column.                                      

        if((DateDiff("day",[Date],DocumentProperty("maxDate"))>=0) and (DateDiff("day",DocumentProperty("minDate"),[Date])>=0),"in range","out of range")

    where maxDate is the name of the property used for the max date slider control and minDate is the name of the property used for the min date slider control. It is important to use DocumentProperty("maxDate") instead of ${maxDate} as the typecasting will be incorrect with the latter. 

    This will create a new column with values of either 'in range' or 'out of range'. You can then use the filter panel to uncheck 'out of range' so only the data in range will be shown. Then you can hide the filter panel for displaying in the Web Player.

  • Sharing your Analysis – Even better in 3.3

    In earlier posts, we discussed how to share your analysis with others using a variety of approaches.  With the release of version 3.3 of TIBCO Spotfire, there are quite a few more approaches available.
    The major update is that Spotfire now provides a way to execute a Bookmark and a Configuration Block directly when launching Spotfire and opening a file. This is supported in both the Web Player and Professional clients.

    Launching analysis files via URL
    To open Spotfire Professional and launch a file from the library, Spotfire 3.3 provides a URI mapping. The following example will open a new instance of Spotfire Professional, and once logged in, will open the file called SelfDrilling from the library inside a folder called MyFiles.

     tibcospotfire:server:http%3a//myserver/:analysis:/MyFiles/SelfDrilling

    To launch the same file from the library in Spotfire Web Player, you can use a more standard URL:
     

    http://myserver/SpotfireWeb/ViewAnalysis.aspx?file=/MyFiles/SelfDrilling

    NOTE: This capability regarding the Web Player has been possible well before Spotfire version 3.3

    Launching with a Bookmark
    In addition to just launching a file inside Spotfire, starting in version 3.3, it is possible to apply a bookmark immediately as the file loads (in either the Web Player or Professional client).
    This is done by appending the bookmark query parameter to the URLs listed earlier. The bookmark query parameter takes in a GUID specific to the bookmark.  To retrieve the full URL to use, you can choose the Copy Bookmark URL option for your specific bookmark from the Bookmark Panel. There is a link for the Web Player and one for the Professional client.


    You then have a URL which you can paste directly into a web browser. This link can be shared via email or social media streams like TIBBR. Below is one such link for the Web Player

    http://myserver/SpotfireWeb/ViewAnalysis.aspx?file=/MyFiles/SelfDrilling &bookmark=b249f05c-a76d-4da7-9909-454dbf2eb86c

    With the addition of this feature, along with the updates to bookmarks in 3.3 which allow you to capture Visualization settings and  Document Properties, you can very easily share insights in your analysis files. Before capturing the bookmark in TIBCO Spotfire Professional, you can update a Text Area with some comments on your analysis you want to share. Then, when you capture the bookmark, make sure you chose to capture ‘ Page Layout and Visualizations’.  

     


     
    When the URL is shared and opened, the updated contents of the Text Area will be shown as well to give the user some insight into the file.  If the person who is creating the bookmark is using the Spotfire Web Player and not Professional client, they will not be able to edit the contents of a Text Area.  Rather, the author of file should create a Multi-line input field Property Control, and allow the user to add their comments in there. When the bookmark is captured, the ‘Properties’ option should be checked to make sure the status of the property is persisted.


     
    Launching with Configuration Blocks
    In addition to bookmarks, you also have the ability to launch a file and pass in a configuration block. A configuration block is a string which configures the initial state of an analysis.  It allows you to do two things. First, pass in parameters which will be used in information links for retrieving data, and then set the initial state of the analysis, like which page to be on, or how the filtering and marking should work.
    Configuration blocks have been around since version 3.1, but they previously required either Automation Services or our APIs to execute.
    Details on what is supported in a configuration block can be found at http://stn.spotfire.com/stn/Tasks/CreatingConfigurationBlock.aspx?usterms=configuration+block&uscat=0,1,2,3&uswords=%22configuration%20block%22
    There is no User Interface to build the Configuration Block URL for you , like the bookmark panel offers, so you will need to build it from scratch. The name of the query parameter to include is configurationBlock and you set it equal to the block values.


    For example, if you want to load a Spotfire analysis file in the Web Player and preset the filtering so that the filter for the column ‘Product Category’ is only set to ‘Vintage Cars’ you can use the following URL:

    http://myserver/SpotfireWeb/ViewAnalysis.aspx?file=/MyFiles/SelfDrilling&configurationBlock=SetFilter(columnName="Product Category",values={"Vintage Cars"});

    Another good use case would be to pass in values to a parameterized information link directly via the URL. Suppose you have one analysis file which shows sales data for four regions. You can distribute one URL which will load the entire analysis file, and then you can pass out other URLs, one for each regional manager. In those URLs we pass in the parameter value to load only data from their region.

     

  • Updated Time Hierarchies in version 3.3

    Before Spotfire version 3.3, time hierarchies were treated just like all other hierarchies. In version 3.3,  a new built-in hierarchy is available specific to dates and times.


       
    They use the new BinByDateTime() function to create the expression as shown in the image below.


     
    With the new support for time series hierarchies, visualizations which have a time series on one of their axis will now display a slider by default.  See the image below which shows the pre 3.3 visualization on top and then how it looks in 3.3.


     
    When these hierarchies are added to a categorical axis, they act like all other hierarchies. However, some additional settings have been made available to show them more naturally like time series hierarchies, including how to handle gaps in the values, like missing months for example.


     
    To understand what each of the three settings does, we will show 3 visualizations which are identical except for this having a different value for this setting.

    These visualizations below show data from July 2005 through June 2007 and have nothing filtered out.
     

    You can see the first two are identical when nothing is filtered out and the last one, using the 'Show all values' option,  includes all the months in 2005 and 2007, even though the data does not exist for those months before July 2005 and after June 2007.

    In the next set of visualizations, we filtered out all the months in 2006.


     
    The top visualization, with the  ‘Show filtered values’ option set, only displays months on the x-axis which are not filtered out and which exist in the data. So, it skips from December 2005 to January 2007 and does not leave any gaps or space between them.


    The middle visualization uses the ‘Show filtered range’ option. It will display a gap for all the months in 2006 with no data.

    The bottom visualization uses the ‘Show all values’ option. It will display both the gap for all the months in 2006, and it will also show all the months in 2005 and 2007.

    In next week’s tip, we will build onto this one and learn how Spotfire handles things like cumulative sums in cases when there are missing time series values.


     

More Posts Next page »

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