function graficoBarra($data, $archivo = "", $meta_data = array('titulo' => 'Sin Título', 'tituloX' => 'Eje X', 'tituloY' => 'Eje Y', 'color' => 'SkyBlue', 'width' => 800, 'height' => 600, 'angle' => 45), $legend = array("Datos")) { # Objeto que crea el gráfico y su tama?o $plot = new PHPlot($meta_data['width'], $meta_data['height']); $plot->SetImageBorderType('plain'); # Setea el archivo donde se guarda la imagen generada y no permite la visualización inmediata $plot->SetPrintImage(false); $plot->SetFileFormat("jpg"); $plot->SetOutputFile($archivo); $plot->SetIsInline(true); # Envio de datos $plot->SetDataValues($data); # Tipo de gráfico y datos $plot->SetDataType("text-data"); $plot->SetPlotType("bars"); # Setiando el True type font //$plot->SetTTFPath(TTFPath); //$plot->SetUseTTF(TRUE); $plot->SetAxisFontSize(2); $plot->SetVertTickIncrement(7); //$plot->SetXTickLength(7); //$plot->SetDataColors($meta_data['color']); $plot->SetDataColors(array($meta_data['color'], 'red', 'white')); $plot->SetLegendPixels(1, 1); $plot->SetLegend($legend); # Etiquetas del eje Y: $plot->SetYTitle($meta_data['tituloY']); $plot->SetYDataLabelPos('plotin'); # Título principal del gráfico: $plot->SetTitle($meta_data['titulo']); # Etiquetas eje X: $plot->SetXTitle($meta_data['tituloX']); if (isset($meta_data['angle'])) { $plot->SetXLabelAngle($meta_data['angle']); } else { $plot->SetXLabelAngle(45); } $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); # Método que dibuja el gráfico $plot->DrawGraph(); $plot->PrintImage(); }
function plotGraph($data) { //Define the object $plot = new PHPlot(); $example_data = $data; $plot->SetDataValues($example_data); $plot->SetDataType('data-data'); //Set titles $plot->SetTitle("temp and humi"); $plot->SetXTitle('time'); $plot->SetYTitle('Y Data'); $legend = array('temp', 'humi'); $plot->SetLegend($legend); $plot->SetXDataLabelAngle(90); //$plot->SetXGridLabelType("time"); $plot->SetXTickLabelPos('xaxis'); $plot->SetXTickPos('plotdown'); $plot->SetXLabelType('time', '%H:%M'); $plot->TuneXAutoTicks(10, 'date'); // $plot->SetXTickIncrement(.5); //$plot->SetXTickIncrement(60 * 24); $plot->SetPlotType('lines'); //$plot->SetPlotAreaWorld(strtotime('00:00'), null, strtotime('23:59'), null); $plot->SetDrawXGrid(true); //Draw it $plot->DrawGraph(); }
public function doGet(WebAppRequest $req, WebAppResponse $res) { // Bootstraps Innomatic require_once 'innomatic/core/InnomaticContainer.php'; $innomatic = InnomaticContainer::instance('innomaticcontainer'); // Sets Innomatic base URL $baseUrl = ''; $webAppPath = $req->getUrlPath(); if (!is_null($webAppPath) && $webAppPath != '/') { $baseUrl = $req->generateControllerPath($webAppPath, true); } $innomatic->setBaseUrl($baseUrl); $innomatic->setInterface(InnomaticContainer::INTERFACE_WEB); $home = WebAppContainer::instance('webappcontainer')->getCurrentWebApp()->getHome(); $innomatic->bootstrap($home, $home . 'core/conf/innomatic.ini'); $id = basename($req->getParameter('id')); //$id = basename($_GET['id']); $args = unserialize(file_get_contents(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id)); require_once 'phplot/PHPlot.php'; $graph = new PHPlot($args['width'], $args['height']); $graph->SetIsInline('1'); //$graph->SetDataColors( array("blue",'white'),array("black") ); //$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid'); // Base $graph->SetDataValues($args['data']); $graph->SetPlotType($args['plottype']); // Appearance $graph->SetPointShape($args['pointshape']); $graph->SetPointSize($args['pointsize']); $graph->SetTitle($args['title']); // Color $graph->SetBackgroundColor($args['backgroundcolor']); $graph->SetGridColor($args['gridcolor']); if (count($args['legend'])) { $graph->SetLegend($args['legend']); } $graph->SetLineWidth($args['linewidth']); $graph->SetTextColor($args['textcolor']); $graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black'); //$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) ); //array('blue','green','yellow','red','orange'); $graph->DrawGraph(); unlink(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id); }
function testBars() { # PHPlot Example: Bar chart, 3 data sets, unshaded $data = array(array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4), array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4), array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4), array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 4)); $plot = new PHPlot(800, 600); $plot->SetIsInline(true); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Unshaded Bar Chart with 3 Data Sets'); # No 3-D shading of the bars: $plot->SetShading(0); # Make a legend for the 3 data sets plotted: $plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration')); # Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph(); }
function plotfile_me($pdf, $mv_id, $w = 800, $h = 600) { $mvs = new mietvertraege(); $mvs->get_mietvertrag_infos_aktuell($mv_id); $mk = new mietkonto(); $datum_mietdefinition = $mk->datum_1_mietdefinition($mv_id); // echo "<h1>$datum_mietdefinition</h1>"; $a_dat = explode('-', $datum_mietdefinition); $jahr_a = date("Y") - 2; $jahr_e = date("Y") + 3; $jahre = $jahr_e - $jahr_a; $z = 0; for ($jahr = $jahr_a; $jahr <= $jahr_e; $jahr++) { $monat = date("m"); $mk->kaltmiete_monatlich($mv_id, $monat, $jahr); if ($jahr > $jahr_a) { $miete_vorjahr = $arr_stat[$z - 1][1]; $prozent = ($mk->ausgangs_kaltmiete - $miete_vorjahr) / ($miete_vorjahr / 100); } else { $prozent = 0; } $prozent = nummer_punkt2komma($prozent); $arr_stat[$z][0] = "{$jahr}\n{$mk->ausgangs_kaltmiete}\nEUR\n{$prozent} %"; $arr_stat[$z][1] = $mk->ausgangs_kaltmiete; $z++; } // print_r($arr_stat); require_once 'phplot.php'; $plot = new PHPlot($w, $h); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($arr_stat); // Main plot title: $plot->SetTitle('MIETENTWICKLUNG' . " {$mvs->einheit_kurzname} \n {$mvs->personen_name_string}"); // No 3-D shading of the bars: $plot->SetShading(0); // Make a legend for the 3 data sets plotted: // $plot->SetLegend(array('Mieteinnahmen', 'Leerstand')); $plot->SetLegend(array('MIETE')); // Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); // Draw it $plot->SetIsInline(true); $img = $plot->DrawGraph(); $px = 'px'; // echo "<hr>$plot->img "; // $plot->PrintImageFrame(); // $hhh = $plot->PrintImage(); $ima = $plot->EncodeImage(); // echo "<a style=\"width:$w$px;heigth:$h$px;\" href=\"?option=stat_mv_big&mv_id=$mv_id\"><img style=\"width:$w$px;heigth:$h$px;\" src=\"$plot->img\"></img></a>"; // die(); // echo "<img src=\"$ima\">"; // die(); if ($mvs->mietvertrag_aktuell == 1) { $pdf->ezNewPage(); $druckdatum = date("d.m.Y"); $pdf->addText(464, 730, 7, "<b>Druckdatum: {$druckdatum}</b>"); $pdf->addPngFromFile($ima, $pdf->x + 10, $pdf->y - $h, $w, $h); } }
<?php # Testing phplot - Line-Points, extensions to suppress either # the line or the points on each plot. # $Id$ require_once 'phplot.php'; $data = array(array('', 1, 1, 2, 3), array('', 2, 2, 3, 4), array('', 3, 3, 4, 5), array('', 4, 4, 5, 6), array('', 5, 5, 6, 7), array('', 6, 6, 7, 8), array('', 7, 7, 8, 9), array('', 8, 8, 9, 10), array('', 9, 9, 10, 11), array('', 10, 10, 11, 12)); $p = new PHPlot(); $p->SetTitle('PlotType: linepoints with suppression'); $p->SetDataType('data-data'); $p->SetDataValues($data); # We don't use the data labels (all set to '') so might as well turn them off: $p->SetXDataLabelPos('none'); # Need to set area and ticks to get reasonable choices. # Increase X range to make room for the legend. $p->SetPlotAreaWorld(0, 0, 13, 20); $p->SetXTickIncrement(1); $p->SetYTickIncrement(2); $p->SetDataColors(array('red', 'green', 'blue')); $p->SetPointShapes(array('circle', 'none', 'diamond')); $p->SetLineStyles(array('solid', 'solid', 'none')); $p->SetLegend(array('circle+line', 'line only', 'diamond only')); # Make the points bigger so we can see them: $p->SetPointSizes(10); # Draw both grids: $p->SetDrawXGrid(True); $p->SetDrawYGrid(True); # The default $p->SetPlotType('linepoints'); $p->DrawGraph();
$tp = array_merge(array('title' => 'Transparent Background', 'suffix' => " (default)", 'FFormat' => NULL), $tp); require_once 'phplot.php'; $data = array(array('', -4, -64, 16, 40), array('', -3, -27, 9, 30), array('', -2, -8, 4, 20), array('', -1, -1, 1, 10), array('', 0, 0, 0, 0), array('', 1, 1, 1, -10), array('', 2, 8, 4, -20), array('', 3, 27, 9, -30), array('', 4, 64, 16, -40)); $p = new PHPlot(); # File format GIF or PNG, to test transparency: if (isset($tp['FFormat'])) { $p->SetFileFormat($tp['FFormat']); } # Background color will be transparent: $p->SetBackgroundColor('yellow'); $p->SetTransparentColor('yellow'); $p->SetTitle($tp['title'] . $tp['suffix']); $p->SetDataType('data-data'); $p->SetDataValues($data); # We don't use the data labels (all set to '') so might as well turn them off: $p->SetXDataLabelPos('none'); # Need to set area and ticks to get reasonable choices. $p->SetPlotAreaWorld(-4, -70, 4, 80); $p->SetXTickIncrement(1); $p->SetYTickIncrement(10); # Don't use dashes for 3rd line: $p->SetLineStyles('solid'); # Make the lines thicker: $p->SetLineWidths(3); # Draw both grids: $p->SetDrawXGrid(True); $p->SetDrawYGrid(True); # And a legend: $p->SetLegend(array('x^3', 'x^2', '-10x')); $p->SetPlotType('lines'); $p->DrawGraph();
<?php # PHPlot Example: Stacked Bars, shaded require_once 'phplot.php'; $data = array(array('Jan', 40, 5, 10, 3), array('Feb', 90, 8, 15, 4), array('Mar', 50, 6, 10, 4), array('Apr', 40, 3, 20, 4), array('May', 75, 2, 10, 5), array('Jun', 45, 6, 15, 5), array('Jul', 40, 5, 20, 6), array('Aug', 35, 6, 12, 6), array('Sep', 50, 5, 10, 7), array('Oct', 45, 6, 15, 8), array('Nov', 35, 6, 20, 9), array('Dec', 40, 7, 12, 9)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('stackedbars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); $plot->SetTitle('Candy Sales by Month and Product'); $plot->SetYTitle('Millions of Units'); $plot->SetLegend(array('Chocolates', 'Mints', 'Hard Candy', 'Sugar-Free')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();
} } } //////////////////////////////////////////////// //Required Settings include "../phplot.php"; $graph = new PHPlot($xsize_in, $ysize_in); $graph->SetDataType($which_data_type); // Must be first thing $graph->SetDataValues($data); //Optional Settings (Don't need them) // $graph->SetTitle("This is a\n\rmultiple line title\n\rspanning three lines."); $graph->SetTitle($title); $graph->SetXTitle($xlbl, $which_xtitle_pos); $graph->SetYTitle($ylbl, $which_ytitle_pos); $graph->SetLegend(array("A", "Bee", "Cee", "Dee")); $graph->SetFileFormat($which_fileformat); $graph->SetPlotType($which_plot_type); $graph->SetUseTTF($which_use_ttf); $graph->SetYTickIncrement($which_yti); $graph->SetXTickIncrement($which_xti); $graph->SetXTickLength($which_xtl); $graph->SetYTickLength($which_ytl); $graph->SetXTickCrossing($which_xtc); $graph->SetYTickCrossing($which_ytc); $graph->SetXTickPos($which_xtick_pos); $graph->SetYTickPos($which_ytick_pos); $graph->SetShading($which_shading); $graph->SetLineWidth($which_line_width); $graph->SetErrorBarLineWidth($which_errorbar_line_width); $graph->SetDrawDashedGrid($which_dashed_grid);
<?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();
} # Create a PHPlot object which will make an 800x400 pixel image: $p = new PHPlot(800, 400); # Use TrueType fonts: //$p->SetDefaultTTFont('./arial.ttf'); # Set the main plot title: $p->SetTitle('PHPlot Customer Satisfaction (estimated)'); # Select the data array representation and store the data: $p->SetDataType('text-data'); $p->SetDataValues($data); # Select the plot type - bar chart: $p->SetPlotType('bars'); # Define the data range. PHPlot can do this automatically, but not as well. $p->SetPlotAreaWorld(0, 0, 9, 100); # Select an overall image background color and another color under the plot: $p->SetBackgroundColor('#ffffcc'); $p->SetDrawPlotAreaBackground(True); $p->SetPlotBgColor('#ffffff'); # Draw lines on all 4 sides of the plot: $p->SetPlotBorderType('full'); # Set a 3 line legend, and position it in the upper left corner: $p->SetLegend(array('Features', 'Bugs', 'Happy Users')); $p->SetLegendWorld(0.1, 95); # Turn data labels on, and all ticks and tick labels off: $p->SetXDataLabelPos('plotdown'); $p->SetXTickPos('none'); $p->SetXTickLabelPos('none'); $p->SetYTickPos('none'); $p->SetYTickLabelPos('none'); # Generate and output the graph now: $p->DrawGraph();
<?php # $Id$ # PHPlot Example: Flat Pie with options require_once 'phplot.php'; $data = array(array('', 10), array('', 20), array('', 30), array('', 35), array('', 5)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetPlotType('pie'); $colors = array('red', 'green', 'blue', 'yellow', 'cyan'); $plot->SetDataColors($colors); $plot->SetLegend($colors); $plot->SetShading(0); $plot->SetLabelScalePosition(0.2); $plot->DrawGraph();
require_once 'phplot.php'; # To test with other plot types, scripts can set $plot_type and then # include this script. if (empty($plot_type)) { $plot_type = 'linepoints'; } $data = array(); $nx = 20; $ny = 5; for ($x = 0; $x < $nx; $x++) { $row = array('', $x); for ($iy = 0; $iy < $ny; $iy++) { $row[] = $ny - $iy; } $data[] = $row; } $shapes = array('dot', 'bowtie', 'none', 'rect', 'none'); for ($iy = 0; $iy < 5; $iy++) { $legend[$iy] = "Data Set #{$iy} using shape {$shapes[$iy]}"; } $p = new PHPlot(800, 600); $p->SetTitle("{$plot_type} plot with legend using point shapes, and\n" . "shape='none' on 2 of the data sets"); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetPlotType($plot_type); $p->SetLineStyles('solid'); $p->SetDrawYGrid(False); $p->SetPointShapes($shapes); $p->SetLegend($legend); $p->SetLegendUseShapes(True); $p->DrawGraph();
} # The variable $plot_type can be set in another script as well. if (empty($plot_type)) { $plot_type = 'linepoints'; } # Use data labels to display only the points we want, # but specify the same values for X to get the correct # spacing. $data = array(array('1990', 1990, 41308, 21015, 62634), array('1995', 1995, 44310, 13883, 61529), array('2000', 2000, 46772, 9000, 59421), array('2004', 2004, 46887, 7738, 57754), array('2006', 2006, 45441, 6888, 53179), array('2008', 2008, 42757, 5840, 49115)); $legend_text = array('Morning Papers', 'Evening Papers', 'Sunday Papers'); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); // Improves presentation in the manual $plot->SetTitle("US Daily Newspaper Circulation\n" . $plot_type . ' plot with SetLegendUseShapes(' . ($use_shapes ? 'True' : 'False') . ')'); $plot->SetPlotType($plot_type); $plot->SetDataType('data-data'); $plot->SetDataValues($data); $plot->SetPlotAreaWorld(1988, 0, 2010, 80000); $plot->SetYTickIncrement(10000); $plot->SetLegend($legend_text); $plot->SetXTickPos('none'); $plot->SetDrawXDataLabelLines(True); $plot->SetLegendUseShapes($use_shapes); // Use color boxes or shapes $plot->SetPointSizes(12); // Make points bigger for visibility $plot->SetLineStyles('solid'); // Make all lines solid $plot->SetLineWidths(2); // Make all lines thicker $plot->DrawGraph();
function costo_externo_interno_año($id_oficina, $año) { $this->autoLayout = false; $this->autoRender = false; $this->loadModel('CentroCosto'); $sql_oficina = ''; if ($id_oficina != 0) { $sql_oficina = " AND Cencos_id='" . $id_oficina . "' "; $cenco = $this->CentroCosto->find('first', array('fields' => array('CentroCosto.Cencos_nombre'), 'conditions' => array('CentroCosto.Cencos_id' => $id_oficina))); $subtitulo_oficina = 'la dependencia ' . mb_convert_case($cenco['CentroCosto']['Cencos_nombre'], MB_CASE_TITLE, "UTF-8"); } else { $subtitulo_oficina = 'todas las dependencias'; } $meses = $this->Solicitud->query("SELECT MONTH(solucionada) AS mes FROM solicitudes WHERE estado='s' " . $sql_oficina . " AND YEAR(solucionada)=" . $año . " GROUP BY MONTH(solucionada)"); if (!empty($meses)) { // Inicializamos el arreglo en ceros (para los meses ke no tienen solicitudes). $totales = array(); for ($i = 1; $i <= 12; $i++) { $totales[$i][0][0] = array('costo_i' => 0, 'costo_e' => 0); } foreach ($meses as $mes) { $costos_e_i = $this->Solicitud->query("SELECT SUM(costo_externo) AS costo_e, SUM(costo_interno) AS costo_i FROM solicitudes WHERE estado='s' AND YEAR(solucionada)=" . $año . " AND MONTH(solucionada)=" . $mes[0]['mes']); $totales[$mes[0]['mes']] = $costos_e_i; } if (!empty($totales)) { $total_costo_interno = $total_costo_externo = 0; $i = 0; $arreglo_plot = array(); foreach ($totales as $mes => $arreglo_mes) { // se construye el array para el PHPlot. if (count($arreglo_mes) > 0) { $arreglo_plot[$i] = array($this->meses[$mes], $arreglo_mes[0][0]['costo_i'], $arreglo_mes[0][0]['costo_e']); $total_costo_interno += $arreglo_mes[0][0]['costo_i']; $total_costo_externo += $arreglo_mes[0][0]['costo_e']; } else { $arreglo_plot[$i] = array($this->meses[$mes], 0, 0); } $i++; } $plot = new PHPlot(1790, 500); $plot->SetDataValues($arreglo_plot); $plot->SetDataType('text-data'); // Fuentes $plot->SetUseTTF(true); $plot->SetFontTTF('legend', 'FreeSans.ttf', 9); $plot->SetFontTTF('title', 'FreeSans.ttf', 14); $plot->SetFontTTF('y_label', 'FreeSans.ttf', 9); $plot->SetFontTTF('x_label', 'FreeSans.ttf', 10); $plot->SetFontTTF('y_title', 'FreeSans.ttf', 14); $plot->SetFontTTF('x_title', 'FreeSans.ttf', 12); // Titulos $plot->SetTitle("\nTotal de costos internos/externos\n" . "de " . $subtitulo_oficina . " en el año " . $año . "\n TOTAL Costo Interno = \$" . $total_costo_interno . "\n" . "TOTAL Costo Externo = \$" . $total_costo_externo); $plot->SetYTitle('$ COSTO'); // Etiquetas $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetYTickLabelPos('none'); $plot->SetYTickPos('none'); $plot->SetYDataLabelPos('plotin'); $plot->SetDrawXGrid(true); // Leyenda $leyenda = array('Costo Interno', 'Costo Externo'); $plot->SetLegend($leyenda); $plot->SetLegendPixels(27, 0); $plot->SetDataColors(array('beige', 'YellowGreen')); $plot->SetPlotType('bars'); $plot->SetShading(5); $plot->DrawGraph(); } } }
# Y2 = cos(x) $end = M_PI * 2.0; $delta = $end / 20.0; $data = array(); for ($x = 0; $x <= $end; $x += $delta) { $data[] = array('', $x, sin($x), cos($x)); } $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('lines'); $plot->SetDataType('data-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Line Plot, Sin and Cos'); # Make a legend for the 2 functions: $plot->SetLegend(array('sin(t)', 'cos(t)')); # Select a plot area and force ticks to nice values: $plot->SetPlotAreaWorld(0, -1, 6.8, 1); # Even though the data labels are empty, with numeric formatting they # will be output as zeros unless we turn them off: $plot->SetXDataLabelPos('none'); $plot->SetXTickIncrement(M_PI / 8.0); $plot->SetXLabelType('data'); $plot->SetPrecisionX(3); $plot->SetYTickIncrement(0.2); $plot->SetYLabelType('data'); $plot->SetPrecisionY(1); # Draw both grids: $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); $plot->DrawGraph();
$plot->SetDataType($data_type); $plot->SetDataValues($data); $plot->SetPlotBorderType('full'); #$plot->SetLabelScalePosition(0.50); # Plot 1 - upper left $plot->SetPlotAreaPixels(4, 25, 398, 323); $plot->SetPieLabelType('label'); $plot->SetPlotBgColor('plum'); $plot->DrawGraph(); # Plot 2 - upper right $plot->SetPlotAreaPixels(402, 25, 797, 323); $plot->SetPieLabelType('index'); $plot->SetPlotBgColor('salmon'); $plot->DrawGraph(); # Plot 3 - lower left $plot->SetPlotAreaPixels(4, 327, 398, 623); $plot->SetPieLabelType(''); // Reset to default $plot->SetDrawPlotAreaBackground(False); $plot->DrawGraph(); # Plot 4 - lower right $plot->SetPlotAreaPixels(402, 327, 797, 623); $plot->SetPieLabelType('value'); $plot->SetPlotBgColor('gray'); $plot->SetDrawPlotAreaBackground(True); // One legend for the whole image. Set it up before the last plot. $plot->SetLegendPosition(0.5, 0.5, 'plot', 0.0, 0.0); $plot->SetLegend($legend); $plot->DrawGraph(); # Done $plot->PrintImage();
exit; } if (DB_num_rows($SalesResult) == 0) { prnMsg(_('There is not sales data for the criteria entered to graph'), 'info'); include 'includes/footer.inc'; exit; } $GraphArrays = array(); $i = 0; while ($myrow = DB_fetch_array($SalesResult)) { $GraphArray[$i] = array(MonthAndYearFromSQLDate($myrow['lastdate_in_period']), $myrow['sales'], $myrow['budget']); $i++; } $graph->SetDataValues($GraphArray); $graph->SetDataColors(array('grey', 'wheat'), array('black')); $graph->SetLegend(array(_('Actual'), _('Budget'))); //Draw it $graph->DrawGraph(); echo '<br /><table class="selection" summary="' . _('Sales Report Graph') . '"> <tr> <th>' . _('Sales Report Graph') . ' <img src="' . $RootPath . '/css/' . $Theme . '/images/printer.png" class="PrintIcon noPrint" title="' . _('Print') . '" alt="' . _('Print') . '" onclick="window.print();" /> </th> </tr> <tr> <td> <img src="companies/' . $_SESSION['DatabaseName'] . '/reports/salesgraph.png" alt="' . _('Sales Report Graph') . '"></img> </td> </tr> </table>'; include 'includes/footer.inc';
} $tp = array_merge(array('title' => "Miscellaneous Options\nColor Map, Line Spacing, Dashed Grid", 'suffix' => " (baseline)", 'colormap' => NULL, 'datacolors' => NULL, 'linespacing' => NULL, 'dashedgrid' => True), $tp); require_once 'phplot.php'; # Land area in 10^6 sq km # $data = array(array('Monday', 10, 23, 7, 15), array('Tuesday', 25, 7, 12, 9), array('Wednesday', 8, 15, 18, 15), array('Thursday', 16, 9, 26, 16), array('Friday', 20, 25, 21, 14)); $plot = new PHPlot(800, 600); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); # Options: if (isset($tp['linespacing'])) { $plot->SetLineSpacing($tp['linespacing']); } if (isset($tp['colormap'])) { $plot->SetRGBArray($tp['colormap']); } if (isset($tp['datacolors'])) { $plot->SetDataColors($tp['datacolors']); $plot->SetErrorBarColors($tp['datacolors']); } $plot->SetDrawDashedGrid($tp['dashedgrid']); $plot->SetTitle($tp['title'] . "\n" . $tp['suffix']); $plot->SetLegend(array('Data Set 1', 'Data Set 2', 'Data Set 3', 'Data Set 4')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); $plot->SetPlotAreaWorld(NULL, 0, NULL, 30); $plot->SetNumYTicks(30); $plot->DrawGraph();
# Set line spacing: if (isset($tp['line_spacing'])) { $p->SetLineSpacing($tp['line_spacing']); } $p->SetTitle($tp['title'] . $tp['suffix']); # Need to set the font for TTF even if legendfont isn't given, to get the size. if ($tp['use_ttf']) { if (isset($tp['legendfont'])) { $p->SetFont('legend', $tp['legendfont'], $tp['ttfsize']); } else { $p->SetFont('legend', $tp['ttfont'], $tp['ttfsize']); } } elseif (isset($tp['legendfont'])) { $p->SetFont('legend', $tp['legendfont']); } $p->SetLegend($tp['text']); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetPlotType('lines'); $p->SetXDataLabelPos('none'); $p->SetXTickIncrement(1.0); $p->SetYTickIncrement(1.0); if (isset($tp['textalign'])) { if (isset($tp['colorboxalign'])) { $p->SetLegendStyle($tp['textalign'], $tp['colorboxalign']); } else { $p->SetLegendStyle($tp['textalign']); } } if (isset($tp['px']) && isset($tp['py'])) { $p->SetLegendPixels($tp['px'], $tp['py']);
# Testing phplot - Points require_once 'phplot.php'; # This array is used for both the point shapes and legend: $shapes = array('circle', 'cross', 'diamond', 'dot', 'halfline', 'line', 'plus', 'rect', 'triangle', 'trianglemid'); # 10 lines, one for each shape: $data = array(array('', 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), array('', 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11), array('', 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), array('', 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13), array('', 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), array('', 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15), array('', 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16), array('', 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17), array('', 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), array('', 10, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19)); $p = new PHPlot(); $p->SetTitle('Points plots, 10 lines/10 shapes'); $p->SetDataType('data-data'); $p->SetDataValues($data); # We don't use the data labels (all set to '') so might as well turn them off: $p->SetXDataLabelPos('none'); # Need to set area and ticks to get reasonable choices. # Increase X range to make room for the legend. $p->SetPlotAreaWorld(0, 0, 13, 20); $p->SetXTickIncrement(1); $p->SetYTickIncrement(2); # Need 10 different colors; defaults are not different: $p->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'orange')); # Show all 10 shapes: $p->SetPointShapes($shapes); # Also show that as the legend: $p->SetLegend($shapes); # Make the points bigger so we can see them: $p->SetPointSizes(10); # Draw both grids: $p->SetDrawXGrid(True); $p->SetDrawYGrid(True); # The default $p->SetPlotType('points'); $p->DrawGraph();
<?php //Include the code include "../phplot.php"; //Define the object $graph = new PHPlot(); //Set some data $example_data = array(array('', 3, 4, 5), array('', 3, 4, 5), array('', 3, 4, 5), array('', 4, 5, 7)); $graph->SetDataValues($example_data); //Error_Reporting(0); $graph->SetPlotType('pie'); $graph->SetLabelScalePosition(1.3); $graph->SetLegend(array('Blue Data', 'Green Data', 'Yellow Data')); //Draw it $graph->DrawGraph();
//don't bother trying to make a graph, if no users. exit; } //Set some data if ($graph_type == 1) { //text-data (no time) $example_data = array($data_array, $data_array); } else { //data-data (any extra entries are time). $example_data = array($data_array); } $graph->SetDataValues($example_data); //Error_Reporting(0); $graph->SetPlotType($graph_type_str); $graph->SetLabelScalePosition(1.27); $graph->SetLegend($legend_array); if ($graph_type == 2) { $graph->SetYLabel($element); $graph->SetXLabel($cw['users']); } else { $graph->SetLegendPixels(1, 1, ""); } //$graph->SetTitle("$element per user"); //Draw it $graph->DrawGraph(); //list things to change on the graph } else { print_header($cw['graphs']); if (isset($graph_selected) && $graph_selected == 1) { echo sprintf($st[143], $element) . "<img src='{$_SERVER['PHP_SELF']}?graph_db={$graph_db}&draw_graph=1&graph_type={$graph_type}&remaining={$remaining}' alt='" . sprintf($st[144], $graph_type_str, $element) . "' /><br />" . $st[145] . "</center>"; } else {
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require 'libs/phplot/phplot.php'; $data = $this->data; $lebar = $this->lebar; //var_dump($lebar); $plot = new PHPlot($lebar, 250); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('PENYELESAIAN SURAT BULAN ' . strtoupper(Tanggal::bulan_indo(date('m')))); $plot->SetBackgroundColor('#eeeeff'); $plot->SetDataColors(array('green', 'red', 'blue', 'grey')); # Make a legend for the 4 data sets plotted: $plot->SetLegend(array('SM selesai', 'SM belum selesai', 'SK selesai', 'SK belum selesai')); //$plot->SetLegendPosition(0, 0, 'image', 0, 0, 5, 5); //$plot->SetShading(0); # Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();
<?php //Include the code include_once '../library/phplot/phplot.php'; //Define the object $data = array(array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4), array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4), array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4), array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 30)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Shaded Bar Chart with 3 Data Sets'); # Make a legend for the 3 data sets plotted: $plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration')); # Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();
//Define the object $graph = new PHPlot(); $graph->SetPrintImage(0); //Set some data $example_data = array(array("a", 1, 2), array("b", 2, 2), array("c", 3, 2), array("d", 5, 2), array("e", 8, 2), array("f", 9, 2), array("f", 4, 2)); $graph->SetPlotAreaWorld(0, 0, 7.5, 10); $graph->SetVertTickPosition('plotleft'); $graph->SetSkipBottomTick(1); $graph->SetDataValues($example_data); $graph->SetDrawYGrid(0); $graph->SetPlotType('bars'); $graph->SetDrawDataLabels('1'); $graph->SetLabelScalePosition('1'); $graph->SetDataColors(array("orange", "blue"), array("green", "yellow")); $graph->SetMarginsPixels(50, 50, 50, 50); $graph->SetLegend(array('Time in Flight', 'Time to Stop')); //Lets have a legend $graph->SetLegendWorld(1, 8); //Lets have a legend position //Draw it $graph->DrawGraph(); //////////////////////NEXT SETTINGS $example_data = array(array("a", 60), array("b", 40), array("c", 50), array("d", 50), array("e", 80), array("f", 90), array("f", 40)); $graph->SetDataValues($example_data); $graph->SetDataColors(array("red"), array("green")); $graph->SetDrawXDataLabels(0); //We already got them in the first graph $graph->SetPlotAreaWorld(0, 0, 7.5, 100); //New Plot Area $graph->SetLegend(array('Size of Dog')); //Lets add a second legend
<?php require_once 'phplot.php'; $data = array(array('Pos', $_GET['pos']), array('Neg', $_GET['neg'])); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Falsos Negativos'); # Make a legend for the 3 data sets plotted: $plot->SetLegend(array('FP', 'FN')); # Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();
} if ($debug) { print_r($allDays); } if ($debug) { print "I" . $maxValue . "I"; } include "../include/phplot/phplot.php"; $graph = new PHPlot(600, 300); $graph->SetDataType("text-data"); $graph->SetDataValues($allDays); $graph->SetYTickIncrement(); $graph->y_tick_increment = ceil(@$graph->y_tick_increment); $graph->SetXLabelType("time"); $graph->SetXTimeFormat("%b %d"); if ($incoming == '2') { $graph->SetLegend(array("Outgoing")); $graph->SetDataColors(array('green')); } elseif ($incoming == '3') { $graph->SetLegend(array("Incoming")); $graph->SetDataColors(array('orange')); } else { $graph->SetLegend(array("All", "Outgoing", "Incoming")); } $graph->SetYTitle("Quantity of calls"); $graph->SetPlotType("bars"); $graph->SetXLabelAngle(90); // Turn off X tick labels and ticks because they don't apply here: $graph->SetXTickLabelPos('none'); $graph->SetXTickPos('none'); $graph->DrawGraph();
// set plot data and colors while ($data = $stat_query->fetch_row()) { $plot_data[] = array($data[0], $data[1]); $data_colors[] = '#' . generateRandomColors(); } break; } /** * Charts data definition end */ // Create plot if ($plot_data && $chart) { // set plot titles $plot->SetTitle($chart_title); // set data $plot->SetDataValues($plot_data); // set plot colors $plot->SetDataColors($data_colors); // set plot shading $plot->SetShading(20); // set plot type to pie $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); // set legend foreach ($plot_data as $row) { $plot->SetLegend(implode(': ', $row)); } //Draw it $plot->DrawGraph(); } exit;
<?php # $Id$ # Test: Stacked area require_once 'phplot.php'; # This is based on area1 with adjusted numbers. $data = array(array('1960', 30, 10, 6, 38, 14, 2), array('1970', 20, 17, 9, 32, 2, 20), array('1980', 20, 14, 12, 27, 2, 25), array('1990', 5, 26, 15, 26, 18, 10), array('2000', 28, 0, 18, 16, 33, 5)); $plot = new PHPlot(800, 600); $plot->SetPlotType('stackedarea'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); $plot->SetTitle('Candy Sales by Flavor'); $plot->SetPlotAreaWorld(NULL, 0, NULL, 110); $plot->SetYTickIncrement(10); $plot->SetYTitle('% of Total'); $plot->SetXTitle('Year'); $plot->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta')); $plot->SetLegend(array('Cherry', 'Lime', 'Lemon', 'Banana', 'Apple', 'Berry')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();