/** * Image_Graph_Simple [Constructor] * * @param int $width The width of the graph in pixels * @param int $height The height of the graph in pixels * @param ??? $plotType ??? * @param ??? $data ??? * @param string $title The title * @param string $lineColor Color for lines * @param string $fillColor Color for fills * @param ??? $font ??? */ function Image_Graph_Simple($width, $height, $plotType, $data, $title, $lineColor = 'black', $fillColor = 'white', $font = false) { parent::__construct($width, $height); $plotarea =& Image_Graph::factory('plotarea'); $dataset =& Image_Graph::factory('dataset', array($data)); if ($font === false) { $font =& Image_Graph::factory('Image_Graph_Font'); } elseif (is_string($font)) { $font =& Image_Graph::factory('ttf_font', $font); $font->setSize(8); } $this->setFont($font); $this->add(Image_Graph::vertical(Image_Graph::factory('title', array($title, array('size_rel' => 2))), $plotarea, 10)); $plotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y); $plot =& $plotarea->addNew($plotType, array(&$dataset)); $plot->setLineColor($lineColor); $plot->setFillColor($fillColor); $axisX =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $axisX->showLabel(IMAGE_GRAPH_LABEL_MINIMUM + IMAGE_GRAPH_LABEL_ZERO + IMAGE_GRAPH_LABEL_MAXIMUM); }
public static function getPieChart($xaxisData, $yaxisData, $title = '', $width = '', $height = '', $charttype = 'vertical', $cachedFileName = false, $target = false, $color = '') { global $log, $lang_crm, $default_charset; require_once 'include/utils/utils.php'; require_once 'include/utils/GraphUtils.php'; include_once 'Image/Graph.php'; include_once 'Image/Canvas.php'; if ($cachedFileName === false) { $cache_file_name = 'cache/images/pie_chart_' . time() . '.png'; } else { $cache_file_name = $cachedFileName; } if (empty($width)) { $width = '500'; } if (empty($height)) { $height = '400'; } if ($target === false) { $target = array(); } $alts = array(); $temp = array(); for ($i = 0; $i < count($xaxisData); $i++) { $name = html_entity_decode($xaxisData[$i], ENT_QUOTES, $default_charset); $pos = substr_count($name, " "); $alts[] = $name; //If the datax value of a string is greater, adding '\n' to it so that it'll come in 2nd line if (strlen($name) >= 14) { $name = substr($name, 0, 34); } if ($pos >= 2) { $val = explode(" ", $name); $n = count($val) - 1; $x = ""; for ($j = 0; $j < count($val); $j++) { if ($j != $n) { $x .= " " . $val[$j]; } else { $x .= "@#" . $val[$j]; } } $name = $x; } $name = str_replace("@#", "\n", $name); $temp[] = $name; } $xaxisData = $temp; $width = $width + $width / 5; $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); $imagemap = $canvas->getImageMap(); $graph =& Image_Graph::factory('graph', $canvas); $font =& $graph->addNew('font', calculate_font_name($lang_crm)); $font->setSize(8); $font->setColor($color); $graph->setFont($font); // create the plotarea layout $title =& Image_Graph::factory('title', array($title, 10)); $plotarea =& Image_Graph::factory('plotarea', array('category', 'axis')); $graph->add(Image_Graph::vertical($title, $plotarea, 5)); // To create unique lables we need to keep track of lable name and its count $uniquex = array(); // Generate colours $colors = color_generator(count($yaxisData), '#33DDFF', '#3322FF'); $dataset =& Image_Graph::factory('dataset'); $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); $sum = 0; $pcvalues = array(); for ($i = 0; $i < count($yaxisData); $i++) { $sum += $yaxisData[$i]; } for ($i = 0; $i < count($yaxisData); $i++) { // To have unique names even in case of duplicates let us add the id $datalabel = $xaxisData[$i]; $xaxisData_appearance = $uniquex[$xaxisData[$i]]; if ($xaxisData_appearance == null) { $uniquex[$xaxisData[$i]] = 1; } else { $datalabel = $xaxisData[$i] . ' [' . $xaxisData_appearance . ']'; $uniquex[$xaxisData[$i]] = $xaxisData_appearance + 1; } $dataset->addPoint($datalabel, $yaxisData[$i], array('url' => $target[$i], 'alt' => $alts[$i] . '=' . sprintf('%0.1f%%', 100 * $yaxisData[$i] / $sum))); $pcvalues[$yaxisData[$i]] = sprintf('%0.1f%%', 100 * $yaxisData[$i] / $sum); $fills->addColor($colors[$i]); } if ($sum == 0) { return null; } // create the pie chart and associate the filling colours $gbplot =& $plotarea->addNew('pie', $dataset); $plotarea->setPadding(array('top' => 0, 'bottom' => 0, 'left' => 0, 'right' => $width / 20)); $plotarea->hideAxis(); $gbplot->setFillStyle($fills); // format the data values $marker_array =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', array($pcvalues)); // set markers $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); $marker->setDataPreprocessor($marker_array); $marker->setFillColor('#FFFFFF'); $marker->setBorderColor($color); $marker->setFontColor($color); $marker->setFontSize(8); $pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker)); $gbplot->setMarker($pointingMarker); $legend_box =& $plotarea->addNew('legend'); $legend_box->setPadding(array('top' => 20, 'bottom' => 0, 'left' => 0, 'right' => 0)); $legend_box->setFillColor('#F5F5F5'); $legend_box->showShadow(); $img = $graph->done(array('tohtml' => true, 'border' => 0, 'filename' => $cache_file_name, 'filepath' => '', 'urlpath' => '')); return $img; }
* None specific * * $Id: plot_step.php,v 1.3 2005/08/03 21:21:52 nosey Exp $ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Step Chart Sample', 12)), Image_Graph::vertical($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 90), 5)); $Legend->setPlotarea($Plotarea); // create the dataset $Dataset[] =& Image_Graph::factory('random', array(10, 2, 5, false)); $Dataset[] =& Image_Graph::factory('random', array(10, 2, 5, false)); $Dataset[] =& Image_Graph::factory('random', array(10, 2, 5, false)); // create the 1st plot as smoothed area chart using the 1st dataset $Plot =& $Plotarea->addNew('Image_Graph_Plot_Step', array($Dataset, 'stacked')); // set a line color $Plot->setLineColor('gray'); $Fill =& Image_Graph::factory('Image_Graph_Fill_Array'); $Fill->addColor('red@0.2'); $Fill->addColor('blue@0.2'); $Fill->addColor('green@0.2'); $Plot->setFillStyle($Fill); // output the Graph
* @author Jesper Veggerby <*****@*****.**> * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: intersection_secondary_axis.php,v 1.5 2005/08/03 21:21:58 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(800, 600)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Testing Secondary Axis Intersection', 10)), $Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(3, 3)), 5)); $DS[0] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 0))); $DS[1] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 1))); $DS[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2))); $DS2[0] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 1))); $DS2[1] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2))); $DS2[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 1))); for ($row = 0; $row < 3; $row++) { for ($col = 0; $col < 3; $col++) { if (isset($DS[$col])) { $Plotarea =& $Matrix->getEntry($row, $col); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $AxisY->setLineColor('silver'); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX->setAxisIntersection($row < 1 ? 0 : 1, IMAGE_GRAPH_AXIS_Y_SECONDARY); $AxisX->setTitle("Intersect at\ny2=" . ($row < 1 ? '0' : '1'));
* * $Id: customize.php,v 1.4 2005/09/08 19:02:17 nosey Exp $ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(450, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Stacked Bar Chart with defined axis properties', 12)), $Plotarea = Image_Graph::factory('plotarea'), 5)); $MarkerX =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', null, IMAGE_GRAPH_AXIS_X); $MarkerX->setFillColor('blue@0.3'); $MarkerX->setLineColor('blue@0.3'); $MarkerX->setLowerBound(7); $MarkerX->setUpperBound(8); $MarkerY =& $Plotarea->addNew('Image_Graph_Axis_Marker_Area', null, IMAGE_GRAPH_AXIS_Y); $MarkerY->setFillColor('green@0.3'); $MarkerY->setLineColor('green@0.3'); $MarkerY->setLowerBound(5.2); $MarkerY->setUpperBound(9.300000000000001); $MarkerY =& $Plotarea->addNew('Image_Graph_Axis_Marker_Line', null, IMAGE_GRAPH_AXIS_Y); $MarkerY->setLineColor('red'); $MarkerY->setValue(14.4); // create the 1st plot as smoothed area chart using the 1st dataset $Plot1 =& $Plotarea->add(Image_Graph::factory('bar', array($Dataset = array(Image_Graph::factory('random', array(8, 1, 10, false)), Image_Graph::factory('random', array(8, 1, 10, false)), Image_Graph::factory('random', array(8, 1, 10, false))), 'stacked')));
/** Function to render the Horizontal Graph */ function pie_chart($referdata, $refer_code, $width, $height, $left, $right, $top, $bottom, $title, $target_val, $cache_file_name, $html_image_name) { global $log, $root_directory, $lang_crm, $theme; //We'll be getting the values in the form of a string separated by commas $datay = explode("::", $referdata); // The datay values $datax = explode("::", $refer_code); // The datax values $target_val = urldecode($target_val); $target = explode("::", $target_val); $alts = array(); $temp = array(); for ($i = 0; $i < count($datax); $i++) { $name = $datax[$i]; $pos = substr_count($name, " "); $alts[] = htmlentities($name) . "=%d"; //If the datax value of a string is greater, adding '\n' to it so that it'll come in 2nd line if (strlen($name) >= 14) { $name = substr($name, 0, 34); } if ($pos >= 2) { $val = explode(" ", $name); $n = count($val) - 1; $x = ""; for ($j = 0; $j < count($val); $j++) { if ($j != $n) { $x .= " " . $val[$j]; } else { $x .= "@#" . $val[$j]; } } $name = $x; } $name = str_replace("@#", "\n", $name); $temp[] = $name; } $datax = $temp; if ($theme == "blue") { $font_color = "#212473"; } else { $font_color = "#000000"; } $width = $width + 140; $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); $imagemap = $canvas->getImageMap(); $graph =& Image_Graph::factory('graph', $canvas); $font =& $graph->addNew('font', calculate_font_name($lang_crm)); // set the font size to 11 pixels $font->setSize(8); $font->setColor($font_color); $graph->setFont($font); // create the plotarea layout $title =& Image_Graph::factory('title', array($title, 10)); $plotarea =& Image_Graph::factory('plotarea', array('category', 'axis')); $footer =& Image_Graph::factory('title', array('Footer', 8)); $legend_box =& Image_Graph::factory('legend'); $graph->add(Image_Graph::vertical($title, $plotarea, 5)); // To create unique lables we need to keep track of lable name and its count $uniquex = array(); // Generate colours $colors = color_generator(count($datay), '#33DDFF', '#3322FF'); $dataset =& Image_Graph::factory('dataset'); $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); $sum = 0; for ($i = 0; $i < count($datay); $i++) { if (isset($_REQUEST['display_view']) && $_REQUEST['display_view'] == 'MATRIX') { $datax[$i] = trim($datax[$i]); if (strlen($datax[$i]) <= 10) { $datax[$i] = $datax[$i]; } else { $datax[$i] = substr($datax[$i], 0, 10) . ".."; } } // To have unique names even in case of duplicates let us add the id $datalabel = $datax[$i]; $datax_appearance = $uniquex[$datax[$i]]; if ($datax_appearance == null) { $uniquex[$datax[$i]] = 1; } else { $datalabel = $datax[$i] . ' [' . $datax_appearance . ']'; $uniquex[$datax[$i]] = $datax_appearance + 1; } $dataset->addPoint($datalabel, $datay[$i], array('url' => $target[$i], 'alt' => $alts[$i])); $sum += $datay[$i]; $fills->addColor($colors[$i]); } // create an array with % values $pcvalues = array(); for ($i = 0; $i < count($datay); $i++) { $pcvalues[$datay[$i]] = sprintf('%0.1f%%', 100 * $datay[$i] / $sum); } // create the pie chart and associate the filling colours $gbplot =& $plotarea->addNew('pie', $dataset); $plotarea->setPadding(array('top' => 20, 'bottom' => 0, 'left' => 0, 'right' => 50)); $plotarea->hideAxis(); $gbplot->setFillStyle($fills); // format the data values $marker_array =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', array($pcvalues)); // set markers $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); $marker->setDataPreprocessor($marker_array); $marker->setFillColor('#FFFFFF'); $marker->setBorderColor($font_color); $marker->setFontColor($font_color); $marker->setFontSize(8); $pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker)); $gbplot->setMarker($pointingMarker); // set legend $legend_box =& $plotarea->addNew('legend'); $legend_box->setPadding(array('top' => 20, 'bottom' => 0, 'left' => 0, 'right' => 0)); $legend_box->setFillColor('#F5F5F5'); $legend_box->showShadow(); $img = $graph->done(array('tohtml' => true, 'border' => 0, 'filename' => $cache_file_name, 'filepath' => '', 'urlpath' => '')); save_image_map($cache_file_name . '.map', $img); return $img; }
* $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; require_once 'Image/Canvas.php'; $Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 300, 'antialias' => 'native')); // create the graph $Graph =& Image_Graph::factory('graph', $Canvas); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Spider/Radar Chart Sample', 12)), Image_Graph::vertical($Plotarea = Image_Graph::factory('Image_Graph_Plotarea_Radar'), $Legend = Image_Graph::factory('legend'), 90), 5)); $Legend->setPlotarea($Plotarea); $Plotarea->addNew('Image_Graph_Grid_Polar', IMAGE_GRAPH_AXIS_Y); // create the dataset $DS1 =& Image_Graph::factory('dataset'); $DS1->addPoint('Life', rand(1, 6)); $DS1->addPoint('Universe', rand(1, 6)); $DS1->addPoint('Everything', rand(1, 6)); $DS1->addPoint('Something', rand(1, 6)); $DS1->addPoint('Nothing', rand(1, 6)); $DS1->addPoint('Irrelevevant', rand(1, 6)); $DS2 =& Image_Graph::factory('dataset'); $DS2->addPoint('Life', rand(1, 6)); $DS2->addPoint('Universe', rand(1, 6)); $DS2->addPoint('Everything', rand(1, 6)); $DS2->addPoint('Something', rand(1, 6));
* @author Jesper Veggerby <*****@*****.**> * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id$ * @link http://pear.php.net/package/Image_Graph */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(600, 600)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Testing Axis Inversion', 10)), $Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(4, 3)), 5)); $DS[0] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 2, '2' => 0))); $DS[1] =& Image_Graph::factory('dataset', array(array('0' => -1, '1' => 2, '2' => 2))); $DS[2] =& Image_Graph::factory('dataset', array(array('0' => 1, '1' => 3, '2' => 2))); for ($row = 0; $row < 4; $row++) { for ($col = 0; $col < 3; $col++) { if (isset($DS[$col])) { $Plotarea =& $Matrix->getEntry($row, $col); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); if ($row >= 1) { $AxisY->setInverted(true); $AxisY->setTitle('Inverted Y', 'vertical'); } else { $AxisY->setTitle('Normal Y', 'vertical'); }
* * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ error_reporting(E_ALL); require_once 'Image/Graph.php'; require_once 'Image/Canvas.php'; $Canvas =& Image_Canvas::factory('cpdf', array('page' => 'A3', 'align' => 'center', 'width' => 600, 'height' => 400)); // create the graph $Graph =& Image_Graph::factory('graph', $Canvas); $Font =& $Graph->addNew('font', 'Verdana'); $Font->setSize(7); $Graph->setFont($Font); $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Image_Graph Demonstration', 12)), Image_Graph::vertical(Image_Graph::vertical($Plotarea_Weather = Image_Graph::factory('plotarea'), $Legend_Weather = Image_Graph::factory('legend'), 85), Image_Graph::horizontal(Image_Graph::vertical(Image_Graph::vertical(Image_Graph::factory('title', array('Demonstration of Mathematical Functions', 10)), $Plotarea_SinCos = Image_Graph::factory('plotarea', 'axis'), 5), $Legend_SinCos = Image_Graph::factory('legend'), 90), $Plotarea_Car = Image_Graph::factory('plotarea'), 50), 60), 5)); $Legend_Weather->setPlotarea($Plotarea_Weather); $Legend_Weather->setFontSize(7); $Legend_SinCos->setPlotarea($Plotarea_SinCos); $Legend_SinCos->setFontSize(8); $GridY_Weather =& $Plotarea_Weather->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y); $GridY_Weather->setLineColor('gray@0.1'); $Marker_AverageSpan =& $Plotarea_Weather->addNew('Image_Graph_Axis_Marker_Area', IMAGE_GRAPH_AXIS_Y); $Marker_AverageSpan->setFillColor('green@0.2'); $Marker_AverageSpan->setLowerBound(3.8); $Marker_AverageSpan->setUpperBound(11.4); $Marker_Average =& $Plotarea_Weather->addNew('Image_Graph_Axis_Marker_Line', IMAGE_GRAPH_AXIS_Y); $Marker_Average->setLineColor('blue@0.4'); $Marker_Average->setValue(7.7); $Dataset_Rainfall =& Image_Graph::factory('dataset'); $Dataset_Rainfall->addPoint('Jan', 60);
/** * A method to visually test the compensatedPriorities() method. * * Tests a series of operation intervals for a zone where some ads are limited * to appear only in certain "channels" of the zone, and display the results * graphically. Uses a changing number of impressions in the zone each operation * interval. */ function testCompensatedPrioritiesSharpChangingZoneInvetory() { $conf = $GLOBALS['_MAX']['CONF']; // Mock the OA_Dal_Maintenance_Priority class $oDal = new MockOA_Dal_Maintenance_Priority($this); $oServiceLocator =& OA_ServiceLocator::instance(); $oServiceLocator->register('OA_Dal_Maintenance_Priority', $oDal); // Partially mock the OA_Maintenance_Priority_AdServer_Task_PriorityCompensation class $oPriorityCompensation = new PartialMock_OA_Maintenance_Priority_AdServer_Task_PriorityCompensation($this); $oPriorityCompensation->setReturnReference('_getDal', $oDal); $oPriorityCompensation->OA_Maintenance_Priority_AdServer_Task_PriorityCompensation(); // Define the number of iterations to test over $iterations = 48; // Define the maximum number of impressions in the zone $maxZoneImpressions = 10000; // Define the maximum number of impressions in the zone $minZoneImpressions = 1000; // Define the zone impression period $zoneImpressionPeriod = 24; // Define the channels, including the % of zone impressions in each $aChannels[1] = 0.1; // Channel 1: 10% of zone traffic $aChannels[2] = 0.02; // Channel 2: 2% of zone traffic // Define the ads, including the required impressions each iteration, // the channel the ad is limited to (if any) and the colour to use in // the graph of results $aAds[1] = array('impressions' => 5000, 'channel' => null, 'colour' => 'red'); $aAds[2] = array('impressions' => 1500, 'channel' => 1, 'colour' => 'blue'); $aAds[3] = array('impressions' => 750, 'channel' => 2, 'colour' => 'green'); // Preapare the graph data sets, ready to accept test data foreach ($aAds as $adKey => $aAdData) { // Add the new data to the graph of the results $dataSetName = 'oDataSet_Ad' . $adKey . '_RequiredImpressions'; ${$dataSetName} =& Image_Graph::factory('dataset'); ${$dataSetName}->setName('Ad ' . $adKey . ': Required Impressions'); $dataSetName = 'oDataSet_Ad' . $adKey . '_AvailableImpressions'; ${$dataSetName} =& Image_Graph::factory('dataset'); ${$dataSetName}->setName('Ad ' . $adKey . ': Available Impressions'); $dataSetName = 'oDataSet_Ad' . $adKey . '_ActualImpressions'; ${$dataSetName} =& Image_Graph::factory('dataset'); ${$dataSetName}->setName('Ad ' . $adKey . ': Delivered Impressions'); } $oDataSetBestError =& Image_Graph::factory('dataset'); $oDataSetBestError->setName('Least Possible Error In Delivery'); $oDataSetTotalError =& Image_Graph::factory('dataset'); $oDataSetTotalError->setName('Total Error In Delivery'); // Prepare the ads/zone for the initial iteration $thisZoneImpressions = $minZoneImpressions; $oZone = new OX_Maintenance_Priority_Zone(array('zoneid' => 1)); $oZone->availableImpressions = $thisZoneImpressions; foreach ($aAds as $adKey => $aAdData) { $oAd = new OA_Maintenance_Priority_Ad(array('ad_id' => $adKey)); $oAd->requiredImpressions = $aAdData['impressions']; $oAd->requestedImpressions = $aAdData['impressions']; $oZone->addAdvert($oAd); } $result = $oPriorityCompensation->compensatedPriorities($oZone); // Perform the iterations for ($iteration = 1; $iteration <= $iterations; $iteration++) { // Calculate how many impressions will be delivered for each ad foreach ($aAds as $adKey => $aAdData) { $aDelivered[$adKey] = 0; } $this->_predictDelivery($aDelivered, $thisZoneImpressions, $aAds, $aChannels, $result, $oPriorityCompensation); // Add the new data to the graph of the results $bestError = 0; $totalError = 0; foreach ($aAds as $adKey => $aAdData) { $dataSetName = 'oDataSet_Ad' . $adKey . '_RequiredImpressions'; ${$dataSetName}->addPoint($iteration, $aAds[$adKey]['impressions']); $dataSetName = 'oDataSet_Ad' . $adKey . '_AvailableImpressions'; if (is_null($aAdData['channel'])) { ${$dataSetName}->addPoint($iteration, $thisZoneImpressions); } else { ${$dataSetName}->addPoint($iteration, $thisZoneImpressions * $aChannels[$aAdData['channel']]); } $dataSetName = 'oDataSet_Ad' . $adKey . '_ActualImpressions'; ${$dataSetName}->addPoint($iteration, $aDelivered[$adKey]); if (!is_null($aAdData['channel']) && $thisZoneImpressions * $aChannels[$aAdData['channel']] < $aAds[$adKey]['impressions']) { $bestError += abs($thisZoneImpressions * $aChannels[$aAdData['channel']] - $aAds[$adKey]['impressions']); } $totalError += abs($oZone->aAdverts[$adKey]->requiredImpressions - $aDelivered[$adKey]); } $oDataSetBestError->addPoint($iteration, $bestError); $oDataSetTotalError->addPoint($iteration, $totalError); // Prepare the ads/zone for the next iteration $previousZoneImpressions = $thisZoneImpressions; if ($iteration == 1) { $thisZoneImpressions = $this->_predictSharpZoneInventory($minZoneImpressions, $maxZoneImpressions, $zoneImpressionPeriod, $iteration); } else { $thisZoneImpressions = $this->_predictSharpZoneInventory($minZoneImpressions, $maxZoneImpressions, $zoneImpressionPeriod, $iteration); } $oZone = new OX_Maintenance_Priority_Zone(array('zoneid' => 1)); $oZone->availableImpressions = $thisZoneImpressions; foreach ($aAds as $adKey => $aAdData) { $oAd = new OA_Maintenance_Priority_Ad(array('ad_id' => $adKey)); $oAd->requiredImpressions = $aAdData['impressions']; $oAd->requestedImpressions = $aAdData['impressions']; $oAd->pastRequiredImpressions = $aAdData['impressions']; $oAd->pastRequestedImpressions = $aAdData['impressions']; $oAd->pastActualImpressions = $aDelivered[$adKey]; $oAd->pastAdZonePriorityFactor = $result['ads'][$adKey]['priority_factor']; $oAd->pastZoneTrafficFraction = $result['ads'][$adKey]['past_zone_traffic_fraction']; $oZone->addAdvert($oAd); } $result = $oPriorityCompensation->compensatedPriorities($oZone); } // Prepare the graph $oCanvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 480, 'antialias' => false)); $oGraph =& Image_Graph::factory('graph', $oCanvas); if (function_exists('imagettfbbox') && isset($conf['graphs']['ttfName'])) { $oFont =& $oGraph->addNew('ttf_font', $conf['graphs']['ttfName']); $oFont->setSize(9); $oGraph->setFont($oFont); } $oGraph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Priority Compensation in Fixed Impression Zone', 12)), Image_Graph::vertical($oPlotarea = Image_Graph::factory('plotarea', array('axis', 'axis_log')), $oLegend = Image_Graph::factory('legend'), 80), 10)); $oLegend->setPlotarea($oPlotarea); $oGridLines =& $oPlotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_X); $oGridLines =& $oPlotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y); $oAxis =& $oPlotarea->getAxis(IMAGE_GRAPH_AXIS_X); $oAxis->setTitle('Operation Intervals'); $oAxis =& $oPlotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $oAxis->setTitle('Impressions', 'vertical'); $counter = 1; $aAxisLabels = array(); while ($counter < $maxZoneImpressions) { $counter *= 10; $aAxisLabels[] = $counter; } $oAxis->setLabelInterval($aAxisLabels); // Ad the data sets to the graph foreach ($aAds as $adKey => $aAdData) { $dataSetName = 'oDataSet_Ad' . $adKey . '_RequiredImpressions'; $oPlot =& $oPlotarea->addNew('line', ${$dataSetName}); $oLineStyle =& Image_Graph::factory('Image_Graph_Line_Dashed', array($aAdData['colour'], 'transparent')); $oPlot->setLineStyle($oLineStyle); $dataSetName = 'oDataSet_Ad' . $adKey . '_AvailableImpressions'; $oPlot =& $oPlotarea->addNew('line', ${$dataSetName}); $oLineStyle =& Image_Graph::factory('Image_Graph_Line_Dotted', array($aAdData['colour'], 'transparent')); $oPlot->setLineStyle($oLineStyle); $dataSetName = 'oDataSet_Ad' . $adKey . '_ActualImpressions'; $oPlot =& $oPlotarea->addNew('line', ${$dataSetName}); $oPlot->setLineColor($aAdData['colour']); } $oPlot =& $oPlotarea->addNew('line', $oDataSetBestError); $oLineStyle =& Image_Graph::factory('Image_Graph_Line_Dotted', array('magenta', 'transparent')); $oPlot->setLineStyle($oLineStyle); $oPlot =& $oPlotarea->addNew('line', $oDataSetTotalError); $oPlot->setLineColor('magenta'); $oPlotarea->setFillColor('white'); $filename = "results/" . __CLASS__ . '_' . __FUNCTION__ . ".png"; $oGraph->done(array('filename' => MAX_PATH . '/tests/' . $filename)); echo '<img src="' . $filename . '" alt="" />' . "\n"; }
* None specific * * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; require_once 'Image/Canvas.php'; $Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 200)); // create the graph $Graph =& Image_Graph::factory('graph', $Canvas); $Font =& $Graph->addNew('font', 'Verdana'); $Font->setSize(8); $Graph->setFont($Font); $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Gradient Filled Step Chart', 11)), Image_Graph::horizontal($Plotarea = Image_Graph::factory('plotarea'), Image_Graph::factory('title', array('Anybody recognize?', array('size' => 7, 'color' => 'gray@0.6', 'angle' => 270))), 98), 5)); $Grid =& $Plotarea->addNew('line_grid', array(), IMAGE_GRAPH_AXIS_Y); $Grid->setLineColor('white@0.4'); $Dataset =& Image_Graph::factory('dataset'); $Dataset->addPoint(1, 20); $Dataset->addPoint(2, 10); $Dataset->addPoint(3, 35); $Dataset->addPoint(4, 5); $Dataset->addPoint(5, 18); $Dataset->addPoint(6, 33); $Plot =& $Plotarea->addNew('step', array(&$Dataset)); $Fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'darkgreen', 'white')); $Plot->setFillStyle($Fill); $Fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'yellow', 'darkred')); $Plotarea->setFillStyle($Fill); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
* @author Jesper Veggerby <*****@*****.**> * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: category.php,v 1.4 2005/08/03 21:21:58 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Testing Category Axis', 10)), $Plotarea = Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'Image_Graph_Axis_Category')), 5)); $DS =& Image_Graph::factory('dataset'); $DS->addPoint('Germany', 'England'); $DS->addPoint('Denmark', 'France'); $DS->addPoint('Sweden', 'Denmark'); $DS->addPoint('England', 'France'); $DS->addPoint('Norway', 'Finland'); $DS->addPoint('Denmark', 'Finland'); $DS->addPoint('Iceland', 'Germany'); $DS->addPoint('Norway', 'France'); $DS2 =& Image_Graph::factory('dataset'); $DS2->addPoint('Sweden', 'France'); $DS2->addPoint('Austria', 'Germany'); $DS2->addPoint('Norway', 'Holland'); $DS2->addPoint('Denmark', 'Germany'); $DS2->addPoint('Sweden', 'Holland');
$Graph =& Image_Graph::factory('graph', array(600, 300)); $Graph->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'lightsteelblue', 'papayawhip'))); // create a random dataset to use for demonstrational purposes $DataSet =& Image_Graph::factory('function', array(1, 9, 'salaries', 8)); $DataSet2 =& Image_Graph::factory('dataset'); $DataSet2->addPoint('CEO', 10); $DataSet2->addPoint('TAP', 32); $DataSet2->addPoint('TBF', 13); $DataSet2->addPoint('ABC', 19); $DataSet2->addPoint('QED', 26); // create and set the plot font $Font =& $Graph->addNew('font', 'Verdana'); $Font->setSize(7); $Graph->setFont($Font); // add a plot area in a vertical layout to display a title on top $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Annual income', 11)), Image_Graph::horizontal($Plotarea = Image_Graph::factory('plotarea'), Image_Graph::vertical($Plotarea2 = Image_Graph::factory('plotarea'), $Legend2 = Image_Graph::factory('legend'), 90)), 5), 5); $Legend2->setPlotarea($Plotarea2); // create a bar grid and fill it with a gradient fill white->lightgray $Grid =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); $Grid->setFillColor('gray@0.2'); $Plotarea->setFillColor('gray@0.2'); // add a line plot to the plotarea based on the function dataset $Plot =& $Plotarea->addNew('line', array(&$DataSet)); // add coins-icon as marker $Plot->setMarker(Image_Graph::factory('Image_Graph_Marker_Icon', './images/coins.png')); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); // make x-axis start at 0 $AxisX->forceMinimum(0); // make x-axis end at 9 $AxisX->forceMaximum(9);
* * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Gradient filled smoothed area chart', 12)), Image_Graph::vertical($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 85), 8)); $Legend->setPlotarea($Plotarea); // create the 1st dataset $Dataset =& Image_Graph::factory('random', array(10, 40, 100, true)); // create the 1st plot as smoothed area chart using the 1st dataset $Plot =& $Plotarea->addNew('smooth_area', array(&$Dataset)); // create a vertical gradient fill using red and yellow, ie bottom of graph // will be yellow and the 'higher' the value the more red it will be, ie a 'fire' effect $Plot->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green', 'lightyellow'))); $Plot->setTitle('Inside scope'); // create the 2nd dataset $Dataset2 =& Image_Graph::factory('random', array(10, 50, 70, true)); // create the 2nd plot as smoothed area chart using the 2nd dataset $Plot2 =& $Plotarea->addNew('smooth_area', array(&$Dataset2)); // create a vertical gradient fill using red and yellow, ie bottom of graph // will be yellow and the 'higher' the value the more red it will be, ie a 'fire' effect
* * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Negative Stacked Bar Chart', 10)), $Plotarea = Image_Graph::factory('plotarea'), 5)); $Dataset[0] =& Image_Graph::factory('dataset'); $Dataset[1] =& Image_Graph::factory('dataset'); $Dataset[2] =& Image_Graph::factory('dataset'); $Dataset[0]->addPoint('A', 1); $Dataset[0]->addPoint('B', 4); $Dataset[0]->addPoint('C', -1); $Dataset[0]->addPoint('D', 2); $Dataset[0]->addPoint('E', 1); $Dataset[0]->addPoint('F', 2); $Dataset[0]->addPoint('G', 3); $Dataset[1]->addPoint('A', 2); $Dataset[1]->addPoint('B', -3); $Dataset[1]->addPoint('C', -2); $Dataset[1]->addPoint('D', 3); $Dataset[1]->addPoint('E', 3);
* @author Jesper Veggerby <*****@*****.**> * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: labelinterval.php,v 1.4 2005/08/03 21:21:58 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(800, 600)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', 'Verdana'); // set the font size to 7 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Testing Changing Axis Label Intervals (Bar Charts also test label distance)', 10)), $Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(4, 4)), 5)); $DS[0] =& Image_Graph::factory('dataset', array(array(0 => 1, 1 => 2, 2 => 0, 3 => 1, 4 => 4))); $DS[1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 1, 'E' => 4))); $DS[2] =& Image_Graph::factory('dataset', array(array(0 => 1, 1 => 2, 2 => -2, 3 => 1, 4 => 4))); $DS[3] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => -2, 'D' => 1, 'E' => 4))); for ($row = 0; $row < 4; $row++) { for ($col = 0; $col < 4; $col++) { if (isset($DS[$col])) { $Plotarea =& $Matrix->getEntry($row, $col); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); if ($row > 2) { $AxisX->setLabelInterval(3); $AxisX->setTitle('"Odd" interval'); } elseif ($row > 0) { $AxisX->setLabelInterval(2);
* * Other: * None specific * * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(600, 400)); $Font =& $Graph->addNew('font', 'Verdana'); $Font->setSize(9); $Graph->setFont($Font); $Graph->add(Image_Graph::vertical(Image_Graph::vertical(Image_Graph::factory('title', array('Weather Conditions by Month', 12)), Image_Graph::factory('title', array('Location: Århus, Denmark', 8)), 80), Image_Graph::vertical($Plotarea_Weather = Image_Graph::factory('plotarea'), $Legend_Weather = Image_Graph::factory('legend'), 85), 9)); $Legend_Weather->setPlotarea($Plotarea_Weather); $GridY_Weather =& $Plotarea_Weather->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y); $GridY_Weather->setLineColor('gray@0.1'); $Dataset_TempAvg =& Image_Graph::factory('dataset'); $Dataset_TempAvg->addPoint('Jan', 0.2); $Dataset_TempAvg->addPoint('Feb', 0.1); $Dataset_TempAvg->addPoint('Mar', 2.3); $Dataset_TempAvg->addPoint('Apr', 5.8); $Dataset_TempAvg->addPoint('May', 10.8); $Dataset_TempAvg->addPoint('Jun', 14.1); $Dataset_TempAvg->addPoint('Jul', 16.2); $Dataset_TempAvg->addPoint('Aug', 15.9); $Dataset_TempAvg->addPoint('Sep', 12.1); $Dataset_TempAvg->addPoint('Oct', 8.699999999999999); $Dataset_TempAvg->addPoint('Nov', 4.4);
protected function GenerateReport_Graph($param, $format, $query, $params = NULL) { freemed::acl_enforce('reporting', 'write'); // Execute query $res = $GLOBALS['sql']->queryAllStoredProc($query); // Get keys foreach ($res[0] as $k => $v) { if (!is_integer($k)) { $ks[] = $k; } } $primary_key = $ks[0]; unset($ks[0]); foreach ($ks as $v) { $keys[] = $v; } // Create Image_Graph LoadObjectDependency('net.php.pear.Image_Graph'); $g =& Image_Graph::factory('graph', array(800, 600)); $f =& $g->addNew('ttf_font', dirname(__FILE__) . '/../data/fonts/FreeSans.ttf'); $f->setSize(10); $g->setFont($f); $g->add(Image_Graph::vertical(Image_Graph::vertical(Image_Graph::factory('title', array($param['report_name'], 12)), Image_Graph::factory('title', array(__('Generated') . ' ' . date('r'), 8)), 80), Image_Graph::vertical($plotarea = Image_Graph::factory('plotarea'), $legend = Image_Graph::factory('legend'), 85), 5)); $legend->setPlotarea($plotarea); // Fancy background stuff $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); $FillArray->addColor('blue@0.2'); $FillArray->addColor('yellow@0.2'); $FillArray->addColor('green@0.2'); $plotarea->setFillStyle($FillArray); $plotarea->setFillColor('silver@0.3'); $Grid =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_X); $Grid->setLineColor('silver'); foreach ($keys as $k => $v) { $data[$k] =& Image_Graph::factory('dataset'); $data[$k]->setName($v); // Load data foreach ($res as $r) { $data[$k]->addPoint($r[$primary_key], $r[$v]); } $plot[$k] =& $plotarea->addNew('line', array($data[$k])); //$plot[$k] =& $plotarea->addNew( 'Image_Graph_Plot_Smoothed_Area', array( $data[ $k ] ) ); } // Check plot colors $colors = array('red', 'blue', 'green', 'yellow', 'purple', 'black', 'orange'); foreach ($plot as $k => $v) { $plot[$k]->setLineColor($colors[$k]); //$plot[ $k ]->setFillColor( $colors[ $k ].'@0.3' ); } $g->setPadding(10); $g->done(); }
* * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Gradient Filled Donut/Pie Chart', 12)), Image_Graph::horizontal($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 60), 5)); $Legend->setPlotarea($Plotarea); $Legend->setAlignment(IMAGE_GRAPH_ALIGN_VERTICAL); // create the dataset $Dataset =& Image_Graph::factory('dataset'); $Dataset->addPoint('Beef', rand(1, 10), 'beef'); $Dataset->addPoint('Pork', rand(1, 10), 'pork'); $Dataset->addPoint('Poultry', rand(1, 10), 'poultry'); $Dataset->addPoint('Camels', rand(1, 10), 'camels'); $Dataset->addPoint('Other', rand(1, 10), 'other'); // create the dataset $Dataset2 =& Image_Graph::factory('dataset'); $Dataset2->addPoint('Beer', rand(1, 10), 'beer'); $Dataset2->addPoint('Wine', rand(1, 10), 'wine'); $Dataset2->addPoint('Alcohol', rand(1, 10), 'alcohol'); $Dataset2->addPoint('Coffee', rand(1, 10), 'coffee');
/** * Creates pie chart image of opportunities by lead_source. * param $datax- the sales stage data to display in the x-axis * param $datay- the sum of opportunity amounts for each opportunity in each sales stage * to display in the y-axis * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.. * All Rights Reserved.. * Contributor(s): ______________________________________.. */ function pipeline_by_lead_source($legends = array('foo', 'bar'), $user_id = array('1'), $cache_file_name = 'a_file', $refresh = true, $width = 900, $height = 500) { global $log, $current_user; $log->debug("Entering pipeline_by_lead_source(" . $legends . ") method ..."); global $app_strings, $lang_crm, $current_module_strings, $log, $charset, $tmp_dir; global $theme; include_once 'Image/Graph.php'; include_once 'Image/Canvas.php'; $font = calculate_font_name($lang_crm); if (!file_exists($cache_file_name) || !file_exists($cache_file_name . '.map') || $refresh == true) { $log =& LoggerManager::getLogger('opportunity charts'); $log->debug("starting pipeline chart"); $log->debug("legends is:"); $log->debug($legends); $log->debug("user_id is: "); $log->debug($user_id); $log->debug("cache_file_name is: {$cache_file_name}"); //Now do the db queries //query for opportunity data that matches $legends and $user $where = ""; //build the where clause for the query that matches $datax $count = count($legends); if ($count > 0) { $where .= " leadsource in ( "; $ls_i = 0; foreach ($legends as $key => $value) { if ($ls_i != 0) { $where .= ", "; } $where .= "'" . addslashes($key) . "'"; $ls_i++; } $where .= ")"; } $opp = new Potentials(); $opp_list = $opp->get_full_list("vtiger_potential.amount DESC, vtiger_potential.closingdate DESC", $where); //build pipeline by lead source data $total = 0; $count = array(); $sum = array(); if (isset($opp_list)) { foreach ($opp_list as $record) { if (!isset($sum[$record->column_fields['leadsource']])) { $sum[$record->column_fields['leadsource']] = 0; } if (isset($record->column_fields['amount']) && isset($record->column_fields['leadsource'])) { // Strip all non numbers from this string. $amount = CurrencyField::convertFromMasterCurrency(preg_replace('/[^0-9]/', '', floor($record->column_fields['amount'])), $current_user->conv_rate); $sum[$record->column_fields['leadsource']] = $sum[$record->column_fields['leadsource']] + $amount / 1000; if (isset($count[$record->column_fields['leadsource']])) { $count[$record->column_fields['leadsource']]++; } else { $count[$record->column_fields['leadsource']] = 1; } $total = $total + $amount / 1000; } } } $visible_legends = array(); $data = array(); $aTargets = array(); $aAlts = array(); foreach ($legends as $lead_source_key => $lead_source_translation) { if (isset($sum[$lead_source_key])) { array_push($data, $sum[$lead_source_key]); if ($lead_source_key != '') { array_push($visible_legends, $lead_source_translation); } else { // put none in if the vtiger_field is blank. array_push($visible_legends, $current_module_strings['NTC_NO_LEGENDS']); } $cvid = getCvIdOfAll("Potentials"); array_push($aTargets, "index.php?module=Potentials&action=ListView&leadsource=" . urlencode($lead_source_key) . "&query=true&type=dbrd&viewname=" . $cvid); array_push($aAlts, $count[$lead_source_key] . " " . $current_module_strings['LBL_OPPS_IN_LEAD_SOURCE'] . " {$lead_source_translation}\t"); } } $log->debug("sum is:"); $log->debug($sum); $log->debug("count is:"); $log->debug($count); $log->debug("total is: {$total}"); if ($total == 0) { $log->debug("Exiting pipeline_by_lead_source method ..."); return $current_module_strings['ERR_NO_OPPS']; } if ($theme == "blue") { $font_color = "#212473"; } else { $font_color = "#000000"; } $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); $imagemap = $canvas->getImageMap(); $graph =& Image_Graph::factory('graph', $canvas); $font =& $graph->addNew('font', calculate_font_name($lang_crm)); // set the font size to 11 pixels $font->setSize(8); $font->setColor($font_color); $graph->setFont($font); // create the plotarea layout $title =& Image_Graph::factory('title', array('Test', 10)); $plotarea =& Image_Graph::factory('plotarea', array('category', 'axis')); $footer =& Image_Graph::factory('title', array('Footer', 8)); $graph->add(Image_Graph::vertical($title, Image_Graph::vertical($plotarea, $footer, 90), 5)); // Generate colours $colors = color_generator(count($visible_legends), '#33CCFF', '#3322FF'); $index = 0; $dataset =& Image_Graph::factory('dataset'); $fills =& Image_Graph::factory('Image_Graph_Fill_Array'); foreach ($visible_legends as $legend) { $dataset->addPoint($legend, $data[$index], array('url' => $aTargets[$index], 'alt' => $aAlts[$index])); $fills->addColor($colors[$index]); $log->debug('point =' . $legend . ',' . $data[$index]); $index++; } // create the pie chart and associate the filling colours $gbplot =& $plotarea->addNew('pie', $dataset); $plotarea->hideAxis(); $gbplot->setFillStyle($fills); // Setup title $titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'] . $current_user->currency_symbol . $total . $app_strings['LBL_THOUSANDS_SYMBOL']; //$titlestr = $current_module_strings['LBL_TOTAL_PIPELINE'].$current_user->currency_symbol.$total; $title->setText($titlestr); // format the data values $valueproc =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', $current_user->currency_symbol . "%d"); // set markers $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); $marker->setDataPreprocessor($valueproc); $marker->setFillColor('#FFFFFF'); $marker->setBorderColor($font_color); $marker->setFontColor($font_color); $marker->setFontSize(8); $pointingMarker =& $graph->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$marker)); $gbplot->setMarker($pointingMarker); // set legend $legend_box =& $plotarea->addNew('legend'); $legend_box->setPadding(array('top' => 20, 'bottom' => 0, 'left' => 0, 'right' => 0)); $legend_box->setFillColor('#F5F5F5'); $legend_box->showShadow(); $subtitle = $current_module_strings['LBL_OPP_SIZE'] . $current_user->currency_symbol . $current_module_strings['LBL_OPP_SIZE_VALUE']; $footer->setText($subtitle); $footer->setAlignment(IMAGE_GRAPH_ALIGN_TOP_LEFT); $imgMap = $graph->done(array('tohtml' => true, 'border' => 0, 'filename' => $cache_file_name, 'filepath' => './', 'urlpath' => '')); //$imgMap = htmlspecialchars($output); save_image_map($cache_file_name . '.map', $imgMap); } else { $imgMap_fp = fopen($cache_file_name . '.map', "rb"); $imgMap = fread($imgMap_fp, filesize($cache_file_name . '.map')); fclose($imgMap_fp); } $fileModTime = filemtime($cache_file_name . '.map'); $return = "\n{$imgMap}"; $log->debug("Exiting pipeline_by_lead_source method ..."); return $return; }
* Main purpose: * Demonstrate Matrix layout * * Other: * None specific * * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(600, 400)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Matrix Layout', 10)), $Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(3, 3)), 5)); for ($i = 0; $i < 9; $i++) { $Dataset =& Image_Graph::factory('random', array(5, 2, 15, false)); $Plotarea =& $Matrix->getEntry($i % 3, floor($i / 3)); $Plotarea->addNew('line_grid', false, IMAGE_GRAPH_AXIS_X); $Plotarea->addNew('line_grid', false, IMAGE_GRAPH_AXIS_Y); $Plot =& $Plotarea->addNew('line', $Dataset); $Plot->setLineColor('red'); $Plot->setTitle("x^2"); } $Graph->done();
require 'Image/Graph.php'; $chart_colors = array('green@0.2', 'blue@0.2', 'red@0.2', 'yellow@0.2', 'orange@0.2', 'purple@0.2', 'green@0.8', 'blue@0.8', 'red@0.8', 'yellow@0.8', 'orange@0.8', 'purple@0.8', 'green@0.4', 'blue@0.4', 'red@0.4', 'yellow@0.4', 'orange@0.4', 'purple@0.4', 'green@0.6', 'blue@0.6', 'red@0.6', 'yellow@0.6', 'orange@0.6', 'purple@0.6', 'green', 'blue', 'red', 'yellow', 'orange', 'purple'); if (!empty($_GET['thumb'])) { $out = array('limit' => 7, 'width' => 400, 'height' => 200, 'center' => 100, 'margin_top' => 50, 'margin_bottom' => 20, 'margin_left' => 160, 'margin_right' => 30); } else { $out = array('limit' => 25, 'width' => 700, 'height' => 500, 'center' => 250, 'margin_top' => 60, 'margin_bottom' => 30, 'margin_left' => 180, 'margin_right' => 30); } // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', $chart_font); // set the font size to 11 pixels $Font->setSize(8); $Graph->setFont($Font); // create the plotareas $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('SpamAssassin rules', 12)), Image_Graph::horizontal($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 60), 5)); $Legend->setPlotarea($Plotarea); $Legend->setAlignment(IMAGE_GRAPH_ALIGN_VERTICAL); $Plotarea->hideAxis(); // create the dataset $Dataset =& Image_Graph::factory('dataset'); $select = "SELECT rule_name, rule_count " . "FROM maia_sa_rules WHERE rule_count > 0 ORDER BY rule_count DESC, rule_name ASC LIMIT " . $out['limit']; $sth = $dbh->prepare($select); $res = $sth->execute(); if (PEAR::isError($sth)) { die($sth->getMessage()); } $keys = array(); $values = array(); if ($res->numRows()) { $sum = 0;
* @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Arial =& $Graph->addNew('font', 'Verdana'); // set the font size to 8 pixels $Arial->setSize(8); // set default font color to white $Arial->setColor('white'); // make the entire graph use this font $Graph->setFont($Arial); // create the graph layout $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('German Car Popularity', 11)), Image_Graph::vertical($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 90), 7)); // associate the legend with the plotarea $Legend->setPlotarea($Plotarea); // make the graph have a gradient filled background $Graph->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green', 'lightblue'))); // and a black border $Graph->setBorderColor('black'); // create and populate the dataset for 'popularity' $Dataset =& Image_Graph::factory('dataset'); $Dataset->addPoint('Audi', 100); $Dataset->addPoint('Mercedes', 41); $Dataset->addPoint('Porsche', 78); $Dataset->addPoint('BMW', 12); // create and populate the dataset for 'defects / 1000 units' $Dataset2 =& Image_Graph::factory('dataset'); $Dataset2->addPoint('Audi', 10);
* * $Id$ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 8 pixels $Font->setSize(8); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Image Filling / Data Preprocessing', 11)), $Plotarea = Image_Graph::factory('plotarea'), 8)); // create a Y grid $GridY =& $Plotarea->addNew('bar_grid', IMAGE_GRAPH_AXIS_Y); // that is light gray in color $GridY->setFillColor('lightgrey'); // create the 1st dataset $Dataset1 =& Image_Graph::factory('random', array(8, 70, 100, false)); // create the 1st plot as smoothed area chart using the 1st dataset $Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area', array(&$Dataset1)); // create a vertical gradient fill using red and yellow, ie bottom of graph // will be yellow and the "higher" the value the more red it will be, ie a "fire" effect $Plot1->setFillStyle(Image_Graph::factory('Image_Graph_Fill_Image', './images/mountain.jpg')); // create a Y data value marker $Marker =& $Plot1->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_MAX); // fill it with white $Marker->setFillColor('white');
* * $Id: plot_pie_rotate.php,v 1.1 2005/09/30 18:59:17 nosey Exp $ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 7 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Meat Export', 12)), Image_Graph::horizontal($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 70), 5)); $Legend->setPlotarea($Plotarea); // create the 1st dataset $Dataset1 =& Image_Graph::factory('dataset'); $Dataset1->addPoint('Beef', rand(1, 10)); $Dataset1->addPoint('Pork', rand(1, 10)); $Dataset1->addPoint('Poultry', rand(1, 10)); $Dataset1->addPoint('Camels', rand(1, 10)); $Dataset1->addPoint('Other', rand(1, 10)); // create the 1st plot as smoothed area chart using the 1st dataset $Plot =& $Plotarea->addNew('pie', array(&$Dataset1)); $Plotarea->hideAxis(); // create a Y data value marker $Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_PCT_Y_TOTAL); // create a pin-point marker type $PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
$w = 600; $h = 200; if ($style == 'tiny') { $w = 300; $h = 150; } else { if ($style == 'full') { $w = 800; $h = 600; } } $Canvas =& Image_Canvas::factory('png', array('width' => $w, 'height' => $h, 'antialias' => 'native')); // create the graph $Graph =& Image_Graph::factory('graph', $Canvas); $Graph->setPadding(10); $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Daily Sales for ' . date('F', time() + 60 * 60 * 24 * (30 * -$monthsback)), 12)), $Plotarea = Image_Graph::factory('plotarea'), 8)); $Graph->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'lightsteelblue', 'papayawhip'))); $Font =& $Graph->addNew('font', 'Verdana'); $Font->setSize(10); $Graph->setFont($Font); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'dateformat')); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); //$AxisX->setFontAngle('vertical'); $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'currencyformat')); if (sizeof($daily['sub_row']) >= 28) { $AxisX->setLabelInterval(2 / $sizefactor); } $AxisX->setFontSize(8); //$AxisX->setTitle('Very obvious', array('angle' => 0, 'size' => 10)); //$Fillerset =& Image_Graph::factory('dataset');
* @author Jesper Veggerby <*****@*****.**> * @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen * @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1 * @version CVS: $Id: impulse.php,v 1.1 2005/08/27 17:27:32 nosey Exp $ * @link http://pear.php.net/package/Image_Graph */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(600, 400)); // add a TrueType font $Font =& $Graph->addNew('ttf_font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(7); $Graph->setFont($Font); // create the plotarea $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Testing Area Plots', 10)), $Matrix = Image_Graph::factory('Image_Graph_Layout_Matrix', array(2, 2, false)), 5)); for ($i = 0; $i < 2; $i++) { for ($j = 0; $j < 2; $j++) { $Matrix->setEntry($i, $j, Image_Graph::factory('plotarea', array('Image_Graph_Axis_Category', 'axis', 'horizontal'))); } } $DS[0][0] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => 2, 'C' => 0, 'D' => 4, 'E' => 3))); $DS[0][1] =& Image_Graph::factory('dataset', array(array('A' => 1, 'B' => -2, 'C' => 1, 'D' => 3, 'E' => -1))); $DS[1][0] =& Image_Graph::factory('dataset', array(array('A' => 2, 'B' => 3, 'C' => 1, 'D' => 4, 'E' => 2))); $DS[1][1] =& Image_Graph::factory('dataset', array(array('A' => -1, 'B' => -3, 'C' => -2, 'D' => -4, 'E' => -1))); for ($row = 0; $row < 2; $row++) { for ($col = 0; $col < 2; $col++) { if (isset($DS[$row][$col])) { $Plotarea =& $Matrix->getEntry($row, $col); $Plot =& $Plotarea->addNew('impulse', $DS[$row][$col]); $Plot->setLineColor('red');
/** Function to render the Horizontal Graph * Portions created by vtiger are Copyright (C) vtiger. * All Rights Reserved. * Contributor(s): ______________________________________.. */ function horizontal_graph($referdata, $refer_code, $width, $height, $left, $right, $top, $bottom, $title, $target_val, $cache_file_name, $html_image_name) { global $log, $root_directory, $lang_crm, $theme; //We'll be getting the values in the form of a string separated by commas $datay = explode("::", $referdata); // The datay values $datax = explode("::", $refer_code); // The datax values // The links values are given as string in the encoded form, here we are decoding it $target_val = urldecode($target_val); $target = explode("::", $target_val); $alts = array(); $temp = array(); for ($i = 0; $i < count($datax); $i++) { $name = $datax[$i]; $pos = substr_count($name, " "); // JFV : prevent utf-8 char garbled and display percentage correctly global $default_charset; $sum = 0; for ($j = 0; $j < count($datay); $j++) { $sum += $datay[$j]; } $alts[] = htmlentities($name, ENT_QUOTES, $default_charset) . " = " . sprintf('%0.1f%%', 100 * $datay[$i] / $sum); // $alts[]=htmlentities($name)."=%d"; // JFV END //If the daatx value of a string is greater, adding '\n' to it so that it'll cme inh 2nd line if (strlen($name) >= 14) { $name = substr($name, 0, 44); } if ($pos >= 2) { $val = explode(" ", $name); $n = count($val) - 1; $x = ""; for ($j = 0; $j < count($val); $j++) { if ($j != $n) { $x .= " " . $val[$j]; } else { $x .= "@#" . $val[$j]; } } $name = $x; } $name = str_replace("@#", "\n", $name); $temp[] = $name; } $datax = $temp; //datay is the values //datax is the status // Set the basic parameters of the graph $canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true)); $imagemap = $canvas->getImageMap(); $graph =& Image_Graph::factory('graph', $canvas); $font =& $graph->addNew('font', calculate_font_name($lang_crm)); // set the font size to 12 $font->setSize(8); if ($theme == "blue") { $font_color = "#212473"; } else { $font_color = "#000000"; } $font->setColor($font_color); $graph->setFont($font); $titlestr =& Image_Graph::factory('title', array($title, 8)); $plotarea =& Image_Graph::factory('plotarea', array('axis', 'axis', 'horizontal')); $graph->add(Image_Graph::vertical($titlestr, $plotarea, 5)); // Now create a bar plot $max = 0; // To create unique lables we need to keep track of lable name and its count $uniquex = array(); $xlabels = array(); $dataset =& Image_Graph::factory('dataset'); if ($theme == 'woodspice') { $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, '#804000', 'white')); } elseif ($theme == 'bluelagoon') { $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); } elseif ($theme == 'softed') { $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'blue', 'white')); } else { $fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL_MIRRORED, 'black', 'white')); } for ($i = 0; $i < count($datay); $i++) { $x = 1 + 2 * $i; if ($datay[$i] >= $max) { $max = $datay[$i]; } $dataset->addPoint($x, $datay[$i], array('url' => $target[$i], 'alt' => $alts[$i])); // build the xaxis label array to allow intermediate ticks $xlabels[$x] = $datax[$i]; $xlabels[$x + 1] = ''; // To have unique names even in case of duplicates let us add the id $datax_appearance = $uniquex[$datax[$i]]; if ($datax_appearance == null) { $uniquex[$datax[$i]] = 1; } else { $xlabels[$x] = $datax[$i] . ' [' . $datax_appearance . ']'; $uniquex[$datax[$i]] = $datax_appearance + 1; } } $bplot =& $plotarea->addNew('bar', $dataset); $bplot->setFillStyle($fill); //You can change the width of the bars if you like $bplot->setBarWidth(50 / count($datax), "%"); $bplot->setPadding(array('top' => 10)); // We want to display the value of each bar at the top //$bplot->value->Show(); //$bplot->value->SetFont(FF_FONT2,FS_BOLD,12); //$bplot->value->SetAlign('left','center'); //$bplot->value->SetColor("black","gray4"); //$bplot->value->SetFormat('%d'); //$graph->SetBackgroundGradient('#E5E5E5','white',GRAD_VER,BGRAD_PLOT); $bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', 'white'))); //$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL, 'white', '#E5E5E5'))); //$bplot->SetFillGradient("navy","lightsteelblue",GRAD_MIDVER); //$graph->SetFrame(false); //$graph->SetMarginColor('cadetblue2'); //$graph->ygrid->SetFill(true,'azure1','azure2'); //$graph->xgrid->Show(); // Add the bar to the graph //$graph->Add($bplot); // Setup title //$titlestr->setText($title); // Setup X-axis $xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $yaxis->setFontSize(10); // Invert X-axis and put Y-axis at bottom $xaxis->setInverted(true); $yaxis->setAxisIntersection('max'); // set grid $gridY =& $plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y); $gridY->setLineColor('#FFFFFF@0.5'); $gridY2 =& $plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); $gridY2->setFillColor('#FFFFFF@0.2'); // Add some grace to y-axis so the bars doesn't go // all the way to the end of the plot area $yaxis->forceMaximum(round($max * 1.1 + 0.5)); $ticks = get_tickspacing(round($max * 1.1 + 0.5)); // First make the labels look right $yaxis->setLabelInterval($ticks[0]); $yaxis->setTickOptions(-5, 0); $yaxis->setLabelInterval($ticks[1], 2); $yaxis->setTickOptions(-2, 0, 2); // Create the xaxis labels $array_data =& Image_Graph::factory('Image_Graph_DataPreprocessor_Array', array($xlabels)); // The fix the tick marks $xaxis->setDataPreprocessor($array_data); $xaxis->forceMinimum(0); $xaxis->forceMaximum(2 * count($datay)); $xaxis->setLabelInterval(1); $xaxis->setTickOptions(0, 0); $xaxis->setLabelInterval(2, 2); $xaxis->setTickOptions(5, 0, 2); // set markers $marker =& $graph->addNew('value_marker', IMAGE_GRAPH_VALUE_Y); $marker->setFillColor('000000@0.0'); $marker->setBorderColor('000000@0.0'); $marker->setFontSize(10); // shift markers 10 pix right $marker_pointing =& $graph->addNew('Image_Graph_Marker_Pointing', array(40, 0, &$marker)); $marker_pointing->setLineColor('000000@0.0'); $bplot->setMarker($marker_pointing); //Getting the graph in the form of html page $img = $graph->done(array('tohtml' => true, 'border' => 0, 'filename' => $cache_file_name, 'filepath' => '', 'urlpath' => '')); save_image_map($cache_file_name . '.map', $img); return $img; }
* * $Id: log_axis_low.php,v 1.1 2006/02/28 22:48:07 nosey Exp $ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ require_once 'Image/Graph.php'; // create the graph $Graph =& Image_Graph::factory('graph', array(400, 300)); // add a TrueType font $Font =& $Graph->addNew('font', 'Verdana'); // set the font size to 11 pixels $Font->setSize(10); $Graph->setFont($Font); // setup the plotarea, legend and their layout $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Small Values on Log Axis Chart Sample', 12)), Image_Graph::vertical($Plotarea = Image_Graph::factory('plotarea', array('axis_log', 'axis')), $Legend = Image_Graph::factory('legend'), 88), 5)); // link the legend with the plotares $Legend->setPlotarea($Plotarea); $Dataset =& Image_Graph::factory('dataset'); $Dataset->addPoint(0.063, 5); $Dataset->addPoint(0.125, 7); $Dataset->addPoint(0.25, 8); $Dataset->addPoint(0.5, 10); $Dataset->addPoint(1, 15); $Dataset->addPoint(2, 30); $Dataset->addPoint(4, 45); $Dataset->addPoint(8, 80); // create the plot as line chart using the dataset $Plot =& $Plotarea->addNew('line', array(&$Dataset)); // set a line color $Plot->setLineColor('red');
* $Id: horizontal.php,v 1.2 2005/10/05 20:56:38 nosey Exp $ * * @package Image_Graph * @author Jesper Veggerby <*****@*****.**> */ error_reporting(E_ALL); include_once 'Image/Graph.php'; include_once 'Image/Canvas.php'; $Dataset =& Image_Graph::factory('dataset', array(array('A' => 10, 'B' => 9, 'C' => 4, 'D' => 6, 'E' => 5, 'F' => 9, 'G' => 11, 'H' => 8))); $Dataset2 =& Image_Graph::factory('dataset', array(array('A' => 121, 'B' => 134, 'C' => 192, 'D' => 213, 'E' => 123, 'F' => 167, 'G' => 153, 'H' => 149))); $Canvas =& Image_Canvas::factory('png', array('width' => 800, 'height' => 400)); // create the graph $Graph =& Image_Graph::factory('graph', &$Canvas); $Graph->setFont(Image_Graph::factory('font', array('Courier New'))); $Graph->setFontSize(8); $Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Vertical & Horizontal Plots', 11)), Image_Graph::vertical(Image_Graph::horizontal($Plotarea = Image_Graph::factory('plotarea'), $Plotarea2 = Image_Graph::factory('plotarea', array('category', 'axis', 'horizontal'))), $Legend = Image_Graph::factory('legend'), 90), 7)); $Legend->setPlotarea($Plotarea); $GridY =& $Plotarea->addNew('line_grid', null, IMAGE_GRAPH_AXIS_Y); $Plot =& $Plotarea->addNew('step', &$Dataset); $Plot->setFillColor('blue@0.2'); $Marker =& Image_Graph::factory('value_marker', IMAGE_GRAPH_VALUE_Y); $Marker->setFontSize(7); $Plot->setMarker($Marker); $Plot12 =& $Plotarea->addNew('line', &$Dataset2, IMAGE_GRAPH_AXIS_Y_SECONDARY); $Plot12->setLineColor('red'); $Plot->setTitle('Primary axis'); $Plot12->setTitle('Secondary axis'); $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); $AxisX->setTitle('X Data', array('size' => 10)); $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); $AxisY->setTitle('Y Data', array('size' => 10));