Working with Charts
To add a new chart to a report click on the icon in the Report Designer toolbar and select “Chart”. Then drag a box around the area in one of report bands where the chart will be located. The Report Designer will then start the Chart Wizard that will help you define the properties of the new chart.
note
a chart can only be added to the Title, Summary or one of Group Header or Footer bands. You cannot add a chart to the Details, Column Header, Column Footer, Page Header or Page Footer bands.Defining a new chart consists of the following steps:
- Define general properties of the chart, such as chart type and orientation.
- Define data for the chart
- Define other chart properties, such as chart title, axes labels, whether or not to include a legend etc.
Defining general properties of the chart
First of all you need to define the type of chart. Some of the other properties of the chart will depend on the type of the chart chosen. Four types of charts are currently available:
- Bar chart
- Line chart
- Area chart
- Pie chart
You also need to specify the background color of the chart and plot and chart orientation. The preview window will show you the result of your selection and will make it easier to understand what each of the properties mean.
Defining data for the chart
The second step is to define the data that the chart will display. The data is usually the subset or all data that the report works with. For example, a report may show the details of a company’s departments – staff members, sales, expenditure etc and a particular chart may show a graph of expenditure per department.
You usually define the data for a chart by specifying expressions for X and Y axes of the chart similar to the ones you define for a tag element. For example, if a report lists staff members of a company represented by a business object StaffMember and you want a chart that displays ages of staff members you can define data expressions like this:
For X axis:
StaffMember.Name
For Y axis:
AGE (StaffMember.DateOfBirth)
You can also specify specific values for both X and Y axes.
A chart can display one graph or a series of graphs. Let’s look at some examples (the configuration for these examples can be found in the SAMPLES
directory of your AwareIM installation – the file SampleCharts.bsv
).
Example1
In this example a report will be showing expense records for some company. Every expense record (ExpenseRecord object) will store a date of the expense, the expense amount and the name of the department. The report will show expense records for each department. The report will show separate charts of expense records for every department. At the end of the report there will be a chart showing total expenses for each department. This is how we can define a report for this example:
The report will have a group band with the following group condition: ExpenseRecord.DepartmentName. Every time the value of the DepartmentName attribute changes the new group will be started. We will include a chart into the Group Footer section of the department group. This chart will show expense records for this particular group. We will define the following expressions for the data of this chart:
For X axis:
ExpenseRecord.Date
For Y axis:
ExpenseRecord.Amount
We will also include another chart in the Summary band of the report. This report will show total expenses for each group. We will define the data for this group like so:
For X axis:
ExpenseRecord.DepartmentName
For Y axis:
SUM ExpenseRecord.Amount
Note that we will set evaluation time for the SUM expression to be at the end of the Department group.
The picture below shows the resulting charts for the Sales department and for all departments:
Example2
This example will also show expenses for a company’s departments as in example 1, but instead of showing separate charts for each department we will be showing expenses for each department as separate graphs on the same chart.
In this case we will also define the Department group as in the example 1 with the same group condition. We will define a chart in the Summary band of the report. This chart will show expenses of all departments. This is how we will define the data for this report:
For X axis:
ExpenseRecord.Date
For Y axis:
ExpenseRecord.Amount
We will also tick the “Support series” checkbox, click on the “Details” button, select the “Series of data determined by group” radio button and select the Department group. Then we will specify the following expression that will determine the name of each series ExpenseRecord.DepartmentName
. This is the crucial step – it will tell the Report Designer that it should combine data for every group on the same chart.
The resulting chart is shown on the picture below:
Example 3
In this example we will be designing a chart that will be showing patient’s records for a particular day in a hospital – heart rate and blood pressure measurements taken at different times during the day.
We assume that the PatientRecord business object has been defined with the following attributes:
- PatientName
- TimeTaken
- HeartRate
- BloodPressureLow
- BloodPressureHigh
We want to define a chart that will show all these measurements at once. We want to have one X-axis showing time of the day and we want to have separate Y-axis for heart rate, low blood pressure and high blood pressure values. This is how we can define the data for this chart:
For X axis:
PatientRecord.TimeTaken
For Y axis:
PatientRecord.HeartRate
Note that for Y-axis we can pick any of the attributes that we want to show – HeartRate, BloodPressureLow or BloodPressureHigh. We will also tick the “Support series” checkbox, click on the “Details” button, select the “Series of data determined by expressions” radio button and define the following additional data expression for Y-axis:
PatientRecord.BloodPressureLow
PatientRecord.BloodPressureHigh
We will also choose the name and color for each series. The resulting chart is shown on the picture below:
Defining other properties of the chart
The final step is to define other properties of the chart. These include the following:
- The title of the chart. You can define a static title, for example “Company Expenses” or you can define an expression similar to those you define in tag elements, for example
<<'Expenses for department ' + Company.DepartmentName>>
Expressions should be enclosed in tag symbols “<<” and “>>”
- Up to two subtitles of the chart. You can define a static text for a subtitle or an expression. If you do not want to define a subtitle leave it blank.
- Whether or not to include a legend for the chart
- Labels of the axes, font and colors of label marks
- Whether or not to include labels for values on the chart
- Whether or not to include gridlines
- Whether or not to include effects, such as 3D effect, gradient effects and others
- Other chart type specific properties
All different properties are grouped in tabs and you can switch between tabs to navigate to a different group of properties. The preview window will show you the result of your selection and will make it easier to understand what each of the properties mean.