Exemplo n.º 1
1
function grafico($v, $nomegraph, $titolo, $x, $upper = Null)
{
    #	$chart = new VerticalBarChart(800,200);
    $chart = new LineChart(700, 245);
    //	var_dump($x);
    $ii = 0;
    $serie = array();
    //	echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><br>";
    foreach ($v as $s) {
        //		var_dump($s);
        //		echo "<br>";
        $serie[$ii] = new XYDataSet();
        $nome_serie[] = $s[0];
        //		echo $s[0]."<br>";
        //		unset($s[0]);
        $flag = True;
        $i = 0;
        $ib = 0;
        foreach ($s as $e) {
            if (!$flag) {
                # per saltare il primo elemento
                //			var_dump($e+0.0);
                while ($ib < $x[$i]) {
                    $serie[$ii]->addPoint(new Point(sprintf("%02d", $ib), 0.0));
                    $ib = $ib + 1;
                }
                $serie[$ii]->addPoint(new Point(sprintf("%02d", $x[$i]), $e + 0.0));
                //				echo "i=",$i,"x=",$x[$i],"ib=",$ib."<br>";
                $ib = $ib + 1;
                $i = $i + 1;
            }
            $flag = False;
        }
        $ii = $ii + 1;
    }
    $ii = 0;
    $dataSet = new XYSeriesDataSet();
    foreach ($serie as $ds) {
        $dataSet->addSerie($nome_serie[$ii], $ds);
        $ii = $ii + 1;
    }
    if ($upper) {
        //		echo "Set massimo valore",$upper,"<br>";
        $chart->setUpper($upper);
        //solo con LineChar()
        $chart->setLower(0.0);
        //solo con LineChar()
    }
    $chart->setDataSet($dataSet);
    $chart->setTitle($titolo);
    $chart->render($nomegraph);
}
 public function display()
 {
     $chart = new LineChart(4500, 350);
     $dataSet = new XYDataSet();
     foreach ($this->data as $key => $datum) {
         $dataSet->addPoint(new Point($datum['client_ip'], $datum['frequency']));
     }
     $chart->setDataSet($dataSet);
     $chart->setTitle("Client Request Frequency Line Plot");
     $chart->render("front-end/images/client_request_vertical_bar_plot.png");
     $session = SessionFactory::create();
     $dom = DOMHandlerFactory::create();
     $dom->setDocumentFromFile(STATISTICAL_LOG_ANALIZER_HTML)->whereIdIs('login-user')->insertNode($session->get('session-user-name'));
     $graph = '<div style="text-align: center;">
                 <img src="front-end/images/client_request_vertical_bar_plot.png" alt="" border="0">
                 </div>';
     $dom->whereIdIs("squidDataContainer")->insertNode($graph);
     $dom->display();
 }
 public function display()
 {
     $session = SessionFactory::create();
     $clientIp = $session->get("selected-client-ip");
     $date = $session->get("selected-date");
     $beginTime = $this->data[0]['time'];
     $endTime = end($this->data)['time'];
     /*CHART*/
     // $chart = new HorizontalBarChart(800,30000);
     $chart = new LineChart(3000, 500);
     $dataSet = new XYDataSet();
     // $protocols = array('http://', 'https://', 'ftp://', 'www.');
     foreach ($this->data as $key => $datum) {
         // $domain = explode('/', str_replace($protocols, '', $datum['url']));
         $dataSet->addPoint(new Point("", $datum['frequency']));
     }
     $chart->setDataSet($dataSet);
     $chart->getPlot()->setGraphPadding(new Padding(5, 3, 20, 140));
     $chart->getPlot()->setLogoFileName("");
     //clear the image logo
     $chart->setTitle("");
     //clear the image title
     $chart->render("front-end/images/domains_request_horizontal_bar_plot.png");
     /*CHART*/
     $session = SessionFactory::create();
     $dom = DOMHandlerFactory::create();
     $dom->setDocumentFromFile(STATISTICAL_LOG_ANALIZER_HTML)->whereIdIs('login-user')->insertNode($session->get('session-user-name'));
     //INSERT TITLE:
     $title = "<h3>Client (" . $clientIp . ") Domains Request Frequency Bar Plot, at: " . $date . " between: " . $beginTime . " and " . $endTime . "</h3>";
     $dom->whereIdIs("body-title")->insertNode($title);
     $graph = '<div style="text-align: center;">
     			<img 
     				src="front-end/images/domains_request_horizontal_bar_plot.png" 
     				alt="" border="0">
     			</div>';
     $dom->whereIdIs("squidDataContainer")->insertNode($graph);
     $dom->display();
 }
Exemplo n.º 4
0
function renderLineChart($value_arrays, $labels = NULL, $title = '', $xlabels = NULL)
{
    $chart = new LineChart(1000, 400);
    $dataSet = new XYSeriesDataSet();
    for ($va = 0; $va < sizeof($value_arrays); $va++) {
        $value_array = $value_arrays[$va];
        $ds = new XYDataSet();
        if (sizeof($value_array)) {
            for ($x = 0; $x < sizeof($value_array); $x++) {
                if ($xlabels) {
                    $label = $xlabels[$x];
                } else {
                    $label = $x + 1;
                }
                $ds->addPoint(new Point($label, $value_array[$x]));
            }
        } else {
            // need at least one point or will except
            $ds->addPoint(new Point(1, 0));
        }
        if ($labels) {
            $label = $labels[$va];
        } else {
            $label = $va;
        }
        $dataSet->addSerie($label, $ds);
    }
    $chart->setDataSet($dataSet);
    $chart->setTitle($title);
    $name = tempnam('/tmp', '.png');
    $chart->render($name);
    $image = base64_encode(file_get_contents($name));
    unlink($name);
    echo '<div style="text-align: center"><img src="data:image/png;base64,';
    echo $image;
    echo '"></div>';
}
 public function display()
 {
     $session = SessionFactory::create();
     $clientIp = $session->get("selected-client-ip");
     $date = $session->get("selected-date");
     $beginTime = $this->data[0]['time'];
     $endTime = end($this->data)['time'];
     /*CHART*/
     $chart = new LineChart(1400, 500);
     $serie1 = new XYDataSet();
     foreach ($this->data as $key => $datum) {
         $serie1->addPoint(new Point("", $datum['client_data']));
     }
     $dataSet = new XYSeriesDataSet();
     $dataSet->addSerie("Client: " . $clientIp . " at " . $date, $serie1);
     $chart->setDataSet($dataSet);
     $chart->getPlot()->setGraphPadding(new Padding(5, 3, 20, 140));
     $chart->setTitle("");
     //clear the image title
     $chart->getPlot()->setLogoFileName("");
     //clear the image logo
     $chart->render("front-end/images/client_data_line_plot.png");
     /*CHART*/
     //DOM:
     $dom = DOMHandlerFactory::create();
     $dom->setDocumentFromFile(STATISTICAL_LOG_ANALIZER_HTML)->whereIdIs('login-user')->insertNode($session->get('session-user-name'));
     //INSERT TITLE:
     $title = "<h3>Client (" . $clientIp . ") Data Consumption Line Chart, \n                            at: " . $date . " between: " . $beginTime . " and " . $endTime . "</h3>";
     $dom->whereIdIs("body-title")->insertNode($title);
     //INSERT GRAPH:
     $graph = '<div style="text-align: center;">
                 <img src="front-end/images/client_data_line_plot.png" alt="" border="0">
                 </div>';
     $dom->whereIdIs("squidDataContainer")->insertNode($graph);
     $dom->display();
 }
Exemplo n.º 6
0
        }
        if ($acompanhamento->getReembolso() != null) {
            $dataSet->addSerie("Reembolso", $serie2);
            //Legenda do grafico
            $dataSet->addSerie("Remuneracao", $serie4);
            //Legenda do grafico
        }
        if ($acompanhamento->getReembolso() == null && $acompanhamento->getRemuneracao() == null) {
            $dataSet->addSerie("Remuneração Previsto", $serie1);
            //Legenda do grafico
            $dataSet->addSerie("Remuneração Realizado", $serie3);
            //Legenda do grafico
            $dataSet->addSerie("Reembolso Previsto", $serie2);
            //Legenda do grafico
            $dataSet->addSerie("Reembolso Realizado", $serie4);
            //Legenda do grafico
        }
        $chart->setDataSet($dataSet);
        $chart->getPlot()->setGraphCaptionRatio(0.8);
        $chart->setTitle("Gráfico por ano (" . $acompanhamento->getAno() . " - Segundo Semestre)");
        $chart->render("generated/" . $acompanhamento->getAno() . "2.png");
        if ($num > 0) {
            echo '<img alt="Vertical bars chart" src="generated/' . $acompanhamento->getAno() . '2.png" style="border: 1px solid gray;"/>
						<p class="FonteTexto">Unidade: R$ 1.000,00</p>';
        }
    }
}
?>
</body>
</html>
Exemplo n.º 7
0
}
usort($matches, 'cmp');
$chart = new VerticalBarChart(1400, 550);
$dataSet = new XYDataSet();
//	$chart->getPlot()->setGraphPadding(new Padding(5, 25, 10, 25));
// add a data point for each month
foreach ($matches as $matchesPerHour) {
    $dataSet->addPoint(new Point($matchesPerHour['hours'], $matchesPerHour['matches']));
}
$chart->setDataSet($dataSet);
// compute oldest date in a nice formatting for chart
$oldestMonth = substr($oldTimestamp, 5, 2);
$oldestMonth .= '/' . substr($oldTimestamp, 0, 4);
$chart->setTitle('Official GU Matches Per Hour (UTC) [ ' . $oldestDate . ' - ' . $oldestMonth . ' ]');
// FIXME: Where should the graph be saved?
$chart->render(dirname(__FILE__) . '/img/matchesPerHourBar.png');
$chart = new LineChart(1400, 550);
$dataSet = new XYDataSet();
//	$chart->getPlot()->setGraphPadding(new Padding(5, 25, 10, 25));
// add a data point for each month
foreach ($matches as $matchesPerHour) {
    $dataSet->addPoint(new Point($matchesPerHour['hours'], $matchesPerHour['matches']));
}
$chart->setDataSet($dataSet);
// compute oldest date in a nice formatting for chart
$oldestMonth = substr($oldTimestamp, 5, 2);
$oldestMonth .= '/' . substr($oldTimestamp, 0, 4);
$chart->setTitle('Official GU Matches Per Hour (UTC) [ ' . $oldestDate . ' - ' . $oldestMonth . ' ]');
// FIXME: Where should the graph be saved?
$chart->render(dirname(__FILE__) . '/img/matchesPerHourLine.png');
Exemplo n.º 8
0
        if ($numX > 12) {
            if ($i % $numX == 0) {
                $dataSet->addPoint(new Point(date("H:i", $row['datetime']), $row['txtdata']));
            } else {
                $dataSet->addPoint(new Point("", $row['txtdata']));
            }
        } else {
            $dataSet->addPoint(new Point(date("H:i", $row['datetime']), $row['txtdata']));
        }
        $i++;
    }
}
$dateTitle = date("Y-m-d H:i", $startTime) . "~" . date("Y-m-d H:i", $endTime);
$chart->setDataSet($dataSet);
$chart->setTitle($dateTitle);
$chart->render("generated/chart2.png");
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>phpChart - Basic Chart</title>
</head>
<body>
	<h3><?php 
echo $sensorName;
?>
</h3>
        <img alt="Line chart" src="generated/demo5.png" style="border: 1px solid gray;"/>
</body>
</html>
Exemplo n.º 9
0
 public function printHumanActivityPerWeek()
 {
     $db_query = "SELECT COUNT(input), MAKEDATE(\n          CASE\n          WHEN WEEKOFYEAR(timestamp) = 52\n          THEN YEAR(timestamp)-1\n          ELSE YEAR(timestamp)\n          END, (WEEKOFYEAR(timestamp) * 7)-4) AS DateOfWeek_Value\n          FROM input\n          GROUP BY WEEKOFYEAR(timestamp)\n          ORDER BY timestamp 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
         $mod = round(count($rows) / 25);
         if ($mod == 0) {
             $mod = 1;
         }
         //otherwise a division by zero might happen below
         //For every row returned from the database we add a new point to the dataset
         foreach ($rows as $row) {
             if ($counter % $mod == 0) {
                 $dataSet->addPoint(new Point(date('d-m-Y', strtotime($row['DateOfWeek_Value'])), $row['COUNT(input)']));
             } else {
                 $dataSet->addPoint(new Point('', $row['COUNT(input)']));
             }
             $counter++;
             //We add 6 "empty" points to make a horizontal line representing a week
             for ($i = 0; $i < 6; $i++) {
                 $dataSet->addPoint(new Point('', $row['COUNT(input)']));
             }
         }
         //We set the line chart's dataset and render the graph
         $chart->setDataSet($dataSet);
         $chart->setTitle(HUMAN_ACTIVITY_PER_WEEK);
         $chart->render(DIR_ROOT . "/generated-graphs/human_activity_per_week.png");
         echo '<p>The following line chart visualizes real human activity per week, by counting the number of input to the system for each day of operation.</p>';
         echo '<img src="generated-graphs/human_activity_per_week.png">';
         echo '<br /><hr /><br />';
     }
 }
Exemplo n.º 10
0
$serie4->addPoint(new Point("Mar {$year}", $ro->getGenderAnnual("03", $year, "female", "IPD")));
$serie4->addPoint(new Point("Apr {$year}", $ro->getGenderAnnual("04", $year, "female", "IPD")));
$serie4->addPoint(new Point("May {$year}", $ro->getGenderAnnual("05", $year, "female", "IPD")));
$serie4->addPoint(new Point("Jun {$year}", $ro->getGenderAnnual("06", $year, "female", "IPD")));
$serie4->addPoint(new Point("Jul {$year}", $ro->getGenderAnnual("07", $year, "female", "IPD")));
$serie4->addPoint(new Point("Aug {$year}", $ro->getGenderAnnual("08", $year, "female", "IPD")));
$serie4->addPoint(new Point("Sep {$year}", $ro->getGenderAnnual("09", $year, "female", "IPD")));
$serie4->addPoint(new Point("Oct {$year}", $ro->getGenderAnnual("10", $year, "female", "IPD")));
$serie4->addPoint(new Point("Nov {$year}", $ro->getGenderAnnual("11", $year, "female", "IPD")));
$serie4->addPoint(new Point("Dec {$year}", $ro->getGenderAnnual("12", $year, "female", "IPD")));
$dataSet = new XYSeriesDataSet();
$dataSet->addSerie("OPD Male", $serie1);
$dataSet->addSerie("OPD Female", $serie2);
$dataSet->addSerie("IPD Male", $serie3);
$dataSet->addSerie("IPD Female", $serie4);
$chart->setDataSet($dataSet);
$chart->setTitle("Gender Census for {$year}");
$chart->getPlot()->setGraphCaptionRatio(0.62);
$chart->render("../../../COCONUT/graphicalReport/chartList/monthlyRegistrationBreakdown.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 line demonstration</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>
	<img alt="Line chart" src="/COCONUT/graphicalReport/chartList/monthlyRegistrationBreakdown.png" style="border: 1px solid gray;"/>
</body>
</html>
Exemplo n.º 11
0
        $chart = new PieChart($width, $height);
    } elseif ($REQUEST['type'] == "hbar") {
        $chart = new HorizontalChart($width, $height);
    } elseif ($REQUEST['type'] == "vbar") {
        $chart = new VerticalChart($width, $height);
        $chart->setLabelMarginBottom(100);
    } else {
        $chart = new LineChart($width, $height);
        $chart->setLabelMarginBottom(150);
    }
    foreach ($REQUEST['datas'] as $data) {
        $chart->addPoint(new Point($data[0], $data[1]));
    }
    $chart->setLogo("");
    $chart->setTitle($REQUEST['title']);
    $chart->render();
    $BL->Disconnect();
}
//GET INVOICE/SALES/SERVERLOAD REPORT
if ($cmd == "load") {
    include_once XMLFEEDS . "uptime.php";
}
if ($cmd == "cbm") {
    include_once XMLFEEDS . "orders_monthly.php";
}
if ($cmd == "inv") {
    include_once XMLFEEDS . "invoices_all.php";
}
if ($cmd == "sbm") {
    include_once XMLFEEDS . "sales_monthly.php";
}
			<td>' . getMonth($i) . '</td>
            <td>' . $nbTr1 . '</td>
            <td>' . $nbTr2 . '</td>
            <td>' . $nbTr3 . '</td>
			
			<td>' . $hparm . ' %</td></tr>';
}
///Creation du graphique
$dataSetCA->addSerie("Enfants", $serie1);
$dataSetCA->addSerie("Adolescents", $serie2);
$dataSetCA->addSerie("Adultes", $serie3);
$chartCA->setDataSet($dataSetCA);
$chartCA->setTitle("Frequence des reservations par age (" . $year . ")");
$chartCA->getPlot()->setGraphCaptionRatio(0.62);
$chartCA->getPlot()->getPalette()->setLineColor(array(new Color(2, 119, 158), new Color(190, 128, 255), new Color(255, 84, 143)));
$chartCA->render("img/chart/" . $year . "/frequenceParAge.png");
?>




</tbody></table>
</div><div class="box-body">
<img src="img/chart/<?php 
echo $year;
?>
/frequenceParAge.png" width="420px" >
        </div><!-- /.box-body-->
    </div><!-- /.box -->

Exemplo n.º 13
0
$serie2->addPoint(new Point("Apr {$year}", $ro->getAnnualInventory("04", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("May {$year}", $ro->getAnnualInventory("05", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Jun {$year}", $ro->getAnnualInventory("06", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Jul {$year}", $ro->getAnnualInventory("07", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Aug {$year}", $ro->getAnnualInventory("08", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Sep {$year}", $ro->getAnnualInventory("09", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Oct {$year}", $ro->getAnnualInventory("10", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Nov {$year}", $ro->getAnnualInventory("11", $year, $description, $inventoryCode, "OPD")));
$serie2->addPoint(new Point("Dec {$year}", $ro->getAnnualInventory("12", $year, $description, $inventoryCode, "OPD")));
$dataSet = new XYSeriesDataSet();
$dataSet->addSerie("IPD", $serie1);
$dataSet->addSerie("OPD", $serie2);
$chart->setDataSet($dataSet);
$chart->setTitle("{$description} dispensed in {$year}");
$chart->getPlot()->setGraphCaptionRatio(0.62);
$chart->render("../../../COCONUT/graphicalReport/chartList/annualInventory.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>Discount Given from <?php 
echo $year;
?>
</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>
	<img alt="Line chart" src="/COCONUT/graphicalReport/chartList/annualInventory.png" style="border: 1px solid gray;"/>

<?php 
echo $ro->getAnnualInventory("Jan", $year, $description, $inventoryCode, "IPD");
Exemplo n.º 14
0
 public function createProbesPerWeek()
 {
     $db_query = "SELECT COUNT(session),\n          MAKEDATE(CASE WHEN WEEKOFYEAR(timestamp) = 52\n            THEN YEAR(timestamp)-1\n            ELSE YEAR(timestamp)\n            END, (WEEKOFYEAR(timestamp) * 7)-4) AS DateOfWeek_Value\n          FROM auth\n          GROUP BY WEEKOFYEAR(timestamp)\n          ORDER BY timestamp 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
         $mod = round(count($rows) / 25);
         if ($mod == 0) {
             $mod = 1;
         }
         //otherwise a division by zero might happen below
         //For every row returned from the database we add a new point to the dataset
         foreach ($rows as $row) {
             if ($counter % $mod == 0) {
                 $dataSet->addPoint(new Point(date('d-m-Y', strtotime($row['DateOfWeek_Value'])), $row['COUNT(session)']));
             } else {
                 $dataSet->addPoint(new Point('', $row['COUNT(session)']));
             }
             $counter++;
             //We add 6 "empty" points to make a horizontal line representing a week
             for ($i = 0; $i < 6; $i++) {
                 $dataSet->addPoint(new Point('', $row['COUNT(session)']));
             }
         }
         //We set the line chart's dataset and render the graph
         $chart->setDataSet($dataSet);
         $chart->setTitle(PROBES_PER_WEEK);
         $chart->render(DIR_ROOT . "/generated-graphs/probes_per_week.png");
     }
 }
 public function printActivityPerWeek()
 {
     $db_query = "SELECT COUNT(command) AS count, EXTRACT(week from timestamp) AS week, EXTRACT(year from timestamp) AS year,\n          to_date('' || EXTRACT(week from timestamp) || ' ' || EXTRACT(year from timestamp), 'IW IYYY') AS date\n          FROM connections\n          WHERE command <> ''\n          GROUP BY week, year\n          ORDER BY week 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
         $mod = round(count($rows) / 25);
         if ($mod == 0) {
             $mod = 1;
         }
         //otherwise a division by zero might happen below
         //For every row returned from the database we add a new point to the dataset
         foreach ($rows as $row) {
             if ($counter % $mod == 0) {
                 $dataSet->addPoint(new Point(date('d-m-Y', strtotime($row['date'])), $row['count']));
             } else {
                 $dataSet->addPoint(new Point('', $row['count']));
             }
             $counter++;
             //We add 6 "empty" points to make a horizontal line representing a week
             for ($i = 0; $i < 6; $i++) {
                 $dataSet->addPoint(new Point('', $row['count']));
             }
         }
         //We set the line chart's dataset and render the graph
         $chart->setDataSet($dataSet);
         $chart->setTitle(ACTIVITY_PER_WEEK);
         $chart->render("generated-graphs/shellshock_activity_per_week.png");
         echo '<p>The following line chart visualizes shellshock commands activity per week, by counting the number of input commands to the system for each day of operation.</p>';
         echo '<img src="generated-graphs/shellshock_activity_per_week.png">';
         echo '<br /><hr /><br />';
     }
 }
Exemplo n.º 16
0
$serie2->addPoint(new Point("Apr {$year}", $ro->getAnnualSenior("04", $year, "OPD")));
$serie2->addPoint(new Point("May {$year}", $ro->getAnnualSenior("05", $year, "OPD")));
$serie2->addPoint(new Point("Jun {$year}", $ro->getAnnualSenior("06", $year, "OPD")));
$serie2->addPoint(new Point("Jul {$year}", $ro->getAnnualSenior("07", $year, "OPD")));
$serie2->addPoint(new Point("Aug {$year}", $ro->getAnnualSenior("08", $year, "OPD")));
$serie2->addPoint(new Point("Sep {$year}", $ro->getAnnualSenior("09", $year, "OPD")));
$serie2->addPoint(new Point("Oct {$year}", $ro->getAnnualSenior("10", $year, "OPD")));
$serie2->addPoint(new Point("Nov {$year}", $ro->getAnnualSenior("11", $year, "OPD")));
$serie2->addPoint(new Point("Dec {$year}", $ro->getAnnualSenior("12", $year, "OPD")));
$dataSet = new XYSeriesDataSet();
$dataSet->addSerie("IPD", $serie1);
$dataSet->addSerie("OPD", $serie2);
$chart->setDataSet($dataSet);
$chart->setTitle("Senior Census for {$year}");
$chart->getPlot()->setGraphCaptionRatio(0.62);
$chart->render("../../../COCONUT/graphicalReport/chartList/annualSenior.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>Senior Census for <?php 
echo $year;
?>
</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>
	<img alt="Line chart" src="/COCONUT/graphicalReport/chartList/annualSenior.png" style="border: 1px solid gray;"/>
</body>
</html>
Exemplo n.º 17
0
    //Display date legend only every $mod rows, 25 distinct values being the optimal for a graph
    $mod = round(count($rows) / 25);
    if ($mod == 0) {
        $mod = 1;
    }
    //otherwise a division by zero might happen below
    //For every row returned from the database we add a new point to the dataset
    foreach ($rows as $row) {
        if ($counter % $mod == 0) {
            $dataSet->addPoint(new Point(date('d-m-Y', strtotime($row['DateOfWeek_Value'])), $row['COUNT(*)']));
        } else {
            $dataSet->addPoint(new Point('', $row['COUNT(*)']));
        }
        $counter++;
        //We add 6 "empty" points to make a horizontal line representing a week
        for ($i = 0; $i < 6; $i++) {
            $dataSet->addPoint(new Point('', $row['COUNT(*)']));
        }
    }
    //We set the line chart's dataset and render the graph
    $chart->setDataSet($dataSet);
    $chart->setTitle("Connections per week");
    $chart->render("generated-graphs/connections_per_week.png");
}
//-----------------------------------------------------------------------------------------------------------------
//END
//-----------------------------------------------------------------------------------------------------------------
//We close the connection
R::close();
//And redirect to the graph presentation page
header('location:honeyd-viz.php');
 /**
  * Función que genera las gráficas con el promedio de errores y
  * violaciones cometidas por los alumnos. Van a mostrarse en el
  * panel del profesor.
  * 
  */
 public function generarGraficaLineaPromedioErroresUnitariosViolaciones()
 {
     $chart = new \LineChart(800, 350);
     $serie_violaciones = new \XYDataSet();
     $serie_errores = new \XYDataSet();
     $num_alumnos_por_intento = array();
     $alumnos_tabla = TableRegistry::get("Alumnos");
     $alumnos = $alumnos_tabla->find('all');
     $intento_realizado = false;
     foreach ($alumnos as $alumno) {
         $intentos_tabla = TableRegistry::get("Intentos");
         $intentos = $intentos_tabla->find('all')->where(['tarea_id' => $_SESSION["lti_idTarea"], 'alumno_id' => $alumno->id]);
         foreach ($intentos as $intento) {
             $intento_realizado = true;
             $clave = "Intento " . $intento->numero_intento;
             if (array_key_exists($clave, $num_alumnos_por_intento)) {
                 $num_alumnos_por_intento[$clave] += 1;
             } else {
                 $num_alumnos_por_intento[$clave] = 1;
             }
             // Violaciones
             $violaciones_tabla = TableRegistry::get("Violaciones");
             $query = $violaciones_tabla->find('all')->where(['intento_id' => $intento->id])->toArray();
             $num_violaciones = count($query);
             $point_violacion = $serie_violaciones->getPointWithX($clave);
             if ($point_violacion != null) {
                 $point_violacion->setY(($point_violacion->getY() + $num_violaciones) / $num_alumnos_por_intento[$clave]);
             } else {
                 $serie_violaciones->addPoint(new \Point($clave, $num_violaciones));
             }
             // Errores
             $errores_tabla = TableRegistry::get("Errores");
             $query = $errores_tabla->find('all')->where(['intento_id' => $intento->id])->toArray();
             $num_errores = count($query);
             $point_error = $serie_errores->getPointWithX($clave);
             if ($point_error != null) {
                 $point_error->setY(($point_error->getY() + $num_errores) / $num_alumnos_por_intento[$clave]);
             } else {
                 $serie_errores->addPoint(new \Point($clave, $num_errores));
             }
         }
     }
     if ($intento_realizado) {
         $dataSet = new \XYSeriesDataSet();
         $dataSet->addSerie("Violaciones de código", $serie_violaciones);
         $dataSet->addSerie("Errores unitarios", $serie_errores);
         $chart->setDataSet($dataSet);
         $chart->setTitle("Promedio de la clase de Violaciones-Errores por intento realizado");
         $chart->render("img/" . $_SESSION["lti_idTarea"] . "-prof-promedioViolacionesErrores.png");
     }
 }
Exemplo n.º 19
0
        $matches[$curTimestamp]['matches'] = '1';
        $matches[$curTimestamp]['hours'] = $curTimestamp;
    } else {
        // if we are still in the same month: 1 more match in the month
        $matches[$curTimestamp]['matches']++;
    }
    // done with this month
    $oldTimestamp = $curTimestamp;
}
// sort matches, beginning with soonest hour of day
/*	function cmp($a, $b)
	{
		if ($a['hours'] == $b['hours']) {
        		return 0;
		}
		return ($a['hours'] < $b['hours']) ? -1 : 1;
	}
*/
usort($matches, 'cmp');
//	$chart = new VerticalBarChart(1400,350);
$chart = new LineChart(690, 350);
$dataSet = new XYDataSet();
$chart->getPlot()->setGraphPadding(new Padding(5, 25, 10, 25));
// add a data point for each month
foreach ($matches as $matchesPerHour) {
    $dataSet->addPoint(new Point($matchesPerHour['hours'], $matchesPerHour['matches']));
}
$chart->setDataSet($dataSet);
$chart->setTitle("Official EIE-FF Matches Per Hour [ 01/2005 - 09/2010 ]");
$chart->render("img/matches.per.hour.eie-ff.png");
Exemplo n.º 20
0
$ybins = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
foreach ($db->loadAssocList() as $row) {
    if ($row['bin_x']) {
        $xbins[$row['bin_x'] - 1]++;
    }
    if ($row['bin_y']) {
        $ybins[$row['bin_y'] - 1]++;
    }
}
for ($x = 0; $x < 31; $x++) {
    $serie1->addPoint(new Point($x + 1, $xbins[$x]));
    $serie2->addPoint(new Point($x + 1, $ybins[$x]));
}
$dataSet = new XYSeriesDataSet();
$dataSet->addSerie("X", $serie1);
$dataSet->addSerie("Y", $serie2);
$chart->setDataSet($dataSet);
$chart->setTitle("3600 Data Points");
//$chart->render("/home/hddev3/public_html/images/render_bins.png");
?>
<div style="text-align: center">
<img src="data:image/png;base64,<?php 
$name = tempnam('.', '.png');
$chart->render($name);
echo base64_encode(file_get_contents($name));
unlink($name);
?>
">
</div>

$serie4->addPoint(new Point("06-05", 800));
$serie4->addPoint(new Point("06-06", 1000));
$serie5 = new XYDataSet();
$serie5->addPoint(new Point("06-01", 380));
$serie5->addPoint(new Point("06-02", 600));
$serie5->addPoint(new Point("06-03", 712));
$serie5->addPoint(new Point("06-04", 842));
$serie5->addPoint(new Point("06-05", 900));
$serie5->addPoint(new Point("06-06", 1200));
$dataSet = new XYSeriesDataSet();
$dataSet->addSerie("Product 1", $serie1);
$dataSet->addSerie("Product 2", $serie2);
$dataSet->addSerie("Product 3", $serie3);
$dataSet->addSerie("Product 4", $serie4);
$dataSet->addSerie("Product 5", $serie5);
$chart->setDataSet($dataSet);
$chart->setTitle("Sales for 2006");
$chart->getPlot()->setGraphCaptionRatio(0.62);
$chart->render("generated/demo6.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 line demonstration</title>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" />
</head>
<body>
	<img alt="Line chart" src="generated/demo6.png" style="border: 1px solid gray;"/>
</body>
</html>
Exemplo n.º 22
-1
function show_img_nb_session($mode_)
{
    $ret = getNB_SESSION($mode_);
    // Number of session chart
    $chart = new LineChart();
    $chart->getPlot()->setLogoFileName('');
    $dataSet = new XYDataSet();
    $step = max(round(count($ret) / MAX_STEPS), 1);
    $step_i = 0;
    foreach ($ret as $day => $num) {
        $text = $step_i % $step == 0 ? substr($day, -2) : '';
        $step_i++;
        $dataSet->addPoint(new Point($text, $num));
    }
    $chart->setDataSet($dataSet);
    $chart->setTitle(_('Number of active sessions'));
    header('Content-Type: image/png');
    $chart->render();
    die;
}