Using FusionCharts PHP Class > Creating Drill-down charts |
In our previous example, we had used FusionCharts to plot a chart using data stored in database. We'll now extend that example itself to create a drill-down chart which can show more information. Before you go further with this page, we recommend you to please see the previous sections like "Basic Examples", Creating Data from Array" as we start off from concepts explained in those pages. If you recall from previous example, we were showing the sum of factory output in a Pie chart as under: |
In this example, we'll extend this example, so that when a user clicks on a Pie slice for a factory, he can drill down to see date wise production for that factory. |
Setting up the pie chart for Link |
To set up the pie chart to enable links for drill-down involves just minor tweaking of our previous BasicDBExample.php. We basically need to add the link attribute for each <set> element. We create a new page Default.php (in DB_DrillDown folder) from the previous page with the following code changes:
The code examples contained in this page are contained in Download Package > Code > PHPClass > DB_DrillDown folder. |
<?php # Connect to the Database # Create a pie 3d chart object # Set Relative Path of chart swf file. # Set chart attributes mysql_close($link); #Create the chart |
As you can see in the code above, we're doing the following: |
|
Please go through FusionCharts PHP Class API Reference section to know more about the functions used in the above code. |
Let's now shift our attention to Detailed.php page. |
Creating the detailed data chart page |
The page Detailed.php contains the following code: |
<?php //Request the factory Id from Querystring, we sent the FactoryId from Default.php # Set Relative Path of chart swf file. # Set chart attributes //Now, we get the data for that factory //Create the chart - Column2D using FusionCharts PHP Class |
Let's analyze the steps involved in the above code: |
|
Please go through FusionCharts PHP Class API Reference section to know more about the functions used in the above code. |
When you now run the app, you'll see the detailed page as under: |