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 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; }
//$p->SetDefaultTTFont('./arial.ttf'); # Set the main plot title: $p->SetTitle('Histórico 10 dias'); $p->SetPrecisionY(1); # Select the data array representation and store the data: $p->SetDataType('text-data'); $p->SetDataValues($data); # Select the plot type - bar chart: $p->SetPlotType('lines'); # Define the data range. PHPlot can do this automatically, but not as well. //$p->SetPlotAreaWorld(0, 0, 9, 400); # 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('Acessos')); //$p->SetLegendWorld(0.1, 95); # Turn data labels on, and all ticks and tick labels off: //$p->SetXDataLabelPos('plotdown'); $p->SetXLabelFontSize(2); $p->SetAxisFontSize(2); $p->SetXTickPos('none'); //$p->SetXTickLabelPos('none'); //$p->SetYTickPos('none'); //$p->SetYTickLabelPos('none'); $p->SetYDataLabelPos('plotin'); # Generate and output the graph now: $p->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-yx'); $p->SetDataValues($data); $p->SetPlotType('bars'); $p->SetTitle('Horizontal Bar Plot With Labels'); $p->SetXTitle('Dependent Variable'); $p->SetYTitle('Independent Variable'); $p->SetYDataLabelPos('plotleft'); $p->SetYTickPos('none'); $p->SetXDataLabelPos('plotin'); $p->SetPlotAreaWorld(0, NULL, 40, NULL); $p->SetXTickIncrement(5); $p->SetImageBorderType('plain'); $p->DrawGraph();
case 'y': $graph->SetDrawXGrid(FALSE); $graph->SetDrawYGrid(TRUE); break; case 'both': $graph->SetDrawXGrid(TRUE); $graph->SetDrawYGrid(TRUE); break; case 'none': $graph->SetDrawXGrid(FALSE); $graph->SetDrawYGrid(FALSE); } $graph->SetXTickLabelPos($which_xtick_label_pos); $graph->SetYTickLabelPos($which_ytick_label_pos); $graph->SetXDataLabelPos($which_xdata_label_pos); $graph->SetYDataLabelPos($which_ydata_label_pos); // Please remember that angles other than 90 are taken as 0 when working fith fixed fonts. $graph->SetXLabelAngle($which_xlabel_angle); $graph->SetYLabelAngle($which_ylabel_angle); //$graph->SetLineStyles(array("dashed","dashed","solid","solid")); $graph->SetPointShape($which_point); $graph->SetPointSize($which_point_size); $graph->SetDrawBrokenLines($which_broken); // Some forms in format_chart.php don't set this variable, suppress errors. @$graph->SetErrorBarShape($which_error_type); $graph->SetXAxisPosition($which_xap); $graph->SetYAxisPosition($which_yap); $graph->SetPlotBorderType($which_btype); if ($maxy_in) { if ($which_data_type = "text-data") { $graph->SetPlotAreaWorld(0, $miny_in, count($data), $maxy_in);
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(); } } }
} $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'])) { $plot->SetYDataLabelPos($tp['ydatalabel']); } if (isset($tp['custom'])) { call_user_func($tp['custom'], $plot); } $plot->DrawGraph();
function BuatBarGraph($filetujuan, $prevtahun, $tahun, $arrStatusAplikan, $urutan, $gel) { $arrPrevTotal = array(); $arrCurTotal = array(); FillArrayPeriod($arrPrevTotal, $arrStatusAplikan, $prevtahun, $gel); FillArrayPeriod($arrCurTotal, $arrStatusAplikan, $tahun, $gel); $maxPrevHeight = 0; $maxCurHeight = 0; foreach ($arrStatusAplikan as $stat) { $data[] = array($stat, $arrPrevTotal[$stat], $arrCurTotal[$stat]); $maxPrevHeight = $maxPrevHeight < $arrPrevTotal[$stat] ? $arrPrevTotal[$stat] : $maxPrevHeight; $maxCurHeight = $maxCurHeight < $arrCurTotal[$stat] ? $arrCurTotal[$stat] : $maxCurHeight; } $plot = new PHPlot(800, 600); //$plot->SetImageBorderType('raised'); $plot->SetFont('y_label', 5); $plot->SetFont('x_label', 5); $plot->SetFont('title', 5); $plot->SetFont('legend', 5); $plot->setShading(10); $plot->SetPlotType('bars'); $plot->SetDataType('text-data'); $plot->SetDataValues($data); $plot->SetTitle('GRAFIK & DATA PMB GEL SISIPAN'); $plot->SetLegend(array($prevtahun, $tahun)); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $maxHeight = $maxPrevHeight < $maxCurHeight ? $maxCurHeight : $maxPrevHeight; $increment = $maxHeight <= 50 ? 5 : ($maxHeight <= 100 ? 10 : ($maxHeight <= 500 ? 50 : 100)); $plot->SetYTickIncrement($increment); $plot->SetYDataLabelPos('plotin'); $plot->SetIsInline(true); $plot->SetOutputFile($filetujuan); $plot->DrawGraph(); }
<?php # PHPlot Example: Stacked Bars, unshaded, with Y data labels 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'); # No shading: $plot->SetShading(0); $plot->SetLegend(array('Chocolates', 'Mints', 'Hard Candy', 'Sugar-Free')); # Make legend lines go bottom to top, like the bar segments (PHPlot > 5.4.0) $plot->SetLegendReverse(True); $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); # Turn on Y Data Labels: Both total and segment labels: $plot->SetYDataLabelPos('plotstack'); $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(); }
} else { fwrite(STDERR, "Error: Unknown data type or not decoded: {$data}-type\n"); exit(1); } $p = new PHPlot(800, 800); $p->SetTitle("Testing PHPlot ({$plot_type}, {$data_type})"); $p->SetDataType($data_type); $p->SetDataValues($data); $p->SetPlotType($plot_type); if ($horizontal) { $p->SetXTitle('X Axis - Dependent variable'); $p->SetYTitle('Y Axis - Independent variable'); $p->SetXDataLabelPos('plotin'); // Tick labels left, Axis Data labels right, so both can be seen. $p->SetYTickLabelPos('plotleft'); $p->SetYDataLabelPos('plotright'); } else { $p->SetXTitle('X Axis - Independent variable'); $p->SetYTitle('Y Axis - Dependent variable'); $p->SetYDataLabelPos('plotin'); // Tick labels below, Axis Data labels above, so both can be seen. $p->SetXTickLabelPos('plotdown'); $p->SetXDataLabelPos('plotup'); } # Customizations for error plots: if ($error_bars) { # With error plots, the default 90 degree position for data value labels # will overlay the error bar, so move them to 45 degrees: $p->data_value_label_angle = 45; # Turn off the grid lines, so the error bars are move visible. $p->SetDrawXGrid(False);
$data = array(); $data_type = 'text-data-yx'; for ($pt = 0; $pt < $n_y; $pt++) { $row = array(strftime('%b', mktime(12, 12, 12, $pt + 1, 1, 2000))); for ($r = 0; $r < $groups; $r++) { $row[] = mt_rand(0, $max_x); } $data[] = $row; } $plot = new PHPlot(640, 480); $plot->SetTitle($title . $suffix); $plot->SetDataType($data_type); $plot->SetDataValues($data); $plot->SetPlotType($plottype); $plot->SetPlotAreaWorld(0, 0, $max_x, $n_y); # Position data labels: $plot->SetYDataLabelPos($labelpos); # Turn data label lines on or off: $plot->SetDrawYDataLabelLines($labellines); # So you can tell which axis $plot->SetXTitle('Dependent value'); $plot->SetYTitle('Independent value'); # Turn off Tick labels and Y Tick marks - they aren't used. $plot->SetYTickLabelPos('none'); $plot->SetYTickPos('none'); # Don't make any plot lines dashed, to avoid confusion with data label lines $plot->SetLineStyles('solid'); # Don't draw grids, so we can see the data lines. $plot->SetDrawXGrid(False); $plot->SetDrawYGrid(False); $plot->DrawGraph();
function solicitudes_reparacion_por_operario($id_operario, $año) { $this->loadModel('ReparacionSolicitud'); $this->loadModel('Funcionario'); $meses = $this->ReparacionSolicitud->query("SELECT MONTH(archivada) AS mes FROM reparacion_solicitudes WHERE estado='a' AND ejecutada=1 AND YEAR(archivada)=" . $año . " GROUP BY MONTH(archivada)"); if (!empty($meses)) { // Inicializamos el arreglo en ceros (para los meses ke no tienen solicitudes). $total = array(); for ($i = 1; $i <= 12; $i++) { $total[$i][0][0] = array('cuenta' => 0); } foreach ($meses as $mes) { $cant_solicitudes = $this->ReparacionSolicitud->query("SELECT COUNT(*) AS cuenta FROM reparacion_solicitudes WHERE id_funcionario=" . $id_operario . " AND estado='a' AND ejecutada=1 AND YEAR(archivada)=" . $año . " AND MONTH(archivada)=" . $mes[0]['mes']); $total[$mes[0]['mes']] = $cant_solicitudes; } if (!empty($total)) { $operario = $this->Funcionario->find('first', array('conditions' => array('Funcionario.id' => $id_operario), 'fields' => array('Funcionario.nombre'))); foreach ($total as $mes => $arreglo_mes) { $arreglo_plot[] = array($this->meses[$mes], $arreglo_mes[0][0]['cuenta']); } $plot = new PHPlot(890, 450); $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', 10); $plot->SetFontTTF('x_label', 'FreeSans.ttf', 10); $plot->SetFontTTF('y_title', 'FreeSans.ttf', 14); // Titulos $plot->SetTitle("\nSolicitudes de reparación\natendidas por " . mb_convert_case($operario['Funcionario']['nombre'], MB_CASE_TITLE, "UTF-8")); $plot->SetXTitle('AÑO ' . $año); $plot->SetYTitle('# SOLICITUDES'); // Etiquetas $plot->SetXTickLabelPos('none'); $plot->SetXTickPos('none'); $plot->SetYTickLabelPos('none'); $plot->SetYTickPos('none'); $plot->SetYDataLabelPos('plotin'); $plot->SetDrawXGrid(true); // Leyenda $leyenda = array('Solicitudes de Reparación'); $plot->SetLegend($leyenda); $plot->SetLegendPixels(703, 0); $plot->SetPlotType('bars'); $plot->SetShading(7); $plot->DrawGraph(); } } }
$p->SetXTitle('This is the X Axis Title'); $p->SetYTitle('This is the Y Axis Title'); $p->SetDataValues($data); if ($tp['horizontal']) { $p->SetDataType('text-data-yx'); } else { $p->SetDataType('text-data'); } // phplot_show_data_array('', $data, $p->data_type); // DEBUG $p->SetPlotType('bars'); if (isset($tp['shade'])) { $p->SetShading($tp['shade']); } if (isset($tp['plotarea'])) { call_user_func_array(array($p, 'SetPlotAreaWorld'), $tp['plotarea']); } if ($tp['ttf']) { $p->SetTTFPath($phplot_test_ttfdir); $p->SetDefaultTTFont($phplot_test_ttfonts['sans']); } if ($tp['yaxis0']) { $p->SetYAxisPosition(0); } if (isset($tp['ydatalabelpos'])) { $p->SetYDataLabelPos($tp['ydatalabelpos']); } if (isset($tp['ydatalabelangle'])) { $p->SetYDataLabelAngle($tp['ydatalabelangle']); } $p->SetYTickPos('none'); $p->DrawGraph();
function get_png($objekt_id, $monat, $jahr, $w = 300, $h = 200) { $monat = sprintf('%02d', $monat); include_once BERLUS_PATH . "/classes/phplot.php"; $plot = new PHPlot($w, $h, "/tmp/plot_sanierung.png"); $plot->SetImageBorderType('plain'); $plot->SetPlotType('stackedbars'); $plot->SetDataType('text-data'); // $column_names = array('LEER VM', 'LEER NEU', 'IST WM','DIFF'); $plot->SetShading(10); $plot->SetLegendReverse(True); // $plot->SetLegend($column_names); $oo = new objekt(); $oo->get_objekt_infos($objekt_id); $anz_einheiten_alle = $oo->anzahl_einheiten_objekt($objekt_id); $datum_heute = "{$jahr}-{$monat}-01"; $mi = new miete(); $datum_vormonat = $mi->tage_minus($datum_heute, 30); $arr = $this->leerstand_finden_monat($objekt_id, $datum_vormonat); $anz_leer_vormonat = count($arr); // unset($arr); $arr_leer = $this->leerstand_finden_monat($objekt_id, $datum_heute); $anz_leer_akt = count($arr_leer); $anz_vermietet = $anz_einheiten_alle - $anz_leer_akt; $leere = $this->array_intersect_recursive($arr_leer, $arr, 'EINHEIT_KURZNAME'); $vermietete = $this->array_intersect_recursive($arr, $arr_leer, 'EINHEIT_KURZNAME'); $leer_akt_string = ''; $anz__L = count($leere); if ($anz__L > 0) { for ($ee = 0; $ee < $anz__L; $ee++) { $leer_akt_string .= $leere[$ee] . "\n"; } } $vermietet_akt_string = ''; $anz__V = count($vermietete); // print_r($vermietete); if ($anz__V > 0) { for ($ee = 0; $ee < $anz__V; $ee++) { $vermietet_akt_string .= $vermietete[$ee] . "\n"; } } // unset($arr); /* * $mvs = new mietvertraege; * $anz_ausgezogene = $mvs->anzahl_ausgezogene_mieter($objekt_id, $jahr, $monat); * $anz_eingezogene = $mvs->anzahl_eingezogene_mieter($objekt_id, $jahr, $monat); */ $bilanz_akt = $anz__V - $anz__L; // 0-1 = -1; $z = 0; /* * $data[$z][] = "ALLE\nAKTUELL"; * $data[$z][] = $anz_einheiten_alle; * * $data[$z][] = 0; * $data[$z][] = 0; * */ // $z++; /* * $data[$z][] = "LEER\nVERM."; * $data[$z][] = 0; * $data[$z][] = $anz_vermietet; * $data[$z][] = $anz_leer_akt; */ $data[$z][] = "VOR-\nMONAT"; $data[$z][] = 0; $data[$z][] = $anz_leer_vormonat; $z++; $data[$z][] = "LEER-\nAKTUELL"; $data[$z][] = 0; $data[$z][] = 0; $data[$z][] = $anz_leer_akt; $z++; $data[$z][] = "LEER\n\n{$leer_akt_string}"; $data[$z][] = '0'; $data[$z][] = '0'; $data[$z][] = $anz__L; $z++; $data[$z][] = "VERM.\n\n{$vermietet_akt_string}"; $data[$z][] = '0'; $data[$z][] = $anz__V; $z++; $data[$z][] = "BILANZ\nEIN/AUS"; if ($bilanz_akt < 0) { $data[$z][] = 0; $data[$z][] = 0; $data[$z][] = 0; $data[$z][] = 0; $data[$z][] = $bilanz_akt; } else { $data[$z][] = 0; $data[$z][] = $bilanz_akt; } // $z++; $plot->SetYDataLabelPos('plotstack'); $plot->SetDataValues($data); // Main plot title: $plot->SetTitle("{$oo->objekt_kurzname} {$monat}/{$jahr}"); // 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); $plot->DrawGraph(); // echo "<hr>$plot->img "; // $plot->PrintImageFrame(); // $ima = $plot->PrintImage(); $ima = $plot->EncodeImage(); // ob_clean(); return $ima; // echo "<img src=\"$ima\"></img>"; }