Is chart element that identifies the patterns or colors assigned to the categories in the chart?
This chapter describes how to use the ADF Data Visualization chart components to display data in charts using simple UI-first development. The chart components include area, bar, horizontal bar, bubble, combination, line, pie, scatter, and spark charts. The chapter defines the data requirements, tag structure, and options for customizing the look and behavior of these components. Show
If your application uses the Fusion technology stack, you can use data controls to create charts. For more information, see "Creating Databound Charts" in Developing Fusion Web Applications with Oracle Application Development Framework. This chapter includes the following sections:
The DVT graph components are legacy server-side components used for displaying data in graphs. However, the use of these components is discouraged in favor of the client-side charts. Graph components include funnel, Pareto, radar, and stock graphs. For information about the DVT graph components, see Appendix H, "Using Graph Components." 23.1 About the Chart ComponentThe DVT chart components give you the capability of producing a variety of data visualizations that let you evaluate multiple data points on multiple axes in many ways. For example, a number of charts assist you in the comparison of results from one group with the results from another group. Charts display series and groups of data. Series and groups are analogous to the rows and columns of a grid of data. Typically, the rows in the grid appear as a series in a chart, and the columns in the grid appear as groups. For most charts, a series appears as a set of markers that are the same color. Typically, the chart legend shows the identification and associated color of each series. For example, in a bar chart, the yellow bars might represent the sales of shoes and the green bars might represent the sales of boots. Groups appear differently in different chart types. For example, in a stacked bar chart, each stack 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 chart type, a single data item might require one or more data values. For example, a scatter chart 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. 23.1.1 Chart Component Use Cases and ExamplesThe chart components include nine types of charts with one or more variations for a total of over 13 different charts that you can use to display data. JDeveloper provides a Components window that displays available chart categories. Figure 23-1 shows the Components window for area, horizontal bar, bubble, combination, line, pie, scatter, and spark charts. Figure 23-1 Components Window for Charts The funnel, pareto, radar, and stock graphs are legacy server-side components used for displaying data in graphs, and their use is discouraged in favor of the client-side chart components. For information about the DVT graph components, see Appendix H, "Using Graph Components." When you select a chart category in the Components window, JDeveloper displays a dialog with descriptions about the available chart types to provide visual assistance when you are creating charts. Figure 23-2 shows the different area chart types and layouts available when you select the Area chart in the Components window. Figure 23-2 Area Chart Types in Create Area Chart Dialog Chart categories include:
Note: The funnel, pareto, radar, and stock components shown in the Components window are legacy server-side graphs, and their use is discouraged in favor of the client-side chart components. For information about using legacy graphs, see Appendix H, "Using Graph Components." 23.1.2 End User and Presentation Features of ChartsChart end user and configurable presentation features include a rich variety of options. 23.1.2.1 Chart Data LabelsUse data labels to display information about the data points. You can customize the text, position, and style. Figure 23-16 shows a bubble chart and a scatter chart, each configured to show data labels. In the bubble chart, the group's value is displayed in the center of the bubble. In the scatter chart, the label position varies by series. In the first series, the label is positioned below the series marker, and the second series is set to auto which displays the label after the marker. The third series label is configured to display the label before the series marker, and the fourth series label displays the label above the marker. Figure 23-16 Chart Data Labels 23.1.2.2 Chart Element LabelsYou can add descriptive labels to most chart components and subcomponents, including titles, subtitles, axis labels, footnotes, and legends. Figure 23-17 shows a bar chart configured to show a title and subtitle. The chart is also configured to show titles for the x-axis, y-axis, legend, and footnote. Figure 23-17 Bar Chart Configured with Labels for Chart, X-Axis, Y-Axis, and Legend 23.1.2.3 Chart SizingCharts use client-side layout management for controlling the size of the chart. A chart can automatically adjust to the size of the chart's container, and the user can resize the chart by resizing its container. You can also specify the size of a chart using its inlineStyle or styleClass attributes. Figure 23-18 shows a portion of a page configured with the af:panelSplitter and dvt:barChart components. The user can drag the splitter to change the bar chart's size. Figure 23-18 Bar Chart Resized by Dragging a Panel Splitter When charts are displayed in a horizontally or vertically restricted area, as in a web page sidebar, the chart is displayed in a fully featured, although simplified display. 23.1.2.4 Chart LegendsChart legends identify the chart's series and associated colors. Figure 23-19 shows a pie chart configured with a legend. In this example, the number of series is greater than the legend area, and the user can scroll through the legend items to see all series on the chart. Figure 23-19 Pie Chart With Scrollable Legend 23.1.2.5 Chart StylingCharts support styling of colors, sizes, and text to customize series, markers, lines, and data items. Figure 23-20 shows an area chart configured with custom colors for the series items and borders and a scatter chart configured with custom markers. Figure 23-20 Charts Showing Styling for Colors and Markers 23.1.2.6 Chart Series HidingYou can configure charts to allow the user to click on a legend series item to hide a series item from view. The resulting chart can be rescaled or rendered without rescaling. Figure 23-21 shows a bar chart configured for series show and hide. When the user clicks the MaxInStock series item in the chart legend, the series no longer renders, and the legend changes to show which series item is hidden from view. The user can click the series item again to restore the series view. Figure 23-21 Bar Chart Configured for Series Show and Hide 23.1.2.7 Chart Reference ObjectsYou can add reference lines or areas to a specified location or area on a chart's axis. Figure 23-22 shows an example of a bar chart configured to show a reference line and reference area along its y-axis. In this example, the chart is configured to display a green reference line at 1665 on the y-axis. The reference area is configured to display in blue all values between a minimum of 1900 and a maximum of 2200. Figure 23-22 Bar Chart Configured With Reference Line and Reference Area 23.1.2.8 Chart Series EffectsBy default, charts apply gradients to chart series. You can remove the gradients to achieve a flatter design or display the series with patterns. Figure 23-23 shows three area charts configured for series effects. Figure 23-23 Area Charts Configured for Series Effects 23.1.2.9 Chart Series CustomizationYou can customize the appearance of individual series in a chart. Depending upon the chart type, you can customize colors, markers, lines, and fill effects. For combination charts, the series is a chart, and you can also specify which chart to display. Figure 23-24 shows a bubble, scatter, line, and combination chart configured with customized series. The charts illustrate how you might customize series colors, lines, and markers. The combination chart also shows how you might configure the series type to display an area, bar, and line chart. Figure 23-24 Chart Series Customization 23.1.2.10 Chart Data CursorYou can add a data cursor to a chart that the user can move to display detail about a data point. Figure 23-25 shows a line chart configured with a data cursor. In this example, the user chose to display the detail for the chart's third series in the fourth group. Figure 23-25 Line Chart Configured With Data Cursor 23.1.2.11 Chart Time AxisCharts support the use of a time axis when the chart's data is based on dates. For example, you can use a time axis to display daily sales. The time data can cover regular or irregular time intervals. Time axes also support mixed frequency time data, where the time stamps vary by series. Figure 23-26 shows three charts configured with a time axis. The horizontal bar chart's time axis contains regular monthly data and is configured to show the year and month with nested labels. The bar chart shows the time axis configured for irregular yearly intervals. The combination chart shows a mixed frequency time axis with time data that varies by series. Figure 23-26 Charts Configured With a Time Axis 23.1.2.12 Chart Popups and Context MenusYou can configure charts to display popups or context menus using the af:showPopupBehavior tag. Figure 23-27 shows a bar chart configured to show a popup when the user clicks the chart. The popup displays an output message in a note window. Figure 23-27 Bar Chart Showing a Popup 23.1.2.13 Chart Selection SupportCharts can be enabled for single or multiple selection of data markers such as bubbles in a bubble chart or shapes in a scatter chart. Enabling selection is required for popups and context menus and for responding programmatically to user clicks on the data markers. Figure 23-28 shows a pie chart enabled for multiple selection. Each data marker is highlighted as the user moves over it to provide a visual clue that the marker is selectable. The user can press Ctrl while selecting to add or delete slices from the selection. Figure 23-28 Pie Chart Enabled for Selection 23.1.2.14 Chart Zoom and ScrollCharts provide the ability to scroll through the data via a view port or simple scrollbar. This feature can be useful for charts containing large amounts of data. Figure 23-29 shows a line chart configured for scrolling with a view port. As the user moves the view port on the master line chart, the detail chart changes to reflect the selected range. Figure 23-29 Line Chart Configured With Viewport for Scrolling The user can also choose to zoom in on a specific period by clicking the Marquee Zoom icon that appears when the user hovers over the chart. Figure 23-30 shows the same line chart configured for marquee zoom. In this example, the user chose to zoom the chart on the October 2013 time period. Figure 23-30 Line Chart Configured for Marquee Zoom 23.1.2.15 Legend and Marker DimmingCharts provide the ability to highlight a series when the user hovers over a legend item or marker. Figure 23-31 shows a bar chart configured with three series. As the user hovers over each series, the remaining series dim from view. Figure 23-31 Chart Configured for Legend and Marker Dimming 23.1.2.16 Pie Chart Other Slice SupportPie charts provide the ability to aggregate data if your data model includes a large number of smaller contributors in relation to the larger contributors. Figure 23-32 shows a pie chart configured to aggregate all values less than two percent of the total. In this example, the tooltip shows the total value of the aggregated slices. Figure 23-32 Pie Chart Showing Other Slice Support 23.1.2.17 Exploding Slices in Pie ChartsWhen one slice is separated from the other slices in a pie, this display is referred to as an exploding pie slice. You can explode a slice to make it stand out from the other slices. Figure 23-33 shows an example of an exploded pie slice. Figure 23-33 Pie Chart Configured With Exploding Pie Slice 23.1.2.18 Chart AnimationCharts support animation upon initial display or data change. 23.1.2.19 Chart Image FormatsChart components rely on HTML5 technologies available in modern browsers for animations and interactivity. 23.1.3 Additional Functionality for Chart ComponentsYou may find it helpful to understand other ADF Faces features before you implement your chart. Additionally, once you have added a chart to your page, you may find that you need to add functionality such as validation and accessibility. Following are links to other functionality that chart components can use:
Additionally, data visualization components share much of the same functionality, such as how data is delivered, automatic partial page rendering (PPR), and how data can be displayed and edited. For more information, see Section 22.2, "Common Functionality in Data Visualization Components." 23.2 Using the Chart ComponentTo use the chart component, define the data, add the chart to a page, and complete the additional configuration in JDeveloper. 23.2.1 Chart Component Data RequirementsThe chart component use a standard CollectionModel for its data structure. This class extends the JSF DataModel class and adds on support for row keys and sorting. In the DataModel class, rows are identified entirely by index. This can cause problems when the underlying data changes from one request to the next, for example a user request to delete one row may delete a different row when another user adds a row. To work around this, the CollectionModel class is based on row keys instead of indexes. For more information about collection-based components, see Chapter 12, "Using Tables, Trees, and Other Collection-Based Components." Data requirements for charts differ with chart type. Data requirements can be any of the following kinds:
23.2.1.1 Area, Bar, Horizontal Bar, and Line Chart Data RequirementsData requirements for area, bar, horizontal bar, and line charts include:
23.2.1.2 Bubble Chart Data RequirementsBubble charts require at least three data values for a data marker. Each data marker in a bubble chart represents three group values:
For more than one group of data, bubble charts require that data be in multiples of three. For example, in a specific bubble chart, 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 chart, you can identify groups of data by examining tooltips on the markers. However, identifying groups is not as important as looking at the overall pattern of the data markers. 23.2.1.3 Combination Chart Data RequirementsCombination charts require one set of data for each chart included in the combination chart. Each chart in the combination chart must meet the data requirements for the area, bar, or line chart components on which it is based. For a list of the data requirements for area, bar, or line chart components, see Section 23.2.1.1, "Area, Bar, Horizontal Bar, and Line Chart Data Requirements." 23.2.1.4 Pie Chart Data RequirementsOne collection of data with one or more sets of data items is required for a pie chart. The data structure is as follows:
23.2.1.5 Scatter Chart Data RequirementsScatter charts require at least two data values for each marker. Each data marker represents the following:
For more than one group of data, the data must be in multiples of two. 23.2.1.6 Spark Chart Data RequirementsLine, bar, and area spark charts require a single series of data values. Floating bar spark charts require two series of data values, one for the float offset, and one for the bar value. 23.2.2 Configuring ChartsBecause of the many chart types and the significant flexibility of the chart components, charts have a large number of DVT tags. The prefix dvt: occurs at the beginning of each chart 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 chart 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 chart tag in JDeveloper, select the tag in the Structure window and press F1 or click Component Help.in the Properties window. DVT charts also share many of the same attributes as other ADF Faces and DVT components. For additional information, see Section 23.1.3, "Additional Functionality for Chart Components." 23.2.3 How to Add a Chart to a PageWhen you are designing your page using simple UI-first development, you use the Components window to add a chart to a JSF page. When you drag and drop a chart component onto the page, a Create Chart dialog displays available categories of chart types, with descriptions, to provide visual assistance when creating charts. You can also specify a quick start layout of the chart's legend. Figure 23-34 shows the Create Bar Chart dialog for bar charts with the default bar chart type and quick start layout selected. Figure 23-34 Create Bar Chart Dialog Once you complete the dialog, and the chart is added to your page, you can use the Properties window to specify data values and configure additional display attributes for the chart. In the Properties window you can click the icon that appears when you hover over the property field to display a property description or edit options. shows the dropdown menu for a bar chart component value attribute. Figure 23-35 Bar Chart Value Attribute Note: If your application uses the Fusion technology stack, then you can use data controls to create a chart and the binding will be done for you. For more information, see "Creating Databound Charts" in Developing Fusion Web Applications with Oracle Application Development Framework Before you begin: It may be helpful to have an understanding of how chart attributes and chart child tags can affect functionality. For more information, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." You must complete the following tasks:
To add a chart to a page:
23.2.4 What Happens When You Add a Chart to a PageJDeveloper generates only a minimal set of tags when you drag and drop a gauge from the Components window onto a JSF page. Example 23-1 shows the code inserted in the JSF page for a bar chart with the quick start layout selected in Figure 23-34. Example 23-1 Bar Chart Sample Code After inserting a chart component into the page, you can use the visual editor or Properties window to add data or customize chart features. For information about setting component attributes, see Section 3.4.7, "How to Set Component Attributes." 23.3 Adding Data to ChartsThe process to add data to charts depends upon the chart's type. In most cases, you specify the data model in the chart's value attribute and configure the chart's data items in the chartDataItem or pieDataItem attributes. For spark charts, you specify the spark chart's value in the sparkItem child component. You can specify the chart's value and chart data items in a managed bean that returns the chart's data or by binding a data control to the chart. 23.3.1 How to Add Data to Area, Bar, Horizontal Bar, Combination, and Line ChartsTo add data to area, bar, horizontal bar, combination, and line charts, specify the data model in the chart's value attribute and configure a chartDataItem for each unique group. For details about data requirements, see Section 23.2.1, "Chart Component Data Requirements." Example 23-2 shows an example of a managed bean that defines the data for a line chart that shows weekly portfolio values for four investors. In this example, the ChartDataSource class defines the chart's CollectionModel in the getWeeklyStockData() method which calls the getPortfolioData() method to define the chart's data items. Example 23-2 Managed Bean Example Defining Data for a Line Chart package view; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; import java.util.HashMap; import java.util.Random; import java.util.List; import org.apache.myfaces.trinidad.model.CollectionModel; import org.apache.myfaces.trinidad.model.ModelUtils; public class ChartDataSource { /** * Object representing the data for a single row of the model. */ public static class ChartDataItem extends HashMapExample 23-3 shows the code on the JSF page that defines the line chart and references the ChartDataSource class. In this example, the managed bean is named chartDataSource. Example 23-3 Sample Code on JSF Page for Line Chart Using Managed Bean for Data Figure 23-36 shows the line chart that is displayed if you configure the line chart using the ChartDataSource class. Figure 23-36 Line Chart Showing Portfolio Data for Four Investors Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add an area, bar, combination, horizontal bar, or line chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To add data to an area, bar, combination, horizontal bar, or line chart:
23.3.2 How to Add Data to Pie ChartsTo add data to a pie chart, specify the data model in the pie chart's value attribute and configure a pieDataItem for each unique series. For information about pie chart data requirements, see Section 23.2.1.4, "Pie Chart Data Requirements." The process to add data to pie charts is similar to the process for adding data to area, bar, horizontal bar, bubble, combination, line, and scatter charts. The primary difference is that you add a pieDataItem instead of a chartDataItem to the chart. Example 23-4 shows a simple example for configuring a pie chart from a managed bean. In this example, the getDefaultPieData() method is added to the chartDataSource bean referenced in Example 23-2. Example 23-4 Sample Method to Supply Data to a Pie Chart public CollectionModel getDefaultPieData() { ListExample 23-5 shows the code on the JSF page that defines a pie chart and references the ChartDataSource class. In this example, the managed bean is named chartDataSource. Example 23-5 Sample Code on JSF Page for Pie Chart Using Managed Bean for Data Figure 23-37 shows the pie chart at run time. In this example, the pie chart is rendered with a legend, and the data labels show the percentage of each slice as a portion of the total. Figure 23-37 Pie Chart Configured From Managed Bean Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a pie chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To add data to a pie chart:
23.3.3 How to Add Data to Bubble or Scatter ChartsTo add data to a bubble or scatter chart, specify the data model in the chart's value attribute and configure a chartDataItem for each unique group. For details about data requirements, see Section 23.2.1, "Chart Component Data Requirements." The process to add data to bubble or scatter charts is similar to the process for adding data to area, bar, horizontal bar, bubble, combination, line, and scatter charts. The primary difference is that you must also specify values for the x-axis and y-axis. For bubble charts, you must also specify values for the z-axis, which represents the size of the bubbles. Example 23-6 shows a simple example for configuring a bubble chart from a managed bean. In this example, the getDefaultBubbleData() method is added to the chartDataSource bean referenced in Example 23-2. Example 23-6 Sample Method to Supply Data to a Bubble Chart public CollectionModel getDefaultBubbleData() { ListFor scatter charts, only the x-axis and y-axis positions are required. Example 23-7 shows a simple example for configuring a scatter chart from a managed bean. In this example, the getDefaultScatterData() method is added to the chartDataSource bean referenced in Example 23-2 Example 23-7 Sample Method to Supply Data to a Scatter Chart public CollectionModel getDefaultScatterData() { ListFigure 23-38 shows the bubble chart and scatter chart displayed at runtime. The tooltips show the data from the first ChartDataItem defined in Example 23-6 and Example 23-7. Figure 23-38 Bubble and Scatter Charts Configured From Managed Bean Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a bubble or scatter chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To add data to a bubble chart:
23.3.4 How to Add Data to SparkchartsSpark charts are simple, charts that display trends or variations, often in the column of a table, or inline with text. Line, bar, and area spark charts require a single series of data values. Example 23-7 shows an example of a line spark chart in a table column. Figure 23-39 Line Spark Chart in Table of Stock Prices Floating bar spark charts require two series of data values, one for the float offset, and one for the bar value. Figure 23-40 shows an example of a floating bar spark chart.
Figure 23-40 Floating Bar Spark Chart In a simple UI-first development scenario you can insert a spark chart using the Components window and bind it to data afterwards. You can provide data to spark charts in any of the following ways:
Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." If you plan on displaying your spark chart in a table, create the ADF table. If you need help creating the table, see Section 12.3.4, "How to Display a Table on a Page." Add a spark chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To add data to a spark chart:
Note: You can also bind the spark chart to a data control if your application uses the Fusion technology stack. To do so, click Bind to ADF Control in the Properties window to select a data collection. For more information about using data controls to supply data to your chart, see "Creating Databound Charts" in Developing Fusion Web Applications with Oracle Application Development Framework. 23.4 Customizing Chart Display ElementsYou can customize most aspects of the chart's display, including its labels, legend, axes, series, and animation effects. Depending upon the chart type, you can also add reference objects to charts, specify the stacking behavior, or add a dual Y-Axis to charts that support it. Pie charts also support the ability to aggregate smaller values or explode a pie slice. 23.4.1 How to Configure Chart LabelsYou can customize the style and position of chart data labels on all charts other than spark charts. Depending on the chart type, you can also add a title, subtitle, footnote, legend title, or axis title. Tip: Use data labels sparingly because they cause clutter and decrease readability. Use data labels primarily to highlight outliers or important values and not to show values for all data points. 23.4.1.1 How to Configure Chart Data LabelsTo configure chart data labels, configure the attributes of the dvt:chartDataItem or dvt:pieDataItem chart child component. If you want the style and position of all chart or pie data items to be the same, you can configure attributes directly on the chart component. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." Add data to your chart. For additional information, see Section 23.3, "Adding Data to Charts." To configure data labels for charts:
23.4.1.2 How to Configure Chart Element LabelsTo configure a chart label, add the chart child component as needed, and configure the style and position of the label. Depending upon the chart type, you can specify labels for the chart's title, subtitle, footnote, legend title, or axis title and tick labels. Note: Sparkcharts are condensed charts that contain minimal formatting and have little support for labels. Use the spark chart's container to provide descriptive text for the spark chart. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To add a title, subtitle or footnote to a chart:
To configure chart axis labels:
For information about customizing chart legend titles, see Section 23.4.2, "How to Configure Chart Legends." 23.4.2 How to Configure Chart LegendsYou can add a legend to all charts except the spark chart to identify the chart's series and associated colors. If you chose a quick start layout that included a legend when you created your chart, you should already have a legend on the page. After you have added the legend, you can customize its position, configure a legend title, or disable scrolling. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure a chart legend:
23.4.3 How to Format Chart Numerical ValuesYou can customize the appearance of numeric values on charts using the dvt:chartValueFormat or dvt:chartTickLabel tags. Use the dvt:chartValueFormat tag to format numeric values for the chart's value, value label, or axis values. Use the dvt:chartTickLabel tag to format the values on the axis labels. The dvt:chartValueFormat and dvt:chartTickLabel tags both allow you to specify the scaling for numeric display. The dvt:chartTickLabel tag also has a rotation property to specify whether the chart will automatically rotate the labels by 90 degrees in order to fit more labels on the axis. The rotation will only be applied to categorical labels for a horizontal axis. You can also specify specific patterns for the numeric values or change the numeric display to currency or percent by adding the af:convertNumber tag to the dvt:chartValueFormat or dvt:chartTickLabel tags. For additional information about using the af:convertNumber tag, see Chapter 7, "Validating and Converting Input." Figure 23-42 shows the effect of adding dvt:chartValueFormat and dvt:chartTickLabel tags to a bar chart configured to display monthly salaries for a fictitious department. In this example, the top bar chart is using default numeric formatting. The bar chart at the bottom of the figure is configured to display the series value and axis label as currency values. Figure 23-42 Bar Chart Configured to Display Currency Values Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To format numeric values on a chart's value, value label, or axis values:
To format numeric values on a chart's axis label:
To specify numeric patterns, currency, or percent using af:convertNumber:
23.4.4 Customizing a Chart AxisDepending upon the chart type, you can configure a time axis on the x-axis or customize the properties of a chart's x-axis, y-axis, y2-axis, or z-axis. 23.4.4.1 How to Configure a Time AxisIf your x-axis includes time data, then you can enable the time axis display. Charts include support for time data that is based on regular or irregular intervals. Charts also support mixed frequency time data, where the individual series contain differing dates. Figure 23-43 shows three charts configured for a time axis. In the horizontal bar chart, the time data is spaced equally. The vertical bar chart shows an example of irregularly spaced data, and the chart provides a visual clue that there is no data for 2014. The combination chart shows mixed frequency time data. In this example, the time data is different for each series (chart) in the combination chart. Figure 23-43 Charts Configured for Regular, Irregular, and Mixed Frequency Time Data To configure a time axis, set the timeAxisType attribute's value to enabled for regular or irregular data, and set it to mixedFrequency for time data that varies by series. Example 23-13 shows the code snippet on the JSF page that defines the horizontal bar chart, bar chart, and combination chart, with the timeAxisType definition highlighted in bold font. Example 23-13 Code on JSF page Defining timeAxisType The code that defines the charts' collection models and populate them with data is stored in the chartDataSource managed bean shown in Example 23-2. Example 23-14 shows the getMonthlyTimeData(), getYearlyIrregularTimeData(), and getYearlyMixedFrequencyTimeData() methods. In this example, the getMonthlyTimeData() method calls the getTimeData() method which is a reusable method that takes the series, group, and time data as its arguments. Example 23-14 Sample Methods Defining Chart Collection Models With Time Data public CollectionModel getYearlyIrregularTimeData() { ListBefore you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure a chart time axis:
23.4.4.2 How to Customize the Chart AxisCharts include support for customizing the x-axis, y-axis, and y2-axis. Depending upon the axis type, you can customize the minimum and maximum values of the data and axis, add a title, specify tick mark increments, configure viewport boundaries, and specify whether the axis baseline starts at the minimum value of the data or at zero. To customize a chart axis, add the dvt:chartXAxis, dvt:chartYAxis, or dvt:chartY2Axis component to the chart and configure the properties for the axis in the Properties window. Table 23-6 lists the chart axis attributes and the axis on which they apply. Most attributes have default settings which are based upon the data, and you only need to change these if you want to modify the defaults. However, you must specify values for the title, attributeChangeListener, and binding attributes if you want to use them. Table 23-6 Chart Axis Attributes
Chart axes also support optional child components which allow you to customize the major and minor tick marks, axis tick labels, and axis lines.
Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To customize a chart axis:
To customize the chart's axis line:
To customize the axis major or minor ticks:
23.4.4.3 Configuring Dual Y-AxisYou can add a second y-axis to area, bar, combination, horizontal bar, and line charts. This feature is useful if you have two series with different ranges of data. For example, you could have a bar chart that shows salary on one y-axis and commission percent on the second. To configure a dual y-axis, add the dvt:chartSeriesStyle component to your chart, and set the assignedToY2 attribute to true. For instructions to configure the dvt:chartSeriesStyle component, see Section 23.4.7.1, "How to Customize a Chart Series." 23.4.5 Adding Reference Objects to a ChartYou can add reference areas or lines to all charts except pie charts using the dvt:referenceLine or dvt:referenceArea components. Reference areas are associated with the chart's axis and typically are associated with the y-axis. Use reference areas or lines to show target values or ranges. Figure 23-44 shows the line chart displayed in Figure 23-36 with a reference area and reference line. In this example, the reference area is configured with a light blue color and a range between 200 and 250. The reference line is configured with a green color and a value of 25. Figure 23-44 Line Chart Configured With Reference Area and Reference Line Example 23-15 shows the code snippet on the JSF page that defines the reference area and line. In this example, the reference area and line are configured as children of the chart's y-axis. Example 23-15 Sample Code on JSF Page Defining Reference Area and Reference Line You can also specify multi-segment reference lines or areas as shown in Figure 23-45. In this example, the bar chart is configured with a multi-segment reference line, and the line chart is configured with a multi-segment reference area. In these examples, the target values vary by year. Figure 23-45 Multi-Segment Reference Line and Reference Area Multi-segment reference lines or reference areas are defined by adding the dvt:referenceAreaItem or dvt:referenceLineItem elements as children of the dvt:referenceArea and dvt:referenceLine components. You can explicitly define a reference area or line item for each segment in the reference line or area, or use the af:iterator tag to loop through the segments. Example 23-16 shows the code snippets on the JSF page that define the bar and line charts. The code related to the reference area and reference line is highlighted in bold. Example 23-16 Code on JSF Page Defining Segmented Reference Area and Line The data for the bar chart is defined in the getYearlyIrregularTimeData() method and is shown in Example 23-14, and the line chart's data is defined in the getYearlySingleTimeData() method. Both methods are contained in the chartDataSource managed bean. Example 23-17 shows the getYearlySingleTimeData() method that defines the line chart's collection model and populates it with sample data. Example 23-17 Sample Method to Define a Chart With Single Series public CollectionModel getYearlySingleTimeData() { List23.4.5.1 How to Add a Reference Object to a ChartTo add a reference object to a chart, add the dvt:referenceArea or dvt:referenceLine component as a child of the chart's associated axis. The process is the same for all charts except the spark charts which use reference objects wrapped inside a reference object set for reference areas and lines. To specify segmented reference lines or areas, add the dvt:referenceAreaItem or dvt:referenceLineItem as a child of the dvt:referenceArea or dvt:referenceLine. To use af:iterator to loop through the reference items, add the af:iterator as a child of the chart's axis and then add the reference item. Note: To add a reference line or object to a spark chart, add the dvt:referenceObjectSet component to the spark chart and configure a dvt:referenceObject for each reference line or area. Consult the tag documentation for additional information. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To add a reference line to a chart:
To add a reference area to a chart:
23.4.5.2 What You May Need to Know About Adding Reference Objects to ChartsThe multi-segmented reference line or area is supported on bubble charts, scatter charts, and charts configured with a time axis. 23.4.6 How to Configure a Stacked ChartStacked charts show cumulative values across groups. Stacked charts typically contain two or more series which are aggregated into one bar, area, or line. For example, you might want to show the total sales of three products, grouped by city. In a clustered bar chart, the bar chart would display three bars, one for each product. In a stacked bar chart, the three bars would be aggregated into one bar for each city. Figure 23-46 shows the effect of stacking series in a bar chart. In this example, the five series in the clustered bar chart at the top of the figure are configured as a stacked bar chart at the bottom of the figure. Figure 23-46 Stacked Bar Chart If you chose a quick start layout that included a stacked display, then JDeveloper automatically stacked the series by group. Otherwise, you can enable stacking by setting the stack attribute to on. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure a stacked chart:
23.4.7 Customizing Chart SeriesYou can customize the fill of all series in a chart by setting the seriesEffect attribute on the chart component. You can customize the appearance of individual series in a chart by adding the dvt:chartSeriesStyle component to your chart. Depending upon the chart type, you can customize colors, markers, lines, and fill effects. For combination charts, you can also specify which chart to display. Note: Spark charts contain only a single series and do not support seriesEffect or chartSeriesStyle. To customize the spark chart, enter values for the dvt:sparkChart component in the Properties window. You can customize the series color and specify which markers are displayed. For more information, click Component Help in the Properties window. 23.4.7.1 How to Customize a Chart SeriesTo customize an individual series in a chart, add the dvt:chartSeriesStyle component and configure its properties in the Properties Window. Table 23-7 lists the attributes available on the chartSeriesStyle component and the chart types for which they apply. Table 23-7 dvt:chartSeriesStyle Tags
Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To customize a chart series:
23.4.7.2 How to Configure Series Fill Effects on All Series in a ChartTo customize the series fill effects for all series in the chart, specify a value for the seriesEffect attribute. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure series fill effects for all series in a chart:
23.4.8 How to Configure the Pie Chart Other SliceUse the Other slice to aggregate smaller data sets visually into one larger set for easier comparison, as shown in Figure 23-32. To configure the Other slice, set a value for the otherThreshold attribute which specifies the percentage under which the slice would be aggregated into the Other slice. Optionally, you can set a value for the Other slice color. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure the pie chart Other slice:
23.4.9 How to Explode Pie Chart SlicesYou can configure the slices of a pie chart so that each slice is separated from the other using the explode attribute of the dvt:pieDataItem. You can specify a value between 1 and 10 for the distance between the slices. Figure 23-47 shows the pie chart displayed inFigure 23-37 configured for exploding slices. In this example, the explode attribute for the pie chart's data item is defined as 0.25. Figure 23-47 Pie Chart Configured For Exploding Slices You can also configure an individual slice to explode using the explode attribute. Figure 23-48 shows the same pie chart configured to explode the Series 1 slice. Figure 23-48 Pie Chart Configured With Single Exploding Slice To configure an individual slice, you can use an EL expression to identify the slice and the value for the explode attribute. The individual slices in a pie chart are its series, and you can reference the series number in the EL expression. For example, to set the explode attribute for the first series (slice) in the pie chart to 0.5, enter the following for the EL expression: #{row.series == 'Series 1' ? 0.5 : 0}. If you wanted to set the explode attribute for the third series to 0.25, you could enter the following for the EL expression: #{row.series == 'Series 3' ? 0.25 : 0}. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To explode pie slices:
23.4.10 How to Configure AnimationTo configure chart animation, add the af:transition tag as a child of the chart component and configure the trigger type and transition effect. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure gauge animation:
23.4.11 What You May Need to Know About Skinning and Customizing Chart Display ElementsCharts also support skinning to customize the color and font styles for the top level components as well as the axes, legend, series, marquee icon, labels, and plot area. You can also use skinning to define the animation duration and chart series effect. Example 23-18 shows the skinning key for a chart configured to show patterns for its series fill effect. Example 23-18 Using a Skinning Key to Define Chart Series Fill Effect af|dvt-chart { -tr-series-effect: pattern; }For the complete list of chart skinning keys, see the Oracle Fusion Middleware Data Visualization Tools Tag Reference for Oracle ADF Faces Skin Selectors. For additional information about customizing your application using skinning and styles, see Chapter 31, "Customizing the Appearance Using Styles and Skins." 23.5 Adding Interactive Features to ChartsYou can add a variety of interactive features to your charts, including data cursors, hide and show behavior, hover behavior, selection support, popups, context menus, and zoom and scroll. 23.5.1 How to Add a Data CursorAdd a data cursor to your chart to allow the user to focus more easily on data points. For charts where selection and other click interactivity is not enabled, the data cursor can be used to provide feedback for the closest data item to the mouse or touch gesture. The data cursor is enabled by default for area and line charts on touch devices. To add the data cursor explicitly, set the dataCursor attribute to on and define the data cursor's behavior. Figure 23-49 shows the line chart displayed in Figure 23-36 configured with a data cursor. In this example, the data cursor displays the series name, group value and series value. The box surrounding the data detail is displayed in the same color as the series fill color. Figure 23-49 Line Chart With Data Cursor Showing Investor Detail Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure a chart data cursor:
Note: The content displayed in the data cursor's tooltip is determined by the dvt:chartDataItem or dvt:pieDataItem component's shortDesc attribute. You can edit this value in the Properties window for dvt:chartDataItem or dvt:pieDataItem. 23.5.2 How to Configure Hide and Show BehaviorTo configure hide and show behavior, which permits the user to click on a legend series item to hide or show a series item, configure the chart's hideAndShowBehavior attribute. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure hide and show behavior:
23.5.3 How to Configure Legend and Marker DimmingTo configure legend and marker dimming, set the chart's hoverBehavior attribute to dim. As the user hovers over each series, the remaining series dim from view. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure legend and marker dimming:
23.5.4 How to Configure Selection SupportCharts can be enabled for single or multiple selection of data markers. Enabling selection is required for popups and context menus and for responding programmatically to user clicks on the data markers. To enable selection support, set the chart's dataSelection attribute to single or multiple. After you have enabled selection support, you can specify a selection listener that will respond to user clicks on the chart. Figure 23-50 shows a bar chart configured for multiple selection support. The user can click to select a single bar or use Ctrl-Click to select multiple bars. The bars highlight to show which bars are selected, and a message is displayed at the top of the page indicating which row key was selected. Figure 23-50 Bar Chart Configured for Multiple Selection Example 23-19 shows the code on the JSF page that defines the bar chart and selection listener, with the selection code highlighted. Example 23-19 Sample Code on JSF Page for Bar Chart Configured for Multiple Selection In this example, the code that defines the bar chart is included in a method named defaultBarData(), and the selection listener is defined in a method named selectionListener(). Example 23-20 shows the defaultBarData() and selectionListener() methods. The methods and imports were added to the chartDataSource class created in Example 23-2. Example 23-20 Sample Methods to Create Bar Chart With a Selection Listener // Additional imports needed by selection listener import oracle.adf.view.faces.bi.component.chart.UIChartBase;import org.apache.myfaces.trinidad.event.SelectionEvent; import org.apache.myfaces.trinidad.model.RowKeySet; // Bar Chart data public CollectionModel getDefaultBarData() { ListBefore you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure chart selection support:
23.5.5 How to Configure Popups and Context MenusThe process to add a popup or context menu is essentially the same. Add the af:showPopupBehavior tag as a child of one of the chart's data items, define the trigger type as click for popup menus or contextMenu for context menus, and add an af:popup containing the desired behavior to the page. Figure 23-51 shows the pie chart displayed in Figure 23-37 configured for popup support. If the user clicks one of the pie slices, a note window pops up with a message. Figure 23-51 Pie Chart Configured With a Note Window Popup Example 23-21 shows the code on the page for the popup menu shown in Figure 23-51. In this example, the af:showPopupBehavior component uses the popupId to reference the af:popup component. The af:popup component is configured with the af:noteWindow component which is configured to display a simple message in the af:outputFormatted component. The triggerType of the af:showPopupBehavior tag is set to click, and the note window will launch when the user clicks one of the pie chart's slices. Example 23-21 Code Example for Pie Chart Popup You can change the popup to a context menu by simply changing the trigger type for the af:showPopupBehavior component to contextMenu as shown in the following code snippet: Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." Add a popup component to your page. For help with configuring the af:popup component, see Chapter 16, "Using Popup Dialogs, Menus, and Windows." To add a popup or context menu to a chart:
23.5.6 How to Configure Chart Zoom and ScrollYou can configure your chart to include marquee zoom and scroll which permits the user to focus on an area of the chart or scroll through the data using the mouse. This feature can be useful for large data sets. Figure 23-52 shows the line chart shown in Figure 23-36 configured for marque zoom and scroll. The user can select an area on the chart and then release the mouse button to zoom in on the selected area. The user can also scroll the mouse wheel upward to zoom in on chart data. To restore the chart to its original display, the user can scroll the mouse wheel downward. Figure 23-52 Line Chart Configured for Marquee Zoom and Scroll You can also add a viewport to the chart which uses a small form factor to display the entire data set, and then configure the original line chart to display a subset of the data. Figure 23-53 shows the same line chart configured with an overview port. When the user zooms in on a chart area, the viewport changes to match the user's selection. The user can stretch or shrink the viewport dragging the handles on each side of the viewport. Figure 23-53 Line Chart Configured With Overview To configure marque zoom and scroll, set a value for the chart's zoomAndScroll attribute. To configure an overview window, add the overview facet and overview window to the chart, and configure the chart's axis for the overview range. Before you begin: It may be helpful to have an understanding of how chart attributes and child tags can affect functionality. For more information about configuring charts, see Section 23.2.2, "Configuring Charts." You may also find it helpful to understand functionality that can be added using other ADF Faces features. For more information, see Section 23.1.3, "Additional Functionality for Chart Components." Add a chart to your page. For help with adding a chart to a page, see Section 23.2.3, "How to Add a Chart to a Page." To configure marquee zoom and scroll:
To add an overview window to your chart:
What is the box on the side of a chart that identifies patterns and colors that are assigned to data or categories?Answer. LEGEND IS A BOX THAT INDENTIFIES THE PATTERNS COLOURS ASSIGNED TO A DATA SERIES IN A CHART.
Which of the following elements uses colors to identify how the data is represented in a chart quizlet?A legend is the chart element that explains the symbols, textures, or colors used to differentiate data series.
How can you identify the chart elements button when you select a chart?How can you identify the Chart Elements button when you select a chart? It is a green plus sign. A pie chart should be considered when you have just one data series to plot.
What is the definition of a data marker element Powerpoint?data marker. a column, bar, area, dot, pie, slice, or other symbol that represents a single data point. data point. individual data plotted in a chart.
|