public function display()
 {
     //graph generation
     $chart = new HorizontalBarChart(800, 4500);
     $dataSet = new XYDataSet();
     foreach ($this->data as $key => $datum) {
         $dataSet->addPoint(new Point($datum['client_ip'], $datum['frequency']));
     }
     $chart->setDataSet($dataSet);
     $chart->getPlot()->setGraphPadding(new Padding(5, 30, 20, 140));
     $chart->getPlot()->setLogoFileName("");
     //clear the image logo
     $chart->setTitle("");
     //clear the image title
     $chart->render("front-end/images/client_request_horizontal_bar_plot.png");
     //graph generation
     $session = SessionFactory::create();
     $selectedDate = $session->get("selected-date");
     $dom = DOMHandlerFactory::create();
     $dom->setDocumentFromFile(STATISTICAL_LOG_ANALIZER_HTML)->whereIdIs('login-user')->insertNode($session->get('session-user-name'));
     $selectedDate = $session->get("selected-date");
     $title = "<h3>Bar Graph IP requests for the day: " . $selectedDate . " </h3>";
     $dom->whereIdIs("body-title")->insertNode($title);
     $graph = '<div style="text-align: center;">
     			<img 
     				src="front-end/images/client_request_horizontal_bar_plot.png" 
     				alt="" border="0">
     			</div>';
     $dom->whereIdIs("squidDataContainer")->insertNode($graph);
     $dom->display();
 }
//-----------------------------------------------------------------------------------------------------------------
//MOST CONNECTIONS PER DAY
//-----------------------------------------------------------------------------------------------------------------
$db_query = "SELECT COUNT(*), date_time\n  FROM connections\n  GROUP BY DAYOFYEAR(date_time)\n  ORDER BY COUNT(*) DESC\n  LIMIT 20 ";
$rows = R::getAll($db_query);
if (count($rows)) {
    //We create a new horizontal bar chart and initialize the dataset
    $chart = new HorizontalBarChart(600, 300);
    $dataSet = new XYDataSet();
    //For every row returned from the database we add a new point to the dataset
    foreach ($rows as $row) {
        $dataSet->addPoint(new Point(date('d-m-Y', strtotime($row['date_time'])), $row['COUNT(*)']));
    }
    //$dataSet->addPoint(new Point(date('l, d-m-Y', strtotime($row['date_time'])), $row['COUNT(*)']));
    //We set the horizontal chart's dataset and render the graph
    $chart->setDataSet($dataSet);
    $chart->setTitle("Most connections per day (Top 20)");
    $chart->getPlot()->setGraphPadding(new Padding(5, 30, 50, 75));
    //top, right, bottom, left | defaults: 5, 30, 50, 50
    $chart->render("generated-graphs/most_connections_per_day.png");
}
//-----------------------------------------------------------------------------------------------------------------
//CONNECTIONS PER DAY
//-----------------------------------------------------------------------------------------------------------------
$db_query = "SELECT COUNT(*), date_time\n  FROM connections\n  GROUP BY DAYOFYEAR(date_time)\n  ORDER BY date_time ASC";
$rows = R::getAll($db_query);
if (count($rows)) {
    //We create a new line chart and initialize the dataset
    $chart = new LineChart(600, 300);
    $dataSet = new XYDataSet();
    //This graph gets messed up for large DBs, so here is a simple way to limit some of the input
 /**
  * Función que genera las gráficas con las medias globales
  * de los intentos y violaciones. Se muestra en el panel
  * del profesor.
  * 
  */
 public function generarGraficaMedias()
 {
     $chart = new \HorizontalBarChart(800, 350);
     $dataSet = new \XYDataSet();
     $this->__calcularMediaIntentos();
     $this->__calcularMediaViolaciones();
     if ($_SESSION["media_intentos_no_pasa_test"] != false) {
         $dataSet->addPoint(new \Point("Intentos sin pasar los test", $_SESSION["media_intentos_no_pasa_test"]));
     }
     if ($_SESSION["media_intentos_pasa_test"] != false) {
         $dataSet->addPoint(new \Point("Intentos para pasar los test", $_SESSION["media_intentos_pasa_test"]));
     }
     if ($_SESSION["media_violaciones"] != false) {
         $dataSet->addPoint(new \Point("Violaciones de código", $_SESSION["media_violaciones"]));
     }
     if ($_SESSION["media_intentos_no_pasa_test"] != false || $_SESSION["media_intentos_pasa_test"] != false || $_SESSION["media_violaciones"] != false) {
         $chart->setDataSet($dataSet);
         $chart->getPlot()->setGraphPadding(new \Padding(5, 30, 20, 140));
         $chart->setTitle("MEDIAS");
         $chart->render("img/" . $_SESSION["lti_idTarea"] . "-prof-medias.png");
     }
 }
Example #4
0
 $dataSet2->addPoint(new Point("Android ({$getos12})", $getos12));
 $dataSet2->addPoint(new Point("BlackBerry ({$getos13})", $getos13));
 $dataSet2->addPoint(new Point("Mobile ({$getos14})", $getos14));
 $chart2->setDataSet($dataSet2);
 $chart2->setTitle("Jenis OS");
 $chart2->render("/os.png");
 $chart3 = new HorizontalBarChart();
 $dataSet3 = new XYDataSet();
 $query = "SELECT ip,filename,count(filename) as jumlahfilename FROM `statistiksitus` WHERE dateflag BETWEEN '{$_POST['DariTanggal']}' AND '{$_POST['SampaiTanggal']}' group by filename ORDER BY `jumlahfilename`  desc limit 6";
 $hasil = mysql_query($query);
 while ($data = mysql_fetch_assoc($hasil)) {
     $filename = $data['filename'];
     $jumlahfilename = $data['jumlahfilename'];
     $dataSet3->addPoint(new Point("{$filename}", $jumlahfilename));
 }
 $chart3->setDataSet($dataSet3);
 $chart3->setTitle("Most visited pages");
 $chart3->render("mostvisited.png");
 $gethari1 = gethari("1");
 $gethari2 = gethari("2");
 $gethari3 = gethari("3");
 $gethari4 = gethari("4");
 $gethari5 = gethari("5");
 $gethari6 = gethari("6");
 $gethari0 = gethari("0");
 $chart4 = new PieChart(400);
 $dataSet4 = new XYDataSet();
 $dataSet4->addPoint(new Point("Senin ({$gethari1})", $gethari1));
 $dataSet4->addPoint(new Point("Selasa ({$gethari2})", $gethari2));
 $dataSet4->addPoint(new Point("Rabu ({$gethari3})", $gethari3));
 $dataSet4->addPoint(new Point("Kamis ({$gethari4})", $gethari4));
 public function createMostProbesPerDay()
 {
     $db_query = "SELECT COUNT(connection), date_trunc('day', timestamp) AS date\n          FROM connections\n          GROUP BY date\n          ORDER BY COUNT(connection) DESC\n          LIMIT 20 ";
     $rows = R::getAll($db_query);
     if (count($rows)) {
         //We create a new horizontal bar chart and initialize the dataset
         $chart = new HorizontalBarChart(600, 300);
         $dataSet = new XYDataSet();
         //For every row returned from the database we add a new point to the dataset
         foreach ($rows as $row) {
             $dataSet->addPoint(new Point(date('d-m-Y', strtotime($row['date'])), $row['count']));
             //$dataSet->addPoint(new Point(date('l, d-m-Y', strtotime($row['timestamp'])), $row['COUNT(session)']));
         }
         //We set the horizontal chart's dataset and render the graph
         $chart->setDataSet($dataSet);
         $chart->setTitle(MOST_PROBES_PER_DAY);
         $chart->getPlot()->setGraphPadding(new Padding(5, 30, 50, 75));
         //top, right, bottom, left | defaults: 5, 30, 50, 50
         $chart->render("generated-graphs/most_probes_per_day.png");
     }
 }
    //else{
    //	$disp='Disponible';
    // }
    $result2 = mysql_query("select id_libro from prestamos where id_profesor='{$idP}'", $link);
    while ($row = mysql_fetch_array($result2)) {
        $id = $row['id_libro'];
        $cantLibros = $cantLibros + 1;
        //   echo "<a href='JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');'>Open a popup window</a>";
        //   <a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>
        //   echo "<tr><td>$id</td><td>$ti</td><td>$aut</td><td>$an</td><td>$edi</td><td>$gen</td><td>$nump</td><td>$stat</td></tr>";
    }
    $dataset->addPoint(new Point("{$nomm}", $cantLibros));
    $cantLibros = 0;
}
//echo"</table>";
$chart2->setDataSet($dataset);
$chart2->getPlot()->setGraphPadding(new Padding(10, 100, 50, 200));
$chart2->setTitle("Libros por profesor");
$chart2->render("generated/GraficaLibros.jpg");
echo "<img src='generated/GraficaLibros.jpg' style='border 1px solid gray'/>";
mysql_free_result($result);
mysql_close($link);
?>
	
  </div>
	
      <br class="clear" />
    </div>
  </div>
</div>
<!-- ####################################################################################################### -->
            $nTH8 = round($n0TH8 / $nombreSemaines / $nbPoste * 100);
        }
        if ($d == 3 or $d == 6) {
            $serieMardi->addPoint(new Point("10h-11h", $nTH1));
            $serieMardi->addPoint(new Point("11h-12h", $nTH2));
            $serieMardi->addPoint(new Point("12h-14h", $nTH3));
        }
        $serieMardi->addPoint(new Point("14h-15h", $nTH4));
        $serieMardi->addPoint(new Point("15h-16h", $nTH5));
        $serieMardi->addPoint(new Point("16h-17h", $nTH6));
        $serieMardi->addPoint(new Point("17h-18h", $nTH7));
        if ($d == 2) {
            $serieMardi->addPoint(new Point("18-19h30", $nTH8));
        }
        $dataSetMardi->addSerie($y, $serieMardi);
        $chartMardi->setDataSet($dataSetMardi);
        //debug($nTH4);
    }
    $chartMardi->getPlot()->getPalette()->setBarColor(array(new Color(144, 213, 236), new Color(229, 87, 91), new Color(167, 119, 229)));
    $chartMardi->setTitle("Répartition de la fréquentation sur le " . getDay($d) . " en %");
    $chartMardi->render("img/chart/" . $year . "/resa-horaire-" . getDay($d) . ".png");
}
//affichage des charts
echo ' <ul class="nav nav-tabs">';
for ($d = 2; $d < 7; ++$d) {
    if ($d == 2) {
        $class = "active";
    } else {
        $class = "";
    }
    echo '<li class="' . $class . '"><a href="#tab_' . $d . '" data-toggle="tab">' . getDay($d) . '</a></li>';
 public function createTop10SSHClients()
 {
     $db_query = "SELECT clients.version, COUNT(client)\n          FROM sessions INNER JOIN clients ON sessions.client = clients.id\n          GROUP BY sessions.client\n          ORDER BY COUNT(client) DESC\n          LIMIT 10";
     $rows = R::getAll($db_query);
     if (count($rows)) {
         //We create a new vertical bar chart and initialize the dataset
         $chart = new HorizontalBarChart(600, 300);
         $dataSet = new XYDataSet();
         //For every row returned from the database we add a new point to the dataset
         foreach ($rows as $row) {
             $dataSet->addPoint(new Point($row['version'] . " ", $row['COUNT(client)']));
         }
         //We set the bar chart's dataset and render the graph
         $chart->setDataSet($dataSet);
         $chart->setTitle(TOP_10_SSH_CLIENTS);
         //For this particular graph we need to set the corrent padding
         $chart->getPlot()->setGraphPadding(new Padding(5, 30, 50, 245));
         //top, right, bottom, left | defaults: 5, 30, 50, 50
         //$chart->getPlot()->setGraphPadding(new Padding(5, 80, 140, 50)); //top, right, bottom, left | defaults: 5, 30, 50, 50
         $chart->render(DIR_ROOT . "/generated-graphs/top10_ssh_clients.png");
     }
 }