| [ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 3 /********************************************************************************* 4 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 5 * ("License"); You may not use this file except in compliance with the License 6 * The Original Code is: vtiger CRM Open Source 7 * The Initial Developer of the Original Code is vtiger. 8 * Portions created by vtiger are Copyright (C) vtiger. 9 * All Rights Reserved. 10 * 11 ********************************************************************************/ 12 13 require_once ('config.php'); 14 require_once ('include/utils/GraphUtils.php'); 15 include_once ('Image/Graph.php'); 16 include_once ('Image/Canvas.php'); 17 18 //$tmp_dir=$root_directory."cache/images/"; 19 20 /** Function to render the Horizontal Graph 21 * Portions created by vtiger are Copyright (C) vtiger. 22 * All Rights Reserved. 23 * Contributor(s): ______________________________________.. 24 */ 25 function horizontal_graph($referdata,$refer_code,$width,$height,$left,$right,$top,$bottom,$title,$target_val,$cache_file_name,$html_image_name) 26 { 27 28 global $log,$root_directory,$lang_crm,$theme; 29 //We'll be getting the values in the form of a string separated by commas 30 $datay=explode("::",$referdata); // The datay values 31 $datax=explode("::",$refer_code); // The datax values 32 33 // The links values are given as string in the encoded form, here we are decoding it 34 $target_val=urldecode($target_val); 35 $target=explode("::",$target_val); 36 37 $alts=array(); 38 $temp=array(); 39 for($i=0;$i<count($datax);$i++) 40 { 41 $name=$datax[$i]; 42 $pos = substr_count($name," "); 43 $alts[]=$name."=%d"; 44 //If the daatx value of a string is greater, adding '\n' to it so that it'll cme inh 2nd line 45 if(strlen($name)>=14) 46 $name=substr($name, 0, 44); 47 if($pos>=2) 48 { 49 $val=explode(" ",$name); 50 $n=count($val)-1; 51 52 $x=""; 53 for($j=0;$j<count($val);$j++) 54 { 55 if($j != $n) 56 { 57 $x .=" ". $val[$j]; 58 } 59 else 60 { 61 $x .= "@#".$val[$j]; 62 } 63 } 64 $name = $x; 65 } 66 $name=str_replace("@#", "\n",$name); 67 $temp[]=$name; 68 } 69 $datax=$temp; 70 71 //datay is the values 72 //datax is the status 73 74 // Set the basic parameters of the graph 75 $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); 76 $imagemap = $canvas->getImageMap(); 77 $graph =& Image_Graph::factory('graph', $canvas); 78 $font =& $graph->addNew('font', calculate_font_name($lang_crm)); 79 // set the font size to 12 80 $font->setSize(8); 81 82 if($theme == "blue") 83 { 84 $font_color = "#212473"; 85 } 86 else 87 { 88 $font_color = "#000000"; 89 } 90 $font->setColor($font_color); 91 92 $graph->setFont($font); 93 $titlestr =& Image_Graph::factory('title', array($title,10)); 94 $plotarea =& Image_Graph::factory('plotarea',array( 95 'axis', 96 'axis', 97 'horizontal' 98 )); 99 $graph->add( 100 Image_Graph::vertical($titlestr, 101 $plotarea, 102 5 103 ) 104 ); 105 106 107 // Now create a bar plot 108 $max=0; 109 $xlabels = array(); 110 $dataset = & Image_Graph::factory('dataset'); 111 $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); 112 for($i=0;$i<count($datay); $i++) 113 { 114 $x=1+2*$i; 115 if($datay[$i]>=$max) $max=$datay[$i]; 116 $dataset->addPoint( 117 $x, 118 $datay[$i], 119 array( 120 'url' => $target[$i], 121 'alt' => $alts[$i] 122 ) 123 ); 124 // build the xaxis label array to allow intermediate ticks 125 $xlabels[$x] = $datax[$i]; 126 $xlabels[$x+1] = ''; 127 } 128 129 130 $bplot = & $plotarea->addNew('bar', $dataset); 131 $bplot->setFillStyle($fill); 132 133 //You can change the width of the bars if you like 134 $bplot->setBarWidth(50/count($datax),"%"); 135 $bplot->setPadding(array('top'=>20)); 136 137 // We want to display the value of each bar at the top 138 //$bplot->value->Show(); 139 //$bplot->value->SetFont(FF_FONT2,FS_BOLD,12); 140 //$bplot->value->SetAlign('left','center'); 141 //$bplot->value->SetColor("black","gray4"); 142 //$bplot->value->SetFormat('%d'); 143 144 //$graph->SetBackgroundGradient('#E5E5E5','white',GRAD_VER,BGRAD_PLOT); 145 $bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5'))); 146 //$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER); 147 148 //$graph->SetFrame(false); 149 //$graph->SetMarginColor('cadetblue2'); 150 //$graph->ygrid->SetFill(true,'azure1','azure2'); 151 //$graph->xgrid->Show(); 152 153 // Add the bar to the graph 154 //$graph->Add($bplot); 155 156 // Setup title 157 //$titlestr->setText($title); 158 159 // Setup X-axis 160 $xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X); 161 $yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); 162 $yaxis->setFontSize(10); 163 164 // Invert X-axis and put Y-axis at bottom 165 $xaxis->setInverted(true); 166 $yaxis->setAxisIntersection('max'); 167 168 // set grid 169 $gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y); 170 $gridY->setLineColor('#E5E5E5@0.5'); 171 $gridY2 =& $plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); 172 $gridY2->setFillColor('#66CDAA@0.2'); 173 174 175 // Add some grace to y-axis so the bars doesn't go 176 // all the way to the end of the plot area 177 $yaxis->forceMaximum(round(($max * 1.1) + 0.5)); 178 $ticks = get_tickspacing($max); 179 180 // First make the labels look right 181 $yaxis->setLabelInterval($ticks[0]); 182 $yaxis->setTickOptions(-5,0); 183 $yaxis->setLabelInterval($ticks[1],2); 184 $yaxis->setTickOptions(-2,0,2); 185 186 // Create the xaxis labels 187 $array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', 188 array($xlabels) 189 ); 190 191 // The fix the tick marks 192 $xaxis->setDataPreprocessor($array_data); 193 $xaxis->forceMinimum(0); 194 $xaxis->forceMaximum(2*count($datay)); 195 $xaxis->setLabelInterval(1); 196 $xaxis->setTickOptions(0,0); 197 $xaxis->setLabelInterval(2,2); 198 $xaxis->setTickOptions(5,0,2); 199 200 // set markers 201 $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); 202 $marker->setFillColor('000000@0.0'); 203 $marker->setBorderColor('000000@0.0'); 204 $marker->setFontSize(10); 205 // shift markers 10 pix right 206 $marker_pointing =& $graph->addNew('Image_Graph_Marker_Pointing', array(10,0,& $marker)); 207 $marker_pointing->setLineColor('000000@0.0'); 208 $bplot->setMarker($marker_pointing); 209 210 211 //Getting the graph in the form of html page 212 $img = $graph->done( 213 array( 214 'tohtml' => true, 215 'border' => 0, 216 'filename' => $cache_file_name, 217 'filepath' => '', 218 'urlpath' => '' 219 )); 220 save_image_map($cache_file_name.'.map', $img); 221 222 return $img; 223 } 224 225 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |