0931-0934

Previous Table of Contents Next

Page 931

axes. In the listbox at the top, you select the axis to be defined, and you can define the custom label for the axis as well as other properties associated with the axis. Change the label for the
x-axis to be Month and the Y1 axis to be Shipments.

Figure 37.15.
The axis definition property sheet.


Additionally, because there is only one data value set displayed in the chart, you can remove the legend box by selecting Chart Frame. The Frame tab of the Frame Properties dialog that appears (shown in Figure 37.16) defines the visual effects used for the chart. To remove the legend box, make sure that the Show Legend checkbox is not selected.

Figure 37.16.
The Frame Properties dialog.


The last modification for this chart is to dynamically modify the chart title at runtime. Instead of displaying a generic title, the title should include the name of the warehouse being displayed. Using the PL/SQL feature of Oracle Graphics, you can change the title in a trigger that fires

Page 932

when the display is first opened. To create this trigger, select Tools Display. Click the Edit button at the right of the Open Procedure field and create the following procedure:

 PROCEDURE OGTRIGGERPROC1 IS   chart   OG_OBJECT;   wh      VARCHAR2(3);   year    number;   whname  VARCHAR2(50);   title   VARCHAR2(100); BEGIN   chart := og_get_object (`wh_monthly');   wh := og_get_char_param (`P_WH_CODE');   year := og_get_num_param (`P_YEAR');   select wh_name     into whname     from warehouses    where wh_code = wh;   title := to_char (year)' Monthly Shipments for `whname;   og_set_title (chart, title); exception   when NO_DATA_FOUND then     og_set_title (chart, `Unknown Warehouse'); END; 

In this procedure, the chart handle must be retrieved as a parameter to the og_set_title built-in procedure. The values of the parameters are then retrieved into PL/SQL variables to be used to define the new title. You establish the exception code in case the display receives an invalid warehouse code.

Creating a Break Chart

A break is a special type of chart that displays data for multiple similar entities on a single chart. An example of this chart is the monthly shipments shown in Figure 37.17. This chart shows the monthly shipments for all five warehouses plotted as separate curves on the same chart.

Figure 37.17.
An example of a break chart.


Page 933

To create this chart, first define a parameter for the chart year and build the following query:

 select to_char (to_date (to_char (h.hist_month_no), `MM'), `MON') Month,      w.wh_name Warehouse,      h.hist_ord_shipped Shipments from warehouses w,      warehouse_history h where h.hist_wh_code = w.wh_code and h.hist_year = :P_YEAR order by h.hist_month_no, w.wh_name 

In the Layout Editor, create a chart using the curved line chart subtype. To define the multiple lines, select the Categories tab in the Chart Properties dialog box as shown in Figure 37.18. To create a multi-line chart, first define the chart category as Month and also set the Subcategory (lower-right corner) equal to Warehouse. This causes the x-axis to vary by month and the data within each category value will be grouped by warehouse.

Figure 37.18.
Defining a break chart subcategory.


Click OK to complete the chart design. Note that the five lines are presented in separate colors with a legend box at the right of the chart that can be used to translate the chart. Save the chart as g38oun08.

Advanced Formatting Techniques

As in all of the Developer/2000 products, Oracle Graphics provides facilities to enhance the application module by using PL/SQL program units. You can use these program units to modify the default processing for a chart as well as to define how data can be displayed or to determine whether the data should be included in the chart at all.

Using Format Triggers

You use a format trigger to modify how a chart element is displayed. In the chart that was created in the section "Creating a Multi-Layer Chart," the chart on the third layer displayed the maximum shipping delay for each month. Suppose that management sets a standard that all

Page 934

orders must be shipped within one week of order placement. To emphasize substandard performance, the chart should indicate any month in which the maximum delay is greater than seven days.

To demonstrate this technique, load the chart created in the "Creating a Multi-Layer Chart" section. In the Layout Editor, use the Layers Management tools to activate the Maximum Delay layer and chart. (Hide all other charts .) Within this chart, click any one of the tick mark labels along the x-axis. This selects all the labels as the active objects. To build the format trigger, select Tools Properties. Next to the format trigger field, click the New button to activate the PL/SQL editor behind the property definition sheet. Click OK to close the property sheet.

In the PL/SQL editor, complete the format trigger procedure as shown:

 --Chart Element Format trigger. Called for each member of a -- specified chart element group (e.g., each bar in a group of -- bars for a bar chart). -- ARGUMENTS: --   ELEM   The current chart element. --   QUERY  The query associated with this chart. The current --          row of the query is the one associated with ELEM. --          Use OG_GET_xxxCELL to get at column values for the --          current row. PROCEDURE OGFORMATTRIG0(elem IN og_object,                         query IN og_query) IS   maxdel     NUMBER; BEGIN   maxdel := OG_GET_NUMCELL (query, OG_NEWDATA, `Maximum Delay');   if maxdel > 7 then     og_set_gcolor (elem, `red');   end if; END; 

This procedure retrieves the value from the query into a PL/SQL variable, and if this value is greater than 7, the month label is displayed in red.

Creating Data Filters

You use a data filter to eliminate data retrieved by a query that should not be included in the chart. Sometimes for better performance, a query retrieves all data from a table without restricting the retrieval in the where clause.

Another use of the data filter is to retrieve all data necessary for all charts in a display and to restrict the results to the individual chart for which it is needed. You can then eliminate this data from the query using a data filter. A data filter is a PL/SQL procedure that is attached to a chart. To create a data filter, select the Data tab in the Chart Properties dialog box. Click the New button next to the filter field to create the filter function in the same way you create a format trigger. This filter is a Boolean (TRUE or FALSE) function and is used to determine whether a row should be plotted on the chart. Suppose, for example, that in the break chart created earlier, only the Wharton, NJ, and Boise, ID, warehouses should be plotted.

Previous Table of Contents Next


Oracle Unleashed
Oracle Development Unleashed (3rd Edition)
ISBN: 0672315750
EAN: 2147483647
Year: 1997
Pages: 391

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net