Dear taarus,
You can do as the following :
CREATE A NEW CHART IN DASHBOARD MODULE
Instruction :
1- Copy one of the chart files in modules/Charts/code that you want to create new chart. (There are 3 type of chart in modules/Charts/code is : Vertical bar chart (vBarF), pie chart (pieF), horizontal bar chart (hBarF)).
2- Rename it (for example: Chart_mychart.php).
3- Go into “predefined_charts.php” in modules/Charts/code and add new entry to $predefined_charts array: 'Chart_mychart' => array('type'=>'code','id'=>'Chart_mychart','label' =>'My Chart').
4- Go to your newly created “Chart-mychart.php” and replace all “original_chart”-variables with your “mychart”-term.
5- In modules/Charts/language/en_us.lang.php (or whatever language file you are using) you'll find variables to set titles and descriptions of your new chart. You need to search for the affected variables and add your names (e.g. LBL_MYCHART_TITLE and the value for it) and adjust the variables in the “Chart-mychart.php”
6- Go to your sugar system and open dashboard module.
7- “your chart” should now be visible in the “add a chart”-dropdown (the name in the menu is the “label” value you add in “predefined_charts.php).
8- Once your new chart is visible you can go on adding the required functionality to your file or adjusting the existing one.
9- The function ‘gen_xml’ generates the XML that is used to create the Flash-chart.
10- Create_chart at the very end of the file defines the type of chart being displayed.
11- The .fla-files are saved in include/charts.
12- To check your xml file has been create in the progress create new chart in ‘gen_xml’ function in C:\Program Files\sugarcrm-4.5.1b\htdocs\sugarcrm\cache\xml\ e19c31c8-526b-ae27-fabd-46112c233961_pipeline_by_mychart_2007_04_30_2010_0 1_01.xml.
CODING : (Example the Chart_pipeline_by_case_status)
Go to gen_xml() function to replace the query for your chart as below :
$query = " SELECT cases.status, users.user_name, cases.assigned_user_id, count(*) AS opp_count, count(*) AS total FROM users,cases ";
and in
PHP Code:
while($row = $opp->db->fetchByAssoc($result, -1, false)) {
// You need add the value important to support your chart here .
$sum = $row['total'];
if(!isset($stageArr[$row['status']]['row_total'])) {$stageArr[$row['status']]['row_total']=0;}
$stageArr[$row['status']][$row['assigned_user_id']]['opp_count'] = $row['opp_count'];
$stageArr[$row['status']][$row['assigned_user_id']]['total'] = $sum;
$stageArr[$row['status']]['people'][$row['assigned_user_id']] = $row['user_name'];
$stageArr[$row['status']]['row_total'] += $sum;
$usernameArr[$row['assigned_user_id']] = $row['user_name'];
$total += $sum;
}
PHP Code:
foreach ($datax as $key=>$translation) {
// You need add the value important to support your chart here to create a xml file.
if(isset($stageArr[$key]['row_total'])){$rowTotalArr[]=$stageArr[$key]['row_total'];}
$fileContents .= ' <dataRow title="'.$translation.'" endLabel="';
if(isset($stageArr[$key]['row_total'])){$fileContents .= $stageArr[$key]['row_total'];}
$fileContents .= '">'."\n";
if(isset($stageArr[$key]['people'])){
asort($stageArr[$key]['people']);
reset($stageArr[$key]['people']);
foreach ($stageArr[$key]['people'] as $nameKey=>$nameValue) {
$fileContents .= ' <bar id="'.$nameKey.'" totalSize="'.$stageArr[$key][$nameKey]['total'].'" altText="'.$nameValue.': '.format_number($stageArr[$key][$nameKey]['opp_count'], 0, 0).' '.$current_module_strings['LBL_CAS_NUMBER'].' '.$current_module_strings['LBL_CAS_IN_STATUS'].' '.$translation.'" url="index.php?module=Cases&action=index&assigned_user_id[]='.$nameKey.'&status='.urlencode($key).'&date_start='.$date_start.'&date_closed='.$date_end.'&query=true&searchFormTab=advanced_search"/>'."\n";
}
}
$fileContents .= ' </dataRow>'."\n";
}
and the last
PHP Code:
$return = create_chart($chart_size,$cache_file_name,$width,$height); // draw the chart.
Regards
Hanny
Bookmarks