本文整理汇总了PHP中Image_Canvas类的典型用法代码示例。如果您正苦于以下问题:PHP Image_Canvas类的具体用法?PHP Image_Canvas怎么用?PHP Image_Canvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image_Canvas类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleDirFiles
function handleDirFiles($dir_name, $save_dir)
{
list($directories, $files) = File_Find::maptree($dir_name);
$new_dir = $save_dir . basename($dir_name);
if (!file_exists($new_dir)) {
mkdir($new_dir, 0777);
}
foreach ($files as $image_file) {
if (ereg("(.*)jpg\$", $image_file)) {
$new_filename = $new_dir . "/" . basename($image_file, ".jpg") . "_resize.jpg";
echo $new_filename . "\n";
$tn_image = new Thumbnail($image_file, 340);
$tn_image->save($new_filename);
$Canvas =& Image_Canvas::factory(isset($_GET['canvas']) ? $_GET['canvas'] : 'jpg', array('width' => 340, 'height' => 340));
$Canvas->image(array('x' => 340, 'y' => 340, 'filename' => $new_filename, 'alignment' => array('horizontal' => 'right', 'vertical' => 'bottom')));
$Canvas->setFont(array('name' => 'Courier New', 'size' => 16, 'color' => '#FF66FF'));
//#FF0033
$Canvas->addText(array('x' => 165, 'y' => 200, 'text' => 'arzen1013', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
$Canvas->setFont(array('name' => 'Courier New', 'size' => 10, 'color' => '#000000'));
//#FF0033
$Canvas->addText(array('x' => 165, 'y' => 320, 'text' => 'http://shop33691629.taobao.com/', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
$Canvas->save(array('filename' => $new_filename));
}
}
}
示例2: create_graph_usemap01
function create_graph_usemap01($width = 700, $height = 160, $fontsize = 7)
{
$Canvas =& Image_Canvas::factory('png', array('width' => $width, 'height' => $height, 'usemap' => true));
// This is how you get the ImageMap object,
// fx. to save map to file (using toHtml())
$Imagemap = $Canvas->getImageMap();
// Create the graph
//$Graph =& Image_Graph::factory('graph', array(600, 140));
$Graph =& Image_Graph::factory('graph', $Canvas);
// add a TrueType font
//$myfont = '/usr/share/fonts/truetype/freefont/FreeSans.ttf';
$myfont = '/usr/share/fonts/truetype/freefont/FreeSerif.ttf';
$Font =& $Graph->addNew('font', $myfont);
//$Font =& $Graph->addNew('font', 'Verdana');
//$Font =& $Graph->addNew('font', 'Helvetica');
// set the font size
$Font->setSize($fontsize);
$Graph->setFont($Font);
#return array(&$Graph, &$Font);
return $Graph;
}
示例3: file
* Main purpose:
* Color chart of named colors
*
* Other:
* Using canvass "outside" Image_Graph
*
* $Id: color_chart.php,v 1.2 2005/08/03 21:21:52 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
$file = file('./data/colors.txt');
require_once 'Image/Canvas.php';
require_once 'Image/Graph/Color.php';
require_once 'Image/Graph/Constants.php';
$Canvas =& Image_Canvas::factory('gd', array('width' => 600, 'height' => 1200));
$i = 0;
$cols = 10;
$Width = $Canvas->getWidth() / $cols;
$rows = count($file) / $cols;
$rows = floor($rows) + ($rows > floor($rows) ? 1 : 0);
$Height = $Canvas->getHeight() / $rows;
while (list($id, $color) = each($file)) {
$color = trim($color);
$x = $i % $cols * $Width + $Width / 2;
$y = floor($i / $cols) * $Height;
$Canvas->setLineColor('black');
$Canvas->setFillColor($color);
$Canvas->rectangle($x - $Width / 4, $y, $x + $Width / 4, $y + $Height / 3);
$Canvas->write($x, $y + $Height / 3 + 3, $color, IMAGE_GRAPH_ALIGN_CENTER_X + IMAGE_GRAPH_ALIGN_TOP);
$rgbColor = Image_Graph_Color::color2RGB($color);
示例4: Image_Graph
/**
* Image_Graph [Constructor].
*
* If passing the 3 parameters they are defined as follows:'
*
* Fx.:
*
* $Graph =& new Image_Graph(400, 300);
*
* or using the factory method:
*
* $Graph =& Image_Graph::factory('graph', array(400, 300));
*
* This causes a 'png' canvas to be created by default.
*
* Otherwise use a single parameter either as an associated array or passing
* the canvas along to the constructor:
*
* 1) Create a new canvas with the following parameters:
*
* 'canvas' - The canvas type, can be any of 'gd', 'jpg', 'png' or 'svg'
* (more to come) - if omitted the default is 'gd'
*
* 'width' - The width of the graph
*
* 'height' - The height of the graph
*
* An example of this usage:
*
* $Graph =& Image_Graph::factory('graph', array(array('width' => 400,
* 'height' => 300, 'canvas' => 'jpg')));
*
* NB! In thïs case remember the "double" array (see {@link Image_Graph::
* factory()})
*
* 2) Use the canvas specified, pass a valid Image_Canvas as
* parameter. Remember to pass by reference, i. e. &$canvas, fx.:
*
* $Graph =& new Image_Graph($Canvas);
*
* or using the factory method:
*
* $Graph =& Image_Graph::factory('graph', $Canvas));
*
* @param mixed $params The width of the graph, an indexed array
* describing a new canvas or a valid {@link Image_Canvas} object
* @param int $height The height of the graph in pixels
* @param bool $createTransparent Specifies whether the graph should be
* created with a transparent background (fx for PNG's - note: transparent
* PNG's is not supported by Internet Explorer!)
*/
function Image_Graph($params, $height = false, $createTransparent = false)
{
parent::__construct();
$this->setFont(Image_Graph::factory('Image_Graph_Font'));
if (defined('IMAGE_GRAPH_DEFAULT_CANVAS_TYPE')) {
$canvasType = IMAGE_GRAPH_DEFAULT_CANVAS_TYPE;
} else {
$canvasType = 'png';
// use GD as default, if nothing else is specified
}
if (is_array($params)) {
if (isset($params['canvas'])) {
$canvasType = $params['canvas'];
}
$width = 0;
$height = 0;
if (isset($params['width'])) {
$width = $params['width'];
}
if (isset($params['height'])) {
$height = $params['height'];
}
} elseif (is_a($params, 'Image_Canvas')) {
$this->_canvas =& $params;
$width = $this->_canvas->getWidth();
$height = $this->_canvas->getHeight();
} elseif (is_numeric($params)) {
$width = $params;
}
if ($this->_canvas == null) {
include_once 'Image/Canvas.php';
$this->_canvas =& Image_Canvas::factory($canvasType, array('width' => $width, 'height' => $height));
}
$this->_setCoords(0, 0, $width - 1, $height - 1);
}
示例5: array
* Usage example for Image_Graph.
*
* Main purpose:
* Show radar chart
*
* Other:
* None specific
*
* $Id$
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
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));
示例6: horizontal_graph
/** 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 . ']';
//.........这里部分代码省略.........
示例7: _regenerateThumbUnit
function _regenerateThumbUnit($photo, $v, &$obj, $field)
{
$firstRedim = true;
if (!isset($v['x']) && !isset($v['y']) && !isset($v['maxx']) && !isset($v['maxy']) && !isset($v['overlay'])) {
copy($photo, IMAGES_UPLOAD_FOLDER . $v['path'] . '/' . $obj->{$field});
$name = $obj->{$field};
} else {
$ph = new traitephoto();
$ph->photo = $photo;
$ph->path = IMAGES_UPLOAD_FOLDER . $v['path'];
$ph->nomsouhaite = $obj->{$field};
$ph->qualite = $v['quality'];
$ph->width = $v['x'];
$ph->height = $v['y'];
$ph->maxx = $v['maxx'];
$ph->maxy = $v['maxy'];
if (isset($v['overlay']) && $firstRedim) {
$type = 'png';
$ph->path = FileUtils::getFolderPath(TMP_PATH);
$ph->nomsouhaite = 'overlaytemp.png';
} else {
$type = $v['type'] ? $v['type'] : null;
}
$ph->resize();
$name = $ph->save($type);
if (isset($v['overlay']) && $firstRedim) {
$source = $v['path'] . '/' . $name;
$infosSource =& Image_Transform::factory('GD');
if (PEAR::isError($infosSource)) {
throw new Exception($infosSource->getMessage());
}
$tmp = FileUtils::getFolderPath(TMP_PATH);
$infosSource->load($tmp . 'overlaytemp.png');
$infosOver =& Image_Transform::factory('GD');
$infosOver->load(APP_ROOT . $v['overlay'][0]);
$opts = array('width' => $infosSource->getImageWidth(), 'height' => $infosSource->getImageHeight(), 'transparent' => true);
$img =& Image_Canvas::factory('png', $opts);
$img->image(array('filename' => TMP_PATH . 'overlaytemp.png', 'x' => 0, 'y' => 0));
switch ($v['overlay']['position']) {
case 'top-left':
$x = 0;
$y = 0;
break;
case 'top-right':
$x = $infosSource->getImageWidth() - $infosOver->getImageWidth();
$y = 0;
break;
case 'bottom-left':
$x = 0;
$y = $infosSource->getImageHeight() - $infosOver->getImageHeight();
break;
case 'bottom-right':
$x = $infosSource->getImageWidth() - $infosOver->getImageWidth();
$y = $infosSource->getImageHeight() - $infosOver->getImageHeight();
break;
default:
$x = 0;
$y = 0;
break;
}
$img->image(array('filename' => APP_ROOT . $v['overlay'][0], 'x' => $x, 'y' => $y));
$img->save(array('filename' => $tmp . 'overlaytemp.png'));
$ph = new traitephoto();
$ph->photo = $tmp . 'overlaytemp.png';
$ph->path = IMAGES_UPLOAD_FOLDER . $v['path'];
$ph->nomsouhaite = $obj->{$field};
$ph->qualite = $v['quality'];
$ph->resize();
$name = $ph->save($v['type'] ? $v['type'] : null);
unset($ph);
}
}
if ($name != $obj->{$field}) {
@unlink(IMAGES_UPLOAD_FOLDER . $v['path'] . '/' . $obj->{$field});
}
unset($ph);
return $name;
}
示例8: display
/**
* A method to launch and display the widget
*/
function display()
{
if ($this->draw) {
$useAntialias = is_callable('imageantialias');
$Canvas = Image_Canvas::factory('png', array('width' => 239, 'height' => 132, 'antialias' => $useAntialias ? 'native' : false));
$Graph = Image_Graph::factory('graph', $Canvas);
if (is_callable('imagettftext')) {
$Font = $Graph->addNew('ttf_font', MAX_PATH . '/lib/fonts/Bitstream/Vera.ttf');
$Font->setSize(7);
$Graph->setFont($Font);
} else {
// TTF library not available, use standard bitmap font
$Graph->setFontSize(7);
}
$Datasets = array(Image_Graph::factory('dataset'), Image_Graph::factory('dataset'));
$Datasets[0]->setName('Impressions');
$Datasets[1]->setName('Clicks');
foreach ($this->aData[0] as $k => $v) {
$Datasets[0]->addPoint($k, $v);
}
$scaleY2 = 1.75;
$maxImpr = max($this->aData[0]);
$maxClick = max($this->aData[1]);
$relation = $maxImpr / ($maxClick > 0 ? $maxClick : 1);
// impressions/clicks
$factor = $relation / $scaleY2;
//scale down to make click ~ 57% of impressions bar height
foreach ($this->aData[1] as $k => $v) {
$Datasets[1]->addPoint($k, $v * $factor);
}
$Graph->add($Plotarea = Image_Graph::factory('plotarea'));
$PlotBg = Image_Graph::factory('Fill_Array');
$PlotBg->addColor('white');
$PlotFg = Image_Graph::factory('Line_Array');
$PlotFg->addColor('white');
$Plotarea->setBackground($PlotBg);
$Plotarea->setBorderColor('white');
$Grid = $Plotarea->addNew('line_grid', IMAGE_GRAPH_AXIS_Y);
$Grid->setLineColor('#cccccc');
$Plot = $Plotarea->addNew('bar', array($Datasets));
$Plot->setLineColor('black@0.2');
$FillArray = Image_Graph::factory('Fill_Array');
$FillArray->add(Image_Graph::factory('Fill_Gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, '#b5da3c', '#6a9a2a')));
$FillArray->add(Image_Graph::factory('Fill_Gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, '#bb5c9e', '#8b4a9e')));
$Plot->setFillStyle($FillArray);
$AxisY2 = $Plotarea->addNew('axis', array(IMAGE_GRAPH_AXIS_Y_SECONDARY));
$AxisY2->forceMaximum(max($this->aData[1]) * $scaleY2 + 1);
$AxisY = $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
if (!max($this->aData[0])) {
$AxisY->forceMaximum(1);
}
$func = create_function('$value', 'return OA_Dashboard_Widget_Graph::_formatY($value);');
$AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', $func));
$AxisY2->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', $func));
ob_start();
$Graph->done();
$content = ob_get_clean();
$this->oTpl->assign('content', $content);
} else {
$this->oTpl->assign('title', $this->title);
$this->oTpl->assign('imageSrc', "dashboard.php?widget={$this->widgetName}&draw=1&cb=" . $this->oTpl->cacheId);
}
$this->oTpl->display();
}
示例9: var_dump
# $displayTiming = TRUE;
#echo "<br> TEST:"; var_dump($CONFIG);
//$_REQUEST = cleanup_input_request();
$probeid = $_REQUEST['probeid'];
if (!is_numeric($probeid)) {
die("Cannot proceed -- Missing probeid input");
}
$tstampF = $_REQUEST['tstampF'];
$tstampT = $_REQUEST['tstampT'];
$bucketsz = $_REQUEST['bucketsz'];
# Select all channel within the period
$data =& multicast_probe_data_query_ts($probeid, $tstampF, $tstampT);
//$data = multicast_probe_data_query($probeid, $fromT, $toT);
//db_disconnect();
#print_r($data);
$Canvas =& Image_Canvas::factory('png', array('width' => 400, 'height' => 350, 'usemap' => true));
// This is how you get the ImageMap object,
// fx. to save map to file (using toHtml())
$Imagemap = $Canvas->getImageMap();
// create the graph
//$Graph =& Image_Graph::factory('graph', array(400, 350));
$Graph =& Image_Graph::factory('graph', $Canvas);
// add a TrueType font
$myfont = '/usr/share/fonts/truetype/freefont/FreeSerif.ttf';
$Font =& $Graph->addNew('font', $myfont);
//$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 11 pixels
$Font->setSize(8);
$Graph->setFont($Font);
// setup the plotarea, legend and their layout
$Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Channel Drop Proportion', 12)), Image_Graph::vertical($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 70), 5));
示例10: array
* Usage example for Image_Graph.
*
* Main purpose:
* Demonstrate logarithmic axis
*
* Other:
* Matrix layout, Axis titles
*
* $Id: log_axis_forcemin.php,v 1.1 2006/02/28 22:48:07 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
require_once 'Image/Canvas.php';
$Canvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 400, 'antialias' => true));
// create the graph
$Graph =& Image_Graph::factory('graph', $Canvas);
// add a TrueType font
$Font =& $Graph->addNew('font', 'Verdana');
// set the font size to 15 pixels
$Font->setSize(8);
// add a title using the created font
for ($i = 0; $i < 2; $i++) {
for ($j = 0; $j < 2; $j++) {
$Axis['X'][$i * 2 + $j] = 'axis' . ($i % 2 == 0 ? '' : '_log');
$Axis['Y'][$i * 2 + $j] = 'axis' . ($j % 2 == 0 ? '' : '_log');
}
}
for ($i = 0; $i < 4; $i++) {
$Plotarea[$i] =& Image_Graph::factory('plotarea', array($Axis['X'][$i], $Axis['Y'][$i]));
示例11: array
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
* General Public License for more details. You should have received a copy of
* the GNU Lesser General Public License along with this library; if not, write
* to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
*
* @category Images
* @package Image_Canvas
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
* @copyright Copyright (C) 2003, 2004 Jesper Veggerby Hansen
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* @version CVS: $Id: canvas.php,v 1.1 2005/08/03 21:11:22 nosey Exp $
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=212
*/
include_once 'Image/Canvas.php';
$Canvas =& Image_Canvas::factory(isset($_GET['canvas']) ? $_GET['canvas'] : 'png', array('width' => 400, 'height' => 300));
$Canvas->setLineColor('black');
$Canvas->rectangle(array('x0' => 0, 'y0' => 0, 'x1' => 399, 'y1' => 299));
$Canvas->setGradientFill(array('direction' => 'horizontal', 'start' => 'red', 'end' => 'blue'));
$Canvas->setLineColor('black');
$Canvas->ellipse(array('x' => 199, 'y' => 149, 'rx' => 50, 'ry' => 50));
$Canvas->setFont(array('name' => 'Arial', 'size' => 12));
$Canvas->addText(array('x' => 0, 'y' => 0, 'text' => 'Demonstration of what Image_Canvas do!'));
$Canvas->setFont(array('name' => 'Times New Roman', 'size' => 12));
$Canvas->addText(array('x' => 399, 'y' => 20, 'text' => 'This does not demonstrate what is does!', 'alignment' => array('horizontal' => 'right')));
$Canvas->setFont(array('name' => 'Courier New', 'size' => 7, 'angle' => 270));
$Canvas->addText(array('x' => 350, 'y' => 50, 'text' => 'True, but it\'s all independent of the format!', 'alignment' => array('horizontal' => 'right')));
$Canvas->setFont(array('name' => 'Garamond', 'size' => 10));
$Canvas->addText(array('x' => 199, 'y' => 295, 'text' => '[Changing format is done by changing 3 letters in the source]', 'alignment' => array('horizontal' => 'center', 'vertical' => 'bottom')));
$Canvas->addVertex(array('x' => 50, 'y' => 200));
$Canvas->addVertex(array('x' => 100, 'y' => 200));
示例12: testScaleBackComplex2
//.........这里部分代码省略.........
${$dataSetName}->addPoint($iteration, $result['ads'][$adKey]['priority_factor']);
$dataSetName = 'oDataSet_Ad_' . $adKey . '_Priority';
${$dataSetName}->addPoint($iteration, $result['ads'][$adKey]['priority']);
}
// Prepare the ads/zone for the next iteration
$oZone = new OX_Maintenance_Priority_Zone(array('zoneid' => 1));
$oZone->availableImpressions = $zoneImpressions;
$zoneTotalRequired = 0;
foreach ($aAds as $adKey => $aAdData) {
if (!($iteration > ($initialIterations + $finalIterations) / 2 && $adKey == 2)) {
$zoneTotalRequired += $aAdData['requiredImpressions'];
}
}
foreach ($aAds as $adKey => $aAdData) {
if (!($iteration > ($initialIterations + $finalIterations) / 2 && $adKey == 2)) {
$oAd = new OA_Maintenance_Priority_Ad(array('ad_id' => $adKey));
$oAd->requiredImpressions = $aAdData['requiredImpressions'];
if ($zoneTotalRequired > $zoneImpressions) {
$oAd->requestedImpressions = floor(($zoneImpressions - 1) / count($aAds));
} else {
$oAd->requestedImpressions = $aAdData['requiredImpressions'];
}
$oAd->pastRequiredImpressions = $aAdData['requiredImpressions'];
$oAd->pastRequestedImpressions = $result['ads'][$adKey]['requested_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 main graph
$oCanvas =& Image_Canvas::factory('png', array('width' => 600, 'height' => 600, '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: Multi-Ad Complex Scale-Back Test', 12)), Image_Graph::vertical($oPlotarea = Image_Graph::factory('plotarea', array('axis', 'axis')), $oLegend = Image_Graph::factory('legend'), 90), 10));
$oLegend->setPlotarea($oPlotarea);
$oPlotareaSecondary =& Image_Graph::factory('plotarea', array('axis', 'axis', IMAGE_GRAPH_AXIS_Y_SECONDARY));
$oGraph->add($oPlotareaSecondary);
$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');
$oAxis =& Image_Graph::factory('axis', IMAGE_GRAPH_AXIS_Y_SECONDARY);
$oPlotarea->add($oAxis);
$oAxis =& $oPlotarea->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
$oAxis->setTitle('Priority Factor', 'vertical2');
// Ad the data sets to the graph
foreach ($aAds as $adKey => $aAdData) {
if ($adKey == 1) {
$dataSetName = 'oDataSet_Ad_' . $adKey . '_PriorityFactor';
$oPlot =& $oPlotarea->addNew('line', ${$dataSetName}, IMAGE_GRAPH_AXIS_Y_SECONDARY);
$oLineStyle =& Image_Graph::factory('Image_Graph_Line_Solid', array($aAdData['priorityFactorColour'], 'transparent'));
$oPlot->setLineStyle($oLineStyle);
$dataSetName = 'oDataSet_Ad_' . $adKey . '_DeliveredImpressions';
$oPlot =& $oPlotarea->addNew('line', ${$dataSetName});
$oLineStyle =& Image_Graph::factory('Image_Graph_Line_Solid', array($aAdData['deliveredColour'], 'transparent'));
$oPlot->setLineStyle($oLineStyle);
$dataSetName = 'oDataSet_Ad_' . $adKey . '_AvailableImpressions';
示例13: pipeline_by_lead_source
/**
* 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));
//.........这里部分代码省略.........
示例14: vertical_graph
/** Function to render the Horizontal Graph
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* Contributor(s): ______________________________________..
*/
function vertical_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, $app_strings;
//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++) {
if ($app_strings[$datax[$i]] != '') {
//HomePage Dashboard Strings i18nized - ahmed
$name = $app_strings[$datax[$i]];
} else {
$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 cme inh 2nd line
if (strlen($name) >= 15) {
$name = substr($name, 0, 15);
}
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, 10));
$plotarea =& Image_Graph::factory('plotarea', array('axis', 'axis', 'vertical'));
$graph->add(Image_Graph::vertical($titlestr, $plotarea, 5));
// Now create a bar plot
$max = 0;
$xlabels = array();
$dataset =& Image_Graph::factory('dataset');
if ($theme == 'woodspice') {
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, '#804000', 'white'));
} elseif ($theme == 'bluelagoon') {
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white'));
} elseif ($theme == 'softed') {
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_MIRRORED, 'blue', 'white'));
} else {
$fill =& Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_HORIZONTAL_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] = '';
}
//$bplot = new BarPlot($datay);
$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' => 20));
$bplot->setBackground(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'white')));
// Setup X-axis
$xaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$yaxis =& $plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
//.........这里部分代码省略.........
示例15: array
* Usage example for Image_Graph.
*
* Main purpose:
* Demonstrate SWF canvas
*
* Other:
* None specific
*
* $Id$
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
require_once 'Image/Canvas.php';
$Canvas =& Image_Canvas::factory('swf', array('width' => 600, 'height' => 400));
// 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(11);
$Graph->add(Image_Graph::vertical(Image_Graph::factory('title', array('Simple Line Chart Sample', &$Font)), 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, 15, true));
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('line', $Dataset);
// set a line color
$Plot->setLineColor('red');
// output the Graph