本文整理汇总了PHP中Image_Graph类的典型用法代码示例。如果您正苦于以下问题:PHP Image_Graph类的具体用法?PHP Image_Graph怎么用?PHP Image_Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Image_Graph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Image_Graph_Plotarea_Radar
/**
* Create the plotarea, implicitely creates 2 normal axis
*/
function Image_Graph_Plotarea_Radar()
{
parent::Image_Graph_Element();
$this->_padding = 10;
$this->_axisX =& Image_Graph::factory('Image_Graph_Axis_Radar');
$this->_axisX->_setParent($this);
$this->_axisY =& Image_Graph::factory('Image_Graph_Axis', IMAGE_GRAPH_AXIS_Y);
$this->_axisY->_setParent($this);
$this->_axisY->_setMinimum(0);
}
示例2: __construct
/**
* Create the plotarea, implicitely creates 2 normal axis
*/
function __construct()
{
parent::__construct();
$this->_padding = array('left' => 10, 'top' => 10, 'right' => 10, 'bottom' => 10);
$this->_axisX =& Image_Graph::factory('Image_Graph_Axis_Radar');
$this->_axisX->_setParent($this);
$this->_axisY =& Image_Graph::factory('Image_Graph_Axis', IMAGE_GRAPH_AXIS_Y);
$this->_axisY->_setParent($this);
$this->_axisY->_setMinimum(0);
}
示例3: showImageData
/** Return the actual Image data
* Classes must override this.
* @param $child_html The child method's return value
* @return A html fragment
*/
public function showImageData()
{
require_once "Image/Graph.php";
$db = AbstractDb::getObject();
$Graph =& Image_Graph::factory("Image_Graph", array(600, 200));
$Plotarea =& $Graph->add(Image_Graph::factory("Image_Graph_Plotarea"));
$Dataset =& Image_Graph::factory("Image_Graph_Dataset_Trivial");
$Bar =& Image_Graph::factory("Image_Graph_Plot_Bar", $Dataset);
$Bar->setFillColor("#9db8d2");
$Plot =& $Plotarea->add($Bar);
$candidate_connections_sql = self::$stats->getSqlCandidateConnectionsQuery("COUNT(distinct user_mac) AS connections, extract('hour' from timestamp_in) AS hour");
$db->execSql("{$candidate_connections_sql} GROUP BY hour ORDER BY hour", $results, false);
if ($results) {
foreach ($results as $row) {
$Dataset->addPoint($row['hour'] . "h", $row['connections']);
}
}
$Graph->done();
}
示例4: showImageData
/** Return the actual Image data
* Classes must override this.
* @param $child_html The child method's return value
* @return A html fragment
*/
public function showImageData()
{
require_once "Image/Graph.php";
$db = AbstractDb::getObject();
$Graph =& Image_Graph::factory("Image_Graph", array(600, 200));
$Plotarea =& $Graph->add(Image_Graph::factory("Image_Graph_Plotarea"));
$Dataset =& Image_Graph::factory("Image_Graph_Dataset_Trivial");
$Bar =& Image_Graph::factory("Image_Graph_Plot_Bar", $Dataset);
$Bar->setFillColor("#9db8d2");
$Plot =& $Plotarea->add($Bar);
$total = 0;
$network_constraint = self::$stats->getSqlNetworkConstraint('account_origin');
$date_constraint = self::$stats->getSqlDateConstraint('reg_date');
$db->execSql("SELECT COUNT(users) AS num_users, date_trunc('month', reg_date) AS month FROM users WHERE account_status = " . ACCOUNT_STATUS_ALLOWED . " {$date_constraint} {$network_constraint} GROUP BY date_trunc('month', reg_date) ORDER BY month", $registration_stats, false);
if ($registration_stats) {
foreach ($registration_stats as $row) {
$Dataset->addPoint(substr($row['month'], 0, 7), $row['num_users']);
}
}
$Graph->done();
}
示例5: 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;
}
示例6:
/**
* Factory method to create vertical layout.
*
* See {@link Image_Graph::layoutFactory()}
*
* @param Image_Graph_Element $part1 The 1st (top) part of the layout
* @param Image_Graph_Element $part2 The 2nd (bottom) part of the layout
* @param int $percentage The percentage of the layout to split at
* (percentage of total width from the top edge)
* @return Image_Graph_Layout The newly created layout object
* @static
*/
function &vertical(&$part1, &$part2, $percentage = 50)
{
$obj =& Image_Graph::layoutFactory('Vertical', $part1, $part2, $percentage);
return $obj;
}
示例7: array
<?php
/**
* Usage example for Image_Graph.
*
* Main purpose:
* Somebody liked it :)
*
* Other:
* None specific
*
* $Id: misc04.php,v 1.2 2005/08/03 21:21:53 nosey Exp $
*
* @package Image_Graph
* @author Jesper Veggerby <pear.nosey@veggerby.dk>
*/
require_once 'Image/Graph.php';
// create the graph
$Graph =& Image_Graph::factory('graph', array(500, 300));
$Plotarea =& $Graph->addNew('plotarea');
$Dataset =& Image_Graph::factory('Image_Graph_Dataset_Random', array(20, 10, 100, true));
$Fill =& Image_Graph::factory('Image_Graph_Fill_Image', './images/audi-tt-coupe.jpg');
$Plotarea->setFillStyle($Fill);
$Plot =& $Plotarea->addNew('Image_Graph_Plot_Smoothed_Area', $Dataset);
$Plot->setFillColor('white@0.4');
// output the Graph
$Graph->done();
示例8: elseif
/**
* Adds an element to the plotarea
*
* @param Image_Graph_Element $element The element to add
* @param int $axis The axis to associate the element with, either
* IMAGE_GRAPH_AXIS_X, IMAGE_GRAPH_AXIS_Y, IMAGE_GRAPH_AXIS_Y_SECONDARY
* or the shorter string notations 'x', 'y' or 'ysec' (defaults to
* IMAGE_GRAPH_AXIS_Y)
* @return Image_Graph_Element The added element
* @see Image_Graph_Common::add()
*/
function &add(&$element, $axis = IMAGE_GRAPH_AXIS_Y)
{
if ($axis == 'x') {
$axis = IMAGE_GRAPH_AXIS_X;
}
if ($axis == 'y') {
$axis = IMAGE_GRAPH_AXIS_Y;
}
if ($axis == 'ysec') {
$axis = IMAGE_GRAPH_AXIS_Y_SECONDARY;
}
if ($axis == IMAGE_GRAPH_AXIS_Y_SECONDARY && $this->_axisYSecondary == null) {
$this->_axisYSecondary =& Image_Graph::factory('axis', IMAGE_GRAPH_AXIS_Y_SECONDARY);
$this->_axisYSecondary->_setMinimum(0);
if ($this->_horizontal) {
$this->_axisYSecondary->_transpose = true;
}
}
parent::add($element);
if (is_a($element, 'Image_Graph_Plot')) {
$element->_setAxisY($axis);
// postpone extrema calculation until we calculate coordinates
//$this->_setExtrema($element);
} elseif (is_a($element, 'Image_Graph_Grid')) {
switch ($axis) {
case IMAGE_GRAPH_AXIS_X:
if ($this->_axisX != null) {
$element->_setPrimaryAxis($this->_axisX);
if ($this->_axisY != null) {
$element->_setSecondaryAxis($this->_axisY);
}
}
break;
case IMAGE_GRAPH_AXIS_Y:
if ($this->_axisY != null) {
$element->_setPrimaryAxis($this->_axisY);
if ($this->_axisX != null) {
$element->_setSecondaryAxis($this->_axisX);
}
}
break;
case IMAGE_GRAPH_AXIS_Y_SECONDARY:
if ($this->_axisYSecondary != null) {
$element->_setPrimaryAxis($this->_axisYSecondary);
if ($this->_axisX != null) {
$element->_setSecondaryAxis($this->_axisX);
}
}
break;
}
} elseif (is_a($element, 'Image_Graph_Axis')) {
switch ($element->_type) {
case IMAGE_GRAPH_AXIS_X:
$this->_axisX =& $element;
break;
case IMAGE_GRAPH_AXIS_Y:
$this->_axisY =& $element;
break;
case IMAGE_GRAPH_AXIS_Y_SECONDARY:
$this->_axisYSecondary =& $element;
break;
}
if ($element->_getMinimum() == $element->_getMaximum()) {
$element->_setMinimum(0);
$element->_setMaximum(1);
}
}
return $element;
}
示例9: Generate
/**
* Generate
* Generates the charts from the data passed into it
*
* @param chart Array of data and labels
*
* @return Void Doesn't return anything.
*/
function Generate($chart) {
$this->graph->add(
$PlotArea =& new Image_Graph_Plotarea()
);
$this->graph->_outputImage = false;
switch ($chart['chart_type']) {
case 'column':
// Add grid
$PlotArea->addGridY(new Image_Graph_Grid_Lines());
$PlotArea->addGridX(new Image_Graph_Grid_Lines());
$labels = array_shift($chart['chart_data']);
$legend_labels = array();
$DataSets = array();
foreach ($chart['chart_data'] as $data) {
$Dataset =& new Image_Graph_Dataset_Trivial();
foreach ($data as $key => $value) {
if (!is_numeric($value)) {
if ($key == 0) {
$legend_labels[] = $value;
}
continue;
}
$Dataset->addPoint($key, $value);
}
$DataSets[] =& $Dataset;
}
$PlotMultiple =& new Image_Graph_Plot_Bar_Multiple($DataSets);
$PlotMultiple->spacing(3);
$PlotMultiple->setXValueWidth(1);
$Plot1 =& $PlotArea->addPlot($PlotMultiple);
$noBorder =& new Image_Graph_Line_Solid();
$noBorder->setThickness(0);
// create a Y data value marker
$Marker =& $Plot1->add(new Image_Graph_Marker_Value(IMAGE_GRAPH_VALUE_Y));
//$Marker->setFillColor(0xFFFFFF);
$Marker->setBorderColor(0xFFFFFF);
$PointingMarker =& $Plot1->add(new Image_Graph_Marker_Pointing(0,-10, $Marker));
$PointingMarker->setLineStyle($noBorder);
$Plot1->setMarker($PointingMarker);
$FillArray =& new Image_Graph_Fill_Array();
foreach ($this->colors as $color) {
$FillArray->add(new Image_Graph_Fill_Gradient(IMAGE_GRAPH_GRAD_RADIAL, eval("return 0x{$color};"), eval("return 0x{$color};"), 200));
}
$Plot1->setFillStyle($FillArray);
$AxisX =& $PlotArea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(
new Image_Graph_DataPreprocessor_Array(
$labels
)
);
$thickAxis =& new Image_Graph_Line_Solid();
$thickAxis->setThickness(2);
$AxisX->setLineStyle($thickAxis);
$AxisX->setLabelInterval(1);
$AxisY =& $PlotArea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setLineStyle($thickAxis);
$AxisY->setDataPreprocessor(new Image_Graph_DataPreprocessor_Function("FormatNumber"));
$this->graph->done();
$canvas =& $this->graph->_canvas();
$canvas =& $this->DrawTitle($canvas,$this->title,true);
$this->DrawLegend($canvas,$legend_labels,'column');
break; // case column
case 'pie':
$DataSet =& new Image_Graph_Dataset_Trivial();
$Plot1 =& $PlotArea->addPlot(new Image_Graph_Plot_Pie($DataSet));
$points = $chart['chart_data'][1];
$labels = $chart['chart_data'][0];
foreach ($points as $key => $value) {
if (!is_numeric($value)) { continue; }
//.........这里部分代码省略.........
示例10: showImageData
/** Return the actual Image data
* Classes must override this.
* @param $child_html The child method's return value
* @param $param mixed: used for $Graph->done()
* @return A html fragment
*/
public function showImageData($child_html = '', $param = false)
{
require_once "Image/Graph.php";
$db = AbstractDb::getObject();
$Graph =& Image_Graph::factory("Image_Graph", array(600, 200));
$Plotarea =& $Graph->add(Image_Graph::factory("Image_Graph_Plotarea"));
$Dataset =& Image_Graph::factory("Image_Graph_Dataset_Trivial");
$Bar =& Image_Graph::factory("Image_Graph_Plot_Bar", $Dataset);
$Bar->setFillColor("#9db8d2");
$Plot =& $Plotarea->add($Bar);
$candidate_connections_sql = self::$stats->getSqlCandidateConnectionsQuery("COUNT(DISTINCT connections.user_id||connections.node_id) AS daily_connections, date_trunc('day', timestamp_in) AS date");
$db->execSql("SELECT SUM(daily_connections) AS connections, date_trunc('month', date) AS month FROM ({$candidate_connections_sql} GROUP BY date) AS daily_connections_table GROUP BY month ORDER BY month", $results, false);
if ($results != null) {
foreach ($results as $row) {
/* Cut xxxx-xx-xx xx:xx:Xx to yy-mm */
$Dataset->addPoint(substr($row['month'], 0, 7), $row['connections']);
}
}
$Graph->done($param);
unset($Graph, $Plot, $Bar, $Plotarea, $Dataset, $row, $results);
}
示例11: get_weekly_volume_graph
function get_weekly_volume_graph($userID, $connection)
{
$beg_date = new Date();
$end_date = new Date();
$wk = array(0, 0, 0, 0, 0, 0, 0);
$wk_actual = array(0, 0, 0, 0, 0, 0, 0);
$label = array(0, 0, 0, 0, 0, 0, 0);
$filename = array("filename" => "/var/www/vanhlebarsoftware/fitlog/graphs/wklygraph.jpg");
// Get current weeks and prior three weeks volume numbers and the next three weeks.
$day_of_wk = $beg_date->getDayOfWeek();
$beg_date->addDays(-($day_of_wk - 1) + 21);
$end_date->copy($beg_date);
$end_date->addDays(6);
for ($i = 0; $i < 7; $i++) {
// Get the planned volume for this particular week.
$query = "SELECT SUM(seconds) AS seconds FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='p'";
$queryStr = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='p'";
$result = @mysql_query($query, $connection);
$resultStr = @mysql_query($query, $connection);
if ($result || $resultStr) {
$tmp = 0;
if ($result) {
$row = mysql_fetch_array($result);
$tmp = convert_seconds_minutes($row["seconds"]);
}
if ($resultStr) {
$rowStr = mysql_fetch_array($resultStr);
$tmp += convert_seconds_minutes($rowStr["seconds"]);
}
$wk[$i] = $tmp;
} else {
$wk[$i] = 0;
}
// Get the actual volume for this particular week.
$query = "SELECT SUM(seconds) AS seconds FROM flmain WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
$queryStr = "SELECT SUM(seconds) AS seconds FROM flstrength WHERE workout_date>='" . $beg_date->format("%Y-%m-%d") . "' AND workout_date<='" . $end_date->format("%Y-%m-%d") . "' AND user_id=" . $userID . " AND plan_type='a'";
$result = @mysql_query($query, $connection);
$resultStr = @mysql_query($queryStr, $connection);
if ($result || $resultStr) {
$tmp = 0;
if ($result) {
$row = mysql_fetch_array($result);
$tmp = convert_seconds_minutes($row["seconds"]);
}
if ($resultStr) {
$rowStr = mysql_fetch_array($resultStr);
$tmp += convert_seconds_minutes($rowStr["seconds"]);
}
$wk_actual[$i] = $tmp;
} else {
$wk_actual[$i] = 0;
}
// Create the labels.
$label[$i] = $end_date->format("%m/%d");
// Move the dates back by one week.
$beg_date->addDays(-7);
$end_date->addDays(-7);
}
for ($i = 0; $i < 7; $i++) {
}
//Setup the graph.
$Graph =& Image_Graph::factory('graph', array(300, 210, TRUE));
$Graph->add(Image_Graph::factory('title', array('Weekly Volume - Actual vs. Planned'), 12));
$Plotarea =& $Graph->addNew('plotarea');
$Dataset =& Image_Graph::factory('dataset');
$Dataset1 =& Image_Graph::factory('dataset');
// Add the actual volume to the graph.
$Dataset1->addPoint($label[6], $wk_actual[6]);
$Dataset1->addPoint($label[5], $wk_actual[5]);
$Dataset1->addPoint($label[4], $wk_actual[4]);
$Dataset1->addPoint($label[3], $wk_actual[3]);
$Dataset1->addPoint($label[2], $wk_actual[2]);
$Dataset1->addPoint($label[1], $wk_actual[1]);
$Dataset1->addPoint($label[0], $wk_actual[0]);
// Add the planned volume to the graph.
$Dataset->addPoint($label[6], $wk[6]);
$Dataset->addPoint($label[5], $wk[5]);
$Dataset->addPoint($label[4], $wk[4]);
$Dataset->addPoint($label[3], $wk[3]);
$Dataset->addPoint($label[2], $wk[2]);
$Dataset->addPoint($label[1], $wk[1]);
$Dataset->addPoint($label[0], $wk[0]);
// Plot the actual data to the graph.
$Plot =& $Plotarea->addNew('line', &$Dataset);
$Plot1 =& $Plotarea->addNew('bar', &$Dataset1);
$Plot1->setFillColor('green@.8');
// Set the axis titles.
$YAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
$YAxis->setTitle('Minutes', 'vertical');
$XAxis =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X);
$XAxis->setTitle("Week", array('angle' => 0));
//Output the finished graph to the graphs directory.
$result = $Graph->done($filename);
if ($result) {
var_dump("error creating graph!");
}
}
示例12: array
$Dataset_Rainfall->addPoint('Mar', 48);
$Dataset_Rainfall->addPoint('Apr', 42);
$Dataset_Rainfall->addPoint('May', 50);
$Dataset_Rainfall->addPoint('Jun', 55);
$Dataset_Rainfall->addPoint('Jul', 67);
$Dataset_Rainfall->addPoint('Aug', 65);
$Dataset_Rainfall->addPoint('Sep', 72);
$Dataset_Rainfall->addPoint('Oct', 77);
$Dataset_Rainfall->addPoint('Nov', 80);
$Dataset_Rainfall->addPoint('Dec', 68);
$Plot_Rainfall =& $Plotarea_Weather->addNew('bar', array(&$Dataset_Rainfall), IMAGE_GRAPH_AXIS_Y_SECONDARY);
$Plot_Rainfall->setLineColor('gray');
$Plot_Rainfall->setFillColor('blue@0.1');
$Plot_Rainfall->setTitle('Average rainfall');
$DataPreprocessor_MM =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d mm');
$DataPreprocessor_DegC =& Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%d C');
$Marker_Rainfall =& $Plot_Rainfall->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
$Marker_Rainfall->setDataPreprocessor($DataPreprocessor_MM);
$PointingMarker_Rainfall =& $Plot_Rainfall->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker_Rainfall));
$Plot_Rainfall->setMarker($PointingMarker_Rainfall);
$AxisX_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX_Weather->setAxisIntersection('min');
$AxisY_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY_Weather->showLabel(IMAGE_GRAPH_LABEL_ZERO);
$AxisY_Weather->setDataPreprocessor($DataPreprocessor_DegC);
$AxisY_Weather->setTitle('Temperature', 'vertical');
$AxisYsecondary_Weather =& $Plotarea_Weather->getAxis(IMAGE_GRAPH_AXIS_Y_SECONDARY);
$AxisYsecondary_Weather->setDataPreprocessor($DataPreprocessor_MM);
$AxisYsecondary_Weather->setTitle('Rainfall', 'vertical2');
// output the graph
$Graph->done();
示例13: array
// 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('Stacked Bar Chart Sample', 12)), Image_Graph::vertical($Plotarea = Image_Graph::factory('plotarea'), $Legend = Image_Graph::factory('legend'), 90), 5));
$Legend->setPlotarea($Plotarea);
// create the dataset
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
$Datasets[] =& Image_Graph::factory('random', array(10, 0, 4, false));
// create the 1st plot as smoothed area chart using the 1st dataset
$Plot =& $Plotarea->addNew('bar', array($Datasets, 'stacked'));
// set a line color
$Plot->setLineColor('gray');
// create a fill array
$FillArray =& Image_Graph::factory('Image_Graph_Fill_Array');
$FillArray->addColor('blue@0.2');
$FillArray->addColor('yellow@0.2');
$FillArray->addColor('green@0.2');
// set a standard fill style
$Plot->setFillStyle($FillArray);
// create a Y data value marker
$Marker =& $Plot->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y);
// and use the marker on the 1st plot
$Plot->setMarker($Marker);
$Plot->setDataSelector(Image_Graph::factory('Image_Graph_DataSelector_NoZeros'));
// output the Graph
$Graph->done();
示例14: 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 . ']';
//.........这里部分代码省略.........
示例15: array
* @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);
$AxisX->setTitle('Changed interval');
} else {
$AxisX->setTitle('Default interval');
}