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(); }
//----------------------------------------------------------------------------------------------------------------- $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 $counter = 1; //Display date legend only every $mod rows, 25 distinct values being the optimal for a graph
* * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * Horizontal bar chart demonstration * */ include "../libchart/classes/libchart.php"; $chart = new HorizontalBarChart(600, 170); $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("Produto", 50)); $dataSet->addPoint(new Point("/wiki/Web_Browser", 75)); $dataSet->addPoint(new Point("/wiki/World_Wide_Web", 122)); $chart->setDataSet($dataSet); $chart->getPlot()->setGraphPadding(new Padding(5, 30, 20, 140)); $chart->setTitle("Most visited pages for www.example.com"); $chart->render("generated/demo2.png"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Libchart horizontal bars demonstration</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" /> </head> <body> <img alt="Horizontal bars chart" src="generated/demo2.png" style="border: 1px solid gray;"/> </body> </html>
/** * 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"); } }
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"); } }
// $identif=$_GET['a']; $link = mysql_connect("mysql6.000webhost.com", "a5996766_hab", "blazing12"); mysql_select_db("a5996766_bib", $link); // echo "<p>$identif</p>"; // echo " Libros del profesor: "."<strong>".$_SESSION['k_username2']."</strong>"; echo "<br><br><br>"; include "libchart/classes/libchart.php"; // $chart2 = new VerticalBarChart(800,300); $chart2 = new HorizontalBarChart(800, 300); // $chart2 = new PieChart(800,300); $chart2->getConfig()->setUseMultipleColor(true); function colore() { return new Color(rand(0, 215), rand(0, 215), rand(0, 215)); } $chart2->getPlot()->getPalette()->setBarColor(array(colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore(), colore())); //$chart2->getPlot()->getPalette()->setBarColor(array( //new Color(255, 0, 0), // new Color(255, 255, 255), // new Color(255, 125, 50), // new Color(255, 125, 0), // )); //$chart2 = new PieChart(800,300); //$chart2 = new LineChart(800,300); $dataset = new XYDataSet(); $profe = $_SESSION['k_username2']; $result = mysql_query("select * from profesores", $link); $cantLibros = 0; // echo "<table border=1>"; // echo "<tr style='font-weight:bold; color:blue;'><td>ID Libro</td><td>Titulo</td><td>Autor</td><td>Año</td><td>Editorial</td><td>Genero</td><td>Num Paginas</td><td>Existentes</td></tr>"; while ($row = mysql_fetch_array($result)) {
$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"); } }