Specifying text properties for titles, labels, axes, and legends

A graph can have four text elements:

The sample illustrates a graph with the text elements  labeled. Printer Sales is labeled as the title. The words that describe the value and category axes are shown as label text, the word Values labels the plotted values on the two axes. Legend is the label for the area at the bottom, which shows three series labeled Stellar, Cosmic, and Galactic, with color keyed columns for each. The graph has columns for each quarter that represent sales in units for the three series.

You can specify properties for each text element.

StepsTo specify text properties for the title, labels, axis values, and legend of a graph:

  1. Select Properties from the graph's pop-up menu and then select the Text page in the Properties view.

  2. Select a text element from the list in the Text Object drop-down list:

    The sample shows the Text Object drop down box on the Text page in the Properties view. The Value Axis Label is highlighted in the list of available text objects and displayed as the selected Text Object.
  3. Specify the font and its characteristics.

Using Auto Size

With Auto Size in effect, PowerBuilder resizes the text appropriately whenever the graph is resized. With Auto Size disabled, you specify the font size of a text element explicitly.

StepsTo have PowerBuilder automatically size a text element in a graph:

  1. On the Text properties page for the graph, select a text element from the list in the Text Object drop-down list.

  2. Select the Autosize check box (this is the default).

StepsTo specify a font size for a text element in a graph:

  1. On the Text properties page for the graph, select a text element from the list in the Text Object drop-down list.

  2. Clear the Autosize check box.

  3. Select the Font size in the Size drop-down list.

Rotating text

For all the text elements, you can specify the number of degrees by which you want to rotate the text.

StepsTo specify rotation for a text element in a graph:

  1. On the Text properties page for the graph, select a text element from the list in the Text Object drop-down list.

  2. Specify the rotation you want in the Escapement box using tenths of a degree (450 means 45 degrees).

Changes you make here are shown in the model graph in the Design view and in the Preview view.

Using display formats

StepsTo use a display format for a text element in a graph:

  1. On the Text properties page for the graph, select a text element from the list in the Text Object drop-down list.

  2. Type a display format in the Format box or choose one from the pop-up menu. To display the pop-up menu, click the button to the right of the Format box.

Modifying display expressions

You can specify an expression for the text that is used for each graph element. The expression is evaluated at execution time.

StepsTo specify an expression for a text element in a graph:

  1. On the Text properties page for the graph, select a text element from the list in the Text Object drop-down list.

  2. Click the button next to the Display Expression box.

    The Modify Expression dialog box displays.

  3. Specify the expression.

    You can paste functions, column names, and operators. Included with column names in the Columns box are statistics about the columns, such as counts and sums.

  4. Click OK to return to the graph's Properties view.

Example

By default, when you generate a pie graph, PowerBuilder puts the title at the top and labels each slice of the pie with the percentage each slice represents of the whole. Percentages are accurate to two decimal places.

The following graph has been enhanced as follows:

The sample shows a pie graph. At the top is the title Sales by representative as of 2 / 20 / 99. At left is a legend with shades of gray for three representatives, Jones, Perez, and Simpson. Each of the three shaded segments of the pie is labeled with the percentage of the total sold by that representative and the number of sales the rep made.

To accomplish this, the display expressions were modified for the title and pie graph labels:

Element

Original expression

Modified expression

Title

title

title + " as of " + date(today())

Pie graph labels

if(seriescount > 1, series, string (percentofseries, "0.00%"))

if(seriescount > 1, series, string(percentofseries,"0%") + " (" + value + ")" )