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 renderLot() { $grafico = new PHPlot(800, 600); $grafico->SetFileFormat("jpg"); $grafico->SetIsInline(True); #Indicamos o títul do gráfico e o título dos dados no eixo X e Y do mesmo $grafico->SetTitle($this->data->titulo); $grafico->SetXTitle($this->data->eixoX); $grafico->SetYTitle($this->data->eixoY); #passamos o tipo de gráfico escolhido if (!$this->data->tipoLot) { $this->data->tipoLot = 'bars'; } $grafico->SetPlotType($this->data->tipoLot); switch ($this->data->tipoLot) { case 'pie': $grafico->SetPieLabelType('index', 'custom', 'mycallback'); $grafico->SetDataType('text-data-single'); break; case 'stackedbars': $grafico->SetDataType('text-data-yx'); break; case 'bubbles': $grafico->SetDataType('data-data-xyz'); break; } $grafico->SetLegend($column_names); #Definimos os dados do gráfico switch ($this->data->tipoLot) { case 'pie': $dados = array(array($this->data->x1, $this->data->y11), array($this->data->x2, $this->data->y21), array($this->data->x3, $this->data->y31), array($this->data->x4, $this->data->y41)); break; default: $dados = array(array($this->data->x1, $this->data->y11, $this->data->y12, $this->data->y13), array($this->data->x2, $this->data->y21, $this->data->y22, $this->data->y23), array($this->data->x3, $this->data->y31, $this->data->y32, $this->data->y33), array($this->data->x4, $this->data->y41, $this->data->y42, $this->data->y43)); break; } $grafico->SetDataValues($dados); #Salvamos o gráfico $caminho = \Manager::getFilesPath(); $fileName = uniqid() . '.jpg'; $grafico->SetOutputFile($caminho . '/' . $fileName); $grafico->SetIsInline(True); $grafico->DrawGraph(); #obtemos o endereco do grafico $this->data->locate = \Manager::getDownloadURL('files', basename($fileName), true); }
function make_plot($plot_type, $data_type, $nx, $ny) { $plot = new PHPlot(1280, 1024); $plot->SetPrintImage(False); $plot->SetFailureImage(False); $plot->SetDataType($data_type); $plot->SetDataValues(make_data_array($plot_type, $data_type, $nx, $ny, 100)); $plot->SetPlotType($plot_type); $plot->SetTitle("Serialize/Unserialize Tests\n{$plot_type} - {$data_type}"); $plot->SetXTickIncrement(5); $plot->SetYTickIncrement(10); $plot->SetPlotBorderType('full'); $plot->SetDrawXGrid(True); $plot->SetDrawYGrid(True); $plot->SetXTitle('X Axis Title'); $plot->SetYTitle('Y Axis Title'); # Select data labels or tick labels based on data type: if ($data_type == 'data-data') { $plot->SetXDataLabelPos('none'); $plot->SetXTickLabelPos('plotdown'); $plot->SetXTickPos('plotdown'); } elseif ($data_type == 'text-data') { $plot->SetXDataLabelPos('plotdown'); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); } elseif ($data_type == 'data-data-yx') { $plot->SetYDataLabelPos('none'); $plot->SetYTickLabelPos('plotleft'); $plot->SetYTickPos('plotleft'); } elseif ($data_type == 'text-data-yx') { $plot->SetYDataLabelPos('plotleft'); $plot->SetYTickLabelPos('none'); $plot->SetYTickPos('none'); } return $plot; }
$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'); $plot->SetYTickIncrement(200); $plot->SetYTitle("EXPORTS\n1000 barrels/day"); $plot->SetPlotType('bars'); $plot->DrawGraph();
} else { $prevData = array($printMonth, 1, $outg, $inc); } $allDays[$allDaysKey] = $prevData; $allDaysKey++; //print"<font color=red>$prevDay=$mkday</font><br>"; } $prevDay = $mkday; $prevDOfMonth = $DayOfMonth; } //if($debug) print_r($allDays); //if($debug) print("I".$maxValue."I"); include "../include/phplot/phplot.php"; $graph = new PHPlot(600, 300); if (isset($Columns) && $Columns > 30) { $graph->SetYTitle("Duration days hours:minutes:seconds"); $graph->SetYTimeFormat("%e %H:%M:%S"); } else { $graph->SetYTitle("Duration hours:minutes:seconds"); $graph->SetYTimeFormat("%H:%M:%S"); } $graph->SetDataType("text-data"); $graph->SetDataValues($allDays); $graph->SetYLabelType("time"); $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"));
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 # PHPlot Example - Horizontal linepoints plot with Y Data Label Lines require_once 'phplot.php'; $data = array(array("SEA\nLEVEL", 0, ''), array('100m', 1, 10), array('200m', 2, 22), array('300m', 3, 30), array('400m', 4, 46), array('500m', 5, 53), array('600m', 6, 65), array('700m', 7, 70), array('800m', 8, 50), array('900m', 9, 35)); $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); // Improves presentation in the manual $plot->SetTitle('Wind Speed at Altitude'); $plot->SetDataType('data-data-yx'); $plot->SetDataValues($data); $plot->SetPlotType('linepoints'); $plot->SetPlotAreaWorld(0, 0, 100, 10); $plot->SetDrawYDataLabelLines(True); $plot->SetXTitle('Wind Speed'); $plot->SetYTitle('Altitude'); $plot->SetYTickLabelPos('none'); $plot->SetYTickPos('none'); $plot->SetXDataLabelPos('plotin'); $plot->SetDrawXGrid(False); $plot->SetDrawYGrid(False); $plot->DrawGraph();
<?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 deg_min_sec($value) { if ($value >= 0) { $sign = ''; } else { $sign = '-'; $value *= -1; } $deg = (int) $value; $value = ($value - $deg) * 60; $min = (int) $value; $sec = (int) (($value - $min) * 60); return "{$sign}{$deg}d {$min}m {$sec}s"; } $data = array(); for ($i = 0; $i < 15; $i++) { $data[] = array('', 13 * $i + $i / 14); } $p = new PHPlot(800, 600); $p->SetTitle("Label Format Test 6 with Y data labels"); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetXDataLabelPos('none'); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->SetYTickIncrement(15); $p->SetYDataLabelPos('plotin'); $p->SetPlotType('bars'); $p->SetYLabelType('custom', 'deg_min_sec'); $p->SetYTitle("Y: custom Deg/Min/Sec"); $p->DrawGraph();
<?php # $Id$ # Testing phplot - Default TT font (2b): Local path and named font. # This test requires a specific font (see TEST_FONT) be present in the images/ # directory. The listed font is redistributable under the Open Fonts License. require_once 'phplot.php'; define('TEST_FONT', 'FreeUniversal-Regular.ttf'); $data = array(array('A', 3, 6), array('B', 2, 4), array('C', 1, 2)); $p = new PHPlot(800, 800); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitle('Local TTF path and SetFontTTF with file basename only'); $p->SetXTitle('X Axis Title'); $p->SetYTitle('Y Axis Title'); $p->SetTTFPath(getcwd() . DIRECTORY_SEPARATOR . 'images'); $p->SetFontTTF('title', TEST_FONT, 18); $p->SetFontTTF('x_title', TEST_FONT, 14); $p->SetFontTTF('y_title', TEST_FONT, 10); $p->DrawGraph(); fwrite(STDERR, "OK defaultfont2b: title font=" . $p->fonts['title']['font'] . "\n");
$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();
<?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();
# This is a cubic equation with roots at -8, 2, 10 for ($x = -10; $x <= 10; $x++) { $data[] = array('', $x, ($x + 8) * ($x - 2) * ($x - 10)); } $p = new PHPlot(400, 800); $p->SetPrintImage(FALSE); $p->SetPlotBorderType('full'); $p->SetTitle("Set/Reset Parameters Test (2)\n" . "Top: Parameters Set\n" . "Bottom: Parameters Reset"); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetPlotType('lines'); $p->SetLegend('Y = F(X)'); $p->SetLegendPixels(100, 200); $p->SetNumXTicks(5); $p->SetNumYTicks(8); $p->SetXTitle('X Axis with 5 ticks'); $p->SetYTitle('Y Axis with 8 ticks'); $p->SetXAxisPosition(-228); $p->SetYAxisPosition(7); $p->SetPlotAreaPixels(70, 80, 380, 400); $p->DrawGraph(); $p->SetLegendPixels(); $p->SetNumXTicks(); $p->SetNumYTicks(); $p->SetXTitle('X Axis'); $p->SetYTitle('Y Axis'); $p->SetXAxisPosition(); $p->SetYAxisPosition(); $p->SetPlotAreaPixels(70, 450, 380, 750); $p->DrawGraph(); $p->PrintImage();
require_once 'phplot.php'; $data = array(); # This is a cubic equation with roots at -8, 2, 10 for ($x = -10; $x <= 10; $x++) { $data[] = array('', $x, ($x + 8) * ($x - 2) * ($x - 10)); } $p = new PHPlot(400, 800); $p->SetPrintImage(FALSE); $p->SetPlotBorderType('full'); $p->SetTitle("Set/Reset Parameters Test (1)\n" . "Top: Parameters Set\n" . "Bottom: Parameters Reset"); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetPlotType('lines'); $p->SetLegend('Y = F(X)'); $p->SetLegendPixels(100, 200); $p->SetXTickIncrement(5.0); $p->SetYTickIncrement(50.0); $p->SetXTitle('X Axis'); $p->SetYTitle('Y Axis'); $p->SetXAxisPosition(-228); $p->SetYAxisPosition(7); $p->SetPlotAreaPixels(70, 80, 380, 400); $p->DrawGraph(); $p->SetLegendPixels(); $p->SetXTickIncrement(); $p->SetYTickIncrement(); $p->SetXAxisPosition(); $p->SetYAxisPosition(); $p->SetPlotAreaPixels(70, 450, 380, 750); $p->DrawGraph(); $p->PrintImage();
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(); }
$p->SetFont('y_title', '', 12); $p->SetFont('x_label', '', 12); $p->SetFont('y_label', '', 12); $p->SetFont('generic', '', 14); } elseif ($tp['use_gdf']) { $p->SetFont('legend', '4'); $p->SetFont('title', '5'); $p->SetFont('x_title', '3'); $p->SetFont('y_title', '3'); $p->SetFont('x_label', '2'); $p->SetFont('y_label', '2'); $p->SetFont('generic', '2'); } # All axis, all labels, both sides $p->SetTitle($tp['title'] . $tp['suffix']); $p->SetLegend(array('Legend 1', 'Legend 2', 'Legend 3')); $p->SetXTitle('X Axis Title Here', 'both'); $p->SetYTitle('Y Axis Title Here', 'both'); $p->SetXTickLabelPos('none'); $p->SetXTickPos('none'); $p->SetXDataLabelPos('both'); $p->SetYTickLabelPos('both'); $p->SetYTickPos('both'); $p->SetYDataLabelPos('plotin'); if (isset($tp['x_label_angle'])) { $p->SetXLabelAngle($tp['x_label_angle']); } if (isset($tp['y_label_angle'])) { $p->SetYLabelAngle($tp['y_label_angle']); } $p->DrawGraph();
<?php # PHPlot example - horizontal thinbarline plot (impulse plot) require_once 'phplot.php'; $data = array(array('', 79, 33.18), array('', 13, 22.62), array('', 71, 41.18), array('', 8, 14.72), array('', 48, 49.92), array('', 46, 49.68), array('', 90, 18.0), array('', 15, 25.5), array('', 73, 39.42), array('', 30, 42.0), array('', 24, 36.48), array('', 85, 25.5), array('', 14, 24.08), array('', 3, 5.82), array('', 98, 3.92), array('', 39, 47.58), array('', 70, 42.0), array('', 16, 26.88), array('', 81, 30.78), array('', 40, 48.0), array('', 44, 49.28)); $plot = new PHPlot(800, 400); $plot->SetImageBorderType('plain'); // Improves presentation in the manual $plot->SetUseTTF(True); $plot->SetTitle('Experimental Results'); $plot->SetXTitle('Density (g/cm³)'); // 179=superscript 3 $plot->SetYTitle('Temperature (°C)'); // 176=degrees $plot->SetPlotType('thinbarline'); $plot->SetDataType('data-data-yx'); $plot->SetDataValues($data); $plot->SetPlotAreaWorld(0, 0, 50, 100); $plot->SetLineWidths(4); $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();
# this script. The parameters are shown in the defaults array below: if (!isset($tp)) { $tp = array(); } $tp = array_merge(array('title' => 'Tick Count:', 'xmin' => 0, 'xmax' => 98, 'ymin' => 0, 'ymax' => 55, 'xti' => 10, 'yti' => 10), $tp); require_once 'phplot.php'; # The data points don't matter at all. The range is set with SetPlotAreaWorld. $data = array(array('', 0, 0), array('', 1, 1)); $p = new PHPlot(); $subtitle = " World: ({$tp['xmin']}, {$tp['ymin']}) :" . " ({$tp['xmax']}, {$tp['ymax']})" . " Tickstep: ({$tp['xti']}, {$tp['yti']})"; $p->SetTitle($tp['title'] . $subtitle); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetXDataLabelPos('none'); $p->SetXTitle('X'); $p->SetYTitle('Y'); $p->SetPlotAreaWorld($tp['xmin'], $tp['ymin'], $tp['xmax'], $tp['ymax']); $p->SetXTickIncrement($tp['xti']); $p->SetYTickIncrement($tp['yti']); #$p->SetSkipTopTick(False); # Draw both grids: $p->SetDrawXGrid(True); $p->SetDrawYGrid(True); # Axes on all sides: $p->SetXTickPos('both'); $p->SetXTickLabelPos('both'); $p->SetYTickPos('both'); $p->SetYTickLabelPos('both'); $p->SetPlotBorderType('full'); $p->SetPlotType('lines'); $p->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);
$data[1][2] = 0; $data[2][3] = 1; $data[5][4] = 0; // Last Y=0 $data[7][3] = 1; $data[10][1] = $data[10][2] = 0; } $plot = new PHPlot(800, 600); $plot->SetImageBorderType('plain'); $plot->SetPlotType('stackedbars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); if ($tp['compat']) { # backward compatible mode $plot->SetTitle('Candy Sales by Month and Product'); $plot->SetYTitle('Millions of Units'); $plot->SetLegend(array('Chocolates', 'Mints', 'Hard Candy', 'Sugar-Free')); } else { $plot->SetTitle($tp['title'] . $tp['suffix']); $plot->SetXTitle('Month'); $plot->SetYTitle('Number of Units'); } $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); if (isset($tp['shading'])) { $plot->SetShading($tp['shading']); } if (isset($tp['xaxispos'])) { $plot->SetXAxisPosition($tp['xaxispos']); } if (isset($tp['ydatalabel'])) {
# To get a repeatable test with 'random' data: mt_srand(1); # Need a base date/time: Can't just use 0 due to UTC/local differences: $base_time = mktime(0, 0, 0, 1, 1, 2000); # Twenty minutes: $interval = 20 * 60; # Random data at intervals: $data = array(); $t = $base_time; for ($i = 1; $i <= 12; $i++) { $data[] = array('', $t, mt_rand(0, 100)); $t += $interval; } $p = new PHPlot(600, 400); $p->SetTitle('Meaningless Data with Time X Tick Labels'); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetXLabelType('time'); $p->SetXTimeFormat('%H:%M'); $p->SetXTitle('Elapsed Time (hours:minutes)'); # Turn off X data labels, use tick labels only: $p->SetXDataLabelPos('none'); $p->SetXTickLabelPos('plotdown'); # Even though tick values are given, it makes up its own unless: $p->SetXTickIncrement($interval); $p->SetDrawXGrid(True); # Set the Y min and max, since the data is 0:100 $p->SetPlotAreaWorld(NULL, 0, NULL, 100); $p->SetYTitle('Meaningless Value'); $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();
<?php # Typical bars with labels, for manual. require_once 'phplot.php'; $data = array(array('First', 10), array('Second', 20), array('Third', 30)); $p = new PHPlot(400, 300); $p->SetDataType('text-data'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitle('Vertical Bar Plot With Labels'); $p->SetXTitle('Independent Variable'); $p->SetYTitle('Dependent Variable'); $p->SetXDataLabelPos('plotdown'); $p->SetXTickPos('none'); $p->SetYDataLabelPos('plotin'); $p->SetPlotAreaWorld(NULL, 0, NULL, 40); $p->SetYTickIncrement(5); $p->SetImageBorderType('plain'); $p->DrawGraph();
<?php # $Id$ # Test types of label formatting 4 (time, data:0:prefix+suffix) require_once 'phplot.php'; $data = array(); $t = mktime(12, 0, 0, 6, 1, 2000); for ($i = 0; $i < 12; $i++) { $data[] = array('', $t, $i * 13.4); $t += 60 * 60 * 24; } $p = new PHPlot(800, 600); $p->SetTitle("Label Format 4"); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetXDataLabelPos('none'); $p->SetXTickIncrement(60 * 60 * 24); $p->SetYTickIncrement(10); $p->SetPlotType('lines'); $p->SetXLabelType('time', '%m/%d'); $p->SetXTitle("X: time MM/DD"); $p->SetYLabelType('data', 0, '$', '#'); $p->SetYTitle("Y: data, prec=0, prefix=\$, suffix=#"); $p->DrawGraph(); #fwrite(STDERR, print_r($p, True));
<?php # $Id$ # PHPlot Test: bug 2914403 Pie + X/Y titles: Undefined property error # The bug was that X and Y titles were supposed to be ignored, but if # set then an undefined property error occurred. require_once 'phplot.php'; $data = array(array('', 50), array('', 30), array('', 20)); $plot = new PHPlot(800, 600); $plot->SetTitle('Pie + X/Y Title Bug'); $plot->SetXTitle('Ignored X title'); $plot->SetYTitle('Ignored Y title'); $plot->SetImageBorderType('plain'); $plot->SetDataType('text-data-single'); $plot->SetDataValues($data); $plot->SetPlotType('pie'); $plot->DrawGraph();
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']); $graph->SetIsInline('1'); $graph->SetShading(5); $graph->SetDrawYGrid(TRUE); $graph->SetDataType('text-data');
for ($i = 0; $i < $n_points; $i++) { $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
<?php # $Id$ # Test types of label formatting 2 (custom, data:3) require_once 'phplot.php'; function my_format($val, $arg) { $m = (int) ($val / 60); $h = (int) ($m / 60); $m %= 60; return sprintf("%dH%dM", $h, $m); } $data = array(); for ($i = 0; $i < 10; $i++) { $data[] = array('', 4000 * $i, 1234 * $i); } $p = new PHPlot(800, 600); $p->SetTitle("Label Format Test 2"); $p->SetDataType('data-data'); $p->SetDataValues($data); $p->SetXDataLabelPos('none'); $p->SetXTickIncrement(2000); $p->SetYTickIncrement(1000); $p->SetPlotType('lines'); $p->SetXLabelType('custom', 'my_format'); $p->SetXTitle("X: custom H:M"); $p->SetYLabelType('data', 3); $p->SetYTitle("Y: data, prec=3"); $p->DrawGraph();