Adding drill-downs to charts is a pretty simple task once you know which properties need to be set. If we look at the following snippet of chart code, we’ll see the 3 properties that should be set to get drill-downs working.
require_once('include/SugarCharts/SugarChartFactory.php'); $sugarChart = SugarChartFactory::getInstance(); $sugarChart->base_url = array( 'module' => 'Opportunities', 'action' => 'index', 'query' => 'true', 'searchFormTab' => 'advanced_search', ); $sugarChart->url_params = array( 'assigned_user_id' => $current_user->id ); $sugarChart->group_by = array('sales_stage',true);
The first two lines of code instantiate our chart engine class. Line 3 sets up our base URL, the static part of the URL that we want to construct. In this case, we would be getting a base url that looks like this:
Line 8 sets any additional parameters that you might need to construct to get the proper URL. Here we are adding an assigned_user_id parameter to our url because this particular chart only returns data for the current user. Line 9, which is the group_by property, we set an array with 2 elements. The first element defines the database field that we are querying against and the second lets the charting engine know we want to enable drill-downs for this particular chart. The final url should look something like this:
When the user clicks on this segment of the chart, they will be taken to the Opportunities list view that is filtered by assigned_user_id and sales_stage.