Previous | Table of Contents | Next

Page 435

Week 3

Day 16

Developer/2000: Using Oracle Graphics and Procedure Builder

In the previous four lessons, you worked with Oracle Forms and Reports to develop pieces of an application. In this lesson, you work with the other two components of Developer/2000: Oracle Graphics and Procedure Builder.

The Role of Oracle Graphics

Oracle Graphics provides a method for generating charts whose values are derived from the contents of one or more tables in an Oracle database. Remember that old saying, "A picture is worth a thousand words?" The purpose of Oracle Graphics is to streamline the graphical presentation of the contents of a database so that trends can be quickly identified, large quantities of data summarized, and comparisons made between sets of data.

Page 436

The Elements of Oracle Graphics

Oracle Graphics uses the same paradigm as Forms and Reports. A tool named Graphics Designer is used to design a chart and generate a runtime version of the chart. Another program named Graphics Runtime runs the generated chart. As you will see in this lesson, you can add a menu item to a Forms menu that will run a chart.

Like Forms and Reports, Oracle Graphics also uses an Object Navigator to create, modify, and view the elements of a chart. Oracle Graphics uses the term display to refer to a graphics object. The object nodes for a display are as follows:

At a minimum, a chart will include a query and a layout.

Building a Chart with the Graphics Designer

Let's start off using Graphics Designer by designing a pie chart based on a single table. You will build a chart that will present the breakdown of students based on year. To invoke
the Graphics Designer, select Oracle Designer for Win95 | Graphics Designer from the
Start menu. The Graphics Designer program will first display the Object Navigator (see Figure 16.1).

Notice that a chart titled UNTITLED is displayed in the Object Navigator. Before going any further, you need to connect to the Oracle database.

Connecting to an Oracle Database

To connect Graphics Designer to an Oracle database, select File | Connect from the menu. A dialog box will appear, prompting you for the username, password, and database to use for establishing an Oracle database connection. Connect to the Oracle database; refer to Day 12, "Developer/2000: Introduction to Oracle Forms," for details on how to do this with Developer/2000.

Page 437

Figure 16.1.
Graphics Designer
first displays Object
Navigator.

Creating a New Chart

To create a new chart, follow these steps:

  1. Select Window | Graphics: Disp1: Layout Editor from the menu. Notice that the menu changes.
  2. Select Chart | Create Chart from the menu—the Chart Genie will appear.
  3. In the Name field, change the name of the query from query0 to Student_Query.
  4. You want to construct a pie chart that shows the relative percentage of students in a given year. To do this, you need to use the GROUP BY clause in the SELECT statement (see Figure 16.2). In the SQL Statement list box, enter
select Year, Count(*)
from Student
group by Year;

Choosing the Chart Type

Next, the Chart Genie will display a window in which you specify the Chart Properties.

  1. In the Name field, enter Students_by_Year.
  2. In the Title field, enter Students by Year.
  3. In the Type selection, select the pie chart. Another grouping, labeled Subtype, will be displayed; select the 3D pie chart. Figure 16.3 shows what the tabbed dialog should look like.
  4. Click OK.

Page 438

Figure 16.2.
Specifying the query
in the Chart Genie.

Figure 16.3.
Specifying the Chart
Properties in the
Chart Genie.

The layout for the 3D pie chart will appear, per your specifications (see Figure 16.4). However, realize that this is only the initial layout. Let's look at some of the changes you might want to add.

Page 439

Figure 16.4.
Layout of the pie
chart.

Customizing the Chart Layout

As you can see in Figure 16.5, there are no percentage labels for the pie segments. To add them, follow these steps:

  1. Select the center of the pie, right-click, and select Frame from the menu. A window labeled Frame Properties will appear.
  2. Select the Pie Frame tab folder.
  3. Enable the checkbox labeled Show Percent Values, as shown in Figure 16.5.
  4. Click OK.

You should now see the percent values displayed in the layout. Let's increase the size of
the title.

  1. Select the title with the mouse.
  2. Select Format | Font from the menu.
  3. Set the title to MS San Serif, Bold, 12 points (see Figure 16.6).

Page 440

Figure 16.5.
Changing the frame
properties to display
percent values.

Figure 16.6.
Formatting the chart
title.

Saving the Chart

To save the pie chart, select File | Save As | File System from the menu. A dialog window will prompt you for the name of the file; enter Students_by_Year. The Graphics Designer saves a file with an extension of .ogd which is shorthand for Oracle Graphics Designer. However, to create a graph with Graphics Runtime, you must generate an .ogr file from the equivalent

Page 441

.ogd file (.ogr is shorthand for Oracle Graphics Runtime). To do this, select File | Administration | Generate | File System from the menu; alternatively, press Alt+t. By default, the Save As dialog window will give the .ogr file the same filename as the .ogd file. Click OK so that the Graphics Designer will save the file as Students_by_Year.ogr. You can exit the Graphics Designer—the next step is to create a shortcut to run the chart with Graphics Runtime.

TIP
Be sure to save your graphics files in a directory that isn't part of the Oracle directory tree (beneath C:\Orawin95). Also, remember to use the Registry Editor to add that directory to GRAPHICS25_PATH, or Graphics Runtime won't be able to open your graphics files.

Creating a Shortcut to Run a Chart

Users are always happy if you can make it simple for them to achieve the desired results. Creating a Windows shortcut is one way to do this. It may not be as seamless as an integrated Developer/2000 application, but it is a "cheap and dirty" way to help a user.

Before you create the shortcut, you should set a preference in Graphics Runtime so that it tries to log on to the database at startup. This will cause Graphics Runtime to prompt you for your username, password, and database if you haven't supplied those on the command line. To do this, follow these steps:

  1. Invoke Graphics Runtime by selecting Start | Developer/2000 for Win95 |
    Graphics Runtime.
  2. Select Edit | Tools Options from the menu.
  3. Enable the checkbox labeled Logon at Startup.
  4. Click Save and OK.
  5. Exit the program.

To create the shortcut, do this:

  1. Right-click New | Shortcut on the Windows95 desktop. The Create Shortcut window appears.
  2. To run the Students by Year chart at runtime, enter the following line in Command Line field:
        c:\Orawin95\bin\g25run32     openfile=c:\Tyo\Students_by_Year.ogr
  1. Click Next.
  2. Give the shortcut a name like Chart - Students by Year.
  3. Click Finish.

Previous | Table of Contents | Next

Используются технологии uCoz