In this tutorial we will show you how to create a chart to present report data in PHP Report Maker. We'll continue to use the Crosstab Report we created in the Crosstab Report tutorial and create a chart to show the total order amount by product category.
Steps to Create a Chart
1. Loading PHP Report Maker
Open PHP Report Maker and connect to the demo database.
2. Adding a Chart
To add a chart to a report, click the report in the database pane on the left, the tabbed Field Setup page and Chart Setup Page will show up on the right. Click the [Charts] tab to go the Chart Setup Page.
Click [+] button to add a new chart.
Enter chart [Name] (preferably alphanumerical characters only) as "OrdersByCategory"and [Caption] as "Orders By Category".
In this example we draw a column chart so we leave the [Chart type] setting unchanged at the default value - [Column 2D Chart].
Under [Category (X) Axis], select "CategoryName" for the [Category field] setting.
Under [Category (Y) Axis], select "Amount" for the [Value field] setting.
Check [Show labels] so we'll see the category names on the X axis.
Check [Show values] so we'll see the amount at the top of each column.
Check [Show hover] so we'll see a hovering box displaying the category name and its amount when we move the mouse over each column.
There are many other advanced chart properties for you to configure the chart, click [Advanced] tab to setup:
In this example, we rotate the category names (rotateLabels) and use slanted labels (slantLabels) on the X axis so they won't overlap each other.
3. PHP Script Generation
Go to the [Generate] tab, click the [Generate] button and PHP Report Maker will generate the required PHP scripts automatically.
4. Running the PHP Application
Click the "Reports" menu button and select "Quarterly Orders by Product" (or select the sub-menu "Orders By Category") to run the report and see the chart.