Ejemplo n.º 1
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");
}
/**
 * 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();
}
Ejemplo n.º 3
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
 }
Ejemplo n.º 4
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);
 }
Ejemplo n.º 5
0
////////////////////////////////////////////////////////////////
// Minimum Values
//
/* Get minimum Temperature value */
$temp = $MyData->getMin("Temperature");
/* Get minimum Temperature value */
$T_Minimum = number_format($temp, 1);
/* Get minimum Humidity value */
$temp = $MyData->getMin("Humidity");
/* Format Min to 1 decimal place */
$H_Minimum = number_format($temp, 1);
////////////////////////////////////////////////////////////////
// Plotting Line Colours
//
/* Set Temperature Line Colour */
$MyData->setPalette("Temperature", array("R" => 0, "G" => 0, "B" => 255));
/* Set Humidity Line Colour */
$MyData->setPalette("Humidity", array("R" => 255, "G" => 0, "B" => 0));
////////////////////////////////////////////////////////////////
// Prepare and create Graph
//
/* Set graph area */
$myPicture = new pImage(1080, 460, $MyData);
/* Turn an AA */
$myPicture->Antialias = TRUE;
/* Rectangle Border */
$myPicture->drawRectangle(0, 0, 1079, 459, array("R" => 0, "G" => 0, "B" => 0));
////////////////////////////////////////////////////////////////
// Headings
//
/* Font Setup */
include "statistics_tile_and_colour.php";
include "statistics_series_total_sum.php";
include "statistics_description_years.php";
include "pChart/class/pData.class.php";
include "pChart/class/pDraw.class.php";
include "pChart/class/pImage.class.php";
include "statistics_description_text.php";
$width = 760;
$height = 500;
$pChart = new pData();
$chart_tile_colours = array("0" => array("R" => 246, "G" => 113, "B" => 53, "Alpha" => 100), "1" => array("R" => 211, "G" => 60, "B" => 29, "Alpha" => 100), "2" => array("R" => 80, "G" => 94, "B" => 97, "Alpha" => 100), "3" => array("R" => 131, "G" => 137, "B" => 129, "Alpha" => 100), "4" => array("R" => 42, "G" => 43, "B" => 45, "Alpha" => 100), "5" => array("R" => 116, "G" => 82, "B" => 73, "Alpha" => 100), "6" => array("R" => 190, "G" => 93, "B" => 72, "Alpha" => 100), "7" => array("R" => 95, "G" => 83, "B" => 84, "Alpha" => 100), "8" => array("R" => 220, "G" => 220, "B" => 220, "Alpha" => 100));
for ($i = 0; $i < count($colours); $i++) {
    $pChart->addPoints(array($tile_colour_results[0][$i], $tile_colour_results[1][$i], $tile_colour_results[2][$i], $tile_colour_results[3][$i], $tile_colour_results[4][$i], $tile_colour_results[5][$i], $tile_colour_results[6][$i], $tile_colour_results[7][$i], $tile_colour_results[8][$i], $tile_colour_results[9][$i], $tile_colour_results[10][$i], $tile_colour_results[11][$i], $tile_colour_results[12][$i]), "Serie{$i}");
    $pChart->setSerieDescription("Serie{$i}", $colours[$i][0]);
    $pChart->setSerieOnAxis("Serie{$i}", 0);
    $pChart->setPalette("Serie{$i}", $chart_tile_colours[$i]);
}
$pChart->addPoints(array(get_tile_total_count($tile_colour_results, 0), get_tile_total_count($tile_colour_results, 1), get_tile_total_count($tile_colour_results, 2), get_tile_total_count($tile_colour_results, 3), get_tile_total_count($tile_colour_results, 4), get_tile_total_count($tile_colour_results, 5), get_tile_total_count($tile_colour_results, 6), get_tile_total_count($tile_colour_results, 7), get_tile_total_count($tile_colour_results, 8), get_tile_total_count($tile_colour_results, 9), get_tile_total_count($tile_colour_results, 10), get_tile_total_count($tile_colour_results, 11), get_tile_total_count($tile_colour_results, 12)), "Serie10");
$pChart->setSerieDrawable("Serie10", FALSE);
$pChart->setPalette("Serie10", array("Alpha" => 0));
$pChart->addPoints(array("Ormax", "Protector", "Polar", "Minster", "Turmalin", "Granat", "E13", "T11", "Nova", "Rubin", "Nortegl", "Hollander", "KDN"), "Absissa");
$pChart->setAbscissa("Absissa");
$pChart->setAxisPosition(0, AXIS_POSITION_LEFT);
$pChart->setAxisName(0, "Laskentamäärät kpl");
$pChart->setAxisUnit(0, "");
$pChartPicture = new pImage($width, $height, $pChart);
$Settings = array("R" => 255, "G" => 255, "B" => 255);
$pChartPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
$pChartPicture->setFontProperties(array("FontName" => "pChart/fonts/arial.ttf", "FontSize" => 14));
$TextSettings = array("Align" => TEXT_ALIGN_BOTTOMMIDDLE, "R" => 0, "G" => 0, "B" => 0);
$pChartPicture->drawText($width / 2, 25, ucfirst($table) . " - Tiilet / Värit", $TextSettings);
 function displayGraph($rrdtool_template, $itemtype, $items_id, $timezone, $time = '1d', $width = '470')
 {
     global $DB, $LANG;
     $timezonefile = str_replace("+", ".", $timezone);
     // Cache 1 minute
     if (file_exists(GLPI_PLUGIN_DOC_DIR . "/monitoring/" . $itemtype . "-" . $items_id . "-" . $time . $timezonefile . ".png")) {
         $time_generate = filectime(GLPI_PLUGIN_DOC_DIR . "/monitoring/" . $itemtype . "-" . $items_id . "-" . $time . $timezonefile . ".png");
         if ($time_generate + 150 > date('U')) {
             return;
         }
     }
     $filename = GLPI_PLUGIN_DOC_DIR . "/monitoring/templates/" . $rrdtool_template . "_graph.json";
     $loadfile = file_get_contents($filename);
     if (!$loadfile) {
         return;
     }
     $a_jsong = json_decode($loadfile);
     // Manage timezones
     $converttimezone = '0';
     if (strstr($timezone, '-')) {
         $timezone_temp = str_replace("-", "", $timezone);
         $converttimezone = $timezone_temp * 3600;
         $timezone = str_replace("-", "+", $timezone);
     } else {
         if (strstr($timezone, '+')) {
             $timezone_temp = str_replace("+", "", $timezone);
             $converttimezone = $timezone_temp * 3600;
             $timezone = str_replace("+", "-", $timezone);
         }
     }
     $opts = "";
     /* pChart library inclusions */
     include_once "../lib/pChart2.1.3/class/pData.class.php";
     include_once "../lib/pChart2.1.3/class/pDraw.class.php";
     include_once "../lib/pChart2.1.3/class/pImage.class.php";
     $MyData = new pData();
     // ** Get in table serviceevents
     $mydatat = array();
     $a_labels = array();
     $a_ref = array();
     $pmServiceevent = new PluginMonitoringServiceevent();
     $pmService = new PluginMonitoringService();
     $pmService->getFromDB($items_id);
     $begin = '';
     switch ($time) {
         case '2h':
             $begin = date('Y-m-d H:i:s', date('U') - 2 * 3600);
             $query = "SELECT * FROM `glpi_plugin_monitoring_serviceevents`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `date` > '" . $begin . "'\n               ORDER BY `date`";
             $result = $DB->query($query);
             $ret = array();
             if (isset($this->jsongraph_a_ref[$rrdtool_template])) {
                 $ret = $pmServiceevent->getData($result, $rrdtool_template, array($this->jsongraph_a_ref[$rrdtool_template], $this->jsongraph_a_convert[$rrdtool_template]));
             } else {
                 $ret = $pmServiceevent->getData($result, $rrdtool_template);
             }
             if (is_array($ret)) {
                 $mydatat = $ret[0];
                 $a_labels = $ret[1];
                 $a_ref = $ret[2];
                 if (!isset($this->jsongraph_a_ref[$rrdtool_template])) {
                     $this->jsongraph_a_ref[$rrdtool_template] = $ret[2];
                     $this->jsongraph_a_convert[$rrdtool_template] = $ret[3];
                 }
             }
             break;
         case '12h':
             $begin = date('Y-m-d H:i:s', date('U') - 12 * 3600);
             $query = "SELECT * FROM `glpi_plugin_monitoring_serviceevents`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `date` > '" . $begin . "'\n               ORDER BY `date`";
             $result = $DB->query($query);
             $ret = $pmServiceevent->getData($result, $rrdtool_template);
             if (is_array($ret)) {
                 $mydatat = $ret[0];
                 $a_labels = $ret[1];
                 $a_ref = $ret[2];
             }
             break;
         case '1d':
             $begin = date('Y-m-d H:i:s', date('U') - 24 * 3600);
             $query = "SELECT * FROM `" . $this->getTable() . "`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `type`='30m'\n               ORDER BY `date`";
             $result = $DB->query($query);
             while ($edata = $DB->fetch_array($result)) {
                 $dat = importArrayFromDB($edata['data']);
                 if (count($dat) > 0) {
                     $datemod = $edata['date'];
                     $split = explode(' ', $datemod);
                     $split2 = explode(':', $split[1]);
                     array_push($a_labels, $split2[0] . ':' . $split2[1]);
                 }
                 foreach ($dat as $name => $value) {
                     if (!isset($mydatat[$name])) {
                         $mydatat[$name] = array();
                     }
                     array_push($mydatat[$name], $value);
                 }
             }
             $ret = $pmServiceevent->getRef($rrdtool_template);
             $a_ref = $ret[0];
             break;
         case '1w':
             $begin = date('Y-m-d H:i:s', date('U') - 7 * 24 * 3600);
             $query = "SELECT * FROM `" . $this->getTable() . "`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `type`='6h'\n               ORDER BY `date`";
             $result = $DB->query($query);
             while ($edata = $DB->fetch_array($result)) {
                 $dat = importArrayFromDB($edata['data']);
                 if (count($dat) > 0) {
                     $datemod = $edata['date'];
                     $daynum = Calendar::getDayNumberInWeek(PluginMonitoringServiceevent::convert_datetime_timestamp($edata['date']));
                     $split = explode(' ', $datemod);
                     $split2 = explode(':', $split[1]);
                     array_push($a_labels, $LANG['calendarDay'][$daynum] . " " . $split2[0] . ':' . $split2[1]);
                 }
                 foreach ($dat as $name => $value) {
                     if (!isset($mydatat[$name])) {
                         $mydatat[$name] = array();
                     }
                     array_push($mydatat[$name], $value);
                 }
             }
             $ret = $pmServiceevent->getRef($rrdtool_template);
             $a_ref = $ret[0];
             break;
         case '1m':
             $begin = date('Y-m-d H:i:s', date('U') - 30 * 24 * 3600);
             $query = "SELECT * FROM `" . $this->getTable() . "`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `type`='1d'\n               ORDER BY `date`";
             $result = $DB->query($query);
             while ($edata = $DB->fetch_array($result)) {
                 $dat = importArrayFromDB($edata['data']);
                 if (count($dat) > 0) {
                     $datemod = $edata['date'];
                     $daynum = Calendar::getDayNumberInWeek(PluginMonitoringServiceevent::convert_datetime_timestamp($edata['date']));
                     $split = explode(' ', $datemod);
                     $split2 = explode(':', $split[1]);
                     $day = explode("-", $split[0]);
                     array_push($a_labels, $LANG['calendarDay'][$daynum] . " " . $day[2]);
                 }
                 foreach ($dat as $name => $value) {
                     if (!isset($mydatat[$name])) {
                         $mydatat[$name] = array();
                     }
                     array_push($mydatat[$name], $value);
                 }
             }
             $ret = $pmServiceevent->getRef($rrdtool_template);
             $a_ref = $ret[0];
             break;
         case '0y6m':
             $begin = date('Y-m-d H:i:s', date('U') - 364 / 2 * 24 * 3600);
             $query = "SELECT * FROM `" . $this->getTable() . "`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `type`='5d'\n               ORDER BY `date`";
             $result = $DB->query($query);
             while ($edata = $DB->fetch_array($result)) {
                 $dat = importArrayFromDB($edata['data']);
                 if (count($dat) > 0) {
                     $datemod = $edata['date'];
                     $daynum = date('m', PluginMonitoringServiceevent::convert_datetime_timestamp($edata['date']));
                     $daynum = $daynum - 1;
                     $split = explode(' ', $datemod);
                     $day = explode("-", $split[0]);
                     array_push($a_labels, $LANG['calendarM'][$daynum] . " " . $day[2]);
                 }
                 foreach ($dat as $name => $value) {
                     if (!isset($mydatat[$name])) {
                         $mydatat[$name] = array();
                     }
                     array_push($mydatat[$name], $value);
                 }
             }
             $ret = $pmServiceevent->getRef($rrdtool_template);
             $a_ref = $ret[0];
             break;
         case '1y':
             $begin = date('Y-m-d H:i:s', date('U') - 365 * 24 * 3600);
             $query = "SELECT * FROM `" . $this->getTable() . "`\n               WHERE `plugin_monitoring_services_id`='" . $items_id . "'\n                  AND `type`='10d'\n               ORDER BY `date`";
             $result = $DB->query($query);
             while ($edata = $DB->fetch_array($result)) {
                 $dat = importArrayFromDB($edata['data']);
                 if (count($dat) > 0) {
                     $datemod = $edata['date'];
                     $daynum = date('m', PluginMonitoringServiceevent::convert_datetime_timestamp($edata['date']));
                     $daynum = $daynum - 1;
                     $split = explode(' ', $datemod);
                     $day = explode("-", $split[0]);
                     array_push($a_labels, $LANG['calendarM'][$daynum] . " " . $day[2]);
                 }
                 foreach ($dat as $name => $value) {
                     if (!isset($mydatat[$name])) {
                         $mydatat[$name] = array();
                     }
                     array_push($mydatat[$name], $value);
                 }
             }
             $ret = $pmServiceevent->getRef($rrdtool_template);
             $a_ref = $ret[0];
             break;
     }
     $i = 0;
     foreach ($mydatat as $name => $data) {
         $i++;
         if ($i == '2') {
             $datat = $data;
             $data = array();
             foreach ($datat as $val) {
                 array_push($data, -$val);
             }
         }
         if (empty($data)) {
             array_push($data, 0);
         }
         $MyData->addPoints($data, $name);
         $color = str_split($a_ref[$name]);
         $MyData->setPalette($name, array("R" => hexdec($color[0] . $color[1]), "G" => hexdec($color[2] . $color[3]), "B" => hexdec($color[4] . $color[5])));
     }
     $MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC, 1);
     //    $MyData->setSerieTicks("Probe 2",4);
     //    $MyData->setAxisName(0,"Temperatures");
     $MyData->addPoints($a_labels, "Labels");
     //    $MyData->setSerieDescription("Labels","Months");
     $MyData->setAbscissa("Labels");
     $myPicture = new pImage(700, 230, $MyData);
     $myPicture->Antialias = FALSE;
     $Settings = array("R" => 225, "G" => 204, "B" => 123);
     $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
     $Settings = array("R" => 255, "G" => 255, "B" => 255);
     $myPicture->drawFilledRectangle(60, 40, 650, 200, $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" => "../lib/pChart2.1.3/fonts/verdana.ttf", "FontSize" => 11));
     $myPicture->drawText(350, 20, $a_jsong->data[0]->labels[0]->title, array("FontSize" => 13, "Align" => TEXT_ALIGN_MIDDLEMIDDLE));
     /* Set the default font */
     $myPicture->setFontProperties(array("FontName" => "../lib/pChart2.1.3/fonts/verdana.ttf", "FontSize" => 7));
     /* Define the chart area */
     $myPicture->setGraphArea(60, 40, 650, 200);
     /* Draw the scale */
     $labelskip = round(count($a_labels) / 8);
     if ($time == '1d') {
         $labelskip = 3;
     } else {
         if ($time == '1m') {
             $labelskip = 3;
         } else {
             if ($time == '0y6m') {
                 $labelskip = 4;
             } else {
                 if ($time == '1y') {
                     $labelskip = 3;
                 }
             }
         }
     }
     $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 158, "GridG" => 158, "GridB" => 158, "GridAlpha" => 80, "DrawSubTicks" => TRUE, "CycleBackground" => FALSE, "LabelSkip" => $labelskip);
     $myPicture->drawScale($scaleSettings);
     /* Write the chart legend */
     $myPicture->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     /* Turn on Antialiasing */
     $myPicture->Antialias = TRUE;
     $Config = array("ForceTransparency" => 60);
     /* Draw the area chart */
     $myPicture->drawAreaChart($Config);
     $myPicture->render(GLPI_PLUGIN_DOC_DIR . "/monitoring/" . $itemtype . "-" . $items_id . "-" . $time . $timezonefile . ".png");
     return;
 }
Ejemplo n.º 8
0
     $chart_limit = 1000;
 }
 $plotShapes = array(SERIE_SHAPE_FILLEDCIRCLE, SERIE_SHAPE_FILLEDTRIANGLE, SERIE_SHAPE_FILLEDSQUARE, SERIE_SHAPE_FILLEDDIAMOND);
 reset($arrFields);
 while (list($idx, $field) = each($arrFields)) {
     if (!isset($chart_cols) or $idx == 0 or in_array($idx, $chart_cols)) {
         $arrSeries[] = $field;
         $myData->addPoints(array_reverse(array_slice($arrCols[$field], 0, $chart_limit)), $field);
         $myData->setSerieWeight($field, $weight);
         if ($plotShape >= 0 and $plotShape < count($plotShapes)) {
             $myData->setSerieShape($field, $plotShapes[$plotShape]);
         } else {
             $myData->setSerieShape($field, $plotShapes[array_rand($plotShapes, 1)]);
         }
         if (isset($palette)) {
             $myData->setPalette($field, $palette['serie'][($nSerie - 1) % $palette['serie_num']]);
         }
         if ($nSerie == 0) {
             $abscissa = $field;
             $myData->setAbscissa($abscissa);
         } else {
             if (isset($chart_cols2) and in_array($idx, $chart_cols2)) {
                 $arrSeriesY2[] = $field;
                 $myData->setSerieOnAxis($field, 1);
                 $myData->setSerieDescription($field, "右){$field}");
             }
         }
         $nSerie += 1;
     }
 }
 if (isset($arrSeriesY2)) {
<?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->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Probe 1");
$MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Probe 2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Probe 3");
$MyData->setPalette("Probe 1", array("R" => 220, "G" => 60, "B" => 20));
$MyData->setSerieTicks("Probe 2", 4);
$MyData->setSerieWeight("Probe 3", 2);
$MyData->setAxisName(0, "Temperatures");
$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);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw a background */
$Settings = array("R" => 190, "G" => 213, "B" => 107, "Dash" => 1, "DashR" => 210, "DashG" => 223, "DashB" => 127);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $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" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(150, 35, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
Ejemplo n.º 10
0
        if (array_key_exists($dateStr, $arrFin)) {
            $pts = $arrFin[$dateStr];
            $myData->AddPoints($pts, "Finished");
        } else {
            $myData->AddPoints(VOID, "Finished");
        }
        if (array_key_exists($dateStr, $arrUnfin)) {
            $pts = $arrUnfin[$dateStr];
            $myData->AddPoints($pts, "Unfinished");
        } else {
            $myData->AddPoints(VOID, "Unfinished");
        }
        $myData->AddPoints($dateStr, "Date");
    }
    $myData->setAbscissa("Date");
    $myData->setPalette("Finished", array("R" => 66, "G" => 116, "B" => 207));
    $myData->setPalette("Unfinished", array("R" => 243, "G" => 168, "B" => 16));
    $labelskip = floor($days / 10);
    $scaleSettings = array("XMargin" => 0, "YMargin" => 0, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelSkip" => $labelskip, "Mode" => SCALE_MODE_START0);
    $format = array("Gradient" => TRUE, "GradientEndR" => 181, "GradientEndG" => 200, "GradientEndB" => 236, "GradientStartR" => 66, "GradientStartG" => 116, "GradientStartB" => 207, "GradientAlpha" => 100);
    $myPicture->setGraphArea(40, 50, 760, $height - 30);
} elseif ($type == 2) {
    $title = "Games per Lobby";
    $explanation = "Last " . $days . " days";
    $sql = "SELECT count( * ) AS cnt, lobbyName\n    FROM " . $tableName . " \n    WHERE lobbyName <> ''\n    AND " . $dateField . " > date_sub( date( now( ) ) , INTERVAL " . $days . " DAY )\n    GROUP BY lobbyName \n    ORDER BY cnt DESC";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        $myData->AddPoints($row['cnt'], "Games");
        $myData->AddPoints($row['lobbyName'], "Lobby");
    }
    $myData->setAbscissa("Lobby");
Ejemplo n.º 11
0
<?php

/* CAT:Polar and radars */
/* pChart library inclusions */
include "../class/pData.class.php";
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(4, 4, 10, 10, 4, 4, 15, 15, 4, 4, 10, 10, 4, 4, 15, 15, 4, 4, 10, 10, 4, 4, 15, 15), "ScoreA");
$MyData->setSerieDescription("ScoreA", "Application A");
$MyData->setPalette("ScoreA", array("R" => 150, "G" => 5, "B" => 217));
/* Define the absissa serie */
$MyData->addPoints(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24), "Time");
$MyData->setAbscissa("Time");
/* Create the pChart object */
$myPicture = new pImage(300, 300, $MyData);
$myPicture->drawGradientArea(0, 0, 300, 300, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 240, "EndG" => 240, "EndB" => 240, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 300, 20, DIRECTION_HORIZONTAL, array("StartR" => 30, "StartG" => 30, "StartB" => 30, "EndR" => 100, "EndG" => 100, "EndB" => 100, "Alpha" => 100));
$myPicture->drawLine(0, 20, 300, 20, array("R" => 255, "G" => 255, "B" => 255));
$RectangleSettings = array("R" => 180, "G" => 180, "B" => 180, "Alpha" => 100);
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 299, 299, 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" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
Ejemplo n.º 12
0
function pch_threshold_graph($graph_type, $index, $data, $width, $height, $font, $antialiasing, $xaxisname = "", $yaxisname = "", $title = "", $show_values = false, $show_legend = false, $font_size)
{
    /* CAT:Threshold Chart */
    /* Create and populate the pData object */
    $MyData = new pData();
    $MyData->addPoints($data, "DEFCA");
    $MyData->setAxisName(0, $yaxisname);
    $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY);
    $MyData->addPoints($index, "Labels");
    $MyData->setSerieDescription("Labels", $xaxisname);
    $MyData->setAbscissa("Labels");
    $MyData->setPalette("DEFCA", array("R" => 55, "G" => 91, "B" => 127));
    /* Create the pChart object */
    $myPicture = new pImage(700, 230, $MyData);
    $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 100));
    $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 200, "G" => 200, "B" => 200));
    /* Write the picture title */
    $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size));
    $myPicture->drawText(60, 35, $title, array("FontSize" => $font_size, "Align" => TEXT_ALIGN_BOTTOMLEFT));
    /* Do some cosmetic and draw the chart */
    $myPicture->setGraphArea(60, 40, 670, 190);
    $myPicture->drawFilledRectangle(60, 40, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
    $myPicture->drawScale(array("GridR" => 180, "GridG" => 180, "GridB" => 180, "Mode" => SCALE_MODE_START0));
    $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => $font_size));
    $settings = array("Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "DisplayValues" => $show_values, "DisplayZeroValues" => FALSE, "DisplayR" => 100, "DisplayG" => 100, "DisplayB" => 100, "DisplayShadow" => TRUE, "Surrounding" => 5, "AroundZero" => FALSE);
    $myPicture->drawSplineChart($settings);
    $myPicture->setShadow(FALSE);
    if ($show_legend) {
        /* Write the chart legend */
        $myPicture->drawLegend(643, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
    }
    /* Render the picture */
    $myPicture->stroke();
}
$stat_avg = $stats_data[2];
$stat_stdev = $stats_data[3];
$stat_count = $stats_data[4];
///////////////////////////////////////////////////////////////////////////////////////////////////////
// THIS DRAWS THE GRAPH
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Create and populate the pData object
$MyData = new pData();
$MyData->addPoints($histogram_data, "histogram_data");
$MyData->setAxisName(0, "Count");
$MyData->addPoints($bin_labels, "Labels");
$MyData->setSerieDescription("Labels", $runner);
$MyData->setAbscissa("Labels");
// change bar colour
$serieSettings = array("R" => 0, "G" => 0, "B" => 0, "Alpha" => 100);
$MyData->setPalette("histogram_data", $serieSettings);
// Create the pChart object
$myPicture = new pImage(700, 500, $MyData);
// Add a border to the picture
$myPicture->drawRectangle(0, 0, 699, 499, array("R" => 0, "G" => 0, "B" => 0));
// Write the picture title
$myPicture->setFontProperties(array("FontName" => "../pchart/fonts/verdana.ttf", "FontSize" => 6));
$myPicture->drawText(500, 150, "Min:" . $stat_min, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(500, 160, "Max:" . $stat_max, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(500, 170, "Avg:" . $stat_avg, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(500, 180, "St. Dev:" . $stat_stdev, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawText(500, 190, "Count:" . $stat_count, array("R" => 0, "G" => 0, "B" => 0));
// Write the chart title
$myPicture->setFontProperties(array("FontName" => "../pchart/fonts/verdana.ttf", "FontSize" => 11));
$myPicture->drawText(350, 55, $runner . " Histogram", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
// Draw the info
Ejemplo n.º 14
0
            $myPicture->setFontProperties(array("FontName" => "pChart/fonts/verdana.ttf", "FontSize" => 10));
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
            /* Set the graph area */
            $myPicture->setGraphArea(50, 40, 65 * $nbr_room + 35, 290);
            $myPicture->drawGradientArea(50, 40, 65 * $nbr_room + 35, 290, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30));
            /* Draw the chart scale */
            $scaleSettings = array("AxisAlpha" => 10, "TickAlpha" => 10, "DrawXLines" => FALSE, "Mode" => SCALE_MODE_START0, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10);
            $myPicture->drawScale($scaleSettings);
            /* Draw the chart */
            $MyData->setSerieDrawable("Objectif", FALSE);
            $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayPos" => LABEL_POS_INSIDE, "Surrounding" => 30));
            $MyData->setSerieDrawable("Objectif", TRUE);
            $MyData->setSerieDrawable("Consomation moyenne des baies (kW)", FALSE);
            $MyData->setSerieDrawable("Salles", FALSE);
            $serieSettings = array("R" => 229, "G" => 11, "B" => 11);
            $MyData->setPalette("Objectif", $serieSettings);
            $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
            $myPicture->drawSplineChart();
            if ($consult_date != "Donnée actuelle") {
                $myPicture->Render("images/consoe_graph_render_{$consult_date}.png");
            } else {
                $myPicture->Render("images/consoe_graph_render.png");
            }
        } else {
            $error = 1;
        }
    }
} catch (Exception $e) {
    // Catch des erreurs et écriture dans le fichier de log
    require 'error_log.php';
}
Ejemplo n.º 15
0
    $ColorPalete = array("R" => 220, "G" => 140, "B" => 100);
} elseif ($_GET['gcolor'] == 'blue') {
    $ColorPalete = array("R" => 100, "G" => 140, "B" => 220);
} elseif ($_GET['gcolor'] == 'green') {
    $ColorPalete = array("R" => 69, "G" => 139, "B" => 16);
} elseif ($_GET['gcolor'] == 'orange') {
    $ColorPalete = array("R" => 255, "G" => 140, "B" => 0);
} else {
    if (SETTINGS_THEME == 'light' || $_GET['bg'] == 'light') {
        $ColorPalete = array("R" => 150, "G" => 150, "B" => 150);
    } else {
        $ColorPalete = array("R" => 250, "G" => 250, "B" => 250);
    }
}
//$ColorPalete["Alpha"] = 100; //прозрачность
$DataSet->setPalette("Serie1", $ColorPalete);
// Initialise the graph
/* Create a pChart object and associate your dataset */
$Test = new pImage($w, $h, $DataSet);
/* Define the boundaries of the graph area */
$Test->setGraphArea($left_border, $top_border, $w - $right_border, $h - $bottom_border);
//градиентная заливка фона
if (SETTINGS_THEME == 'light' || $_GET['bg'] == 'light') {
    $Settings = array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 160, "EndG" => 160, "EndB" => 160, "Alpha" => 100);
} else {
    $Settings = array("StartR" => 132, "StartG" => 153, "StartB" => 172, "EndR" => 82, "EndG" => 103, "EndB" => 122, "Alpha" => 100);
}
$Test->drawGradientArea(0, 0, $w, $h, DIRECTION_VERTICAL, $Settings);
//градиентная заливка поля графика
$Settings["StartR"] = $Settings["StartR"] + 40;
$Settings["StartG"] = $Settings["StartG"] + 40;
Ejemplo n.º 16
0
 function grapBuild($id_empresa = null, $concepto = null, $area_name = null, $fracciones_name = null, $month_name = null, $grapColor = null, $operacion = null, $dateParam = null, $year = null)
 {
     // 		    build the data for ImagesShell
     // 		$operacion = array('1'=>'0');
     // 		$month_name = '';
     $EmpConditions['Empresas.active'] = '1';
     // Check if the area is alive
     $empresas = $this->Empresas->find('list', array('fields' => array('id_empresa', 'empresa'), array('conditions' => $EmpConditions)));
     App::Import('Shell', 'Shell');
     App::Import('Vendor', array('shells/calendar'));
     $myCalendar = new CalendarShell(new Object());
     $myCalendar->initialize();
     // 	  $calendar = $myCalendar->main($year=date('Y'),false);
     $month = $myCalendar->months(true, false, $year);
     //   		$url= '/tmp/images/';
     $url = "../../app/webroot/img/thumbs/daily/";
     $this->autoRender = false;
     // i don't remember why is this but do it
     App::import('Vendor', 'pData', array('file' => 'pcharts' . DS . 'class' . DS . 'pData.class.php'));
     App::import('Vendor', 'pDraw', array('file' => 'pcharts' . DS . 'class' . DS . 'pDraw.class.php'));
     App::import('Vendor', 'pImage', array('file' => 'pcharts' . DS . 'class' . DS . 'pImage.class.php'));
     $fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pcharts' . DS . 'fonts' . DS;
     $maxValue = max($operacion);
     /* Create and populate the pData object */
     $MyData = new pData();
     // 		$MyData->addPoints($report_day,"Temperature");
     $MyData->addPoints($operacion, $concepto);
     // 		$MyData->setSerieDrawable($concepto,TRUE);
     $MyData->setAxisName(0, $concepto);
     // 		$MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"),"Labels");
     $MyData->addPoints($dateParam, "dateParam");
     $MyData->setSerieDescription("dateParam", "Dias");
     $MyData->setAbscissa("dateParam");
     // 		$MyData->drawAll();
     /* Create the per bar palette */
     $Palette = array("0" => array("R" => 188, "G" => 224, "B" => 46, "Alpha" => 80), "1" => array("R" => 143, "G" => 189, "B" => 216, "Alpha" => 80), "2" => array("R" => 239, "G" => 210, "B" => 121, "Alpha" => 80), "3" => array("R" => 122, "G" => 224, "B" => 146, "Alpha" => 80), "4" => array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 80), "5" => array("R" => 46, "G" => 151, "B" => 224, "Alpha" => 80), "6" => array("R" => 137, "G" => 154, "B" => 173, "Alpha" => 80), "7" => array("R" => 76, "G" => 136, "B" => 190, "Alpha" => 80), "8" => array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80));
     // 		$MyData->normalize(100,"%");
     $xLenght = "220";
     /* Create the pChart object */
     $myPicture = new pImage(700, $xLenght, $MyData, TRUE);
     /* Draw serie 1 in red with a 80% opacity */
     $MyData->setPalette(array($concepto), $Palette[$grapColor]);
     $Settings = array("R" => 200, "G" => 200, "B" => 200, "StartR" => 250, "StartG" => 250, "StartB" => 250, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 0);
     $Settings = array("R" => 255, "G" => 255, "B" => 255, "StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 0);
     //$myPicture->drawRectangle(0,0,699,229,array("R"=>200,"G"=>200,"B"=>200));
     $myPicture->drawFilledRectangle(0, 0, 700, $xLenght + 10, $Settings);
     /* Overlay with a gradient */
     $myPicture->drawGradientArea(0, 0, 700, $xLenght + 10, DIRECTION_VERTICAL, $Settings);
     /* Write the chart title */
     $myPicture->setFontProperties(array("FontName" => $fontFolder . "Forgotte.ttf", "FontSize" => 10));
     /* Draw some thresholds */
     // 		$myPicture->setShadow(FALSE);
     // 		$myPicture->drawThreshold(-40,array("WriteCaption"=>TRUE,"R"=>0,"G"=>0,"B"=>0,"Ticks"=>4));
     // 		$myPicture->drawThreshold($maxValue,array("WriteCaption"=>TRUE,"R"=>0,"G"=>0,"B"=>0,"Ticks"=>4));
     //TODO->Define if mensual or annual
     if (isset($month_name) and isset($area_name)) {
         if (trim($area_name) === 'Tijuana') {
             $area = 'Mexicali';
         } else {
             $area = $area_name;
         }
         $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $area . "-" . $month[$month_name]['spanish'] . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
         //Diario
     }
     if (!isset($month_name) and !isset($area_name)) {
         $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $empresas[$id_empresa] . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
         //Annual
     }
     if (!isset($month_name) and isset($area_name)) {
         if (trim($area_name) === 'Tijuana') {
             $area = 'Mexicali';
         } else {
             $area = $area_name;
         }
         $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $area . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
         //areaAnnual
     }
     if (isset($month_name) and !isset($area_name)) {
         $myPicture->drawText(350, 30, ucfirst($concepto) . "-" . $empresas[$id_empresa] . "-" . $month[$month_name]['spanish'] . "-" . $year, array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
         //areaAnnual
     }
     /* Define the 2nd chart area */
     $myPicture->setGraphArea(60, 35, 660, 200);
     $myPicture->setFontProperties(array("FontName" => $fontFolder . "pf_arma_five.ttf", "FontSize" => 6));
     /* Draw the scale */
     $scaleSettings = array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "RemoveXAxis" => FALSE, "Mode" => SCALE_MODE_ADDALL_START0, "DrawArrows" => TRUE, "ArrowSize" => 6);
     $myPicture->drawScale($scaleSettings);
     $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => FALSE, "Rounded" => FALSE, "Surrounding" => 15, "InnerSurrounding" => 15));
     //TODO->Define if mensual or annual
     if (isset($month_name) and isset($area_name)) {
         $myPicture->autoOutput($url . "{$concepto}" . "_" . "{$area_name}" . "_" . "{$month_name}" . "_" . $year . ".png");
         //Diario
     }
     if (!isset($month_name) and !isset($area_name)) {
         $myPicture->autoOutput($url . $concepto . "_" . strtolower($empresas[$id_empresa]) . "_" . $year . ".png");
         //Annual
     }
     if (!isset($month_name) and isset($area_name)) {
         $myPicture->autoOutput($url . "{$concepto}" . "_" . $area_name . "_" . $year . ".png");
         //areaAnnual
     }
     if (isset($month_name) and !isset($area_name)) {
         $myPicture->autoOutput($url . $concepto . "_" . strtolower($empresas[$id_empresa]) . "_" . $month_name . "_" . $year . ".png");
         //areaAnnual
     }
 }
Ejemplo n.º 17
0
 function createStatistics($graph, $limit, $lastUpdate, $language)
 {
     SpotTranslation::initialize($language);
     $spotStatistics = new SpotStatistics($this->_db);
     include_once "images/pchart/pData.class.php";
     include_once "images/pchart/pDraw.class.php";
     include_once "images/pchart/pImage.class.php";
     $width = 800;
     $height = 500;
     $titleHeight = 20;
     $dataSet = array();
     $graphs = $this->getValidStatisticsGraphs();
     $limits = $this->getValidStatisticsLimits();
     switch ($graph) {
         case 'spotsperhour':
             $prepData = $this->prepareData($spotStatistics->getSpotCountPerHour($limit, $lastUpdate));
             $legend = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23');
             for ($x = 0; $x <= 23; $x++) {
                 $dataSet[] = @$prepData[$x];
             }
             $graphicType = "bar";
             break;
         case 'spotsperweekday':
             $prepData = $this->prepareData($spotStatistics->getSpotCountPerWeekday($limit, $lastUpdate));
             $legend = array(_("Monday"), _("Tuesday"), _("Wednesday"), _("Thursday"), _("Friday"), _("Saturday"), _("Sunday"));
             $dataSet = array(@$prepData[1], @$prepData[2], @$prepData[3], @$prepData[4], @$prepData[5], @$prepData[6], @$prepData[0]);
             $graphicType = "bar";
             break;
         case 'spotspermonth':
             $prepData = $this->prepareData($spotStatistics->getSpotCountPerMonth($limit, $lastUpdate));
             $legend = array(_("January"), _("February"), _("March"), _("April"), _("May"), _("June"), _("July"), _("August"), _("September"), _("October"), _("November"), _("December"));
             for ($x = 1; $x <= 12; $x++) {
                 $dataSet[] = @$prepData[$x];
             }
             $graphicType = "bar";
             break;
         case 'spotspercategory':
             $prepData = $this->prepareData($spotStatistics->getSpotCountPerCategory($limit, $lastUpdate));
             $legend = array(_(SpotCategories::HeadCat2Desc(0)), _(SpotCategories::HeadCat2Desc(1)), _(SpotCategories::HeadCat2Desc(2)), _(SpotCategories::HeadCat2Desc(3)));
             for ($x = 0; $x <= 3; $x++) {
                 $dataSet[] = @$prepData[$x];
             }
             $graphicType = "3Dpie";
             break;
     }
     # switch
     array_walk($dataSet, create_function('& $item, $key', 'if ($item === NULL) $item = 0;'));
     $title = $graphs[$graph];
     if (!empty($limit)) {
         $title .= " (" . $limits[$limit] . ")";
     }
     # if
     $imgData = new pData();
     if ($graphicType == "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 ($graphicType == "3Dpie") {
         include_once "images/pchart/pPie.class.php";
         $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();
         $data = $this->getImageInfoFromString($imageString);
         return array('metadata' => $data['metadata'], 'content' => $imageString);
     }
     # img
 }
Ejemplo n.º 18
0
 }
 if ($result) {
     $i = 1;
     while ($row = mysqli_fetch_assoc($result)) {
         $rounds[$i] = $i;
         $date[] = date("M d", strtotime($row['Date']));
         $average[] = $row['Average'];
         $i++;
     }
 }
 $myData = new pData();
 $myData->addPoints($average, "Serie1");
 $myData->setSerieDescription("Serie1", "Average");
 $myData->setSerieOnAxis("Serie1", 0);
 $serieSettings = array("R" => 218, "G" => 165, "B" => 32);
 $myData->setPalette("Serie1", $serieSettings);
 $myData->addPoints($date, "Absissa");
 $myData->setAbscissa("Absissa");
 $myData->setAxisPosition(0, AXIS_POSITION_LEFT);
 $myData->setAxisName(0, "Players");
 $myData->setAxisUnit(0, "");
 $myPicture = new pImage(600, 300, $myData, TRUE);
 $myPicture->setFontProperties(array("FontName" => "../pchart/fonts/Forgotte.ttf", "FontSize" => 12));
 $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 150, "G" => 150, "B" => 150);
 // if so, this is a server stats page
 if (!empty($sid)) {
     $myPicture->drawText(297, 18, "Average number of players in server in last " . $limit . " days of server activity.", $TextSettings);
 } else {
     $myPicture->drawText(297, 18, "Average number of players in servers in last " . $limit . " days of server activity.", $TextSettings);
 }
 $myPicture->setShadow(FALSE);
Ejemplo n.º 19
0
    public static function tests_pchart2()
    {
        /*
            $xmlStr = <<<EOT
        <testsuites>
        <testsuite2 name="whaever">
          <testsuite name="DatabaseTest" file="/Users/pfonseca/Dev/cintient/src/tests/DatabaseTest.php" tests="23" assertions="79" failures="0" errors="0" time="0.129403">
            <testsuite name="DatabaseTest::testExecuteNoParamsBinding" tests="5" assertions="15" failures="0" errors="0" time="0.028787">
              <testcase name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
              <testcase name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
              <testcase name="testExecuteNoParamsBinding with data set #2" assertions="3" time="0.004264"/>
              <testcase name="testExecuteNoParamsBinding with data set #3" assertions="3" time="0.004306"/>
              <testcase name="testExecuteNoParamsBinding with data set #4" assertions="3" time="0.004747"/>
            </testsuite>
            <testsuite name="DatabaseTest::testQueryNoParamsBinding" tests="1" assertions="3" failures="0" errors="0" time="0.004441">
              <testcase name="testQueryNoParamsBinding with data set #0" assertions="3" time="0.004441"/>
            </testsuite>
            <testsuite name="DatabaseTest::testQueryParamsBinding" tests="1" assertions="3" failures="0" errors="0" time="0.004417">
              <testcase name="testQueryParamsBinding with data set #0" assertions="3" time="0.004417"/>
            </testsuite>
            <testsuite name="DatabaseTest::testQueryParamsBindingExcessValues" tests="1" assertions="3" failures="0" errors="0" time="0.005673">
              <testcase name="testQueryParamsBindingExcessValues with data set #0" assertions="3" time="0.005673"/>
            </testsuite>
          </testsuite>
        </testsuite2>
        </testsuites>
        EOT;
        */
        $xmlStr = <<<EOT
<aa>
  <aa1>
    <aa2 name="DatabaseTest" file="/Users/pfonseca/Dev/cintient/src/tests/DatabaseTest.php" tests="23" assertions="79" failures="0" errors="0" time="0.129403">
      <aa3 name="DatabaseTest::testExecuteNoParamsBinding" tests="5" assertions="15" failures="3" errors="0" time="0.028787">
        <aa41 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
        <aa42 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa43 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa44 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa45 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa46 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
      </aa3>
      <aa4 name="DatabaseTest::testExecuteParamsBinding" tests="5" assertions="12" failures="1" errors="0" time="0.010916">
        <aa41 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
        <aa42 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa43 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa44 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
      </aa4>
      <aa5 name="DatabaseTest::testQuery" tests="5" assertions="4" failures="0" errors="0" time="0.004554">
        <aa51 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
        <aa52 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa53 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa54 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
      </aa5>
      <aa6 name="DatabaseTest::testInsert" tests="5" assertions="7" failures="6" errors="0" time="0.014587">
        <aa61 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa6>
      <aa7 name="DatabaseTest::testBeginTransaction" tests="5" assertions="25" failures="4" errors="0" time="0.023787">
        <aa71 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa7>
      <aa6 name="DatabaseTest::testInsert" tests="5" assertions="7" failures="6" errors="0" time="0.014587">
        <aa61 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa6>
      <aa7 name="DatabaseTest::testBeginTransaction" tests="5" assertions="25" failures="4" errors="0" time="0.023787">
        <aa71 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa7>
    </aa2>
    <ab2 name="DatabaseTest" file="/Users/pfonseca/Dev/cintient/src/tests/DatabaseTest.php" tests="23" assertions="79" failures="0" errors="0" time="0.129403">
      <ab6 name="DatabaseTest::testInsert" tests="5" assertions="7" failures="6" errors="0" time="0.018787">
        <ab61 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </ab6>
      <ab7 name="DatabaseTest::testBeginTransaction" tests="5" assertions="25" failures="4" errors="0" time="0.028787">
        <ab71 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </ab7>
    </ab2>
  </aa1>
</aa>
EOT;
        //
        // Access file testsuites directly (last level before testcases).
        // This can't be a closure because of its recursiveness.
        //
        function f($node)
        {
            if (isset($node->attributes()->file)) {
                return $node;
            } else {
                return f($node->children());
            }
        }
        $xml = new SimpleXMLElement($xmlStr);
        $classes = array();
        $xmls = $xml->children();
        /*
            foreach ($xmls as $node) {
              $getRootNode = f($node);
              $classXml = f($node);
              $class = new TestClass();
              $class->setName($classXml->getName());
              $class->setFile((string)$classXml->attributes()->file);
              $class->setTests((string)$classXml->attributes()->tests);
              $class->setAssertions((string)$classXml->attributes()->assertions);
              $class->setFailures((string)$classXml->attributes()->failures);
              $class->setErrors((string)$classXml->attributes()->errors);
              $class->setTime((string)$classXml->attributes()->time);
        
              $methods = array();
              foreach ($classXml->children() as $methodXml) {
                $method = new TestMethod();
                $method->setName($methodXml->getName());
                $method->setTests((string)$methodXml->attributes()->tests);
                $method->setAssertions((string)$methodXml->attributes()->assertions);
                $method->setFailures((string)$methodXml->attributes()->failures);
                $method->setErrors((string)$methodXml->attributes()->errors);
                $method->setTime((string)$methodXml->attributes()->time);
        
                $cases = array();
                foreach ($methodXml->children() as $caseXml) {
                  $case = new TestCase();
                  $case->setName((string)$caseXml->getName());
                  $case->setAssertions((string)$caseXml->attributes()->assertions);
                  $case->setTime((string)$caseXml->attributes()->time);
                  $cases[] = $case;
                }
                $method->setTestCases($cases);
                $methods[] = $method;
              }
              $class->setTestMethods($methods);
              $classes[] = $class;
            }*/
        foreach ($xmls as $node) {
            $assertions = 0;
            // total number of "test" points
            $successes = array();
            // assertions - failures
            $failures = array();
            $testMethods = array();
            $classXml = f($node);
            $class = new TestClass();
            $class->setName($classXml->getName());
            $class->setFile((string) $classXml->attributes()->file);
            $class->setTests((string) $classXml->attributes()->tests);
            $class->setAssertions((string) $classXml->attributes()->assertions);
            $class->setFailures((string) $classXml->attributes()->failures);
            $class->setErrors((string) $classXml->attributes()->errors);
            $class->setTime((string) $classXml->attributes()->time);
            $methods = array();
            $i = 0;
            foreach ($classXml->children() as $methodXml) {
                $method = new TestMethod();
                $method->setName($methodXml->getName());
                $method->setTests((string) $methodXml->attributes()->tests);
                $method->setAssertions((string) $methodXml->attributes()->assertions);
                $method->setFailures((string) $methodXml->attributes()->failures);
                $method->setErrors((string) $methodXml->attributes()->errors);
                $method->setTime((string) $methodXml->attributes()->time);
                /*
                $cases = array();
                foreach ($methodXml->children() as $caseXml) {
                  $case = new TestCase();
                  $case->setName((string)$caseXml->getName());
                  $case->setAssertions((string)$caseXml->attributes()->assertions);
                  $case->setTime((string)$caseXml->attributes()->time);
                  $cases[] = $case;
                }
                $method->setTestCases($cases);
                */
                $methods[] = $method;
                $time = (double) $methodXml->attributes()->time * 1000;
                // to milliseconds
                $testMethods[] = $methodXml->attributes()->name;
                $f = (double) $methodXml->attributes()->failures * $time / (double) $methodXml->attributes()->assertions;
                $successes[] = (double) $time - (double) $f;
                $failures[] = $f;
                $i++;
            }
            $chartWidth = 700;
            if ($i == 1) {
                $i++;
            }
            $chartHeight = 25 * $i + 60;
            /* pChart library inclusions */
            include 'lib/pChart/class/pData.class';
            include 'lib/pChart/class/pDraw.class';
            include 'lib/pChart/class/pImage.class';
            $MyData = new pData();
            $MyData->addPoints($successes, "Ok");
            $MyData->addPoints($failures, "Fail");
            $MyData->setPalette("Ok", array("R" => 124, "G" => 196, "B" => 0, "Alpha" => 100));
            $MyData->setPalette("Fail", array("R" => 254, "G" => 15, "B" => 0, "Alpha" => 100));
            $MyData->setAxisName(0, "Time (ms)");
            //$MyData->setAxisUnit(0,"ms");
            $MyData->addPoints($testMethods, " ");
            $MyData->setAbscissa(" ");
            /* Create the pChart object */
            //
            // ~40px for each test
            //
            $myPicture = new pImage($chartWidth, $chartHeight, $MyData);
            $myPicture->Antialias = false;
            $myPicture->drawGradientArea(0, 0, $chartWidth, $chartHeight, DIRECTION_VERTICAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
            /* Write the picture title */
            $myPicture->setFontProperties(array("FontName" => CINTIENT_INSTALL_DIR . "lib/pChart/fonts/pf_arma_five.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255));
            $myPicture->drawText(10, 13, "Unit tests on " . $classXml->getName(), array("R" => 255, "G" => 255, "B" => 255));
            /* Draw the scale and the chart */
            $myPicture->setGraphArea(240, 40, 640, $chartHeight - 20);
            $myPicture->drawFilledRectangle(240, 40, 640, $chartHeight - 20, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -100, "Alpha" => 10));
            $myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL, "DrawSubTicks" => true, "MinDivHeight" => 20, 'GridTicks' => 2, 'DrawXLines' => true, 'DrawYLines' => ALL));
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
            $myPicture->drawStackedBarChart(array("Interleave" => 2, "Gradient" => false));
            $myPicture->drawLegend(15, $chartHeight - 15, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
            $myPicture->setShadow(FALSE);
            /* Write the chart legend */
            //$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
            /* Render the picture (choose the best way) */
            $myPicture->autoOutput("pictures/example.drawStackedBarChart.png");
            $class->setTestMethods($methods);
            $classes[] = $class;
        }
        //
        // We're exactly at the test class (file) root level, with level 1 being
        // the unit test (method of the original class) and level 2 being
        // the various datasets used in the test (each a test case).
        //
        /* @ 700x230 Stacked bar chart drawing example. */
        exit;
    }
Ejemplo n.º 20
0
/**
 * eval_ccpc_genGraphRadar - Génère un graphique de type Radar simple sous forme d'image au format PNG
 *
 * @category : eval_ccpc_functions
 * @param array $data Données à partir desquelles le graphique est généré
 * @return string URL de l'image générée
 *
 * @Author Ali Bellamine
 *
 * Structure de $data :<br>
 * 	['data'][nom du label] => (int) Valeur du label<br>
 * 	['settings']['max'] => (int) Valeur maximale<br>
 * 	['settings']['height'] => (int) Hauteur du graphique (en px)<br>
 * 	['settings']['width'] => (int) Largeur du graphique (en px)
 *
 */
function eval_ccpc_genGraphRadar($data)
{
    // On vérifie les données fournit
    if (isset($data) && isset($data['data']) && count($data['data']) > 0) {
        // On récupère le hash de $data
        $hash = md5(json_encode($data));
        // Chemin du fichier
        $filePath = PLUGIN_PATH . 'cache/' . $hash . '.png';
        $filePathURI = ROOT . 'evaluations/ccpc/cache/' . $hash . '.png';
        if (is_file($filePath)) {
            return $filePathURI;
        } else {
            // On crée l'image
            /* On inclut la librairie */
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pData.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pRadar.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pDraw.class.php';
            require_once PLUGIN_PATH . 'core/pChart2.1.4/class/pImage.class.php';
            /* On crée l'objet pData */
            // Préparation des données
            $tempLegendArray = array();
            // Contient les légendes
            $tempDataArray = array();
            // Contient les données chiffrés
            foreach ($data['data'] as $tempDataLegend => $tempDataValue) {
                $tempLegendArray[] = $tempDataLegend;
                if (is_numeric($tempDataValue)) {
                    $tempDataArray[] = $tempDataValue;
                } else {
                    return FALSE;
                }
            }
            $MyData = new pData();
            $MyData->addPoints($tempDataArray, 'Valeurs');
            $MyData->setPalette("Valeurs", array("R" => 150, "G" => 5, "B" => 217));
            $MyData->addPoints($tempLegendArray, 'Label');
            $MyData->setAbscissa("Label");
            $MyData->setSerieDescription("Label", "Label");
            /* On crée l'objet pChart */
            if (isset($data['settings']['width'])) {
                $width = $data['settings']['width'];
            } else {
                $width = 600;
            }
            if (isset($data['settings']['height'])) {
                $height = $data['settings']['height'];
            } else {
                $height = 300;
            }
            $myPicture = new pImage($width, $height, $MyData, TRUE);
            $myPicture->setFontProperties(array("FontName" => PLUGIN_PATH . 'core/pChart2.1.4/fonts/verdana.ttf', "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0));
            // On détermine les limites
            $myPicture->setGraphArea(0, 0, $width, $height - 30);
            /* On crée l'objet pRadar */
            $SplitChart = new pRadar();
            $Options = array("DrawPoly" => TRUE, "LabelPos" => RADAR_LABELS_HORIZONTAL, "WriteValues" => TRUE, "WriteValuesInBubble " => TRUE, "InnerBubbleR" => 255, "InnerBubbleG" => 255, "InnerBubbleB" => 255, "ValueFontSize" => 20, "ValuePadding" => 10, "Layout" => RADAR_LAYOUT_CIRCLE, "BackgroundGradient" => array("StartR" => 255, "StartG" => 255, "StartB" => 255, "StartAlpha" => 100, "EndR" => 207, "EndG" => 227, "EndB" => 125, "EndAlpha" => 50));
            if (isset($data['settings']['max']) && is_numeric($data['settings']['max'])) {
                // Prise en charge de la possibilité d'imposer le min et le max
                $Options['FixedMax'] = $data['settings']['max'];
            }
            $SplitChart->drawRadar($myPicture, $MyData, $Options);
            $myPicture->render($filePath);
            return $filePathURI;
        }
    } else {
        return FALSE;
    }
}
Ejemplo n.º 21
0
 private function drawCharts($filename, $yAxisLabel, $dataSeriesAllTime, $labelSeriesAllTime, $dataSeriesLast2Month, $labelSeriesLast2Month)
 {
     /* Build the dataset for all time*/
     $allTimeData = new pData();
     $allTimeData->addPoints($dataSeriesAllTime, "members");
     $allTimeData->setAxisName(0, $yAxisLabel);
     $allTimeData->addPoints($labelSeriesAllTime, "Labels");
     $serieSettings = array("R" => 74, "G" => 102, "B" => 27, "Alpha" => 90);
     $allTimeData->setPalette("members", $serieSettings);
     // $allTimeData->setSerieOnAxis("Labels", 1);
     $allTimeData->setAbscissa("Labels");
     /* Create the chart*/
     $allTimePicture = new pImage(400, 250, $allTimeData, true);
     $allTimePicture->setFontProperties(array("FontName" => "../lib/pchart-2.1.3/fonts/verdana.ttf", "FontSize" => 6));
     /* Add a border to the picture */
     $allTimePicture->setGraphArea(50, 20, 380, 210);
     $allTimePicture->drawFilledRectangle(50, 20, 380, 210, array("R" => 232, "G" => 238, "B" => 248, "Alpha" => 100));
     $allTimePicture->drawScale(array("XMargin" => 0, "DrawSubTicks" => true, "DrawXLines" => false, "Mode" => SCALE_MODE_START0, "CycleBackground" => true, "LabelSkip" => 52, "ForceTransparency" => 0));
     $allTimePicture->drawAreaChart(array("DisplayValues" => false, "DisplayColor" => DISPLAY_AUTO, ""));
     $allTimePicture->render($filename . "-alltime.png");
     /* Build the dataset for the last two month */
     $last2MonthData = new pData();
     $last2MonthData->addPoints($dataSeriesLast2Month, "members");
     $last2MonthData->setAxisName(0, $yAxisLabel);
     $last2MonthData->addPoints($labelSeriesLast2Month, "Labels");
     $last2MonthData->setPalette("members", $serieSettings);
     $last2MonthData->setAbscissa("Labels");
     /* Create the chart*/
     $last2MonthPicture = new pImage(400, 250, $last2MonthData, true);
     $last2MonthPicture->setFontProperties(array("FontName" => "../lib/pchart-2.1.3/fonts/verdana.ttf", "FontSize" => 6));
     $last2MonthPicture->Antialias = true;
     /* Add a border to the picture */
     $last2MonthPicture->setGraphArea(50, 20, 380, 210);
     $miny = min($dataSeriesLast2Month);
     $maxy = max($dataSeriesLast2Month);
     $axisBoundaries = array(0 => array("Min" => $miny, "Max" => $maxy));
     $last2MonthPicture->drawFilledRectangle(50, 20, 380, 210, array("R" => 232, "G" => 238, "B" => 248, "Alpha" => 100));
     $last2MonthPicture->drawScale(array("DrawSubTicks" => true, "DrawXLines" => true, "CycleBackground" => true, "LabelSkip" => 13, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $axisBoundaries));
     // get min and max values set scales accordingly
     $last2MonthPicture->drawAreaChart(array("DisplayValues" => false, "DisplayColor" => DISPLAY_AUTO, ""));
     $last2MonthPicture->render($filename . "-last2month.png");
 }
Ejemplo n.º 22
0
 public function drawCompetencyExpertsRadar($img, $points, $competences, $roles, $skale)
 {
     $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));
     $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(700 * 1.53, 700 * 1.53, $MyData);
     $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . '/fonts/georgia.ttf', "FontSize" => round(14 * 1.53), "R" => 80, "G" => 80, "B" => 80));
     /* Create the pRadar object */
     $SplitChart = new \pRadar();
     /* Draw a radar chart */
     $myPicture->setGraphArea(10 * 1.53, 80 * 1.53, 640 * 1.53, 640 * 1.53);
     $Options = array("Layout" => RADAR_LAYOUT_STAR, 'SegmentHeight' => ceil($skale['max'] / 4), "FontName" => dirname(__FILE__) . '/fonts/georgia.ttf', "FontSize" => round(14 * 1.53), 'LabelPos' => RADAR_LABELS_HORIZONTAL, 'LineWidth' => 3);
     $SplitChart->drawRadar($myPicture, $MyData, $Options);
     /* Write the chart legend */
     $myPicture->setFontProperties(array("FontName" => dirname(__FILE__) . '/fonts/georgia.ttf', "FontSize" => round(12 * 1.53)));
     $myPicture->drawLegend(220 * 1.53, 20 * 1.53, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     $myPicture->render($img);
 }
Ejemplo n.º 23
0
         array_push($http_count_values, NULL);
     } else {
         array_push($http_count_values, $http_count[strval($day)]);
     }
     if (!isset($email_count[strval($day)])) {
         array_push($email_count_values, NULL);
     } else {
         array_push($email_count_values, $email_count[strval($day)]);
     }
 }
 if (count($day_ftp_count) == 0 && count($report_count) == 0) {
     $ftp_count_values[0] = 0;
 }
 $legend_offset = 415 + 165;
 $MyData->addPoints($reports_array, "Reports");
 $MyData->setPalette("Reports", array("R" => 220, "G" => 82, "B" => 91, "Alpha" => 100));
 $MyData->addPoints($ftp_count_values, "FTP");
 $MyData->setPalette("FTP", array("R" => 0, "G" => 39, "B" => 94, "Alpha" => 100));
 if ($enable_http_mode && ($show_http_to_users || $pony_db->priv_is_admin())) {
     $MyData->addPoints($http_count_values, "HTTP");
     $MyData->setPalette("HTTP", array("R" => 150, "G" => 10, "B" => 150, "Alpha" => 100));
     $legend_offset -= 35;
 }
 if ($enable_email_mode && ($show_email_to_users || $pony_db->priv_is_admin())) {
     $MyData->addPoints($email_count_values, "E-mail");
     $MyData->setPalette("E-mail", array("R" => 10, "G" => 150, "B" => 10, "Alpha" => 100));
     $legend_offset -= 40;
 }
 $MyData->setAxisName(0, win2uni($lang['Count']));
 $MyData->addPoints($chart_day_labels, "Labels");
 $MyData->setSerieDescription("Labels", win2uni($lang['Days']));
Ejemplo n.º 24
0
<?php

//ini_set('display_errors', 'On');
//error_reporting(E_ALL);
// phpinfo();
/* pChart library inclusions */
include "../pChart/class/pData.class.php";
include "../pChart/class/pDraw.class.php";
include "../pChart/class/pImage.class.php";
/* Create the pData object with some random values*/
$MyData = new pData();
/* Import the data from a CSV file */
$MyData->importFromCSV("/var/ram/readings.csv", array("GotHeader" => True, "SkipColumns" => array(0)));
$MyData->setPalette("Temperature", array("R" => 0, "G" => 128, "B" => 0));
$MyData->setPalette("CPU-Temp", array("R" => 128, "G" => 0, "B" => 128));
$MyData->setPalette("Pressure", array("R" => 255, "G" => 0, "B" => 0));
$MyData->setSerieOnAxis("Temperature", 0);
$MyData->setSerieOnAxis("CPU-Temp", 1);
$MyData->setSerieOnAxis("Pressure", 2);
$MyData->setAxisName(0, "Temperature");
$MyData->setAxisName(1, "Temperature");
$MyData->setAxisName(2, "Pressure");
$MyData->setAxisPosition(1, AXIS_POSITION_RIGHT);
/* Get latest value before reversing Series for plotting */
$latest = $MyData->Data['Series']['Pressure']['Data'][0];
/* Reverse series so latest value is on the right */
$MyData->reverseSerie("Temperature");
$MyData->reverseSerie("CPU-Temp");
$MyData->reverseSerie("Pressure");
$earliest = $MyData->Data['Series']['Pressure']['Data'][0];
/* Create the chart*/
Ejemplo n.º 25
0
<?php

/* CAT:Polar and radars */
/* pChart library inclusions */
include "../class/pData.class.php";
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(8, 4, 6, 4, 2, 7), "Score");
$MyData->setSerieDescription("Score", "Application A");
$MyData->setPalette("Score", array("R" => 157, "G" => 196, "B" => 22));
/* Define the absissa serie */
$MyData->addPoints(array("Speed", "Weight", "Cost", "Size", "Ease", "Utility"), "Families");
$MyData->setAbscissa("Families");
/* Create the pChart object */
$myPicture = new pImage(300, 300, $MyData);
$myPicture->drawGradientArea(0, 0, 300, 300, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 240, "EndG" => 240, "EndB" => 240, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 300, 20, DIRECTION_HORIZONTAL, array("StartR" => 30, "StartG" => 30, "StartB" => 30, "EndR" => 100, "EndG" => 100, "EndB" => 100, "Alpha" => 100));
$myPicture->drawLine(0, 20, 300, 20, array("R" => 255, "G" => 255, "B" => 255));
$RectangleSettings = array("R" => 180, "G" => 180, "B" => 180, "Alpha" => 100);
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 299, 299, 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" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
Ejemplo n.º 26
0
            $serieSettings4 = $serieSettingsS;
            $DynVar5[] = round(0.9 * Conv2TF($row_SysDB['TempCore3'] / 1000), 0);
            $DynVarDef5 = "Core 3";
            $serieSettings5 = $serieSettingsS;
            $DynVar6[] = round(0.9 * Conv2TF($row_SysDB['TempCore4'] / 1000), 0);
            $DynVarDef6 = "Core 4";
            $serieSettings6 = $serieSettingsS;
        }
        $DynVarUnits = "degrees F";
        break;
}
$MyData = new pData();
if (isset($DynVar2)) {
    $MyData->addPoints($DynVar2, $DynVarDef2);
    $MyData->setSerieWeight($DynVarDef2, $chWeight / 3);
    $MyData->setPalette($DynVarDef2, $serieSettings2);
}
if (isset($DynVar3)) {
    $MyData->addPoints($DynVar3, $DynVarDef3);
    $MyData->setSerieWeight($DynVarDef3, $chWeight / 3);
    $MyData->setPalette($DynVarDef3, $serieSettings3);
}
if (isset($DynVar4)) {
    $MyData->addPoints($DynVar4, $DynVarDef4);
    $MyData->setSerieWeight($DynVarDef4, $chWeight / 3);
    $MyData->setPalette($DynVarDef4, $serieSettings4);
}
if (isset($DynVar5)) {
    $MyData->addPoints($DynVar5, $DynVarDef5);
    $MyData->setSerieWeight($DynVarDef5, $chWeight / 3);
    $MyData->setPalette($DynVarDef5, $serieSettings5);
Ejemplo n.º 27
0
<?php

/* CAT:Misc */
/* 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(2, 7, 5, 18, 19, 22, 23, 25, 22, 12, 10, 10), "DEFCA");
$MyData->setAxisName(0, "\$ Incomes");
$MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY);
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aou", "Sep", "Oct", "Nov", "Dec"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
$MyData->setPalette("DEFCA", array("R" => 55, "G" => 91, "B" => 127));
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 100));
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 200, "G" => 200, "B" => 200));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(60, 35, "2k9 Average Incomes", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT));
/* Do some cosmetic and draw the chart */
$myPicture->setGraphArea(60, 40, 670, 190);
$myPicture->drawFilledRectangle(60, 40, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("GridR" => 180, "GridG" => 180, "GridB" => 180));
/* Draw a spline chart on top */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawFilledSplineChart();
$myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
Ejemplo n.º 28
0
    }
}
//var_dump($data1);
$MyData = new pData();
$MyData->addPoints($data1, "Probe 1");
$MyData->addPoints($data2, "Probe 2");
$MyData->addPoints($data3, "Probe 3");
//$myPicture->drawScale(array("DrawYLines"=>array(0)));
//$MyData->setSerieTicks("Probe 2",1);
//$MyData->setSerieWeight("Probe 3",1);
$MyData->setAxisName(0, "Temperatures");
$MyData->addPoints($labels, "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setSerieTicks(10);
$MyData->setAbscissa("Labels");
$MyData->setPalette("Probe 1", array("R" => 13, "G" => 35, "B" => 58));
$MyData->setPalette("Probe 2", array("R" => 145, "G" => 0, "B" => 0));
$MyData->setPalette("Probe 3", array("R" => 242, "G" => 143, "B" => 67));
/* Create the pChart object */
$W = 1024;
if (isset($_GET["w"])) {
    $W = $_GET["w"];
}
$myPicture = new pImage($W, 400, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
//$myPicture->drawGraphAreaGradient(132,153,172,50,TARGET_BACKGROUND);
/* Add a border to the picture */
//$myPicture->drawRectangle(0,0,1023,399,array("R"=>0,"G"=>0,"B"=>0));
//$myPicture->drawGradientArea(0,0,1024,400, DIRECTION_HORIZONTAL);
//$myPicture->drawFilledRectangle(0,0,1024,400,array("R"=>47,"G"=>126,"B"=>216,"Surrounding"=>-200,"Alpha"=>80));
             if ($perfor >= 0.6 and $perfor < 0.8) {
                 $string_perfor = $string_perfor . "<div>Bien   <img src=\"graphix/level3.png\" height=\"40\" width=\"40\"></div>";
             } else {
                 $string_perfor = $string_perfor . "<div>Excellent   <img src=\"graphix/level4.png\" height=\"40\" width=\"40\"></div>";
             }
         }
     }
 }
 //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));
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(24, 25, 26, 25, 25), "My Serie 1");
$MyData->addPoints(array(12, 13, 14, 16, 18), "My Serie 2");
$MyData->addPoints(array(80, 76, 73, 71, 33), "My Serie 3");
$MyData->addPoints(array(47, 67, 78, 76, 54), "My Serie 4");
/* Define the series name */
$MyData->setSerieDescription("My Serie 1", "Temperature");
$MyData->setSerieDescription("My Serie 2", "Humidity");
/* Dispatche the series on different axis */
$MyData->setSerieOnAxis("My Serie 1", 1);
$MyData->setSerieOnAxis("My Serie 2", 1);
$MyData->setSerieOnAxis("My Serie 3", 2);
$MyData->setSerieOnAxis("My Serie 4", 2);
/* Set the format of the axis */
$MyData->setAxisDisplay(1, AXIS_FORMAT_DEFAULT);
$MyData->setAxisDisplay(2, AXIS_FORMAT_DEFAULT);
$MyData->setAxisDisplay(1, AXIS_FORMAT_TIME, "H:i");
/* Set the unit of the axis */
$MyData->setAxisUnit(1, "°C");
$MyData->setAxisUnit(2, "%");
/* Set the name of the axis */
$MyData->setAxisName(1, "Temperature");
$MyData->setAxisName(2, "Humidity");
/* Change the color of one serie */
$serieSettings = array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80);
$MyData->setPalette("My Serie 4", $serieSettings);
/* Load a palette file */
$MyData->loadPalette("resources/palette.txt", FALSE);
/* Output the data structure */
print_r($MyData->getData());