Exemplo n.º 1
1
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();
}
Exemplo n.º 2
0
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();
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
function testBars()
{
    # PHPlot Example: Bar chart, 3 data sets, unshaded
    $data = array(array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4), array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4), array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4), array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 4));
    $plot = new PHPlot(800, 600);
    $plot->SetIsInline(true);
    $plot->SetImageBorderType('plain');
    $plot->SetPlotType('bars');
    $plot->SetDataType('text-data');
    $plot->SetDataValues($data);
    # Main plot title:
    $plot->SetTitle('Unshaded Bar Chart with 3 Data Sets');
    # No 3-D shading of the bars:
    $plot->SetShading(0);
    # Make a legend for the 3 data sets plotted:
    $plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration'));
    # Turn off X tick labels and ticks because they don't apply here:
    $plot->SetXTickLabelPos('none');
    $plot->SetXTickPos('none');
    $plot->DrawGraph();
}
Exemplo n.º 5
0
# 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();
Exemplo n.º 6
0
 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>";
 }
Exemplo n.º 7
0
 function plotfile_me($pdf, $mv_id, $w = 800, $h = 600)
 {
     $mvs = new mietvertraege();
     $mvs->get_mietvertrag_infos_aktuell($mv_id);
     $mk = new mietkonto();
     $datum_mietdefinition = $mk->datum_1_mietdefinition($mv_id);
     // echo "<h1>$datum_mietdefinition</h1>";
     $a_dat = explode('-', $datum_mietdefinition);
     $jahr_a = date("Y") - 2;
     $jahr_e = date("Y") + 3;
     $jahre = $jahr_e - $jahr_a;
     $z = 0;
     for ($jahr = $jahr_a; $jahr <= $jahr_e; $jahr++) {
         $monat = date("m");
         $mk->kaltmiete_monatlich($mv_id, $monat, $jahr);
         if ($jahr > $jahr_a) {
             $miete_vorjahr = $arr_stat[$z - 1][1];
             $prozent = ($mk->ausgangs_kaltmiete - $miete_vorjahr) / ($miete_vorjahr / 100);
         } else {
             $prozent = 0;
         }
         $prozent = nummer_punkt2komma($prozent);
         $arr_stat[$z][0] = "{$jahr}\n{$mk->ausgangs_kaltmiete}\nEUR\n{$prozent} %";
         $arr_stat[$z][1] = $mk->ausgangs_kaltmiete;
         $z++;
     }
     // print_r($arr_stat);
     require_once 'phplot.php';
     $plot = new PHPlot($w, $h);
     $plot->SetImageBorderType('plain');
     $plot->SetPlotType('bars');
     $plot->SetDataType('text-data');
     $plot->SetDataValues($arr_stat);
     // Main plot title:
     $plot->SetTitle('MIETENTWICKLUNG' . " {$mvs->einheit_kurzname} \n {$mvs->personen_name_string}");
     // No 3-D shading of the bars:
     $plot->SetShading(0);
     // Make a legend for the 3 data sets plotted:
     // $plot->SetLegend(array('Mieteinnahmen', 'Leerstand'));
     $plot->SetLegend(array('MIETE'));
     // Turn off X tick labels and ticks because they don't apply here:
     $plot->SetXTickLabelPos('none');
     $plot->SetXTickPos('none');
     // Draw it
     $plot->SetIsInline(true);
     $img = $plot->DrawGraph();
     $px = 'px';
     // echo "<hr>$plot->img ";
     // $plot->PrintImageFrame();
     // $hhh = $plot->PrintImage();
     $ima = $plot->EncodeImage();
     // echo "<a style=\"width:$w$px;heigth:$h$px;\" href=\"?option=stat_mv_big&mv_id=$mv_id\"><img style=\"width:$w$px;heigth:$h$px;\" src=\"$plot->img\"></img></a>";
     // die();
     // echo "<img src=\"$ima\">";
     // die();
     if ($mvs->mietvertrag_aktuell == 1) {
         $pdf->ezNewPage();
         $druckdatum = date("d.m.Y");
         $pdf->addText(464, 730, 7, "<b>Druckdatum: {$druckdatum}</b>");
         $pdf->addPngFromFile($ima, $pdf->x + 10, $pdf->y - $h, $w, $h);
     }
 }
Exemplo n.º 8
0
//Optional Settings (Don't need them)
//	$graph->SetTitle("This is a\n\rmultiple line title\n\rspanning three lines.");
$graph->SetTitle($title);
$graph->SetXTitle($xlbl, $which_xtitle_pos);
$graph->SetYTitle($ylbl, $which_ytitle_pos);
$graph->SetLegend(array("A", "Bee", "Cee", "Dee"));
$graph->SetFileFormat($which_fileformat);
$graph->SetPlotType($which_plot_type);
$graph->SetUseTTF($which_use_ttf);
$graph->SetYTickIncrement($which_yti);
$graph->SetXTickIncrement($which_xti);
$graph->SetXTickLength($which_xtl);
$graph->SetYTickLength($which_ytl);
$graph->SetXTickCrossing($which_xtc);
$graph->SetYTickCrossing($which_ytc);
$graph->SetXTickPos($which_xtick_pos);
$graph->SetYTickPos($which_ytick_pos);
$graph->SetShading($which_shading);
$graph->SetLineWidth($which_line_width);
$graph->SetErrorBarLineWidth($which_errorbar_line_width);
$graph->SetDrawDashedGrid($which_dashed_grid);
switch ($which_draw_grid) {
    case 'x':
        $graph->SetDrawXGrid(TRUE);
        $graph->SetDrawYGrid(FALSE);
        break;
    case 'y':
        $graph->SetDrawXGrid(FALSE);
        $graph->SetDrawYGrid(TRUE);
        break;
    case 'both':
Exemplo n.º 9
0
$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();
Exemplo n.º 10
0
$a = 0.5;
$d_theta = M_PI / 48.0;
for ($theta = M_PI * 7; $theta >= 0; $theta -= $d_theta) {
    $data[] = array('', $a * $theta * cos($theta), $a * $theta * sin($theta));
}
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('points');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('Scatterplot (points plot)');
# Need to set area and ticks to get reasonable choices.
$plot->SetPlotAreaWorld(-12, -12, 12, 12);
$plot->SetXTickIncrement(2);
$plot->SetYTickIncrement(2);
# Move axes and ticks to 0,0, but turn off tick labels:
$plot->SetXAxisPosition(0);
# Is default
$plot->SetYAxisPosition(0);
$plot->SetXTickPos('xaxis');
$plot->SetXTickLabelPos('none');
$plot->SetYTickPos('yaxis');
$plot->SetYTickLabelPos('none');
# Turn on 4 sided borders, now that axes are inside:
$plot->SetPlotBorderType('full');
# Draw both grids:
$plot->SetDrawXGrid(True);
$plot->SetDrawYGrid(True);
# Is default
$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();
         }
     }
 }
Exemplo n.º 12
0
 // Remember that angles other than 90 are taken as 0 when working with fixed fonts.
 if (isset($stat['x_label_angle'])) {
     $graph->SetXLabelAngle($stat['x_label_angle']);
 } else {
     $graph->SetXLabelAngle(0);
 }
 $graph->SetYLabelAngle(0);
 if (!(isset($stat['tick_increment_y']) && $stat['tick_increment_y'])) {
     $stat['tick_increment_y'] = stats__get_y_increment($stat['data']);
 }
 $graph->SetYTickIncrement($stat['tick_increment_y']);
 $graph->SetXTickLabelPos('plotdown');
 // plotup, plotdown, both, xaxis, none
 $graph->SetYTickLabelPos('both');
 // plotleft, plotright, both, yaxis, none
 $graph->SetXTickPos('plotdown');
 // plotup, plotdown, both, xaxis, none
 $graph->SetYTickPos('both');
 // plotleft, plotright, both, yaxis, none
 //Set some data
 if ($stat['reverse_data']) {
     $data = array_reverse($stat['data']);
 } else {
     $data = $stat['data'];
 }
 $graph->SetDataValues($data);
 $graph->SetXTickLabelPos('none');
 $graph->SetXTickPos('none');
 //echo '<pre>';
 //var_dump($stat);
 //echo '</pre>';
Exemplo n.º 13
0
#                       <=12    13-17   17-28   30-39   40-54    >=55
$data = array(array('Cherry', 1, 1, 2, 2, 4, 3, 3, 4, 3, 5, 5, 6, 6), array('Apple', 2, 1, 9, 2, 7, 3, 4, 4, 7, 5, 3, 6, 7), array('Pear', 3, '', 2, 2, 2, 3, 3, 4, 4, 5, 3, 6, 2), array('Grape', 4, 1, 8, 2, 5, 3, 5, 4, 6, 5, 3, 6, 4), array('Kiwi', 5, '', 0, 2, 3, 3, 4, 4, 4, 5, 5, 6, 2), array('Banana', 6, 1, 5, 2, 4, 3, 6, 4, 3, 5, 3, 6, 4));
$plot = new PHPlot(600, 600);
$plot->SetTitle("Flavor Preference By Age Group");
$plot->SetDataType('data-data-xyz');
$plot->SetDataValues($data);
$plot->SetPlotType('bubbles');
$plot->SetDataColors('yellow');
// Use same color for all data sets
$plot->SetDrawPlotAreaBackground(True);
$plot->SetPlotBgColor('plum');
$plot->SetLightGridColor('red');
// Change grid color to make it visible
$plot->SetImageBorderType('plain');
$plot->SetPlotBorderType('full');
$plot->SetXTickIncrement(1);
// For grid line spacing
$plot->SetYTickIncrement(1);
$plot->SetPlotAreaWorld(0, 0, 6.5, 6.5);
# Establish the handler for the Y label text:
$plot->SetYLabelType('custom', 'get_label', $y_labels);
$plot->SetXTickPos('both');
// Tick marks on both sides
$plot->SetYTickPos('both');
// Tick marks on top and bottom too
$plot->SetXDataLabelPos('both');
// X axis data labels top and bottom
$plot->SetYTickLabelPos('both');
// Y axis labels left and right
$plot->SetDrawXGrid(True);
$plot->DrawGraph();
Exemplo n.º 14
0
# you turn one on PHPlot turns the other off.
# 'xtick' need only be set if you want it different from 'xticklabel', for
# example to have X tick marks and data labels.
$data = array(array('AAA', 0, 0), array('BBB', 1, 8), array('CCC', 2, 3), array('DDD', 3, 7), array('EEE', 4, 5));
$p = new PHPlot(400, 300);
$p->SetTitle($tp['title'] . $tp['suffix']);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetPlotAreaWorld(0, 0, 4, 10);
$p->SetXTickIncrement(1);
$p->SetYTickIncrement(1);
$p->SetPlotBorderType('full');
$p->SetXDataLabelPos($tp['xdatalabel']);
$p->SetXTickLabelPos($tp['xticklabel']);
if (isset($tp['xtick'])) {
    $p->SetXTickPos($tp['xtick']);
} else {
    $p->SetXTickPos($tp['xticklabel']);
}
$p->SetYTickLabelPos($tp['yticklabel']);
$p->SetYTickPos($tp['yticklabel']);
$p->SetXTitle('X TITLE');
$p->SetYTitle('Y TITLE');
# Tick skip tests:
if (isset($tp['skiptick'])) {
    $s = $tp['skiptick'];
    $n = strlen($s);
    for ($i = 0; $i < $n; $i++) {
        switch ($s[$i]) {
            case 'T':
                $p->SetSkipTopTick(True);
 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();
         }
     }
 }
Exemplo n.º 16
0
 function graficarDemandaPronosticoError($oData)
 {
     $sql = "select\r\n\t\t\t\tdate_format(c1.fecha_fin, '%d/%m/%Y') fecha_fin, \r\n\t\t\t\tcantidad_demandada, \r\n\t\t\t\tprediccion, \r\n\t\t\t\terror,\r\n\t\t\t\tsenial \r\n\t\t\t\tfrom (\r\n\t\t\t\t\tselect\r\n\t\t\t\t\tfecha_fin, \r\n\t\t\t\t\tcantidad_demandada, \r\n\t\t\t\t\tprediccion, \r\n\t\t\t\t\terror, \r\n\t\t\t\t\tsenial \r\n\t\t\t\t\tfrom predicciones t1 \r\n\t\t\t\t\tinner join periodos t2 on t1.id_periodo = t2.id_periodo \r\n\t\t\t\t\twhere id_producto= " . $oData["id_producto"] . " \r\n\t\t\t\t\torder by fecha_fin asc) c1";
     $rs = getRS($sql);
     $data = array();
     $nro = getNrosRows($rs);
     $flag = 1;
     if ($nro) {
         while ($row = getRow($rs)) {
             if ($flag) {
                 $inicio = $row['fecha_fin'];
                 $flag = 0;
             }
             $nro--;
             if ($nro == 0) {
                 $fin = $row['fecha_fin'];
             }
             $data[] = array('', $row['cantidad_demandada'], $row['prediccion'], $row['error'], $row['senial']);
         }
     }
     $plot = new PHPlot(800, 465);
     //$plot->SetImageBorderType('plain');
     $plot->SetPlotType('lines');
     //tipo de gráfico
     $plot->SetDataType('text-data');
     $plot->SetDataValues($data);
     $plot->SetTitle('Demanda real, predicción, error y señal de rastreo. Periodo ' . $inicio . ' al ' . $fin);
     //Título
     $plot->SetLegend(array('Demanda real', 'Pronóstico', 'Error', 'Señal de rastreo'));
     //Referencia
     $plot->SetLineWidths(2);
     //ancho de la linea
     $plot->SetLineStyles("solid");
     //estilo de la linea
     $plot->SetDataColors(array('green', 'blue', 'red', 'purple'));
     $plot->SetXTickLabelPos('none');
     $plot->SetXTickPos('none');
     # Draw both grids:
     $plot->SetDrawXGrid(True);
     $plot->SetDrawYGrid(True);
     $plot->DrawGraph();
 }
	/**
	 * Adds raw image data of the graph to the output.
	 * @param $opts FormOptions
	 */
	public function draw( FormOptions $opts ) {
		global $wgTranslatePHPlotFont, $wgLang;

		$width = $opts->getValue( 'width' );
		$height = $opts->getValue( 'height' );
		// Define the object
		$plot = new PHPlot( $width, $height );

		list( $legend, $resData ) = $this->getData( $opts );
		$count = count( $resData );
		$skip = intval( $count / ( $width / 60 ) - 1 );
		$i = $count;

		foreach ( $resData as $date => $edits ) {
			if ( $skip > 0 ) {
				if ( ( $count - $i ) % $skip !== 0 ) $date = '';
			}

			if ( strpos( $date, ';' ) !== false ) {
				list( , $date ) = explode( ';', $date, 2 );
			}

			array_unshift( $edits, $date );
			$data[] = $edits;
			$i--;
		}

		$font = FCFontFinder::find( $wgLang->getCode() );

		if ( $font ) {
			$plot->SetDefaultTTFont( $font );
		} else {
			$plot->SetDefaultTTFont( $wgTranslatePHPlotFont );
		}
		$plot->SetDataValues( $data );

		if ( $legend !== null ) {
			$plot->SetLegend( $legend );
		}

		$numberFont = FCFontFinder::find( 'en' );

		$plot->setFont( 'x_label', $numberFont, 8 );
		$plot->setFont( 'y_label', $numberFont, 8 );

		$yTitle = wfMsg( 'translate-stats-' . $opts['count'] );

		// Turn off X axis ticks and labels because they get in the way:
		$plot->SetYTitle( $yTitle );
		$plot->SetXTickLabelPos( 'none' );
		$plot->SetXTickPos( 'none' );
		$plot->SetXLabelAngle( 45 );


		$max = max( array_map( 'max', $resData ) );
		$max = self::roundToSignificant( $max, 1 );
		$max = round( $max, intval( -log( $max, 10 ) ) );

		$yTick = 10;
		while ( $max / $yTick > $height / 20 ) {
			$yTick *= 2;
		}

		// If we have very small case, ensure that there is at least one tick
		$yTick = min( $max, $yTick );
		$yTick = self::roundToSignificant( $yTick );
		$plot->SetYTickIncrement( $yTick );
		$plot->SetPlotAreaWorld( null, 0, null, $max );


		$plot->SetTransparentColor( 'white' );
		$plot->SetBackgroundColor( 'white' );

		// Draw it
		$plot->DrawGraph();
	}
Exemplo n.º 18
0
}
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();
Exemplo n.º 19
0
function guifi_stats_chart03()
{
    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;
    }
    if (isset($_GET['zone'])) {
        $zone_id = $_GET['zone'];
        if ($zone_id == "3671") {
            $zone_id = "0";
        }
    } else {
        $zone_id = "0";
    }
    $vsql = "select COUNT(*) as num, month(FROM_UNIXTIME(timestamp_created)) as mes\n      from {guifi_location} 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 MONTH(FROM_UNIXTIME(timestamp_created)) ";
    $result = db_query($vsql);
    $tot = 0;
    $valor = 0;
    while ($record = db_fetch_object($result)) {
        $tot += $record->num;
        $data[] = array("{$record->mes}", $record->num);
    }
    foreach ($data as &$dat) {
        $dat[1] = $dat[1] * 100 / $tot;
    }
    $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->SetYTickIncrement(10);
    $plot->SetSkipBottomTick(TRUE);
    $plot->SetSkipLeftTick(TRUE);
    $plot->SetTickLength(0);
    $plot->SetXTickPos('none');
    $plot->SetYTickPos('none');
    $plot->SetDrawYGrid(FALSE);
    $plot->SetYTickLabelPos('none');
    $plot->SetYDataLabelPos('plotin');
    $plot->SetTickColor('grey');
    $plot->SetTTFPath($gDirTTFfonts);
    $plot->SetFontTTF('title', 'Vera.ttf', 12);
    if (isset($_GET['title'])) {
        $plot->SetTitle("guifi.net      \n" . t($_GET['title']));
    } else {
        if ($zone_id == "0") {
            $plot->SetTitle("guifi.net      \n" . t('Monthly average'));
        } else {
            $plot->SetTitle("guifi.net    " . t('zone') . ": " . guifi_get_zone_name($zone_id) . "\n" . t('Monthly average'));
        }
    }
    $plot->SetXTitle(t('Months'));
    $plot->SetYTitle(t('% Working nodes'));
    $plot->SetXDataLabelPos('plotdown');
    $plot->SetXLabelAngle(0);
    $plot->SetYLabelType('data', 2);
    $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();
}
Exemplo n.º 20
0
# $Id$
# Multi-line data labels - baseline: TTf at 0 deg
require_once 'config.php';
$ttfont = $phplot_test_ttfdir . '/' . $phplot_test_ttfonts['sans'];
# This is a parameterized test. Other scripts can set $tp and then include
# this script. The parameters are shown in the defaults array below:
if (!isset($tp)) {
    $tp = array();
}
$tp = array_merge(array('title' => 'Multi-line data labels', 'suffix' => '', 'font' => $ttfont, 'angle' => NULL), $tp);
require_once 'phplot.php';
$data = array(array("AAA", 0, 6), array("BBB\nCC", 1, 4), array("CCC\nDD\nE", 2, 2), array("D", 3, 0), array("E\nFF\nGGG", 4, 2), array("FFF\nG\nHHH", 5, 4), array("G", 6, 6));
$p = new PHPlot(400, 300);
if (isset($tp['font'])) {
    $p->SetDefaultTTFont($tp['font']);
}
$p->SetTitle($tp['title'] . $tp['suffix']);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('plotdown');
$p->SetXTickIncrement(1.0);
$p->SetYTickIncrement(1.0);
# Tick label and tick mark positions:
$p->SetXTickPos('xaxis');
$p->SetXTickLabelPos('none');
if (isset($tp['angle'])) {
    $p->SetXLabelAngle($tp['angle']);
}
$p->SetPlotType('lines');
$p->DrawGraph();
Exemplo n.º 21
0
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();
}
Exemplo n.º 22
0
$result = mysql_query("SELECT Max(player_money_total_amount) max,min(player_money_total_amount) min FROM meridian103.player_money_total;");
while ($row = mysql_fetch_assoc($result)) {
    $max = $row['max'];
    $min = $row['min'];
}
$min -= 1000000;
mysql_free_result($result);
*/
$result = mysql_query("SELECT player_money_total_amount amount, player_money_total_time time from meridian103.player_money_total where date(player_money_total_time) = date(now()) order by player_money_total_time ASC;");
while ($row = mysql_fetch_assoc($result)) {
    $data[] = array($row['time'], $row['amount']);
}
mysql_free_result($result);
mysql_close($link);
//Define the object
$plot = new PHPlot();
$plot->SetTitle("Server 103 Total Shillings over Time - Period 1 Day");
$plot->SetFontGD('y_label', 5);
$plot->SetFontGD('x_label', 5);
//$plot->SetPlotAreaWorld(NULL,$min,NULL,$max);
$plot->SetXLabelAngle(90);
$plot->SetYDataLabelPos('plotin');
$plot->SetDrawYDataLabelLines('false');
//$plot->SetFontGD('y_title', 5);
//$plot->SetFontGD('x_title', 5);
$plot->SetDataValues($data);
//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
Exemplo n.º 23
0
require_once 'phplot.php';
if (!isset($case)) {
    $case = 1;
}
$data = array(array('Monday', 10, 20, 30), array('Tuesday', 10, 20, 30), array('Wednesday', 10, 20, 30), array('Thursday', 10, 20, 30), array('Friday', 10, 20, 30));
// Common setup:
$plot = new PHPlot(460, 600);
$plot->SetTitle("Multiple Plots, horiz & vertical (case {$case})");
$plot->SetPlotType('bars');
$plot->SetPrintImage(False);
$plot->SetDataValues($data);
// Plot #1:
$plot->SetPlotAreaPixels(NULL, 60, NULL, 300);
$plot->SetPlotAreaWorld();
$plot->SetDataType('text-data');
$plot->SetXTickPos('none');
$plot->DrawGraph();
// Plot #2:
$plot->SetPlotAreaPixels(NULL, 330, NULL, 570);
$plot->SetPlotAreaWorld();
$plot->SetDataType('text-data-yx');
if ($case == 2) {
    // Reset label positions
    $plot->SetXTickLabelPos('plotdown');
    $plot->SetXDataLabelPos('none');
    $plot->SetYTickLabelPos('none');
    $plot->SetYDataLabelPos('plotleft');
    $plot->SetXTickPos('plotdown');
}
$plot->DrawGraph();
// Finish:
Exemplo n.º 24
0
# 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();
	/**
	* Generate a graph for this tag
	* @param string $tag
	* @param string $filePath
	* @return bool, success
	*/
	public function makePngGraph( $tag, $filePath ) {
		if( !function_exists( 'ImageCreate' ) ) {
			// GD is not installed
			return false;
		}
		global $wgPHPlotDir, $wgMemc;
		require_once( "$wgPHPlotDir/phplot.php" ); // load classes
		// Define the object
		$plot = new PHPlot( 1000, 400 );
		// Set file path
		$dir = dirname($filePath);
		// Make sure directory exists
		if( !file_exists($dir) && !wfMkdirParents( $dir, 0777, __METHOD__ ) ) {
			throw new MWException( 'Could not create file directory!' );
		}
		$plot->SetOutputFile( $filePath );
		$plot->SetIsInline( true );
		$data = array();
		$totalVal = $totalCount = $n = 0;
		// Define the data using the DB rows
		list($res,$u,$maxC,$days) = $this->doQuery( $tag );
		if( !$maxC ) {
			return false;
		}
		// Label spacing
		$int = intval( ceil($days/10) ); // 10 labels at most
		foreach( $res as $row ) {
			$totalVal += (int)$row->rfh_total;
			$totalCount += (int)$row->rfh_count;
			$dayCount = (real)$row->rfh_count;
			if( !$row->rfh_count ) {
				continue; // bad data
			}
			// Nudge values up by 1
			$dayAve = 1 + (real)$row->rfh_total/(real)$row->rfh_count;
			$cumAve = 1 + (real)$totalVal/(real)$totalCount;
			$year = intval( substr( $row->rfh_date, 0, 4 ) );
			$month = intval( substr( $row->rfh_date, 4, 2 ) );
			$day = intval( substr( $row->rfh_date, 6, 2 ) );
			# Fill in days with no votes to keep spacing even
			if( isset($lastDate) ) {
				$dayGap = wfTimestamp(TS_UNIX,$row->rfh_date) - wfTimestamp(TS_UNIX,$lastDate);
				$x = intval( $dayGap/86400 );
				# Day gaps...
				for( $x; $x > 1; --$x ) {
					$data[] = array("",$lastDAve,$lastRAve,0);
					$n++;
				}
			}
			$n++;
			# Label point?
			if( $n >= $int || !count($data) ) {
				$p = ($days > 31) ? "{$month}-".substr( $year, 2, 2 ) : "{$month}/{$day}";
				$n = 0;
			} else {
				$p = "";
			}
			$data[] = array( $p, $dayAve, $cumAve, $dayCount );
			$lastDate = $row->rfh_date;
			$lastDAve = $dayAve;
			$lastRAve = $cumAve;
		}
		// Minimum sample size
		if( count($data) < 2 ) {
			return false;
		}
		// Re-scale voter count to fit to graph
		$this->dScale = ceil($maxC/5);
		// Cache the scale value to memory
		$key = wfMemcKey( 'feedback', 'scale', $this->page->getArticleId(), $this->period );
		$wgMemc->set( $key, $this->dScale, 7*24*3600 );
		// Fit to [0,4]
		foreach( $data as $x => $dataRow ) {
			$data[$x][3] = $dataRow[3]/$this->dScale;
		}
		$plot->SetDataValues($data);
		$plot->SetPointShapes( array('dot','dot','dot') );
		$plot->setPointSizes( array(1,1,4) );
		$plot->SetDataColors( array('blue','green','red') );
		$plot->SetLineStyles( array('solid','solid','solid') );
		$plot->SetBackgroundColor('#F8F8F8');
		// Turn off X axis ticks and labels because they get in the way:
		$plot->SetXTickLabelPos('none');
		$plot->SetXTickPos('none');
		$plot->SetYTickIncrement( .5 );
		// Set plot area
		$plot->SetPlotAreaWorld( 0, 0, null, 5 );
		// Show total number of votes
		$plot->SetLegend( array("#{$totalCount}") );
		// Draw it!
		$plot->DrawGraph();
		return true;
	}