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(); }
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 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(); }
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(); }
return $a['hours'] < $b['hours'] ? -1 : 1; } 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');
<?php require "../conn/pdo.php"; require "../conn/conninfo.php"; $sensors = new conninfo($pdo); $data_sensor_name = trim($_GET["sensor"]); $lastMinutes = trim($_GET["min"]); include "../libchart/libchart/classes/libchart.php"; $chart = new LineChart(1200, 600); $dataSet = new XYDataSet(); if (strlen($data_sensor_name) > 0) { $nowtime = time(); $startDate = $nowtime - 60 * $lastMinutes; $endDate = $nowtime; $tmpList = $sensors->get_sensordata_range($data_sensor_name, $startDate, $endDate); $numX = count($tmpList) / 10; $i = 0; foreach ($tmpList as $row) { if ($i == 0) { $startTime = $row['datetime']; } $endTime = $row['datetime']; $sensorName = $row['name']; if ($i % $numX == 0) { $dataSet->addPoint(new Point(date("H:i", $row['datetime']), $row['txtdata'])); } else { $dataSet->addPoint(new Point("", $row['txtdata'])); } $i++; } }
* Time: 18:25 */ namespace graph_library; require_once '../Autoloader.php'; header('Content-Type:image/png'); $platno = new Canvas(); $podaci = new DataCollection(); $barchart = new BarChart('Cijena dionica', 295, 500); $legend = new Legend(); $legend->addItem(new LegendItem('Relativni odnos dionica zadnjih 5 godina')); $podaci->addItems(array(new DataCollectionItem([2011, 10]), new DataCollectionItem([2012, 15]), new DataCollectionItem([2013, 8]), new DataCollectionItem([2014, 19]), new DataCollectionItem([2015, 22]))); $barchart->setLegend($legend, 10, 25); $barchart->colorData(16, 80, 57, $barchart->addData($podaci)); $platno->addChart($barchart, 30, 305); $lineChart = new LineChart('Cijena dionica', 300, 300); $lineChart->setLegend($legend, 10, 30); $lineChart->colorData(16, 80, 57, $lineChart->addData($podaci)); $platno->addChart($lineChart, 2, 0); // pie chart $pieChart = new PieChart('naslov pie charta', 300, 300); $legend = new Legend(); $legend->addItem(new LegendItem('1. item legende')); $legend->addItem(new LegendItem('2. item legende')); $podatak = new DataCollection(); $podatak->addItem(new DataCollectionItem([5])); $id_podataka = $pieChart->addData($podatak); $pieChart->colorData(56, 80, 57, $id_podataka); $podatak = new DataCollection(); $podatak->addItem(new DataCollectionItem([17])); $id_podataka = $pieChart->addData($podatak);
function stats() { $this->validateRights([USER_ADMIN]); if (isset($_REQUEST['top_articles'])) { if ($t = $this->db->fetch('SELECT views FROM articles ORDER BY views DESC LIMIT 5')) { $v = [0]; foreach ($t as $a) { $v[] = $a['views']; } unset($v[0]); $this->data['image'] = new GDImage(NULL, new Size(800, 500)); $g = new BarChart(new Boundary(0, 0, $this->data['image']->size()->width, $this->data['image']->size()->height)); $g->depth(15); $g->background(new Color(255, 144, 130, 127)); $g->values(['bgcolors' => [new Color(255, 102, 91), new Color(50, 255, 0), new Color(63, 168, 255), new Color(255, 220, 22), new Color(255, 112, 238)], 'labels' => TRUE, 'thickness' => 3]); $g->data($v); $g->title(['text' => 'Топ 5 публикаций', 'color' => new Color(255, 255, 255), 'font' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Bold.ttf', 14), 'margin' => ['top' => 0, 'bottom' => 15]]); $g->axis(['font_x' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Regular.ttf', 8), 'font_y' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Regular.ttf', 8), 'bgcolor' => new Color(255, 255, 255, 100), 'fgcolor' => new Color(255, 255, 255), 'y_lines' => TRUE]); $g->max(50); $g->min(0); $g->draw($this->data['image']->getHandle()); } $this->data['subaction'] = 'image'; } else { if (isset($_REQUEST['storage_usage'])) { $this->validateArgs($_REQUEST, [['start_date', 'string'], ['end_date', 'string'], ['resolution', 'numeric']]); $s = $_REQUEST['start_date']; $e = $_REQUEST['end_date']; $r = $_REQUEST['resolution']; $v = []; if ($t = $this->db->call('show_storage_usage', [$s, $e, $r])) { $b = $t[0]['balance']; for ($i = 1; $i < count($t); $i++) { if ($r == 1) { $v[sprintf('%02d.%02d.%04d', $t[$i]['day'], $t[$i]['month'], $t[$i]['year'])] = round(($b += $t[$i]['balance']) / 1024 / 1024, 2); } else { if ($r == 2) { $v[sprintf('%02d.%04d', $t[$i]['month'], $t[$i]['year'])] = round(($b += $t[$i]['balance']) / 1024 / 1024, 2); } } } $this->data['image'] = new GDImage(NULL, new Size(800, 500)); $g = new LineChart(new Boundary(0, 0, $this->data['image']->size()->width, $this->data['image']->size()->height)); $g->depth(15); $g->background(new Color(255, 144, 130, 127)); $g->values(['bgcolors' => [new Color(0, 255, 0)], 'fgcolors' => [new Color(255, 255, 255)], 'font' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Regular.ttf', 10), 'labels' => TRUE, 'thickness' => 2]); $g->data($v); $g->title(['text' => 'Использование хранилища', 'color' => new Color(255, 255, 255), 'font' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Bold.ttf', 14), 'margin' => ['top' => 0, 'bottom' => 15]]); $g->axis(['font_x' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Regular.ttf', 8, 90), 'font_y' => new Font(PATH_ROOT . '/css/fonts/OpenSans-Regular.ttf', 8), 'bgcolor' => new Color(255, 255, 255, 100), 'fgcolor' => new Color(255, 255, 255), 'y_lines' => TRUE]); $g->draw($this->data['image']->getHandle()); } $this->data['subaction'] = 'image'; } else { if ($t = $this->db->fetch('SELECT COUNT(*) AS total_users FROM users')) { $this->data['stats']['total_users'] = $t[0]['total_users']; } if ($t = $this->db->fetch('SELECT COUNT(*) AS total_admins FROM users WHERE is_admin=1')) { $this->data['stats']['total_admins'] = $t[0]['total_admins']; } if ($t = $this->db->fetch('SELECT id, login, DATE_FORMAT(reg_date, \'%e.%m.%Y %H:%i\') AS reg_date FROM users WHERE reg_date=(SELECT MAX(reg_date) FROM users)')) { $this->data['stats']['last_user'] = $t[0]; } if ($t = $this->db->fetch('SELECT SUM(file_size) AS total_size FROM storage')) { $this->data['stats']['storage_usage'] = round($t[0]['total_size'] / 1024 / 1024, 1) . ($this->app->config['storage']['max_size'] != -1 ? ' из ' . $this->app->config['storage']['max_size'] : '') . ' МБ'; } if ($t = $this->db->fetch('SELECT COUNT(*) AS total_sections FROM sections')) { $this->data['stats']['total_sections'] = $t[0]['total_sections']; } if ($t = $this->db->fetch('SELECT COUNT(*) AS total_articles FROM articles')) { $this->data['stats']['total_articles'] = $t[0]['total_articles']; } if ($t = $this->db->fetch('SELECT COUNT(*) AS total_unverified_articles FROM articles WHERE verifier_id IS NULL')) { $this->data['stats']['total_unverified_articles'] = $t[0]['total_unverified_articles']; } if ($t = $this->db->fetch('SELECT COUNT(*) AS total_comments FROM comments')) { $this->data['stats']['total_comments'] = $t[0]['total_comments']; } if ($t = $this->db->fetch('SELECT articles.id AS id, articles.title AS title, data_folder, users.id AS user_id, login FROM articles INNER JOIN sections ON articles.section_id=sections.id INNER JOIN users ON author_id=users.id ORDER BY views DESC LIMIT 5')) { foreach ($t as &$a) { $a['href'] = $this->app->config['path']['section'] . $a['data_folder'] . '/' . $a['id'] . '/'; } unset($a); $this->data['stats']['top_articles'] = $t; } } } }
<?php /** * Created by PhpStorm. * User: martinmatak * Date: 06/03/16 * Time: 16:10 */ namespace graph_library; require_once '../Autoloader.php'; header('Content-Type:image/png'); $platno = new Canvas(); $podaci = new DataCollection(); //line chart $line_chart = new LineChart('Cijena dionica', 300, 300); $legend = new Legend(); $legend->addItem(new LegendItem('Relativni odnos dionica zadnjih 5 godina')); $podaci->addItems(array(new DataCollectionItem([2011, 10]), new DataCollectionItem([2012, 15]), new DataCollectionItem([2013, 8]), new DataCollectionItem([2014, 19]), new DataCollectionItem([2015, 22]))); $line_chart->setLegend($legend, 10, 100); $id_podataka = $line_chart->addData($podaci); $line_chart->colorData(16, 80, 57, $id_podataka); $platno->addChart($line_chart, 0, 0); //pie chart $line_chart = new PieChart('Naslov pie charta', 300, 300); $pieLegend = new Legend(); $pieLegend->addItem(new LegendItem('1. item legende')); $pieLegend->addItem(new LegendItem('2. item legende')); $line_chart->setLegend($pieLegend, 200, 100); $podatak = new DataCollection(); $podatak->addItem(new DataCollectionItem([5]));
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 />'; } }
<div id="first_row" class="row"> <div class="col-sm-8"></div> <div class="col-sm-2"></div> <div class="col-sm-2"><a id="back" href="<?php echo "dashboard.php?id=" . $dashboard_id; ?> ">返回表盘</a></div> </div> <hr> <div class="row"> <div class="col-sm-1"></div> <div class="col-sm-10"><div class="row"> <?php #linechart echo "<div class='col-sm-6'>"; $line_chart = new LineChart(); $line_panel = new Panel(); $line_chart->demo(); $line_panel->data["content"] = "<div class='ichart' id='chart1'></div>"; $line_panel->addOptionCreate(); $line_panel->show(); echo '<script>' . '$("#chart1").highcharts(' . $line_chart->getChartJson() . ');' . '</script>'; echo "</div>"; #ColumnChart echo "<div class='col-sm-6'>"; $column_chart = new ColumnChart(); $column_panel = new Panel(); $column_chart->demo(); $column_panel->data["content"] = "<div class='ichart' id='chart2'></div>"; $column_panel->addOptionCreate(); $column_panel->show();
$remuneracao_real = floor($remuneracao_real / 1000); $reembolso = floor($item['reembolso'] / 1000); $reembolso_real = floor($reembolso_real / 1000); $remuneracao = floor($item['remuneracao'] / 1000); $serie1->addPoint(new Point($mes . "- G" . $item['grupo'], $remuneracao)); $serie3->addPoint(new Point($mes . "- G" . $item['grupo'], $remuneracao_real)); $serie2->addPoint(new Point($mes . "- G" . $item['grupo'], $reembolso)); $serie4->addPoint(new Point($mes . "- G" . $item['grupo'], $reembolso_real)); } $ano_grafico = $acompanhamento->getAno(); } //$chart = new VerticalBarChart(1480,450); if ($acompanhamento->getGrafico() == 1) { $chart = new VerticalBarChart(1390, 390); } else { $chart = new LineChart(1480, 450); } $dataSet = new XYSeriesDataSet(); if ($acompanhamento->getRemuneracao() != null) { $dataSet->addSerie("Remuneração Previsto", $serie1); //Legenda do grafico $dataSet->addSerie("Remuneração Realizado", $serie3); //Legenda do grafico } 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) {
} if (isset($REQUEST['cmd']) && $REQUEST['cmd'] == 'REPORT_IMAGE') { $width = 600; $height = 400; error_reporting(0); header("Content-type: image/png"); require_once LIBRARIES . "libchart" . PATH_SEP . "libchart.php"; if ($REQUEST['type'] == "pie") { $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") {
<div class="box-header"><i class="fa fa-bar-chart-o"></i><h3 class="box-title">Les réservations par classe d'âge, année <?php echo $year; ?> </h3></div> <div class="box-body"> <table class="table"> <thead><tr><th>Mois</th> <th>Enfants - de 14 ans</th> <th>Adolescents(15-25)</th> <th>Adultes</th> <th>% par mois</th></tr></thead><tbody> <?php //initialisation graphique// $chartCA = new LineChart(600, 250); $dataSetCA = new XYSeriesDataSet(); $serie1 = new XYDataSet(); $serie2 = new XYDataSet(); $serie3 = new XYDataSet(); for ($i = 1; $i <= $month; ++$i) { $nbTr1 = getStatFrequenceTypeAbo($i, 1, 14, $year); $nbTr2 = getStatFrequenceTypeAbo($i, 15, 25, $year); $nbTr3 = getStatFrequenceTypeAbo($i, 20, 99, $year); //donnees du graphique $serie1->addPoint(new Point(getMonth($i), $nbTr1)); $serie2->addPoint(new Point(getMonth($i), $nbTr2)); $serie3->addPoint(new Point(getMonth($i), $nbTr3)); $row2 = getStatHeureTypeAbo($year, $i); $hparm = ceil($row2 * 100 / 56160); echo '<tr>
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * Multiple line chart demonstration. * */ include "../../../COCONUT/libchart/libchart/classes/libchart.php"; $chart = new LineChart("1200", "500"); $ro = new database1(); $serie1 = new XYDataSet(); $serie1->addPoint(new Point("Jan {$year}", $ro->getAnnualInventory("01", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Feb {$year}", $ro->getAnnualInventory("02", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Mar {$year}", $ro->getAnnualInventory("03", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Apr {$year}", $ro->getAnnualInventory("04", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("May {$year}", $ro->getAnnualInventory("05", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Jun {$year}", $ro->getAnnualInventory("06", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Jul {$year}", $ro->getAnnualInventory("07", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Aug {$year}", $ro->getAnnualInventory("08", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Sep {$year}", $ro->getAnnualInventory("09", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Oct {$year}", $ro->getAnnualInventory("10", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Nov {$year}", $ro->getAnnualInventory("11", $year, $description, $inventoryCode, "IPD") / 1000)); $serie1->addPoint(new Point("Dec {$year}", $ro->getAnnualInventory("12", $year, $description, $inventoryCode, "IPD") / 1000)); $serie2 = new XYDataSet();
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"); } }
* This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ /** * Line demonstration * */ include "../libchart.php"; $chart = new LineChart(); $chart->addPoint(new Point("06-01", 273)); $chart->addPoint(new Point("06-02", 421)); $chart->addPoint(new Point("06-03", 642)); $chart->addPoint(new Point("06-04", 799)); $chart->addPoint(new Point("06-05", 1009)); $chart->addPoint(new Point("06-06", 1406)); $chart->addPoint(new Point("06-07", 1820)); $chart->addPoint(new Point("06-08", 2511)); $chart->addPoint(new Point("06-09", 2832)); $chart->addPoint(new Point("06-10", 3550)); $chart->addPoint(new Point("06-11", 4143)); $chart->addPoint(new Point("06-12", 4715)); $chart->setTitle("Sales for 2006"); $chart->render("generated/demo5.png"); ?>
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * Multiple line chart demonstration. * */ include "../../../COCONUT/libchart/libchart/classes/libchart.php"; $chart = new LineChart("1500", "500"); $ro = new database1(); $serie1 = new XYDataSet(); $serie1->addPoint(new Point("Jan {$year}", $ro->getAnnualSenior("01", $year, "IPD"))); $serie1->addPoint(new Point("Feb {$year}", $ro->getAnnualSenior("02", $year, "IPD"))); $serie1->addPoint(new Point("Mar {$year}", $ro->getAnnualSenior("03", $year, "IPD"))); $serie1->addPoint(new Point("Apr {$year}", $ro->getAnnualSenior("04", $year, "IPD"))); $serie1->addPoint(new Point("May {$year}", $ro->getAnnualSenior("05", $year, "IPD"))); $serie1->addPoint(new Point("Jun {$year}", $ro->getAnnualSenior("06", $year, "IPD"))); $serie1->addPoint(new Point("Jul {$year}", $ro->getAnnualSenior("07", $year, "IPD"))); $serie1->addPoint(new Point("Aug {$year}", $ro->getAnnualSenior("08", $year, "IPD"))); $serie1->addPoint(new Point("Sep {$year}", $ro->getAnnualSenior("09", $year, "IPD"))); $serie1->addPoint(new Point("Oct {$year}", $ro->getAnnualSenior("10", $year, "IPD"))); $serie1->addPoint(new Point("Nov {$year}", $ro->getAnnualSenior("11", $year, "IPD"))); $serie1->addPoint(new Point("Dec {$year}", $ro->getAnnualSenior("12", $year, "IPD"))); $serie2 = new XYDataSet();
/** * 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"); } }
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * Multiple line chart demonstration. * */ include "../libchart/classes/libchart.php"; $chart = new LineChart(); $serie1 = new XYDataSet(); $serie1->addPoint(new Point("06-01", 273)); $serie1->addPoint(new Point("06-02", 421)); $serie1->addPoint(new Point("06-03", 642)); $serie1->addPoint(new Point("06-04", 799)); $serie1->addPoint(new Point("06-05", 1009)); $serie1->addPoint(new Point("06-06", 1106)); $serie2 = new XYDataSet(); $serie2->addPoint(new Point("06-01", 280)); $serie2->addPoint(new Point("06-02", 300)); $serie2->addPoint(new Point("06-03", 212)); $serie2->addPoint(new Point("06-04", 542)); $serie2->addPoint(new Point("06-05", 600)); $serie2->addPoint(new Point("06-06", 850)); $serie3 = new XYDataSet();
<?php defined('_JEXEC') or die; ini_set('display_errors', 1); error_reporting(E_ALL); include "libchart/libchart/classes/libchart.php"; $chart = new LineChart(650, 200); $db = JFactory::getDBO(); $query = <<<QUERY SELECT bin_x, bin_y FROM fleet_acceleration WHERE bin_x AND bin_y ORDER BY date DESC LIMIT 3600 QUERY; $db->setQuery($query); $serie1 = new XYDataSet(); $serie2 = new XYDataSet(); $xbins = 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); $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]));
$d = array(); for ($i = 0; $i < $w; $i++) { if (!isset($seires[$key][$i . ""])) { $seires[$key][$i . ""] = 0; } $d[$i] = (int) $seires[$key][$i . ""]; } //补齐未过日期的值(null 是无线) // for($i=$w;$i<7;$i++){ // if(!isset($seires[$key][$i.""])) { // $seires[$key][$i.""]=null; // } // $d[$i]=$seires[$key][$i.""]; // } array_push($data, array("name" => $key, "data" => $d)); } //设置图表参数 $chart_lw = new LineChart(); $chart_lw->data["chart"]["type"] = "line"; $chart_lw->data["title"] = array("text" => "缺陷发展趋势"); $chart_lw->data["subtitle"] = array("text" => "本周缺陷发展趋势"); $chart_lw->data["xAxis"] = array("title" => array("text" => "(单位:当前周)"), "categories" => array("星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日")); $chart_lw->data["yAxis"] = array("title" => array("text" => "新增缺陷数(个)")); $chart_lw->data["series"] = $data; echo $chart_lw->getChartJson(); } } } } } }
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * Multiple line chart demonstration. * */ include "../../../COCONUT/libchart/libchart/classes/libchart.php"; $chart = new LineChart("1500", "500"); $ro = new database1(); $serie1 = new XYDataSet(); $serie1->addPoint(new Point("Jan {$year}", $ro->getGenderAnnual("01", $year, "male", "OPD"))); $serie1->addPoint(new Point("Feb {$year}", $ro->getGenderAnnual("02", $year, "male", "OPD"))); $serie1->addPoint(new Point("Mar {$year}", $ro->getGenderAnnual("03", $year, "male", "OPD"))); $serie1->addPoint(new Point("Apr {$year}", $ro->getGenderAnnual("04", $year, "male", "OPD"))); $serie1->addPoint(new Point("May {$year}", $ro->getGenderAnnual("05", $year, "male", "OPD"))); $serie1->addPoint(new Point("Jun {$year}", $ro->getGenderAnnual("06", $year, "male", "OPD"))); $serie1->addPoint(new Point("Jul {$year}", $ro->getGenderAnnual("07", $year, "male", "OPD"))); $serie1->addPoint(new Point("Aug {$year}", $ro->getGenderAnnual("08", $year, "male", "OPD"))); $serie1->addPoint(new Point("Sep {$year}", $ro->getGenderAnnual("09", $year, "male", "OPD"))); $serie1->addPoint(new Point("Oct {$year}", $ro->getGenderAnnual("10", $year, "male", "OPD"))); $serie1->addPoint(new Point("Nov {$year}", $ro->getGenderAnnual("11", $year, "male", "OPD"))); $serie1->addPoint(new Point("Dec {$year}", $ro->getGenderAnnual("12", $year, "male", "OPD"))); $serie2 = new XYDataSet();
* * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ /** * Line chart demonstration * */ include "../libchart/classes/libchart.php"; $chart = new LineChart(); $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("06-01", 273)); $dataSet->addPoint(new Point("06-02", 421)); $dataSet->addPoint(new Point("06-03", 642)); $dataSet->addPoint(new Point("06-04", 799)); $dataSet->addPoint(new Point("06-05", 1009)); $dataSet->addPoint(new Point("06-06", 1406)); $dataSet->addPoint(new Point("06-07", 1820)); $dataSet->addPoint(new Point("06-08", 2511)); $dataSet->addPoint(new Point("06-09", 2832)); $dataSet->addPoint(new Point("06-10", 3550)); $dataSet->addPoint(new Point("06-11", 4143)); $dataSet->addPoint(new Point("06-12", 4715)); $chart->setDataSet($dataSet); $chart->setTitle("Sales for 2006");
public static function _getReportChart($report, $start_date, $end_date, $frequency, $decorator = null) { $line_chart = new LineChart(); $line_chart->setTitle($report->getTitle()); $series = new Series(); $temp = ReportPeer::getQueryResults($report->getId(), $start_date, $end_date, $frequency); if (self::isEmpty($temp)) { return null; } $titles = $report->getQueryTitles(); $arrays = ReportPeer::fillWithEmptyValues($temp, $start_date, $end_date, $frequency); for ($i = 0; $i < sizeof($arrays); $i++) { $series->addSerie(new Serie(array_values($arrays[$i]), $titles[$i])); } $factors = Utils::find_factors(sizeof($arrays[0]) - 1, 7); $factor = $factors[sizeof($factors) - 1]; $labels = array(); for ($j = 0; $j < $factor + 1; $j++) { $labels[] = $j + 1; } $temp = array_keys($arrays[0]); for ($j = 0; $j < sizeof($labels); $j++) { if ($frequency == QueryResultPeer::FREQUENCY_MONTH) { $labels[$j] = date('M y', strtotime($temp[$j * (sizeof($arrays[0]) - 1) / $factor])); } else { $labels[$j] = $temp[$j * (sizeof($arrays[0]) - 1) / $factor]; } } $series->setXLabels($labels); $series->autoSetYLabels(5); $series->normalize(); $line_chart->setSeries($series); if ($decorator) { $decorator->decorate($line_chart); } return array('values' => $arrays, 'chart' => $line_chart); }
} $counter++; } //We set the line chart's dataset and render the graph $chart->setDataSet($dataSet); $chart->setTitle("Connections per day"); $chart->render("generated-graphs/connections_per_day.png"); } //----------------------------------------------------------------------------------------------------------------- //CONNECTIONS PER WEEK //----------------------------------------------------------------------------------------------------------------- $db_query = "SELECT COUNT(*), MAKEDATE(\n CASE\n WHEN WEEKOFYEAR(date_time) = 52\n THEN YEAR(date_time)-1\n ELSE YEAR(date_time)\n END, (WEEKOFYEAR(date_time) * 7)-4) AS DateOfWeek_Value\n FROM connections\n GROUP BY WEEKOFYEAR(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 $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(*)']));
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 />'; } }
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; }
public function lineChartHamSpam($timespan, $title, $size_x, $size_y, $output) { $ydata = array(); $ydata2 = array(); $dates = array(); $session = Registry::get('session'); $chart = new LineChart($size_x, $size_y); $chart->getPlot()->getPalette()->setLineColor(array(new Color(208, 48, 128))); $line1 = new XYDataSet(); $limit = $this->getDataPoints($timespan); $range = $this->getRangeInSeconds($timespan); if ($timespan == "daily") { $grouping = "GROUP BY FROM_UNIXTIME(ts, '%Y.%m.%d. %H')"; } else { $grouping = "GROUP BY FROM_UNIXTIME(ts, '%Y.%m.%d.')"; } if ($timespan == "daily") { $delta = 3600; $date_format = "H:i"; } else { $delta = 86400; $date_format = "m.d."; } if (Registry::get('admin_user') == 0) { $q = ''; $auditdomains = $session->get('auditdomains'); foreach ($auditdomains as $a) { if ($q) { $q .= ",?"; } else { $q = "?"; } } reset($auditdomains); $query = $this->db->query("select arrived-(arrived%{$delta}) as ts, count(*) as num from " . VIEW_MESSAGES . " where arrived > {$range} AND todomain IN ({$q}) {$domains} {$grouping} ORDER BY ts DESC limit {$limit}", $auditdomains); } else { $query = $this->db->query("select arrived-(arrived%{$delta}) as ts, count(*) as num from " . TABLE_META . " where arrived > {$range} {$grouping} ORDER BY ts DESC limit {$limit}"); } foreach ($query->rows as $q) { array_push($ydata, $q['num']); array_push($dates, date($date_format, $q['ts'])); } if ($query->num_rows >= 15) { $i = 0; while (list($k, $v) = each($dates)) { $i++; if ($i % 3) { $dates[$k] = ""; } } reset($dates); } $ydata = array_reverse($ydata); $dates = array_reverse($dates); for ($i = 0; $i < count($ydata); $i++) { $ts = $dates[$i]; $line1->addPoint(new Point("{$ts}", $ydata[$i])); } $dataSet = new XYSeriesDataSet(); $dataSet->addSerie("RCVD", $line1); $chart->setDataSet($dataSet); $chart->setTitle($title); $chart->getPlot()->setGraphCaptionRatio(0.8); $this->sendOutput($chart, $output); }