本文整理汇总了PHP中pImage::drawScale方法的典型用法代码示例。如果您正苦于以下问题:PHP pImage::drawScale方法的具体用法?PHP pImage::drawScale怎么用?PHP pImage::drawScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pImage
的用法示例。
在下文中一共展示了pImage::drawScale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: grafico
/**
* Gera um gráfico de linha
* @param array $dados Array no formato array('Label' => array(pontos))
* @param string $tipo linha ou barra
*/
function grafico($dados, $tipo = 'linha')
{
require_once 'exemplos/graficos/pChart/class/pDraw.class.php';
require_once 'exemplos/graficos/pChart/class/pImage.class.php';
require_once 'exemplos/graficos/pChart/class/pData.class.php';
// precisamos ter dados para montar os gráficos
$DataSet = new pData();
// Adicionando os pontos de um gráfico de linha
// horas de trabalho na semana
foreach ($dados as $label => $pontos) {
$DataSet->addPoints($pontos, $label);
}
$DataSet->setAxisName(0, 'Horas');
// unidade
$DataSet->setAxisUnit(0, 'h');
$settings = array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80);
$DataSet->setPalette("Joao", $settings);
// Labels
$DataSet->addPoints(array('Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'), 'Dias');
$DataSet->setSerieDescription('Dias', 'Dias da Semana');
$DataSet->setAbscissa('Dias');
$Graph = new pImage(700, 230, $DataSet);
$Graph->setFontProperties(array('FontName' => 'exemplos/graficos/pChart/fonts/verdana.ttf', 'FontSize' => 8));
$Graph->setGraphArea(50, 40, 670, 190);
$scale = array('GridR' => 150, 'GridG' => 150, 'GridB' => 150, 'DrawSubTicks' => true, 'CycleBackground' => true);
$Graph->drawScale($scale);
if ($tipo == 'linha') {
$Graph->drawLineChart();
} else {
$Graph->drawBarChart();
}
$Graph->drawLegend(540, 25, array('Style' => LEGEND_ROUND, 'Mode' => LEGEND_VERTICAL));
$Graph->drawText(60, 20, "Horas Trabalhadas");
$Graph->autoOutput();
}
示例2: create_common_image
function create_common_image($title, $width, $height, $data, $chart_type = 'line')
{
global $pchart_path;
/* Create the pChart object */
$myPicture = new pImage($width, $height, $data);
/* Draw the background */
$Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 1, "DashR" => 185, "DashG" => 225, "DashB" => 255);
$myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 206, "StartG" => 235, "StartB" => 235, "EndR" => 71, "EndG" => 150, "EndB" => 205, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, $width, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/arialbd.ttf", "FontSize" => 9));
$myPicture->drawText(24, 12, win2uni($title), array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLELEFT));
$myPicture->drawFromPNG(4, 4, "includes/design/images/chart_pie.png");
if ($chart_type == 'line') {
$myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/arial.ttf", "FontSize" => 8));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 64, 450 + 200, 190);
$myPicture->drawFilledRectangle(60, 50, 450 + 200, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -255, "Alpha" => 60));
$myPicture->drawScale(array("Mode" => SCALE_MODE_START0, "DrawSubTicks" => FALSE, "GridR" => 151, "GridG" => 197, "GridB" => 254, "GridAlpha" => 30));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
}
$myPicture->setFontProperties(array("FontName" => $pchart_path . "/fonts/pf_arma_five.ttf", "FontSize" => 6));
return $myPicture;
}
示例3: index
function index()
{
$width = 600;
$height = 230;
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Female");
$MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Male");
//$MyData->addPoints(array(2,0,5,18,19,22),"Probe 3");
$MyData->setSerieTicks("Male", 4);
$MyData->setAxisName(0, "Number of males, females");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage($width, $height, $MyData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
//$myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
//$myPicture->setFontProperties(array("FontName"=>pClass."fonts/Silkscreen.ttf","FontSize"=>6));
//$myPicture->drawText(10,13,"drawBarChart() - draw a bar chart",array("R"=>255,"G"=>255,"B"=>255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(250, 55, "Average time to find a set", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("DrawSubTicks" => TRUE));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->setFontProperties(array("FontName" => pClass . "fonts/pf_arma_five.ttf", "FontSize" => 10));
$myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 30));
//$myPicture->drawBarChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Surrounding"=>30));
$myPicture->setShadow(FALSE);
/* Draw the scale and the 2nd chart */
/*
$myPicture->setGraphArea(500,60,670,190);
$myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE));
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->drawBarChart();
$myPicture->setShadow(FALSE);
*/
/* Write the chart legend */
//$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
$myPicture->drawLegend(500, 105, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
/* Render the picture (choose the best way) */
$myPicture->stroke();
}
示例4: renderChart
function renderChart($chartType, $title, $prepData, $legend)
{
$width = 800;
$height = 500;
$titleHeight = 20;
/*
* Create a dataset we can use
*/
$dataSet = array_values($prepData);
$imgData = new pData();
if ($chartType == "bar") {
$imgData->addPoints($dataSet, "data");
$imgData->addPoints($legend, "legend");
$imgData->setAbscissa("legend");
$imgData->setPalette("data", array("R" => 0, "G" => 108, "B" => 171, "Alpha" => 100));
$img = new pImage($width, $height, $imgData);
$img->drawGradientArea(0, $titleHeight, $width, $height, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 18, "EndG" => 52, "EndB" => 86, "Alpha" => 100));
$img->drawGradientArea(0, 0, $width, $titleHeight, DIRECTION_VERTICAL, array("StartR" => 18, "StartG" => 52, "StartB" => 86, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
$img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Bold.ttf", "FontSize" => 10));
$img->drawText($width / 2, 13, $title, array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255));
$img->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "images/ttf/liberation-sans/LiberationSans-Regular.ttf", "FontSize" => 9));
$img->setGraphArea(60, $titleHeight + 20, $width - 50, $height - 30);
$img->drawScale(array("GridR" => 200, "GridG" => 200, "GridB" => 200, "Mode" => SCALE_MODE_START0));
$img->drawBarChart(array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Surrounding" => 10));
} elseif ($chartType == "3Dpie") {
$imgData->addPoints($dataSet, "data");
$imgData->addPoints($legend, "legend");
$imgData->setAbscissa("legend");
$img = new pImage($width, $height, $imgData, TRUE);
$PieChart = new pPie($img, $imgData);
$img->drawGradientArea(0, $titleHeight, $width, $height, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 18, "EndG" => 52, "EndB" => 86, "Alpha" => 100));
$img->drawGradientArea(0, 0, $width, $titleHeight, DIRECTION_VERTICAL, array("StartR" => 18, "StartG" => 52, "StartB" => 86, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
$img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Bold.ttf", "FontSize" => 10));
$img->drawText($width / 2, 13, $title, array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 255, "G" => 255, "B" => 255));
$PieChart->setSliceColor(0, array("R" => 0, "G" => 108, "B" => 171));
$PieChart->setSliceColor(1, array("R" => 205, "G" => 159, "B" => 0));
$PieChart->setSliceColor(2, array("R" => 0, "G" => 171, "B" => 0));
$PieChart->setSliceColor(3, array("R" => 171, "G" => 28, "B" => 0));
$img->setFontProperties(array("FontName" => "images/ttf/liberation-sans/LiberationSans-Regular.ttf", "FontSize" => 9));
$PieChart->draw3DPie($width / 2, $height / 2 + $titleHeight, array("Radius" => $width / 2 - 100, "SecondPass" => TRUE, "DrawLabels" => TRUE, "WriteValues" => TRUE, "Precision" => 2, "ValueR" => 0, "ValueG" => 0, "ValueB" => 0, "ValueAlpha" => 100, "SkewFactor" => 0.6, "LabelR" => 255, "LabelG" => 255, "LabelB" => 255, "LabelAlpha" => 100));
}
# if
if (isset($img)) {
ob_start();
$img->render(NULL);
$imageString = ob_get_clean();
$dimensions = $this->_svcImageUtil->getImageDimensions($imageString);
return array('metadata' => $dimensions, 'content' => $imageString);
} else {
return false;
}
# else
}
示例5: RenderValueChart
function RenderValueChart(&$debug2)
{
$conditions = [["BETWEEN 1 AND 19"], ["BETWEEN 20 AND 49"], ["BETWEEN 50 AND 99"], ["BETWEEN 100 AND 199"], ["BETWEEN 200 AND 299"], ["BETWEEN 300 AND 499"], ["BETWEEN 500 AND 999"], ["> 999"]];
$label = ["1-19", "20-49", "50-99", "100-199", "200-299", "300-499", "500-999", ">1000"];
coinValueCount($conditions, $array_result);
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($array_result, "Värde (kr)");
$MyData->setAxisName(0, "Antal");
$MyData->addPoints($label, "Months");
$MyData->setSerieDescription("Months", "Month");
$MyData->setAbscissa("Months");
/* Create the cache object */
$myCache1 = new pCache(array("CacheFolder" => PCHART_PATH . "/class/cache"));
/* Compute the hash linked to the chart data */
$ChartHash1 = $myCache1->getHash($MyData);
/* Test if we got this hash in our cache already */
if ($myCache1->isInCache($ChartHash1)) {
/* If we have it, get the picture from the cache! */
$myCache1->saveFromCache($ChartHash1, WWW_PATH . "/tmp/valuechart.png");
$debug2 = "Old image";
} else {
/* Create the pChart object */
$myPicture = new pImage(700, 400, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = TRUE;
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 399, array("R" => 0, "G" => 0, "B" => 0));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => PCHART_PATH . "/fonts/Forgotte.ttf", "FontSize" => 15, "R" => 80, "G" => 80, "B" => 80));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 650, 350);
/* Draw the scale */
$scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_START0);
$myPicture->drawScale($scaleSettings);
/* Write the chart legend */
$myPicture->drawLegend(340, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "DisplayR" => 255, "DisplayG" => 255, "DisplayB" => 255, "DisplayShadow" => TRUE, "Surrounding" => 10);
$myPicture->drawBarChart();
/* Push the rendered picture to the cache */
$myCache1->writeToCache($ChartHash1, $myPicture);
/* Render the picture (choose the best way) */
$myPicture->Render(WWW_PATH . "/tmp/valuechart.png");
$debug2 = "Picture rendered";
}
}
示例6: pData
//.........这里部分代码省略.........
// Make scales based on 5% of the range of values
$scaleMax = round($range * 0.05 + $scaleMax);
if ($scaleMin < 0) {
$scaleMin = $scaleMin - round($range * 0.05);
}
$AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
$scaleSettings["Mode"] = SCALE_MODE_MANUAL;
$scaleSettings["ManualScale"] = $AxisBoundaries;
} else {
if ($barexists) {
$scaleMin = "Unknown";
$scaleMax = 0;
foreach ($this->plot as $k => $v) {
if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
$series = $v["name"] . $k;
$min = $graphData->getMin($series);
if ($scaleMin == "Unknown" || $min < $scaleMin) {
$scaleMin = $min;
}
$max = $graphData->getMax($series);
if ($scaleMax == "Unknown" || $max > $scaleMax) {
$scaleMax = $max;
}
}
}
if ($scaleMin > 0) {
$scaleMin = 0;
}
$range = $scaleMax - $scaleMin;
// Make scales based on 5% of the range of values
$scaleMax = round($range * 0.05 + $scaleMax);
if ($scaleMin < 0) {
$scaleMin = $scaleMin - round($range * 0.05);
}
$AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
$scaleSettings["Mode"] = SCALE_MODE_MANUAL;
$scaleSettings["ManualScale"] = $AxisBoundaries;
}
}
$graphImage->drawScale($scaleSettings);
// If there's a Pie chart we want to draw different legends
$piechart = false;
foreach ($this->plot as $k => $v) {
foreach ($this->plot as $k1 => $v1) {
$series = $v1["name"] . $k1;
$graphData->setSerieDrawable($series, FALSE);
}
$series = $v["name"] . $k;
$graphData->setSerieDrawable($series, TRUE);
switch ($v["type"]) {
case "PIE":
$piechart = true;
$pie = new pPie($graphImage, $graphData);
//$pie->draw2DPie($width_actual / 2,$height_actual / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE));
$pie->draw2DPie($width_actual / 2, $height_actual / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255));
break;
case "PIE3D":
$piechart = true;
$pie = new pPie($graphImage, $graphData);
$pie->draw3DPie($this->width_actual / 2, $this->height_actual / 2, 80, array("SecondPass" => FALSE));
break;
case "STACKEDBAR":
case "BAR":
if ($stackeddrawn) {
break;
}
if ($barexists) {
foreach ($this->plot as $k1 => $v1) {
if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR") {
$graphData->setSerieDrawable($v1["name"] . $k1, TRUE);
}
}
}
$stackeddrawn = true;
$settings = array("Surrounding" => -30, "InnerSurrounding" => 30);
if ($stackedexists) {
$graphImage->drawStackedBarChart($settings);
} else {
$graphImage->drawBarChart($settings);
}
break;
case "LINE":
default:
if (count($v["data"]) == 1) {
$v["data"][] = 0;
}
$graphImage->drawLineChart($settings);
break;
}
}
$graphData->drawAll();
if ($piechart) {
$pie->drawPieLegend($this->width_actual - 100, 30, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
} else {
$graphImage->drawLegend($this->width_actual - 180, 22, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
}
$graphImage->setShadow(TRUE, array("X" => 0, "Y" => 0, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$graphImage->render($outputfile);
return true;
}
示例7: pData
/* CAT:Bar Chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(13251, 4118, 3087, 1460, 1248, 156, 26, 9, 8), "Hits");
$MyData->setAxisName(0, "Hits");
$MyData->addPoints(array("Firefox", "Chrome", "Internet Explorer", "Opera", "Safari", "Mozilla", "SeaMonkey", "Camino", "Lunascape"), "Browsers");
$MyData->setSerieDescription("Browsers", "Browsers");
$MyData->setAbscissa("Browsers");
$MyData->setAbscissaName("Browsers");
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC, 1);
/* Create the pChart object */
$myPicture = new pImage(500, 500, $MyData);
$myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the chart scale */
$myPicture->setGraphArea(100, 30, 480, 480);
$myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM));
//
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30));
/* Write the legend */
$myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBarChart.vertical.png");
示例8: array
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawStackedBarChart() - draw a stacked bar chart", array("R" => 255, "G" => 255, "B" => 255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(250, 55, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawStackedBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 60));
$myPicture->setShadow(FALSE);
/* Draw the scale and the 2nd chart */
$myPicture->setGraphArea(500, 60, 670, 190);
$myPicture->drawFilledRectangle(500, 60, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL, "DrawSubTicks" => TRUE));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawStackedBarChart();
$myPicture->setShadow(FALSE);
/* Write the chart legend */
$myPicture->drawLegend(510, 205, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.png");
示例9: PlotLine
function PlotLine($rowX, $rowY, $name, $ch)
{
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pData.class.php";
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pDraw.class.php";
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pImage.class.php";
include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pPie.class.php";
//**************************************
$myData = new pData();
$myData->addPoints($rowX, "Serie1");
$myData->setSerieDescription("Serie1", $name);
//$myData->setSerieOnAxis("Serie1",0);
$myData->addPoints($rowY, "Absissa");
$myData->setAbscissa("Absissa");
//$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa");
//$myData->setAbscissa("Absissa");
$myData->setAxisPosition(0, AXIS_POSITION_LEFT);
//$myData->setAxisName(0,"1st axis");
$myData->setAxisUnit(0, "");
$myPicture = new pImage(700, 230, $myData);
$Settings = array("R" => 240, "G" => 242, "B" => 241, "Dash" => 1, "DashR" => 260, "DashG" => 262, "DashB" => 261);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
$Settings = array("StartR" => 252, "StartG" => 255, "StartB" => 254, "EndR" => 252, "EndG" => 255, "EndB" => 254, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14));
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 252, "G" => 252, "B" => 252, "DrawBox" => 1, "BoxAlpha" => 30);
//$myPicture->drawText(350,25,$name,$TextSettings);
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 50, 675, 190);
//$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
$Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
$myPicture->drawScale($Settings);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Config = "";
if ($ch == 1) {
$myPicture->drawSplineChart($Config);
}
if ($ch == 2) {
$myPicture->drawBarChart($Config);
}
if ($ch == 3) {
$myPicture->drawLineChart($Config);
}
if ($ch == 4) {
$myPicture->drawPlotChart($Config);
}
if ($ch == 5) {
$myPicture->drawStepChart($Config);
}
if ($ch == 6) {
$myPicture->drawAreaChart($Config);
}
if ($ch == 7) {
$myPicture->drawFilledSplineChart($Config);
}
if ($ch == 8) {
$myPicture->drawFilledStepChart($Config);
}
if ($ch == 9) {
$myPicture->drawStackedAreaChart($Config);
}
$Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
$myPicture->drawLegend(563, 16, $Config);
$myPicture->stroke();
}
示例10: pData
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->loadPalette("../palettes/blind.color", TRUE);
$MyData->addPoints(array(150, 220, 300, 250, 420, 200, 300, 200, 110), "Server A");
$MyData->addPoints(array("January", "February", "March", "April", "May", "Juin", "July", "August", "September"), "Months");
$MyData->setSerieDescription("Months", "Month");
$MyData->setAbscissa("Months");
/* Create the floating 0 data serie */
$MyData->addPoints(array(60, 80, 20, 40, 40, 50, 90, 30, 100), "Floating 0");
$MyData->setSerieDrawable("Floating 0", FALSE);
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 110, "G" => 110, "B" => 110));
/* Write the title */
$myPicture->drawText(10, 13, "Net Income 2k8");
/* Set the graphical area */
$myPicture->setGraphArea(50, 30, 680, 180);
/* Draw the scale */
$AxisBoundaries = array(0 => array("Min" => 0, "Max" => 500));
$myPicture->drawScale(array("InnerTickWidth" => 0, "OuterTickWidth" => 0, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "LabelRotation" => 45, "DrawXLines" => FALSE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridTicks" => 0, "GridAlpha" => 30, "AxisAlpha" => 0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$settings = array("Floating0Serie" => "Floating 0", "Surrounding" => 10);
$myPicture->drawBarChart($settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBarChart.span.png");
示例11: pImage
$MyData->setAxisName(0, "Temperature");
$MyData->setAxisName(1, "Humidity");
$MyData->setAxisName(2, "Empty value");
/* Create the abscissa serie */
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "My labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawScale() - draw the X-Y scales", array("R" => 255, "G" => 255, "B" => 255));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
/* Write the chart title */
$myPicture->setGraphArea(90, 60, 660, 190);
$myPicture->drawText(350, 55, "My chart title", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
$myPicture->drawFilledRectangle(90, 60, 660, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
/* Draw the scale */
$myPicture->drawScale(array("DrawYLines" => array(0), "Pos" => SCALE_POS_LEFTRIGHT));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawScale.multiple.png");
开发者ID:Esleelkartea,项目名称:herramienta_para_autodiagnostico_ADEADA,代码行数:31,代码来源:example.drawScale.multiple.php
示例12: drawBarChart
protected function drawBarChart(ChartDataset $CDs)
{
if (!extension_loaded("gd") && !extension_loaded("gd2")) {
/* Extension not loaded */
// NO BARCHARTS AND ERRORS FOR YOU!
return;
}
/* Create and populate the pData object */
$MyData = new pData();
if (empty($CDs->data)) {
return;
}
//print_r($CDs->data);
foreach ($CDs->data as $points) {
//print_r($points);
$MyData->addPoints($points["points"], $points["label"]);
}
$MyData->setAxisName(0, "Amount Sold");
$MyData->setSerieDescription($points["label"], $points["label"]);
$MyData->setAbscissa($points["label"]);
/* Create the pChart object */
$myPicture = new pImage(1000, 230, $MyData);
// the horrible way to add fonts is just one bunch of fucked up shit, not making sense. bullshit parameters and paths.
//$myPicture->setFontProperties(array("FontName"=>"Bedizen"));
$myPicture->setFontProperties(array("FontName" => "pChart2.1.4//fonts/calibri.ttf", "FontSize" => 11));
//print_r(is_file("C:/xampp_jan2015/htdocs/hackerbar/web/fonts/GeosansLight.ttf"));
/* Turn of Antialiasing */
$myPicture->Antialias = false;
/* Add a border to the picture */
$myPicture->drawGradientArea(0, 0, 1000, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 1000, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
$myPicture->drawRectangle(0, 0, 999, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Set the default font */
//$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 850, 200);
/* Draw the scale */
$scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Write the chart legend */
$myPicture->drawLegend(860, 25, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$settings = array("Surrounding" => -30, "InnerSurrounding" => 30);
$myPicture->drawBarChart($settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("images/barcharts/" . $points["label"] . ".png");
//$myPicture->auto
$myPicture->render("myfile.png");
}
示例13: array
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawLabel() - Write labels over your charts", array("R" => 255, "G" => 255, "B" => 255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(155, 55, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 60, 670, 190);
$myPicture->drawFilledRectangle(60, 60, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawScale(array("DrawSubTicks" => TRUE));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawSplineChart();
$myPicture->setShadow(FALSE);
/* Write the chart legend */
$myPicture->drawLegend(600, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Write a label over the chart */
$LabelSettings = array("TitleR" => 255, "TitleG" => 255, "TitleB" => 255, "DrawSerieColor" => FALSE, "TitleMode" => LABEL_TITLE_BACKGROUND, "OverrideTitle" => "Information", "ForceLabels" => array("Issue with the recording device", "New recording device"), "GradientEndR" => 220, "GradientEndG" => 255, "GradientEndB" => 220, "TitleBackgroundG" => 155);
$myPicture->writeLabel(array("Probe 2"), array(1, 3), $LabelSettings);
/* Write a label over the chart */
$LabelSettings = array("NoTitle" => TRUE, "GradientEndR" => 255, "GradientEndG" => 200, "GradientEndB" => 200);
$myPicture->writeLabel(array("Probe 1"), 5, $LabelSettings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawLabel.caption.png");
示例14: pData
/* CAT:Bar Chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->loadPalette("../palettes/light.color", TRUE);
$MyData->addPoints(array(150, 220, 300, -250, -420, -200, 300, 200, 100), "Server A");
$MyData->addPoints(array(140, 0, 340, -300, -320, -300, 200, 100, 50), "Server B");
$MyData->setAxisName(0, "Hits");
$MyData->addPoints(array("January", "February", "March", "April", "May", "Juin", "July", "August", "September"), "Months");
$MyData->setSerieDescription("Months", "Month");
$MyData->setAbscissa("Months");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale */
$myPicture->setGraphArea(50, 30, 680, 200);
$myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "DisplayR" => 255, "DisplayG" => 255, "DisplayB" => 255, "DisplayShadow" => TRUE, "Surrounding" => 10);
$myPicture->drawBarChart($settings);
/* Write the chart legend */
$myPicture->drawLegend(580, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBarChart.can.png");
示例15: plotBarChart
protected function plotBarChart(pImage $picture, $options = array())
{
$picture->setShadow(FALSE);
$Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "DrawXLines" => FALSE, "DrawYLines" => ALL, "GridTicks" => 1, "GridR" => 168, "GridG" => 186, "GridB" => 203, "GridAlpha" => 30, "AxisR" => 40, "AxisG" => 40, "AxisB" => 43, "AxisAlpha" => 100, "TickR" => 40, "TickG" => 40, "TickB" => 43, "TickAlpha" => 50, "DrawSubTicks" => 1, "SubTickR" => 168, "SubTickG" => 186, "SubTickB" => 203, "SubTickAlpha" => 100, "DrawArrows" => false, "CycleBackground" => false, "LabelRotation" => 90);
$Settings = array_merge($Settings, $options);
$picture->drawScale($Settings);
$options = array('AroundZero' => true, 'Draw0Line' => true);
$picture->drawBarChart($options);
$Config = array("FontName" => sfConfig::get('sf_web_dir') . "/fonts/Ubuntu-R.ttf", "FontSize" => 6, "FontR" => 40, "FontG" => 40, "FontB" => 43, "Margin" => 6, "Alpha" => 100, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL, "Family" => LEGEND_FAMILY_LINE);
$picture->drawLegend(655, 50, $Config);
return $picture;
}