Example #1
0
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;
}
/**
 * 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();
}
Example #3
0
function createGraphe($vData, $hData, $titre, $vLabel, $hLabel)
{
    $MyData = new pData();
    /*Je présente ma série de données à utiliser pour le graphique et je détermine le titre de l'axe vertical avec setAxisName*/
    $MyData->addPoints($vData, "vertical");
    $MyData->setSerieWeight("vertical", 2);
    $MyData->setAxisName(0, $vLabel);
    /*J'indique les données horizontales du graphique. Il doit y avoir le même nombre que pour ma série de données précédentes (logique)*/
    $MyData->addPoints($hData, "horizontal");
    $MyData->setSerieDescription("horizontal", $hLabel);
    $MyData->setAbscissa("horizontal");
    $MyData->setPalette("vertical", array("R" => 255, "G" => 0, "B" => 0));
    /* Je crée l'image qui contiendra mon graphique précédemment crée */
    $myPicture = new pImage(900, 400, $MyData);
    /* Je crée une bordure à mon image */
    $myPicture->drawRectangle(0, 0, 899, 399, array("R" => 0, "G" => 0, "B" => 0));
    /* J'indique le titre de mon graphique, son positionnement sur l'image et sa police */
    $myPicture->setFontProperties(array("FontName" => "./pChart2.1.4/fonts/Forgotte.ttf", "FontSize" => 11));
    $myPicture->drawText(200, 25, $titre, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
    /* Je choisi la font de mon graphique */
    $myPicture->setFontProperties(array("FontName" => "./pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6));
    /* Je détermine la taille du graphique et son emplacement dans l'image */
    $myPicture->setGraphArea(60, 40, 800, 380);
    /* Paramètres pour dessiner le graphique à partir des deux abscisses */
    $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => FALSE, "CycleBackground" => TRUE, "LabelSkip" => 4);
    $myPicture->drawScale($scaleSettings);
    /* Je dessine mon graphique en fonction des paramètres précédents */
    $myPicture->drawAreaChart();
    $myPicture->drawLineChart();
    /* J'indique le chemin où je souhaite que mon image soit créée */
    $myPicture->Render("img/" . $titre . ".png");
}
 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();
 }
 /**
  * Sets fonts and sizes
  * 
  * @param pData $myData People's Years data
  * 
  * @return pImage the Chart Image Box
  */
 protected static function listadoPersonasXedadConfigChart($myData)
 {
     /* Create the pChart object */
     $myPicture = new pImage(300, 230, $myData);
     /* Write the picture title */
     $myPicture->setFontProperties(array("FontName" => PathsUtils::$chartFontsDir . "/Silkscreen.ttf", "FontSize" => 6));
     $myPicture->drawText(10, 13, "Recuento de Años de nacimiento", array("R" => 255, "G" => 255, "B" => 255));
     /* Set the default font properties */
     $myPicture->setFontProperties(array("FontName" => PathsUtils::$chartFontsDir . "/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     return $myPicture;
 }
Example #6
0
 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
 }
Example #7
0
 protected function getTextWidthHeight($text, $fontSize = false)
 {
     if (!$fontSize) {
         $fontSize = $this->fontSize;
     }
     if (!$this->pImage) {
         $this->initpImage();
     }
     // could not find a way to get pixel perfect width & height info using imageftbbox
     $textInfo = $this->pImage->drawText(0, 0, $text, array('Alpha' => 0, 'FontSize' => $fontSize, 'FontName' => $this->font));
     return array($textInfo[1]["X"] + 1, $textInfo[0]["Y"] - $textInfo[2]["Y"]);
 }
 /**
  * Setup the image to display an error message if something went wrong.
  */
 protected function setupError()
 {
     $this->chartImage = new pImage(590, 350);
     if (array_key_exists('error_message', $this->args)) {
         $error_msg = $this->args['error_message'];
     } else {
         $error_msg = "An error occurred with the chart.";
         I2CE::getConfig()->setIfIsSet($error_msg, "/modules/pChart/defaults/error_message");
     }
     $msgs = explode("\n", wordwrap($error_msg, 50, "\n", true));
     $this->setFont(null, 20);
     for ($place = 30; $place <= 350; $place += 30) {
         if (count($msgs) == 0) {
             break;
         }
         $msg = array_shift($msgs);
         $this->chartImage->drawText(10, $place, $msg);
     }
 }
Example #9
0
function ring2d($x, $y, $name)
{
    $MyData = new pData();
    $MyData->addPoints($x, "ScoreA");
    $MyData->setSerieDescription("ScoreA", "Application A");
    /* Define the absissa serie */
    $MyData->addPoints($y, "Labels");
    $MyData->setAbscissa("Labels");
    /* Create the pChart object */
    $myPicture = new pImage(500, 250, $MyData);
    /* Draw a solid background */
    $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
    $myPicture->drawFilledRectangle(0, 0, 500, 500, $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, 500, 500, DIRECTION_VERTICAL, $Settings);
    $myPicture->drawGradientArea(0, 0, 500, 30, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
    /* Add a border to the picture */
    $myPicture->drawRectangle(0, 0, 500, 250, array("R" => 0, "G" => 0, "B" => 0));
    /* Write the picture title */
    $myPicture->setFontProperties(array("FontName" => "mod/pchart/fonts/verdana.ttf", "FontSize" => 12));
    $myPicture->drawText(15, 20, $name, array("R" => 255, "G" => 255, "B" => 255));
    /* Set the default font properties */
    $myPicture->setFontProperties(array("FontName" => "mod/pchart/fonts/verdana.ttf", "FontSize" => 12, "R" => 80, "G" => 80, "B" => 80));
    /* Enable shadow computing */
    $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50));
    /* Create the pPie object */
    $PieChart = new pPie($myPicture, $MyData);
    /* Draw an AA pie chart */
    $PieChart->draw2DRing(390, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "Border" => TRUE));
    /* Write the legend box */
    $myPicture->setShadow(FALSE);
    $PieChart->drawPieLegend(10, 50, array("Alpha" => 20));
    /* Render the picture (choose the best way) */
    $myPicture->autoOutput("2dring.png");
}
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");
$myData->setScatterSerieDescription(0, "Trigonometric function");
$myData->setScatterSerieTicks(0, 4);
$myData->setScatterSerieColor(0, array("R" => 180, "G" => 0, "B" => 0));
$myData->setScatterSeriePicture(0, "resources/chart_line.png");
/* Create the pChart object */
$myPicture = new pImage(400, 400, $myData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 400, 400, $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, 400, 400, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 400, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawScatterLineChart() - Draw a scatter line chart", array("R" => 255, "G" => 255, "B" => 255));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 399, 399, array("R" => 0, "G" => 0, "B" => 0));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Set the graph area */
$myPicture->setGraphArea(50, 50, 350, 350);
/* Create the Scatter chart object */
$myScatter = new pScatter($myPicture, $myData);
/* Draw the scale */
$myScatter->drawScatterScale();
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw a scatter plot chart */
$myScatter->drawScatterLineChart();
/* Draw the legend */
}
$MyData->setAxisName(0, "Size (cm)");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
$MyData->setAbscissaName("Time (years)");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw the background and the border  */
$myPicture->drawFilledRectangle(0, 0, 699, 229, array("R" => 200, "G" => 200, "B" => 200));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 100, "EndG" => 100, "EndB" => 100, "Alpha" => 30));
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(150, 35, "Size by time generations", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(40, 40, 680, 200);
/* Draw the scale */
$scaleSettings = array("LabelSkip" => 4, "XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridAlpha" => 30, "GridR" => 140, "GridG" => 140, "GridB" => 140, "DrawSubTicks" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the line chart */
$myPicture->drawZoneChart("Bounds 1", "Bounds 2", array("LineAlpha" => 100, "AreaR" => 230, "AreaG" => 230, "AreaB" => 230, "AreaAlpha" => 20, "LineTicks" => 3));
$MyData->setSerieDrawable(array("Bounds 1", "Bounds 2"), FALSE);
/* Draw the line chart */
$myPicture->drawLineChart();
$myPicture->drawPlotChart(array("PlotBorder" => TRUE, "PlotSize" => 2, "BorderSize" => 3, "Surrounding" => 60, "BorderAlpha" => 50));
$MyData->setAxisName(0, "Strength");
for ($i = 0; $i <= 720; $i = $i + 20) {
    $MyData->addPoints(cos(deg2rad($i)) * 100, "Probe 1");
    $MyData->addPoints(cos(deg2rad($i + 90)) * 60, "Probe 2");
}
/* Create the pChart object */
$myPicture = new pImage(847, 304, $MyData);
$myPicture->drawGradientArea(0, 0, 847, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 17, "EndG" => 17, "EndB" => 17, "Alpha" => 100));
$myPicture->drawGradientArea(0, 250, 847, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 27, "EndG" => 27, "EndB" => 27, "Alpha" => 100));
$myPicture->drawLine(0, 249, 847, 249, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawLine(0, 250, 847, 250, array("R" => 70, "G" => 70, "B" => 70));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 846, 303, array("R" => 204, "G" => 204, "B" => 204));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawText(423, 14, "Cyclic magnetic field strength", array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLEMIDDLE));
/* Define the chart area */
$myPicture->setGraphArea(58, 27, 816, 228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(58, 27, 816, 228, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw the scale */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$ScaleSettings = array("XMargin" => 4, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
$myPicture->drawScale($ScaleSettings);
/* Draw the spline chart */
$myPicture->drawFilledSplineChart();
/* Write the chart boundaries */
$BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
$myPicture->writeBounds(BOUND_BOTH, $BoundsSettings);
Example #14
0
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
$MyData->setSerieTicks("Probe 1", 4);
$MyData->setAxisName(0, "Spanung in [mV]");
/* Create the pChart object */
$myPicture = new pImage(800, 400, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Add a border to the picture */
//$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));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 799, 399, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "libs/pChart2.1.4/fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(150, 35, "Spannungsverlauf seit Ladung", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "libs/pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 750, 370);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "GridAlpha" => 100, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Write the chart legend */
//$myPicture->drawLegend(640,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Enable shadow computing */
//$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
/* Draw the area chart */
//$Threshold = "";
Example #15
0
/* Draw the background */
$Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 0, "DashR" => 255, "DashG" => 255, "DashB" => 255);
$myPicture->drawFilledRectangle(0, 0, 700, 450, $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,800,350,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(800,350,0,0,array("R"=>0,"G"=>0,"B"=>0));
/* Write the chart title */
// $myPicture->setFontProperties(array("FontName"=>"./fonts/simsun.ttc","FontSize"=>8,"R"=>255,"G"=>255,"B"=>255));
//$myPicture->drawText(10,16,"Average recorded temperature",array("FontSize"=>11,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0));
/* Define the chart area */
$myPicture->drawText(200, 60, $chart_title);
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0));
$myPicture->setGraphArea(40, 60, 800, 400);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "Mode" => SCALE_MODE_START0, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 45, "LabelSkip" => $row_number / 60);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the line chart */
$myPicture->drawLineChart();
//$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
/* Write the chart legend */
//$myPicture->drawLegend(590,9,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL,"FontR"=>255,"FontG"=>255,"FontB"=>255));
//$myPicture->drawLegend(100,40,array("Style"=>LEGEND_FAMILY_BOX,"Mode"=>LEGEND_VERTICAL));
Example #16
0
$myPicture = new pImage($width, $height, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the background */
//$myPicture->drawFilledRectangle(3,0,$width-1,$height-4,array("R"=>120, "G"=>185, "B"=>255, "Dash"=>0, "DashR"=>255, "DashG"=>255, "DashB"=>255));
$myPicture->drawFilledRectangle(3, 0, $width - 1, $height - 4, array("R" => 120, "G" => 215, "B" => 180, "Dash" => 0, "DashR" => 255, "DashG" => 255, "DashB" => 255));
$myPicture->drawRectangle(3, 0, $width - 1, $height - 4, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawFilledRectangle(0, 3, $width - 4, $height - 1, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 85));
$myPicture->drawRectangle(0, 3, $width - 4, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
/* Overlay with a gradient */
// $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
// $myPicture->drawGradientArea(0,0,800,350,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));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font_t, "R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(5, 5 + $font_t * 2, $chart_title);
$myPicture->setFontProperties(array("FontName" => "./fonts/simhei.ttf", "FontSize" => $font, "R" => 0, "G" => 0, "B" => 0));
$myPicture->setGraphArea(55, 15 + $font_t * 2, $width * 0.9 - 50, $height - 50);
/* Draw the scale */
$scaleSettings = array("FLOATING" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_START0, "CycleBackground" => FALSE, "LabelRotation" => 30, "LabelSkip" => round($row_number / ($width / 30)));
$myPicture->drawScale($scaleSettings);
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1.5, "Y" => 1.5, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the line chart */
$myPicture->drawLineChart();
//$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>2,"Surrounding"=>-60,"BorderAlpha"=>80));
/* Write the data bounds */
//$myPicture->writeBounds();
/* Write the chart legend */
$myPicture->setFontProperties(array("FontName" => "./fonts/simsun.ttc", "FontSize" => $font, "R" => 0, "G" => 0, "B" => 0));
$myPicture->drawLegend($width * 0.9 - 40, 30 + $font_t * 2, array("Style" => LEGEND_BOX, "Mode" => LEGEND_VERTICAL, "Alpha" => 10, "Margin" => 4, "R" => 255, "G" => 255, "B" => 255));
 protected function plotPieChart(pImage $picture, pData $data, $options = array())
 {
     $pie = new pPie($picture, $data);
     $raw_data = $data->getData();
     $n_series = $options['n_series'];
     $series_names = array_keys($raw_data['Series']);
     $chart_height = $options['chart_height'];
     $title_height = isset($options['title_height']) ? $options['title_height'] : 50;
     $c = -1;
     foreach ($series_names as $key => $id) {
         if ('labels' == $id) {
             continue;
         }
         $c++;
         $data->setSerieDrawable($id, true);
         $posX = $c == 0 ? 225 : (($c + 1) % 2 == 1 ? 225 + 450 : 225);
         $posY = $c == 0 ? $chart_height / 2 : $chart_height / 2 + $chart_height * (floor($c / 2) + $c % 2);
         $posY = $title_height + $posY;
         // title
         $options = array('Radius' => $chart_height / 2 * 0.9, 'SkewFactore' => 0.5, 'SliceHeight' => 10, 'DataGapAngle' => 0, 'Border' => TRUE, 'BorderR' => 255, 'BorderG' => 255, 'BorderB' => 255, 'SecondPass' => true, 'WriteValues' => true, 'ValueR' => 0, 'ValueG' => 0, 'ValueB' => 0);
         $pie->draw3DPie($posX, $posY, $options);
         $data->setSerieDrawable($id, false);
         $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 40, "G" => 40, "B" => 43);
         $picture->drawText($posX, $posY - $chart_height / 2 * 0.9, $raw_data['Series'][$id]['Description'], $TextSettings);
     }
     $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);
     $pie->drawPieLegend(450, 50, $Config);
 }
$MyData->setAxisName(0, "Temperatures");
/* 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);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(160, 35, "Measured temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
$myPicture->drawText(340, 30, "(and associated standard deviation)", array("FontSize" => 10, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(60, 50, 670, 200);
/* Draw the scale */
$scaleSettings = array("LabelSkip" => 9, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the line chart */
$myPicture->drawPlotChart(array("PlotSize" => 2));
/* Compute the serie average and standard deviation */
$Average = $MyData->getSerieAverage("Probe 1");
 $MyData->addPoints($tabModule, "Labels");
 $MyData->setAbscissa("Labels");
 /* Create the pChart object */
 $myPicture = new pImage(1000, 460, $MyData);
 /* Draw a solid background */
 $Settings = array("R" => 255, "G" => 255, "B" => 255, "Dash" => 1, "DashR" => 255, "DashG" => 255, "DashB" => 255);
 $myPicture->drawFilledRectangle(0, 0, 1000, 460, $Settings);
 /* Overlay some gradient areas */
 $Settings = array("StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 240, "EndG" => 255, "EndB" => 247, "Alpha" => 90);
 $myPicture->drawGradientArea(0, 0, 1000, 460, DIRECTION_VERTICAL, $Settings);
 $myPicture->drawGradientArea(0, 0, 1000, 20, DIRECTION_VERTICAL, array("StartR" => 255, "StartG" => 99, "StartB" => 71, "EndR" => 124, "EndG" => 122, "EndB" => 122, "Alpha" => 100));
 /* Draw the border */
 $myPicture->drawRectangle(0, 0, 999, 459, array("R" => 255, "G" => 99, "B" => 71));
 /* Write the title */
 $myPicture->setFontProperties(array("FontName" => "pChart2.1.4/fonts/arial.ttf", "FontSize" => 18));
 $myPicture->drawText(10, 18, $var2["shortname"] . "    " . date('d-m-Y'), array("R" => 255, "G" => 255, "B" => 255));
 /* Define general drawing parameters */
 $myPicture->setFontProperties(array("FontName" => "pChart2.1.4/fonts/arial.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
 $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
 /* Create the radar object */
 $SplitChart = new pRadar();
 /* Draw the 1st radar chart */
 $myPicture->setGraphArea(20, 25, 995, 425);
 $Options = array("Layout" => RADAR_LAYOUT_STAR, "LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50));
 $SplitChart->drawRadar($myPicture, $MyData, $Options);
 /* Write down the legend */
 $myPicture->setFontProperties(array("FontName" => "pChart2.1.4/fonts/arial.ttf", "FontSize" => 15));
 $myPicture->drawLegend(10, 440, array("Style" => LEGEND_BOX, "Mode" => LEGEND_HORIZONTAL));
 /* Render the picture */
 $pictureName = "Charts/" . $key1 . "_" . $count_cor . ".png";
 $myPicture->Render($pictureName);
$MyData->setSerieDescription("Labels", "Months");
$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, "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));
    $Settings = array("StartR" => $StartR, "StartG" => $StartG, "StartB" => $StartB, "EndR" => $EndR, "EndG" => $EndG, "EndB" => $EndB, "Alpha" => 50);
    //$Settings = array("StartR"=>125, "StartG"=>92, "StartB"=>231, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
    if ($g_direction == "vertical") {
        $myPicture->drawGradientArea(0, 0, $anchura, $altura, DIRECTION_VERTICAL, $Settings);
    } else {
        $myPicture->drawGradientArea(0, 0, $anchura, $altura, DIRECTION_HORIZONTAL, $Settings);
    }
} else {
    $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
    $myPicture->drawGradientArea(0, 0, $anchura, $altura, DIRECTION_VERTICAL, $Settings);
}
$myPicture->drawRectangle(0, 0, $anchura - 1, $altura - 1, 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" => 255, "G" => 255, "B" => 255);
$myPicture->drawText($anchura / 2, 25, $title, $TextSettings);
$myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 10));
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 0, "G" => 0, "B" => 0);
$myPicture->drawText($anchura / 2, $altura - 20, "Evaluaciones", $TextSettings);
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 50, $anchura - 25, $altura - 40);
$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);
$AxisBoundaries = array(0 => array("Min" => 0, "Max" => 10));
$ScaleSettings = array("Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "DrawSubTicks" => TRUE, "DrawArrows" => TRUE, "ArrowSize" => 6);
$myPicture->drawScale($ScaleSettings);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
/* Create the 2nd scatter chart binding */
$myData->setScatterSerie("Probe 2", "Probe 3", 1);
$myData->setScatterSerieDescription(1, "Last Year");
$myData->setScatterSeriePicture(1, "resources/accept.png");
/* Create the pChart object */
$myPicture = new pImage(400, 400, $myData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 400, 400, $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, 400, 400, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 400, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawScatterPlotChart() - Draw a scatter plot chart", array("R" => 255, "G" => 255, "B" => 255));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 399, 399, array("R" => 0, "G" => 0, "B" => 0));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Set the graph area */
$myPicture->setGraphArea(50, 50, 350, 350);
/* Create the Scatter chart object */
$myScatter = new pScatter($myPicture, $myData);
/* Draw the scale */
$myScatter->drawScatterScale();
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw a scatter plot chart */
$myScatter->drawScatterPlotChart();
/* Draw the legend */
Example #23
0
$MyData->addPoints(array("Size", "Speed", "Reliability", "Functionalities", "Ease of use", "Weight"), "Labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Draw a solid background */
$Settings = array("R" => 179, "G" => 217, "B" => 91, "Dash" => 1, "DashR" => 199, "DashG" => 237, "DashB" => 111);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
/* Overlay some gradient areas */
$Settings = array("StartR" => 194, "StartG" => 231, "StartB" => 44, "EndR" => 43, "EndG" => 107, "EndB" => 58, "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" => 100));
/* 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, "pRadar - Draw radar charts", array("R" => 255, "G" => 255, "B" => 255));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Create the pRadar object */
$SplitChart = new pRadar();
/* Draw a radar chart */
$myPicture->setGraphArea(10, 25, 300, 225);
$Options = array("Layout" => RADAR_LAYOUT_STAR, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50), "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6);
$SplitChart->drawRadar($myPicture, $MyData, $Options);
/* Draw a radar chart */
$myPicture->setGraphArea(390, 25, 690, 225);
$Options = array("Layout" => RADAR_LAYOUT_CIRCLE, "LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6);
$SplitChart->drawRadar($myPicture, $MyData, $Options);
/* Write the chart legend */
 function generate_graph_image($outputfile)
 {
     // Create Graph Dataset and set axis attributes
     $graphData = new pData();
     $graphData->setAxisName(0, $this->ytitle_actual);
     $graphData->addPoints($this->xlabels, "xaxis");
     $graphData->setSerieDescription("xaxis", "xaxis");
     $graphData->setAbscissa("xaxis");
     $graphData->setXAxisName("ooo");
     // Add each series of plot values to dataset, but Reportico will
     // duplicate series were the same data are displayed in different forms
     // so only add each unique series once
     $seriesadded = array();
     foreach ($this->plot as $k => $v) {
         $series = $v["name"] . $k;
         $graphData->addPoints($v["data"], $series);
         $graphData->setSerieDescription($series, $v["legend"]);
     }
     /*
     $graph->xgrid->SetColor($this->xgridcolor);
     $graph->ygrid->SetColor($this->ygridcolor);
     */
     /*
     switch ( $this->xgriddisplay )
     {
     	case "all":
     		$graph->xgrid->Show(true,true);
     		break;
     	case "major":
     		$graph->xgrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->xgrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->xgrid->Show(false,false);
     		break;
     }
     
     switch ( $this->ygriddisplay )
     {
     	case "all":
     		$graph->ygrid->Show(true,true);
     		break;
     	case "major":
     		$graph->ygrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->ygrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->ygrid->Show(false,false);
     		break;
     }
     */
     /*
     $graph->xaxis->SetFont($fontfamilies[$xaxisfont],$fontstyles[$xaxisfontstyle], $xaxisfontsize);
     $graph->xaxis->SetColor($xaxiscolor,$xaxisfontcolor);
     $graph->yaxis->SetFont($fontfamilies[$yaxisfont],$fontstyles[$yaxisfontstyle], $yaxisfontsize);
     $graph->yaxis->SetColor($yaxiscolor,$yaxisfontcolor);
     $graph->xaxis->title->SetFont($fontfamilies[$xtitlefont],$fontstyles[$xtitlefontstyle], $xtitlefontsize);
     $graph->xaxis->title->SetColor($xtitlecolor);
     $graph->yaxis->title->SetFont($fontfamilies[$ytitlefont],$fontstyles[$ytitlefontstyle], $ytitlefontsize);
     $graph->yaxis->title->SetColor($ytitlecolor);
     $graph->xaxis->SetLabelAngle(90);
     $graph->xaxis->SetLabelMargin(15); 
     $graph->yaxis->SetLabelMargin(15); 
     $graph->xaxis->SetTickLabels($xlabels);
     $graph->xaxis->SetTextLabelInterval($xticklabint);
     $graph->yaxis->SetTextLabelInterval($yticklabint);
     $graph->xaxis->SetTextTickInterval($xtickinterval);
     $graph->yaxis->SetTextTickInterval($ytickinterval);
     */
     /*
     if ( $gridpos == "front" )
     	$graph->SetGridDepth(DEPTH_FRONT); 
     */
     // Display the graph
     /*?$graph->Stroke();*/
     $this->apply_defaults_internal();
     //echo "oo<BR>";
     //echo "<PRE>";
     //var_dump($graphData);
     //echo $this->width."<BR>";
     //echo $this->height_actual."<BR>";
     $graphImage = new pImage($this->width_actual, $this->height_actual, $graphData);
     /* Turn of Antialiasing */
     $graphImage->Antialias = TRUE;
     // Add gradient fill from chosen background color to white
     $startgradient = $this->htmltorgb("#ffffff");
     $color = $this->htmltorgb($this->graphcolor);
     $graphImage->drawGradientArea(0, 0, $this->width_actual, $this->height_actual, DIRECTION_VERTICAL, array("StartR" => $startgradient[0], "StartG" => $startgradient[1], "StartB" => $startgradient[2], "EndR" => $color[0], "EndG" => $color[1], "EndB" => $color[2], "Alpha" => 100));
     /* Add a border to the picture */
     $graphImage->drawRectangle(0, 0, $this->width_actual - 1, $this->height_actual - 1, array("R" => 200, "G" => 200, "B" => 200));
     /* Set the title font and draw it */
     $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->titlefont, "FontSize" => $this->titlefontsize));
     $this->titlecolor = $this->htmltorgb($this->titlecolor);
     $graphImage->drawText(20, 30, $this->title_actual, array("R" => $this->titlecolor[0], "G" => $this->titlecolor[1], "B" => $this->titlecolor[2]));
     /* Set the default font from the X title font */
     $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->xtitlefont, "FontSize" => $this->xtitlefontsize));
     /* Define the chart area */
     $graphImage->setGraphArea($this->marginleft, $this->margintop, $this->width_actual - $this->marginright, $this->height_actual - $this->marginbottom);
     //$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"LabelRotation"=>30);
     //$graphImage->drawScale($scaleSettings);
     //$settings = array("Surrounding"=>-30,"InnerSurrounding"=>30);
     //$graphImage->drawBarChart($settings);
     //$graphImage->autoOutput("pictures/example.drawBarChart.simple.png");
     //return;
     // Before plotting a series ensure they are all not drawable.
     /// Plot the chart data
     $stackeddrawn = false;
     $stackedexists = false;
     $barexists = false;
     foreach ($this->plot as $k => $v) {
         if ($v["type"] == "STACKEDBAR") {
             $stackedexists = true;
         }
         if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
             $barexists = true;
         }
     }
     /* Draw the scale */
     $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 30);
     // For stacked charts fix up the Max and Min values;
     if ($stackedexists) {
         $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;
                 }
                 $scaleMax = $scaleMax + $graphData->getMax($series);
             }
         }
         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;
     } 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;
 }
$MyData->setAxisUnit(0, "m");
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC);
/* Create the abscissa serie */
$MyData->addPoints(array(1230768000, 1233446400, 1235865600, 1238544000, 1241136000, 1243814400), "Timestamp");
$MyData->setSerieDescription("Timestamp", "Sampled Dates");
$MyData->setAbscissa("Timestamp");
$MyData->setXAxisDisplay(AXIS_FORMAT_DATE);
/* 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(60, 60, 660, 190);
$myPicture->drawText(350, 55, "My chart title", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
$myPicture->drawFilledRectangle(60, 60, 660, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
/* Draw the scale */
$myPicture->drawScale();
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawScale.dates.png");
Example #26
0
            $myPicture->setFontProperties(array("FontName" => "./fonts/msyh.ttf", "FontSize" => $font_t, "R" => 0, "G" => 0, "B" => 0));
            $scaleRGB = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "GridAlpha" => 100);
        } else {
            if ($bg == 3) {
                $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
                $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
                $myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
                $myPicture->setFontProperties(array("FontName" => "./fonts/msyh.ttf", "FontSize" => $font_t, "R" => 0, "G" => 0, "B" => 0));
                $scaleRGB = array("GridR" => 200, "GridG" => 200, "GridB" => 200);
            }
        }
    }
}
/* Draw Title */
$marg = min(min($width, $height) * 0.04, 10);
$myPicture->drawText($marg, $marg, $chart_title, array("Align" => TEXT_ALIGN_TOPLEFT));
/* Deal Chart Data and Draw Chart*/
if (isset($err)) {
    $myPicture->drawText($width * 0.3, $height * 0.5, $err);
} else {
    /* Draw PieChart */
    if ($chartType == 'pie3d' or $chartType == 'pie2d') {
        /* Deal Chart Data */
        if (!isset($chart_limit)) {
            $chart_limit = 1;
        }
        $rowPie = $chart_limit - 1;
        reset($arrFields);
        while (list($idx, $field) = each($arrFields)) {
            if ($idx == 0) {
                $pieValueKeyLabel = $field;
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create the pChart object */
$myPicture = new pImage(700, 230);
/* 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, "drawRectangle() - Transparency & colors", array("R" => 255, "G" => 255, "B" => 255));
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw a rectangle */
$RectangleSettings = array("R" => 181, "G" => 209, "B" => 27, "Alpha" => 100);
$myPicture->drawRectangle(20, 60, 400, 170, $RectangleSettings);
/* Draw a rectangle */
$RectangleSettings = array("R" => 209, "G" => 134, "B" => 27, "Alpha" => 30);
$myPicture->drawRectangle(30, 30, 200, 200, $RectangleSettings);
/* Draw a rectangle */
$RectangleSettings = array("R" => 209, "G" => 31, "B" => 27, "Alpha" => 100);
$myPicture->drawRectangle(480, 50, 650, 80, $RectangleSettings);
/* Draw a rectangle */
$RectangleSettings = array("R" => 209, "G" => 125, "B" => 27, "Alpha" => 100);
$myPicture->drawRectangle(480, 90, 650, 120, $RectangleSettings);
/* Draw a rectangle */
}
/* Set the image map name */
$myPicture->initialiseImageMap("ImageMapSplineChart", IMAGE_MAP_STORAGE_FILE, "SplineChart", "../tmp");
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* 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);
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(150, 35, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 650, 200);
/* Draw the scale */
$scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Turn on Antialiasing */
$myPicture->Antialias = TRUE;
/* Draw the line chart */
$Settings = array("RecordImageMap" => TRUE);
$myPicture->drawSplineChart($Settings);
$myPicture->drawPlotChart(array("PlotBorder" => TRUE, "PlotSize" => 3, "BorderSize" => 1, "Surrounding" => -60, "BorderAlpha" => 80));
/* Write the chart legend */
$myPicture->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
Example #29
0
 /**
  * Desenha um gráfico de torta
  * @param $title título do graico
  * @param $data vetor contendo os dados do gráfico
  * @param $width largura do gráfico
  * @param $height altura do gráfico
  * @param $outputPath caminho de saída do gráfico
  */
 public function drawPieChart($title, $data, $width, $height, $outputPath)
 {
     // cria o modelo de dados
     $modelo = new pData();
     $newdata = array();
     foreach ($data as $legend => $value) {
         $newdata[] = $value == NULL ? VOID : $value;
         $labels[] = $legend;
     }
     $modelo->addPoints($newdata, "ScoreA");
     /* Define the absissa serie */
     $modelo->addPoints($labels, "Labels");
     $modelo->setAbscissa("Labels");
     // cria o objeto que irá conter a imagem do gráfico
     $imagem = new pImage($width, $height, $modelo);
     // adiciona uma borda na forma de um retângulo dentro da imagem
     $imagem->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
     // escreve um título dentro do gráfico
     $imagem->setFontProperties(array("FontName" => "app/lib/pchart/fonts/Forgotte.ttf", "FontSize" => 11));
     $imagem->drawText(60, 35, $title, array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT));
     // define a fonte dos dados do gráfico
     $imagem->setFontProperties(array("FontName" => "app/lib/pchart/fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     // cria o gráfico de torta
     $pie = new pPie($imagem, $modelo);
     // desenha o gráfico de torta
     $pie->draw3DPie($width / 2, $height / 2, array('WriteValues' => TRUE, 'DrawLabels' => TRUE, "Radius" => $width / 4, 'ValueR' => 0, 'ValueG' => 0, 'ValueB' => 0, 'ValueAlpha' => 80));
     // desenha a legenda do gráfico
     $imagem->setShadow(FALSE);
     $pie->drawPieLegend(15, 40, array("Alpha" => 20));
     // grava o gráfico em um arquivo
     $imagem->render($outputPath);
 }
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create the pChart object */
$myPicture = new pImage(700, 230);
/* 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, "drawText() - add some text to your charts", array("R" => 255, "G" => 255, "B" => 255));
/* Enable shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Write some text */
$myPicture->setFontProperties(array("FontName" => "../fonts/advent_light.ttf", "FontSize" => 20));
$TextSettings = array("R" => 255, "G" => 255, "B" => 255, "Angle" => 10);
$myPicture->drawText(60, 115, "10 degree text", $TextSettings);
/* Write some text */
$TextSettings = array("R" => 0, "G" => 0, "B" => 0, "Angle" => 0, "FontSize" => 40);
$myPicture->drawText(220, 130, "Simple text", $TextSettings);
/* Write some text */
$TextSettings = array("R" => 200, "G" => 100, "B" => 0, "Angle" => 90, "FontSize" => 14);
$myPicture->drawText(500, 170, "Vertical Text", $TextSettings);
/* Write some text */
$myPicture->setFontProperties(array("FontName" => "../fonts/Bedizen.ttf", "FontSize" => 6));
$TextSettings = array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Angle" => 0, "FontSize" => 10);