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;
Sample code to prepare
chart:
Local Chart &cChart;
Local Rowset &wecntrs;
Local SQL &WSQL;
Local number &i,
&empcnt;
Local string
&perrating;
/* Get data by using SQL*/
&wecntrs =
GetLevel0()(1).GetRowset(Scroll.PERFORM_RATIN);
&WSQL =
CreateSQL("select
COUNT(EMPLID),PERFORM_RATING from PS_PERFORM_RATIN group by
PERFORM_RATING");
&i = 1;
/* Prepare Data */
While
&WSQL.Fetch(&empcnt, &perrating)
&wecntrs(&i).PERFORM_WRK.EMPL_COUNT.Value = &empcnt;
&wecntrs(&i).PERFORM_WRK.PERFORM_RATING.Value =
&perrating;
&wecntrs.InsertRow(&i);
&i = &i + 1;
End-While;
/**Chart properties **/
&cChart =
GetChart(PERFORM_WRK.PERFORM_RATING);/* PERFORM_WRK.PERFORM_RATING assingned to
chart */
&cChart.HasLegend =
True;
&cChart.LegendPosition
= %ChartLegend_Right;
&cChart.Type =
%ChartType_3DPie;
&cChart.SetData(&wecntrs); /* &wecntrs is a rowset ,this contains data. */
&cChart.SetDataXAxis(PERFORM_WRK.PERFORM_RATING);
&cChart.SetDataYAxis(PERFORM_WRK.EMPL_COUNT);
&cChart.IsDrillable =
True;
/* set data hints */
&cChart.SetDataHints(PERFORM_WRK.PERFORM_RATING);
/* set data colors */
&cSliceColors =
CreateArray(12, 10, 2, 5);
&cChart.SetColorArray(&cSliceColors);
/* To explode data */
Local array of number
&ExplodedArray;
&ExplodedArray =
CreateArray(4);
&cChart.SetExplodedSectorsArray(&ExplodedArray);
/* Set axis text properties */
&cChart.XAxisLabelOrient
= %ChartText_Horizontal;
&cChart.XAxisTitle =
"Performance";
&cChart.YAxisTitle =
"Performance Count";
Sample Output:
NOTE:
- &cChart.IsDrillable =
True;
If set this property as true
then y-axis field change will trigger when we click
on part of a chart.