Exemplo 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();
}
Exemplo n.º 3
0
 function index()
 {
     $width = 600;
     $height = 230;
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Female");
     $MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Male");
     //$MyData->addPoints(array(2,0,5,18,19,22),"Probe 3");
     $MyData->setSerieTicks("Male", 4);
     $MyData->setAxisName(0, "Number of males, females");
     $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
     $MyData->setSerieDescription("Labels", "Months");
     $MyData->setAbscissa("Labels");
     /* Create the pChart object */
     $myPicture = new pImage($width, $height, $MyData);
     /* Draw the background */
     $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
     $myPicture->drawFilledRectangle(0, 0, $width, $height, $Settings);
     /* Overlay with a gradient */
     $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
     $myPicture->drawGradientArea(0, 0, $width, $height, DIRECTION_VERTICAL, $Settings);
     //$myPicture->drawGradientArea(0,0,700,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>80));
     /* Add a border to the picture */
     $myPicture->drawRectangle(0, 0, $width - 1, $height - 1, array("R" => 0, "G" => 0, "B" => 0));
     /* Write the picture title */
     //$myPicture->setFontProperties(array("FontName"=>pClass."fonts/Silkscreen.ttf","FontSize"=>6));
     //$myPicture->drawText(10,13,"drawBarChart() - draw a bar chart",array("R"=>255,"G"=>255,"B"=>255));
     /* Write the chart title */
     $myPicture->setFontProperties(array("FontName" => pClass . "fonts/Forgotte.ttf", "FontSize" => 11));
     $myPicture->drawText(250, 55, "Average time to find a set", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
     /* Draw the scale and the 1st chart */
     $myPicture->setGraphArea(60, 60, 450, 190);
     $myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
     $myPicture->drawScale(array("DrawSubTicks" => TRUE));
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $myPicture->setFontProperties(array("FontName" => pClass . "fonts/pf_arma_five.ttf", "FontSize" => 10));
     $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 30));
     //$myPicture->drawBarChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Surrounding"=>30));
     $myPicture->setShadow(FALSE);
     /* Draw the scale and the 2nd chart */
     /*
     $myPicture->setGraphArea(500,60,670,190);
     $myPicture->drawFilledRectangle(500,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
     $myPicture->drawScale(array("Pos"=>SCALE_POS_TOPBOTTOM,"DrawSubTicks"=>TRUE));
     $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
     $myPicture->drawBarChart();
     $myPicture->setShadow(FALSE);
     */
     /* Write the chart legend */
     //$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
     $myPicture->drawLegend(500, 105, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
     /* Render the picture (choose the best way) */
     $myPicture->stroke();
 }
 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");
 }
Exemplo n.º 5
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";
    }
}
Exemplo n.º 6
0
 /**
  * Desenha um gráfico de barras
  * @param $title título do graico
  * @param $data matriz contendo as séries de dados
  * @param $xlabels vetor contendo os rótulos do eixo X
  * @param $ylabel  rótulo do eixo Y
  * @param $width largura do gráfico
  * @param $height altura do gráfico
  * @param $outputPath caminho de saída do gráfico
  */
 public function drawBarChart($title, $data, $xlabels, $ylabel, $width, $height, $outputPath)
 {
     // cria o modelo de dados
     $modelo = new pData();
     foreach ($data as $legend => $serie) {
         $newdata = array();
         foreach ($serie as $value) {
             $newdata[$legend][] = $value == NULL ? VOID : $value;
         }
         $modelo->addPoints($newdata[$legend], $legend);
     }
     $modelo->setAxisName(0, $ylabel);
     $modelo->addPoints($xlabels, "Labels");
     $modelo->setAbscissa("Labels");
     // cria o objeto que irá conter a imagem do gráfico
     $imagem = new pImage($width, $height, $modelo);
     // desliga a suavização de linhas
     $imagem->Antialias = FALSE;
     // 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/pf_arma_five.ttf", "FontSize" => 6));
     // define a área do gráfico
     $imagem->setGraphArea(60, 40, $width - 50, $height - 30);
     // define a escala do gráfico
     $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "CycleBackground" => TRUE);
     $imagem->drawScale($scaleSettings);
     // desenha a legenda do gráfico
     $imagem->drawLegend(60, $height - 13, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     // cria uma sombra nas barras do gráfico
     $imagem->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     // desenha o gráfico de barras
     $imagem->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Surrounding" => 200));
     // grava o gráfico em um arquivo
     $imagem->render($outputPath);
 }
Exemplo n.º 7
0
// print_r($csvdata_point);
// echo "</pre>\r\n";
// // // -----------------
//=============================================================================================
// $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 */
Exemplo n.º 8
0
     $sth = $db->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
     $sth->execute(array(':consult_date' => $consult_date . "%"));
     $datas = $sth->fetchAll();
 }
 if (count($datas) > 0) {
     $room_value = array();
     $room_name = array();
     $nbr_room = count($datas);
     foreach ($datas as $data) {
         $room_value[] = $data['room_usable_power'] - $data['room_used_power'];
         $room_name[] = $data['room_name'];
     }
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->addPoints($room_value, "Capacite electrique disponible (kW)");
     $MyData->setAxisName(0, "Capacite electrique disponible (kW)");
     $MyData->addPoints($room_name, "Salles");
     $MyData->setAbscissa("Salles");
     /* Create the pChart object */
     $myPicture = new pImage(65 * $nbr_room + 65, 330, $MyData);
     // Taille dynamique de l'image en fonction du nombre de réponse SQL
     /* Draw the background */
     $Settings = array("R" => 39, "G" => 43, "B" => 48, "Dash" => 1, "DashR" => 122, "DashG" => 130, "DashB" => 136);
     $myPicture->drawFilledRectangle(0, 0, 65 * $nbr_room + 65, 330, $Settings);
     /* Overlay with a gradient */
     $Settings = array("StartR" => 39, "StartG" => 43, "StartB" => 48, "EndR" => 122, "EndG" => 130, "EndB" => 136, "Alpha" => 50);
     $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 330, DIRECTION_VERTICAL, $Settings);
     $myPicture->drawGradientArea(0, 0, 65 * $nbr_room + 65, 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, 65 * $nbr_room + 64, 329, array("R" => 0, "G" => 0, "B" => 0));
     /* Write the chart title */
Exemplo n.º 9
0
 protected function buildTripChartData($options)
 {
     $data = parent::buildTripChartData($options);
     if (!$data) {
         return $data;
     }
     $this->setOption('title', $data['title']);
     $myData = new pData();
     // x-axis
     $x_id = $data['x']['id'];
     $myData->addPoints($data['x']['values'], $x_id);
     $myData->setSerieDescription($x_id, $data['x']['description']);
     $myData->setAbscissa($x_id);
     // Y-axis
     $myData->setAxisName(0, $data['y']['description']);
     foreach ($data['y']['series'] as $key => $serie) {
         $values = $this->filterNulls($serie['values']);
         if (!$values) {
             continue;
         }
         $y_id = $serie['id'];
         $myData->addPoints($values, $y_id);
         $myData->setSerieDescription($y_id, $serie['label']);
     }
     return $myData;
 }
<?php

/* 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));
 function func_bargraphGenerate($student_id, $time, $type, $basepath, $success, $r = "", $g = "", $b = "", $name)
 {
     $bookIdResult = $this->func_getBookId('1,2');
     $bookID = array();
     foreach ($bookIdResult as $book) {
         $bookID[] = $book['book_id'];
     }
     $getActivityTypeIdResult = $this->func_getActivityTypeId('WORD HUNT');
     foreach ($getActivityTypeIdResult as $activityTypeId) {
         $activityTypeId = $activityTypeId['activity_type_id'];
     }
     $getActivityIdResult = $this->func_getActivityId($bookID, $activityTypeId);
     $actId = array();
     foreach ($getActivityIdResult as $activityId) {
         $actId[] = $activityId['activity_id'];
     }
     $actNewId = implode(',', $actId);
     $k = 0;
     $j = 0;
     for ($i = 0; $i < 5; $i = $i + 1) {
         $date[$k] = date("Y-m-d", strtotime("-{$i} day"));
         $dateRec[] = date('M d', strtotime("-{$i} day"));
         $k = $k + 1;
     }
     $successaccessmentResult = $this->fun_getAssmentResult($student_id, $actNewId, '', $date, "word_hunt", $success);
     $totalaccessmentResult = $this->fun_getAssmentResult($student_id, $actNewId, '', $date, "word_hunt", '0,1');
     for ($i = 0; $i < 5; $i = $i + 1) {
         $j = $i;
         if ($totalaccessmentResult['0']['count_' . $j] == "0") {
             $totalaccessmentResult['0']['count_' . $j] = 1;
         }
         $per[$i] = $successaccessmentResult['0']['count_' . $j] / $totalaccessmentResult['0']['count_' . $j] * 100;
     }
     $MyData = new pData();
     $MyData->addPoints($per, "Server A");
     $MyData->setAxisName(0, "Percentage");
     $MyData->addPoints(array_reverse($dateRec), "Months");
     $MyData->setSerieDescription("Months", "Month");
     $MyData->setAbscissa("Months");
     $myPicture = new pImage(350, 230, $MyData);
     /* Turn of Antialiasing */
     $myPicture->Antialias = FALSE;
     /* Add a border to the picture */
     $myPicture->drawGradientArea(0, 0, 400, 230, DIRECTION_VERTICAL, array("StartR" => 255, "StartG" => 255, "StartB" => 255, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 100));
     // $myPicture->drawRectangle(0,0,400,229,array("R"=>0,"G"=>0,"B"=>0));
     /* Set the default font */
     $myPicture->setFontProperties(array("FontName" => $basepath . "Silkscreen.ttf", "FontSize" => 6));
     /* Define the chart area */
     $myPicture->setGraphArea(60, 40, 350, 200);
     /* Draw the scale */
     $scaleSettings = array("GridR" => 300, "GridG" => 300, "GridB" => 200, "DrawSubTicks" => FALSE, "CycleBackground" => FALSE, "Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_MANUAL, "LabelingMethod" => LABELING_ALL);
     $myPicture->drawScale($scaleSettings);
     /* 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, "Mode" => 0);
     $myPicture->drawBarChart($settings, $r, $g, $b);
     /* Render the picture (choose the best way) */
     $picname = $student_id . '_' . $name . '_' . $time . '.png';
     $this->fun_getImageLog($student_id, $picname, $type, $time, $name);
     $myPicture->render("uploads/graph/" . $picname);
 }
<?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();
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 */
Exemplo n.º 13
0
<?php

/* CAT:Scaling */
/* 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(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));
Exemplo n.º 14
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));
/* CAT:Scatter chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
include "../class/pScatter.class.php";
/* Create the pData object */
$myData = new pData();
/* Create the X axis and the binded series */
for ($i = 0; $i <= 360; $i = $i + 10) {
    $myData->addPoints(cos(deg2rad($i)) * 20, "Probe 1");
}
for ($i = 0; $i <= 360; $i = $i + 10) {
    $myData->addPoints(sin(deg2rad($i)) * 20, "Probe 2");
}
$myData->setAxisName(0, "Index");
$myData->setAxisXY(0, AXIS_X);
$myData->setAxisPosition(0, AXIS_POSITION_BOTTOM);
/* Create the Y axis and the binded series */
for ($i = 0; $i <= 360; $i = $i + 10) {
    $myData->addPoints($i, "Probe 3");
}
$myData->setSerieOnAxis("Probe 3", 1);
$myData->setAxisName(1, "Degree");
$myData->setAxisXY(1, AXIS_Y);
$myData->setAxisUnit(1, "°");
$myData->setAxisPosition(1, AXIS_POSITION_RIGHT);
/* Create the 1st scatter chart binding */
$myData->setScatterSerie("Probe 1", "Probe 3", 0);
$myData->setScatterSerieDescription(0, "This year");
$myData->setScatterSerieColor(0, array("R" => 0, "G" => 0, "B" => 0));
Exemplo n.º 16
0
 public function showAreaChart($data, $y_axis, $type)
 {
     global $tmpchartfolder, $pchartfolder;
     if ($pchartfolder == "") {
         $pchartfolder = "./pchart2";
     }
     //echo "$pchartfolder/class/pData.class.php";die;
     include_once "{$pchartfolder}/class/pData.class.php";
     include_once "{$pchartfolder}/class/pDraw.class.php";
     include_once "{$pchartfolder}/class/pImage.class.php";
     if ($tmpchartfolder == "") {
         $tmpchartfolder = $pchartfolder . "/cache";
     }
     $w = $data['width'] + 0;
     $h = $data['height'] + 0;
     $legendpos = $data['chartLegendPos'];
     //$legendpos="Right";
     $seriesexp = $data['seriesexp'];
     $catexp = $data['catexp'];
     $valueexp = $data['valueexp'];
     $labelexp = $data['labelexp'];
     $ylabel = $data['ylabel'] . '';
     $xlabel = $data['xlabel'] . '';
     $ylabel = str_replace(array('"', "'"), '', $ylabel);
     $xlabel = str_replace(array('"', "'"), '', $xlabel);
     $scalesetting = $data['scalesetting'];
     $x = $data['x'];
     $y1 = $data['y'];
     $legendx = 0;
     $legendy = 0;
     $titlefontname = $data['titlefontname'] . '';
     $titlefontsize = $data['titlefontsize'] + 0;
     $DataSet = new pData();
     foreach ($catexp as $a => $b) {
         $catexp1[] = str_replace(array('"', "'"), '', $b);
     }
     $n = 0;
     $DataSet->addPoints($catexp1, 'S00');
     $DataSet->setSerieDescription('S00', 'asdasd');
     //$DataSet->AddSerie('S0');
     //$DataSet->SetSerieName('S0',"Cat");
     $DataSet->setAbscissa('S00');
     $n = $n + 1;
     $ds = trim($data['dataset']);
     if ($ds != "") {
         $sql = $this->subdataset[$ds];
         $param = $data['param'];
         foreach ($param as $p) {
             foreach ($p as $tag => $value) {
                 $sql = str_replace('$P{' . $tag . '}', $value, $sql);
             }
         }
         $sql = $this->changeSubDataSetSql($sql);
     } else {
         $sql = $this->sql;
     }
     $result = @mysql_query($sql);
     //query from db
     $chartdata = array();
     $i = 0;
     //echo $sql."<br/><br/>";
     $seriesname = array();
     while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
         $j = 0;
         foreach ($row as $key => $value) {
             //$chartdata[$j][$i]=$value;
             if ($value == '') {
                 $value = 0;
             }
             if ($key == str_replace(array('$F{', '}'), '', $seriesexp[0])) {
                 array_push($seriesname, $value);
             } else {
                 foreach ($valueexp as $v => $y) {
                     if ($key == str_replace(array('$F{', '}'), '', $y)) {
                         $chartdata[$i][$j] = (int) $value;
                         $j++;
                     }
                 }
             }
         }
         $i++;
     }
     if ($i == 0) {
         return 0;
     }
     foreach ($seriesname as $s => $v) {
         $DataSet->addPoints($chartdata[$s], "{$v}");
         //  $DataSet->AddSerie("$v");
     }
     $DataSet->setAxisName(0, $ylabel);
     $this->chart = new pImage($w, $h, $DataSet);
     //$c = new pChart($w,$h);
     //$this->setChartColor();
     $this->chart->drawRectangle(1, 1, $w - 2, $h - 2);
     $legendfontsize = 8;
     $this->chart->setFontProperties(array('FontName' => "{$pchartfolder}/fonts/calibri.ttf", 'FontSize' => $legendfontsize));
     $Title = $data['charttitle']['text'];
     switch ($legendpos) {
         case "Top":
             $legendmode = array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
             $lgsize = $this->chart->getLegendSize($legendmode);
             $diffx = $w - $lgsize['Width'];
             if ($diffx > 0) {
                 $legendx = $diffx / 2;
             } else {
                 $legendx = 0;
             }
             //$legendy=$h-$lgsize['Height']+$legendfontsize;
             if ($legendy < 0) {
                 $legendy = 0;
             }
             if ($Title == '') {
                 $graphareay1 = 5;
                 $legendy = $graphareay1 + 5;
                 $graphareax1 = 40;
                 $graphareax2 = $w - 10;
                 $graphareay2 = $h - $legendfontsize - 15;
             } else {
                 $graphareay1 = 30;
                 $legendy = $graphareay1 + 5;
                 $graphareax1 = 40;
                 $graphareax2 = $w - 10;
                 $graphareay2 = $h - $legendfontsize - 15;
             }
             break;
         case "Left":
             $legendmode = array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL);
             $lgsize = $this->chart->getLegendSize($legendmode);
             $legendx = $lgsize['Width'];
             if ($Title == '') {
                 $legendy = 10;
                 $graphareay1 = 5;
                 $graphareax1 = $legendx + 5;
                 $graphareax2 = $w - 5;
                 $graphareay2 = $h - 20;
             } else {
                 $legendy = 30;
                 $graphareay1 = 40;
                 $graphareax1 = $legendx + 5;
                 $graphareax2 = $w - 5;
                 $graphareay2 = $h - 20;
             }
             break;
         case "Right":
             $legendmode = array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL);
             $lgsize = $this->chart->getLegendSize($legendmode);
             $legendx = $w - $lgsize['Width'];
             if ($Title == '') {
                 $legendy = 10;
                 $graphareay1 = 5;
                 $graphareax1 = 40;
                 $graphareax2 = $legendx - 5;
                 $graphareay2 = $h - 20;
             } else {
                 $legendy = 30;
                 $graphareay1 = 30;
                 $graphareax1 = 40;
                 $graphareax2 = $legendx - 5;
                 $graphareay2 = $h - 20;
             }
             break;
         case "Bottom":
             $legendmode = array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
             $lgsize = $this->chart->getLegendSize($legendmode);
             $diffx = $w - $lgsize['Width'];
             if ($diffx > 0) {
                 $legendx = $diffx / 2;
             } else {
                 $legendx = 0;
             }
             $legendy = $h - $lgsize['Height'] + $legendfontsize;
             if ($legendy < 0) {
                 $legendy = 0;
             }
             if ($Title == '') {
                 $graphareay1 = 5;
                 $graphareax1 = 40;
                 $graphareax2 = $w - 10;
                 $graphareay2 = $legendy - $legendfontsize - 15;
             } else {
                 $graphareay1 = 30;
                 $graphareax1 = 40;
                 $graphareax2 = $w - 10;
                 $graphareay2 = $legendy - $legendfontsize - 15;
             }
             break;
         default:
             $legendmode = array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
             $lgsize = $this->chart->getLegendSize($legendmode);
             $diffx = $w - $lgsize['Width'];
             if ($diffx > 0) {
                 $legendx = $diffx / 2;
             } else {
                 $legendx = 0;
             }
             $legendy = $h - $lgsize['Height'] + $legendfontsize;
             if ($legendy < 0) {
                 $legendy = 0;
             }
             if ($Title == '') {
                 $graphareay1 = 5;
                 $graphareax1 = 40;
                 $graphareax2 = $w - 10;
                 $graphareay2 = $legendy - $legendfontsize - 15;
             } else {
                 $graphareay1 = 30;
                 $graphareax1 = 40;
                 $graphareax2 = $w - 10;
                 $graphareay2 = $legendy - $legendfontsize - 15;
             }
             break;
     }
     //echo "$graphareax1,$graphareay1,$graphareax2,$graphareay2";die;
     $this->chart->setGraphArea($graphareax1, $graphareay1, $graphareax2, $graphareay2);
     $this->chart->setFontProperties(array('FontName' => "{$pchartfolder}/fonts/calibri.ttf", 'FontSize' => 8));
     //if($type=='StackedBarChart')
     //  $scalesetting=array("Floating"=>TRUE,"GridR"=>200, "GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE, "CycleBackground"=>TRUE,
     //    "DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL_START0,"DrawArrows"=>TRUE,"ArrowSize"=>6);
     //else
     $ScaleSpacing = 5;
     $scalesetting = $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0, 'ScaleSpacing' => $ScaleSpacing);
     $this->chart->drawScale($scalesetting);
     $this->chart->drawLegend($legendx, $legendy, $legendmode);
     $Title = str_replace(array('"', "'"), '', $data['charttitle']['text']);
     if ($Title != '') {
         $titlefontsize + 0;
         if ($titlefontsize == 0) {
             $titlefontsize = 8;
         }
         if ($titlefontname == '') {
             $titlefontname = 'calibri';
         }
         $titlefontname = strtolower($titlefontname);
         $textsetting = array('DrawBox' => FALSE, 'FontSize' => $titlefontsize, 'FontName' => "{$pchartfolder}/fonts/" . $titlefontname . ".ttf", 'align' => TEXT_ALIGN_TOPMIDDLE);
         $this->chart->drawText($w / 3, $titlefontsize + 10, $Title, $textsetting);
     }
     $this->chart->setFontProperties(array('FontName' => "{$pchartfolder}/fonts/calibri.ttf", 'FontSize' => 7));
     $this->chart->drawStackedAreaChart(array("Surrounding" => 60));
     $randomchartno = rand();
     $photofile = "{$tmpchartfolder}/chart{$randomchartno}.png";
     $this->chart->Render($photofile);
     if (file_exists($photofile)) {
         $this->pdf->Image($photofile, $x + $this->arrayPageSetting["leftMargin"], $y_axis + $y1, $w, $h, "PNG");
         unlink($photofile);
     }
 }
/* CAT:Bubble chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
include "../class/pBubble.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->loadPalette("../palettes/summer.color", TRUE);
$MyData->addPoints(array(34, 55, 15, 62, 38, 42), "Probe1");
$MyData->addPoints(array(5, 10, 8, 9, 15, 10), "Probe1Weight");
$MyData->addPoints(array(5, 10, -5, -1, 0, -10), "Probe2");
$MyData->addPoints(array(6, 10, 14, 10, 14, 6), "Probe2Weight");
$MyData->setSerieDescription("Probe1", "This year");
$MyData->setSerieDescription("Probe2", "Last year");
$MyData->setAxisName(0, "Current stock");
$MyData->addPoints(array("Apple", "Banana", "Orange", "Lemon", "Peach", "Strawberry"), "Product");
$MyData->setAbscissa("Product");
/* 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));
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$BaseTs = mktime(0, 0, 0, 12, 25, 2011);
$LastIn = 0;
$LastOut = 0;
for ($i = 0; $i <= 1440; $i++) {
    $LastIn = abs($LastIn + rand(-1000, +1000));
    $LastOut = abs($LastOut + rand(-1000, +1000));
    $MyData->addPoints($LastIn, "Inbound");
    $MyData->addPoints($LastOut, "Outbound");
    $MyData->addPoints($BaseTs + $i * 60, "TimeStamp");
}
$MyData->setAxisName(0, "Bandwidth");
$MyData->setAxisDisplay(0, AXIS_FORMAT_TRAFFIC);
$MyData->setSerieDescription("TimeStamp", "time");
$MyData->setAbscissa("TimeStamp");
$MyData->setXAxisDisplay(AXIS_FORMAT_TIME, "H:00");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw a background */
$Settings = array("R" => 90, "G" => 90, "B" => 90, "Dash" => 1, "DashR" => 120, "DashG" => 120, "DashB" => 120);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, $Settings);
Exemplo n.º 19
0
/**
 * Helper method to draw bar graph
 * parameters have same meaning as displayGraph's parameters
 */
function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $graphOptions)
{
    // getting data from DB
    if (is_int($frid) && $frid > 0) {
        $dbData = getData($frid, $fid);
    } else {
        $dbData = getData("", $fid);
    }
    foreach ($dbData as $entry) {
        // mayor - OR array of mayors if there's more than one in the dataset, depending on the one-to-may in a relationship
        $dataRawValue = display($entry, $dataElement);
        // city_name;
        $labelRawValue = display($entry, $labelElement);
        if (!is_array($dataRawValue) && $dataRawValue) {
            $dataRawValue = array($dataRawValue);
        }
        if (!is_array($labelRawValue)) {
            $labelRawValue = array($labelRawValue);
        }
        foreach ($labelRawValue as $thisLabelValue) {
            if ($dataPoints[$thisLabelValue]) {
                $dataPoints[$thisLabelValue] = array_merge($dataPoints[$thisLabelValue], $dataRawValue);
            } else {
                $dataPoints[$thisLabelValue] = $dataRawValue;
            }
        }
    }
    // Oct 29 Update for column heading for graphs:
    $elementHandler = xoops_getmodulehandler('elements', 'formulize');
    $elementObject = $elementHandler->get($labelElement);
    $labelElement = $elementObject->getVar('ele_colhead') ? $elementObject->getVar('ele_colhead') : printSmart($elementObject->getVar('ele_caption'));
    $elementObject = $elementHandler->get($dataElement);
    $dataElement = $elementObject->getVar('ele_colhead') ? $elementObject->getVar('ele_colhead') : printSmart($elementObject->getVar('ele_caption'));
    // end of Update
    switch ($operation) {
        case "count":
            // count the values in each label of the array
            foreach (array_keys($dataPoints) as $key) {
                if (!empty($dataPoints[$key])) {
                    $dataPoints[$key] = count($dataPoints[$key]);
                } else {
                    $dataPoints[$key] = 0;
                }
            }
            if ($labelElement == $dataElement) {
                $dataElement = "count of " . $labelElement;
            } else {
                $dataElement = "count of " . $dataElement;
            }
            break;
        case "sum":
        case "display":
            // TODO: Check this!
            foreach ($dataPoints as $thisLabel => $theseValues) {
                $dataPoints[$thisLabel] = array_sum($theseValues);
            }
            $dataElement = ($operation == "display" ? "number of " : "sum of ") . $dataElement;
            break;
        case "count-unique":
            foreach ($dataPoints as $thisLabel => $theseValues) {
                $dataPoints[$thisLabel] = count(array_unique($theseValues));
            }
            if ($dataElement == $labelElement) {
                $dataElement = "count of unique " . $labelElement;
            } else {
                $dataElement = "count of unique " . $dataElement;
            }
            break;
        default:
            echo "Sorry, the operation \"{$operation}\" for Bar graph is not supported at the moment!";
            return;
    }
    // print("dataElement: ".$dataElement." ");
    // print("labelElement: ".$labelElement." ");
    // process the graph options
    // these defaults will be used, unless overwritten by values from the $graphOptions array
    $sizeMultiplier = sizeof(array_keys($dataPoints));
    $BAR_THICKNESS = 40;
    $IMAGE_WIDTH = 600;
    $IMAGE_DEFAULT_WIDTH = $IMAGE_WIDTH;
    if ($sizeMultiplier > 1) {
        $IMAGE_HEIGHT = $BAR_THICKNESS * $sizeMultiplier / 0.5;
    } else {
        $IMAGE_HEIGHT = $BAR_THICKNESS * 4;
    }
    $IMAGE_DEFAULT_HEIGHT = $IMAGE_HEIGHT;
    $IMAGE_ORIENTATION = "vertical";
    $BACKGROUND_R = 141;
    $BACKGROUND_G = 189;
    $BACKGROUND_B = 225;
    $BARCOLOR_R = 143;
    $BARCOLOR_G = 190;
    $BARCOLOR_B = 88;
    if (sizeof($graphOptions) > 0) {
        foreach ($graphOptions as $graphoption => $value) {
            switch ($graphoption) {
                case "width":
                    $IMAGE_WIDTH = $value;
                    break;
                case "height":
                    $IMAGE_HEIGHT = $value;
                    break;
                case "orientation":
                    $IMAGE_ORIENTATION = $value;
                    if ($IMAGE_ORIENTATION == "horizontal") {
                        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
                            $IMAGE_HEIGHT = 500;
                        } else {
                            if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
                                $IMAGE_WIDTH = $BAR_THICKNESS * $sizeMultiplier / 0.5;
                            }
                        }
                    }
                    break;
                case "backgroundcolor":
                    // print_r($value);
                    foreach ($value as $RGB => $colorvalue) {
                        switch ($RGB) {
                            case "R":
                                $BACKGROUND_R = $colorvalue;
                                break;
                            case "G":
                                $BACKGROUND_G = $colorvalue;
                                break;
                            case "B":
                                $BACKGROUND_B = $colorvalue;
                                break;
                            default:
                                echo "Please follow the correct format of backgroundcolor.";
                                break;
                        }
                    }
                    break;
                case "barcolor":
                    // print_r($value);
                    foreach ($value as $RGB => $colorvalue) {
                        switch ($RGB) {
                            case "R":
                                $BARCOLOR_R = $colorvalue;
                                break;
                            case "G":
                                $BARCOLOR_G = $colorvalue;
                                break;
                            case "B":
                                $BARCOLOR_B = $colorvalue;
                                break;
                            default:
                                echo "Please follow the correct format of backgroundcolor.";
                                break;
                        }
                    }
                    break;
                default:
                    echo "Sorry, the graph option \"{$graphoption}\" for Bar graph is not supported at the moment!<br>";
                    break;
            }
        }
    }
    // reset width/height of the image in case the label is too long
    if (strlen($labelElement) * 4.5 >= $IMAGE_HEIGHT and $IMAGE_ORIENTATION == "vertical") {
        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
            $IMAGE_HEIGHT = strlen($labelElement) * 5;
        } else {
            $labelElement = substr($labelElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($dataElement) * 4.5 >= $IMAGE_HEIGHT and $IMAGE_ORIENTATION == "horizontal") {
        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
            $IMAGE_HEIGHT = strlen($dataElement) * 5;
        } else {
            $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($labelElement) * 4.5 >= $IMAGE_WIDTH and $IMAGE_ORIENTATION == "horizontal") {
        if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
            $IMAGE_WIDTH = strlen($labelElement) * 5;
        } else {
            $labelElement = substr($labelElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($dataElement) * 4.5 >= $IMAGE_WIDTH and $IMAGE_ORIENTATION == "vertical") {
        if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
            $IMAGE_WIDTH = strlen($dataElement) * 5;
        } else {
            $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    }
    // Code straightly copied from pChart documentation to draw the graph
    $myData = new pData();
    $myData->addPoints(array_values($dataPoints), $dataElement);
    $myData->setAxisName(0, $dataElement);
    $myData->addPoints(array_keys($dataPoints), $labelElement);
    $myData->setSerieDescription($labelElement, $labelElement);
    $myData->setAbscissa($labelElement);
    $myData->setAbscissaName($labelElement);
    // $myData -> setAxisDisplay(0, AXIS_FORMAT_CUSTOM, "YAxisFormat");
    /* Create the pChart object */
    $myPicture = new pImage($IMAGE_WIDTH, $IMAGE_HEIGHT, $myData);
    $myPicture->drawGradientArea(0, 0, $IMAGE_WIDTH, $IMAGE_HEIGHT, DIRECTION_VERTICAL, array("StartR" => $BACKGROUND_R, "StartG" => $BACKGROUND_G, "StartB" => $BACKGROUND_B, "EndR" => $BACKGROUND_R, "EndG" => $BACKGROUND_G, "EndB" => $BACKGROUND_B, "Alpha" => 100));
    $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 30));
    $myPicture->setFontProperties(array("FontName" => "modules/formulize/libraries/pChart/fonts/arial.ttf", "FontSize" => 8));
    $paddingtoLeft = $IMAGE_WIDTH * 0.15;
    $paddingtoTop = $IMAGE_HEIGHT * 0.2;
    if ($paddingtoTop > 50) {
        $paddingtoTop = 50;
    }
    /* Draw the chart scale */
    $myPicture->setGraphArea($paddingtoLeft, $paddingtoTop, $IMAGE_WIDTH * 0.9, $IMAGE_HEIGHT * 0.88);
    if ($IMAGE_ORIENTATION == "vertical") {
        $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50));
    } else {
        $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50));
    }
    /* Turn on shadow computing */
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    $Palette = array("0" => array("R" => $BARCOLOR_R, "G" => $BARCOLOR_G, "B" => $BARCOLOR_B, "Alpha" => 100));
    for ($i = 1; $i < $sizeMultiplier; $i++) {
        $Palette[$i] = array("R" => $BARCOLOR_R, "G" => $BARCOLOR_G, "B" => $BARCOLOR_B, "Alpha" => 100);
    }
    // print_r($Palette);
    $myPicture->drawBarChart(array("OverrideColors" => $Palette));
    /* Draw the chart */
    $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette));
    renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $operation, $graphOptions);
    return;
}
Exemplo n.º 20
0
     $myData->addPoints($st, "Probe 3");
     $ysquare = pow($st, 2);
     $sumy = $sumy + $st;
     $sumysquare = $sumysquare + $ysquare;
     $xy = $atp * $st;
     $sumxy = $sumxy + $xy;
 }
 // calculate pearson
 $numerator = $num * $sumxy - $sumx * $sumy;
 $denominator = sqrt(($num * $sumxsquare - pow($sumx, 2)) * ($num * $sumysquare - pow($sumy, 2)));
 if ($denominator == 0) {
     $pearson2 = 0;
 } else {
     $pearson2 = $numerator / $denominator;
 }
 $myData->setAxisName(0, "{$xaxis}");
 $myData->setAxisXY(0, AXIS_X);
 $myData->setAxisPosition(0, AXIS_POSITION_TOP);
 $myData->setSerieOnAxis("Probe 3", 1);
 $myData->setAxisName(1, "{$yaxis}");
 $myData->setAxisXY(1, AXIS_Y);
 $myData->setAxisPosition(1, AXIS_POSITION_LEFT);
 /* Create the 1st scatter chart binding */
 $myData->setScatterSerie("Probe 1", "Probe 3", 0);
 // $myData->setScatterSerieDescription(0,"$extype");
 $myData->setScatterSerieDescription(0, "3rd Quartile");
 $myData->setScatterSerieColor(0, array("R" => 0, "G" => 0, "B" => 0));
 /* Create the pChart object */
 $myPicture = new pImage(600, 600, $myData);
 /* Draw the background */
 $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
Exemplo n.º 21
0
    $myData->setSerieDescription($key, $key);
    $myData->setSerieOnAxis($key, 0);
}
//$myData->addPoints(array(28,-19,18,4,-2,-31,17,48),"Serie1");
//$myData->setSerieDescription("Serie1","Serie 1");
//$myData->setSerieOnAxis("Serie1",0);
//
//$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") {
Exemplo n.º 22
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, VOID, 12, 10, 15, 8, 5, 6, 9), "Help Desk");
$MyData->setAxisName(0, "Incidents");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jui", "Aou", "Sep", "Oct", "Nov", "Dec"), "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" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 20));
$myPicture->drawGradientArea(0, 0, 60, 230, DIRECTION_HORIZONTAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
/* Do some cosmetics */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawLine(60, 0, 60, 230, array("R" => 70, "G" => 70, "B" => 70));
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(35, 115, "Recorded cases", array("R" => 255, "G" => 255, "B" => 255, "FontSize" => 20, "Angle" => 90, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw a spline chart */
$myPicture->setGraphArea(100, 30, 680, 190);
$myPicture->drawFilledRectangle(100, 30, 680, 190, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 20));
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawScale(array("AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE));
$myPicture->drawSplineChart();
<?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));
<?php

/* CAT:Bar Chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(13251, 4118, 3087, 1460, 1248, 156, 26, 9, 8), "Hits");
$MyData->setAxisName(0, "Hits");
$MyData->addPoints(array("Firefox", "Chrome", "Internet Explorer", "Opera", "Safari", "Mozilla", "SeaMonkey", "Camino", "Lunascape"), "Browsers");
$MyData->setSerieDescription("Browsers", "Browsers");
$MyData->setAbscissa("Browsers");
$MyData->setAbscissaName("Browsers");
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC, 1);
/* Create the pChart object */
$myPicture = new pImage(500, 500, $MyData);
$myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the chart scale */
$myPicture->setGraphArea(100, 30, 480, 480);
$myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM));
//
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30));
/* Write the legend */
$myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
Exemplo n.º 25
0
         $joins[] = $row['PlayersJoinedServer'];
         $leaves[] = $row['PlayersLeftServer'];
         $i++;
     }
 }
 $myData = new pData();
 $myData->addPoints($joins, "Serie1");
 $myData->setSerieDescription("Serie1", "Joins");
 $myData->setSerieOnAxis("Serie1", 0);
 $myData->addPoints($leaves, "Serie2");
 $myData->setSerieDescription("Serie2", "Leaves");
 $myData->setSerieOnAxis("Serie2", 0);
 $myData->addPoints($rounds, "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, "Joins and leaves of this server in last " . $limit . " rounds.", $TextSettings);
 } else {
     $myPicture->drawText(297, 18, "Joins and leaves of these servers in last " . $limit . " rounds.", $TextSettings);
 }
 $myPicture->setShadow(FALSE);
 $myPicture->setGraphArea(50, 50, 576, 270);
 $myPicture->setFontProperties(array("R" => 150, "G" => 150, "B" => 150, "FontName" => "../pchart/fonts/pf_arma_five.ttf", "FontSize" => 6));
 $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 150, "GridG" => 150, "GridB" => 150, "GridAlpha" => 50, "TickR" => 150, "TickG" => 150, "TickB" => 150, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 0, "DrawSubTicks" => 1, "SubTickR" => 150, "SubTickG" => 150, "SubTickB" => 150, "SubTickAlpha" => 50, "DrawYLines" => NONE, "AxisR" => 150, "AxisG" => 150, "AxisB" => 150);
 $myPicture->drawScale($Settings);
Exemplo n.º 26
0
 public function createCharts($lenght, $width = 1000, $height = 400, $statisticsUncategorized, $params, $options)
 {
     //print_r($params);
     //print_r($options);
     $year = date('Y');
     $month = date('m');
     $y = date('Y', strtotime('-' . ($lenght - 1) . ' month'));
     $m = date('m', strtotime('-' . ($lenght - 1) . ' month'));
     $user = Zend_Registry::get('User');
     $invoicesDb = new Sales_Model_DbTable_Invoice();
     $creditnotesDb = new Sales_Model_DbTable_Creditnote();
     $turnover = array();
     $turnoverCategories = array();
     while ($y <= $year) {
         while ($m) {
             if ($y < $year || $m <= $month) {
                 //Get invoices
                 $ym = str_pad($m, 2, '0', STR_PAD_LEFT);
                 $query = 'i.state = 105';
                 $query .= " AND (invoicedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')";
                 $query .= ' AND i.clientid = ' . $user['clientid'];
                 $query .= ' AND c.clientid = ' . $user['clientid'];
                 if ($params['catid']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c');
                 }
                 if ($params['country']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i');
                 }
                 $invoices = $invoicesDb->fetchAll($invoicesDb->select()->from(array('i' => 'invoice'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false));
                 //Get credit notes
                 $ym = str_pad($m, 2, '0', STR_PAD_LEFT);
                 $query = 'i.state = 105';
                 $query .= " AND (creditnotedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')";
                 $query .= ' AND i.clientid = ' . $user['clientid'];
                 $query .= ' AND c.clientid = ' . $user['clientid'];
                 if ($params['catid']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c');
                 }
                 if ($params['country']) {
                     $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i');
                 }
                 $creditnotes = $creditnotesDb->fetchAll($creditnotesDb->select()->from(array('i' => 'creditnote'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false));
                 $turnover[$y . $ym] = 0;
                 $turnoverCategories[0][$y . $ym] = 0;
                 //Calculate invoices
                 foreach ($invoices as $invoice) {
                     $turnover[$y . $ym] += $invoice->subtotal;
                     if (isset($turnoverCategories[$invoice->catid][$y . $ym])) {
                         $turnoverCategories[$invoice->catid][$y . $ym] += $invoice->subtotal;
                     } else {
                         $turnoverCategories[$invoice->catid][$y . $ym] = $invoice->subtotal;
                     }
                 }
                 //Calculate credit notes
                 foreach ($creditnotes as $creditnote) {
                     $turnover[$y . $ym] -= $creditnote->subtotal;
                     if (isset($turnoverCategories[$creditnote->catid][$y . $ym])) {
                         $turnoverCategories[$creditnote->catid][$y . $ym] += $creditnote->subtotal;
                     } else {
                         $turnoverCategories[$creditnote->catid][$y . $ym] = $creditnote->subtotal;
                     }
                 }
                 //Calculate categories
                 foreach ($options['categories'] as $id => $category) {
                     if (isset($turnoverCategories[$id][$y . $ym])) {
                         $turnoverCategories[$id][$y . $ym] = round($turnoverCategories[$id][$y . $ym]);
                     } else {
                         $turnoverCategories[$id][$y . $ym] = 0;
                     }
                 }
                 $turnover[$y . $ym] = round($turnover[$y . $ym]);
                 $turnoverCategories[0][$y . $ym] = round($turnoverCategories[0][$y . $ym]);
                 $dataDb = 'total:' . $turnover[$y . $ym] . ';';
                 foreach ($turnoverCategories as $key => $value) {
                     if (isset($value[$y . $ym])) {
                         $dataDb .= $key . ':' . $value[$y . $ym] . ';';
                     }
                 }
                 //$archiveDb->addArchive($y.$ym, $dataDb, $user['clientid']);
                 $months[$y . $ym] = $y . '/' . $ym;
             }
             ++$m;
             if ($m > 12) {
                 $m = 0;
             }
         }
         ++$y;
         $m = 1;
     }
     //Merge subcategories to main categories
     foreach ($turnoverCategories as $id => $values) {
         if (isset($options['categories'][$id]['childs']) && $id != $params['catid']) {
             foreach ($options['categories'][$id]['childs'] as $childId) {
                 foreach ($values as $month => $value) {
                     $turnoverCategories[$id][$month] += $turnoverCategories[$childId][$month];
                 }
                 unset($turnoverCategories[$childId]);
             }
         }
     }
     //Remove empty arrays
     foreach ($turnoverCategories as $key => $values) {
         if (!array_sum($values)) {
             unset($turnoverCategories[$key]);
         }
     }
     require_once BASE_PATH . '/library/pChart/class/pData.class.php';
     require_once BASE_PATH . '/library/pChart/class/pDraw.class.php';
     require_once BASE_PATH . '/library/pChart/class/pImage.class.php';
     //Turnover
     /* Create your dataset object */
     $turnoverData = new pData();
     /* Add data in your dataset */
     $turnoverData->addPoints($turnover, 'Values');
     $turnoverData->setAxisName(0, '€ / Netto');
     /* Create the X serie */
     $turnoverData->addPoints($months, 'Labels');
     $turnoverData->setSerieDescription('Labels', 'Months');
     $turnoverData->setAbscissa('Labels');
     /* Create a pChart object and associate your dataset */
     $turnover = new pImage($width, $height, $turnoverData);
     /* Turn off AA processing */
     $turnover->Antialias = FALSE;
     /* Choose a nice font */
     $turnover->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10));
     /* Define the boundaries of the graph area */
     $turnover->setGraphArea(75, 20, $width - 30, $height - 60);
     /* Draw the scale, keep everything automatic */
     $turnover->drawScale(array('DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_START0, 'LabelRotation' => 45));
     /* Draw the scale, keep everything automatic */
     $settings = array('Gradient' => TRUE, 'GradientMode' => GRADIENT_EFFECT_CAN, 'DisplayPos' => LABEL_POS_INSIDE, 'DisplayValues' => TRUE, 'DisplayR' => 0, 'DisplayG' => 0, 'DisplayB' => 0, 'DisplayShadow' => TRUE, 'Surrounding' => 10);
     $turnover->drawBarChart($settings);
     /* Build the PNG file and send it to the web browser */
     if (!file_exists(BASE_PATH . '/cache/chart/')) {
         mkdir(BASE_PATH . '/cache/chart/');
         chmod(BASE_PATH . '/cache/chart/', 0777);
     }
     $turnover->Render(BASE_PATH . '/cache/chart/turnover-' . $width . '-' . $height . '.png');
     //Turnover by categories
     /* Create your dataset object */
     $turnoverCategoriesData = new pData();
     /* Add data in your dataset */
     $turnoverCategoriesTotal = array();
     foreach ($turnoverCategories as $key => $value) {
         $turnoverCategoriesTotal[$key] = array_sum($value);
     }
     arsort($turnoverCategoriesTotal);
     foreach ($turnoverCategoriesTotal as $key => $value) {
         if ($key && isset($options['categories'][$key])) {
             $turnoverCategoriesData->addPoints($turnoverCategories[$key], $options['categories'][$key]['title']);
         }
     }
     if (isset($turnoverCategories[0])) {
         $turnoverCategoriesData->addPoints($turnoverCategories[0], $statisticsUncategorized);
     }
     $turnoverCategoriesData->setAxisName(0, '€ / Netto');
     /* Create the X serie */
     $turnoverCategoriesData->addPoints($months, 'Labels');
     $turnoverCategoriesData->setSerieDescription('Labels', 'Months');
     $turnoverCategoriesData->setAbscissa('Labels');
     /* Create a pChart object and associate your dataset */
     $turnoverCategories = new pImage($width, $height, $turnoverCategoriesData);
     /* Turn off AA processing */
     $turnoverCategories->Antialias = FALSE;
     /* Choose a nice font */
     $turnoverCategories->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10));
     /* Define the boundaries of the graph area */
     $turnoverCategories->setGraphArea(75, 20, $width - 30, $height - 60);
     /* Draw the scale, keep everything automatic */
     $turnoverCategories->drawScale(array('XMargin' => 2, 'DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_ADDALL_START0, 'LabelRotation' => 45));
     /* Draw the scale, keep everything automatic */
     $settings = array();
     $turnoverCategories->drawStackedAreaChart($settings);
     /* Write the chart legend */
     $turnoverCategories->drawLegend(100, 20, array('Style' => LEGEND_NOBORDER, 'Mode' => LEGEND_VERTICAL));
     /* Build the PNG file and send it to the web browser */
     $turnoverCategories->Render(BASE_PATH . '/cache/chart/turnover-category-' . $width . '-' . $height . '.png');
 }
<?php

/* CAT:Scatter chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
include "../class/pScatter.class.php";
/* Create the pData object */
$myData = new pData();
/* Create the X axis and the binded series */
for ($i = 0; $i <= 360; $i = $i + 10) {
    $myData->addPoints(cos(deg2rad($i)) * 20, "Probe 1");
}
$myData->setAxisName(0, "X-Index");
$myData->setAxisXY(0, AXIS_X);
$myData->setAxisPosition(0, AXIS_POSITION_BOTTOM);
/* 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");
/* Library settings */
define("CLASS_PATH", "../../../class");
define("FONT_PATH", "../../../fonts");
/* pChart library inclusions */
include CLASS_PATH . "/pData.class.php";
include CLASS_PATH . "/pDraw.class.php";
include CLASS_PATH . "/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->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);
/* Retrieve the image map */
if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) {
    $myPicture->dumpImageMap("ImageMapSplineChart", IMAGE_MAP_STORAGE_FILE, "SplineChart", "../tmp");
}
/* Set the image map name */
$myPicture->initialiseImageMap("ImageMapSplineChart", IMAGE_MAP_STORAGE_FILE, "SplineChart", "../tmp");
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
Exemplo n.º 29
0
 function generate_graph_image($outputfile)
 {
     // Create Graph Dataset and set axis attributes
     $graphData = new pData();
     $graphData->setAxisName(0, $this->ytitle_actual);
     $graphData->addPoints($this->xlabels, "xaxis");
     $graphData->setSerieDescription("xaxis", "xaxis");
     $graphData->setAbscissa("xaxis");
     $graphData->setXAxisName("ooo");
     // Add each series of plot values to dataset, but Reportico will
     // duplicate series were the same data are displayed in different forms
     // so only add each unique series once
     $seriesadded = array();
     foreach ($this->plot as $k => $v) {
         $series = $v["name"] . $k;
         $graphData->addPoints($v["data"], $series);
         $graphData->setSerieDescription($series, $v["legend"]);
     }
     /*
     $graph->xgrid->SetColor($this->xgridcolor);
     $graph->ygrid->SetColor($this->ygridcolor);
     */
     /*
     switch ( $this->xgriddisplay )
     {
     	case "all":
     		$graph->xgrid->Show(true,true);
     		break;
     	case "major":
     		$graph->xgrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->xgrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->xgrid->Show(false,false);
     		break;
     }
     
     switch ( $this->ygriddisplay )
     {
     	case "all":
     		$graph->ygrid->Show(true,true);
     		break;
     	case "major":
     		$graph->ygrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->ygrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->ygrid->Show(false,false);
     		break;
     }
     */
     /*
     $graph->xaxis->SetFont($fontfamilies[$xaxisfont],$fontstyles[$xaxisfontstyle], $xaxisfontsize);
     $graph->xaxis->SetColor($xaxiscolor,$xaxisfontcolor);
     $graph->yaxis->SetFont($fontfamilies[$yaxisfont],$fontstyles[$yaxisfontstyle], $yaxisfontsize);
     $graph->yaxis->SetColor($yaxiscolor,$yaxisfontcolor);
     $graph->xaxis->title->SetFont($fontfamilies[$xtitlefont],$fontstyles[$xtitlefontstyle], $xtitlefontsize);
     $graph->xaxis->title->SetColor($xtitlecolor);
     $graph->yaxis->title->SetFont($fontfamilies[$ytitlefont],$fontstyles[$ytitlefontstyle], $ytitlefontsize);
     $graph->yaxis->title->SetColor($ytitlecolor);
     $graph->xaxis->SetLabelAngle(90);
     $graph->xaxis->SetLabelMargin(15); 
     $graph->yaxis->SetLabelMargin(15); 
     $graph->xaxis->SetTickLabels($xlabels);
     $graph->xaxis->SetTextLabelInterval($xticklabint);
     $graph->yaxis->SetTextLabelInterval($yticklabint);
     $graph->xaxis->SetTextTickInterval($xtickinterval);
     $graph->yaxis->SetTextTickInterval($ytickinterval);
     */
     /*
     if ( $gridpos == "front" )
     	$graph->SetGridDepth(DEPTH_FRONT); 
     */
     // Display the graph
     /*?$graph->Stroke();*/
     $this->apply_defaults_internal();
     //echo "oo<BR>";
     //echo "<PRE>";
     //var_dump($graphData);
     //echo $this->width."<BR>";
     //echo $this->height_actual."<BR>";
     $graphImage = new pImage($this->width_actual, $this->height_actual, $graphData);
     /* Turn of Antialiasing */
     $graphImage->Antialias = TRUE;
     // Add gradient fill from chosen background color to white
     $startgradient = $this->htmltorgb("#ffffff");
     $color = $this->htmltorgb($this->graphcolor);
     $graphImage->drawGradientArea(0, 0, $this->width_actual, $this->height_actual, DIRECTION_VERTICAL, array("StartR" => $startgradient[0], "StartG" => $startgradient[1], "StartB" => $startgradient[2], "EndR" => $color[0], "EndG" => $color[1], "EndB" => $color[2], "Alpha" => 100));
     /* Add a border to the picture */
     $graphImage->drawRectangle(0, 0, $this->width_actual - 1, $this->height_actual - 1, array("R" => 200, "G" => 200, "B" => 200));
     /* Set the title font and draw it */
     $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->titlefont, "FontSize" => $this->titlefontsize));
     $this->titlecolor = $this->htmltorgb($this->titlecolor);
     $graphImage->drawText(20, 30, $this->title_actual, array("R" => $this->titlecolor[0], "G" => $this->titlecolor[1], "B" => $this->titlecolor[2]));
     /* Set the default font from the X title font */
     $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->xtitlefont, "FontSize" => $this->xtitlefontsize));
     /* Define the chart area */
     $graphImage->setGraphArea($this->marginleft, $this->margintop, $this->width_actual - $this->marginright, $this->height_actual - $this->marginbottom);
     //$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"LabelRotation"=>30);
     //$graphImage->drawScale($scaleSettings);
     //$settings = array("Surrounding"=>-30,"InnerSurrounding"=>30);
     //$graphImage->drawBarChart($settings);
     //$graphImage->autoOutput("pictures/example.drawBarChart.simple.png");
     //return;
     // Before plotting a series ensure they are all not drawable.
     /// Plot the chart data
     $stackeddrawn = false;
     $stackedexists = false;
     $barexists = false;
     foreach ($this->plot as $k => $v) {
         if ($v["type"] == "STACKEDBAR") {
             $stackedexists = true;
         }
         if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
             $barexists = true;
         }
     }
     /* Draw the scale */
     $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 30);
     // For stacked charts fix up the Max and Min values;
     if ($stackedexists) {
         $scaleMin = "Unknown";
         $scaleMax = 0;
         foreach ($this->plot as $k => $v) {
             if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                 $series = $v["name"] . $k;
                 $min = $graphData->getMin($series);
                 if ($scaleMin == "Unknown" || $min < $scaleMin) {
                     $scaleMin = $min;
                 }
                 $scaleMax = $scaleMax + $graphData->getMax($series);
             }
         }
         if ($scaleMin > 0) {
             $scaleMin = 0;
         }
         $range = $scaleMax - $scaleMin;
         // Make scales based on 5% of the range of values
         $scaleMax = round($range * 0.05 + $scaleMax);
         if ($scaleMin < 0) {
             $scaleMin = $scaleMin - round($range * 0.05);
         }
         $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
         $scaleSettings["Mode"] = SCALE_MODE_MANUAL;
         $scaleSettings["ManualScale"] = $AxisBoundaries;
     } else {
         if ($barexists) {
             $scaleMin = "Unknown";
             $scaleMax = 0;
             foreach ($this->plot as $k => $v) {
                 if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                     $series = $v["name"] . $k;
                     $min = $graphData->getMin($series);
                     if ($scaleMin == "Unknown" || $min < $scaleMin) {
                         $scaleMin = $min;
                     }
                     $max = $graphData->getMax($series);
                     if ($scaleMax == "Unknown" || $max > $scaleMax) {
                         $scaleMax = $max;
                     }
                 }
             }
             if ($scaleMin > 0) {
                 $scaleMin = 0;
             }
             $range = $scaleMax - $scaleMin;
             // Make scales based on 5% of the range of values
             $scaleMax = round($range * 0.05 + $scaleMax);
             if ($scaleMin < 0) {
                 $scaleMin = $scaleMin - round($range * 0.05);
             }
             $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
             $scaleSettings["Mode"] = SCALE_MODE_MANUAL;
             $scaleSettings["ManualScale"] = $AxisBoundaries;
         }
     }
     $graphImage->drawScale($scaleSettings);
     // If there's a Pie chart we want to draw different legends
     $piechart = false;
     foreach ($this->plot as $k => $v) {
         foreach ($this->plot as $k1 => $v1) {
             $series = $v1["name"] . $k1;
             $graphData->setSerieDrawable($series, FALSE);
         }
         $series = $v["name"] . $k;
         $graphData->setSerieDrawable($series, TRUE);
         switch ($v["type"]) {
             case "PIE":
                 $piechart = true;
                 $pie = new pPie($graphImage, $graphData);
                 //$pie->draw2DPie($width_actual / 2,$height_actual / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE));
                 $pie->draw2DPie($width_actual / 2, $height_actual / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255));
                 break;
             case "PIE3D":
                 $piechart = true;
                 $pie = new pPie($graphImage, $graphData);
                 $pie->draw3DPie($this->width_actual / 2, $this->height_actual / 2, 80, array("SecondPass" => FALSE));
                 break;
             case "STACKEDBAR":
             case "BAR":
                 if ($stackeddrawn) {
                     break;
                 }
                 if ($barexists) {
                     foreach ($this->plot as $k1 => $v1) {
                         if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR") {
                             $graphData->setSerieDrawable($v1["name"] . $k1, TRUE);
                         }
                     }
                 }
                 $stackeddrawn = true;
                 $settings = array("Surrounding" => -30, "InnerSurrounding" => 30);
                 if ($stackedexists) {
                     $graphImage->drawStackedBarChart($settings);
                 } else {
                     $graphImage->drawBarChart($settings);
                 }
                 break;
             case "LINE":
             default:
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->drawLineChart($settings);
                 break;
         }
     }
     $graphData->drawAll();
     if ($piechart) {
         $pie->drawPieLegend($this->width_actual - 100, 30, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
     } else {
         $graphImage->drawLegend($this->width_actual - 180, 22, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
     }
     $graphImage->setShadow(TRUE, array("X" => 0, "Y" => 0, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $graphImage->render($outputfile);
     return true;
 }
Exemplo n.º 30
0
$oMySQL->ExecuteSQL($SQLString);
foreach ($oMySQL->arrayedResult as $row) {
    switch ($Type) {
        case "day":
            $time = date('h:m', $row["unixtime"]);
            break;
        case "week":
            $time = date('d.m.', $row["unixtime"]);
            break;
    }
    $myData->addPoints($time, "time");
    $venku = $row["value"] == NULL ? VOID : $row["value"];
    $myData->addPoints($venku, "value");
}
$myData->setSerieWeight("value", 1.5);
$myData->setAxisName(0, "Teplota");
$myData->setAxisUnit(0, "°C");
/* Create the abscissa serie */
$myData->setAbscissa("time");
//set the x line
//$myData->setAbscissaName("Den");
//$myData->setXAxisDisplay(AXIS_FORMAT_DATE);
$myPicture = new pImage($Graphwidth, $Graphheigth, $myData);
$Settings = array("R" => 240, "G" => 240, "B" => 240);
$myPicture->setFontProperties(array("FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 8));
$myPicture->drawFilledRectangle(0, 0, $Graphwidth, $Graphheigth, $Settings);
$myPicture->drawRectangle(0, 0, $Graphwidth, $Graphheigth, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->drawRectangle(0, 0, $Graphwidth - 1, $Graphheigth - 1, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 30, $Graphwidth - 70, $Graphheigth - 40);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));