Associating Scripts with Radio Buttons

Radio buttons are typically used to allow a user to select one option from a group of options; for example, to select one type of chart over another. The exercises in this section assume that you have previously inserted an Dashboard section in Sample3.bqy and renamed it Controls. These exercises show you how to embed a chart and add radio buttons for user-control of the chart type.

  To embed a chart in an Dashboard section:

  1. In the Controls section, toggle to Design mode.

    When in Design mode, the Element pane is displayed below the Section frame as a hierarchical structure of available Dashboard objects.

  2. Elements pane, drag the chart named RevbyTime to the Content pane.

The script in this exercise changes the chart type to a line chart. Before changing the chart with the script, verify that RevbyTime is a vertical bar chart. To verify and change the chart type, activate the RevByTime section and choose Format, then Chart Type, then Vertical Bar, and then return to the Controls section.

  To associate a script with a radio button:

  1. Elements pane, drag a radio button control to the Content pane and use the Properties dialog box to specify its title as Line.

    (See Changing a Control Object Title for detailed instructions.)

  2. With the Line object’s selection handles visible, choose Dashboard, then Scripts or press [F8].

  3. Use the Object browser to locate and expand the RevByTime section of ActiveDocument.

  4. Expand the RevbyTime Properties folder, then double-click ChartType.

    Interactive Reporting automatically enters the first part of the script in the Scripting frame. Property ChartType as BqChartType is displayed in the Description frame. BqChartType is a constant whose values is displayed in the Constants collection of the Object browser.

  5. To select the applicable BqChartType, use the Object browser to scroll down to Constants and expand it, then expand the BqChartType collection.

    Image shows the Script Editor.
  6. In the Script Editor, type and equals sign (=) immediately after ChartType.

  7. Double-click bqChartTypeLine.

    Interactive Reporting adds the rest of the script to the Scripting frame.

  8. Click OK to save the script and close the Script Editor.

  9. Toggle to Run mode and click the Line radio button.

    The chart changes to a Line chart.

    Example

    Create a second radio button with the title Vertical Bar by toggling to Design mode and working through the preceding exercise.

    Add a script to this radio button to change the chart type to vertical bar (bqChartTypeVerticalBar).

    Tip:

    Radio buttons work in groups: when one button in the group is selected, the others in the same group are cleared. Set the group name in the Properties dialog box for each button. The default group name is RadioGroup.