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 plotBarData($dataArray, $title) { $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)); $data = $dataArray; $plot = new PHPlot(400, 300); $plot->SetIsInline(true); $plot->SetOutputFile($title . '.png'); $plot->SetImageBorderType('plain'); $plot->SetPlotType('bars'); //$plot->SetPlotType('stackedbars'); //$plot->SetPlotType('lines'); $plot->SetDataType('text-data'); //$plot->SetDataType('data-data'); $plot->SetPlotAreaWorld(NULL, -10, NULL, 35); $plot->SetDataValues($data); $plot->SetDataColors(array('red', 'blue', 'green', 'yellow')); # Main plot title: $plot->SetTitle($title); # No 3-D shading of the bars: $plot->SetShading(0); # Make a legend for the 3 data sets plotted: $plot->SetLegend(array('min', 'avg', 'max')); //$plot->SetLegendPosition(0, 0, 'image', 0, 0, 35, 5); # Turn off X tick labels and ticks because they don't apply here: $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $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); }
// 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;
$data2[] = array('', $data1[$i][1], ($data1[$i][2] + $data1[$i][3]) / 2); } $p = new PHPlot(800, 600); $p->SetPrintImage(0); // Do not output image until told // First plot: $p->SetDataValues($data1); $p->SetDataType('text-data'); $p->SetPlotType('ohlc'); $p->SetPlotAreaWorld(NULL, 0); // For Y to start at 0 $p->SetXTickPos('none'); $p->SetTitle('OHLC and Line Plot Overlay'); $p->SetXTitle('Date', 'plotdown'); $p->SetYTitle('Security Price', 'plotleft'); $p->SetDrawPlotAreaBackground(True); $p->SetPlotBgColor('PeachPuff'); $p->SetMarginsPixels(50, 50, 50, 50); $p->DrawGraph(); // Second plot: $p->SetDrawPlotAreaBackground(False); $p->SetDataValues($data2); $p->SetDataType('text-data'); $p->SetPlotType('lines'); $p->SetDataColors(array('red', 'orange')); // Must clear X and Y titles or they are drawn again, possibly with offset. $p->SetXTitle(''); $p->SetYTitle(''); $p->DrawGraph(); // Now output the completed image $p->PrintImage();
$data[] = $row; } # This gets imploded to be the title, after options are added on: $title = array("Lines plot"); if ($tp['truecolor']) { $p = new PHPlot_truecolor(1024, 768); $title[] = "Truecolor"; } else { $p = new PHPlot(1024, 768); $title[] = "Palette Color"; } $p->SetCallback('draw_setup', 'pre_plot'); $p->SetCallback('draw_all', 'post_plot'); # Reload data colors and apply alpha to all: if (isset($tp['alpha'])) { $p->SetDataColors(NULL, NULL, $tp['alpha']); $title[] = "Alpha=" . $tp['alpha']; } $p->SetFileFormat($tp['output']); $title[] = strtoupper($tp['output']) . ' Output'; if ($tp['antialias']) { $title[] = "Antialiased"; } if ($tp['noalphablend']) { $title[] = "No alpha blending"; } if (isset($tp['gamma'])) { $title[] = "Gamma=" . $tp['gamma']; } if ($tp['savealpha']) { $title[] = "Save alpha";
} $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();
<?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();
$graph->SetDrawYGrid("1"); // 1 = true $graph->SetDataValues($data); $graph->SetImageArea(600, 400); $graph->SetVertTickIncrement(""); $graph->SetHorizTickIncrement(1); $graph->SetErrorBarLineWidth(1); $graph->SetYScaleType("log"); $graph->SetPointShape("halfline"); $graph->SetErrorBarShape("line"); $graph->SetPlotType("points"); $graph->SetXGridLabelType("title"); $graph->SetXLabel("Day"); $graph->SetYLabel("index"); $graph->SetTitle("Stock Market Data"); //$graph->SetErrorBarColors(array("blue","red","green","black")); $graph->SetDataColors(array("blue", "green", "yellow", "red"), array("black")); //$graph->SetPlotAreaWorld(0,5,32,30); //$graph->SetPlotAreaPixels(150,50,600,400); /* //Other settings $graph->SetPlotBgColor(array(222,222,222)); $graph->SetBackgroundColor(array(200,222,222)); //can use rgb values or "name" values $graph->SetTextColor("black"); $graph->SetGridColor("black"); $graph->SetLightGridColor(array(175,175,175)); $graph->SetTickColor("black"); $graph->SetTitleColor(array(0,0,0)); // Can be array or name */ //Draw the graph $graph->DrawGraph();
require_once 'phplot.php'; $data1 = array(array('1981', 5996), array('1982', 5113), array('1983', 5051), array('1984', 5437), array('1985', 5067), array('1986', 6224), array('1987', 6678), array('1988', 7402), array('1989', 8061), array('1990', 8018), array('1991', 7627), array('1992', 7888), array('1993', 8620), array('1994', 8996), array('1995', 8835), array('1996', 9478), array('1997', 10162), array('1998', 10708), array('1999', 10852), array('2000', 11459)); $data2 = array(array('1981', 595), array('1982', 815), array('1983', 739), array('1984', 722), array('1985', 781), array('1986', 785), array('1987', 764), array('1988', 815), array('1989', 859), array('1990', 857), array('1991', 1001), array('1992', 950), array('1993', 1003), array('1994', 942), array('1995', 949), array('1996', 981), array('1997', 1003), array('1998', 945), array('1999', 940), array('2000', 1040)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); # Disable auto-output: $plot->SetPrintImage(0); # There is only one title: it is outside both plot areas. $plot->SetTitle('US Petroleum Import/Export'); # Set up area for first plot: $plot->SetPlotAreaPixels(80, 40, 740, 350); # Do the first plot: $plot->SetDataType('text-data'); $plot->SetDataValues($data1); $plot->SetPlotAreaWorld(NULL, 0, NULL, 13000); $plot->SetDataColors(array('blue')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetYTickIncrement(1000); $plot->SetYTitle("IMPORTS\n1000 barrels/day"); $plot->SetPlotType('bars'); $plot->DrawGraph(); # Set up area for second plot: $plot->SetPlotAreaPixels(80, 400, 740, 550); # Do the second plot: $plot->SetDataType('text-data'); $plot->SetDataValues($data2); $plot->SetPlotAreaWorld(NULL, 0, NULL, 1300); $plot->SetDataColors(array('green')); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none');
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ require 'libs/phplot/phplot.php'; $color = array('DarkGreen', 'green', 'orange', 'blue', 'red', 'SkyBlue', 'purple', 'peru', 'cyan', 'salmon', 'SlateBlue', 'yellow', 'magenta', 'aquamarine1', 'gold', 'violet'); $data = $this->data; $lebar = $this->lebar * 0.4; $plot = new PHPlot($lebar, 250); $plot->SetImageBorderType('plain'); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('TIPE NASKAH ' . date('Y')); $plot->SetBackgroundColor('#eeeeff'); # Make a legend for the 3 data sets plotted: # Turn off X tick labels and ticks because they don't apply here: $plot->SetDataColors(array('lavender', 'red', 'green', 'blue', 'yellow', 'SlateBlue', 'cyan', 'magenta', 'brown', 'pink', 'gray', 'orange', 'purple', 'peru', 'salmon', 'aquamarine1', 'violet', 'gold')); $plot->SetDataColors($color); foreach ($data as $row) { $plot->SetLegend(implode(': ', $row)); } # Place the legend in the upper left corner: $plot->SetLegendPixels(5, 5); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->DrawGraph();
<?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();
function BuatPieGraph($filetujuan, $prevtahun, $tahun, $urutan, $gel) { $fg = GetaField("aplikan a left outer join pmbperiod p on a.PMBPeriodID=p.PMBPeriodID and a.KodeID=p.KodeID and p.Tahun='{$tahun}'", "a.SudahBekerja='N' and a.KodeID", KodeID, "count(a.AplikanID)"); $nfg = GetaField("aplikan a left outer join pmbperiod p on a.PMBPeriodID=p.PMBPeriodID and a.KodeID=p.KodeID and p.Tahun='{$tahun}'", "a.SudahBekerja='Y' and a.KodeID", KodeID, "count(a.AplikanID)"); $data = array(array('Fresh Graduate', $fg), array('Non Fresh Graduate', $nfg)); $plot = new PHPlot(800, 600); //$plot->SetImageBorderType('raised'); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetDataColors(array('red', 'blue', 'green', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'gray', 'orange')); $plot->setShading(60); $plot->SetLabelScalePosition(0.2); $plot->SetFont('generic', 5); $plot->SetFont('title', 5); $plot->SetFont('legend', 5); $plot->SetTitle("Resume % Aplikan Fresh / non Fresh Graduate"); foreach ($data as $row) { $plot->SetLegend(implode(': ', $row)); } $plot->SetIsInline(true); $plot->SetOutputFile($filetujuan); $plot->DrawGraph(); }
function BuatPieGraph($filetujuan, $prevtahun, $tahun, $urutan, $gel) { $fg = GetaField("pmb b left outer join pmbperiod p on b.PMBPeriodID=p.PMBPeriodID and b.KodeID=p.KodeID and LEFT(p.PMBPeriodID, 4)='{$tahun}'", "(b.TahunLulus='{$prevtahun}' or b.TahunLulus='{$tahun}') and b.KodeID", KodeID, "count(b.PMBID)"); $nfg = GetaField("pmb b left outer join pmbperiod p on b.PMBPeriodID=p.PMBPeriodID and b.KodeID=p.KodeID and LEFT(p.PMBPeriodID, 4)='{$tahun}'", "b.TahunLulus < '{$prevtahun}' and b.KodeID", KodeID, "count(b.PMBID)"); $data = array(array('Fresh Graduate', $fg), array('Non Fresh Graduate', $nfg)); $plot = new PHPlot(800, 600); //$plot->SetImageBorderType('raised'); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetDataColors(array('red', 'blue', 'green', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'gray', 'orange')); $plot->setShading(60); $plot->SetLabelScalePosition(0.2); $plot->SetFont('generic', 5); $plot->SetFont('title', 5); $plot->SetFont('legend', 5); $plot->SetTitle("Persentase Calon Mahasiswa Fresh / non Fresh Graduate"); foreach ($data as $row) { $plot->SetLegend(implode(': ', $row)); } $plot->SetIsInline(true); $plot->SetOutputFile($filetujuan); $plot->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(); }
$plot->SetFontTTF('x_title', $font, 14); $plot->SetFontTTF('y_title', $font, 10); # Disable auto-output: $plot->SetPrintImage(0); $title = "Test {$n_plots} Plots with TTF Title (sequence {$title_sequence})"; $y1 = $title_space; // Top of plot area for ($i = 0; $i < $n_plots; $i++) { if ($i == $title_sequence) { $plot->SetTitle($title); } $y2 = $y1 + $height_of_each_plot; // Bottom of plot area # fwrite(STDERR, "Plot $i area: min=(80, $y1) : max=(740, $y2)\n"); $plot->SetPlotAreaPixels(80, $y1, 740, $y2); $plot->SetDataType('text-data'); $plot->SetDataValues($report[$i]); $plot->SetPlotAreaWorld(NULL, 0, NULL, $max_x); $plot->SetDataColors(array('blue')); $plot->SetXTickLabelPos('none'); $plot->SetXDataLabelPos('plotdown'); $plot->SetXTickPos('plotdown'); $plot->SetYTickIncrement(1); $plot->SetXTitle("Chart {$i} X Values"); $plot->SetYTitle("Chart {$i} Y Values"); $plot->SetPlotType('bars'); $plot->DrawGraph(); $y1 = $y2 + $space_below_plots; // Start next plot below last plot } $plot->PrintImage();
} 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();
//Include the code include "../phplot.php"; //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
<?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();
} // Read and check the file header. $row = fgetcsv($f); if ($row === FALSE || $row[0] != 'Date' || $row[1] != 'Open' || $row[2] != 'High' || $row[3] != 'Low' || $row[4] != 'Close') { fwrite(STDERR, "Incorrect header in: {$filename}\n"); return FALSE; } // Read the rest of the file and convert. while ($d = fgetcsv($f)) { $data[] = array('', strtotime($d[0]), $d[1], $d[2], $d[3], $d[4]); } fclose($f); return $data; } $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); // Improves presentation in the manual $plot->SetTitle("Filled Candlesticks Financial Plot (data-data)\nMSFT Q1 2009"); $plot->SetDataType('data-data'); $plot->SetDataValues(read_prices_data_data(DATAFILE)); $plot->SetPlotType('candlesticks2'); $plot->SetDataColors(array('red', 'DarkGreen', 'red', 'DarkGreen')); $plot->SetXLabelAngle(90); $plot->SetXLabelType('time', '%Y-%m-%d'); $plot->SetXTickIncrement(7 * 24 * 60 * 60); // 1 week interval if (method_exists($plot, 'TuneYAutoRange')) { $plot->TuneYAutoRange(0); } // Suppress Y zero magnet (PHPlot >= 6.0.0) $plot->DrawGraph();
} // Read and check the file header. $row = fgetcsv($f); if ($row === FALSE || $row[0] != 'Date' || $row[1] != 'Open' || $row[2] != 'High' || $row[3] != 'Low' || $row[4] != 'Close') { fwrite(STDERR, "Incorrect header in: {$filename}\n"); return FALSE; } // Read the rest of the file and convert. while ($d = fgetcsv($f)) { $data[] = array('', strtotime($d[0]), $d[1], $d[2], $d[3], $d[4]); } fclose($f); return $data; } $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); // Improves presentation in the manual $plot->SetTitle("Candlesticks Financial Plot (data-data)\nMSFT Q1 2009"); $plot->SetDataType('data-data'); $plot->SetDataValues(read_prices_data_data(DATAFILE)); $plot->SetPlotType('candlesticks'); $plot->SetDataColors(array('SlateBlue', 'black', 'SlateBlue', 'black')); $plot->SetXLabelAngle(90); $plot->SetXLabelType('time', '%Y-%m-%d'); $plot->SetXTickIncrement(7 * 24 * 60 * 60); // 1 week interval if (method_exists($plot, 'TuneYAutoRange')) { $plot->TuneYAutoRange(0); } // Suppress Y zero magnet (PHPlot >= 6.0.0) $plot->DrawGraph();
include 'includes/footer.inc'; 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>';
<?php //Include the code include "../phplot.php"; //Define the object and get background image 0cars.jpg //////NOTE! THIS EXAMPLE WILL ONLY WORK IF YOU HAVE //////JPEG SUPPORT ENABLED. (Use a different file as a background //////if you have png or gif enabled. $graph = new PHPlot(500, 223, "", "0cars.jpg"); //Set some data $example_data = array(array("55", 5), array("60", 10), array("65", 20), array("70", 30), array("75", 25), array("80", 10)); $graph->SetDataValues($example_data); //Set up some nice formatting things $graph->SetTitle("Speed Histogram"); $graph->SetXLabel("Miles per Hour"); $graph->SetYLabel("Percent of Cars"); $graph->SetVertTickIncrement(5); $graph->SetPlotAreaWorld(0, 0, 6, 35); //Make the margins nice for the background image $graph->SetMarginsPixels(80, 35, 35, 70); //Set up some color and printing options $graph->background_done = 1; //The image background we get from 0cars.jpg $graph->SetDrawPlotAreaBackground(0); //Plot Area background we get from the image $graph->SetDataColors(array("white"), array("black")); //Set Output format $graph->SetFileFormat("png"); //Draw it $graph->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(); } } }
<?php # $Id$ # PHPlot Example: Pie/text-data-single require_once 'phplot.php'; # The data labels aren't used directly by PHPlot. They are here for our # reference, and we copy them to the legend below. $data = array(array('Australia', 7849), array('Dem Rep Congo', 299), array('Canada', 5447), array('Columbia', 944), array('Ghana', 541), array('China', 3215), array('Philippines', 791), array('South Africa', 19454), array('Mexico', 311), array('United States', 9458), array('USSR', 9710)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('pie'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); # Set enough different colors; $plot->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'brown', 'lavender', 'pink', 'gray', 'orange')); # Main plot title: $plot->SetTitle("World Gold Production, 1990\n(1000s of Troy Ounces)"); # Build a legend from our data array. # Each call to SetLegend makes one line as "label: value". foreach ($data as $row) { $plot->SetLegend(implode(': ', $row)); } $plot->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();
# PHPlot / contrib / color_range : Example # $Id$ # This is a bar chart with a color gradient for the bars in each group. require_once 'phplot.php'; require_once 'color_range.php'; $bars_per_group = 10; $x_values = 4; mt_srand(1); $data = array(); for ($i = 0; $i < $x_values; $i++) { $row = array($i); for ($j = 0; $j < $bars_per_group; $j++) { $row[] = mt_rand(0, 100); } $data[] = $row; } $p = new PHPlot(800, 600); $p->SetTitle('Example - Bar Chart with gradient colors'); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetPlotAreaWorld(0, 0, $x_values, 100); # This isn't necessary, as we do know how many data sets (bars_per_group): $n_data = count_data_sets($data, 'text-data'); # Make a gradient color map: $colors = color_range($p->SetRGBColor('SkyBlue'), $p->SetRGBColor('DarkGreen'), $n_data); $p->SetDataColors($colors); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->SetPlotType('bars'); $p->DrawGraph();
require 'mem_image.php'; $graph = new PHPlot(500, 300); $graph->SetDataType('data-data'); //Specify some data $data = array(array('', 2000, 750), array('', 2010, 1700), array('', 2015, 2000), array('', 2020, 1800), array('', 2025, 1300), array('', 2030, 400)); $graph->SetDataValues($data); //Specify plotting area details $graph->SetPlotType('lines'); $graph->SetTitleFontSize('2'); $graph->SetTitle('Social Security trust fund asset estimates, in $ billions'); $graph->SetMarginsPixels(null, null, 40, null); $graph->SetPlotAreaWorld(2000, 0, 2035, 2000); $graph->SetPlotBgColor('white'); $graph->SetPlotBorderType('left'); $graph->SetBackgroundColor('white'); $graph->SetDataColors(array('red'), array('black')); //Define the X axis $graph->SetXLabel('Year'); $graph->SetXTickIncrement(5); //Define the Y axis $graph->SetYTickIncrement(500); $graph->SetPrecisionY(0); $graph->SetLightGridColor('blue'); //Disable image output $graph->SetPrintImage(false); //Draw the graph $graph->DrawGraph(); $pdf = new PDF_MemImage(); $pdf->AddPage(); $pdf->GDImage($graph->img, 30, 20, 140); $pdf->Output();
license@systemsmanager.net so we can mail you a copy immediately. */ include DIR_WS_CLASSES . 'phplot.php'; $year = $_GET['year'] ? $_GET['year'] : date('Y'); $month = $_GET['month'] ? $_GET['month'] : date('n'); $days = date('t', mktime(0, 0, 0, $month)) + 1; $stats = array(); for ($i = 1; $i < $days; $i++) { $stats[] = array($i, '0', '0'); } $banner_stats_query = smn_db_query("select dayofmonth(banners_history_date) as banner_day, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and month(banners_history_date) = '" . $month . "' and year(banners_history_date) = '" . $year . "'"); while ($banner_stats = smn_db_fetch_array($banner_stats_query)) { $stats[$banner_stats['banner_day'] - 1] = array($banner_stats['banner_day'], $banner_stats['value'] ? $banner_stats['value'] : '0', $banner_stats['dvalue'] ? $banner_stats['dvalue'] : '0'); } $graph = new PHPlot(600, 350, 'images/graphs/banner_daily-' . $banner_id . '.' . $banner_extension); $graph->SetFileFormat($banner_extension); $graph->SetIsInline(1); $graph->SetPrintImage(0); $graph->SetSkipBottomTick(1); $graph->SetDrawYGrid(1); $graph->SetPrecisionY(0); $graph->SetPlotType('lines'); $graph->SetPlotBorderType('left'); $graph->SetTitleFontSize('4'); $graph->SetTitle(sprintf(TEXT_BANNERS_DAILY_STATISTICS, $banner['banners_title'], strftime('%B', mktime(0, 0, 0, $month)), $year)); $graph->SetBackgroundColor('white'); $graph->SetVertTickPosition('plotleft'); $graph->SetDataValues($stats); $graph->SetDataColors(array('blue', 'red'), array('blue', 'red')); $graph->DrawGraph(); $graph->PrintImage();
<?php # PHPlot Example: Point chart with error bars require_once 'phplot.php'; $data = array(array('', 1, 23.5, 5, 5), array('', 2, 20.1, 3, 3), array('', 3, 19.1, 2, 2), array('', 4, 16.8, 3, 3), array('', 5, 18.4, 4, 6), array('', 6, 20.5, 3, 2), array('', 7, 23.2, 4, 4), array('', 8, 23.1, 5, 2), array('', 9, 24.5, 2, 2), array('', 10, 28.1, 2, 2)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('points'); $plot->SetDataType('data-data-error'); $plot->SetDataValues($data); # Main plot title: $plot->SetTitle('Points Plot With Error Bars'); # Set data range and tick increments to get nice even numbers: $plot->SetPlotAreaWorld(0, 0, 11, 40); $plot->SetXTickIncrement(1); $plot->SetYTickIncrement(5); # Draw both grids: $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); # Is default # Set some options for error bars: $plot->SetErrorBarShape('tee'); # Is default $plot->SetErrorBarSize(10); $plot->SetErrorBarLineWidth(2); # Use a darker color for the plot: $plot->SetDataColors('brown'); $plot->SetErrorBarColors('brown'); # Make the points bigger so we can see them: $plot->SetPointSizes(10); $plot->DrawGraph();