Page 435
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.
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
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.
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.
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.
To create a new chart, follow these steps:
select Year, Count(*) from Student group by Year;
Next, the Chart Genie will display a window in which you specify the Chart Properties.
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.
As you can see in Figure 16.5, there are no percentage labels for the pie segments. To add them, follow these steps:
You should now see the percent values displayed in the layout. Let's increase the size of
the title.
Page 440
Figure 16.5.
Changing the frame
properties to display
percent values.
Figure 16.6.
Formatting the chart
title.
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 Designerthe 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. |
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:
To create the shortcut, do this:
c:\Orawin95\bin\g25run32 openfile=c:\Tyo\Students_by_Year.ogr