function index()
 {
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints(getGenders($this->db), "ScoreA");
     $MyData->setSerieDescription("ScoreA", "Application A");
     /* Define the absissa serie */
     $MyData->addPoints(array("Female", "Male"), "Labels");
     $MyData->setAbscissa("Labels");
     /* Create the pChart object */
     $myPicture = new pImage(240, 180, $MyData, TRUE);
     /* Set the default font properties */
     $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     /* Create the pPie object */
     $PieChart = new pPie($myPicture, $MyData);
     /* Enable shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 3, "Y" => 3, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     /* Draw a splitted pie chart */
     $PieChart->draw3DPie(120, 90, array("Radius" => 100, "DataGapAngle" => 12, "DataGapRadius" => 10, "Border" => TRUE));
     /* Write the legend box */
     $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 0, "G" => 0, "B" => 0));
     $PieChart->drawPieLegend(140, 160, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     /* Render the picture (choose the best way) */
     $myPicture->stroke();
     //$myPicture->autoOutput("pictures/example.draw3DPie.transparent.png");
 }
Exemple #2
0
function plot($lift)
{
    $MyData = new pData();
    $positivelift = array();
    $negativelift = array();
    foreach ($lift as $heading => $fpm) {
        if ($fpm > 0) {
            $positivelift[$heading] = $fpm;
            $negativelift[$heading] = 0;
        } else {
            $negativelift[$heading] = -$fpm;
            $positivelift[$heading] = 0;
        }
    }
    $MyData->addPoints($positivelift, "ScoreA");
    // green
    $MyData->addPoints($negativelift, "ScoreB");
    // red
    $MyData->addPoints(array_keys($lift), "Coord");
    $MyData->setAbscissa("Coord");
    $myPicture = new pImage(700, 700, $MyData);
    $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    $SplitChart = new pRadar();
    $myPicture->setGraphArea(10, 10, 690, 690);
    $Options = array("LabelPos" => RADAR_LABELS_HORIZONTAL, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 50, "EndR" => 32, "EndG" => 109, "EndB" => 174, "EndAlpha" => 30), "DrawPoly" => TRUE, "PolyAlpha" => 50, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6);
    $SplitChart->drawPolar($myPicture, $MyData, $Options);
    $myPicture->autoOutput("lift.png");
}
/**
 * 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();
}
 /**
  * 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;
 }
 function showTimeline($ticket, $params = array())
 {
     global $CFG_GLPI;
     /* Create and populate the pData object */
     $MyData = new pData();
     /* Create the pChart object */
     $myPicture = new pImage(820, 29, $MyData);
     /* Create the pIndicator object */
     $Indicator = new pIndicator($myPicture);
     $myPicture->setFontProperties(array("FontName" => GLPI_ROOT . "/plugins/timelineticket/lib/pChart2.1.4/fonts/pf_arma_five.ttf", "FontSize" => 6));
     /* Define the indicator sections */
     $IndicatorSections = array();
     $_usersfinished = array();
     $a_users_list = array();
     $IndicatorSections = PluginTimelineticketToolbox::getDetails($ticket, 'user');
     foreach ($IndicatorSections as $users_id => $data) {
         $a_users_list[$users_id] = $users_id;
         $a_end = end($data);
         if ($a_end['R'] == 235 && $a_end['G'] == 235 && $a_end['B'] == 235) {
             $_usersfinished[$users_id] = true;
         } else {
             $_usersfinished[$users_id] = false;
         }
     }
     echo "<tr>";
     echo "<th colspan='2'>";
     if (count($a_users_list) > 1) {
         _e('Technicians in charge of the ticket', 'timelineticket');
     } else {
         _e('Technician in charge of the ticket');
     }
     echo "</th>";
     echo "</tr>";
     foreach ($IndicatorSections as $users_id => $array) {
         echo "<tr class='tab_bg_2'>";
         echo "<td width='100'>";
         echo getUsername($users_id);
         echo "</td>";
         echo "<td>";
         if ($ticket->fields['status'] != Ticket::CLOSED && $_usersfinished[$users_id] != 0) {
             $IndicatorSettings = array("Values" => array(100, 201), "CaptionPosition" => INDICATOR_CAPTION_BOTTOM, "CaptionLayout" => INDICATOR_CAPTION_DEFAULT, "CaptionR" => 0, "CaptionG" => 0, "CaptionB" => 0, "DrawLeftHead" => false, "DrawRightHead" => true, "ValueDisplay" => false, "IndicatorSections" => $array, "SectionsMargin" => 0);
             $Indicator->draw(2, 2, 805, 25, $IndicatorSettings);
         } else {
             $IndicatorSettings = array("Values" => array(100, 201), "CaptionPosition" => INDICATOR_CAPTION_BOTTOM, "CaptionLayout" => INDICATOR_CAPTION_DEFAULT, "CaptionR" => 0, "CaptionG" => 0, "CaptionB" => 0, "DrawLeftHead" => false, "DrawRightHead" => false, "ValueDisplay" => false, "IndicatorSections" => $array, "SectionsMargin" => 0);
             $Indicator->draw(2, 2, 814, 25, $IndicatorSettings);
         }
         $filename = $uid = Session::getLoginUserID(false) . "_testuser" . $users_id;
         $myPicture->render(GLPI_GRAPH_DIR . "/" . $filename . ".png");
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file=" . $filename . ".png'><br/>";
         echo "</td>";
         echo "</tr>";
     }
 }
 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 f****d 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");
 }
Exemple #7
0
 protected function action_getImageMap()
 {
     ob_start();
     global $current_user;
     if (!isset($_REQUEST['imageMapId'])) {
         return;
     }
     require_once 'modules/AOR_Charts/lib/pChart/pChart.php';
     $img = new pImage(100, 100);
     $imageMapDir = create_cache_directory('modules/AOR_Charts/ImageMap/' . $current_user->id . '/');
     $id = $current_user->id . "-" . (int) $_REQUEST['imageMapId'];
     ob_clean();
     $img->dumpImageMap($id, IMAGE_MAP_STORAGE_FILE, $id, $imageMapDir);
 }
 /**
  * Set the font for the image object.
  * @param string $font
  * @param int $fontSize
  */
 protected function setFont($font = null, $fontSize = null)
 {
     $prop = array();
     $fontFile = null;
     if ($font !== null) {
         $fontFile = I2CE::getFileSearch()->search("PCHART_FONTS", $font . ".ttf");
     }
     if ($fontFile === null) {
         I2CE::getConfig()->setIfIsSet($font, "/modules/pChart/defaults/font");
         if (!$font) {
             $font = "calibri";
         }
         $fontFile = I2CE::getFileSearch()->search("PCHART_FONTS", $font . ".ttf");
         if ($fontFile === null) {
             I2CE::raiseError("Couldn't find font {$font} for pChart.");
             return;
         }
     }
     $prop['FontName'] = $fontFile;
     if ($fontSize === null) {
         I2CE::getConfig()->setIfIsSet($fontSize, "/modules/pChart/defaults/font_size");
         if (!$fontSize) {
             $fontSize = 10;
         }
     }
     $prop['FontSize'] = $fontSize;
     $this->chartImage->setFontProperties($prop);
 }
Exemple #9
0
function PlotPie($rowA, $rowB, $name, $cch)
{
    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($rowA, "ScoreA");
    $MyData->setSerieDescription("ScoreA", "Application A");
    /* Define the absissa serie */
    $MyData->addPoints($rowB, "Labels");
    $MyData->setAbscissa("Labels");
    /* Create the pChart object */
    $myPicture = new pImage(700, 630, $MyData);
    $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, 690);
    //$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));
    /* Create the pPie object */
    $PieChart = new pPie($myPicture, $MyData);
    /* Draw an AA pie chart */
    if ($cch == 11) {
        $PieChart->draw2DPie(160, 140, array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE));
    }
    if ($cch == 12) {
        $PieChart->draw2DRing(160, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "Border" => TRUE));
    }
    if ($cch == 13) {
        $PieChart->draw3DPie(160, 140, array("Radius" => 70, "DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE));
    }
    /* Write the legend box */
    $myPicture->setShadow(FALSE);
    $PieChart->drawPieLegend(15, 40, array("Alpha" => 20));
    /* Render the picture (choose the best way) */
    $myPicture->autoOutput("pictures/example.draw2DPie.labels.png");
}
Exemple #10
0
 public function drawCompetencyExpertsRadar($img, $points, $competences, $roles, $skale, $palettes)
 {
     $MyData = new \pData();
     /*$palettes = array(
           array("R"=>84,"G"=>85,"B"=>86),
           array("R"=>21,"G"=>101,"B"=>112),
           array("R"=>223,"G"=>72,"B"=>11),
           array("R"=>10,"G"=>120,"B"=>40),
           array("R"=>200,"G"=>150,"B"=>20),
       );*/
     /*$palettes = array(
         0  => array('R' => 191, 'G' => 191, 'B' => 191),
         1  => array('R' => 226, 'G' => 24, 'B' => 54),
         2  => array('R' => 244, 'G' => 122, 'B' => 32),
         3  => array('R' => 146, 'G' => 0, 'B' => 61),
         4  => array('R' => 91, 'G' => 74, 'B' => 63),
         5  => array('R' => 55, 'G' => 96, 'B' => 146),
         6  => array('R' => 119, 'G' => 147, 'B' => 60),
       );*/
     $i = 0;
     foreach ($points as $roleID => $data) {
         $MyData->addPoints($data, "Score" . $roleID);
         $MyData->setSerieDescription("Score" . $roleID, $roles[$roleID]['name']);
         $MyData->setPalette("Score" . $roleID, $palettes[$i++]);
     }
     $labels = array();
     foreach ($competences as $competency) {
         $labels[] = strpos($competency, ' ') !== false ? $this->divideString($competency) : $competency;
     }
     $MyData->addPoints($labels, "Labels");
     $MyData->setAbscissa("Labels");
     $myPicture = new \pImage(460 * 1.53, 330 * 1.53, $MyData);
     $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . '/fonts/calibri.ttf', "FontSize" => round(7 * 1.53), "R" => 80, "G" => 80, "B" => 80));
     /* Create the pRadar object */
     $SplitChart = new \pRadar();
     /* Draw a radar chart */
     $myPicture->setGraphArea(70 * 1.53, 30 * 1.53, 340 * 1.53, 300 * 1.53);
     $Options = array("Layout" => RADAR_LAYOUT_STAR, 'SegmentHeight' => ceil($skale['max'] / 4), "FontName" => dirname(__FILE__) . '/fonts/calibri.ttf', "FontSize" => round(7 * 1.53), 'LabelPos' => RADAR_LABELS_HORIZONTAL, 'LineWidth' => 3);
     $SplitChart->drawRadar($myPicture, $MyData, $Options);
     $myPicture->render($img);
 }
Exemple #11
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"]);
 }
Exemple #12
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 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
 }
Exemple #14
0
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";
    }
}
/* Create the Y axis and the binded series */
for ($i = 0; $i <= 360; $i = $i + 10) {
    $myData->addPoints(sin(deg2rad(30 - $i)) * 20, "Probe 2");
}
$myData->setSerieOnAxis("Probe 2", 1);
$myData->setAxisName(1, "Y-Index");
$myData->setAxisXY(1, AXIS_Y);
$myData->setAxisPosition(1, AXIS_POSITION_RIGHT);
/* Create the 1st scatter chart binding */
$myData->setScatterSerie("Probe 1", "Probe 2", 0);
$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 */
/* CAT:Stacked 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(4, 1, 0, 12, 8, 4, 0, 12, 8), "Frontend #1");
$MyData->addPoints(array(3, 12, 15, 8, VOID, VOID, 12, 15, 8), "Frontend #2");
$MyData->addPoints(array(4, 4, 4, 4, 4, 4, 4, 4, 4), "Frontend #3");
$MyData->setAxisName(0, "Average Usage");
$MyData->addPoints(array("January", "February", "March", "April", "May", "June", "July", "August", "September"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* 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));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->drawStackedAreaChart(array("DrawPlot" => TRUE, "DrawLine" => TRUE, "LineSurrounding" => -20));
/* Turn on shadow processing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Write the chart legend */
$myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedAreaChart.simple.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->addPoints(array(1700, 2500, 7800, 4500, 3150), "Distance");
$MyData->setAxisName(0, "Maximum distance");
$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 */
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
for ($i = 0; $i <= 10; $i = $i + 0.2) {
    $MyData->addPoints(log($i + 1) * 10, "Bounds 1");
    $MyData->addPoints(log($i + 3) * 10 + rand(0, 2) - 1, "Probe 1");
    $MyData->addPoints(log($i + 6) * 10, "Bounds 2");
    $MyData->addPoints($i * 10, "Labels");
}
$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);
Exemple #19
0
 /**
  * 绘制图表并生成图片
  * @method drawChart
  * @return [type]    [description]
  */
 protected function drawChart($data_arr, $lab_arr, $pic_name)
 {
     /* pChart library inclusions */
     include "libs/pChart2.1.4/class/pData.class.php";
     include "libs/pChart2.1.4/class/pDraw.class.php";
     include "libs/pChart2.1.4/class/pPie.class.php";
     include "libs/pChart2.1.4/class/pImage.class.php";
     /* pData object creation */
     $MyData = new \pData();
     /* Data definition */
     $MyData->addPoints($data_arr, "Value");
     /* Labels definition */
     $MyData->addPoints($lab_arr, "Legend");
     $MyData->setAbscissa("Legend");
     /* Create the pChart object */
     $myPicture = new \pImage(500, 150, $MyData);
     /* Draw a gradient background */
     $myPicture->drawGradientArea(0, 0, 500, 150, DIRECTION_HORIZONTAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
     /* Add a border to the picture */
     // $myPicture->drawRectangle(0,0,399,149,array("R"=>0,"G"=>0,"B"=>0));
     /* Create the pPie object */
     $PieChart = new \pPie($myPicture, $MyData);
     /* Enable shadow computing */
     $myPicture->setShadow(FALSE);
     /* Set the default font properties */
     $myPicture->setFontProperties(array("FontName" => __DIR__ . "/libs/pChart2.1.4/fonts/msyh.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80));
     /* Draw a splitted pie chart */
     $PieChart->draw3DPie(250, 100, array("Radius" => 80, "DrawLabels" => TRUE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => FALSE));
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput(public_path() . '/pictures/' . $pic_name);
 }
include "../class/pDraw.class.php";
include "../class/pRadar.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(40, 20, 15, 10, 8, 4), "ScoreA");
$MyData->addPoints(array(8, 10, 12, 20, 30, 15), "ScoreB");
$MyData->addPoints(array(4, 8, 16, 32, 16, 8), "ScoreC");
$MyData->setSerieDescription("ScoreA", "Application A");
$MyData->setSerieDescription("ScoreB", "Application B");
$MyData->setSerieDescription("ScoreC", "Application C");
/* Define the absissa serie */
$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 */
<?php

/* CAT:Spline 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->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));
include CLASS_PATH . "/pDraw.class.php";
include CLASS_PATH . "/pImage.class.php";
include CLASS_PATH . "/pStock.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(35, 28, 17, 27, 12, 12, 20, 15, 20, 28), "Open");
$MyData->addPoints(array(20, 17, 25, 20, 25, 23, 16, 29, 26, 17), "Close");
$MyData->addPoints(array(10, 11, 14, 11, 9, 4, 3, 7, 9, 5), "Min");
$MyData->addPoints(array(37, 32, 33, 29, 29, 25, 22, 34, 29, 31), "Max");
$MyData->addPoints(array(30, 20, 21, 24, 22, 18, 18, 24, 22, 24), "Median");
$MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY, "\$");
$MyData->addPoints(array("Dec 13", "Dec 14", "Dec 15", "Dec 16", "Dec 17", "Dec 20", "Dec 21", "Dec 22", "Dec 23", "Dec 24"), "Time");
$MyData->setAbscissa("Time");
$MyData->setAbscissaName("Time");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Retrieve the image map */
if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) {
    $myPicture->dumpImageMap("ImageMapStockChart", IMAGE_MAP_STORAGE_FILE, "StockChart", "../tmp");
}
/* Set the image map name */
$myPicture->initialiseImageMap("ImageMapStockChart", IMAGE_MAP_STORAGE_FILE, "StockChart", "../tmp");
/* Turn of AAliasing */
$myPicture->Antialias = FALSE;
/* Draw the border */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(60, 30, 650, 190);
/* Draw the scale */
$scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
<?php

/* CAT:Drawing */
/* pChart library inclusions */
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);
 /**
  * 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);
 }
/* CAT:Stacked 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(4, VOID, VOID, 12, 8, 3), "Frontend #1");
$MyData->addPoints(array(3, 12, 15, 8, 5, 5), "Frontend #2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Frontend #3");
$MyData->setAxisName(0, "Average Usage");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* 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));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15));
/* Write a label */
$myPicture->writeLabel(array("Frontend #1", "Frontend #2", "Frontend #3"), 1, array("DrawVerticalLine" => TRUE));
/* Write the chart legend */
$myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.shaded.png");
     }
 }
 //preparation radar chart graph
 /* Prepare some nice data & axis config */
 $MyData = new pData();
 $MyData->addPoints($tabMoyenne, "ScoreA");
 $MyData->addPoints($tabNote, "ScoreB");
 $MyData->setSerieDescription("ScoreA", "Moyenne classe");
 $MyData->setSerieDescription("ScoreB", "Notes étudiant");
 $MyData->setPalette("ScoreB", array("R" => 0, "G" => 0, "B" => 0, "Alpha" => 100));
 $MyData->setPalette("ScoreA", array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 100));
 /* Create the X serie */
 $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));
/* 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/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) */
Exemple #28
0
// // // -----------------
//=============================================================================================
// $MyData = new pData();
// for($i=0;$i<=30;$i++) { $MyData->addPoints(rand(1,15),"Probe 1"); }
// $MyData->setSerieTicks("Probe 2",4);
// $MyData->setAxisName(0,"Temperatures");
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints($csvdata_values, "Temperature");
$MyData->addPoints($csvdata_point, "Labels");
$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 */
function pieGen($stats, $mode)
{
    global $centreon_path;
    // Create and populate the pData object
    $MyData = new pData();
    // print_r($stats["average"]);
    $arrPoints = array();
    $i = 0;
    // Host groups
    if ($mode == "hgs") {
        $MyData->addPoints(array($stats["average"]["UP_TP"], $stats["average"]["DOWN_TP"], $stats["average"]["UNDETERMINED_TP"], $stats["average"]["UNREACHABLE_TP"], $stats["average"]["MAINTENANCE_TP"]), "Hostgroups");
        $MyData->setSerieDescription("Hostgroups", "Hostgroups");
        $arrPoints = array("Up", "Down", "Undeterminded", "Unreachable", "Schedule Downtime");
        // Define the absissa serie
        $MyData->addPoints($arrPoints, "Labels");
        $MyData->setAbscissa("Labels");
        // Create the pChart object
        $myPicture = new pImage(120, 120, $MyData, TRUE);
        // Create the pPie object
        $PieChart = new pPie($myPicture, $MyData);
        $i = 0;
        /* Define the slice color */
        if ($stats["average"]["UP_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 25, "G" => 238, "B" => 17));
            // UP
            $i++;
        }
        if ($stats["average"]["DOWN_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 249, "G" => 30, "B" => 5));
            // DOWN
            $i++;
        }
        if ($stats["average"]["UNDETERMINED_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 248, "B" => 255));
            // UNDETERMINED
            //$PieChart->setSliceColor($i,array("R"=>240,"G"=>240,"B"=>240));
            $i++;
        }
        if ($stats["average"]["UNREACHABLE_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 130, "G" => 207, "B" => 216));
            // UNREACHABLE
            $i++;
        }
        if ($stats["average"]["MAINTENANCE_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 153, "B" => 255));
            // MAINTENANCE
            $i++;
        }
    }
    // Service Groups
    if ($mode == "sgs") {
        $MyData->addPoints(array($stats["average"]["OK_TP"], $stats["average"]["WARNING_TP"], $stats["average"]["CRITICAL_TP"], $stats["average"]["UNKNOWN_TP"], $stats["average"]["MAINTENANCE_TP"], $stats["average"]["UNDETERMINED_TP"]), "Servicegroups");
        $MyData->setSerieDescription("Servicegroups", "Servicegroups");
        $arrPoints = array("Ok", "Warning", "Critical", "Unknown", "Schedule Downtime", "Undeterminded");
        // Define the absissa serie
        $MyData->addPoints($arrPoints, "Labels");
        $MyData->setAbscissa("Labels");
        // Create the pChart object
        $myPicture = new pImage(120, 120, $MyData, TRUE);
        // Create the pPie object
        $PieChart = new pPie($myPicture, $MyData);
        /* Define the slice color */
        if ($stats["average"]["OK_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 13, "G" => 235, "B" => 58));
            // OK
            $i++;
        }
        if ($stats["average"]["WARNING_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 248, "G" => 199, "B" => 6));
            // DOWN
            $i++;
        }
        if ($stats["average"]["CRITICAL_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 249, "G" => 30, "B" => 5));
            // DOWN
            $i++;
        }
        if ($stats["average"]["UNKNOWN_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 220, "G" => 218, "B" => 218));
            // UNKNOWN
            $i++;
        }
        if ($stats["average"]["MAINTENANCE_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 153, "B" => 255));
            // MAINTENANCE
            $i++;
        }
        if ($stats["average"]["UNDETERMINED_TP"] > 0) {
            $PieChart->setSliceColor($i, array("R" => 204, "G" => 248, "B" => 255));
            // UNDETERMINED
            //$PieChart->setSliceColor($i,array("R"=>240,"G"=>240,"B"=>240)); // UNDETERMINED
            $i++;
        }
    }
    $Settings = array("R" => 255, "G" => 255, "B" => 255);
    $myPicture->drawFilledRectangle(0, 0, 120, 120, $Settings);
    //  Enable shadow computing
    // $myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
    // Draw a splitted pie chart
    $PieChart->draw3DPie(60, 70, array("Radius" => 50, "DataGapAngle" => 8, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
    /* Render the picture  */
    //	$pie_file = tempnam( "/tmp" , "reportreon_pie_" );
    $pie_file = tempnam($centreon_path . "/www/modules/pdfreports/generatedFiles/tmp", "reportreon_pie_");
    $myPicture->render($pie_file . ".png");
    @unlink($pie_file);
    return $pie_file . ".png";
}
//$myData->addPoints(array(-37,37,-38,16,-4,39,29,6),"Serie2");
//$myData->setSerieDescription("Serie2","Serie 2");
//$myData->setSerieOnAxis("Serie2",0);
//
//$myData->addPoints(array(16,46,-32,35,32,-15,40,29),"Serie3");
//$myData->setSerieDescription("Serie3","Serie 3");
//$myData->setSerieOnAxis("Serie3",0);
$myData->setAxisPosition(0, AXIS_POSITION_LEFT);
$myData->setAxisName(0, "Notas");
$myData->setAxisUnit(0, "");
$myData->addPoints(array("1er Trimestre", "2ndo Trimestre", "3er Trimestre"), "Absissa");
$myData->setAbscissa("Absissa");
//$myData->addPoints(array("1","2","3"),"Labels");
//$myData->setSerieDescription("Labels","Evaluaciones");
//$myData->setAbscissa("Labels");
$myPicture = new pImage($anchura, $altura, $myData);
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, $anchura, $altura, $Settings);
if ($g_enabled == "on") {
    list($StartR, $StartG, $StartB) = extractColors($g_gradient_start);
    list($EndR, $EndG, $EndB) = extractColors($g_gradient_end);
    $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);