Skip Headers
Oracle® Fusion Middleware Web User Interface Developer's Guide for Oracle Application Development Framework
11g Release 1 (11.1.1.6.0)

Part Number B31973-11
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

24 Using ADF Graph Components

This chapter describes how to use an ADF graph component to display data, and provides the options for graph customization.

This chapter includes the following sections:

For information about the data binding of ADF graphs, see the "Creating Databound ADF Graphs" section in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

24.1 Introduction to the Graph Component

The graph component gives you the capability of producing more than 50 types of graphs, including a variety of area, bar, bubble, combination, funnel, line, Pareto, pie, radar, scatter, sparkchart, and stock graphs. This component lets you evaluate multiple data points on multiple axes in many ways. For example, a number of graphs assist you in the comparison of results from one group with the results from another group.

A Component Gallery displays available graph categories, types, and descriptions to provide visual assistance when you are creating graphs and specifying a quick-start layout. Figure 24-1 shows the Component Gallery for horizontal bar graphs.

Figure 24-1 Component Gallery for Horizontal Bar Graphs

component gallery for horizontal bar graphs.

When a graph is inserted into a JSF page using the Component Gallery, a set of child tags that support customization of the graph is automatically inserted. Example 24-1 shows the source code for a horizontal bar graph with the quick-start layout selected in the Component Gallery in Figure 24-1.

Example 24-1 Horizontal Bar Graph Sample Code

<dvt:horizontalBarGraph id="horizontalBarGraph1"
        value="#{bindings.SalesStageDataView1.graphModel}"
        subType="BAR_HORIZ_CLUST">
        customLayout="CL_NONE"
  <dvt:background>
    <dvt:specialEffects/>
  </dvt:background>
  <dvt:graphPlotArea/>
  <dvt:seriesSet>
      <dvt:series/>
  </dvt:seriesSet>
  <dvt:o1Axis/>
  <dvt:y1Axis/>
  <dvt:legendArea automaticPlacement="AP_NEVER" position="LAP_BOTTOM"/>
  <dvt:legendTitle text="Legend Title"/>
  <dvt:graphSubtitle horizontalAlignment="CENTER" text="Subtitle"/>  <dvt:graphTitle horizontalAlignment="CENTER" text="Title"/>
</dvt:horizontalBarGraph>

Figure 24-2 shows the visual editor display of the horizontal bar graph created with the Component Gallery in Figure 24-1.

Figure 24-2 Horizontal Bar Graph in Visual Editor

Horizontal bar graph in visual editor.

When editing a graph in the visual editor, graph components such as the title, legend area, plot area, background, axis labels, and display of bars can be selected to display a context menu with editing choices. For more information about editing a graph in the visual editor, see Section 24.6, "Customizing the Appearance of Graphs."

Graphs are displayed in a default size of 400 X 300 pixels. You can customize the size of a graph or specify dynamic resizing to fit an area across different browser window sizes. When graphs are displayed in a horizontally or vertically restricted area, for example in a web page sidebar, the graph is displayed in a fully featured, although, simplified display.

To support visually impaired users who read web pages with a screen reader, graphs are automatically replaced with pivot tables when screen reader mode is enabled for the application. Screen readers can more easily navigate and read the data in a pivot table than in a graph. For information about enabling screen reader mode, see Section 22.2, "Exposing Accessibility Preferences." For information about ADF pivot tables, see Section 26.1, "Introduction to the ADF Pivot Table Component."

By default, graphs are displayed using a Flash player as specified in the graph component imageFormat attribute. Alternatively, graphs can be displayed using a Portable Network Graphics (PNG) output format, as in the case when plug-ins are not allowed on client machines, or in bi-directional locales. Although static rendering is fully supported when using a PNG output format, certain interactive features are not available including:

Both Flash and PNG image formats for graphs support bi-directional locales. Figure 24-3 shows bi-directional support in multiple pie graphs displayed with a Flash image format.

Figure 24-3 Bi-directional Support in Graphs

Bi-directional Support in Graph

24.2 Understanding the Graph Tags

Because of the many graph types and the significant flexibility of the graph components, graphs have a large number of DVT tags. The prefix (dvt:) occurs at the beginning of each graph tag name indicating that the tag belongs to the ADF Data Visualization Tools (DVT) tag library. The following list identifies groups of tags related to the graph component:

For complete descriptions of all the tags, their attributes, and a list of valid values, consult the DVT tag documentation. To access this documentation for a specific tag in JDeveloper, select the tag in the Structure window and press F1. To access the full ADF Data Visualization Tools tag library in JDeveloper Help, expand the Javadoc and Tag Library References node in the online Help Table of Contents and click the link to the tag library in the JDeveloper Tag Library Reference topic.

24.2.1 Graph-Specific Tags

There are 13 graph-specific tags:

  • dvt:areaGraph: Supports an area graph in which data is represented as a filled-in area. Use area graphs to show trends over time, such as sales for the last 12 months. Area graphs require at least two groups of data along an axis. The axis is often labeled with increments of time such as months.

  • dvt:barGraph: Supports a bar graph in which data is represented as a series of vertical bars. Use bar graphs to examine trends over time or to compare items at the same time, such as sales for different product divisions in several regions.

  • dvt:horizontalBarGraph: Creates a graph that displays bars horizontally along the y-axis. Use horizontal bar graphs to provide an orientation that allows you to show trends or compare values.

  • dvt:bubbleGraph: Creates a graph in which data is represented by the location and size of round data markers (bubbles). Use bubble graphs to show correlations among three types of values, especially when you have a number of data items and you want to see the general relationships. For example, use a bubble graph to plot salaries (x-axis), years of experience (y-axis), and productivity (size of bubble) for your work force. Such a graph allows you to examine productivity relative to salary and experience.

  • dvt:comboGraph: Creates a graph that uses different types of data markers (bars, lines, or areas) to display different kinds of data items. Use combination graphs to compare bars and lines, bars and areas, lines and areas, or all three combinations.

  • dvt:funnelGraph: Creates a graph that is a visual representation of data related to steps in a process. The steps appear as vertical slices across a horizontal cone-shaped section. As the actual value for a given step or slice approaches the quota for that slice, the slice fills. Typically, a funnel graph requires actual values and target values against a stage value, which might be time. For example, use the funnel graph to watch a process where the different sections of the funnel represent different stages in the sales cycle.

  • dvt:lineGraph: Creates a graph in which data is represented as a line, as a series of data points, or as data points that are connected by a line. Line graphs require data for at least two points for each member in a group. For example, a line graph over months requires at least two months. Typically a line of a specific color is associated with each group of data such as the Americas, Europe, and Asia. Use line graphs to compare items over the same time.

  • dvt:paretoGraph: Creates a graph in which data is represented by bars and a percentage line that indicates the cumulative percentage of bars. Each set of bars identifies different sources of defects, such as the cause of a traffic accident. The bars are arranged by value, from the largest number to the lowest number of incidents. A Pareto graph is always a dual-Y graph in which the first y-axis corresponds to values that the bars represent and the second y-axis runs from 0% to 100% and corresponds to the cumulative percentage values. Use Pareto graphs to identify and compare the sources of defects.

  • dvt:pieGraph: Creates a graph in which one group of data is represented as sections of a circle causing the circle to look like a sliced pie. Use pie graphs to show the relationship of parts to a whole such as how much revenue comes from each product line.

  • dvt:radarGraph: Creates a graph that appears as a circular line graph. Use radar graphs to show patterns that occur in cycles, such as monthly sales for the last three years.

  • dvt:scatterGraph: Creates a graph in which data is represented by the location of data markers. Use scatter graphs to show correlation between two different kinds of data values such as sales and costs for top products. Use scatter graphs in particular to see general relationships among a number of items. A scatter graph can display data in a directional manner as a polar graph.

  • dvt:sparkChart: Creates a simple, condensed graph that displays trends or variations in a single data value, typically stamped in the column of a table or in line with related text. Sparkcharts have basic conditional formatting.

    Note:

    In this release sparkcharts are created by inserting the dvt:sparkChart tag from the Component Palette and then binding the component to data. Sparkcharts cannot be created using the Data Controls panel.

  • dvt:stockGraph: Creates a graph in which data shows the high, low, and closing prices of a stock. Each stock marker displays two to four separate values (not counting the optional volume marker) depending on the specific type of stock graph chosen.

24.2.2 Common Graph Child Tags

Types of common customization and related child tags include:

  • Animation effects for graphs: dvt:animationOnDisplay and dvt:animationOnDataChange tags.

  • Alerts that highlight a data point with a custom icon: dvt:alertSet and dvt:alert tags.

  • Annotations that insert notes for specific data points: dvt:annotationSet and dvt:annotation tags.

  • Appearance and titles for the graph: dvt:background, dvt:graphFont, dvt:graphFootnote, dvt:graphPlotArea, dvt:graphSubtitle, and dvt:graphTitle tags.

  • Colors and appearance of bars, areas, lines, and pie slices (also known as series items): dvt:seriesSet and dvt:series tags.

  • Formatting categorical attributes in the ordinal axis and marker tooltips: dvt:attributeFormat.

  • Legend appearance: dvt:legendArea, dvt:legendText, and dvt:legendTitle tags.

  • Marker customization related to each axis: dvt:markerText, dvt:x1Format, dvt:y1Format, dvt:y2Format, and dvt:zFormat tags.

  • Reference lines and reference areas: dvt:referenceObjectSet and dvt:referenceObject tags.

  • Customization for the ordinal axis (also known as the category axis) used with bar, area, combination, line, radar, and stock graphs with group labels: dvt:o1Axis, dvt:o1MajorTick, dvt:o1TickLabel, and dvt:o1Title tags.

  • Customization for the x-axis used with scatter and bubble graphs with numerical labels: dvt:x1Axis, dvt:x1MajorTick, dvt:x1TickLabel, dvt:x1MinorTick, and dvt:x1Title tags.

  • Customization for the y1-axis: dvt:y1Axis, dvt:y1BaseLine, dvt:y1MajorTick, dvt:y1TickLabel, dvt:y1MinorTick, and dvt:y1Title tags.

  • Customization for the y2-axis: dvt:y2Axis, dvt:y2BaseLine, dvt:y2MajorTick, dvt:y2TickLabel, dvt:y2MinorTick, and dvt:y2Title tags.

24.2.3 Graph-Specific Child Tags

Types of graph-specific customizations and related child tags include:

  • Gradients that are used for a graph only in conjunction with dvt:background, dvt:legendArea, dvt:graphPlotArea, dvt:graphPieFrame, dvt:series, dvt:referenceObject, or dvt:timeSelector subcomponents: dvt:specialEffects and dvt:gradientStopStyle tags.

  • Interactivity specifications for subcomponents of a graph: dvt:shapeAttributesSet and dvt:shapeAttributes tags.

  • Formatting numerical data values for graph: dvt:sliceLabel, dvt:x1TickLabel, dvt:y1TickLabel, dvt:y2TickLabel, dvt:x1Format, dvt:y1Format, dvt:y2Format, dvt:zFormat, and dvt:stockVolumeFormat.

  • Time axis customization for area, bar, combination, line, and stacked bar graphs: dvt:timeAxisDateFormat, and dvt:timeSelector tags.

  • Selection of a range on a time axis for master-detail graphs: dvt:timeSelector tag.

  • Pareto graphs: dvt:paretoLine and dvt:paretoMarker tags.

  • Pie graphs: dvt:graphPieFrame, dvt:pieFeeler, dvt:slice, and dvt:sliceLabel tags.

  • Sparkcharts: dvt:sparkItem tag provides data for the sparkchart.

  • Stock graphs: dvt:stockMarker, dvt:stockVolumeformat, and dvt:volumeMarker tags.

24.2.4 Child Set Tags

Child set tags include:

  • dvt:alertSet tag: Wraps dvt:alert tags that define an additional data point that needs to be highlighted with a separate symbol, such as an error or warning.

  • dvt:annotationSet tag: Wraps dvt:annotation tags that define an annotation on a graph. An annotation is associated with a specific data point on a graph

  • dvt:referenceObjectSet tag: Wraps dvt:referenceObject tags that define a reference line or a reference area for a graph. You can define an unlimited number of reference objects for a given graph.

  • dvt:seriesSet tag: Wraps dvt:series tags that define a set of data markers or series on a graph.

  • dvt:shapeAttributesSet tag: Wraps dvt:shapeAttributes tags that specified interactivity properties on a subcomponent of a graph.

In each case, during design, you must create the wrapper tag first, followed by a related tag for each item in the set. Example 24-2 shows the sequence of the tags when you create a set of alert tags to define two alert points for an area graph.

Example 24-2 Sample Code for a Set of Alert Tags

<dvt:areaGraph id="areaGraph1" subType="AREA_VERT_ABS">
  <dvt:background>
    <dvt:specialEffects/>
  </dvt:background>
  <dvt:graphPlotArea/>
  <dvt:alertSet>
    <dvt:alert xValue="Boston" yValue="3.50"
           yValueAssignment="Y1AXIS" imageSource="myWarning.gif"/>
    <dvt:alert xValue="Boston" yValue="5.50"
           yValueAssignment="Y1AXIS" imageSource="myError.gif"/>
  </dvt:alertSet>
  <dvt:o1Axis/>
  <dvt:y1Axis/>
  <dvt:legendArea automaticPlacement="AP_NEVER"/>
</dvt:areaGraph>

24.3 Understanding Data Requirements for Graphs

Data requirements for graphs differ with graph type. Data requirements can be any of the following kinds:

Similar graphs share similar data requirements. For example, you can group the following graphs under the category of area graphs:

24.3.1 Area Graphs Data Requirements

An area graph is one in which data is represented as a filled-in area. The following kinds of area graphs are available:

  • Absolute: Each area marker connects a series of two or more data values. This kind of graph has the following variations: Absolute area graph with a single y-axis and absolute area graph with a split dual-Y axis.

    In a split dual-Y graph, the plot area is split into two sections, so that sets of data assigned to the different Y-axes appear in different parts of the plot area.

  • Stacked: Area markers are stacked. The values of each set of data are added to the values for previous sets. The size of the stack represents a cumulative total. This kind of graph has the following variations: Stacked area graph with a single y-axis and stacked area graph with a split dual y-axis.

  • Percentage: Area markers show the percentage of the cumulative total of all sets of data.

Data guidelines for area graphs are:

  • Area graphs require at least two groups of data. A group is represented by a position along the horizontal axis that runs through all area markers. In a graph that shows data for a three-month period, the groups might be labeled Jan, Feb, and Mar.

  • Area graphs require one or more series of data. A filled-in area represents a series or set of data and is labeled by legend text, such as the continent of the Americas, Europe, and Asia.

  • Percentage area graphs cannot have negative numbers.

  • Dual-Y graphs require two sets of data.

24.3.2 Bar Graph Data Requirements

A bar graph is one in which data is represented as a series of bars. The following kinds of bar graphs are available:

  • Clustered: Each cluster of bars represents a group of data. For example, if data is grouped by employee, one cluster might consist of a Salary bar and a Commission bar for a given employee. This kind of graph includes the following variations: Vertical clustered bar graphs and horizontal clustered bar graphs. All variations of clustered bar graphs can be arranged as single y-axis, dual y-axis, and split dual y-axis graphs.

  • Stacked: Bars for each set of data are appended to previous sets of data. The size of the stack represents a cumulative data total. This kind of graph includes the following variations: Vertical stacked bar graphs and horizontal stacked bar graphs. All variations of stacked bar graphs can be arranged as single y-axis, dual y-axis, and split dual y-axis graphs.

  • Percentage: Bars are stacked and show the percentage of a given set of data relative to the cumulative total of all sets of data. Percentage bar graphs are arranged only with a single y-axis.

Data guidelines for bar graphs are:

  • Percentage bar graphs cannot have negative numbers.

  • Dual-Y graphs require two sets of data.

24.3.3 Bubble Graph Data Requirements

A bubble graph is one in which data is represented by the location and size of round data markers (bubbles). Each data marker in a bubble graph represents three group values:

  • The first data value is the X value. It determines the marker's location along the x-axis.

  • The second data value is the Y value. It determines the marker's location along the y-axis.

  • The third data value is the z value. It determines the size of the marker.

The following kinds of bubble graphs are available: Bubble graph with a single y-axis and bubble graph with a dual y-axis.

Data guidelines for a bubble graph are:

  • Bubble graphs require at least three data values for a data marker.

  • For more than one group of data, bubble graphs require that data must be in multiples of three. For example, in a specific bubble graph, you might need three values for Paris, three for Tokyo, and so on. An example of these three values might be: X value is average life expectancy, Y value is average income, and z value is population.

    Note:

    When you look at a bubble graph, you can identify groups of data by examining tooltips on the markers. However, identifying groups is not as important as looking more at the overall pattern of the data markers.

24.3.4 Combination Graph Data Requirements

A combination graph uses different types of data markers to display different sets of data. The data markers used are bar, area, and line.

Data guidelines for combination graphs are:

  • Combination graphs require at least two sets of data or else the graph cannot show different marker types.

  • Combination graphs require at least two groups of data or else the graph cannot render an area marker or a line marker.

24.3.5 Funnel Graph Data Requirements

A funnel graph is a visual representation of data related to steps in a process. As the value for a given step (or slice) of the funnel approaches the quota for that slice, the slice fills. A funnel renders a three-dimensional chart that represents target and actual values, and levels by color. A funnel graph displays data where the target is considered to be 100%. Therefore, if the actual value is 50 and target is 200, then 25% of the slice will be filled.

Data guidelines for funnel graphs are:

  • Funnel graphs require two series (or sets of data). These two sets of data serve as the target and actual data values. Threshold values appear in the graph legend.

    Another variation of the funnel graph requires only one set of data, where the data values shown are percentages of the total values. To produce this type of funnel graph, you must set the funnelPercentMeasure property on the graph to be True. This setting should be done in the XML for the graph.

  • Funnel graphs require at least one group of data to be used as a stage.

24.3.6 Line Graph Data Requirements

A line graph represents data as a line, as a series of data points, or as data points that are connected by a line. The following kinds of line graphs are available:

  • Absolute: Each line segment connects two data points. This kind of graph can have its axes arranged as single y-axis, dual y-axis, and split dual y-axis.

  • Stacked: Lines for each set of data are appended to previous sets of data. The size of the stack represents a cumulative data total. This kind of graph can have its axes arranged as single y-axis, dual y-axis, and split dual y-axis.

  • Percentage: Lines are stacked and each line shows the percentage of a given set of data relative to the cumulative total of all sets of data. Percentage line graphs are arranged only with a single y-axis.

Data guidelines for line graphs are:

  • Line graphs require at least two groups of data because lines require at least two points. A group is represented by a marker of each color. The group has a tick label such as the name of a month.

  • Percentage line graphs cannot have negative numbers.

  • Dual-Y graphs require two sets of data.

24.3.7 Pareto Graph Data Requirements

Pareto graphs are specifically designed for identifying sources of defects. In a Pareto graph, a series of bars identifies different sources of defects. These bars are arranged by value, from the greatest number to the lowest number. A line shows the percentage of the cumulative values of the bars to the total values of all the bars in the graph. The line always ends at 100%.

Pareto graphs are always dual-Y graphs. The y1-axis corresponds to values that the bars represent. The y2-axis corresponds to the cumulative percentage values.

Data guidelines for Pareto graphs are:

  • Pareto graphs require at least two groups of data.

  • Pareto graphs cannot have negative numbers.

  • If you pass more than one set of data to a Pareto graph, the graph uses only the first set of data.

  • Do not pass percentage values as part of the data for a Pareto graph. The graph calculates the percentages based on the data that you pass.

24.3.8 Pie Graph Data Requirements

A pie graph represents data as sections of one or more circles, making the circles look like sliced pies. The following varieties of pie graphs are available:

  • Pie: The center of each circle is full. Pie graphs can consist of a single pie or multiple pies.

  • Ring: The center of each circle has a hole in which the total pie value is displayed. Ring graphs can consist of a single ring or multiple rings.

The data structure of a pie graph follows:

  • Each pie or ring represents one group of data and has a pie or ring label such as the name of a month. If you have only one group of data, then only one pie or ring appears even if you selected a multiple pie or ring graph type. Also, if any group has all zero data, then the pie or ring for that group is not displayed.

  • A series or set of data is represented by all the slices of the same color. You see legend text for each set of this data. For example, if there is a separate set of data for each country, then the name of each country appears in the legend text.

Data guidelines for pie graphs are:

  • Pie graphs cannot have negative numbers.

  • Multiple pie graphs require at least two groups of data.

24.3.9 Polar Graph Data Requirements

A polar graph is a circular scatter graph. In a polar graph, as in a scatter graph, data is represented by the location of data markers. In a polar graph, the plot area, where the markers appear, is circular. For information about scatter graphs, see Section 24.3.11, "Scatter Graph Data Requirements."

Like scatter graphs, polar graphs are especially useful when you want to see general relationships among a number of data items. Use polar graphs rather than scatter graphs when the data has a directional aspect.

Each data marker in a polar graph represents two data values:

  • The first data value is the X value. It determines the location of the marker along the x-axis, which is the location around the circle, clockwise.

  • The second data value is the Y value. It determines the location of the marker along the y-axis, which is the distance from the center of the graph.

Data guidelines for a polar graph require at least two data values for each marker.

24.3.10 Radar Graph Data Requirements

A radar graph is a polygonal line graph similar to how a polar graph is a circular scatter graph. Use radar graphs to show patterns that occur in cycles, such as monthly sales for the last three years.

The data structure of a radar graph follows:

  • The number of sides on the polygon is equal to the number of groups of data. Each corner of the polygon represents a group.

  • A series or set of data is represented by a line, all the markers of the same color, or both. It is labeled by legend text.

Data guidelines for radar graphs require at least three groups of data.

24.3.11 Scatter Graph Data Requirements

A scatter graph represents data by the location of data markers. Scatter graphs are especially useful when you want to see general relationships among a number of data points. For example, you can use a scatter graph to examine the relationships between Sales and Profit values for specific products.

Scatter graphs have either a single y-axis or a dual y-axis. Each data marker in a scatter graph represents two values:

  • The first data value is the X value. It determines the marker's location along the x-axis.

  • The second data value is the Y value. It determines the marker's location along the y-axis.

Data guidelines for scatter graphs are:

  • Scatter graphs require two data values for each marker.

  • For more than one group of data, the data must be in multiples of two.

24.3.12 Sparkchart Data Requirements

Sparkcharts are used for displaying trends or variations in a single series of data values. They are condensed, simple visualizations designed to be stamped in a table or used inline with text. Since sparkcharts contain no labels, the adjacent columns of a table or surrounding text provide context for sparkchart content.

Sparkcharts do not accept tabular data or graphDataModel. Data guidelines for sparkcharts are:

  • Line, bar, and area sparkcharts require a single series of data values. Figure 24-4 shows an example of a line sparkchart in a table column.

    Figure 24-4 Line Sparkchart

    line sparkchart
  • Floating bar sparkcharts require two series of data values, one for the float offset, and one for the bar value. Figure 24-5 shows an example of a floating bar sparkchart in a table column.

    Figure 24-5 Floating Bar Sparkchart

    Floating bar sparkchart example.

24.3.13 Stock Graph Data Requirements

Stock graphs display stock prices and, optionally, the volume of trading for one or more stocks in a graph. When any stock or candle stock graph includes the volume of trading, the volume appears as bars in the lower part of the graph.

Candle stock graphs display stock prices and, optionally, the volume of trading for only a single stock. When a candle stock graph includes the volume of trading, the volume appears as bars in the lower part of the graph.

Candle stock graphs also show the lesser of the open and close values at the bottom of the candle. The greater value appears at the top of the candle. If the closing value is greater than the opening value, then the candle is green. If the opening value is higher than the closing value, then the candle is red.

24.3.13.1 Stock Graphs: High-Low-Close

Data requirements for a high-low-close stock graph are:

  • Each stock marker requires a group of three data values in the following sequence: High, Low, Close. To display stock data for more than one day, data must be in multiples of three, such as three data values for Monday, three data values for Tuesday, and so on.

  • A series (or set) of data is represented by markers of the same color that represent one stock. A series is labeled by legend text such as Stock A. The legend appears even if you have only one stock with the except of candle stock graphs. Most high-low-close stock graphs have only one series. If you show more than one series and the prices of the different stocks overlap, then some stock markers obscure other stock markers.

24.3.13.2 Stock Graphs: High-Low-Close with Volume

Data requirements for a high-low-close stock graph with volume are:

  • Each stock marker requires a group of four data values in the following sequence: High, Low, Close, Volume. To display stock data for more than one day, data must be in multiples of four and sequenced as follows: Monday High, Monday Low, Monday Close, Monday Volume, and so on for each additional day.

  • High-low-close stock graphs that also show volume can display the data for only one stock. The label for this stock appears in the legend of the graph.

24.3.13.3 Stock Graphs: Open-High-Low-Close

Data requirements for an open-high-low-close stock graph are:

  • Each stock marker requires a group of four data values in the following sequence: Open, High, Low, Close. To display stock data for more than one day, data must be in multiples of four, such as four data values for Monday, four data values for Tuesday, and so on.

  • A series (or set) of data is represented by markers that have the same color and represent one stock. A series is labeled by legend text such as Stock A. The legend appears even if you have only one stock. Most open-high-low-close stock graphs have only one series. If you show more than one series and the prices of the different stocks overlap, then some stock markers obscure other stock markers.

24.3.13.4 Stock Graphs: Open-High-Low-Close with Volume

Data requirements for an open-high-low-close stock graph with volume are:

  • Each stock marker requires a group of five data values in the following sequence: Open, High, Low, Close, Volume. To display stock data for more than one day, data must be in multiples of five and sequenced as follows: Monday Open, Monday High, Monday Low, Monday Close, Monday Volume, and so on for each additional day.

  • Open-high-low-close stock graphs that also show volume can display the data for only one stock. The label for this stock appears in the legend of the graph.

24.3.13.5 Candle Stock Graphs: Open-Close

Data requirements for an open-close candle stock graph are:

  • Each stock marker requires a group of two data values in the following sequence: Open, Close. To display stock data for more than one day, data must be in multiples of two, such as two data values for Monday, two data values for Tuesday, and so on.

  • A series (or set of data) is represented by markers for one stock. Candle stock graphs allow the display of values for only one stock. For this reason, no legend appears in these graphs and you should show the series label (which is the name of the stock) in the title of the graph.

24.3.13.6 Candle Stock Graphs: Open-Close with Volume

Data requirements for an open-close candle stock graph with volume are:

  • Each stock marker requires a group of three data values in the following sequence: Open, Close, Volume. To display stock data for more than one day, data must be in multiples of three, such as three data values for Monday, three data values for Tuesday, and so on.

  • A series (or set of data) is represented by markers for one stock. Candle stock graphs allow the display of values for only one stock. For this reason, no legend appears in these graphs and you should show the series label (which is the name of the stock) in the title of the graph.

24.3.13.7 Candle Stock Graphs: Open-High-Low-Close

Data requirements for an open-high-low-close candle stock graph are:

  • Each stock marker requires a group of four data values in the following sequence: Open, High, Low, Close. To display stock data for more than one day, data must be in multiples of four, such as four data values for Monday, four data values for Tuesday, and so on.

  • A series (or set) of data is represented by markers for one stock. Candle stock graphs allow the display of values for only one stock. For this reason, no legend appears in these graphs and you should show the series label (which is the name of the stock) in the title of the graph.

24.3.13.8 Candle Stock Graphs: Open-High-Low-Close with Volume

Data requirements for an open-high-low-close candle stock graph with volume are:

  • Each stock marker requires a group of five data values in the following sequence: Open, High, Low, Close, Volume. To display stock data for more than one day, data must be in multiples of five, such as five data values for Monday, five data values for Tuesday, and so on.

  • A series (or set) of data is represented by markers for one stock. Candle stock graphs allow the display of values for only one stock. For this reason, no legend appears in these graphs and you should show the series label (which is the name of the stock) in the title of the graph.

24.4 Creating a Graph

You can use any of the following data sources to create a graph component:

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.

  • 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-6 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-6 Comparison of Annual Sales

Tabular data for graph.

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).

24.4.2 What Happens When You Create a Graph Using Tabular Data

When you create a graph that is powered by data obtained from a list referenced the tabularData attribute a vertical clustered bar graph is created by default. You have the option of changing the settings of the graphType attribute to any of the more than 50 graphs that are available as long as the tabular data meets the data requirements for that graph type. You can also change the settings of the many additional attributes on the dvt:graph tag.

Customize the graph by dragging any of the graph child tags to the dvt:graph node in the Structure window and providing settings for the attributes that you want to specify.

24.4.3 What You May Need to Know About Graph Image Formats

By default, graphs are displayed using the following image formats:

  • If supported, use HTML5.

  • Otherwise, use Flash if the Flash Player is available. Also use Flash for browsers which don't offer enough HTML5 support.

  • Otherwise, use a fallback like a Portable Network Graphics (PNG) output format, as in the case when plug-ins are not allowed on client machines or bi-directional locales. A PNG output format is used also when printing graphs. Although static rendering is fully supported when using a PNG output format, certain interactive features are not available including:

    • Animation

    • Context menus

    • Popup support

    • Interactivity

You can change the default output format using the web.xml context parameter, oracle.adf.view.rich.dvt.DEFAULT_IMAGE_FORMAT. Applications that have this context parameter and haven't specified an image format, would automatically default to HTML5. Use the graph imageFormat attribute to explicitly set HTML5, for example, imageFormat="HTML5." If the browser does not fully support HTML5, fallback to Flash or PNG image is used. For more information, see Section A.2.3.22, "Graph and Gauge Image Format."

You can disable the use of Flash content across the entire application by setting a flash-player-usage context parameter in adf-config.xml. For more information, see Section A.4.3, "Configuring Flash as Component Output Format."

When graphs are displayed in ADF table cells through stamping, a PNG_STAMPED setting is required for the graph's imageFormat attribute.

24.5 Changing the Graph Type

When you insert a graph using the Data Controls panel or the Component Palette, the Component Gallery displays available graph categories, types, and quick-start layout options from which to choose. Selecting a graph type sets the subType attribute for that graph. You can change the type for all graphs except the funnel and radar graphs.

To change the type of a graph:

  1. In the Structure window, right-click the graph node and choose Go to Properties.

  2. In the Common attributes category of the Property Inspector, for the SubType attribute, select the desired type from the attribute dropdown menu. The valid values will vary depending on the graph.

    For example, the valid values for a bar graph are:

    • BAR_VERT_CLUST: Clustered bar graph that has a vertical orientation.

    • BAR_VERT_CLUST_SPLIT2Y: Clustered, vertical, split dual-Y bar graph.

    • BAR_VERT_CLUST2Y: Clustered, vertical, dual-Y bar graph.

    • BAR_VERT_FLOAT_STACK: Floating, vertical, stacked bar graph.

    • BAR_VERT_PERCENT: Percent, vertical bar graph.

    • BAR_VERT_STACK: Stacked, vertical bar graph.

    • BAR_VERT_STACK_SPLIT2Y: Stacked, vertical, split dual-Y bar graph.

    • BAR_VERT_STACK2Y: Stacked, vertical, dual-Y bar graph.

24.6 Customizing the Appearance of Graphs

Most graph types have common features that are available for customization. The following types of customization are supported by most graph types:

Note:

In order to avoid invalid color values, JDeveloper provides a color selection dialog when you specify color-related attributes in graph elements.

When you edit graph components in the visual editor, specialized context menus and Property Inspector buttons are available to support the customization of graph features. Popups in the editor provide confirmation of selection of the graph feature to be customized. For example, Figure 24-7 shows the popup displayed in the plot area of a line graph.

Figure 24-7 Visual Editor Popup in Line Graph

Popup displaying plot area in visual editor.

When the graph feature is selected in the visual editor, a specialized editing context menu is made available. Figure 24-8 shows the line graph plot area context menu from which you can choose a variety of options including removing the default display of the horizontal grid marks. You can also use the context menu or the Property Inspector buttons to configure special fill effects in the plot area. The selection of the graph tags is synchronized in the visual editor, Structure window, Property Inspector, and source editor.

Figure 24-8 Line Graph Plot Area Context Menu

Plot area context menu synched with Property Inspector.

For additional information about configuring line graphs, see. Section 24.7.2, "Changing the Appearance of Lines in Graphs." For additional information about configuring special fill effects, see Section 24.8.2, "Using Gradient Special Effects in Graphs."

24.6.1 Changing the Color, Style, and Display of Graph Data Values

For most graph types, an entry appears in the legend for each set of data values represented as graph bars, lines, areas, points, and slices. This entry identifies a set of related data values and displays the color that represents the set in the graph. For example, a bar graph might use yellow bars to represent the sales of shoes and green bars to represent the sales of boots. The graph component refers to each set of related data values as a series.

The graph automatically assigns a different color to each set of data values. You can customize the colors assigned to each series, including the fill color and the border color. For some graph types, you can enable filtering the display of data values in a graph by hiding or showing the series from the graph legend.

You can specify additional characteristics for specific graph types such as the width and style of lines in a line graph with choices including solid lines, dotted lines, lines with dashes, and so on. For more information, see Section 24.7.2, "Changing the Appearance of Lines in Graphs."

For scatter graphs you can separate data marker shape and color from the series to display the interdependence of data values. For more information, see Section 24.7.4, "Customizing Scatter Graph Series Markers."

You can also customize the colors of each series in a graph by adding gradient special effects. For more information, see Section 24.8.2, "Using Gradient Special Effects in Graphs."

24.6.1.1 How to Specify the Color and Style for Individual Series Items

Use one dvt:seriesSet tag to wrap all the individual dvt:series tags for a graph and set attributes for color and style of graph data markers.

To specify the color and style for series items in a graph:

  1. In the Structure window, right-click the dvt:seriesSet child tag in the graph node, and choose Go to Properties.

  2. Optionally, use the Property Inspector to specify values for attributes of the dvt:seriesSet tag.

    The attributes of this tag determine default settings for all series tags in the set. However, you can override these settings for a given series by entering values in the corresponding attributes of a dvt:series tag.

  3. In the Structure window, right-click the seriesSet node and choose Insert inside dvt:seriesSet > Series.

    The first dvt:series tag represents the first series item that appears in the Create Graph Binding dialog.

  4. Use the Property Inspector to specify colors and other characteristics as needed for the dvt:series tag.

  5. Repeat Step 3 and Step 4 for each series item.

24.6.1.2 How to Enable Hiding and Showing Series Items

For graph types including area, bar, bubble, combination, line, pie, radar, and scatter, you can enable the hiding or showing of the series in a graph at runtime. Although at least one series must be displayed in the graph, users can filter the display of data values by clicking on the corresponding legend item.

To enable hiding and show series items:

  1. In the Structure window, right-click the graph node and choose Go to Properties.

  2. In the Property Inspector, in the Series section of the Appearance attributes category, set the hideAndShowBehavior attribute of the graph. Valid values include:

    • none: Default value, no hide and show series behavior is enabled.

    • withRescale: Rescales the graph to show only the visible series.

    • withoutRescale: Hides the series, but does not rescale the graph.

24.6.2 Formatting Data Values in Graphs

The attributes in a data collection can be data values or categories of data values. Data values are numbers represented by markers, like bar height, or points in a scatter graph. Categories of data values are members represented as an ordinal axis label, or appear as additional properties in a tooltip. You can format both numerical and categorical attributes by using ADF Faces converter tags, including af:convertNumber for numerical data values, and af:convertNumber, af:convertDateTime, and af:convertColor for categorical data values.

Converter tag attributes let you format percents, scale numbers, control the number of decimal places, placement of signs, and so on. For more information about ADF Faces converters, see Chapter 6, "Validating and Converting Input."

24.6.2.1 How to Format Categorical Data Values

Categorical data values in graphs are represented by the name in the page definition file (<pagename>PageDef.xml) that defines the graph's data model. Example 24-4 shows the XML code in a page definition file for a page with a graph displaying categorical data values for the hire date and the bonus cost for employees.

Example 24-4 Categorical Data Value Names in Page Definition File

<graph IterBinding="EmpView1Iterator" id="EmpView1"
    xmlns="http://xmlns.oracle.com/adfm/dvt" type="BAR_VERT_CLUST">
  <graphDataMap leafOnly="true">
    <series>
      <data>
        <item value="Bonus"/>
      </data>
    </series>
    <groups>
        <item value="Hiredate"/>
    </groups>
  </graphDataMap>
</graph>

For each categorical attribute to be formatted, use the dvt:attributeFormat tag to specify the name of the categorical data value, and specify the child converter tag to be used when formatting the attribute. You can use af:convertNumber, af:convertDateTime, and af:convertColor to specify formatting for a categorical attribute.

For example, you can format the hire date and bonus categorical data values defined in the page definition file in Example 24-4.

To format categorical data values defined in a page definition file:

  1. In the Structure window, right-click the bar graph tag and choose Insert inside dvt:barGraph > ADF Data Visualizations > Attribute Format.

  2. In the Property Inspector, for the Name attribute, enter Hiredate as the name of the af1 category attribute.

  3. In the Structure window, right-click the attribute format tag you named and choose Insert inside dvt:attributeFormat > Convert Date Time.

  4. In the Property Inspector, for the Pattern attribute, enter the formatting pattern for the date/time string conforming to java.text.SimpleDateFormat. For the TimeZone attribute, enter the timezone to interpret any time information in the data string.

  5. Repeat Steps 1-4 for the bonus category attribute, setting Bonus as the name of the af2 category attribute, adding an af:convertNumber converter, and formatting the attribute for currency.

Example 24-5 shows the XML code that is generated if you format the categorical data values in a bar graph.

Example 24-5 Formatting Categorical Data Values in a Bar Graph

<dvt:barGraph id="barGraph1" value="#{bindings.EmpView1.graphModel}" 
    subType="BAR_VERT_CLUST">
  <dvt:attributeFormat id="af1" name="Hiredate">
    <af:convertDateTime pattern = "yyyy-MM-dd hh:mm:ss a"  timeZone="US/Pacific"/>
  </dvt:attributeFormat>
  <dvt:attributeFormat id="af2" name="Bonus">
    <af:convertNumber type = "currency" currencySymbol = "$"
  </dvt:attributeFormat>
</dvt:barGraph

Note:

If there is a single categorical date attribute being displayed on the ordinal (O1) axis, then the graph displays a time axis. The time axis will show dates in a hierarchical format as opposed to a single label on the axis, for example, June 27, 2001. To display a single label on the ordinal axis, the time axis should be turned off, for example timeAxisType="TAT_OFF" and a dvt:attributeFormat tag should be used to specify the date format.

24.6.2.2 How to Format Numerical Data Values

Use the ADF Faces af:convertNumber tag to specify formatting for numeric data values related to any of the following graph tags:

  • dvt:sliceLabel

  • dvt:stockVolumeFormat

  • dvt:x1TickLabel

  • dvt:x1Format

  • dvt:y1TickLabel

  • dvt:y1Format

  • dvt:y2TickLabel

  • dvt:y2Format

  • dvt:zFormat

For example, by default a pie graph shows the relationship of parts to a whole, represented as slices in a pie, and each slice label displays the percentage that each slice represents. You can configure a pie graph to represent each slice as a value such as the cost of materials, labor, and profit that make up the list price. Specify the textType attribute of the dvt:sliceLabel tag to display the value represented in the slice, and format the number accordingly.

To format numbers in the slice label of a pie graph:

  1. In the Structure window, right-click the child dvt:sliceLabel tag of the pie graph tag and choose Go to Properties.

  2. In the Property Inspector, choose LD_VALUE from the TextType attribute dropdown list to specify that the pie slice in the graph represents a value.

  3. In the Property Inspector, click Configure Slice Label and choose Number Format from the dropdown list.

  4. In the Property Inspector, for the af:convertNumber tag, specify the values as currency, using a dollar sign as the currency symbol.

Example 24-6 shows the XML code that is generated if you format the numerical data values in the slice label of a pie graph to appear as currency, and use the dollar sign symbol.

Example 24-6 Formatting Numerical Data Values in the Slice Label of a Pie Graph

<pieGraph>
...
  <dvt:sliceLabel textType="LD_Value">
    <af:convertNumber type="currency" currencySymbol="$"/>
  </dvt:sliceLabel>
...
</pieGraph>

You can also use the ADF Faces af:convertNumber tag to format numbers in the marker text of a graph.

For example, you can provide different formatting for the marker text of each axis in the graph. In this procedure, the af:convertNumber tag is used to format the marker text on dvt:y1Format.

To format numerical values in the marker text associated with the y1-axis of a graph:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Marker Text.

  2. In the Property Inspector, optionally enter values for attributes of dvt:markerText.

    For example, select true for the rendered attribute to display the text in the graph.

  3. In the Property Inspector, click Configure Marker and choose Y1 Format.

  4. In the Property Inspector, optionally enter values as needed for the dvt:y1Format attributes.

  5. In the Property Inspector, click Configure Number Format and specify values as needed for the attributes of the af:convertNumber tag.

    For example, select a percent value for the type attribute to place a percentage sign after the marker text.

Example 24-7 shows the XML code that is generated when you format the numbers in the marker text for the y1-axis of a graph. This example specifies that numbers are followed by a percentage sign and the text appears above the markers. For example, in a bar graph, the text will appear above the bars.

Example 24-7 Formatting Numbers in Graph Marker Text

<dvt:barGraph>
  <dvt:markerText rendered="true" markerTextPlace="MTP_OUTSIDE_MAX">
    <dvt:y1Format>
      <af:convertNumber type="percent"/>
    </dvt:y1Format>
  </dvt:markerText>
</dvt:barGraph>

Note:

When the textType attribute of a pie slice label is set to percent (LD_PERCENT), or the markerTooltipType attribute of a graph tooltip is set to percent (MTT_PERCENT_XXX), a child af:convertNumber tag, if used, will be automatically set to percent for its type attribute. When af:convertNumber is forced to percent, graph clears the pattern attribute. This means that patterns are ignored when a graph forces percent formatting. This is applicable for pie, Pareto, funnel and any bar, line, or area percent graph.

24.6.2.3 What You May Need to Know About Automatic Scaling and Precision

In order to achieve a compact and clean display, graphs automatically determine the scale and precision of the values being displayed in axis labels, marker text, and tooltips. For example, a value of 40,000 will be formatted as 40K, and 0.230546 will be displayed with 2 decimal points as 0.23.

Automatic formatting still occurs when af:convertNumber is specified. Graph tags that support af:convertNumber child tags have scaling and autoPrecision attributes that can be used to control the graph's automatic number formatting. By default, these attribute values are set to scaling="auto" and autoPrecision="on". Fraction digit settings specified in af:convertNumber, such as minFractionDigits, maxFractionDigits, or pattern, are ignored unless autoPrecision is set to off.

24.6.3 Formatting Text in Graphs

You can format text in any of the following subcomponents of a graph:

  • Annotation: Includes only the dvt:annotation tag.

  • Axis title: Includes the dvt:o1Title, dvt:x1Title, dvt:y1Title, and dvt:y2Title tags.

  • Axis tick label: Includes the dvt:o1TickLabel, dvt:x1TickLabel, dvt:y1TickLabel, and dvt:y2TickLabel tags.

  • Graph title: Includes the dvt:graphFootnote, dvt:graphSubtitle, and dvt:graphTitle tags.

  • Legend: Includes only the dvt:legendText tag.

  • Marker: Includes only the dvt:markerText tag.

Use the dvt:graphFont tag as a child of the specific subcomponent for which you want to format text. For an example of formatting text in a graph, see Section 24.6.5.2, "How to Specify Titles and Footnotes in a Graph,".

24.6.3.1 How to Globally Set Graph Font Using a Skin

You can set the font attributes of graph components globally across all pages in your application by using a cascading style sheet (CSS) to build a skin, and configuring your application to use the skin. By applying a skin to define the fonts used in graph components, the pages in an application will be smaller and more organized, with a consistent style easily modified by changing the CSS file.

You can use the ADF Data Visualization Tools Skin Selectors to define the font styles for graph components. Graph component skin selectors include the following:

  • af|dvt-graphFootnote

  • af|dvt-graphSubtitle

  • af|dvt-graphTitle

  • af|dvt-o1Title

  • af|dvt-x1Title

  • af|dvt-y1Title

  • af|dvt-y2Title

  • af|dvt-pieLabel

  • af|dvt-ringTotalLabel

  • af|dvt-legendTitle

  • af|dvt-legendText

  • af|dvt-markerText

  • af|dvt-o1TickLabel

  • af|dvt-x1TickLabel

  • af|dvt-y1TickLabel

  • af|dvt-y2TickLabel

  • af|dvt-annotation

  • af|dvt-sliceLabel

  • af|dvt-tooltips

You can also use ADF Data Visualization Tools global skin selectors to define the font attributes across multiple graph components. Global skin selector names end in the :alias pseudo-class, and affect the skin for more than one component. Global graph skin selectors include the following:

  • .AFDvtGraphFont:alias: Specifies the font attributes for all graph components.

  • .AFDvtGraphTitlesFont:alias: Specifies the font attributes for all graph title components.

  • .AFDvtGraphLabelsFont:alias: Specifies the font attributes for all graph label components.

To use a custom skin to set graph fonts:

  1. Add a custom skin to your application containing the defined skin style selectors for the graph subcomponents. You can specify values for the following attributes:

    • -tr-font-family: Specifies the font family (name). It may not contain more than one font. If multiple fonts are specified, the first font will be used.

    • -tr-font-size: Specifies the size of the font. Units of absolute size are defined as:

      • pt: Points - the standard font size used by CSS2, where 1 point equals 1/72nd of an inch.

      • in: Inches, where 1 inch equals 72 points.

      • cm: Centimeters, where 1 centimeter equals approximately 28 points.

      • mm: Millimeters, where 1 millimeter equals approximately 2.8 points.

      • pc: Picas, where 1 pica equals 12 points.

      You can also use font size names for this attribute, including the following:

      • xx-small: 8 points

      • x-small: 9 points

      • small: 10 points

      • medium: 12 points

      • large: 14 points

      • x-large: 16 points

      • xx-large: 18 points

    • -tr-font-style: Specifies the style of the font. Valid values are normal or italic.

    • -tr-font-weight: Specifies the weight of the font. Valid values are normal or bold.

    • -tr-text-decoration: Specifies whether or not the underline emphasis is rendered. Valid values are none or underline.

    • -tr-color: Specifies the color of the font. Valid values are color names for HTML and CSS. The World Wide Consortium lists 17 valid color names including aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange (CSS 2.1), purple, red, silver, teal, white, and yellow.

      You can also use 3, 6, or 8 digits HEX (alpha channel is first 2 digit in 8 digit HEX), RGB, or RGBA.

    For example, specify the font family for all graph titles in a mySkin.css file as follows:

    af|dvt-graphTitle,
    {
      -tr-font-family: Comic Sans MS:
    }
    
  2. Register the custom skin with the application in the trinidad-skins.xml file. For example, mySkin.css extends the default blafplus-rich.desktop style sheet:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <skins xmlns="http://myfaces.apache.org/trinidad/skin">
      <skin>
        <id>mySkinExtends.desktop</id>
        <family>mySkinExtends</family>
        <extends>blafplus-rich.desktop</extends>
        <render-kit-id>org.apache.myfaces.trinidad.desktop</render-kit-id>
        <style-sheet-name>skins/mySkin.css</style-sheet-name>
      </skin>
    </skins>
    
  3. Configure the application to use the custom skin in the trinidad-config.xml file. For example:

    <trinidad-config xmlns="http://myfaces.apache.org/trinidad/config">
      <skin-family>mySkin</skin-family>
    </trinidad-config>
    
  4. Package the custom skin into a jar file to deploy with the application. The trinidad-skins.xml file that defines the skin and that references the CSS file must be within the META-INF directory.

For detailed information about applying a custom skin to applications, see Chapter 20, "Customizing the Appearance Using Styles and Skins."

24.6.4 Changing Graph Size and Style

You can customize the width and height of a graph and you can allow for dynamic resizing of a graph based on changes to the size of its container. You can also control the style sheet used by a graph. These two aspects of a graph are interrelated in that they share the use of the graph inlineStyle attribute.

24.6.4.1 How to Specify the Size of a Graph at Initial Display

You can specify the initial size of a graph by setting values for attributes of the dvt:<type>Graph tag. If you do not also provide for dynamic resizing of the graph, then the initial size becomes the only display size for the graph.

To specify the size of a graph at its initial display:

  1. In the Structure window, right-click the graph node and choose Go to Properties.

  2. In the Style attributes category of the Property Inspector, enter a value for the inlineStyle attribute of the graph tag. For example:

    inlineStyle="width:200px;height:200px"
    

24.6.4.2 How to Provide for Dynamic Resizing of a Graph

You must enter values in each of two attributes of the dvt:<type>Graph tag to allow for a graph to resize when its container in a JSF page changes in size. The values that you specify for this capability also are useful for creating a graph component that fills an area across different browser window sizes.

To allow dynamic resizing of a graph:

  1. In the Structure window, right-click the graph node and choose Go to Properties.

  2. In the Behavior attributes category of the Property Inspector for the DynamicResize attribute, select the value DYNAMIC_SIZE.

  3. In the Style attributes category of the Property Inspector for the InlineStyle attribute, enter a fixed number of pixels or a relative percent for both width and height.

    For example, to create a graph that fills its container's width and has a height of 200 pixels, use the following setting for the inlineStyle attribute: "width:100%;height:200px;".

24.6.4.3 How to Use a Specific Style Sheet for a Graph

You have the option of selecting any of the standard styles available for the dvt:<type>Graph tag. You can also specify a custom style sheet for use with a graph.

To select a specific style sheet for a graph:

  1. If you want to use one of the standard style sheets provided with the graph, do the following:

    1. In the Structure window, right-click the graph node and choose Go to Properties.

    2. In the Appearance attributes category, select the desired style sheet from the style attribute dropdown list.

  2. If you want to use a custom style sheet, then set the following attributes in the Style attributes category of the Property Inspector:

    1. For the StyleClass attribute, select Edit from the Property menu choices, and select the CSS style class to use for this gauge.

    2. In the InlineStyle attribute, enter a fixed number of pixels or a relative percent for both width and height.

      For example, to create a graph that fills its container's width and has a height of 200 pixels, use the following setting for the inlineStyle attribute: "width:100%;height:200px;"

24.6.5 Changing Graph Background, Plot Area, and Title

The graph automatically provides default settings for its background and plot area based on the style it is using. You can customize these settings using child tags of the graph.

The graph also provides title, subtitle, and footnote options that you can specify. By default, no text is provided for titles and footnotes. When you enter this information, you can also specify the font and font characteristics that you want to use for the text.

24.6.5.1 How to Customize the Background and Plot Area of a Graph

You can customize the following parts of graphs related to background and plot area:

  • Background: The area on which the graph is plotted.

  • Plot area: A frame in which data is plotted for all graphs other than pie graphs. Axes are displayed on at least two borders of the plot area.

  • Pie frame: A frame in which pie graphs are plotted without the use of axes.

To customize the background and plot area of a graph:

  1. If you want to customize the background of a graph, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Background.

    2. Use the Property Inspector to enter colors in the attributes that you want to customize in the dvt:background tag.

  2. If you want to customize the plot area of any graph other than a pie graph, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Plot Area.

    2. Use the Property Inspector to enter colors in the attributes that you want to customize in the dvt:graphPlotArea tag.

  3. If you want to customize the plot area of a pie graph, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Pie Frame.

    2. Use the Property Inspector to enter colors in the attributes that you want to customize in the dvt:graphPieFrame tag.

Note:

You can also customize the colors of the background and plot area in a graph by adding gradient special effects. For more information, see Section 24.8.2, "Using Gradient Special Effects in Graphs."

24.6.5.2 How to Specify Titles and Footnotes in a Graph

You have the option of specifying a title, subtitle, and footnote for a graph. You use a separate child tag of the graph for each of these text entries. The attributes of each of these child tags let you define the horizontal alignment of the text field, the text content, and whether or not the text should be rendered.

The tags for title, subtitle, and footnote support the use of a child graph font tag to let you identify the exact font characteristics to be used for each text field.

To specify titles and a footnote for a graph:

  1. If you want to enter a graph title, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Graph Title.

    2. Use the Property Inspector to specify values in the attributes of the dvt:graphTitle tag.

    3. If you want to provide specific font characteristics for the text, then in the Structure window, right-click the dvt:graphTitle node and choose Insert inside dvt:graphTitle > Font.

    4. Use the Property Inspector to specify values for the attributes of the dvt:graphFont tag.

  2. If you want to enter a graph subtitle, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Subtitle.

    2. Use the Property Inspector to specify values in the attributes of the dvt:graphSubtitle tag.

    3. If you want to provide specific font characteristics for the text, in the Structure window, right-click the dvt:graphSubtitle node and choose Insert inside dvt:graphSubtitle > Font.

    4. Use the Property Inspector to specify values for the attributes of the dvt:graphFont tag.

  3. If you want to enter a graph footnote, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Footnote.

    2. Use the Property Inspector to specify values in the attributes of the dvt:graphFootnote tag.

    3. If you want to provide specific font characteristics for the text, then in the Structure window, right-click the dvt:graphFootnote node and choose Insert inside dvt:graphFootnote > Font.

    4. Use the Property Inspector to specify values for the attributes of the dvt:graphFont tag.

24.6.6 Customizing Graph Axes and Labels

Graphs can have the following axes:

  • Ordinal axis (also known as the o1-axis): The ordinal (or category) axis of a graph shows ordered data, such as ratings or stages, or shows nominal data, such as different cities or different products. The ordinal axis appears on bar, line, area, combination, or radar graphs. When the ordinal axis is horizontal and contains time data, it is called a time axis.

    An example of an ordinal axis is the horizontal line across the bottom of the plot area of a vertical bar graph. The values along this axis do not identify the extent of the data shown. Instead, they identify the different groups to which the data belongs.

  • x1-axis: The x1-axis shows the values that appear along the horizontal axis in a graph. This axis has regular intervals of numbers instead of group labels. It is referred to as the x-axis.

  • y1-axis: The y1-axis is the primary y-axis. It is usually the vertical value axis along the left side of the plot area. It has regular intervals of numbers.

  • y2-axis: The y2-axis is the secondary y-axis. It is usually the vertical axis along the right side of the plot area. It has regular intervals of numbers.

For each axis, there are several graph child tags that support customization. The following sections discuss the options available for various kinds of customization of an axis.

24.6.6.1 How to Specify the Title, Appearance, and Scaling of an Axis

The following graph child tags support customization of the title, and appearance of an axis:

  • Title: Specifies the text and alignment for an axis title. Includes the following tags: dvt:o1Title, dvt:x1Title, dvt:y1Title, and dvt:y2Title. An axis does not show a title unless you use the appropriate title tag.

  • Axis: Controls the color, line width, scaling, increment between tick marks, visibility of the axis, and scrolling in specific graph types. Includes the following tags: dvt:o1Axis, dvt:x1Axis, dvt:y1Axis, dvt:y2Axis.

    Note:

    Scaling attributes are not present on the dvt:o1Axis tag because the ordinal axis does not display numeric values.

To specify the title and appearance of an x1-axis:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > x1 Title.

  2. In the Property Inspector, enter the text for the axis title and optionally specify values for other attributes of this tag.

  3. If you want to specify font characteristics for the title, do the following:

    1. In the Structure window, right-click the dvt:x1Title node and choose Insert inside dvt:x1Title > Font.

    2. In the Property Inspector, enter the desired values for the characteristics of the font.

  4. Optionally, in the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > x1 Axis.

  5. In the Property Inspector, enter the desired values for the attributes of this tag.

The procedure for controlling the title and appearance of any graph axis is similar to the procedure for the x-axis. However, insert the title and axis tags related to the specific axis that you want to customize.

24.6.6.2 How to Specify Scrolling on an Axis

Scrolling on a graph axis can be specified for the following graph types:

  • Area, bar, and line graphs for the dvt:o1Axis, dvt:y1Axis, and dvt:y2Axis tags.

  • Bubble and scatter graphs for the dvt:x1Axis,dvt:y1Axis, and dvt:y2Axis tags.

By default, a graph axis scrolling attribute is set to off. You can specify these values for the scrolling attribute:

  • off: Scrolling is disabled (default).

  • on: Scrolling is enabled and the scroll bar is always present.

  • asNeeded: Scrolling is enabled, but the scrollbar is not initially present. After zooming on the graph, the scrollbar displays and remains visible for the session.

  • hidden: Scrolling is enabled but the scroll bar is always hidden. User may use pan scrolling.

24.6.6.3 How to Control the Appearance of Tick Marks and Labels on an Axis

Tick marks are used to indicate specific values along a scale on a graph. The following graph child tags support customization of the tick marks and their labels on an axis:

  • Major tick: Controls the color, width, and style of tick marks on the axis. Includes the following tags: dvt:o1MajorTick, dvt:x1MajorTick, dvt:y1MajorTick, and dvt:y2MajorTick. Major tick increments are calculated automatically by default, or you can specify the tick steps with the majorIncrement attribute.

  • Minor tick: Controls the color, width, and style of minor tick marks on the axis. Includes the following tags: dvt:x1MinorTick, dvt:y1MinorTick, and dvt:y2MinorTick. Minor tick increments are one-half of the major tick increment by default, or you can specify the tick steps with the minorIncrement attribute. Minor ticks do not support labels.

  • Tick label: Controls the rotation of major tick label text and lets you specify font characteristics for the label. Includes the following tags: dvt:o1TickLabel, dvt:x1TickLabel, dvt:y1TickLabel, and dvt:y2TickLabel. These tags can also have a dvt:graphFont child tag to change font characteristics of the label.

To control the appearance of the ordinal axis tick labels:

  1. In the visual editor, select the o1 Tick Label element on the graph.

    Alternatively, you can select the dvt:o1Axis element in the Structure window, then in the Property Inspector click the Configure o1Axis button and choose Value Labels.

  2. In the Property Inspector enter values as needed for the following properties:

    • TextRotation: Use to specify the degree of text rotation to improve readability of the tick labels.

      Note:

      Use rotation angles that are multiples of 90 degrees to achieve best results. For Flash image types, embedded fonts are required to support rotated text in non-90 degree angles, and embedded fonts are not available for all locales.

    • TickLabelSkipMode: Use to specify if and how tick labels will be displayed on the ordinal axis. When you set the value at TLS_MANUAL, you can optionally use the tickLabelSkipCount to set the number of tick labels to display between tick labels and tickLabelSkipFirst to set the index of the first tick label to be skipped.

  3. Optionally, in the Property Inspector, click the Configure Font button to set properties for the child dvt:graphFont tag.

To control the appearance of tick marks and labels on an x-axis:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > X1 Major Tick.

  2. In the Property Inspector, enter desired values for the attributes of this tag and click the Configure Tick Label button to add an X1 Tick Label tag to the graph.

  3. In the Property Inspector, enter desired values for the X1 Tick Label and if desired, click the Configure Font button to specify font characteristics for the tick label.

  4. If you want to specify minor ticks in the graph, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > X1 Minor Tick.

    2. In the Property Inspector, enter desired values for the characteristics of the font.

      Note:

      For the tickStyle attribute you must specify a value other than GS_NONE or GS_AUTOMATIC.

The procedure for controlling the appearance of tick marks on any graph axis is similar to the procedure for the x-axis. However, you customize the major tick and label tags and insert the minor ticks related to the specific axis that you want to customize.

24.6.6.4 How to Format Numbers on an Axis

The dvt:markerText tag lets you to control the format of numbers on an axis. The following dvt:markerText child tags wrap the number format for specific axes: dvt:x1Format, dvt:y1Format, and dvt:y2Format.

To format numbers on these axes, insert child tags for the appropriate axis as shown in Section 24.6.2, "Formatting Data Values in Graphs."

24.6.6.5 How to Set Minimum and Maximum Values on a Data Axis

The Y-axes have the following graph child tags to support the starting value of the axis: dvt:y1Axis, and dvt:y2Axis. You have the option of specifying different scaling on each y-axis in a dual y-axis graph. For example, the y1-axis might represent units in hundreds while the y2-axis might represent sales in thousands of dollars.

Some graphs, such as scatter and bubble graphs, contain a dvt:x1Axis child tag for which the minimum and maximum values can also be set.

To specify the starting value on a y1-axis:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > y1 Axis.

  2. In the Property Inspector, for the AxisMinValue field, enter the starting value for the y1-axis.

  3. In the AxisMinAutoScaled field, select false from the attribute dropdown list.

    You must set this attribute in order for the minimum value to be honored.

To establish the starting value on a y2-axis, use a similar procedure, but insert the dvt:y2Axis tag as a child of the graph.

24.6.7 Customizing Graph Legends

Graph components provide child tags for the following kinds of customization for the legend:

  • Specifying the color, border, visibility, positioning, and scrollability of the legend area relative to the graph, dvt:legendArea tag

  • Specifying the font characteristics and positioning of the text that is related to each colored entry in the legend, dvt:legendText tag

  • Specifying an optional title and font characteristics for the legend area, dvt:legendTitle tag

To customize the legend area, legend text, and title:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Legend Area.

  2. Use the Property Inspector to specify values for the attributes of this tag. For example, you can specify the following attributes for the legend area:

    • AutomaticPlacement and Position: Specify automatic positioning of the legend area on the right or the bottom of the graph with the default value of AP_ALWAYS. Setting the value at AP_NEVER requires the value of the position attribute to be used for positioning of the legend area.

    • Scrolling: Specify scrolling in the legend area when required space exceeds available space using the value asNeeded. By default the value is set to off.

    • PositionHint: Specify the alignment of the legend toward the center of the plot area using the value alignToCenter. By default the value is set to alignToEdge which aligns the legend toward the edge of the graph frame.

  3. If you want to customize the legend text, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Legend Text.

    2. Use the Property Inspector to enter values for the attributes of this tag.

    3. Right-click the dvt:legendText node and choose Insert inside dvt:legendText > Font.

    4. Use the Property Inspector to specify values for the attributes of the font tag.

  4. If you want to enter a title for the legend, do the following:

    1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization, then Legend Title.

    2. Use the Property Inspector to enter values for the attributes of this tag.

    3. Right-click the dvt:legendTitle node and choose Insert inside dvt:legendTitle > Font.

    4. Use the Property Inspector to specify values for the attributes of the font tag.

24.6.8 Customizing Tooltips in Graphs

Tooltips are useful to display identification or detail information for data markers. They can be very useful in smaller graphs without enough space to display markerText. Graphs automatically displays tooltips for components like title, subtitle, footnote, legend text, and annotations when their text is truncated.

In most graphs, if you move the cursor over a data marker, then a tooltip is displayed. In a line or area graph, you must move the cursor over a data marker or at the corners of the line or area and not merely over the line or area.

You can specify that each graph marker (such as bars) displays a tooltip with information. The following graph attributes are used together to customize a graph tooltip:

  • MarkerTooltipType: Specifies whether tooltips are displayed for markers (such as bars) and identifies the kind of information that appears in the tooltips. You have the option to display the following information: text only, values only, or text and values. For specific graph types, options include displaying cumulative data value for each stacked graph marker or displaying percentage data value for each pie slice marker.

  • SeriesTooltipLabel: Specifies whether tooltips are displayed for each set of values that appear in a legend. This attribute also controls the kind of information that appears in a series tooltip. For example, you could choose to display text that identifies a general term for the entire series (such as Product) or a specific term for a given member of the series (such as a specific Product name).

    Note:

    The graph displays series tooltip labels only if the graph's markerTooltipType attribute has a setting that includes text.

  • GroupTooltipLabelType: Specifies whether tooltip labels are displayed for data groups along an axis. For example, sales for specific products might be grouped by years or quarters. You can choose to display text that identifies a general term for the entire group (such as Time) or specific terms for each member of the group (such as Q1, Q2, Q3, or Q4 for quarters).

You can quickly format all the marker tooltips in a graph by setting the graph's markerTooltipTemplate attribute to a tokenized String. The attribute accepts a String that may contain any number of a set of predefined tokens. For example:

<dvt:lineGraph markerTooltipTemplate="Template Based Tooltip NEW_LINE SERIES_LABEL GROUP_LABEL NEW_LINE Value: Y_VALUE"/>

The list of supported tokens is described in Table 24-1.

Table 24-1 markerTooltipTemplate String Tokens

Token Description

NEW_LINE

Inserts a new line.

SERIES_LABEL

The series label for the series of this marker.

GROUP_LABEL

The group label for the group of this marker.

X_VALUE

The X value of a scatter or bubble marker or continuous time axis marker.

Y_VALUE

The Y value of this marker (if this marker has a Y value).

Z_VALUE

The Z value (bubble size) of a bubble marker.

PIE_VALUE

The value of a pie slice.

PIE_PERCENT

The pie slice percentage value.

ACTUAL_VALUE

The actual value for a funnel slice.

TARGET_VALUE

The target value for a funnel slice.

HIGH_VALUE

The high value for a stock marker.

LOW_VALUE

The low value for a stock marker.

CLOSE_VALUE

The close value for a stock marker.

OPEN_VALUE

The open value for a stock marker.

VOLUME_VALUE

The volume value for a stock volume marker.

CUM_VALUE

The cumulative stacked value for a stacked graph.

CUM_PERCENT

The cumulative percentage value for a stacked percent graph or Pareto graph.


You can use the graph's customToolTipCallback attribute to specify tooltips that vary on an object by object basis. For example:

<dvt:graph id="g2" customToolTipCallback="#{customToolTipCallback.callback}"

24.7 Customizing the Appearance of Specific Graph Types

The graph components support more than 50 graph types. Some of the graph attributes and several child tags relate only to specific graph types.

24.7.1 Changing the Appearance of Pie Graphs

You can customize the appearance of pie graphs and you can specify that you want one slice of a pie to be separated from the other slices in the pie.

24.7.1.1 How to Customize the Overall Appearance of Pie Graphs

You can customize the appearance of a pie graph by inserting any of the following child tags within the graph tag:

  • dvt:pieFeeler tag: Specifies the color of a line, called a pie feeler, that extends from a pie slice to a slice label.

  • dvt:slice tag: Specifies the location of a label for a pie slice.

  • dvt:sliceLabel tag: Specifies the characteristics of the labels that describe each slice of a pie or ring graph. Each slice represents a data value. Use the textType attribute of this tag to indicate whether the slice label should show text only, value only, percent only, or text and percent. If you want to format numbers or specify font characteristics, you can add the following tags as a child to the dvt:sliceLabel tag: dvt:graphFont and af:convertNumber.

24.7.1.2 How to Customize an Exploding Pie Slice

When one slice is separated from the other slices in a pie, this display is referred to as an exploding pie slice. The reason for separating one slice is to highlight that slice possibly as having the highest value of the quantity being measured in the graph.

The slices of a pie graph are the sets of data that are represented in the graph legend. As such, the slices are the series items of a pie graph.

Before you begin:

Follow the procedure in Section 24.6.1.1, "How to Specify the Color and Style for Individual Series Items" to create a series set that wraps individual series items.

To customize one slice in a pie graph:

  1. Follow the procedure in Section 24.6.1.1, "How to Specify the Color and Style for Individual Series Items" to create a series set that wraps individual series items.

  2. To separate one slice in a pie graph, in the Property Inspector, for the series tag that represents the pie slice that you want to separate from the pie, set the PieSliceExplode attribute between 0 to 100, where 100 is the maximum exploded distance available.

  3. To animate the slices in a pie graph, in the Property Inspector, set the InteractiveSliceBehavior attribute on the dvt:pieGraph tag. Valid values are any combination of the following:

    • none: No interactive slice behavior enabled.

    • explode: User can click to explode the slices in a pie graph.

    • explodeAll: Add Explode All and Unite All options to a context menu.

    For example, you can specify that users can explode the slices in a pie graph, and use a context menu to explode or collapse all the slices in the graph in the code:

    <dvt:pieGraph interactiveSliceBehavior="explode explodeAll"/>
    

Note:

The interactiveSliceBehavior attribute is only available in a Flash image format, while the pieSliceExplode attribute is available in all image formats.

24.7.2 Changing the Appearance of Lines in Graphs

You can use attributes of the dvt:seriesSet child of a graph tag to change the appearance of lines in graphs.

24.7.2.1 How to Display Either Data Lines or Markers in Graphs

You have the option of displaying data lines or data markers in a line, combination, or radar graph. If you display markers rather than data lines, then the markers appear in the legend automatically.

In the Property Inspector, set the following attributes of the dvt:seriesSet tag to display data lines or data markers:

  • LineDisplayed: Specifies whether data lines appear in the graph. You can set these values:

    • True indicates that data lines are displayed in the graph.

    • False indicates that markers are displayed in the graph rather than data lines.

  • MarkerDisplayed: Specifies whether markers or data lines appear in graph. You can set these values:

    • True indicates that markers are displayed in a graph.

    • False indicates that data lines are displayed in a graph.

Note:

Do not set both the lineDisplayed attribute and the markerDisplayed attribute to False.

24.7.2.2 How to Change the Appearance of Lines in a Graph Series

You can customize the appearance of lines by using the dvt:seriesSet tag and the dvt:series tag as described in the following list:

  • On the dvt:seriesSet tag, you can affect all the dvt:series tags within that set by specifying values for the following attributes:

    • defaultMarkerShape: Used only for line, scatter, and combination graphs. Identifies a default marker shape for all the series in the series set.

    • defaultMarkerType: Used only for combination graphs. Valid values include MT_AREA, MT_BAR, MT_MARKER, and MT_DEFAULT.

  • On the dvt:series tag, you can specify settings for each individual series using the following line attributes:

    • lineWidth: Specifies the width of a line in pixels

    • lineStyle: Specifies whether you want the graph to use solid lines, dotted lines, dashed lines, or dash-dot combination lines.

See the procedures in Section 24.6.1.1, "How to Specify the Color and Style for Individual Series Items" for more information about using the dvt:seriesSet tag and the dvt:series tag.

24.7.3 Customizing Pareto Graphs

A Pareto graph identifies the sources of defects using a series of bars. The bars are arranged by value, from the greatest to the lowest number. The Pareto line shows the percentage of cumulative values of the bars, to the total values of all the bars in the graph. The line always ends at 100 percent.

You can customize the Pareto line and the Pareto marker by using the following graph child tags:

  • dvt:paretoLine tag: Lets you specify the color, line width, and line style (such as solid, dashed, dotted, or a combination of dash-dot).

  • dvt:paretoMarker tag: Lets you specify the shape of the Pareto markers.

To customize a Pareto graph:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Pareto Line.

  2. In the Property Inspector, specify values for the attributes of this tag.

  3. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Pareto Marker.

  4. In the Property Inspector, select a value for the markerShape attribute.

24.7.4 Customizing Scatter Graph Series Markers

In scatter graphs, related data values in a series are represented by the data marker's shape and color. You can separate marker shape and color from the series to display the interdependence of data values.

For example, Figure 24-9 shows a scatter graph that uses City and Product attributes collectively to determine the series represented by the data marker's shape and color.

Figure 24-9 Scatter Graph with Series Marker

Scatter graph with single series.

The row header attributes can be used to override the default series specification. Figure 24-10 shows a scatter graph that displays the data values for the City attribute mapped to shapes and the Product attribute mapped to colors.

Figure 24-10 Scatter Graph with Series Item Markers

Scatter graph with separate series items

Use the following attributes to customize the scatter graph series markers:

  • markerShape - Specifies the row header attribute name to use to set the marker color. The graph will display the default index based series marker colors if this attribute is not specified.

  • markerColor - Specifies the row header attribute name to use to set the marker shape. The graph will display the default index based series marker shapes if this attribute is not specified.

For example, specify City and Product as separate series item markers using this code:

<dvt:scatterGraph markerColor="Product" markerShape="City" value="#{bindings.View1.graphModel}"/>

24.8 Adding Specialized Features to Graphs

There are graph customization features that include the ability to define series-related reference lines and axis-related reference areas, the option of adding gradient special effects to several parts of a graph, the option of setting some parts of a graph to transparent colors, and the use of alerts and annotations in graphs. These special features also let you use interactive capabilities of the graph.

24.8.1 Adding Reference Lines or Areas to Graphs

Reference lines and areas can be set to display always, on rollover only, or never, regardless of how many there are and whether they are associated with a series or an axis.

You can create reference lines that are associated with a series (that is a set of data values that appears as a single color in the graph legend). If there are multiple series with reference lines, then the reference lines show only when you move the cursor over a series marker or the corresponding series legend item. This is because multiple reference lines can be confusing to users.

You can also create reference areas that are associated with an axis. Typically, these areas are associated with a y-axis. If there are multiple reference areas, then these areas are also displayed when you move the cursor over the related axis.

If your application does not know how many reference lines or areas it will need until it is running, then you can create reference lines or areas dynamically at runtime.

24.8.1.1 How to Create Reference Lines or Areas During Design

Both reference lines and reference areas are created by the use of the following tags:

  • dvt:referenceObjectSet: Wraps all the reference object tags for reference lines or reference areas for this graph.

  • dvt:referenceObject: Identifies whether the tag represents a reference line or a reference area and specifies characteristics for the tag.

To add reference lines or areas to a graph during design:

  1. In the Structure window, right-click the graph node and choose Insert inside dvt:<type>Graph > ADF Data Visualization > Reference Object Set.

  2. If you are defining reference areas related to specific axes, then specify a value for the appropriate axis or axes attributes: displayX1, displayY1, or displayY2.

    The value RO_DISPLAY_AUTOMATIC enables the display of a reference area only when the mouse moves over the related axis. This choice prevents the confusion that might occur if multiple reference areas were displayed all the time.

    Optionally, you can apply a gradient special effect to the reference area. For more information see Section 24.8.2.1, "How to Add Gradient Special Effects to a Graph."

  3. In the Structure window, right-click the dvt:referenceObjectSet node and choose Insert inside dvt:referenceObjectSet > Reference Object.

  4. In the Property Inspector, do the following:

    1. In the Common attributes category, specify values for the index attribute of the reference object, the type attribute of the reference object (RO_LINE or RO_AREA), the associated object in the association attribute (a series for a reference line or a specific axis for a reference area). Also specify if the object should be displayed in the legend using the displayedInLegend attribute, and specify the text, if any, to display in the legend.

    2. If you are creating a reference line, then specify values for the attributes related to the line. This includes specifying the series number of the series to which the line is related. The series number refers to the sequence in which the series appear in the Graph data binding dialog.

    3. If you are creating a reference area, then specify the low value and the high value that represent the reference area on the specified axis.

  5. In the Structure window, right-click the graph node and choose Go To Properties.

  6. In the Property Inspector, select the Appearance attributes category and do the following to control the display of reference lines and reference areas:

    1. If you have defined reference lines (which must be related to a series), then expand the dvt:series node and specify a value for the behavior of the displaySeries attribute.

      The value RO_DISPLAY_AUTOMATIC enables the display of a reference line only when the cursor moves over a series item (such as a bar) or over the corresponding series entry in the graph legend. This choice prevents the confusion that might occur if multiple series reference lines were displayed all the time.

    2. If you have defined reference areas (which must be related to specific axes), then associate the reference object with the appropriate axis or axes.

24.8.1.2 What Happens When You Create Reference Lines or Areas During Design

When you create reference lines or areas during design, XML code is generated within the graph XML on the JSF page. The reference objects (both lines and areas) are wrapped by the dvt:referenceObjectSet tags. Example 24-8 shows the code for three reference areas associated with the y1-axis, one reference area associated with the y2-axis, and four reference lines associated with different series.

Example 24-8 XML Code for Reference Lines and Areas in a Graph

<dvt:barGraph value ="#{sampleGraph.graphDataModel}" graphType="BAR_VERT_CLUST2Y"
     imageFormat="FLASH">
  <dvt:referenceObjectSet
     displayX1="RO_DISPLAY_AUTOMATIC" 
     displayY2="RO_DISPLAY_AUTOMATIC" 
    <dvt:referenceObject index="1" type="RO_AREA" association="Y1AXIS" 
     location="RO_BACK" color="#55FF0000" lowValue="0" highValue="4000"
     displayedInLegend="true" text="Low"/>
    <dvt:referenceObject index="2" type="RO_AREA" association="Y1AXIS" 
      location="RO_BACK" color="#55FFFF00"  lowValue="4000" highValue="10000"
      displayedInLegend="true" text="Medium"/>
    <dvt:referenceObject index="3" type="RO_AREA" association="Y1AXIS" 
      location="RO_BACK" color="#5500FF00"  lowValue="10000" highValue="18000"
      displayedInLegend="true" text="High"/>
    <dvt:referenceObject index="4" type="RO_AREA" association="Y2AXIS" 
      location="RO_FRONT" color="#550000FF" lowValue="300" highValue="700"/>
    <dvt:referenceObject index="5" type="RO_LINE" association="SERIES" series="0" 
      location="RO_FRONT" color="#ffff66" lineValue="5000" lineWidth="3" 
      lineStyle="LS_SOLID"/>
    <dvt:referenceObject index="6" type="RO_LINE" association="SERIES" series="0" 
      location="RO_FRONT" color="#ffff66" lineValue="16730" lineWidth="3"
      lineStyle="LS_SOLID"/>
    <dvt:referenceObject index="7" type="RO_LINE" association="SERIES" series="1" 
      location="RO_BACK" color="#99cc66" lineValue="500" lineWidth="3"
      lineStyle="LS_SOLID"/>
    <dvt:referenceObject index="8" type="RO_LINE" association="SERIES" series="1" 
      location="RO_BACK" color="#99cc66" lineValue="1711" lineWidth="3"
      lineStyle="LS_SOLID"/>
  </dvt:referenceObjectSet>
</dvt:barGraph>

24.8.1.3 How to Create Reference Lines or Areas Dynamically

If you want to create reference objects dynamically at runtime, then you use only the dvt:referenceObjectSet tag. You set the referenceObjectMap attribute on this tag with a method reference to the code that creates a map of the child component reference objects. The method that creates this map must be stored in a managed bean.

To create reference lines or areas dynamically:

  1. Write a method that creates a map of the child component reference objects that you want to create during runtime. Example 24-9 shows sample code for creating this method.

  2. In the Structure window, right-click the graph node, then choose Insert inside dvt:<type>Graph > ADF Data Visualization > Reference Object Set.

  3. In the Property Inspector, specify in the referenceObjectMap attribute a method reference to the code that creates the map of child component reference objects.

    For example, for the managed bean (sampleGraph) and the method getReferenceObjectMapList, the attribute should be set to the following value: referenceObjectMap="#{sampleGraph.referenceObjectMapList}"

Example 24-9 Code for a Map of Child Reference Objects

Managed bean SampleGraph.java : 
   public Map getReferenceObjectMapList() { 
     HashMap map = new HashMap(); 
     ReferenceObject referenceObject = new ReferenceObject(); 
     referenceObject.setIndex(1); 
     referenceObject.setColor(Color.red); 
     referenceObject.setLineValue(30); 
     referenceObject.setLineWidth(3); 
     map.put(new Integer(1), referenceObject); 
     return map;
    } 

24.8.2 Using Gradient Special Effects in Graphs

A gradient is a special effect in which an object changes color gradually. Each color in a gradient is represented by a stop. The first stop is stop 0, the second is stop 1, and so on. You can specify any number of stops in the special effects for a subcomponent of a graph that supports special effects.

You can define gradient special effects for the following subcomponents of a graph:

  • Graph background: Use the dvt:background tag.

  • Graph plot area: Use the dvt:graphPlotArea tag.

  • Graph pie frame: Use the dvt:graphPieFrame tag.

  • Legend area: Use the dvt:legendArea tag.

  • Series: Use the dvt:series tag.

    Note:

    By default, a graph's series gradient is set in the seriesEffect attribute with a value of SE_AUTO_GRADIENT to make the data markers appear smoother and apply graphic antialiasing. You must set the attribute to SE_NONE in order to specify a custom series gradient.

  • Time selector: Use the dvt:timeSelector tag.

  • Reference area: Use the dvt:referenceObject tag.

The approach that you use to define gradient special effects is identical for each part of the graph that supports these effects.

24.8.2.1 How to Add Gradient Special Effects to a Graph

For each subcomponent of a graph to which you want to add special effects, you must insert a dvt:specialEffects tag as a child tag of the subcomponent. For example, if you want to add a gradient to the background of a graph, then you would create one dvt:specialEffects tag that is a child of the dvt:background tag.

Then, optionally if you want to control the rate of change for the fill color of the subcomponent, you would insert as many dvt:gradientStopStyle tags as you need to control the color and rate of change for the fill color of the component. These dvt:gradientStopStyle tags then must be inserted as child tags of the single dvt:specialEffects tag.

To add a gradient special effect to the background of a graph:

  1. In the Structure window, right-click the dvt:background node that is a child of the graph node, then choose Insert inside dvt:background, then Special Effects.

  2. Use the Property Inspector to enter values for the attributes of the dvt:specialEffects tag:

    1. For fillType attribute, choose FT_GRADIENT.

      For gradientDirection attribute, select the direction of change that you want to use for the gradient fill.

    2. For numStops attribute, enter the number of stops to use for the gradient.

  3. Optionally, in the Structure window, right-click the dvt:specialEffects node and choose Insert within dvt:specialEffects > dvt:gradientStopStyle if you want to control the color and rate of change for each gradient stop.

  4. Use the Property Inspector to enter values for the attributes of the dvt:gradientStopStyle tag:

    1. For the stopIndex attribute, enter a zero-based integer as an index within the dvt:gradientStopStyle tags that are included within the specialEffects tag.

    2. For the gradientStopColor attribute, enter the color that you want to use at this specific point along the gradient.

    3. For the gradientStopPosition attribute, enter the proportional distance along a gradient for the identified stop color. The gradient is scaled from 0 to 100. If 0 or 100 is not specified, default positions are used for those points.

  5. Repeat Step 3 and Step 4 for each gradient stop that you want to specify.

24.8.2.2 What Happens When You Add a Gradient Special Effect to a Graph

Example 24-10 shows the XML code that is generated when you add a gradient fill to the background of a graph and specify two stops.

Example 24-10 XML Code Generated for Adding a Gradient to the Background of a Graph

<dvt:graph >
  <dvt:background borderColor="#848284">
    <dvt:specialEffects fillType="FT_GRADIENT" gradientDirection="GD_RADIAL"
             gradientNumStops="2">
      <dvt:gradientStopStyle stopIndex="0" gradientStopPosition="60"
             gradientStopColor="FFFFCC"/>
      <dvt:gradientStopStyle stopIndex="1" gradientStopPosition="90"
             gradientStopColor="FFFF99"/>
    </dvt:specialEffects> 
  </dvt:background>
</dvt:graph>

24.8.3 Specifying Transparent Colors for Parts of a Graph

You can specify that various parts of a graph show transparent colors by setting the borderTransparent and fillTransparent attributes on the graph child tags related to these parts of the graph. The following list identifies the parts of the graph that support transparency:

  • Graph background: Use the dvt:background tag. By default the fillTransparent attribute is set to true.

  • Graph legend area: Use the dvt:legendArea tag.

  • Graph pie frame: Use the dvt:graphPieFrame tag.

  • Graph plot area: Use the dvt:graphPlotArea tag.

24.8.4 Adding Context Menus to Graphs

Graphs support right-click context menus using facets for any of three types:

  • Context menus displayed on any non selectable area within the component, for example, the plot area

  • Context menus displayed on any selectable element, for example, the marker in a scatter graph

  • Context menus displayed on multiple selectable elements

24.8.4.1 How to Configure Graph Context Menus

Context menus can be defined for graph components using these context menu facets:

  • bodyContextMenu: Specifies a context menu that is displayed on non selectable elements in the graph component.

  • contextMenu: Specifies a context menu that is displayed on any selectable element in the graph component.

  • multiSelectContextMenu: Specifies a content menu that is displayed when multiple elements are selected in the graph component.

Each facet supports a single child component. For all of these facets to work, selection must be enabled and supported for the specific graph type. Context menus are currently only supported in Flash.

Due to technical limitations when using the Flash rendering format, context menu contents are currently displayed using the Flash Player's context menu. This imposes several limitations defined by the Flash Player. For more information, see Section 24.8.4.2, "What You May Need to Know About Flash Rendering Format."

For example, Figure 24-11 shows a scatter graph context menu with custom menu items.

Figure 24-11 Scatter Graph Custom Context Menu

Scatter Graph Custom Context Menu

Example 24-11 shows a code sample for configuring a scatter graph context menu.

Example 24-11 Code Sample for Scatter Graph Context Menu

<dvt:scatterGraph binding="#{contextMenu.graph}" subType="SCATTER"
                  dataSelection="multiple" id="graph" shortDesc="ScatterGraph">
  <f:facet name="contextMenu">
    <af:popup contentDelivery="lazyUncached" id="p1">
      <af:menu id="m1">
        <af:commandMenuItem text="Show Details"
                            actionListener="#{contextMenu.menuItemListener}"
                            id="cmi1"/>
        <af:group id="g1">
          <af:commandMenuItem text="Add Task for #{contextMenu.currentSeriesId}"
                              actionListener="#{contextMenu.menuItemListener}"
                              id="cmi2"/>
          <af:commandMenuItem text="Add Task"
                              actionListener="#{contextMenu.menuItemListener}"
                              id="cmi3"/>
          <af:commandMenuItem text="Add Notes"
                              actionListener="#{contextMenu.menuItemListener}"
                              id="cmi4"/>
        </af:group>
      </af:menu>
    </af:popup>
  </f:facet>
  <f:facet name="bodyContextMenu">
    <af:popup contentDelivery="immediate" id="p2">
      <af:menu id="m2">
        <af:goMenuItem text="www.oracle.com"
                       destination="http://www.oracle.com"
                       id="gmi1"/>
      </af:menu>
    </af:popup>
  </f:facet>
  <f:facet name="multiSelectContextMenu">
    <af:popup contentDelivery="lazyUncached" id="p3">
      <af:menu id="m3">
        <af:commandMenuItem text="Compare Selected Objects"
                            actionListener="#{contextMenu.menuItemListener}"
                            id="cmi5"/>
      </af:menu>
    </af:popup>
  </f:facet>
</dvt:scatterGraph>

Example 24-12 shows a code sample for a managed bean to create a custom context menu. For help with managed beans, see Section 2.6, "Creating and Using Managed Beans."

Example 24-12 Managed Bean to Create Custom Context Menu

import java.util.Set;
import javax.faces.component.UIComponent;
import javax.faces.event.ActionEvent;
import oracle.adf.view.faces.bi.component.graph.DataSelection;
import oracle.adf.view.faces.bi.component.graph.GraphSelection;
import oracle.adf.view.faces.bi.component.graph.UIGraph;
import oracle.adf.view.faces.bi.model.KeyMap;
import oracle.adf.view.rich.component.rich.nav.RichCommandMenuItem;
import oracle.adf.view.rich.component.rich.output.RichOutputFormatted;
import org.apache.myfaces.trinidad.context.RequestContext;

public class ContextMenu {
  private RichOutputFormatted m_outputFormatted;
  public RichOutputFormatted getOutputFormatted() {
    if(m_outputFormatted == null)
      m_outputFormatted = new RichOutputFormatted();
    return m_outputFormatted;
  }
  public void setOutputFormatted(RichOutputFormatted text) {
    m_outputFormatted = text;
  }
  private String m_status = "Click Menu Item for Status";
  public String getStatus() {
    return m_status;
  }
  private UIGraph m_graph;
  public UIGraph getGraph() {
    if(m_graph == null)
      m_graph = new UIGraph();
    return m_graph;
  }
  public void setGraph(UIGraph graph) {
    m_graph = graph;
  } 
  public String getCurrentSeriesId() {
    if(m_graph != null) {
      Set<? extends GraphSelection> set = m_graph.getSelection();
      if(set != null && !set.isEmpty()) {
        GraphSelection selection = set.iterator().next();
        if(selection instanceof DataSelection) {
          DataSelection dataSelection = (DataSelection) selection;
          KeyMap seriesKey = dataSelection.getSeriesKey();
          Set seriesKeySet = seriesKey.keySet();
          for(Object key : seriesKeySet) {
            return seriesKey.get((String)key);
          }
        }
      }
    }
    return null;
  }
  /**
   * Called when a commandMenuItem is clicked.  Updates the outputText with information about the menu item clicked.
   * @param actionEvent
   */
  public void menuItemListener(ActionEvent actionEvent) {
    UIComponent component = actionEvent.getComponent();
    if(component instanceof RichCommandMenuItem) {
      RichCommandMenuItem cmi = (RichCommandMenuItem) component;
      // Add the text of the item into the status message
      StringBuilder s = new StringBuilder();
      s.append("You clicked on \"").append(cmi.getText()).append("\".  <br><br>");
      // If graph data is selected, add that too
      Set<? extends GraphSelection> selectionSet = m_graph.getSelection();
      if(!selectionSet.isEmpty()) {
        // Write out the selection state
        s.append("The current graph selection is: <br>");
        s.append(SelectionSample.convertSelectionStateToString(selectionSet));
      }
      m_status = s.toString();
      RequestContext.getCurrentInstance().addPartialTarget(m_outputFormatted);
    }
  }
}

The managed bean in the preceding example calls the SelectionSample class which is displayed in Example 24-13. Store the code for this class in an additional managed bean.

Example 24-13 Managed Bean for Custom Context Menu SelectionSample Class

import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import javax.faces.model.SelectItem;
import oracle.adf.view.faces.bi.component.graph.DataSelection;
import oracle.adf.view.faces.bi.component.graph.GraphSelection;
import oracle.adf.view.faces.bi.event.graph.SelectionEvent;
import oracle.adf.view.faces.bi.model.KeyMap;
public class SelectionSample {
  public void selectionListener(SelectionEvent selectionEvent) {
    StringBuilder eventInfo = new StringBuilder();
    Set<? extends GraphSelection> selectionSet = 
                           selectionEvent.getGraphSelection();
    eventInfo.append(convertSelectionStateToString(selectionSet));
    // Store on the selection string
    m_selectionInfo = eventInfo.toString();
  }
  /**
   * Returns selection state formatted with one selected data point per line.
   * @param selectionSet
   * @return
   */
  public static String convertSelectionStateToString 
                       (Set<? extends GraphSelection> selectionSet) {
    StringBuilder selectionState = new StringBuilder();
    for(GraphSelection selection: selectionSet) {
      if(selection instanceof DataSelection) {
        DataSelection ds = (DataSelection) selection;
        Set seriesKeySet = ds.getSeriesKey().keySet();
        for(Object key : seriesKeySet) {
          selectionState.append(key).append(": ").
                                 append(ds.getSeriesKey().get((String)key));
        }
        List<KeyMap> groupKeys = ds.getGroupKeys();
        for(KeyMap groupKey : groupKeys) {
          Set groupKeySet = groupKey.keySet();
          for(Object key : groupKeySet) {
            selectionState.append("; ").append(key).append(": ").
                                        append(groupKey.get((String)key));
          }
        }
        selectionState.append("<br>");
      }
    }
    return selectionState.toString();
  }
  private String m_selectionInfo = "Select a marker to see information here.";
  public String getSelectionInfo() {
    return m_selectionInfo;
  }
  private String graphType = "bubbleGraph";
  public String getGraphType() {
      return graphType;
  }
  public void setGraphType(String type) {
      graphType = type;
  }
  private List graphList;
  public List getGraphList() {
      graphList = new ArrayList();
      SelectItem graph = new SelectItem("bubbleGraph", "Bubble Graph");
      graphList.add(graph);
      graph = new SelectItem("scatterGraph", "Scatter Graph");
      graphList.add(graph);
      return graphList;
  }
}

24.8.4.2 What You May Need to Know About Flash Rendering Format

Due to technical limitations when using the Flash rendering format, context menu contents are currently displayed using the Flash Player's context menu. This imposes several limitations defined by the Flash Player:

  • Flash does not allow for submenus it its context menu.

  • Flash limits custom menu items to 15. Any built-in menu items for the component, for example, a pie graph interactiveSliceBehavior menu item, will count towards the limit,

  • Flash limits menu items to text-only. Icons or other controls possible in ADF Faces menus are not possible in Flash menus.

  • Each menu caption must contain at least one visible character. Control characters, new lines, and other white space characters are ignored. No caption can be more than 100 characters long.

  • Menu captions that are identical to another custom item are ignored, whether the matching item is visible or not. Menu captions are compared to built-in captions or existing custom captions without regard to case, punctuation, or white space.

  • The following captions are not allowed, although the words may be used in conjunction with other words to form a custom caption: Save, Zoom In, Zoom Out, 100%, Show All, Quality, Play, Loop, Rewind, Forward, Back, Movie not loaded, About, Print, Show Redraw Regions, Debugger, Undo, Cut, Copy, Paste, Delete, Select All, Open, Open in new window, and Copy link.

  • None of the following words can appear in a custom caption on their own or in conjunction with other words: Adobe, Macromedia, Flash Player, or Settings.

Additionally, since the request from Flash for context menu items is a synchronous call, a server request to evaluate EL is not possible when the context menu is invoked. To provide context menus that vary by selected object, the menus will be pre-fetched if the context menu popup uses the setting contentDelivery="lazyUncached". For context menus that may vary by state, this means that any EL expressions within the menu definition will be called repeatedly at render time, with different selection and currency states. When using these context menus that are pre-fetched, the application must be aware of the following:

  • Long running or slow code should not be executed in any EL expression that may be used to determine how the context menu is displayed. This does not apply to af:commandMenuItem attributes that are called after a menu item is selected, such as actionListener.

  • In the future, if the Flash limitations are solved, the ADF context menu may be displayed in place of the Flash context menu. To ensure upgrade compatibility, you should code such that an EL expression will function both in cases where the menu is pre-fetched, and also where the EL expression is evaluated when the menu is invoked. The only component state that applications should rely on are selection and currency.

24.8.5 Providing Interactive Capability for Graphs

You can add a number of interactive functions to graphs including:

  • Marker and legend dimming

    Markers include lines, bars, areas, scatter markers, bubbles, and pie slices.

  • Zooming and scrolling

  • Changing zoom and scroll levels

24.8.5.1 How to Provide Marker and Legend Dimming

You can force all the data markers for a given set of data to be highlighted when you move the cursor over one data marker in the set or over the corresponding entry in the graph legend. The highlighting effect is visually achieved by dimming the other data markers in the set. For example, if a bar graph displays sales by month for four products (P1, P2, P3, P4), when you move the cursor over product P2 in January, all the P2 bars are highlighted, and the P1, P3, and P4 bars are dimmed.

Because the graph refers to all the data markers in a given set of data (such as all the P2 bars) as a series, then the ability to highlight the data markers in a series is part of the graph's series rollover behavior feature.

Series rollover behavior is available only in the following graph types: bar, line, area, pie, scatter, polar, radar, and bubble graphs.

To dim all the data markers in a series:

  1. In the Structure window, right-click the graph node and choose Go to Properties.

  2. In the Appearance attributes category, in the SeriesRolloverBehavior field, use the dropdown list to select RB_DIM.

24.8.5.2 How to React to Changes in the Zoom and Scroll Levels

You can provide custom code that will be executed when the zoom and scroll levels change on a graph. In a managed bean you store methods that takes as input a ZoomEvent or ScrollEvent. With these events, users can determine which axis is zoomed, as well as the current extent of the zoomed axes.

To provide custom behavior in response to zooming and scrolling in a graph:

  1. In a managed bean, write a custom method that performs the desired behavior when a zoom or scroll event is triggered. Example 24-14 shows sample code for creating this method.

  2. In the Structure window, right-click the graph node and choose Go to Properties.

  3. Select the Behavior attributes category and expand the Advanced node and do one or both of the following:

    • In the zoomlListener field, specify a reference to the method that you stored in the managed bean.

      For example, if the method setZoom is stored in the managed bean SampleGraph, then the setting becomes: "#{sampleGraph.zoom)".

    • In the scrollListener field, specify a reference to the method that you stored in the managed bean.

      For example, if the method setScroll is stored in the managed bean SampleGraph, then the setting becomes: "#{sampleGraph.scroll)".

Example 24-14 Sample Code to Set Zoom and Scroll

Managed bean sampleGraph.java
public void setZoom(ZoomEvent event) {
        System.out.println("Start Group: " + event.getAxisStartGroup(ZoomEvent.O1AXIS));
        System.out.println("Group Count: " + event.getAxisGroupCount(ZoomEvent.O1AXIS));
        System.out.println("Start Group Label: " + event.getAxisStartGroupLabel(ZoomEvent.O1AXIS));
public void setScroll(ScrollEvent event) {
        System.out.println("End Group Label: " + event.getAxisEndGroupLabel(ScrollEvent.O1AXIS));
        System.out.println("Axis Min: " + 
event.getAxisMin(ScrollEvent.O1AXIS));
        System.out.println("Axis Max: " + 
event.getAxisMax(ScrollEvent.O1AXIS));

24.8.6 Providing an Interactive Time Axis for Graphs

You can define relative ranges and explicit ranges for the display of time data.

24.8.6.1 How to Define a Relative Range of Time Data for Display

You can define a simple relative range of time data to be displayed, such as the last seven days. This will force old data to scroll off the left edge of the graph as new data points are added to the display of an active data graph. Relative time range specifications are not limited to use in active data graphs.

To specify a relative range of time data for display:

  1. In the Structure window, right click the graph node and choose Go to Properties.

  2. In the Appearance attributes category, expand the dvt:timeAxis node and specify values for the following attributes:

    1. In the timeRangeMode attribute, specify the value TRM_RELATIVE_LAST or TRM_RELATIVE_FIRST depending on whether the relative range applies to the end of the time range (such as the last seven days) or to the beginning of the time range (such as the first seven days).

    2. In the timeRelativeRange attribute, specify the relative range in milliseconds.

24.8.6.2 How to Define an Explicit Range of Time Data for Display

You can define an explicit range of time data to be displayed, such as the period between March 15 and March 25. In this example, the year, hour, minute, and second use default values because they were not stated in the start and end values.

To specify an explicit range of time data for display:

  1. In the Structure window, right click the graph node and choose Go to Properties.

  2. In the Appearance attributes category, specify the values for the following attributes:

    1. In the timeRangeMode attribute, specify the value TRM_EXPLICIT.

    2. In the timeRangeStart attribute, enter the initial date for the time range.

    3. In the timeRangeEnd attribute, enter the ending date for the time range.

24.8.7 Adding Alerts and Annotations to Graphs

Alerts define a data value on a graph that must be highlighted with a separate symbol, such as an error or warning. An icon marks the location of the alert. When the cursor moves over the alert icon, the text of that alert is displayed. An unlimited number of alerts can be defined for a graph using dvt:alert tags. The alerts are wrapped in a dvt:alertSet tag, that is a child of graph tag. Example 24-15 shows a set of alerts for an area graph.

Example 24-15 Sample Code for Set of Graph Alerts

<dvt:areaGraph>
  <dvt:alertSet>
    <dvt:alert xValue="Boston" yValue="3.50" yValueAssignment="Y1AXIS"
         imageSource="myWarning.gif"/>
    <dvt:alert xValue="Boston" yValue="5.50" yValueAssignment="Y1AXIS"
          imageSource="myError.gif"/> 
  </dvt:alertSet>
</dvt:areaGraph>

Annotations are associated with a data value on a graph to provide information when the cursor moves over the data value. An unlimited number of annotations can be defined for a graph using dvt:annotation tags and multiple annotations can be associated with a single data value. The annotations are wrapped in a dvt:annotationSet tag that is a child of the graph tag.

The data marker associated with the annotation is defined using these attributes of the dvt:annotation tag:

  • series - Specifies the zero-based index of a series in a graph. In most graphs, each series appears as a set of markers that are the same color. For example, in a multiple pie graph, each yellow slice might represent sales of shoes, while each green slice represents the sales of boots. In a bar graph, all of the yellow bars might represent the sales of shoes, and the green bars might represent the sales of boots.

  • group - Specifies the zero-based index of a group in a graph. Groups appear differently in different graph types. In a clustered bar graph, each cluster of bars is a group. In a stacked bar graph, each stack is a group. In a multiple pie graph, each pie is a group.

Example 24-16 shows a set of annotations for an area graph.

Example 24-16 Sample Code for a Set of Annotations

<dvt:areaGraph> 
  <dvt:annotationSet>
    <dvt:annotation series="0" group="0" text="annotation #1"/>
    <dvt:annotation series="0" group="7" fillColor="#55FFFF00"
           borderColor="#55FF0000" text="second annotation"/>
  </dvt:annotationSet>
</dvt:areaGraph>

You can control the position of the annotation in the plot area of a graph using these attributes:

  • position - Specifies the type of positioning to use for the annotation. Valid values are:

    • dataValue (default) - Positions the annotation by the data value defined in the series and group attributes. Overlap with other annotations is avoided.

    • absolute - Positions the annotation at the exact point defined by the xValue and the yValue in graphs with both those axes. Overlap with other annotations is not avoided.

    • percentage - Positions the annotation at the exact point defined by using the xValue and yValue as a percentage between 0 and 100 of the plot area of graphs with both those axes. Overlap with other annotations is not avoided.

  • xValue - Specifies the X value at which to position the annotation. This setting only applies when the annotation position is absolute or percentage.

  • yValue - Specifies the Y value at which to position the annotation. This setting only applies when the annotation position is absolute or percentage.

  • horizontalAlignment - Specifies the horizontal positioning of the annotation. This setting only applies when the annotation position attribute is absolute or percentage. Valid values are LEFT (default), CENTER, LEADING, or RIGHT.

  • verticalAlignment - Specifies the vertical positioning of the annotation. This setting only applies when the annotation position attribute is absolute or percentage. Valid values are CENTER (default), TOP, or BOTTOM.

24.9 Animating Graphs

Graph components dvt:areaGraph, dvt:bubbleGraph, dvt:barGraph, dvt:lineGraph, dvt:comboGraph, dvt:pieGraph, and dvt:scatterGraph support animation effects such as slideshow transition for initial display of the graph component and for partial page refresh (PPR) events. Animation effects are specified in the graph's animationOnDisplay and animationOnDataChange properties with these values:

Animation effects can also be performed using active data. The Active Data Service (ADS) allows you to bind ADF Faces components to an active data source using the ADF model layer. To allow this, you must configure the components and the bindings so that the components can display the data as it is updated in the source. Alternatively, you can configure the application to poll the data source for changes at prescribed intervals.

24.9.1 How to Configure Graph Components to Display Active Data

To use the Active Data Service, you must have a data source that publishes events when data is changed, and you must create business services that react to those events and the associated data controls to represent those services. For more information about ADS and configuring your application, see the "Using the Active Data Service" chapter in the Oracle Fusion Middleware Fusion Developer's Guide for Oracle Application Development Framework.

Configure databound graphs to display active data by setting a value on the binding element in the corresponding page definition file.

To configure a graph to display active data:

  1. In the Structure window, select the graph node.

  2. In the Property Inspector, enter a unique value in the ID field.

    If you do not select an identifier, one will be entered for you.

  3. Open the page's associated page definition file.

  4. In the Structure window for the page definition file, select the node that represents the attribute binding for the component. In the Property Inspector, select Push for the ChangeEventPolicy attribute.

24.9.2 How to Specify Animation Effects for Graphs

In the Property Inspector for the graph you wish to animate, set the following attributes:

  • animationOnDisplay: Optional. Use with or without ADS to specify the type of initial rendering effect to apply. Valid values are:

    • none (default): Do not show any initial rendering effect.

    • auto: Apply an initial rendering effect automatically chosen based on graph or gauge type.

    • alphaFade

    • conveyorFromLeft or conveyorFromRight

    • cubeToLeft or cubeToRight

    • flipLeft or flipRight

    • slideToLeft or slideToRight

    • transitionToLeft or transitionToRight

    • zoom

  • animationOnDataChange: Use to specify the type of data change animation to apply. Valid values are:

    • none: Apply no data change animation effects.

    • activeData (default): Apply Active Data Service (ADS) data change animation events.

    • auto: Apply partial page refresh (PPR) and ADS data change animation events.

    • alphaFade

    • conveyorFromLeft or conveyorFromRight

    • cubeToLeft or cubeToRight

    • flipLeft or flipRight

    • slideToLeft or slideToRight

    • transitionToLeft or transitionToRight

    • zoom

  • animationDuration: Use to specify the animation duration in milliseconds.

  • animationIndicators: Use to specify the type of data change indicators to show. Valid values are:

    • none: Show no data change indicators.

    • all (default): Show all data change indicators.

  • animationUpColor: Use to specify the RGB hexadecimal color used to indicate that a data value has increased.

  • animationDownColor: Use to specify the RGB hexadecimal color used to indicate that a data value has decreased.