$myPicture->setGraphArea(58, 27, 816, 228);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(58, 27, 816, 228, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw the scale */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$ScaleSettings = array("XMargin" => 4, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
$myPicture->drawScale($ScaleSettings);
/* Draw the spline chart */
$myPicture->drawFilledSplineChart();
/* Write the chart boundaries */
$BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
$myPicture->writeBounds(BOUND_BOTH, $BoundsSettings);
/* Write the 0 line */
$myPicture->drawThreshold(0, array("WriteCaption" => TRUE));
/* Write the chart legend */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$myPicture->drawLegend(560, 266, array("Style" => LEGEND_NOBORDER));
/* Write the 1st data series statistics */
$Settings = array("R" => 188, "G" => 224, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
$myPicture->drawText(620, 270, "Max : " . ceil($MyData->getMax("Probe 1")), $Settings);
$myPicture->drawText(680, 270, "Min : " . ceil($MyData->getMin("Probe 1")), $Settings);
$myPicture->drawText(740, 270, "Avg : " . ceil($MyData->getSerieAverage("Probe 1")), $Settings);
/* Write the 2nd data series statistics */
$Settings = array("R" => 224, "G" => 100, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
$myPicture->drawText(620, 283, "Max : " . ceil($MyData->getMax("Probe 2")), $Settings);
$myPicture->drawText(680, 283, "Min : " . ceil($MyData->getMin("Probe 2")), $Settings);
$myPicture->drawText(740, 283, "Avg : " . ceil($MyData->getSerieAverage("Probe 2")), $Settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
 function generate_graph_image($outputfile)
 {
     // Create Graph Dataset and set axis attributes
     $graphData = new pData();
     $graphData->setAxisName(0, $this->ytitle_actual);
     $graphData->addPoints($this->xlabels, "xaxis");
     $graphData->setSerieDescription("xaxis", "xaxis");
     $graphData->setAbscissa("xaxis");
     $graphData->setXAxisName("ooo");
     // 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->addPoints($v["data"], $series);
         $graphData->setSerieDescription($series, $v["legend"]);
     }
     /*
     $graph->xgrid->SetColor($this->xgridcolor);
     $graph->ygrid->SetColor($this->ygridcolor);
     */
     /*
     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($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 "oo<BR>";
     //echo "<PRE>";
     //var_dump($graphData);
     //echo $this->width."<BR>";
     //echo $this->height_actual."<BR>";
     $graphImage = new pImage($this->width_actual, $this->height_actual, $graphData);
     /* Turn of Antialiasing */
     $graphImage->Antialias = TRUE;
     // Add gradient fill from chosen background color to white
     $startgradient = $this->htmltorgb("#ffffff");
     $color = $this->htmltorgb($this->graphcolor);
     $graphImage->drawGradientArea(0, 0, $this->width_actual, $this->height_actual, 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, $this->width_actual - 1, $this->height_actual - 1, array("R" => 200, "G" => 200, "B" => 200));
     /* Set the title font and draw it */
     $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->titlefont, "FontSize" => $this->titlefontsize));
     $this->titlecolor = $this->htmltorgb($this->titlecolor);
     $graphImage->drawText(20, 30, $this->title_actual, array("R" => $this->titlecolor[0], "G" => $this->titlecolor[1], "B" => $this->titlecolor[2]));
     /* Set the default font from the X title font */
     $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->xtitlefont, "FontSize" => $this->xtitlefontsize));
     /* Define the chart area */
     $graphImage->setGraphArea($this->marginleft, $this->margintop, $this->width_actual - $this->marginright, $this->height_actual - $this->marginbottom);
     //$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"LabelRotation"=>30);
     //$graphImage->drawScale($scaleSettings);
     //$settings = array("Surrounding"=>-30,"InnerSurrounding"=>30);
     //$graphImage->drawBarChart($settings);
     //$graphImage->autoOutput("pictures/example.drawBarChart.simple.png");
     //return;
     // Before plotting a series ensure they are all not drawable.
     /// Plot the chart data
     $stackeddrawn = false;
     $stackedexists = false;
     $barexists = false;
     foreach ($this->plot as $k => $v) {
         if ($v["type"] == "STACKEDBAR") {
             $stackedexists = true;
         }
         if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
             $barexists = true;
         }
     }
     /* Draw the scale */
     $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 30);
     // For stacked charts fix up the Max and Min values;
     if ($stackedexists) {
         $scaleMin = "Unknown";
         $scaleMax = 0;
         foreach ($this->plot as $k => $v) {
             if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                 $series = $v["name"] . $k;
                 $min = $graphData->getMin($series);
                 if ($scaleMin == "Unknown" || $min < $scaleMin) {
                     $scaleMin = $min;
                 }
                 $scaleMax = $scaleMax + $graphData->getMax($series);
             }
         }
         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));
         $scaleSettings["Mode"] = SCALE_MODE_MANUAL;
         $scaleSettings["ManualScale"] = $AxisBoundaries;
     } else {
         if ($barexists) {
             $scaleMin = "Unknown";
             $scaleMax = 0;
             foreach ($this->plot as $k => $v) {
                 if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
                     $series = $v["name"] . $k;
                     $min = $graphData->getMin($series);
                     if ($scaleMin == "Unknown" || $min < $scaleMin) {
                         $scaleMin = $min;
                     }
                     $max = $graphData->getMax($series);
                     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));
             $scaleSettings["Mode"] = SCALE_MODE_MANUAL;
             $scaleSettings["ManualScale"] = $AxisBoundaries;
         }
     }
     $graphImage->drawScale($scaleSettings);
     // If there's a Pie chart we want to draw different legends
     $piechart = false;
     foreach ($this->plot as $k => $v) {
         foreach ($this->plot as $k1 => $v1) {
             $series = $v1["name"] . $k1;
             $graphData->setSerieDrawable($series, FALSE);
         }
         $series = $v["name"] . $k;
         $graphData->setSerieDrawable($series, TRUE);
         switch ($v["type"]) {
             case "PIE":
                 $piechart = true;
                 $pie = new pPie($graphImage, $graphData);
                 //$pie->draw2DPie($width_actual / 2,$height_actual / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE));
                 $pie->draw2DPie($width_actual / 2, $height_actual / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255));
                 break;
             case "PIE3D":
                 $piechart = true;
                 $pie = new pPie($graphImage, $graphData);
                 $pie->draw3DPie($this->width_actual / 2, $this->height_actual / 2, 80, array("SecondPass" => FALSE));
                 break;
             case "STACKEDBAR":
             case "BAR":
                 if ($stackeddrawn) {
                     break;
                 }
                 if ($barexists) {
                     foreach ($this->plot as $k1 => $v1) {
                         if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR") {
                             $graphData->setSerieDrawable($v1["name"] . $k1, TRUE);
                         }
                     }
                 }
                 $stackeddrawn = true;
                 $settings = array("Surrounding" => -30, "InnerSurrounding" => 30);
                 if ($stackedexists) {
                     $graphImage->drawStackedBarChart($settings);
                 } else {
                     $graphImage->drawBarChart($settings);
                 }
                 break;
             case "LINE":
             default:
                 if (count($v["data"]) == 1) {
                     $v["data"][] = 0;
                 }
                 $graphImage->drawLineChart($settings);
                 break;
         }
     }
     $graphData->drawAll();
     if ($piechart) {
         $pie->drawPieLegend($this->width_actual - 100, 30, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
     } else {
         $graphImage->drawLegend($this->width_actual - 180, 22, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL));
     }
     $graphImage->setShadow(TRUE, array("X" => 0, "Y" => 0, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
     $graphImage->render($outputfile);
     return true;
 }
$myPicture->setGraphArea(48, 17, 680, 190);
/* Draw a rectangle */
$myPicture->drawFilledRectangle(53, 22, 675, 185, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
/* Draw the scale */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$ScaleSettings = array("XMargin" => 5, "YMargin" => 5, "Floating" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
$myPicture->drawScale($ScaleSettings);
/* Define the visual thresholds */
$Threshold = "";
$Threshold[] = array("Min" => -100, "Max" => -35, "R" => 117, "G" => 140, "B" => 240, "Alpha" => 40);
$Threshold[] = array("Min" => -35, "Max" => 35, "R" => 240, "G" => 232, "B" => 20, "Alpha" => 60);
$Threshold[] = array("Min" => 35, "Max" => 100, "R" => 240, "G" => 121, "B" => 20, "Alpha" => 80);
/* Draw the spline chart */
$myPicture->drawFilledSplineChart(array("Threshold" => $Threshold));
/* Write the chart boundaries */
$BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
$myPicture->writeBounds(BOUND_BOTH, $BoundsSettings);
/* Write the 0 line */
$myPicture->drawThreshold(0, array("WriteCaption" => TRUE));
/* Write the chart legend */
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
$myPicture->drawLegend(620, 217, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Write the 1st data series statistics */
$Settings = array("R" => 188, "G" => 224, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
$myPicture->drawText(10, 222, "Max : " . ceil($MyData->getMax("Probe 1")), $Settings);
$myPicture->drawText(60, 222, "Min : " . ceil($MyData->getMin("Probe 1")), $Settings);
$myPicture->drawText(110, 222, "Avg : " . ceil($MyData->getSerieAverage("Probe 1")), $Settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
예제 #4
0
 public static function tests_pchart3()
 {
     /* @ 700x230 Filled spline chart drawing example. */
     /* pChart library inclusions */
     include 'lib/pChart/class/pData.class';
     include 'lib/pChart/class/pDraw.class';
     include 'lib/pChart/class/pImage.class';
     /* Create and populate the pData object */
     $MyData = new pData();
     $MyData->setAxisName(0, "Strength");
     for ($i = 0; $i <= 720; $i = $i + 20) {
         $MyData->addPoints(cos(deg2rad($i)) * 100, "Probe 1");
         $MyData->addPoints(cos(deg2rad($i + 90)) * 60, "Probe 2");
     }
     /* Create the pChart object */
     $myPicture = new pImage(847, 304, $MyData);
     $myPicture->drawGradientArea(0, 0, 847, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 17, "EndG" => 17, "EndB" => 17, "Alpha" => 100));
     $myPicture->drawGradientArea(0, 250, 847, 304, DIRECTION_VERTICAL, array("StartR" => 47, "StartG" => 47, "StartB" => 47, "EndR" => 27, "EndG" => 27, "EndB" => 27, "Alpha" => 100));
     $myPicture->drawLine(0, 249, 847, 249, array("R" => 0, "G" => 0, "B" => 0));
     $myPicture->drawLine(0, 250, 847, 250, array("R" => 70, "G" => 70, "B" => 70));
     /* Add a border to the picture */
     $myPicture->drawRectangle(0, 0, 846, 303, array("R" => 204, "G" => 204, "B" => 204));
     /* Write the picture title */
     $myPicture->setFontProperties(array("FontName" => CINTIENT_INSTALL_DIR . "lib/pChart/fonts/pf_arma_five.ttf", "FontSize" => 6));
     $myPicture->drawText(423, 14, "Cyclic magnetic field strength", array("R" => 255, "G" => 255, "B" => 255, "Align" => TEXT_ALIGN_MIDDLEMIDDLE));
     /* Define the chart area */
     $myPicture->setGraphArea(58, 27, 816, 228);
     /* Draw a rectangle */
     $myPicture->drawFilledRectangle(58, 27, 816, 228, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0));
     /* Turn on shadow computing */
     $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20));
     /* Draw the scale */
     $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
     $ScaleSettings = array("XMargin" => 4, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE);
     $myPicture->drawScale($ScaleSettings);
     /* Draw the spline chart */
     $myPicture->drawFilledSplineChart();
     /* Write the chart boundaries */
     $BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237);
     $myPicture->writeBounds(BOUND_BOTH, $BoundsSettings);
     /* Write the 0 line */
     $myPicture->drawThreshold(0, array("WriteCaption" => TRUE));
     /* Write the chart legend */
     $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255));
     $myPicture->drawLegend(560, 266, array("Style" => LEGEND_NOBORDER));
     /* Write the 1st data series statistics */
     $Settings = array("R" => 188, "G" => 224, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
     $myPicture->drawText(620, 270, "Max : " . ceil($MyData->getMax("Probe 1")), $Settings);
     $myPicture->drawText(680, 270, "Min : " . ceil($MyData->getMin("Probe 1")), $Settings);
     $myPicture->drawText(740, 270, "Avg : " . ceil($MyData->getSerieAverage("Probe 1")), $Settings);
     /* Write the 2nd data series statistics */
     $Settings = array("R" => 224, "G" => 100, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT);
     $myPicture->drawText(620, 283, "Max : " . ceil($MyData->getMax("Probe 2")), $Settings);
     $myPicture->drawText(680, 283, "Min : " . ceil($MyData->getMin("Probe 2")), $Settings);
     $myPicture->drawText(740, 283, "Avg : " . ceil($MyData->getSerieAverage("Probe 2")), $Settings);
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
 }
예제 #5
0
////////////////////////////////////////////////////////////////
// Standard Deviation Values
//
/* get Standard Deviation Temperature Value */
$temp = $MyData->getStandardDeviation("Temperature");
/* Format SD to 3 decimal places */
$T_StandardDeviation = number_format($temp, 1);
/* get Standard Deviation Humidity Value */
$temp = $MyData->getStandardDeviation("Humidity");
/* Format SD to 1 decimal places */
$H_StandardDeviation = number_format($temp, 1);
////////////////////////////////////////////////////////////////
// Minimum Values
//
/* Get minimum Temperature value */
$temp = $MyData->getMin("Temperature");
/* Get minimum Temperature value */
$T_Minimum = number_format($temp, 1);
/* Get minimum Humidity value */
$temp = $MyData->getMin("Humidity");
/* Format Min to 1 decimal place */
$H_Minimum = number_format($temp, 1);
////////////////////////////////////////////////////////////////
// Plotting Line Colours
//
/* Set Temperature Line Colour */
$MyData->setPalette("Temperature", array("R" => 0, "G" => 0, "B" => 255));
/* Set Humidity Line Colour */
$MyData->setPalette("Humidity", array("R" => 255, "G" => 0, "B" => 0));
////////////////////////////////////////////////////////////////
// Prepare and create Graph
        $stackedexists = true;
    }
    if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") {
        $barexists = true;
    }
}
/* Draw the scale */
$scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 30);
// For stacked charts fix up the Max and Min values;
if ($stackedexists) {
    $scaleMin = "Unknown";
    $scaleMax = 0;
    foreach ($plot as $k => $v) {
        if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") {
            $series = $v["name"] . $k;
            $min = $graphData->getMin($series);
            if ($scaleMin == "Unknown" || $min < $scaleMin) {
                $scaleMin = $min;
            }
            $scaleMax = $scaleMax + $graphData->getMax($series);
        }
    }
    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);
    }