|
Diagrams FastReport allows to insert diagrams into the report. For this purpose, the "TfrxChartObject" Let us illustrate a simple construction of a diagram using the following example. To perform this, we would need the "country.db" table from the "DBDEMOS" demo database distribution kit. The table contains data about countries, their area and population:
Let us create a new project in Delphi. Put the "TTable," "TfrxDBDataSet," and "TfrxReport" components on the form and then customize them: Table1: frxDBDataSet1: Let us enter the report designer and connect the data source in the "Report|Data " window. After that, put the "Diagram" object to the report list:
Let us set the object size (18x8 cm). To customize the object, call its editor by double-clicking on it.
The following items are denoted by figures in the picture: During the first activation, the editor window will contain an image shown in the picture. The first thing to be done is to add one or several series (one series in our example). To perform this, click the
As you can see, there are eight different types of series available. After adding the series, the bar 3 becomes active. Here you should specify, which data should be used for plotting. First of all, let us select the data set in the "Data set" pulldown. Fill the "X values" and "Y values" fields in the following way (they can also be selected from the pulldowns):
It is necessary to note here, that X-axis values can be of any type (string, for example), since they are informational. However, the Y-axis values must rigorously be of figure type. In our case (with circle diagram) the X-axis values are used for comments of inscriptions displaying, while only the Y-axis values are used for the diagram construction. Let us close the setting (click "OK" to close the editor), and then start report construction:
What can be improved in this report? First of all, it would be nice to sort values in descending order. Again, we enter the diagram editor and select the series in the upper part of the window. Now we select the required sorting mode:
If starting the report now, we would see that the data in the explaining table is sorted. |
||||||||||||