Scatter Graph Data Requirements

24-16 Web User Interface Developers Guide for Oracle Application Development Framework ■ ADF Data Controls: You declaratively create a databound graph by dragging and dropping a data collection from the ADF Data Controls panel. You can create a graph using a data collection that provides row set data as described in the Creating Databound ADF Graphs section in the Oracle Fusion Middleware Fusion Developers Guide for Oracle Application Development Framework. ■ Hierarchical data: You can create a graph from a data control that provides hierarchical data. However, the current release does not include an implementation of a hierarchical data control that is supported by graph. ■ Tabular data: You can provide CSV comma-separated value data to a graph through the tabularData attribute as shown in Section 24.4.1, How to Create a Graph Using Tabular Data. .

24.4.1 How to Create a Graph Using Tabular Data

The process of creating a graph from tabular data includes the following steps: ■ Storing tabular data in a method in the graph’s managed bean. ■ Creating a graph that uses the tabular data stored in the managed bean.

24.4.1.1 Storing Tabular Data for a Graph in a Managed Bean

The tabularData attribute of a dvt:graph component lets you specify a list of data that the graph uses to create a grid and populate itself. To construct this list, you require an understanding of series and groups of data in a graph as well as knowledge of the structure of the list.

24.4.1.1.1 Series and Groups of Data A graph displays series and groups of data. Series

and groups are analogous to the rows and columns of a grid. Usually the rows in the grid appear as a series in a graph and the columns in the grid appear as groups in the graph. For most graphs, a series appears as a set of markers that are the same color. Usually the graph legend shows the identification and associated color of each series. For example, in a bar graph, the yellow bars might represent the sales of shoes and the green bars might represent the sales of boots. Groups appear differently in different graph types. In a clustered bar graph, each cluster is a group. In a stacked bar graph, each stack is a group. In a multiple pie graph, each pie is a group. A group might represent time periods, such as years. A group might also represent geographical locations such as regions. Depending on the data requirements for a graph type, a single group might require multiple data values. For example, a scatter graph requires two values for each data marker. The first value determines where the marker appears along the x-axis while the second value determines where the marker appears along the y-axis.

24.4.1.1.2 Structure of the List of Tabular Data The list that contains the tabular data

consists of a three-member Object array for each data value to be passed to the graph. The members of each array must be organized as follows: ■ The first member index 0 is the column label, in the grid, of the data value. This is generally a String. If the graph has a time axis, then this should be a Java Date. Column labels typically identify groups in the graph. ■ The second member index 1 is the row label, in the grid, of the data value. This is generally a String. Row labels appear as series labels in the graph, usually in the legend. Using ADF Graph Components 24-17 ■ The third member index 2 is the data value, which is usually Double.

24.4.1.1.3 Example of a List of Data

Figure 24–5 has three columns: 2006, 2007, and 2008. This graph also has two row: Shoes and Boots. This data produces a graph that compares annual sales for boots and shoes over a three-year period. Figure 24–5 Comparison of Annual Sales Example 24–3 shows code that creates the list of data required for a graph to compare annual sales of shoes and boots for a three-year period. Example 24–3 Code to Create a List of Data for a Graph public List getTabularData { ArrayList list = new ArrayList; String[] rowLabels = new String[] {Boots, Shoes}; String[] colLabels = new String[] {2006, 2007, 2008}; Double [] [] values = new Double[][]{ {120000, 122000, 175000}, {90000, 110000, 150000} }; for int c = 0; c colLabels.length; c++ { for int r = 0; r rowLabels.length; r++ { list.add new Object [] {colLabels[c], rowLabels[r], new Double values[r][c]}; } } return list; }

24.4.1.2 Creating a Graph Using Tabular Data

Use the tabularData attribute of a graph tag to reference data that is stored in a method in a managed bean. To create a graph that uses data from a managed bean: 1. In the Structure window, right-click the graph node and choose Go to Properties. 2. In the Data attributes category of the Property Inspector, click the TabularData attribute dropdown menu and choose Expression Builder. 3. From the ensuing dialog, use the search box to locate the managed bean. 4. Expand the managed bean node and select the method that contains the list of tabular data.

5. Click OK.

In the Expression Builder, the tabularData attribute is set to reference the method that you selected in the managed bean. For example, for a managed bean named named sampleGraph and a method named getTabularData, the tabularData attribute has the following setting: sampleGraph.tabularData.