array_unshift($date, date("M-j", $row['ts']));
        $last_time = $row['ts'];
    } else {
        array_unshift($date, '');
    }
}
$cache_image = IMAGE_PATH . "/progress/trend_{$player}_{$last_time}.png";
if (file_exists($cache_image)) {
    header('Content-type: image/png');
    readfile($cache_image);
    exit;
}
$Chart = new pChart(400, 200);
$Chart->drawBackground($bg_color['red'], $bg_color['green'], $bg_color['blue']);
$Chart->setGraphArea(40, 28, 339, 174);
$Chart->drawGraphAreaGradient(40, 40, 40, -50);
if (count($date) < 2) {
    $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 11);
    $Chart->drawTextBox(100, 90, 180, 110, "Not Enough Session Data", 0, 0, 0, 0, ALIGN_LEFT, FALSE, 255, 255, 255, 0);
} else {
    $DataSet = new pData();
    $DataSet->AddPoint($skill, 'SerieSkill');
    $DataSet->AddPoint($skill_change, 'SerieSession');
    $DataSet->AddPoint($date, 'SerieDate');
    $DataSet->AddSerie('SerieSkill');
    $DataSet->SetAbsciseLabelSerie('SerieDate');
    $DataSet->SetSerieName('Skill', 'SerieSkill');
    $DataSet->SetSerieName('Session', 'SerieSession');
    $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 7);
    $DataSet->SetYAxisName('Skill');
    $DataSet->SetYAxisUnit('K');
Example #2
0
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1");
$DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2");
$DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->setGraphArea(120, 20, 675, 190);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
$Test->drawGraphAreaGradient(163, 203, 167, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the bar chart
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Draw the title
$Title = "  Average Temperatures during\r\n  the first months of 2008  ";
$Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30);
// Draw the legend
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
// Render the picture
Example #3
0
 function generate_graph_image($outputfile)
 {
     // Create Graph Dataset and set axis attributes
     $graphData = new pData();
     $graphData->setYAxisName($this->ytitle);
     $graphData->AddPoint($this->xlabels, "xaxis");
     //$graphData->SetSerieName("xaxis","xaxis");
     $graphData->SetAbsciseLabelSerie("xaxis");
     $graphData->setXAxisName($this->xtitle);
     // Add each series of plot values to dataset, but Reportico will
     // duplicate series were the same data are displayed in different forms
     // so only add each unique series once
     $seriesadded = array();
     foreach ($this->plot as $k => $v) {
         $series = $v["name"] . $k;
         $graphData->AddPoint($v["data"], $series);
         $graphData->SetSerieName($v["legend"], $series);
         $graphData->AddSerie($series);
     }
     /*
     switch ( $this->xgriddisplay )
     {
     	case "all":
     		$graph->xgrid->Show(true,true);
     		break;
     	case "major":
     		$graph->xgrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->xgrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->xgrid->Show(false,false);
     		break;
     }
     
     switch ( $this->ygriddisplay )
     {
     	case "all":
     		$graph->ygrid->Show(true,true);
     		break;
     	case "major":
     		$graph->ygrid->Show(true,false);
     		break;
     	case "minor":
     		$graph->ygrid->Show(false,true);
     		break;
     	case "none":
     	default:
     		$graph->ygrid->Show(false,false);
     		break;
     }
     */
     /*
     $graph->xaxis->SetFont($fontfamilies[$xaxisfont],$fontstyles[$xaxisfontstyle], $xaxisfontsize);
     $graph->xaxis->SetColor($xaxiscolor,$xaxisfontcolor);
     $graph->yaxis->SetFont($fontfamilies[$yaxisfont],$fontstyles[$yaxisfontstyle], $yaxisfontsize);
     $graph->yaxis->SetColor($yaxiscolor,$yaxisfontcolor);
     $graph->xaxis->title->SetFont($fontfamilies[$xtitlefont],$fontstyles[$xtitlefontstyle], $xtitlefontsize);
     $graph->xaxis->title->SetColor($xtitlecolor);
     $graph->yaxis->title->SetFont($fontfamilies[$ytitlefont],$fontstyles[$ytitlefontstyle], $ytitlefontsize);
     $graph->yaxis->title->SetColor($ytitlecolor);
     $graph->xaxis->SetLabelAngle(90);
     $graph->xaxis->SetLabelMargin(15); 
     $graph->yaxis->SetLabelMargin(15); 
     $graph->xaxis->SetTickLabels($this->xlabels);
     $graph->xaxis->SetTextLabelInterval($xticklabint);
     $graph->yaxis->SetTextLabelInterval($yticklabint);
     $graph->xaxis->SetTextTickInterval($xtickinterval);
     $graph->yaxis->SetTextTickInterval($ytickinterval);
     */
     /*
     if ( $gridpos == "front" )
     	$graph->SetGridDepth(DEPTH_FRONT); 
     */
     // Display the graph
     /*?$graph->Stroke();*/
     $this->apply_defaults_internal();
     //echo $this->width_pdf_actual.",".$this->height_pdf_actual."<BR>";
     $graphImage = new pChart($this->width_pdf_actual, $this->height_pdf_actual);
     /* Turn of Antialiasing */
     $graphImage->Antialias = TRUE;
     // Add gradient fill from chosen background color to white
     $startgradient = htmltorgb("#ffffff");
     //$graphImage->drawGradientArea(0,0,$width,$height,DIRECTION_VERTICAL,array(
     //"StartR"=>$startgradient[0], "StartG"=>$startgradient[1], "StartB"=>$startgradient[2],
     //"EndR"=>$color[0], "EndG"=>$color[1], "EndB"=>$color[2],"Alpha"=>100));
     /* Add a border to the picture */
     //$graphImage->drawRectangle(0,0,$width - 1,$height - 1,200,200,200);
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xaxisfont, $this->xaxisfontsize);
     /* Define the chart area */
     $graphImage->setGraphArea($this->marginleft_actual, $this->margintop_actual, $this->width_pdf_actual - $this->marginright_actual, $this->height_pdf_actual - $this->marginbottom_actual);
     $graphImage->drawFilledRoundedRectangle(3, 3, $this->width_pdf_actual - 3, $this->height_pdf_actual - 3, 5, 240, 240, 240);
     $graphImage->drawRoundedRectangle(1, 1, $this->width_pdf_actual - 1, $this->height_pdf_actual - 1, 5, 230, 230, 230);
     // Before plotting a series ensure they are all not drawable.
     /// Plot the chart data
     $stackeddrawn = false;
     $linedrawn = false;
     $scatterdrawn = false;
     $piedrawn = false;
     $stackedexists = false;
     $overlayexists = false;
     $barexists = false;
     foreach ($this->plot as $k => $v) {
         if ($v["type"] == "OVERLAYBAR") {
             $overlayexists = true;
         }
         if ($v["type"] == "STACKEDBAR") {
             $stackedexists = true;
         }
         if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
             $barexists = true;
         }
         // Set plot colors
         if ($v["linecolor"]) {
             $graphImage->Palette[$k] = htmltorgb_pchart($v["linecolor"]);
         }
         $url .= "&plotlinecolor{$k}=" . $v["linecolor"];
     }
     $scale_drawing_mode = SCALE_NORMAL;
     $scale_drawing_mode = SCALE_START0;
     // For stacked charts fix up the Max and Min values;
     if ($stackedexists) {
         $scale_drawing_mode = SCALE_ADDALL;
         $scaleMin = "Unknown";
         $scaleMax = 0;
         $min = false;
         $max = false;
         foreach ($plot as $k => $v) {
             if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                 $series = $v["name"] . $k;
                 minmaxValueOfSeries($v["data"], $min, $max);
                 if ($scaleMin == "Unknown" || $min < $scaleMin) {
                     $scaleMin = $min;
                 }
                 $scaleMax = $scaleMax + $max;
             }
         }
         if ($scaleMin > 0) {
             $scaleMin = 0;
         }
         $range = $scaleMax - $scaleMin;
         // Make scales based on 5% of the range of values
         $scaleMax = round($range * 0.05 + $scaleMax);
         if ($scaleMin < 0) {
             $scaleMin = $scaleMin - round($range * 0.05);
         }
         $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
     } else {
         if ($barexists || $overlayexists) {
             $scaleMin = "Unknown";
             $scaleMax = 0;
             $min = false;
             $max = false;
             foreach ($this->plot as $k => $v) {
                 if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                     $series = $v["name"] . $k;
                     minmaxValueOfSeries($v["data"], $min, $max);
                     if ($scaleMin == "Unknown" || $min < $scaleMin) {
                         $scaleMin = $min;
                     }
                     if ($scaleMax == "Unknown" || $max > $scaleMax) {
                         $scaleMax = $max;
                     }
                 }
             }
             if ($scaleMin > 0) {
                 $scaleMin = 0;
             }
             $range = $scaleMax - $scaleMin;
             // Make scales based on 5% of the range of values
             $scaleMax = round($range * 0.05 + $scaleMax);
             if ($scaleMin < 0) {
                 $scaleMin = $scaleMin - round($range * 0.05);
             }
             $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax));
         }
     }
     //echo "<PRE>";
     //var_dump($graphData->GetDataDescription());
     //die;
     // Find out if a scale is required, will be except for pie charts
     $scalerequired = false;
     foreach ($this->plot as $k => $v) {
         switch ($v["type"]) {
             case "BAR":
             case "STACKEDBAR":
             case "OVERLAYBAR":
             case "LINE":
                 $scalerequired = "NORMAL";
                 break;
             case "SCATTER":
                 $scalerequired = "SCATTER";
                 break;
         }
     }
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xtitlefont, $this->xtitlefontsize);
     if ($scalerequired) {
         $graphImage->setGraphArea($this->marginleft_actual, $this->margintop_actual, $this->width_pdf_actual - $this->marginright, $this->height_pdf_actual - $this->marginbottom_actual);
         $graphImage->drawGraphAreaGradient(240, 240, 240, -20);
         // Automatic generation of x tick interval based on number of ticks
         if ($this->xticklabelinterval_actual == "AUTO") {
             $labct = count($this->plot[0]["data"]);
             $this->xticklabelinterval_actual = floor($labct / 35) + 1;
         }
         if ($scalerequired == "NORMAL") {
             $graphImage->drawScale($graphData->GetData(), $graphData->GetDataDescription(), $scale_drawing_mode, 0, 0, 0, TRUE, 40, FALSE, TRUE, $this->xticklabelinterval_actual, FALSE);
         }
         $graphImage->drawGrid(2, TRUE, 230, 230, 230, 45);
     } else {
         $this->marginright = 5;
         $this->marginbottom = 5;
         $this->marginleft = 5;
         $this->marginright_actual = 5;
         $this->marginbottom_actual = 5;
         $this->marginleft_actual = 5;
         //$this->margintop_actual = 5;
         $graphImage->setGraphArea($this->marginleft, $this->margintop_actual, $this->width_pdf_actual - $this->marginright, $this->height_pdf_actual - $this->marginbottom);
         $graphImage->drawGraphAreaGradient(240, 240, 240, -10);
     }
     // If there's a Pie chart we want to draw different legends
     $piechart = false;
     foreach ($this->plot as $k => $v) {
         disableAllSeries($this->plot, $graphData);
         $series = $v["name"] . $k;
         setSerieDrawable($this->plot, $graphData, $series, TRUE);
         switch ($v["type"]) {
             case "PIE":
                 $piedrawn = true;
                 $piechart = true;
                 $graphImage->drawFilledCircle($this->width_pdf_actual / 2 + 2, $this->margintop_actual + 2 + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45 + 1, 200, 200, 200);
                 $graphImage->drawBasicPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.45, PIE_PERCENTAGE_LABEL, 255, 255, 218);
                 break;
             case "PIE3D":
                 $piedrawn = true;
                 $piechart = true;
                 $graphImage->drawPieGraph($graphData->GetData(), $graphData->GetDataDescription(), $this->width_pdf_actual / 2, $this->margintop_actual + ($this->height_pdf_actual - $this->margintop_actual - $this->marginbottom_actual) / 2, ($this->height_pdf_actual - $this->marginbottom_actual - $this->margintop_actual - 20) * 0.5, PIE_PERCENTAGE_LABEL, true, 60, 20, 0, 0);
                 break;
             case "OVERLAYBAR":
             case "STACKEDBAR":
             case "BAR":
                 if ($stackeddrawn) {
                     break;
                 }
                 if ($barexists || $overlayexists) {
                     foreach ($this->plot as $k1 => $v1) {
                         if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
                             setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                         }
                     }
                 }
                 $stackeddrawn = true;
                 if ($stackedexists) {
                     $graphImage->drawStackedBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
                 } else {
                     if ($overlayexists) {
                         $graphImage->drawOverlayBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
                     } else {
                         $graphImage->drawBarGraph($graphData->GetData(), $graphData->GetDataDescription());
                     }
                 }
                 break;
             case "SCATTER":
                 if ($scatterdrawn) {
                     break;
                 }
                 $scatterdrawn = true;
                 $series1 = false;
                 $series2 = false;
                 $graphImage->reportWarnings("GD");
                 $ct = 0;
                 foreach ($this->plot as $k1 => $v1) {
                     if ($v1["type"] == "SCATTER") {
                         if ($ct == 0) {
                             $series1 = $v1["name"] . $k1;
                         }
                         if ($ct == 1) {
                             $series2 = $v1["name"] . $k1;
                         }
                         $ct++;
                         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                     }
                 }
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->drawXYScale($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2, 0, 0, 0);
                 //$graphImage->drawXYGraph($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2);
                 $graphImage->drawXYPlotGraph($graphData->GetData(), $graphData->GetDataDescription(), $series1, $series2);
                 $graphImage->writeValues($graphData->GetData(), $graphData->GetDataDescription(), $series2);
                 break;
             case "LINE":
             default:
                 if ($linedrawn) {
                     break;
                 }
                 $linedrawn = true;
                 foreach ($this->plot as $k1 => $v1) {
                     if ($v1["type"] == "LINE") {
                         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
                     }
                 }
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->LineWidth = 1;
                 $graphImage->drawLineGraph($graphData->GetData(), $graphData->GetDataDescription());
                 $graphImage->drawPlotGraph($graphData->GetData(), $graphData->GetDataDescription());
                 $graphImage->LineWidth = 1;
                 break;
         }
     }
     foreach ($this->plot as $k1 => $v1) {
         setSerieDrawable($this->plot, $graphData, $v1["name"] . $k1, TRUE);
     }
     // Draw Legend if legend value has been set
     $drawlegend = false;
     foreach ($this->plot as $k => $v) {
         if (isset($v["legend"]) && $v["legend"]) {
             // Temporarily Dont draw legend for Pie
             //if ( $piechart )
             //$graphImage->drawPieLegend($this->width_pdf_actual - 180,30,$graphData->GetData(), $graphData->GetDataDescription(), 250, 250, 250);
             if (!$piechart) {
                 $graphImage->drawLegend($this->width_pdf_actual - 120, 30, $graphData->GetDataDescription(), 254, 254, 254, 0, 0, 0);
             }
             break;
         }
     }
     $graphImage->setFontProperties(PCHARTFONTS_DIR . $this->xtitlefont, $this->titlefontsize);
     $graphImage->drawTitle(0, 24, $this->title_actual, 50, 50, 50, $this->width_pdf_actual);
     //$graphImage->setShadow(TRUE,array("X"=>0,"Y"=>0,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
     //$graphImage->Render("example.png");
     //$graphImage->Stroke();
     $graphImage->render($outputfile);
     return true;
 }
Example #4
0
 /**
  * Initializes the chart, sets the properties
  */
 public function initializeChart()
 {
     global $wgPChart4mwFontPath;
     // Retrieve the parameters for the chart
     $args = $this->chartArgs;
     // Create a chart object
     $pChart = new pChart($args["sizeX"], $args["sizeY"]);
     // Draw background colors. If needed, a gradient should be drawn
     if ($args["bgtype"] == "normal") {
         $pChart->drawFilledRectangle(0, 0, $args["sizeX"], $args["sizeY"], $args["bgcolor"][0], $args["bgcolor"][1], $args["bgcolor"][2]);
     } else {
         $pChart->drawGraphAreaGradient($args["bgcolor"][0], $args["bgcolor"][1], $args["bgcolor"][2], 50, TARGET_BACKGROUND);
     }
     // Set default font properties
     $pChart->setFontProperties($wgPChart4mwFontPath . "/" . $args["textfont"], $args["textsize"]);
     // Define the graph area, by computing the margins, legend size, title size etc.
     $pChart = $this->setGraphArea($pChart);
     if ($args["graphbgtype"] == "normal") {
         $pChart->drawGraphArea($args["graphbgcolor"][0], $args["graphbgcolor"][1], $args["graphbgcolor"][2]);
     } elseif ($args["graphbgtype"] == "gradient") {
         $pChart->drawGraphAreaGradient($args["graphbgcolor"][0], $args["graphbgcolor"][1], $args["graphbgcolor"][2], 50);
     }
     $this->pChart = $pChart;
     if (!$this->empty) {
         $this->drawScaleAndGrid();
         $this->setColorPalette();
     }
     return $this->pChart;
 }
    switch ($v["type"]) {
        case "BAR":
        case "STACKEDBAR":
        case "OVERLAYBAR":
        case "LINE":
            $scalerequired = "NORMAL";
            break;
        case "SCATTER":
            $scalerequired = "SCATTER";
            break;
    }
}
$graphImage->setFontProperties(PCHARTFONTS_DIR . $xtitlefont, $xtitlefontsize);
if ($scalerequired) {
    $graphImage->setGraphArea($marginleft, $margintop, $width - $marginright, $height - $marginbottom);
    $graphImage->drawGraphAreaGradient(240, 240, 240, -20);
    // Automatic generation of x tick interval based on number of ticks
    if ($xticklabint == "AUTO") {
        $labct = count($plot[0]["data"]);
        $xticklabint = floor($labct / 50) + 1;
    }
    if ($scalerequired == "NORMAL") {
        $graphImage->drawScale($graphData->GetData(), $graphData->GetDataDescription(), $scale_drawing_mode, 0, 0, 0, TRUE, 40, FALSE, TRUE, $xticklabint, FALSE);
    }
    $graphImage->drawGrid(1, TRUE, 230, 230, 230, 45);
} else {
    $marginright = 5;
    $marginbottom = 5;
    $marginleft = 5;
    //$margintop = 5;
    $graphImage->setGraphArea($marginleft, $margintop, $width - $marginright, $height - $marginbottom);
$DataSet->AddPoint(array(3.4, 6.4, 8.6, 9.800000000000001, 9.9, 9.4, 7.7, 13, 11, 13.6, 11.2, 5.6), "Serie2");
$DataSet->AddPoint(array(7.1, 9.1, 10, 9.699999999999999, 8.199999999999999, 10, 7.7, 9.9, 9.800000000000001, 6.4, 11.6, 15.6), "Serie3");
$DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May", "June", "July", "Aug", "Sept", "Oct", "Nov", "Dec"), "Serie4");
//$DataSet->AddAllSeries();
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->AddSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie4");
$DataSet->SetSerieName("Charcoal", "Serie1");
$DataSet->SetSerieName("Firewood", "Serie2");
$DataSet->SetSerieName("Kerosene", "Serie3");
$DataSet->SetYAxisName("Amount Used (kg)");
$DataSet->SetXAxisName("Month of the year");
// Initialise the graph
$Test = new pChart(660, 230);
$Test->drawGraphAreaGradient(90, 90, 90, 90, TARGET_BACKGROUND);
// Prepare the graph area
$Test->setFontProperties("fonts/tahoma.ttf", 8);
$Test->setGraphArea(60, 40, 595, 190);
// Initialise graph area
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
// Draw the SourceForge Rank graph
$DataSet->SetYAxisName("Amount of Fuel Used");
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 0);
$Test->drawGraphAreaGradient(40, 40, 40, -50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 10);
$Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
Example #7
0
 $DataSet->SetSerieName("Rank", "rank");
 $DataSet->SetYAxisName("Punkte");
 $DataSet->SetAbsciseLabelSerie("time");
 //$DataSet->SetXAxisFormat("date");
 // Cache definition
 $Cache = new pCache('../charts/Cache/');
 if ($use_cache && !$Cache->GetFromCache(md5($user['name']), $DataSet->GetData(), $FileName) or !$use_cache) {
     // Initialise the graph
     $Test = new pChart(715, 230);
     $Test->setDateFormat('d.m H:i');
     $Test->setFontProperties("../charts/Fonts/tahoma.ttf", 8);
     $Test->setGraphArea(60, 30, 650, 150);
     $Test->drawFilledRoundedRectangle(7, 7, 708, 223, 5, 240, 240, 240);
     $Test->drawRoundedRectangle(5, 5, 710, 225, 5, 163, 203, 167);
     $Test->drawGraphArea(255, 255, 255, TRUE);
     $Test->drawGraphAreaGradient(163, 203, 167, 50);
     $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_DIFF, 150, 150, 150, TRUE, 75, 0, FALSE, $skip_scale);
     $Test->drawGrid(4, TRUE, 230, 230, 230, 40);
     // Draw the graph
     $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
     if ($scale_hours <= 48) {
         $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 2, 1, 255, 255, 255);
     }
     // Draw labels
     if (!empty($ccities)) {
         foreach ($ccities as $k => $v) {
             $Test->setLabel($DataSet->GetData(), $DataSet->GetDataDescription(), "points", $k, "Städte: {$v}", 239, 233, 195);
         }
     }
     $Test->clearShadow();
     // Clear the scale
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
// Compute the points
for ($i = 0; $i <= 360; $i = $i + 10) {
    $DataSet->AddPoint(cos($i * 3.14 / 180) * 80 + $i, "Serie1");
    $DataSet->AddPoint(sin($i * 3.14 / 180) * 80 + $i, "Serie2");
}
$DataSet->SetSerieName("Trigonometric function", "Serie1");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetXAxisName("X Axis");
$DataSet->SetYAxisName("Y Axis");
// Initialise the graph
$Test = new pChart(300, 300);
$Test->drawGraphAreaGradient(0, 0, 0, -100, TARGET_BACKGROUND);
// Prepare the graph area
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(55, 30, 270, 230);
$Test->drawXYScale($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1", "Serie2", 213, 217, 221, TRUE, 45);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawGraphAreaGradient(30, 30, 30, -50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the chart
$Test->setShadowProperties(2, 2, 0, 0, 0, 60, 4);
$Test->drawXYGraph($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1", "Serie2", 0);
$Test->clearShadow();
// Draw the title
$Title = "Drawing X versus Y charts trigonometric functions  ";
$Test->drawTextBox(0, 280, 300, 300, $Title, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
// Draw the legend
Example #9
0
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1");
$DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2");
$DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("∞C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
// Graph area setup
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(60, 20, 585, 180);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2);
$Test->drawGraphAreaGradient(162, 183, 202, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the line chart
$Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 4, 2, -1, -1, -1, TRUE);
// Draw the legend
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(605, 142, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
Example #10
0
$DataSet->AddPoint(array(5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 1, 2, 3, 4), "Serie6");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie6");
$DataSet->SetAbsciseLabelSerie("Serie6");
// $DataSet->SetSerieName("Sedentary","Serie5");
$DataSet->SetYAxisName("Activity");
$DataSet->SetYAxisUnit(" min");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(800, 230);
/* $Test->setColorPalette(0,155,206,240); 
 $Test->setColorPalette(1,107,183,233); 
 $Test->setColorPalette(2,81,170,230); 
 $Test->setColorPalette(3,46,151,224); 
*/
$Test->drawGraphAreaGradient(230, 230, 230, 50, TARGET_BACKGROUND);
// $Test->loadColorPalette("pChart/tones-8.txt");
//$Test->createColorGradientPalette(10,194,251,23,20,151,5);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(80, 20, 775, 190);
$Test->drawGraphArea(180, 190, 210, TRUE);
$Test->setFixedScale(0, 60, 6);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 100, 100, 100, TRUE, 0, 2, TRUE);
//$Test->drawGraphAreaGradient(150,150,150,80);
// $Test->drawGraphAreaGradient(163,203,167,50);
$Test->drawGrid(2, TRUE, 230, 230, 230, 40);
// Draw the bar chart
// Draw the title
// $Title = "  Average Temperatures during\r\n  the first months of 2008  ";
// $Test->drawTextBox(0,0,50,230,$Title,90,255,255,255,ALIGN_BOTTOM_CENTER,TRUE,0,0,0,30);
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 60);
Example #11
0
 /**
  * Рисуем графики с помощью библиотеки pChart
  * @param object $model
  * @param integer $max_id
  * @param integer $x
  * @param integer $y
  * @param integer $y2
  */
 public function pChart($model, $max_id, $x, $y, $y2 = NULL)
 {
     /* Include the pData class */
     require_once Yii::getAlias('@app') . '/pChart/pChart/pData.class';
     require_once Yii::getAlias('@app') . '/pChart/pChart/pCache.class';
     require_once Yii::getAlias('@app') . '/pChart/pChart/pChart.class';
     //создаем объект данных
     $myData = new \pData();
     if (!$y2) {
         $datas = $model::find()->select([$x, $y])->andWhere("id > {$max_id} - 7")->all();
     } else {
         $datas = $model::find()->select([$x, $y, $y2])->andWhere("id > {$max_id} - 7")->all();
     }
     foreach ($datas as $key => $data) {
         $myData->AddPoint($data->{$x}, $x);
         $myData->AddPoint($data->{$y}, $y);
         if ($y2 != NULL) {
             $myData->AddPoint($data->{$y2}, $y2);
         }
     }
     //устанавливаем точки с датами
     //на ось абсцисс
     $myData->SetAbsciseLabelSerie($x);
     //помечаем данные как предназначеные для
     //отображения
     $myData->AddSerie($y);
     $myData->AddSerie($y2);
     //устанавливаем имена
     $myData->SetSerieName($y);
     $myData->SetSerieName($y2);
     //создаем график шириной  и высотой  px
     $graph = new \pChart(340, 130);
     //устанавливаем шрифт и размер шрифта
     $graph->setFontProperties(Yii::getAlias('@app') . '/pChart/Fonts/tahoma.ttf', true, 8);
     //координаты левой верхней вершины и правой нижней
     //вершины графика
     $graph->setGraphArea(35, 20, 330, 110);
     //добавляем бэкграунд
     $graph->drawBackground(255, 0, 0);
     $graph->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
     //рисуем заполненный четырехугольник
     $graph->drawFilledRoundedRectangle(7, 7, 993, 493, 5, 240, 240, 240);
     //теперь незаполненный для эффекта тени
     $graph->drawRoundedRectangle(5, 5, 995, 495, 5, 0, 200, 0);
     //прорисовываем фон графика
     $graph->drawGraphArea(200, 255, 255, TRUE);
     //устанавливаем данные для графиков
     $graph->drawScale($myData->GetData(), $myData->GetDataDescription(), SCALE_NORMAL, 10, 10, 10, true, 0, 2);
     //рисуем сетку для графика
     $graph->drawGrid(4, TRUE, 200, 230, 230, 50);
     //прорисовываем линейные графики
     $graph->drawLineGraph($myData->GetData(), $myData->GetDataDescription());
     // рисуем точки на графике
     $graph->drawPlotGraph($myData->GetData(), $myData->GetDataDescription(), 3, 2, 255, 255, 255);
     // пишем в подвале некоторый текст
     $graph->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf', true), 8);
     $graph->drawTextBox(805, 470, 990, 480, "{$x}", 0, 150, 150, 150, ALIGN_CENTER, TRUE, -1, -1, -1, 30);
     $graph->drawTextBox(10, 470, 140, 480, "{$y}", 0, 250, 250, 250, ALIGN_CENTER, TRUE, -1, -1, -1, 30);
     //ложим легенду
     $graph->drawLegend(90, 35, $myData->GetDataDescription(), 255, 255, 255);
     //Пишем заголовок
     $graph->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf', true), 8);
     $graph->drawTitle(480, 22, "График", 50, 50, 50, -1, -1, true);
     //выводим в браузер
     $graph->Render(Url::to('@app/web/uploads/' . $y . '.png'));
 }
Example #12
0
}
if ($_GET['g9color'] == 'red') {
    $Test->setColorPalette(2, 220, 50, 50);
} elseif ($_GET['g9color'] == 'brown') {
    $Test->setColorPalette(2, 220, 140, 100);
} elseif ($_GET['g9color'] == 'blue') {
    $Test->setColorPalette(2, 100, 140, 220);
} elseif ($_GET['g9color'] == 'green') {
    $Test->setColorPalette(2, 100, 200, 100);
} elseif ($_GET['g9color'] == 'orange') {
    $Test->setColorPalette(2, 220, 190, 50);
} else {
}
//---------------------------- Set [bcolor] background (R,G,G,1/Y)
if ($_GET['bcolor'] == 'red') {
    $Test->drawGraphAreaGradient(250, 210, 210, 50, TARGET_BACKGROUND);
} elseif ($_GET['bcolor'] == 'blue') {
    $Test->drawGraphAreaGradient(170, 220, 250, 50, TARGET_BACKGROUND);
} elseif ($_GET['bcolor'] == 'green') {
    $Test->drawGraphAreaGradient(210, 250, 210, 50, TARGET_BACKGROUND);
} else {
}
//---------------------------- Title
$Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 10);
if ($_GET['title']) {
    $Test->drawTitle(100, 15, $_GET['title'], 150, 150, 150);
} else {
}
//---------------------------- Font
$Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 8);
//---------------------------- Set GraphArea
Example #13
0
 public function build()
 {
     require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pData.php';
     require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pChart.php';
     $dataSet = new pData();
     foreach ($this->lines as $name => $ordinateValues) {
         if (count($ordinateValues) != count($this->absciseValues)) {
             throw new Exception('Count of line "' . $name . '" ordinate points "' . count($ordinateValues) . '" mismatch to abscise points "' . count($this->absciseValues) . '"');
         }
         $dataSet->AddPoint($ordinateValues, $name);
     }
     $dataSet->AddPoint($this->absciseValues, 'Abscise');
     $dataSet->AddAllSeries();
     $dataSet->RemoveSerie('Abscise');
     $dataSet->SetAbsciseLabelSerie('Abscise');
     foreach ($this->lines as $name => $ordinateValues) {
         $dataSet->SetSerieName($name, $name);
     }
     $dataSet->SetYAxisUnit($this->ordinateStepTitle);
     $dataSet->SetXAxisUnit($this->absciseStepTitle);
     $chart = new pChart($this->maxWidth, $this->maxHeight);
     $chart->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
     // Graph area setup
     $chart->setFontProperties(PCHART_FONTS_DIR . DIRECTORY_SEPARATOR . 'tahoma.ttf', 10);
     $chart->setGraphArea($this->graphMargins[0], $this->graphMargins[1], $this->maxWidth - $this->graphMargins[2], $this->maxHeight - $this->graphMargins[3]);
     $chart->drawGraphArea(213, 217, 221, FALSE);
     $ordinateScaleMargin = ($this->getMaxOrdinateValue() - $this->getMinOrdinateValue()) / $this->ordinateDevisions;
     $chart->setFixedScale($this->getMinOrdinateValue() - $ordinateScaleMargin, $this->getMaxOrdinateValue() + $ordinateScaleMargin, $this->ordinateDevisions);
     $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2);
     $chart->drawGraphAreaGradient(162, 183, 202, 50);
     $chart->drawGrid(4, TRUE, 230, 230, 230, 20);
     // Draw the line chart
     //		$chart->setShadowProperties(1, 1, 0, 0, 0, 30, 4);
     $chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
     $chart->clearShadow();
     $chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 5, 3, -1, -1, -1, TRUE);
     // Draw the legend
     $chart->drawLegend($this->maxWidth - $this->graphMargins[2] + 10, $this->graphMargins[1], $dataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
     // Draw chart title
     if ($this->chartTitle) {
         $chart->drawTextBox(0, $this->maxHeight - 20, $this->maxWidth, $this->maxHeight, $this->chartTitle, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
     }
     // Render the picture
     $chart->addBorder(2);
     $chart->Render($this->outputFilepath);
 }
Example #14
0
}
if ($v9 != 0 && $c9r != 0) {
    $Test->setColorPalette(8, $c9r, $c9g, $c9b);
}
//---------------------------- Background
$Test->drawBackground($cbg, $cbg, $cbg);
//---------------------------- Title
$Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 10);
$Test->drawTitle(2, 15, $title, 150, 150, 150);
//---------------------------- Font
$Test->setFontProperties("./pChart/Fonts/tahoma.ttf", 8);
//---------------------------- Set GraphArea
$Test->setGraphArea(0, 0, $w, $h);
//---------------------------- Set background graphics (R,G,G,1/Y)
if ($bg_r != 0 && $bg_g != 0 && $bg_b != 0) {
    $Test->drawGraphAreaGradient($bg_r, $bg_g, $bg_b, 5);
}
//---------------------------- Calc center
$midX = $w / 2;
$midY = $h / 2;
//---------------------------- Draw pie
if ($_GET['gtype'] == 'pie') {
    $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, $cbg, $cbg, $cbg, 1);
} elseif ($_GET['gtype'] == 'pie2') {
    $Test->drawFlatPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, 5, 1);
} elseif ($_GET['gtype'] == 'pie3') {
    $Test->setShadowProperties(3, 3, $csh, $csh, $csh, 90);
    $Test->drawFlatPieGraphWithShadow($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, 5, 1);
} elseif ($_GET['gtype'] == 'pie4') {
    $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $midX, $midY, $radius, PIE_PERCENTAGE_LABEL, TRUE, 60, 20, 5, 1);
} else {
Example #15
0
            $OLNum[] = $data_server[$i];
        }
    }
}
$pChartDataSet = new pData();
$pChartDataSet->AddPoint($XAxis, "Serie1");
$pChartDataSet->AddPoint($OLNum, "Serie2");
$pChartDataSet->AddSerie("Serie2");
$pChartDataSet->RemoveSerie("Serie1");
$pChartDataSet->SetAbsciseLabelSerie("Serie1");
$pChartDataSet->SetYAxisName("在\n线\n人\n数\n//\n人");
$pChartDataSet->SetYAxisFormat("floor");
$pChartDataSet->SetXAxisFormat("number");
// 设置作图区域
$pChartGraph = new pChart($imgWidth, 253);
$pChartGraph->drawGraphAreaGradient(90, 90, 90, 90, TARGET_BACKGROUND);
$pChartGraph->setGraphArea(70, 30, $imgWidth + 70 - 90, 253 + 30 - 80);
$pChartGraph->setFontProperties(DRAWFONE_PATH, 8);
$pChartGraph->drawScale($pChartDataSet->GetData(), $pChartDataSet->GetDataDescription(), SCALE_NORMAL, 250, 250, 250, TRUE, 0, 0, FALSE, 1);
// 开始作图
$pChartGraph->setColorPalette(0, 0, 255, 255);
$pChartGraph->drawGraphAreaGradient(40, 40, 40, -50);
$pChartGraph->drawGrid(1, TRUE, 115, 115, 115, 10);
$pChartGraph->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
$pChartGraph->drawFilledLineGraph($pChartDataSet->GetData(), $pChartDataSet->GetDataDescription(), 25);
$pChartGraph->clearShadow();
$pChartGraph->setFontProperties(DRAWFONE_PATH, 10);
$pChartGraph->drawTitle($imgWidth / 2, 22, "实时在线人数查询(" . $dateTime . ") 峰值( " . $maxNumberIndex . ", " . $maxNumber . "人 )", 255, 255, 255, 585);
$pChartGraph->writeValues($pChartDataSet->GetData(), $pChartDataSet->GetDataDescription(), "Serie2");
// 结束
$pChartGraph->Stroke();
Example #16
-1
function grafico($dados, $eixo, $cor1, $grafico, $situacao, $legenda)
{
    include_once "pChart/pChart/pData.class";
    include_once "pChart/pChart/pChart.class";
    $DataSet = new pData();
    $DataSet->AddPoint($dados, "Serie1");
    $DataSet->AddPoint($eixo, "Serie2");
    $DataSet->AddAllSeries();
    $DataSet->RemoveSerie("Serie2");
    $DataSet->SetAbsciseLabelSerie("Serie2");
    $DataSet->SetSerieName($legenda, "Serie1");
    $Test = new pChart(720, 430);
    $Test->drawGraphAreaGradient($cor1, 173, 131, 50, TARGET_BACKGROUND);
    $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 8);
    $Test->setGraphArea(50, 80, 675, 390);
    $Test->drawGraphArea(217, 217, 211, FALSE);
    $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
    $Test->drawGraphAreaGradient(163, 203, 167, 50);
    $Test->drawGrid(4, TRUE, 230, 230, 230, 20);
    $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
    $Title = "{$situacao}";
    $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 14);
    $Test->drawTextBox(0, 0, 700, 60, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 30, 0, 0, 30);
    $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 9);
    $Test->drawLegend(520, 70, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
    $Test->addBorder(2);
    $Test->Render("images/" . $grafico);
}
Example #17
-1
 function cartesianChart($type, $x, $y, $w, $h, $imgname = '', $config = array())
 {
     $w -= 4;
     $h -= 4;
     $settings = array('FontName' => 'tahoma.ttf', 'FontSize' => 8, 'LegendFontSize' => 8, 'LegendFontName' => 'tahoma.ttf', 'Logo' => '', 'LogoTransparency' => 20, 'XAxisFormat' => 'number', 'XAxisUnit' => '', 'YAxisFormat' => 'number', 'YAxisUnit' => '', 'XLogo' => 0, 'YLogo' => 0, 'Xlabel' => 'x label', 'XAngle' => 0, 'Ylabel' => 'y label', 'Legend' => '', 'Textbox' => '', 'TextboxFontSize' => 8, 'TextboxFontName' => 'tahoma.ttf', 'ImgR' => 132, 'ImgG' => 173, 'ImgB' => 131, 'Decay' => 80, 'BGR' => 163, 'BGG' => 203, 'BGB' => 167, 'Decay2' => 80, 'Filled' => '', 'DataR' => 191, 'DataG' => 120, 'DataB' => 71, 'LBR' => 226, 'LBG' => 228, 'LBB' => 230, 'LR' => 0, 'LG' => 0, 'LB' => 0);
     // Get the custom settings
     if (is_array($config)) {
         foreach ($config as $key => $val) {
             $settings[$key] = $val;
         }
     }
     $DataSet = new pData();
     $DataSet->AddPoint($y, "Serie1");
     $DataSet->AddPoint($x, "Serie2");
     $DataSet->AddAllSeries();
     $DataSet->RemoveSerie("Serie2");
     $DataSet->SetAbsciseLabelSerie("Serie2");
     $DataSet->SetSerieName($settings['Legend'], "Serie1");
     $DataSet->SetYAxisName($settings['Ylabel']);
     $DataSet->SetXAxisName($settings['Xlabel']);
     $DataSet->SetXAxisFormat($settings['XAxisFormat']);
     if (strlen($settings['XAxisUnit'])) {
         $DataSet->SetXAxisUnit($settings['XAxisUnit']);
     }
     if (strlen($settings['YAxisUnit'])) {
         $DataSet->SetYAxisUnit($settings['YAxisUnit']);
     }
     $DataSet->SetYAxisFormat($settings['YAxisFormat']);
     // Initialise the graph
     $Test = new pChart($w, $h);
     $Test->drawGraphAreaGradient($settings['ImgR'], $settings['ImgG'], $settings['ImgB'], $settings['Decay'], TARGET_BACKGROUND);
     $FontSize = $settings['FontSize'];
     $FontName = $this->_ext_path . "/fonts/" . $settings['FontName'];
     $Test->setFontProperties($FontName, $FontSize);
     //Calc Textbox Height
     if (strlen($settings['Textbox'])) {
         $TextboxFontSize = $settings['TextboxFontSize'];
         $TextboxFontName = $this->_ext_path . "/fonts/" . $settings['TextboxFontName'];
         $Position = imageftbbox($TextboxFontSize, 0, $TextboxFontName, $settings['Textbox']);
         $TextboxHeight = $Position[1] - $Position[7] + 8;
     } else {
         $TextboxHeight = 0;
     }
     // Maximize The graph area
     //on Y axis
     if ($settings['XAxisFormat'] == 'time') {
         $xdata = "99:99:99";
         $Position = imageftbbox($FontSize, 0, $FontName, $xdata);
         $WXmax = $Position[2] - $Position[0];
         $TextHeightX = $Position[1] - $Position[7];
     } elseif ($settings['XAxisFormat'] == 'date') {
         $xdata = "99/99/9999";
         $Position = imageftbbox($FontSize, 0, $FontName, $xdata);
         $WXmax = $Position[2] - $Position[0];
         $TextHeightX = $Position[1] - $Position[7];
     } else {
         $WXmax = 0;
         foreach ($x as $xdata) {
             $xdata .= $settings['XAxisUnit'];
             $Position = imageftbbox($FontSize, 0, $FontName, $xdata);
             $TextWidth = $Position[2] - $Position[0];
             $TextHeightX = $Position[1] - $Position[7];
             $WXmax = $TextWidth > $WXmax ? $TextWidth : $WXmax;
         }
     }
     if ($settings['XAngle'] > 0) {
         $sin = abs(sin(deg2rad($settings['XAngle'])));
         $cos = abs(cos(deg2rad($settings['XAngle'])));
         $HXmax = $WXmax * $sin + $TextHeightX * $cos;
     } else {
         $HXmax = $TextHeightX;
     }
     //on Y axis...
     if ($settings['YAxisFormat'] == 'time') {
         $ydata = "99:99:99";
         $Position = imageftbbox($FontSize, 0, $FontName, $ydata);
         $WYmax = $Position[2] - $Position[0];
         $TextHeightY = $Position[1] - $Position[7];
     } elseif ($settings['YAxisFormat'] == 'date') {
         $ydata = "99/99/9999";
         $Position = imageftbbox($FontSize, 0, $FontName, $ydata);
         $WYmax = $Position[2] - $Position[0];
         $TextHeightY = $Position[1] - $Position[7];
     } else {
         $WYmax = 0;
         foreach ($y as $ydata) {
             $ydata .= $settings['YAxisUnit'];
             //echo $ydata."<br>";
             $Position = imageftbbox($FontSize, 0, $FontName, $ydata);
             $TextWidth = $Position[2] - $Position[0];
             $TextHeightY = $Position[1] - $Position[7];
             $WYmax = $TextWidth > $WYmax ? $TextWidth : $WYmax;
         }
     }
     $Test->setGraphArea($WYmax + $TextHeightY + 35, 20, $w - 25, $h - $HXmax - $TextHeightX - $TextboxHeight - 20);
     //$Test->setGraphArea(60,20,$w-25,($settings['XAngle']==0)?$h-70:$h-100);
     $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, $settings['XAngle'], 0, TRUE);
     $Test->drawGraphAreaGradient($settings['BGR'], $settings['BGG'], $settings['BGB'], $settings['Decay2']);
     $Test->drawGrid(4, TRUE, 230, 230, 230, 20);
     // This will put the picture "logo.png" with transparency
     if (strlen($settings['Logo'])) {
         $XLogo = $WYmax + $TextHeightY + 35 + $settings['XLogo'];
         $YLogo = 20 + $settings['XLogo'];
         $logo = $settings['Logo'];
         //Fing extension of logo : png,gif or jpg
         if ($this->_findexts($logo) == "png") {
             echo "png!";
             $Test->drawFromPNG($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
         } elseif ($this->_findexts($logo) == "gif") {
             echo "gif!";
             $Test->drawFromGIF($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
         } elseif ($this->_findexts($logo) == "jpg") {
             echo "jpg";
             $Test->drawFromJPG($logo, $XLogo, $YLogo, $settings['LogoTransparency']);
         }
     }
     $Test->setColorPalette(0, $settings['DataR'], $settings['DataG'], $settings['DataB']);
     if ($type == "bar") {
         // Draw the bar chart
         $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
     } elseif ($type == "line") {
         $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
         $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
     } elseif ($type == "cubic") {
         $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
         $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
         $Test->clearShadow();
         if ($settings['Filled'] == 'yes') {
             $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
         }
         $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
     }
     // Draw the textbox
     if (strlen($settings['Textbox'])) {
         $Test->setFontProperties($TextboxFontName, $TextboxFontSize);
         $Test->drawTextBox(0, $h - $TextboxHeight, $w, $h, $settings['Textbox'], 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30);
     }
     // Draw the legend
     if (strlen($settings['Legend'])) {
         $LegendFontSize = $settings['LegendFontSize'];
         $LegendFontName = $this->_ext_path . "/fonts/" . $settings['LegendFontName'];
         $Position = imageftbbox($LegendFontSize, 0, $LegendFontName, $settings['Legend']);
         $LegendW = $Position[2] - $Position[0] + 40;
         $Test->setFontProperties($LegendFontName, $LegendFontSize);
         $Test->drawLegend($w - $LegendW, 10, $DataSet->GetDataDescription(), $settings['LBR'], $settings['LBG'], $settings['LBB'], 52, 58, 82, $settings['LR'], $settings['LG'], $settings['LB'], TRUE);
     }
     // Render the picture
     $Test->addBorder(2);
     if (strlen($imgname)) {
         //custom image name
         $imgname = $this->_img_path . "/" . $imgname;
     } else {
         $this->obj->load->helper('string');
         $imgname = $this->_img_path . "/{$type}-" . random_string('alnum', 16) . ".png";
     }
     $Test->Render($imgname);
     return array("name" => '/' . $imgname, "w" => $w + 4, "h" => $h + 4);
 }