To create a chart:
- Open PeopleSoft Application Designer.
- Open the page where the chart is to be inserted.
- Insert the chart control by either:
- Clicking on the chart icon in the toolbar, or
- Selecting Insert, Chart
- Draw the chart control on the page.
- Associate the chart control with a record field
Every chart control must be associated with a record field. This is just the field for the chart control. It is not the field used for drilling down for data in the chart.
Bring up the chart control properties by either
- Double-clicking on the chart control, or
- Right-clicking on the chart control and selecting Page Field Properties.
- Select the record name and field for the chart.
On the Record tab of the chart control properties, select the record and field for the chart.
To make the control a page anchor, select the Enable as Page Anchor on the General tab.
- Write your PeopleCode.
In some event on the page, such as Activate, put the PeopleCode you need for populating the chart.
- Get the chart.
The first thing you must do is get the chart. You must use the record and field name that you associated with the chart control on the page.
&oChart = GetChart(QE_CHART_DUMREC.QE_CHART_FIELD);
- Set the data records.
Set the data record. The SetData function associates the record data with the chart. Then use the SetDataYAxis and SetDataXAxis functions to associate specific fields in the record with the Y axis data and the X axis data.
&oChart.SetData(Record.QE_CHART_RECORD);
&oChart.SetDataYAxis(QE_CHART_RECORD.QE_CHART_SALES);
&oChart.SetDataXAxis(QE_CHART_RECORD.QE_CHART_PRODUCT);
This is all the code needed to create a chart. You don’t need to set the chart type: the default is a 2D bar chart. You don’t need to set the series unless you want to group your data. Everything else is also optional.
- (Optional) Set the data series.
In this example, we want to set the region as the series. This means that the data will be grouped according to the region.
&oChart.SetDataSeries(QE_CHART_RECORD.QE_CHART_REGION);
- (Optional) Set the chart type.
Because we want a stacked bar for the chart, we must set the Type property of the chart. This means that each product (footballs, rackets, and so on) will have a single bar, and the data series (California, Oregon, and so on) will be what is ‘stacked’.
&oChart.Type = %ChartType_2DStackedBar;
- (Optional) Set legend and label attributes.
For this example, we want a legend, and want it to appear in the right side. In addition, because the text of the series labels is so large, they must be vertical to display all of them.
&oChart.HasLegend = True; &oChart.LegendPosition = %ChartLegend_Right;
&oChart.XAxisLabelOrient = %ChartText_Vertical;
###
More links:
MIPRO Consulting main website.
You should follow MIPRO on Twitter and Facebook.