/** * Renders the chart * @param IUser $logged_user * @return string */ function render(IUser $logged_user) { $db_result = DB::execute("SELECT milestone_id, COUNT(*) as count FROM " . TABLE_PREFIX . "project_objects WHERE project_id = ? AND type='Task' AND state >= ? AND visibility >= ? GROUP BY milestone_id", $this->project->getId(), STATE_VISIBLE, $logged_user->getMinVisibility()); $array_result = $db_result instanceof DBResult ? $db_result->toArrayIndexedBy('milestone_id') : false; if (is_foreachable($array_result)) { $pie_chart = new PieChart('400px', '400px', 'milestone_eta_report_pie_chart_placeholder'); $this->serie_array = array(); $this->milestones = array(); // Set data for the rest foreach ($array_result as $serie_data) { $point = new ChartPoint('1', $serie_data['count']); $serie = new ChartSerie($point); if (intval($serie_data['milestone_id'])) { $milestone = new RemediaMilestone(intval($serie_data['milestone_id'])); $label = PieChart::makeShortForPieChart($milestone->getName()); $this->milestones[] = $milestone; } else { $label = lang('No Milestone'); } //if $serie->setOption('label', $label); $this->serie_array[] = $serie; } //foreach $pie_chart->addSeries($this->serie_array); return $pie_chart->render(); } else { return '<p class="empty_slate">' . lang('There are no milestones in this project.') . '</p>'; } //if }
public function pieChartHamSpam($emails = '', $timespan, $title, $output) { $ham = $spam = 0; $range = $this->getRangeInSeconds($timespan); $chart = new PieChart(SIZE_X, SIZE_Y); $query = $this->db->query("SELECT COUNT(*) AS SPAM FROM " . TABLE_META . " WHERE {$emails} AND arrived > {$range}"); if ($query->num_rows > 0) { $spam = $query->row['SPAM']; } $query = $this->db->query("SELECT COUNT(*) AS HAM FROM " . TABLE_META . " WHERE {$emails} AND arrived > {$range}"); if ($query->num_rows > 0) { $ham = $query->row['HAM']; } if ($ham > $spam) { $chart->getPlot()->getPalette()->setPieColor(array(new Color(26, 192, 144), new Color(208, 48, 128))); } else { $chart->getPlot()->getPalette()->setPieColor(array(new Color(208, 48, 128), new Color(26, 192, 144))); } $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("HAM ({$ham})", $ham)); $dataSet->addPoint(new Point("SPAM ({$spam})", $spam)); $chart->setDataSet($dataSet); $chart->setTitle($title); $this->sendOutput($chart, $output); }
/** * Create a PieChart * * @param array $data associative array contianing label and values */ protected function PieChart($data) { $DataSet = new pData(); $Canvas = new GDCanvas(400, 200, false); $Chart = new PieChart(400, 200, $Canvas); $Chart->setFontProperties(dirname(__FILE__) . '/pchart/Fonts/DroidSans.ttf', 8); $DataSet->AddPoints(array_values($data), 'Serie1'); $DataSet->AddPoints(array_keys($data), 'Serie2'); $DataSet->AddAllSeries(); $DataSet->SetAbscissaLabelSeries("Serie2"); $Chart->drawBasicPieGraph($DataSet->getData(), $DataSet->GetDataDescription(), 120, 100, 60, PIE_PERCENTAGE); $Chart->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); header('Content-Type: image/png'); $Chart->Render(''); }
function age() { if ($this->Session->read('Policy') <= 2) { $this->redirect(array('controller' => 'users', 'action' => 'login')); return; } $sqlage = "SELECT YEAR( CURRENT_DATE( ) ) - YEAR( users.birthday ) AS age, COUNT( * ) AS count\r\n FROM users\r\n GROUP BY (\r\n YEAR( CURRENT_DATE( ) ) - YEAR( users.birthday )\r\n )"; $data = $this->query($sqlage); $chart = new PieChart(); $dataSet = new XYDataSet(); while ($row = mysql_fetch_array($data)) { $dataSet->addPoint(new Point("Age :" . $row[0] . "(" . $row[1] . ")", $row[1])); } $chart->setDataSet($dataSet); $chart->setTitle("Report age"); $chart->render("../webroot/img/age.png"); }
/** * @author Ibnu Daqiqil Id * @param string $title Judul Chart * @param array $data Data array dengan dua dimensi (key,value) * @param integer $x Lebar chart * @param integer $y Tinggi Chart * @param string $type tipe output chart (bar_vertikal,bar_horizontal,pie) * @param boolean $render Apakah di render ke file? */ function create_bar_chart($title, $data, $x = 500, $y = 300, $type = "bar_vertikal", $render_file = FALSE) { if ("bar_horizontal" == $type) { $chart = new HorizontalBarChart($x, $y); } else { if ("bar_vertikal" == $type) { $chart = new VerticalBarChart($x, $y); } else { $chart = new PieChart($x, $y); } } $dataSet = new XYDataSet(); foreach ($data as $value) { $dataSet->addPoint(new Point($value['key'], $value['value'])); } $chart->setDataSet($dataSet); $chart->setTitle($title); if (!$render_file) { return $chart->render(); } else { return $chart->render($render_file); } }
public function execute($request) { $this->data = $this->getGraphService()->getEmployeeCountBySubUnit(); if (count($this->data) > 0) { $pieChart = new PieChart(); $pieChart->setChartNumber('emp_distribution'); $pieChart->setWidth(300); $pieChart->setHeight(225); $pieChart->setStyles(array('margin-top' => '10px')); $dataFormatter = new GraphDataFormatter(); $dataFormatter->setGroupMappings(array('default-label' => '---', 'label-index' => 'name', 'value-index' => 'COUNT')); $pieChart->setDataFormatter($dataFormatter); $metaDataObject = new GraphMetaData(); $legend = new GraphLegendData(); $legend->setLegendDivId('div_legend_pim_employee_distribution'); $legend->setUseSeparateContainer(true); $legend->setLabels($dataFormatter->extractLabels($this->data, 'name')); $metaDataObject->setLegend($legend); $pieChart->setData($this->data); $pieChart->setPropertes(array('show-legend' => true, 'show-labels' => true, 'interactive' => true, 'suffixForValueHover' => 'Employee(s)')); $pieChart->setMetaDataObject($metaDataObject); $this->chart = $pieChart; } }
//top, right, bottom, left | defaults: 5, 30, 50, 50 $chart->render("generated-graphs/icmp_connections_per_ip.png"); //We set the pie chart's dataset and render the graph $pie_chart->setDataSet($dataSet); $pie_chart->setTitle("Number of ICMP connections per unique IP (Top 10)"); $pie_chart->render("generated-graphs/icmp_connections_per_ip_pie.png"); } //----------------------------------------------------------------------------------------------------------------- //CONNECTIONS BY DESTINATION PORTS //----------------------------------------------------------------------------------------------------------------- $db_query = "SELECT dest_port, COUNT(dest_port), proto\n FROM connections\n GROUP BY dest_port\n ORDER BY COUNT(dest_port) DESC "; $rows = R::getAll($db_query); if (count($rows)) { //We create a new vertical bar chart,a new pie chart and initialize the dataset $chart = new VerticalBarChart(600, 300); $pie_chart = new PieChart(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['dest_port'] . " / " . $row['proto'], $row['COUNT(dest_port)'])); } //We set the bar chart's dataset and render the graph $chart->setDataSet($dataSet); $chart->setTitle("Number of connections by destination port"); $chart->render("generated-graphs/connections_by_dest_port.png"); //We set the pie chart's dataset and render the graph $pie_chart->setDataSet($dataSet); $pie_chart->setTitle("Number of connections by destination port"); $pie_chart->render("generated-graphs/connections_by_dest_port_pie.png"); } //-----------------------------------------------------------------------------------------------------------------
* * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ********************************************************************************************************* * Description: * this extension creates a pie chart of the comparison of hotspots per unique users * * Authors: Liran Tal <*****@*****.**> * ********************************************************************************************************* */ include 'checklogin.php'; include 'opendb.php'; include 'libchart/libchart.php'; header("Content-type: image/png"); $chart = new PieChart(620, 320); // getting total downloads of days in a month $sql = "SELECT " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".name, count(distinct(UserName)), count(radacctid), " . " avg(AcctSessionTime), sum(AcctSessionTime) FROM " . $configValues['CONFIG_DB_TBL_RADACCT'] . " JOIN " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . " ON (" . $configValues['CONFIG_DB_TBL_RADACCT'] . ".calledstationid LIKE " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".mac) GROUP BY " . $configValues['CONFIG_DB_TBL_DALOHOTSPOTS'] . ".name;"; $res = $dbSocket->query($sql); while ($row = $res->fetchRow()) { $chart->addPoint(new Point("{$row['0']} ({$row['3']} seconds)", "{$row['3']}")); } $chart->setTitle("Distribution of Time usage per Hotspot"); $chart->render(); include 'closedb.php'; ?>
* 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 * */ /** * Vertical bars demonstration * */ include "../libchart.php"; $chart = new PieChart(); $chart->addPoint(new Point("Mozilla Firefox (80)", 80)); $chart->addPoint(new Point("Konqueror (75)", 75)); $chart->addPoint(new Point("Opera (50)", 50)); $chart->addPoint(new Point("Safari (37)", 37)); $chart->addPoint(new Point("Dillo (37)", 37)); $chart->addPoint(new Point("Other (72)", 70)); $chart->setTitle("User agents for www.example.com"); $chart->render("generated/demo3.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>Libcharts pie chart demonstration</title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" /> </head>
if (($handle = fopen($csvfile, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; for ($c = 0; $c < $num; $c++) { if ($c % 2) { array_push($count, $data[$c]); } else { array_push($matchtype, $data[$c]); } } } } require_once "/var/www/ChartDirector/lib/phpchartdir.php"; # Create a PieChart object of size 360 x 300 pixels $c = new PieChart(780, 390); # Set the center of the pie at (180, 140) and the radius to 100 pixels $c->setPieSize(410, 215, 195); # Add a title to the pie chart $c->addTitle($display_date); # Set the color palette $colors = array(0x3e8e35, 0x8fc28a, 0x2c7524, 0xe38919, 0xf8930d, 0xa86916, 0xc2965d); # Set the font $c->setLabelStyle("arial.ttf", 10); # Set the sector colors $c->setColors2(DataColor, $colors); # Set the gradient $c->setSectorStyle(LocalGradientShading); # Draw the pie in 3D $c->set3D(); $c->addLegend(0, 0);
public function printShockpotGeoData() { $db_query = "SELECT source_ip, COUNT(source_ip) AS count\n FROM connections\n GROUP BY source_ip\n ORDER BY COUNT(source_ip) DESC\n LIMIT 10 "; $rows = R::getAll($db_query); if (count($rows)) { //We create a new vertical bar chart, a new pie chart and initialize the dataset $verticalChart = new VerticalBarChart(600, 300); $pieChart = new PieChart(600, 300); $dataSet = new XYDataSet(); //We create a "intensity" pie chart as well along with a dataset $intensityPieChart = new PieChart(600, 300); $intensityDataSet = new XYDataSet(); //We create a new Google Map and initialize its columns, //where the decoded geolocation data will be entered in the format //of Lat(number), Lon(number) and IP(string) $gMapTop10 = new QMapGoogleGraph(); $gMapTop10->addColumns(array(array('number', 'Lat'), array('number', 'Lon'), array('string', 'IP'))); //We create a new Intensity Map and initialize its columns, //where the decoded geolocation data will be entered in the format //of Country(2 letter string), #Probes(number) $intensityMap = new QIntensitymapGoogleGraph(); $intensityMap->addDrawProperties(array("title" => 'IntensityMap')); $intensityMap->addColumns(array(array('string', '', 'Country'), array('number', '#Probes', 'a'))); //We create a temporary table in the database where we will store the IPs along with their #probes //and the corresponding country code, otherwise the Intensity Map won't work, because we need to //GROUP BY country code and SUM the #Probers per country $temp_table = 'CREATE TEMPORARY TABLE temp_ip (ip TEXT, counter INTEGER, country TEXT)'; R::exec($temp_table); //We create a dummy counter to use for the markers' tooltip inside Google Map like: IP 3/10 //We use the same counter for the IP <table> as well $counter = 1; //We create a skeleton for the table echo '<p>The following table displays the top 10 IP addresses connected to the system (ordered by volume of connections).</p>'; echo '<table><thead>'; echo '<tr class="dark">'; echo '<th>ID</th>'; echo '<th>IP Address</th>'; echo '<th>Probes</th>'; echo '<th>City</th>'; echo '<th>Region</th>'; echo '<th>Country Name</th>'; echo '<th>Code</th>'; echo '<th>Latitude</th>'; echo '<th>Longitude</th>'; echo '<th>Hostname</th>'; echo '<th colspan="9">IP Lookup</th>'; echo '</tr></thead><tbody>'; //We need to add data on the correct Map columns. The columns are always 0 or 1 or 2 for every repetition //so we can hardcode it into our code, but we need a way to automatically increase the row index. So we //create a dummy index variable to be increased after every repetition (as many db results we have) $col = 0; //For every row returned from the database... foreach ($rows as $row) { //We create a new GeoDataObject which geolocates the IP address $geodata = new GeoDataObject($this, $row['source_ip']); //We prepare the label for our vertical bar chart and add the point $label = $row['source_ip'] . " - " . $geodata->countryCode; $dataSet->addPoint(new Point($label, $row['count'])); //We next prepare the marker's tooltip inside Google Map $tooltip = "<strong>TOP {$counter}/10:</strong> " . $row['source_ip'] . "<br />" . "<strong>Probes:</strong> " . $row['count'] . "<br />" . "<strong>City:</strong> " . $geodata->city . "<br />" . "<strong>Region:</strong> " . $geodata->region . "<br />" . "<strong>Country:</strong> " . $geodata->countryName . "<br />" . "<strong>Latitude:</strong> " . $geodata->latitude . "<br />" . "<strong>Longitude:</strong> " . $geodata->longitude . "<br />"; //And add the marker to the map $gMapTop10->setValues(array(array($col, 0, (double) $geodata->latitude), array($col, 1, (double) $geodata->longitude), array($col, 2, $tooltip))); //We prepare the data that will be inserted in our temporary table $ip = $row['source_ip']; $ip_count = $row['count']; $country_code = $geodata->countryCode; $country_query = "INSERT INTO temp_ip VALUES('{$ip}', '{$ip_count}', '{$country_code}')"; R::exec($country_query); //For every row returned from the database we create a new table row with the data as columns echo '<tr class="light">'; echo '<td>' . $counter . '</td>'; echo '<td>' . $row['source_ip'] . '</td>'; echo '<td>' . $row['count'] . '</td>'; echo '<td>' . $geodata->city . '</td>'; echo '<td>' . $geodata->region . '</td>'; echo '<td>' . $geodata->countryName . '</td>'; echo '<td>' . $geodata->countryCode . '</td>'; echo '<td>' . $geodata->latitude . '</td>'; echo '<td>' . $geodata->longitude . '</td>'; echo '<td>' . get_host($row['source_ip']) . '</td>'; echo '<td class="icon"><a href="http://www.dshield.org/ipinfo.html?ip=' . $row['source_ip'] . '" target="_blank"><img class="icon" src="images/dshield.ico"/></a></td>'; echo '<td class="icon"><a href="http://www.ipvoid.com/scan/' . $row['source_ip'] . '" target="_blank"><img class="icon" src="images/ipvoid.ico"/></a></td>'; echo '<td class="icon"><a href="http://www.robtex.com/ip/' . $row['source_ip'] . '.html" target="_blank"><img class="icon" src="images/robtex.ico"/></a></td>'; echo '<td class="icon"><a href="http://www.fortiguard.com/ip_rep/index.php?data=' . $row['source_ip'] . '&lookup=Lookup" target="_blank"><img class="icon" src="images/fortiguard.ico"/></a></td>'; echo '<td class="icon"><a href="http://labs.alienvault.com/labs/index.php/projects/open-source-ip-reputation-portal/information-about-ip/?ip=' . $row['source_ip'] . '" target="_blank"><img class="icon" src="images/alienvault.ico"/></a></td>'; echo '<td class="icon"><a href="http://www.reputationauthority.org/lookup.php?ip=' . $row['source_ip'] . '" target="_blank"><img class="icon" src="images/watchguard.ico"/></a></td>'; echo '<td class="icon"><a href="http://www.mcafee.com/threat-intelligence/ip/default.aspx?ip=' . $row['source_ip'] . '" target="_blank"><img class="icon" src="images/mcafee.ico"/></a></td>'; echo '<td class="icon"><a href="http://www.ip-adress.com/ip_tracer/' . $row['source_ip'] . '" target="_blank"><img class="icon" src="images/ip_tracer.png"/></a></td>'; echo '<td class="icon"><a href="https://www.virustotal.com/en/ip-address/' . $row['source_ip'] . '/information/" target="_blank"><img class="icon" src="images/virustotal.ico"/></a></td>'; echo '</tr>'; //Lastly, we increase the index used by maps to indicate the next row, //and the dummy counter that indicates the next IP index (out of 10) $col++; $counter++; } //Close tbody and table element, it's ready. echo '</tbody></table>'; echo '<hr /><br />'; //While still inside the if(count($rows)) clause (otherwise the dataSet will be empty), //we set the bar chart's dataset, render the graph and display it (we're inside html code!) $verticalChart->setDataSet($dataSet); $verticalChart->setTitle(NUMBER_OF_CONNECTIONS_PER_UNIQUE_IP_CC); //For this particular graph we need to set the corrent padding $verticalChart->getPlot()->setGraphPadding(new Padding(5, 50, 100, 50)); //top, right, bottom, left | defaults: 5, 30, 50, 50 $verticalChart->render("generated-graphs/connections_per_ip_geo.png"); echo '<p>The following vertical bar chart visualizes the top 10 IPs ordered by the number of connections to the system.' . '<br/>Notice the two-letter country code to after each IP get a quick view of the locations where the attacks are coming from.</p>'; echo '<img src="generated-graphs/connections_per_ip_geo.png">'; //We set the pie chart's dataset, render the graph and display it (we're inside html code!) $pieChart->setDataSet($dataSet); $pieChart->setTitle(NUMBER_OF_CONNECTIONS_PER_UNIQUE_IP_CC); $pieChart->render("generated-graphs/connections_per_ip_geo_pie.png"); echo '<p>The following pie chart visualizes the top 10 IPs ordered by the number of connections to the system.' . '<br/>Notice the two-letter country code to after each IP get a quick view of the locations where the attacks are coming from.</p>'; echo '<img src="generated-graphs/connections_per_ip_geo_pie.png">'; echo '<hr /><br />'; //Charts are ready, so is Google Map, let's render it below echo '<p>The following zoomable world map marks the geographic locations of the top 10 IPs according to their latitude and longitude values. ' . 'Click on them to get the full information available from the database.<p>'; //echo '<div align=center>'; echo $gMapTop10->render(); //echo '</div>'; echo '<br/><hr /><br />'; //Lastly, we prepare the data for the Intesity Map $db_query_map = "SELECT country, SUM(counter) AS sum\n FROM temp_ip\n GROUP BY country\n ORDER BY SUM(counter) DESC "; //LIMIT 10 "; $rows = R::getAll($db_query_map); if (count($rows)) { $col = 0; //Dummy row index //For every row returned from the database add the values to Intensity Map's table and intensityPieChart foreach ($rows as $row) { $countryProbes = $row['country'] . " - " . $row['sum']; $intensityDataSet->addPoint(new Point($countryProbes, $row['sum'])); $intensityMap->setValues(array(array($col, 0, (string) $row['country']), array($col, 1, (int) $row['sum']))); $col++; } } //Intensity Map is ready, render it echo '<p>The following Intensity Map shows the volume of attacks per country by summarising probes originating from the same nation, using the same IP or not.</p>'; echo $intensityMap->render(); echo '<br/>'; //We set the "intensity" pie chart's dataset, render the graph and display it (we're inside html code!) $intensityPieChart->setDataSet($intensityDataSet); $intensityPieChart->setTitle(NUMBER_OF_CONNECTIONS_PER_COUNTRY); $intensityPieChart->render("generated-graphs/connections_per_country_pie.png"); echo '<p>The following pie chart visualizes the volume of attacks per country by summarising probes originating from the same nation, using the same IP or not.</p>'; echo '<img src="generated-graphs/connections_per_country_pie.png">'; if (GEO_METHOD == 'LOCAL') { echo '<hr /><small><a href="http://www.maxmind.com">http://www.maxmind.com</a></small><br />'; } else { if (GEO_METHOD == 'GEOPLUGIN') { echo '<hr /><small><a href="http://www.geoplugin.com/geolocation/" target="_new">IP Geolocation</a> by <a href="http://www.geoplugin.com/" target="_new">geoPlugin</a></small><br />'; } else { //TODO } } } //END IF }
<?php /** * Created by PhpStorm. * User: martinmatak * Date: 06/03/16 * Time: 15:36 */ namespace graph_library; require_once '../Autoloader.php'; header('Content-Type:image/png'); $platno = new Canvas(); $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); $pieChart->colorData(16, 20, 17, $id_podataka); $podatak = new DataCollection(); $podatak->addItem(new DataCollectionItem([35])); $id_podataka = $pieChart->addData($podatak); $pieChart->colorData(36, 40, 57, $id_podataka); $podatak = new DataCollection(); $podatak->addItem(new DataCollectionItem([35]));
function getPieChart($sid, $tableName, $columnName) { $datasetDAO = new DatasetDAO(); $cid = $datasetDAO->getCidBySidTableNameColumName($sid, $tableName, $columnName); $pieChartInput = new stdClass(); $inputObj = new stdClass(); $inputObj->sid = $sid; $inputObj->oneSid = true; $inputObj->tableName = $tableName; $inputObj->title = 'pieChart'; $pieChartInput->inputObj = $inputObj; $pieChartInput->table = $tableName; $columnObj = new stdClass(); $columnObj->cid = $cid; $pieChartInput->pieColumnCat = $columnObj; $pieChartInput->pieColumnAgg = $columnObj; $pieChartInput->pieAggType = "Count"; $pieChartInput->where = ""; $pieChart = new PieChart(null, null, null, null, null, null, null, null, null, null, null); $pieData = $pieChart->query($pieChartInput); $chartId = str_replace(".", "dot", "{$sid}{$tableName}{$columnName}"); $pieData["chartId"] = $chartId; $pieData["columnName"] = $columnName; // foreach ($pieData["content"] as $key => $value) { // SAVETODB($cid, $value->Category, $value->AggValue); // //$value["Category"], $value["AggValue"] // } return $pieData; }
public function __construct($chartLabel) { parent::__construct($chartLabel); $this->defaults = array_merge($this->defaults, array('pieHole')); $this->chartType = 'PieChart'; }
<div id="search-result"> <?php require_once "{$root}/Function/libchart/classes/libchart.php"; $Stati = $d->GetRows("*", "tab_stato_call", "", "", "stato_call"); //Padding::Padding ($top, $right, $bottom, $left) define("ChartPath", "tmp/chart.png"); define("ChartWidth", 1000); define("ChartHeight", 400); $chart = new PieChart(ChartWidth, ChartHeight); $chart->getPlot()->setGraphPadding(new Padding("5", "5", "5", "5")); $chart->setTitle("Stato rollout filiali Unicredit - Sicilia"); $dataSet = new XYDataSet(); foreach ($Stati as $key => $field) { $stat = $d->GetRows("count(id_filiale) as count", "tab_filiali", "id_stato = '" . $field['id_stato_call'] . "'"); /* echo "[Debug]: count stato: ".$stat[0]['count']." <br />"; */ $dataSet->addPoint(new Point($field['stato_call'] . " ( " . $stat[0]['count'] . " )", $stat[0]['count'])); } $chart->setDataSet($dataSet); $chart->render(ChartPath); ?> <img src="<?php echo ChartPath; ?> " alt="chart" /> </div>
function show_page($mode_) { if (isset($_GET['from'])) { $t0 = strtotime($_GET['from']); } else { $t0 = strtotime($mode_->get_default_from()); } if (isset($_GET['to'])) { $t1 = strtotime($_GET['to']); } else { $t1 = time(); } $t0 = $mode_->transform_date($t0); $t1 = $mode_->transform_date($t1); if ($t0 > $t1) { popup_error(_('Error: "from" date is after "to" date, the dates will be reversed')); $buf = $t0; $t0 = $t1; $t1 = $buf; } if ($t1 > time()) { popup_error(_('Error: "to" field is in the future, the current time will be used')); $t1 = $mode_->transform_date(time()); } if ($t0 > time()) { popup_error(_('Error: "from" field is in the future, the current time will be used')); $t0 = $mode_->transform_date(time()); } $t2 = strtotime($mode_->get_next(), $t1); /* General system */ if (!is_writable(TMP_DIR)) { popup_error(sprintf(_("%s is not writable"), TMP_DIR)); page_header(); echo '<h1>' . _('Reporting') . '</h1>'; page_footer(); die; } list($session_number, $result, $res_server, $end_status, $end_status_by_server) = get_session_history($t0, $t2, $mode_); $info2 = get_server_history($t0, $t2, $mode_); $chart = new LineChart(); $chart->getPlot()->setLogoFileName(''); $dataSet = new XYDataSet(); $step = max(round(count($result) / MAX_STEPS), 1); $step_i = 0; foreach ($result as $day => $num) { $text = ''; if ($step_i % $step == 0) { $text = $mode_->get_pretty_date($day); } $step_i++; $dataSet->addPoint(new Point($text, $num)); } $chart->setDataSet($dataSet); $chart->setTitle(_('Number of launched sessions')); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $file_id = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); // Foreach server $servers = array(); foreach ($res_server as $server_id => $value) { $servers[$server_id] = array(); $server = $_SESSION['service']->server_info($server_id); if ($server) { $servers[$server_id]['name'] = $server->getDisplayName(); } else { $servers[$server_id]['name'] = $server_id; } } if ($session_number > 0) { $dataSet = new XYDataSet(); foreach ($res_server as $server_id => $c) { if ($server_id === "") { $server_id = _("unknown"); } $tot = 0; foreach ($c as $k => $v) { $tot += $v; } $value = $tot * 100 / $session_number; $dataSet->addPoint(new Point(str_replace(array('%SERVER%', '%TOTAL%'), array($servers[$server_id]['name'], (int) $tot), ngettext(_('%SERVER% (%TOTAL% session)'), _('%SERVER% (%TOTAL% sessions)'), $value)), $value)); } $chart = new PieChart(); $chart->getPlot()->setLogoFileName(''); $chart->setTitle(_('Session repartition')); $chart->setDataSet($dataSet); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $file_id2 = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); if (count($end_status) > 0) { $dataSet = new XYDataSet(); foreach ($end_status as $status_session => $number_status) { $dataSet->addPoint(new Point(str_replace(array('%STATUS%', '%TOTAL%'), array(Session::textEndStatus($status_session), (int) $number_status), ngettext(_('%STATUS% (%TOTAL% session)'), _('%STATUS% (%TOTAL% sessions)'), $number_status)), $number_status)); } $chart = new PieChart(); $chart->getPlot()->setLogoFileName(''); $chart->setTitle(_('Session end status')); $chart->setDataSet($dataSet); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $file_id3 = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); } } // Foreach server foreach ($res_server as $server_id => $value) { $chart = new LineChart(); $chart->getPlot()->setLogoFileName(''); $dataSet = new XYDataSet(); $step = max(round(count($value) / MAX_STEPS), 1); $step_i = 0; foreach ($value 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 launched sessions')); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $servers[$server_id]['session_file'] = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); $dataSet = new XYDataSet(); $end_status2 = array(); if (array_key_exists($server_id, $end_status_by_server)) { $end_status2 = $end_status_by_server[$server_id]; } if (count($end_status2) > 0) { foreach ($end_status2 as $status_session => $number_status) { $dataSet->addPoint(new Point(str_replace(array('%STATUS%', '%TOTAL%'), array(Session::textEndStatus($status_session), (int) $number_status), ngettext(_('%STATUS% (%TOTAL% session)'), _('%STATUS% (%TOTAL% sessions)'), $number_status)), $number_status)); } $chart = new PieChart(); $chart->getPlot()->setLogoFileName(''); $chart->setTitle(_('Session end status')); $chart->setDataSet($dataSet); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $servers[$server_id]['session_end_status'] = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); } if (!isset($info2[$server_id])) { continue; } $dataSet_cpu = new XYDataSet(); $step = max(round(count($info2[$server_id]['cpu']) / MAX_STEPS), 1); $step_i = 0; foreach ($info2[$server_id]['cpu'] as $day => $num) { $text = $step_i % $step == 0 ? substr($day, -2) : ''; $step_i++; $b = get_avg_value($num); $dataSet_cpu->addPoint(new Point($text, $b)); } $chart = new LineChart(); $chart->getPlot()->setLogoFileName(''); $chart->setDataSet($dataSet_cpu); $chart->setTitle(_('CPU usage')); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $servers[$server_id]['cpu_file'] = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); $dataSet_ram = new XYDataSet(); $step = max(round(count($info2[$server_id]['ram']) / MAX_STEPS), 1); $step_i = 0; foreach ($info2[$server_id]['ram'] as $day => $num) { $text = $step_i % $step == 0 ? substr($day, -2) : ''; $step_i++; $b = get_avg_value($num); $dataSet_ram->addPoint(new Point($text, $b)); } $chart = new LineChart(); $chart->getPlot()->setLogoFileName(''); $chart->setDataSet($dataSet_ram); $chart->setTitle(_('RAM usage')); $tmpfile = tempnam(TMP_DIR, REPORT_PREFIX); $servers[$server_id]['ram_file'] = substr($tmpfile, strlen(TMP_DIR . '/' . REPORT_PREFIX)); $chart->render($tmpfile); } page_header(array('js_files' => array('media/script/lib/calendarpopup/CalendarPopup.js'))); echo '<h1>' . _('Reporting') . '</h1>'; echo '<div id="calendar_day_from" style="position: absolute; visibility: hidden; background: white;"></div>'; echo '<div id="calendar_day_to" style="position: absolute; visibility: hidden; background: white;"></div>'; echo '<script type="text/javascript" charset="utf-8">'; echo ' document.write(getCalendarStyles());'; echo ' var calendar_day_from = new CalendarPopup("calendar_day_from");'; echo ' calendar_day_from.setReturnFunction(\'func_day_from\');'; echo ' function func_day_from(y,m,d) {'; echo ' if (m < 10)'; echo ' m = \'0\'+m;'; echo ' if (d < 10)'; echo ' d = \'0\'+d;'; echo ' $(\'from\').value = y+\'-\'+m+\'-\'+d;'; echo ' $(\'anchor_day_from\').innerHTML = $(\'from\').value;'; echo ' }'; echo ' var calendar_day_to = new CalendarPopup("calendar_day_to");'; echo ' calendar_day_to.setReturnFunction(\'func_day_to\');'; echo ' function func_day_to(y,m,d) {'; echo ' if (m < 10)'; echo ' m = \'0\'+m;'; echo ' if (d < 10)'; echo ' d = \'0\'+d;'; echo ' $(\'to\').value = y+\'-\'+m+\'-\'+d;'; echo ' $(\'anchor_day_to\').innerHTML = $(\'to\').value;'; echo ' }'; echo ' Event.observe(window, \'load\', function() {'; echo ' func_day_from(' . date('Y', $t0) . ', ' . date('m', $t0) . ', ' . date('d', $t0) . ');'; echo ' func_day_to(' . date('Y', $t1) . ', ' . date('m', $t1) . ', ' . date('d', $t1) . ');'; echo ' });'; echo ' function generateReport() {'; echo ' $(\'from\').value+= \' \'+$(\'hour_from\').value+\':00\';'; echo ' $(\'to\').value+= \' \'+$(\'hour_to\').value+\':00\';'; echo ' return true;'; echo ' }'; echo '</script>'; echo '<form onsubmit="return generateReport();">'; echo '<input id="from" name="from" value="" type="hidden" />'; echo '<input id="to" name="to" value="" type="hidden" />'; echo '<strong>' . _('From') . '</strong> '; echo '<a href="#" id="anchor_day_from" onclick="calendar_day_from.select($(\'from\'), \'anchor_day_from\'); return false;" >' . date('Y-m-d', $t0) . '</a> '; echo '<select id="hour_from">'; for ($i = 0; $i < 24; $i++) { echo '<option value="' . $i . '"'; if ((int) date('H', $t0) == $i) { echo ' selected="selected"'; } echo '>' . $i . ':00</option>'; } echo '</select> '; echo '<strong>' . _('to') . '</strong> '; echo '<a href="#" id="anchor_day_to" onclick="calendar_day_to.select($(\'to\'), \'anchor_day_to\'); return false;" >' . date('Y-m-d', $t1) . '</a> '; echo '<select id="hour_to">'; for ($i = 0; $i < 24; $i++) { echo '<option value="' . $i . '"'; if ((int) date('H', $t1) == $i) { echo ' selected="selected"'; } echo '>' . $i . ':00</option>'; } echo '</select> '; echo '<strong>' . _('step') . '</strong>'; echo '<select name="mode">'; echo '<option value="minute"'; if ($mode_->get_value() == 'minute') { echo ' selected="selected"'; } echo '>' . ReportMode_minute::get_name() . '</option>'; echo '<option value="hour"'; if ($mode_->get_value() == 'hour') { echo ' selected="selected"'; } echo '>' . ReportMode_hour::get_name() . '</option>'; echo '<option value="day"'; if ($mode_->get_value() == 'day') { echo ' selected="selected"'; } echo '>' . ReportMode_day::get_name() . '</option>'; echo '</select> '; echo '<input type="submit" value="' . _('Refresh') . '" />'; echo '</form>'; echo '<div>'; echo '<table><tr><td>'; echo '<img src="?img=1&file=' . $file_id . '" />'; echo '</td><td><i>'; if ($mode_->get_value() == 'day') { echo _('Abscissa: day of the month'); } else { if ($mode_->get_value() == 'hour') { echo _('Abscissa: hour of the day'); } else { if ($mode_->get_value() == 'minute') { echo _('Abscissa: minute of the hour'); } } } echo '<br/>'; echo _('Ordinate: number of sessions'); echo '</i></td></tr>'; echo '<tr><td>'; echo '<img src="?img=nb_sessions&mode=' . $mode_->get_value() . '&from=' . date('Y-m-d H:i:s', $t0) . '&to=' . date('Y-m-d H:i:s', $t1) . '" />'; echo '</td><td><i>'; if ($mode_->get_value() == 'day') { echo _('Abscissa: day of the month'); } else { if ($mode_->get_value() == 'hour') { echo _('Abscissa: hour of the day'); } else { if ($mode_->get_value() == 'minute') { echo _('Abscissa: minute of the hour'); } } } echo '<br/>'; echo _('Ordinate: number of sessions'); echo '</i></td></tr>'; echo '</table>'; if ($session_number > 0) { if (isset($file_id2)) { echo '<img src="?img=1&file=' . $file_id2 . '" />'; } echo ' '; if (isset($file_id3)) { echo '<img src="?img=1&file=' . $file_id3 . '" />'; } } echo '<form action="session-reporting.php">'; echo '<input type="hidden" name="search_by[]" value="time" />'; echo '<input type="hidden" name="from" value="' . $t0 . '" />'; echo '<input type="hidden" name="to" value="' . $t1 . '" />'; echo '<input type="submit" value="' . _('See archived sessions in this time range') . '" />'; echo '</form>'; foreach ($servers as $server_id => $value) { echo '<hr/>'; echo '<h2>' . _('Server') . ' ' . $value['name'] . '</h2>'; echo '<table>'; if (isset($value['session_file'])) { echo '<tr><td>'; echo '<img src="?img=1&file=' . $value['session_file'] . '" />'; echo '</td><td><i>'; if ($mode_->get_value() == 'day') { echo _('Abscissa: day of the month'); } else { if ($mode_->get_value() == 'hour') { echo _('Abscissa: hour of the day'); } else { if ($mode_->get_value() == 'minute') { echo _('Abscissa: minute of the hour'); } } } echo '<br/>'; echo _('Ordinate: number of sessions'); echo '</i></td></tr>'; } if (isset($value['session_end_status'])) { echo '<tr><td>'; echo '<img src="?img=1&file=' . $value['session_end_status'] . '" />'; echo '</td><td></td></tr>'; } if (isset($value['cpu_file'])) { echo '<tr><td>'; echo '<img src="?img=1&file=' . $value['cpu_file'] . '" />'; echo '</td><td><i>'; if ($mode_->get_value() == 'day') { echo _('Abscissa: day of the month'); } else { if ($mode_->get_value() == 'hour') { echo _('Abscissa: hour of the day'); } else { if ($mode_->get_value() == 'minute') { echo _('Abscissa: minute of the hour'); } } } echo '<br/>'; echo _('Ordinate: CPU usage in percent'); echo '</i></td></tr>'; } if (isset($value['ram_file'])) { echo '<tr><td>'; echo '<img src="?img=1&file=' . $value['ram_file'] . '" />'; echo '</td><td><i>'; if ($mode_->get_value() == 'day') { echo _('Abscissa: day of the month'); } else { if ($mode_->get_value() == 'hour') { echo _('Abscissa: hour of the day'); } else { if ($mode_->get_value() == 'minute') { echo _('Abscissa: minute of the hour'); } } } echo '<br/>'; echo _('Ordinate: RAM usage in percent'); echo '</i></td></tr>'; } echo '</table>'; } echo '</div>'; page_footer(); die; }
private function runGenerateFactorPieChart($w, $h, $factor, $file) { $chart = new PieChart($w, $h); foreach ($this->mitgliederFactorCount[$factor] as $label => $count) { if (!empty($label)) { $chart->addData(new Chart_Data($label, $count)); } } $chart->plot($file); }
//type of chart, pie, vertical bar, horizontal, etc. $type = isset($_GET['type']) ? $_GET['type'] : '1'; $chartType = isset($_GET['chart']) ? $_GET['chart'] : '1'; $user = isset($_GET['user']) ? $_GET['user'] : $_SESSION['USER_LOGGED']; $chartsObj = new chartsClass(); //$chart = new PieChart(450,300); switch ($type) { case '1': $chart = new VerticalBarChart(430, 280); break; case '2': $chart = new HorizontalBarChart(430, 200); break; case '3': $chart = new LineChart(430, 280); break; case '4': $chart = new PieChart(430, 200); break; } switch ($chartType) { case '1': $dataSet = $chartsObj->getDatasetCasesByStatus(); break; default: $dataSet = $chartsObj->getDatasetCasesByProcess(); break; } $chart->setDataSet($dataSet); $chart->setTitle("Cases list"); $chart->render();
<?php require_once "{$root}/Function/libchart/classes/libchart.php"; require_once "{$root}/Function/Db.php"; require_once "{$root}/Function/Debug.php"; require_once "{$root}/Function/DataTime.php"; $Stati = GetRows("tab_stato_mch", "", "stato_mch", $db, 1); /* echo "<pre>"; print_r($Stati); echo "</pre>"; */ //Padding::Padding ($top, $right, $bottom, $left) define("ChartPath", "tmp/chart.png"); define("ChartWidth", 1000); define("ChartHeight", 400); $chart = new PieChart(ChartWidth, ChartHeight); $chart->getPlot()->setGraphPadding(new Padding("5", "5", "5", "5")); $chart->setTitle("Statistiche Magazzino RollOut"); $dataSet = new XYDataSet(); foreach ($Stati as $key => $field) { $stat = GetRows("tab_macchine", "id_stato = '" . $field['id_stato_call'] . "'", "", $db, 1, "count(id_macchina) as count"); /* echo "[Debug]: count stato: ".$stat[0]['count']." <br />"; */ $dataSet->addPoint(new Point($field['stato_call'] . " ( " . $stat[0]['count'] . " )", $stat[0]['count'])); } $chart->setDataSet($dataSet); $chart->render(ChartPath); ?>
<?php /* Example13: A 2D exploded pie graph */ // Standard inclusions require_once "../lib/pData.php"; require_once "../lib/pChart.php"; require_once '../lib/GDCanvas.php'; require_once '../lib/BackgroundStyle.php'; require_once '../lib/PieChart.php'; // Definitions $DataSet = new pData(); $Canvas = new GDCanvas(300, 200); $Chart = new PieChart(300, 200, $Canvas); // Dataset $DataSet->AddPoints(array(10, 2, 3, 5, 3), "Serie1"); $DataSet->AddPoints(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbscissaLabelSeries("Serie2"); // Initialise the graph $Chart->setFontProperties("../Fonts/tahoma.ttf", 8); // Draw the pie chart $shadowProperties = ShadowProperties::FromSettings(2, 2, new Color(200)); $Chart->drawFlatPieGraphWithShadow($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 60, PIE_PERCENTAGE, 8, 0, $shadowProperties); $Chart->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); $Chart->Render("Example13.png"); header("Content-Type:image/png"); readfile("Example13.png");
* Pie chart demonstration * */ include "../libchart/classes/libchart.php"; $chart = new PieChart(); $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("Mozilla Firefox (10 feedback)", 10)); $dataSet->addPoint(new Point("Konqueror (75)", 75)); $dataSet->addPoint(new Point("Opera (50)", 50)); $dataSet->addPoint(new Point("Safari (37)", 37)); $dataSet->addPoint(new Point("Dillo (37)", 37)); $dataSet->addPoint(new Point("Other (72)", 70)); $chart->setDataSet($dataSet); $chart->setTitle("User agents for www.example.com"); $chart->render("generated/demo3.png"); $chart2 = new PieChart(); $dataSet2 = new XYDataSet(); $dataSet2->addPoint(new Point("Mozilla (10)", 10)); $dataSet2->addPoint(new Point("Konqror (75)", 75)); $dataSet2->addPoint(new Point("Opa (50)", 50)); $dataSet2->addPoint(new Point("Saf (37)", 37)); $dataSet2->addPoint(new Point("Dilo (37)", 37)); $dataSet2->addPoint(new Point("Oter (72)", 70)); $chart2->setDataSet($dataSet2); $chart2->setTitle("User agents for www.example.com"); $chart2->render("generated/demo4.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 pie chart demonstration</title>
<?php require '../lib/PieChart.php'; $chart = new PieChart('p', 130, 100); $chart->setDataFormat(Chart::SIMPLE_ENCODING); $data = new ChartData(array(80, -20)); $data->setColor('f9f900'); $chart->addData($data); // I pass null to enable the "legend" trick $data = new ChartData(null); $data->setColor('ffffff'); $data->setLegend('O O O'); $chart->addData($data); $chart->setLegendPosition('r'); $chart->setRotation(0.628); if (isset($_GET['debug'])) { var_dump($chart->getQuery()); echo $chart->validate(); echo $chart->toHtml(); } else { header('Content-Type: image/png'); echo $chart; }
* * 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/>. * */ /** * Pie chart demonstration * */ include "../../../COCONUT/libchart/libchart/classes/libchart.php"; $chart = new PieChart(); $ro = new database1(); $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("OPD (" . number_format($ro->getPxRevenueDaily_opd($fromMonth, $fromDay, $fromYear), 2) . ")", $ro->getPxRevenueDaily_opd($fromMonth, $fromDay, $fromYear))); $dataSet->addPoint(new Point("IPD (" . number_format($ro->getPxRevenueDaily_ipd($fromMonth, $fromDay, $fromYear), 2) . ")", $ro->getPxRevenueDaily_ipd($fromMonth, $fromDay, $fromYear))); $chart->setDataSet($dataSet); $chart->setTitle("Collection Report For {$fromMonth} {$fromDay}, {$fromYear} "); $chart->render("../../../COCONUT/graphicalReport/chartList/dailyRevenue.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></title> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" /> </head> <body>
* * 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/>. * */ /** * Pie chart demonstration * */ include "../libchart/classes/libchart.php"; $chart = new PieChart(); $chart->getPlot()->getPalette()->setPieColor(array(new Color(255, 0, 0), new Color(255, 255, 255))); $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("Amanita abrupta", 80)); $dataSet->addPoint(new Point("Amanita arocheae", 75)); $dataSet->addPoint(new Point("Clitocybe dealbata", 50)); $dataSet->addPoint(new Point("Cortinarius rubellus", 70)); $dataSet->addPoint(new Point("Gyromitra esculenta", 37)); $dataSet->addPoint(new Point("Lepiota castanea", 37)); $chart->setDataSet($dataSet); $chart->setTitle("Deadly mushrooms"); $chart->render("generated/pie_chart_color.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>
public function testDrawBasicPieGraph() { // Dataset definition $DataSet = new pData(); $DataSet->addPoints(array(10, 2, 3, 5, 3), "Serie1"); $DataSet->addPoints(array("Jan", "Feb", "Mar", "Apr", "May"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->setAbscissaLabelSeries("Serie2"); $this->assertEquals(array(0 => array('Serie1' => 10, 'Name' => 0, 'Serie2' => 'Jan'), 1 => array('Serie1' => 2, 'Name' => 1, 'Serie2' => 'Feb'), 2 => array('Serie1' => 3, 'Name' => 2, 'Serie2' => 'Mar'), 3 => array('Serie1' => 5, 'Name' => 3, 'Serie2' => 'Apr'), 4 => array('Serie1' => 3, 'Name' => 4, 'Serie2' => 'May')), $DataSet->getData()); $this->assertEquals(array(0 => 'Serie1', 1 => 'Serie2'), $DataSet->getDataDescription()->values); // Initialise the graph $canvas = new TestCanvas(); $Test = new PieChart(300, 200, $canvas); $Test->loadColorPalette(dirname(__FILE__) . "/../sample/softtones.txt"); // Draw the pie chart $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, ShadowProperties::NoShadow(), 70, PIE_PERCENTAGE, new Color(255, 255, 218)); $Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250)); $this->assertEquals('0ec1d5de67ae53239101143106d5ee4a', md5($canvas->getActionLog())); }
/* Libchart - PHP chart library * Copyright (C) 2005-2011 Jean-Marc Trémeaux (jm.tremeaux at gmail.com) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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/>. * */ /** * Direct PNG output demonstration (image not saved to disk) * */ include "../libchart/classes/libchart.php"; header("Content-type: image/png"); $chart = new PieChart(500, 300); $dataSet = new XYDataSet(); $dataSet->addPoint(new Point("Bleu d'Auvergne", 50)); $dataSet->addPoint(new Point("Tomme de Savoie", 75)); $dataSet->addPoint(new Point("Crottin de Chavignol", 30)); $chart->setDataSet($dataSet); $chart->setTitle("Preferred Cheese"); $chart->render();
$sql .= "WHERE ((last_status IN ('F', 'C') AND status_on BETWEEN " . qpg($from_date) . " AND " . qpg($to_date) . ") "; $sql .= "OR last_status NOT IN ('F','C')) "; if (isset($system_id)) { $sql .= "AND request.system_id={$system_id} "; } if (isset($request_type)) { $sql .= "AND request.request_type={$request_type} "; } if (isset($requested_by)) { $sql .= "AND requester_id = {$requested_by} "; } $sql .= "GROUP BY status_lookup.lookup_desc, request.last_status "; $sql .= "ORDER BY 2 DESC;"; // echo "$sql"; $debuggroups['PieChart'] = 1; $pie = new PieChart($sql); /* include("page-header.php"); */ $pie->Render(); /* include("page-footer.php"); */ error_reporting(7); if ($debuglevel > 0) { $total_query_time = sprintf("%3.06lf", $total_query_time); error_log("{$sysabbr} total_query_ TQ: {$total_query_time} URI: {$REQUEST_URI}", 0); $total_time = sprintf("%3.06lf", duration($begin_processing, microtime())); error_log("{$sysabbr} process_time TT: {$total_time} Agent: {$HTTP_USER_AGENT} Referrer: {$HTTP_REFERER} ", 0); error_log("=============================================== Endof {$PHP_SELF}"); }
$spiderweb_panel->show(); echo '<script>' . '$("#chart3").highcharts(' . $spiderweb_chart->getChartJson() . ');' . '</script>'; echo "</div>"; #ColumnChart echo "<div class='col-sm-6'>"; $line_column_chart = new LineAndColumnChart(); $line_column_panel = new Panel(); $line_column_chart->demo(); $line_column_panel->data["content"] = "<div class='ichart' id='chart4'></div>"; $line_column_panel->addOptionCreate(); $line_column_panel->show(); echo '<script>' . '$("#chart4").highcharts(' . $line_column_chart->getChartJson() . ');' . '</script>'; echo "</div>"; #PieChart echo "<div class='col-sm-6'>"; $pie_chart = new PieChart(); $pie_panel = new Panel(); $pie_chart->demo(); $pie_panel->data["content"] = "<div class='ichart' id='chart5'></div>"; $pie_panel->addOptionCreate(); $pie_panel->show(); echo '<script>' . '$("#chart5").highcharts(' . $pie_chart->getChartJson() . ');' . '</script>'; echo "</div>"; #Dim2PieChart echo "<div class='col-sm-6'>"; $dim2pie_chart = new Dim2PieChart(); $dim2pie_panel = new Panel(); $dim2pie_chart->demo(); $dim2pie_panel->data["content"] = "<div class='ichart' id='chart6'></div>"; $dim2pie_panel->addOptionCreate(); $dim2pie_panel->show();
/** * Display a nice graph from data * * @param type Type of data. * @param sort Field */ function renderGraph($machines, $type, $sort, $filter) { $id = "{$type} {$sort}"; $chart = new PieChart(770, 340); $dataSet = new XYDataSet(); $div = 1; $mod = 0; $suffix = ""; switch ($id) { case "BootGeneral TotalMem": $div = 1024; $mod = 64; $suffix = " MB"; break; case "BootGeneral Freq": $div = 1; $mod = 200; $suffix = " Mhz"; break; case "BootDisk Capacity": $div = 1000; $mod = 20; $suffix = " GB"; break; case "Memory Size": $div = 1024; $mod = 0; $suffix = " MB"; break; } $data = array(); foreach ($machines as $machine) { foreach ($machine[1] as $inv) { // filter data in ranges if ($div != 1) { $inv /= $div; $inv = round($inv); } if ($mod) { $inv /= $mod; $inv = round($inv); $inv *= $mod; if ($inv != 0) { $inv = $d - $mod + 1 . "-" . $inv; } } if ($suffix != "") { $inv = $inv . $suffix; } $data[$inv] += 1; } } // For each data count the occurence foreach ($data as $key => $value) { $dataSet->addPoint(new Point("{$key} ({$value})", $value)); } $chart->setDataSet($dataSet); $chart->setTitle(ucfirst($sort)); header("Content-type: image/png"); @$chart->render(); exit; }
if (($handle = fopen($csvfile, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $num = count($data); $row++; for ($c = 0; $c < $num; $c++) { if ($c % 2) { array_push($searches, $data[$c]); } else { array_push($services, $data[$c]); } } } } require_once "/var/www/ChartDirector/lib/phpchartdir.php"; # Create a PieChart object of size 360 x 300 pixels $c = new PieChart(770, 390); # Set the center of the pie at (180, 140) and the radius to 100 pixels $c->setPieSize(470, 200, 180); # Add a title to the pie chart $c->addTitle($display_date . ' / ' . $display_geo . ' / ' . $display_searchtype); # Set the color palette $colors = array(0x378a30, 0x71cb68, 0x276a21, 0x7bb372, 0xe8fee7, 0x5d9758, 0x355e72, 0x6699b6, 0x6a9db8, 0x7fb0ce, 0x95c8e5, 0x699cb9, 0xd47710, 0xde8a30, 0xd37108, 0xd29039, 0xf29e43, 0xee7d05); # Set the font $c->setLabelStyle("arial.ttf", 9); # Set the sector colors $c->setColors2(DataColor, $colors); # Set the gradient $c->setSectorStyle(LocalGradientShading); # Draw the pie in 3D $c->set3D(); $c->addLegend(0, 30);