<?php require_once './conexao.php'; //Include the code require_once './phplot/phplot.php'; //Define the object $plot = new PHPlot(); $buscar = mysql_query("SELECT count(id), bairro FROM " . " ocorrencia GROUP BY bairro ORDER BY count(id) DESC"); $data = array(); while ($ver = mysql_fetch_array($buscar)) { $data[] = array($ver['bairro'], $ver['count(id)']); } $plot->SetTitleColor('blue'); //$plot->SetTitle(""); $plot->SetImageBorderType('plain'); #$plot->SetBackgroundColor('YellowGreen'); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); foreach ($data as $row) { $plot->SetLegend($row[0]); } // Copy labels to legend $plot->DrawGraph();
<?php session_start(); require_once 'phplot.php'; echo $_GET[countKeywords]; $data = array(array('新增文件', intval($_GET[countnew])), array('删除文件', intval($_GET[countdel])), array('修改文件', intval($_GET[countmodify]))); $plot = new PHPlot(350, 280); $plot->SetTTFPath('./public'); $plot->SetDefaultTTFont('SIMHEI.TTF'); $plot->SetUseTTF(True); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetPlotBorderType('full'); $plot->SetBackgroundColor('#ffffcc'); $plot->SetDrawPlotAreaBackground(True); $plot->SetPlotBgColor('#ffffff'); $plot->SetDataValues($data); $plot->SetTitle("新增文件数:{$_GET['countnew']} 删除文件数:{$_GET['countdel']} 修改文件数:{$_GET['countmodify']}"); $plot->SetTitleColor('#D9773A'); foreach ($data as $row) { $plot->Setshading(10); } $plot->SetDataBorderColors('black'); $plot->DrawGraph();
<?php # $Id$ # PHPlot test - transparency - palette, set background then set transparent require_once 'phplot.php'; $data = array(array('A', 6), array('B', 4), array('C', 2), array('D', 0)); $p = new PHPlot(); $p->SetTitle('Palette, Set background color, Set transparent'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitleColor('green'); // For contrast vs black/clear background $p->SetBackgroundColor('yellow'); $p->SetTransparentColor('yellow'); $p->DrawGraph();
$myrow = DB_fetch_row($result); $GraphTitle .= ' ' . _('For Salesperson:') . ' ' . $myrow[0]; $WhereClause .= " salesperson='" . $_POST['SalesmanCode'] . "' AND"; } if ($_POST['GraphOn'] == 'Customer') { $GraphTitle .= ' ' . _('For Customers from') . ' ' . $_POST['ValueFrom'] . ' ' . _('to') . ' ' . $_POST['ValueTo']; $WhereClause .= " cust >='" . $_POST['ValueFrom'] . "' AND cust <='" . $_POST['ValueTo'] . "' AND"; } if ($_POST['GraphOn'] == 'StockID') { $GraphTitle .= ' ' . _('For Items from') . ' ' . $_POST['ValueFrom'] . ' ' . _('to') . ' ' . $_POST['ValueTo']; $WhereClause .= " stockid >='" . $_POST['ValueFrom'] . "' AND stockid <='" . $_POST['ValueTo'] . "' AND"; } $WhereClause = "WHERE " . $WhereClause . " salesanalysis.periodno>='" . $_POST['FromPeriod'] . "' AND salesanalysis.periodno <= '" . $_POST['ToPeriod'] . "'"; $SQL = "SELECT salesanalysis.periodno,\n\t\t\t\tperiods.lastdate_in_period,\n\t\t\t\tSUM(CASE WHEN budgetoractual=1 THEN " . $SelectClause . " ELSE 0 END) AS sales,\n\t\t\t\tSUM(CASE WHEN budgetoractual=0 THEN " . $SelectClause . " ELSE 0 END) AS budget\n\t\tFROM salesanalysis INNER JOIN periods ON salesanalysis.periodno=periods.periodno " . $WhereClause . "\n\t\tGROUP BY salesanalysis.periodno,\n\t\t\tperiods.lastdate_in_period\n\t\tORDER BY salesanalysis.periodno"; $graph->SetTitle($GraphTitle); $graph->SetTitleColor('blue'); $graph->SetOutputFile('companies/' . $_SESSION['DatabaseName'] . '/reports/salesgraph.png'); $graph->SetXTitle(_('Month')); if ($_POST['GraphValue'] == 'Net') { $graph->SetYTitle(_('Sales Value')); } elseif ($_POST['GraphValue'] == 'GP') { $graph->SetYTitle(_('Gross Profit')); } else { $graph->SetYTitle(_('Quantity')); } $graph->SetXTickPos('none'); $graph->SetXTickLabelPos('none'); $graph->SetBackgroundColor('white'); $graph->SetTitleColor('blue'); $graph->SetFileFormat('png'); $graph->SetPlotType($_POST['GraphType']);
<?php # $Id$ # Testing phplot - Title Colors. Case 1 - 3 different colors (main, X, Y) # Other scripts can set $c1, $c2, and/or $c3 to a color or NULL to set the # main, X, and/or Y titles, then include this script. require_once 'phplot.php'; if (empty($c1) && empty($c2) && empty($c3)) { $c1 = 'red'; $c2 = 'blue'; $c3 = 'green'; } $subtitle = 'Main: ' . (empty($c1) ? 'default' : $c1) . ', X: ' . (empty($c2) ? 'default' : $c2) . ', Y: ' . (empty($c3) ? 'default' : $c3); $data = array(array('A', 0), array('B', 1), array('C', 2)); $p = new PHPlot(600, 600); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitle("Title color test\n{$subtitle}"); $p->SetXTitle("Title color test - X title", 'both'); $p->SetYTitle("Title color test - Y title", 'both'); if (!empty($c1)) { $p->SetTitleColor($c1); } if (!empty($c2)) { $p->SetXTitleColor($c2); } if (!empty($c3)) { $p->SetYTitleColor($c3); } $p->DrawGraph();
function guifi_stats_chart07() { include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php'; $gDirTTFfonts = drupal_get_path('module', 'guifi') . '/contrib/fonts/'; if (isset($_GET['width'])) { $gwidth = $_GET['width']; } else { $gwidth = 500; } if (isset($_GET['height'])) { $gheight = $_GET['height']; } else { $gheight = 450; } $today = getdate(); $year = $today[year]; $month = $today[mon]; $month = $month - 12; $n = 0; $tot = 0; if ($month < 1) { $year = $year - 1; $month = 12 + $month; } $datemin = mktime(0, 0, 0, $month, 1, $year); if (isset($_GET['zone'])) { $zone_id = $_GET['zone']; if ($zone_id == "0") { $zone_id = "0"; } //"3671"; } else { $zone_id = "0"; } $avalue = array(); $adata = array(); for ($i = 0; $i < 10; $i++) { $adata[] = array(0, 0); } $vsql = "select sum(if(timestamp_created >= " . $datemin . ",1,0)) as num, count(*) as total, zone_id\n from {guifi_location}\n where status_flag='Working' "; if ($zone_id != "0") { $achilds = guifi_zone_childs($zone_id); $v = ""; foreach ($achilds as $key => $child) { if ($v == "") { $v .= "zone_id=" . $child; } else { $v .= " or zone_id=" . $child; } } $vsql .= "AND (" . $v . ") "; } $vsql .= "GROUP BY zone_id "; $result = db_query($vsql); while ($record = db_fetch_object($result)) { if ($record->total >= 20) { $vn = $record->num / $record->total * 100; $vmin = 0; for ($i = 1; $i < 10; $i++) { if ($adata[$vmin][1] > $adata[$i][1]) { $vmin = $i; } } if ($vn > $adata[$vmin][1]) { $adata[$vmin][0] = $record->zone_id; $adata[$vmin][1] = $vn; } } } for ($i = 0; $i < 10; $i++) { if ($adata[$i][1] != 0) { $avalue[$adata[$i][0]] = $adata[$i][1]; } } arsort($avalue); foreach ($avalue as $key => $value) { if ($value != 0) { $data[] = array(substr(guifi_get_zone_name($key), 0, 20) . " �", $value); } } $shapes = array('none'); $plot = new PHPlot($gwidth, $gheight); $plot->SetPlotAreaWorld(0, 0, NULL, NULL); $plot->SetFileFormat('png'); $plot->SetDataType("text-data"); $plot->SetDataValues($data); $plot->SetPlotType("bars"); $plot->SetXTickIncrement(1); $plot->SetSkipBottomTick(TRUE); $plot->SetSkipLeftTick(TRUE); $plot->SetTickLength(0); //$plot->SetXTickPos('none'); $plot->SetYDataLabelPos('plotin'); $plot->SetYLabelType('data', 0); $plot->SetTickColor('grey'); $plot->SetTTFPath($gDirTTFfonts); $plot->SetFontTTF('title', 'Vera.ttf', 12); $plot->SetFontTTF('x_label', 'Vera.ttf', 8); if (isset($_GET['title'])) { $plot->SetTitle("guifi.net \n" . t($_GET['title'])); } else { if ($zone_id == "0") { $plot->SetTitle("guifi.net \n" . t('Largest annual increase')); } else { $plot->SetTitle("guifi.net " . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Largest annual increase')); } } //$plot->SetXTitle(t('Zones')); $plot->SetYTitle(t('% increase')); $plot->SetXDataLabelPos('plotdown'); //$plot->SetXLabelAngle(45); $plot->SetXDataLabelAngle(75); $plot->SetGridColor('red'); $plot->SetPlotBorderType('left'); $plot->SetDataColors(array('orange')); $plot->SetTextColor('DimGrey'); $plot->SetTitleColor('DimGrey'); $plot->SetLightGridColor('grey'); $plot->SetBackgroundColor('white'); $plot->SetTransparentColor('white'); $plot->SetIsInline(TRUE); $plot->DrawGraph(); }
function plot_guifi() { include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php'; $result = db_query("select COUNT(*) as num, MONTH(FROM_UNIXTIME(timestamp_created)) as mes, YEAR(FROM_UNIXTIME(timestamp_created)) as ano from {guifi_location} where status_flag='Working' GROUP BY YEAR(FROM_UNIXTIME(timestamp_created)),MONTH(FROM_UNIXTIME(timestamp_created)) "); $inicial = 5; $nreg = $inicial; $tot = 0; $ano = 2004; $mes = 5; $items = 2004; $label = ""; while ($record = db_fetch_object($result)) { if ($record->ano >= 2004) { if ($mes == 12) { $mes = 1; $ano++; } else { $mes++; } while ($ano < $record->ano || $mes < $record->mes) { $nreg++; if ($mes == 6) { $label = $ano; } else { $label = ''; } $data[] = array("{$label}", $nreg, $tot, ''); if ($mes == 12) { $mes = 1; $ano++; } else { $mes++; } } $tot += $record->num; $nreg++; if ($mes == 6) { $label = $ano; } else { $label = ''; } $data[] = array("{$label}", $nreg, $tot, ''); } else { $tot += $record->num; } } while ($mes < 12) { $nreg++; $mes++; if ($mes == 6) { $label = $ano; } else { $label = ''; } $data[] = array("{$label}", $nreg, ""); } $items = ($ano - $items + 1) * 12; if ($tot % 1000 < 30) { $data[$nreg - $inicial - 1][3] = $tot; $vt = floor($tot / 1000) * 1000; $vtitle = $vt . " " . t('Nodes') . "!!!"; $tcolor = 'red'; } else { $vtitle = t('Working nodes'); $tcolor = 'DimGrey'; } $shapes = array('none', 'circle'); $plot = new PHPlot(200, 150); $plot->SetPlotAreaWorld(0, 0, $items, NULL); $plot->SetFileFormat('png'); $plot->SetDataType("data-data"); $plot->SetDataValues($data); $plot->SetPlotType("linepoints"); $plot->SetYTickIncrement(2000); $plot->SetXTickIncrement(12); $plot->SetSkipBottomTick(TRUE); $plot->SetSkipLeftTick(TRUE); $plot->SetXAxisPosition(0); $plot->SetPointShapes($shapes); $plot->SetPointSizes(10); $plot->SetTickLength(3); $plot->SetDrawXGrid(TRUE); $plot->SetTickColor('grey'); $plot->SetTitle($vtitle); $plot->SetDrawXDataLabelLines(FALSE); $plot->SetXLabelAngle(0); $plot->SetXLabelType('custom', 'Plot1_LabelFormat'); $plot->SetGridColor('red'); $plot->SetPlotBorderType('left'); $plot->SetDataColors(array('orange')); $plot->SetTextColor('DimGrey'); $plot->SetTitleColor($tcolor); $plot->SetLightGridColor('grey'); $plot->SetBackgroundColor('white'); $plot->SetTransparentColor('white'); $plot->SetXTickLabelPos('none'); $plot->SetXDataLabelPos('plotdown'); $plot->SetIsInline(TRUE); $plot->DrawGraph(); }
# $Id$ # PHPlot test: Coloring various items require_once 'phplot.php'; $data = array(); $x = 0.0; $dx = M_PI / 4.0; for ($i = 0; $i < 50; $i++) { $y = $x * sin($x); $data[] = array('', $i, $y); $x += $dx; } $plot = new PHPlot(800, 600); $plot->SetPlotType('lines'); $plot->SetDataType('data-data'); $plot->SetDataValues($data); $plot->SetLineWidths(2); $plot->SetPlotAreaWorld(0, -40, 50, 40); # Turn everything on to test colors: $plot->SetTitle("Color Tests\n" . " SetGridColor blue (used for axes, legend border)\n" . " SetLightGridColor magenta\n" . " SetTextColor red\n" . " SetTickColor green\n" . " SetTitleColor gold"); $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); $plot->SetLegend('Color Tests'); $plot->SetXTitle('X Title Here'); $plot->SetYTitle('Y Title Here'); # Set colors: $plot->SetGridColor('blue'); $plot->SetLightGridColor('magenta'); $plot->SetTextColor('red'); $plot->SetTickColor('green'); $plot->SetTitleColor('gold'); $plot->DrawGraph();
$p->SetDataValues($data1); $p->SetDataType('data-data'); $p->SetPlotType('lines'); $p->SetPlotAreaWorld(NULL, 0, NULL, NULL); // Force Y to start at 0 $p->SetPlotAreaPixels(60, 40, 740, 560); // Force same window for both plots $p->SetYTickPos('plotleft'); // The default $p->SetYTickLabelPos('plotleft'); // The default $p->SetXTickIncrement(1); $p->SetDataColors('blue'); // Force data color $p->SetTitle('Overlay Line Plots to get Different Y Scales'); $p->SetTitleColor('black'); $p->SetXTitle('X Axis Title'); $p->SetYTitle('Temperature', 'plotleft'); $p->SetYTitleColor('blue'); $p->DrawGraph(); // Second plot: $p->SetDataValues($data2); $p->SetDataType('data-data'); $p->SetPlotType('lines'); $p->SetPlotAreaWorld(NULL, 0, NULL, NULL); // Force Y to start at 0 $p->SetYTickPos('plotright'); $p->SetYTickLabelPos('plotright'); // Right Y title only: $p->SetXTitle(''); // Clear this so it doesn't plot again
$row[] = sin($x + $i * $phase_factor); } $data[] = $row; } $plot = new PHPlot(1000, 800); $plot->SetPlotType('linepoints'); $plot->SetDataType('data-data'); $plot->SetDataValues($data); $plot->SetTitle("Line Plot, {$n} phases of Sin(x)"); $plot->SetPlotAreaWorld(0, -1, 2 * M_PI, 1); # Range: [0,-1] : [2 Pi, 1] $plot->SetXTickIncrement(M_PI / 8.0); # X tick step $plot->SetYTickIncrement(0.2); # Y tick step $plot->SetXLabelType('data', 3); # Format X tick labels as N.NNN $plot->SetLineStyles('solid'); # Make all lines solid $plot->SetYLabelType('data', 1); # Format Y tick labels as N.N $plot->SetDrawXGrid(True); # Draw X grid lines $plot->SetDrawYGrid(True); # Draw Y grid lines # Because one of the data colors is almost white, switch to black background: $plot->SetBackgroundColor('black'); $plot->SetTitleColor('white'); $plot->SetTextColor('white'); $plot->SetGridColor('white'); $plot->DrawGraph();
if (empty($data_type)) { $data_type = 'text-data'; } // text-data | text-data-yz # Driver array: key => method, and color: $cfg = array('text' => array('method' => 'SetTextColor', 'color' => 'red'), 'ticklabel' => array('method' => 'SetTickLabelColor', 'color' => 'DarkGreen'), 'datalabel' => array('method' => 'SetDataLabelColor', 'color' => 'purple'), 'datavaluelabel' => array('method' => 'SetDataValueLabelColor', 'color' => 'peru')); $data = array(array('A', 1, 2, 3, 4), array('B', 2, 3, 4, 5), array('C', 3, 4, 5, 6)); $plot = new PHPlot(800, 600); $plot->SetDataType($data_type); $plot->SetDataValues($data); $plot->SetPlotType($plot_type); $plot->SetXTitle('X Axis Title Here'); $plot->SetYTitle('Y Axis Title Here'); // Change all 3 title colors to show the change in data value // labels, which used title color incorrectly through 5.6.0 $plot->SetTitleColor('grey'); $plot->SetXTitleColor('SlateBlue'); $plot->SetYTitleColor('gold'); $plot->SetFont('x_label', '5'); $plot->SetFont('y_label', '5'); $plot->SetFont('x_title', '5'); $plot->SetFont('y_title', '5'); $plot->SetLegend(array('A', 'B', 'C')); # Turn off ticks on independent axis, and turn on data value labels. This # depends on the plot type and data type (horizontal or vertical): $label_pos = $plot_type == 'stackedbars' ? 'plotstack' : 'plotin'; if ($data_type == 'text-data-yx') { // Horizontal plot $plot->SetYTickPos('none'); $plot->SetXDataLabelPos($label_pos); } else {