Exemple #1
0
 /**
  * Draw the XY type plot
  *
  * @param array $data plot data array reference
  * @param array $xmlArr xml array reference
  * @return object refernce XY plot object reference
  */
 public function renderXYPlot(&$data, &$xmlArr)
 {
     $id = $xmlArr['ATTRIBUTES']['ID'];
     $field = $xmlArr['ATTRIBUTES']['FIELD'];
     $chartType = $xmlArr['ATTRIBUTES']['CHARTTYPE'];
     $pointType = $xmlArr['ATTRIBUTES']['POINTTYPE'];
     $weight = $xmlArr['ATTRIBUTES']['WEIGHT'];
     $color = $xmlArr['ATTRIBUTES']['COLOR'];
     $fillColor = $xmlArr['ATTRIBUTES']['FILLCOLOR'];
     $showVal = $xmlArr['ATTRIBUTES']['SHOWVALUE'];
     $legend = $xmlArr['ATTRIBUTES']['LEGENDFIELD'];
     $visible = $xmlArr['ATTRIBUTES']['VISIBLE'];
     if ($chartType == 'Line' or $chartType == 'Bar') {
         if ($chartType == 'Line') {
             include_once JPGRAPH_DIR . '/jpgraph_line.php';
             $plot = new LinePlot($data);
             $this->_drawMark($plot->mark, $xmlArr['POINTMARK']['ATTRIBUTES']['TYPE'], $xmlArr['POINTMARK']['ATTRIBUTES']['COLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['FILLCOLOR'], $xmlArr['POINTMARK']['ATTRIBUTES']['SIZE']);
             $plot->SetBarCenter();
             $plot->SetCenter();
         } else {
             if ($chartType == 'Bar') {
                 include_once JPGRAPH_DIR . '/jpgraph_bar.php';
                 $plot = new BarPlot($data);
                 $plot->SetAlign('center');
             }
         }
         if ($color) {
             $plot->SetColor($color);
         }
         if ($fillColor) {
             $plot->SetFillColor($fillColor);
         }
         if ($weight) {
             $plot->SetWeight($weight);
         }
         if ($showVal == 1) {
             $plot->value->Show();
         }
         if ($legend) {
             $plot->SetLegend($legend);
         }
         $this->_drawString($plot->value, $xmlArr['VALUE']['ATTRIBUTES']['FONT'], $xmlArr['VALUE']['ATTRIBUTES']['COLOR']);
     }
     if ($chartType == 'GroupBar' or $chartType == 'AccBar') {
         $children = $xmlArr['ATTRIBUTES']['CHILDREN'];
         $childList = explode(",", $children);
         foreach ($childList as $child) {
             $childPlotList[] = $this->m_PlotList[$child];
         }
         if ($chartType == 'GroupBar') {
             $plot = new GroupBarPlot($childPlotList);
         } else {
             if ($chartType == 'AccBar') {
                 $plot = new AccBarPlot($childPlotList);
             }
         }
     }
     $this->m_PlotList[$id] = $plot;
     if ($visible == 1) {
         return $plot;
     }
     return null;
 }
Exemple #2
0
//Setup Mian Title
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->title->Set("{$txt_7day}");
$graph->title->SetColor("{$textcolour}");
//Setup x axis
$graph->xaxis->SetColor("{$xtextcolour}");
$graph->xaxis->HideLabels(true);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->xaxis->title->Set("{$txt_rain} ({$rain_unit})");
$graph->xaxis->title->SetColor("{$xtextcolour}");
// Setup y axis
$graph->yaxis->SetFont(FF_ARIAL, FS_BOLD, 8);
$graph->yaxis->SetColor("{$ytextcolour}");
$graph->yaxis->SetLabelFormat("{$rain_format}");
$graph->yaxis->HideTicks(true, true);
// Create the bar pot
$bplot = new BarPlot($datay);
$bplot->SetWidth(0.7);
$bplot->SetAlign("center");
$bplot->value->SetFont(FF_ARIAL, FS_BOLD);
$bplot->value->HideZero();
$bplot->value->SetColor("black");
$bplot->SetValuePos('top');
$bplot->value->Show();
$bplot->value->SetFormat("{$rain_format}");
$bplot->SetFillGradient("{$rain_col}", "#EEEEEE", GRAD_LEFT_REFLECTION);
$bplot->SetColor("{$rain_col}");
//Add plot
$graph->Add($bplot);
// Finally send the graph to the browser
$graph->Stroke();
Exemple #3
0
$graph->SetShadow();
// Use an integer X-scale
$graph->SetScale("intlin");
// Set title and subtitle
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("(\"left\" aligned bars)");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Make the margin around the plot a little bit bigger
// then default
$graph->img->SetMargin(40, 120, 40, 40);
// Slightly adjust the legend from it's default position in the
// top right corner to middle right side
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Create a red line plot
$p1 = new LinePlot($datay, $datax);
$p1->SetColor("red");
$p1->SetLegend("Status one");
$graph->Add($p1);
// Create the bar plot
$b1 = new BarPlot($databary, $databarx);
$b1->SetLegend("Status two");
$b1->SetAlign("left");
$b1->SetShadow();
$graph->Add($b1);
// Finally output the  image
$graph->Stroke();
?>


Exemple #4
0
    if ($i % 10 == 0) {
        $databarx[] = $i;
        $databary[] = $datay[$i] / 2;
    }
}
// New graph with a background image and drop shadow
$graph = new Graph(450, 300);
$graph->img->SetMargin(40, 180, 40, 40);
$graph->SetBackgroundImage("tiger_bkg.png", BGIMG_FILLFRAME);
//$graph->img->SetAntiAliasing();
$graph->SetScale("intlin");
$graph->SetShadow();
$graph->title->Set("Combined bar and line plot");
$graph->subtitle->Set("(\"center\" aligned bars)");
// Use built in font
$graph->title->SetFont(FF_FONT1, FS_BOLD);
// Slightly adjust the legend from it's default position in the
// top right corner.
$graph->legend->Pos(0.05, 0.5, "right", "center");
// Create the first line
$p1 = new LinePlot($datay, $datax);
$p1->SetWeight(1);
$p1->SetColor("red");
$p1->SetLegend("Triumph Tiger -98");
$graph->Add($p1);
$b1 = new BarPlot($databary, $databarx);
$b1->SetAbsWidth(10);
$b1->SetAlign("center");
$b1->SetShadow();
$graph->Add($b1);
$graph->Stroke();
Exemple #5
0
function getLastYearPlot($re, $an, $art = false)
{
    $employee = $_SESSION["login"];
    $keys = array_keys($re);
    $sum = array();
    $avg = array();
    $monate = array();
    $gut = array();
    if ($re) {
        foreach ($re as $month) {
            if ($month["summe"] < 0) {
                $gut[] = $month["summe"] * -1;
                $sum[] = 0;
                $avg[] = 0;
            } else {
                $sum[] = $month["summe"];
                $gut[] = 0;
                if ($month["count"] > 0) {
                    $avg[] = $month["summe"] / $month["count"];
                } else {
                    $avg[] = 0;
                }
            }
        }
    }
    if ($an) {
        foreach ($an as $month) {
            $sumA[] = $month["summe"];
        }
    }
    if ($keys) {
        foreach ($keys as $m) {
            $monate[] = substr($m, 4, 2);
        }
    }
    $monate = array_splice($monate, 0, -1);
    $sum = array_splice($sum, 0, -1);
    $gut = array_splice($gut, 0, -1);
    if (!empty($sumA)) {
        $sumA = array_splice($sumA, 0, -1);
    } else {
        $sumA[] = 0;
    }
    $avg = array_splice($avg, 0, -1);
    $graph = new Graph(520, 320);
    if ($art) {
        $art = "textlin";
    } else {
        $art = "textlog";
    }
    $graph->SetScale($art);
    $graph->img->SetMargin(65, 10, 10, 90);
    $sumplot = new BarPlot($sum);
    // Graph Umsatz
    $sumplot->SetColor("darkgreen");
    $sumplot->SetWidth(1.0);
    $sumplot->SetAlign("center");
    //$sumplot->SetCenter(true);
    //$sumplot->mark->SetType(MARK_CIRCLE);
    $sumplot->SetLegend("Gesamtumsatz");
    $graph->Add($sumplot);
    $avgplot = new BarPlot($avg);
    // Graph durchn. Umsatz
    $avgplot->SetColor("darkred");
    $avgplot->SetFillColor("red");
    $avgplot->SetWidth(0.5);
    $avgplot->SetAlign("center");
    //$avgplot->SetStyle("dashed");
    //$avgplot->SetCenter(true);
    $avgplot->SetLegend("duchschnitt");
    $graph->Add($avgplot);
    if (empty($gut)) {
        $gut[] = 0;
    }
    $gutplot = new BarPlot($gut);
    // Graph Umsatz
    $gutplot->SetColor("darkgreen");
    $gutplot->SetFillColor("green");
    $gutplot->SetWidth(0.2);
    $gutplot->SetAlign("center");
    //$sumplot->SetCenter(true);
    //$sumplot->mark->SetType(MARK_CIRCLE);
    $gutplot->SetLegend("Gutschrift");
    $graph->Add($gutplot);
    $angbplot = new LinePlot($sumA);
    // Graph Angebote
    $angbplot->SetColor("darkblue");
    //$angbplot->SetStyle("dashed");
    $angbplot->SetCenter(true);
    $angbplot->mark->SetType(MARK_FILLEDCIRCLE);
    $angbplot->mark->SetWidth(4);
    $angbplot->mark->SetFillColor("yellow");
    //$angbplot->mark->SetType(MARK_CIRCLE);
    $angbplot->SetLegend("Angbote");
    $graph->Add($angbplot);
    $graph->yaxis->title->SetFont(FONTART, FONTSTYLE);
    $graph->xaxis->title->SetFont(FONTART, FONTSTYLE);
    $graph->yaxis->SetFont(FONTART, FONTSTYLE);
    $graph->xaxis->SetFont(FONTART, FONTSTYLE);
    $graph->xaxis->title->Set("Monate");
    $graph->yaxis->title->Set("Euro");
    $graph->yaxis->SetTitleMargin(50);
    $graph->xaxis->SetTickLabels($monate);
    $graph->legend->Pos(0.03, 0.9, "left", "center");
    $IMG = 'tmp/' . $employee . '.png';
    @exec('rm ' . $IMG);
    $graph->Stroke($IMG);
    return $IMG;
}