Spotfire® Enterprise Runtime for R

Building a Spotfire Control to Check the Debugging Option

You can create a data function that uses the Spotfire debugging flag to check if data function debugging is enabled, and then use a Spotfire control to report the status of the debugging option.

About this task

Being able to determine quickly if you have set the debugging option for your data functions is a useful developing technique. Perform this task in Spotfire Analyst.

Before you begin

  • You must have the Advanced Analytics license in Spotfire Analyst to use the data function feature. If you do not see the menu item, contact the Spotfire administrator.
  • Load a data set or an existing visualization to use for testing the debugging flag. If you are starting with a blank Spotfire Analyst session, you can use one of the data sets provided as examples. Follow the instructions in Importing TERR Data Sets Using a Data Function.

Procedure

  1. From the Spotfire Analyst menu, click Tools > Register Data Functions.
  2. Register the new data function.
    1. In the Name text box, provide a meaningful name, such as DebugFlagTest.
    2. Clear the check box Allow caching.
      You must ensure there is no caching so that the data function checks the option each time you send a request.
    3. In the Script tab, write the following script.
      #create an object to check if the data function debuging option is set. 
      debug <- getOption("debug.spotfireConnector", FALSE)
      
      #create an object to hold the output text reporting if the option is set. 
      x<- "Debugging is not enabled."
      if (debug) x <- "Debugging is enabled."
      For more information about the getOption function, see the TERR Language Reference.
    4. Click the Output Parameters tab, and then click Add to specify the output parameter.
    5. For the Result parameter name, specify x, and for the Type, select Value.
    6. Click OK, and then click Run.
      The Edit Parameters dialog box is displayed.
    7. Clear the Refresh function automatically check box, and then select the Output tab.
    8. In the Output parameters list box, select the x output parameter, and for Output handler, select Document property.
    9. Click New, and in the New Property dialog box, for Name, type DebugFlag.
    10. Click OK, and then close the Register Data Functions dialog box.
      You are prompted to save the data function to the library.
    11. Click Yes to save the data function in the library so you can use it in all of your data-function-enabled visualizations.
  3. Create a text area to provide the information returned from the data function.
    1. Add a Text Area to the visualization, and in the Text Area title bar, click the Edit Text Area button.
    2. Click the Insert Property Control button, and from the list, select Label.
      The Property Control dialog box is displayed.
    3. In the Document Properties tab, accept the default.
      The new property should be selected, and the Value should be the value you provided in the data function.
    4. Click OK to insert the label control.
    5. In the Edit Text Area window, click the Insert Action Control button.
      The Action Control dialog box is displayed.
    6. In the Actions pane, select Data Function.
    7. Provide Display text, such as Refresh.
    8. From the Control type drop-down list box, select Button.
    9. From the Available data functions list box, select the data function you created.
    10. Click OK to accept the changes.
    11. Move the button in the text area to an appropriate position in relation to the label control, and then close the Edit Text Area window, saving the changes.
    12. Optional: Provide a descriptive title for the text area (or remove the title), and resize the text area to an appropriate size.
  4. Test the new controls.
    1. In the text box you created, click the button.
      The label control text should reflect the state of the data function debugging option.
    2. From the menu, click Tools > Options, and in the Options dialog box, scroll and select Data Functions, and then change the state of the Enable Data Function debugging check box, and save the change.
    3. In the text area, click the button again. The status should change to reflect the current state of the data function debugging option.