/* CAT:Stacked chart */
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(4, VOID, VOID, 12, 8, 3), "Frontend #1");
$MyData->addPoints(array(3, 12, 15, 8, 5, 5), "Frontend #2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Frontend #3");
$MyData->setAxisName(0, "Average Usage");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15));
/* Write a label */
$myPicture->writeLabel(array("Frontend #1", "Frontend #2", "Frontend #3"), 1, array("DrawVerticalLine" => TRUE));
/* Write the chart legend */
$myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.shaded.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;
 }
Example #3
0
 }
 $arrDisplayValues = array("DisplayValues" => FALSE);
 if ($plot == 2) {
     $arrDisplayValues["DisplayValues"] = TRUE;
 }
 /* Enable shadow computing */
 $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
 /* Draw the stacked area chart */
 if ($chartType == 'area2') {
     $myPicture->drawStackedAreaChart();
 } else {
     if ($chartType == 'bar') {
         $myPicture->drawBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15) + $arrDisplayValues);
     } else {
         if ($chartType == 'bar2') {
             $myPicture->drawStackedBarChart();
         } else {
             $myPicture->drawLineChart();
             if ($plot > 0) {
                 $myPicture->drawPlotChart($arrDisplayValues + array("PlotSize" => $weight * 1.5 + 3, "PlotBorder" => TRUE, "BorderSize" => 0.8, "BorderAlpha" => 75, "Surrounding" => -30));
             }
         }
     }
 }
 // 隐藏主坐标轴数据,画副坐标轴数据
 if (isset($arrSeriesY2)) {
     foreach ($arrSeries as $serie) {
         if (in_array($serie, $arrSeriesY2)) {
             $myData->setSerieDrawable($serie, TRUE);
         } else {
             $myData->setSerieDrawable($serie, FALSE);
$MyData->addPoints(array(19, 0, -8, 8, -8, 12, -19, -10, 5, 12, -20, -8, 10, -11, -12, 8, -17, -14, 0), "Probe 4");
$MyData->setAxisName(0, "Temperatures");
$MyData->addPoints(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Time");
$MyData->setSerieDescription("Time", "Hour of the day");
$MyData->setAbscissa("Time");
$MyData->setXAxisUnit("h");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale */
$myPicture->setGraphArea(60, 30, 650, 190);
$myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Mode" => SCALE_MODE_ADDALL));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw some thresholds */
$myPicture->setShadow(FALSE);
$myPicture->drawThreshold(-40, array("WriteCaption" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Ticks" => 4));
$myPicture->drawThreshold(28, array("WriteCaption" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Ticks" => 4));
/* Draw the chart */
$myPicture->drawStackedBarChart(array("Rounded" => TRUE, "DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "DisplaySize" => 6, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255));
/* Write the chart legend */
$myPicture->drawLegend(570, 212, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.rounded.png");
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawStackedBarChart() - draw a stacked bar chart", array("R" => 255, "G" => 255, "B" => 255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(250, 55, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawStackedBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Rounded" => TRUE, "Surrounding" => 60));
$myPicture->setShadow(FALSE);
/* Draw the scale and the 2nd chart */
$myPicture->setGraphArea(500, 60, 670, 190);
$myPicture->drawFilledRectangle(500, 60, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL, "DrawSubTicks" => TRUE));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawStackedBarChart();
$myPicture->setShadow(FALSE);
/* Write the chart legend */
$myPicture->drawLegend(510, 205, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.png");
Example #6
0
    public static function tests_pchart2()
    {
        /*
            $xmlStr = <<<EOT
        <testsuites>
        <testsuite2 name="whaever">
          <testsuite name="DatabaseTest" file="/Users/pfonseca/Dev/cintient/src/tests/DatabaseTest.php" tests="23" assertions="79" failures="0" errors="0" time="0.129403">
            <testsuite name="DatabaseTest::testExecuteNoParamsBinding" tests="5" assertions="15" failures="0" errors="0" time="0.028787">
              <testcase name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
              <testcase name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
              <testcase name="testExecuteNoParamsBinding with data set #2" assertions="3" time="0.004264"/>
              <testcase name="testExecuteNoParamsBinding with data set #3" assertions="3" time="0.004306"/>
              <testcase name="testExecuteNoParamsBinding with data set #4" assertions="3" time="0.004747"/>
            </testsuite>
            <testsuite name="DatabaseTest::testQueryNoParamsBinding" tests="1" assertions="3" failures="0" errors="0" time="0.004441">
              <testcase name="testQueryNoParamsBinding with data set #0" assertions="3" time="0.004441"/>
            </testsuite>
            <testsuite name="DatabaseTest::testQueryParamsBinding" tests="1" assertions="3" failures="0" errors="0" time="0.004417">
              <testcase name="testQueryParamsBinding with data set #0" assertions="3" time="0.004417"/>
            </testsuite>
            <testsuite name="DatabaseTest::testQueryParamsBindingExcessValues" tests="1" assertions="3" failures="0" errors="0" time="0.005673">
              <testcase name="testQueryParamsBindingExcessValues with data set #0" assertions="3" time="0.005673"/>
            </testsuite>
          </testsuite>
        </testsuite2>
        </testsuites>
        EOT;
        */
        $xmlStr = <<<EOT
<aa>
  <aa1>
    <aa2 name="DatabaseTest" file="/Users/pfonseca/Dev/cintient/src/tests/DatabaseTest.php" tests="23" assertions="79" failures="0" errors="0" time="0.129403">
      <aa3 name="DatabaseTest::testExecuteNoParamsBinding" tests="5" assertions="15" failures="3" errors="0" time="0.028787">
        <aa41 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
        <aa42 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa43 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa44 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa45 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa46 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
      </aa3>
      <aa4 name="DatabaseTest::testExecuteParamsBinding" tests="5" assertions="12" failures="1" errors="0" time="0.010916">
        <aa41 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
        <aa42 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa43 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa44 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
      </aa4>
      <aa5 name="DatabaseTest::testQuery" tests="5" assertions="4" failures="0" errors="0" time="0.004554">
        <aa51 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
        <aa52 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa53 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
        <aa54 name="testExecuteNoParamsBinding with data set #1" assertions="3" time="0.004554"/>
      </aa5>
      <aa6 name="DatabaseTest::testInsert" tests="5" assertions="7" failures="6" errors="0" time="0.014587">
        <aa61 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa6>
      <aa7 name="DatabaseTest::testBeginTransaction" tests="5" assertions="25" failures="4" errors="0" time="0.023787">
        <aa71 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa7>
      <aa6 name="DatabaseTest::testInsert" tests="5" assertions="7" failures="6" errors="0" time="0.014587">
        <aa61 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa6>
      <aa7 name="DatabaseTest::testBeginTransaction" tests="5" assertions="25" failures="4" errors="0" time="0.023787">
        <aa71 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </aa7>
    </aa2>
    <ab2 name="DatabaseTest" file="/Users/pfonseca/Dev/cintient/src/tests/DatabaseTest.php" tests="23" assertions="79" failures="0" errors="0" time="0.129403">
      <ab6 name="DatabaseTest::testInsert" tests="5" assertions="7" failures="6" errors="0" time="0.018787">
        <ab61 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </ab6>
      <ab7 name="DatabaseTest::testBeginTransaction" tests="5" assertions="25" failures="4" errors="0" time="0.028787">
        <ab71 name="testExecuteNoParamsBinding with data set #0" assertions="3" time="0.010916"/>
      </ab7>
    </ab2>
  </aa1>
</aa>
EOT;
        //
        // Access file testsuites directly (last level before testcases).
        // This can't be a closure because of its recursiveness.
        //
        function f($node)
        {
            if (isset($node->attributes()->file)) {
                return $node;
            } else {
                return f($node->children());
            }
        }
        $xml = new SimpleXMLElement($xmlStr);
        $classes = array();
        $xmls = $xml->children();
        /*
            foreach ($xmls as $node) {
              $getRootNode = f($node);
              $classXml = f($node);
              $class = new TestClass();
              $class->setName($classXml->getName());
              $class->setFile((string)$classXml->attributes()->file);
              $class->setTests((string)$classXml->attributes()->tests);
              $class->setAssertions((string)$classXml->attributes()->assertions);
              $class->setFailures((string)$classXml->attributes()->failures);
              $class->setErrors((string)$classXml->attributes()->errors);
              $class->setTime((string)$classXml->attributes()->time);
        
              $methods = array();
              foreach ($classXml->children() as $methodXml) {
                $method = new TestMethod();
                $method->setName($methodXml->getName());
                $method->setTests((string)$methodXml->attributes()->tests);
                $method->setAssertions((string)$methodXml->attributes()->assertions);
                $method->setFailures((string)$methodXml->attributes()->failures);
                $method->setErrors((string)$methodXml->attributes()->errors);
                $method->setTime((string)$methodXml->attributes()->time);
        
                $cases = array();
                foreach ($methodXml->children() as $caseXml) {
                  $case = new TestCase();
                  $case->setName((string)$caseXml->getName());
                  $case->setAssertions((string)$caseXml->attributes()->assertions);
                  $case->setTime((string)$caseXml->attributes()->time);
                  $cases[] = $case;
                }
                $method->setTestCases($cases);
                $methods[] = $method;
              }
              $class->setTestMethods($methods);
              $classes[] = $class;
            }*/
        foreach ($xmls as $node) {
            $assertions = 0;
            // total number of "test" points
            $successes = array();
            // assertions - failures
            $failures = array();
            $testMethods = array();
            $classXml = f($node);
            $class = new TestClass();
            $class->setName($classXml->getName());
            $class->setFile((string) $classXml->attributes()->file);
            $class->setTests((string) $classXml->attributes()->tests);
            $class->setAssertions((string) $classXml->attributes()->assertions);
            $class->setFailures((string) $classXml->attributes()->failures);
            $class->setErrors((string) $classXml->attributes()->errors);
            $class->setTime((string) $classXml->attributes()->time);
            $methods = array();
            $i = 0;
            foreach ($classXml->children() as $methodXml) {
                $method = new TestMethod();
                $method->setName($methodXml->getName());
                $method->setTests((string) $methodXml->attributes()->tests);
                $method->setAssertions((string) $methodXml->attributes()->assertions);
                $method->setFailures((string) $methodXml->attributes()->failures);
                $method->setErrors((string) $methodXml->attributes()->errors);
                $method->setTime((string) $methodXml->attributes()->time);
                /*
                $cases = array();
                foreach ($methodXml->children() as $caseXml) {
                  $case = new TestCase();
                  $case->setName((string)$caseXml->getName());
                  $case->setAssertions((string)$caseXml->attributes()->assertions);
                  $case->setTime((string)$caseXml->attributes()->time);
                  $cases[] = $case;
                }
                $method->setTestCases($cases);
                */
                $methods[] = $method;
                $time = (double) $methodXml->attributes()->time * 1000;
                // to milliseconds
                $testMethods[] = $methodXml->attributes()->name;
                $f = (double) $methodXml->attributes()->failures * $time / (double) $methodXml->attributes()->assertions;
                $successes[] = (double) $time - (double) $f;
                $failures[] = $f;
                $i++;
            }
            $chartWidth = 700;
            if ($i == 1) {
                $i++;
            }
            $chartHeight = 25 * $i + 60;
            /* pChart library inclusions */
            include 'lib/pChart/class/pData.class';
            include 'lib/pChart/class/pDraw.class';
            include 'lib/pChart/class/pImage.class';
            $MyData = new pData();
            $MyData->addPoints($successes, "Ok");
            $MyData->addPoints($failures, "Fail");
            $MyData->setPalette("Ok", array("R" => 124, "G" => 196, "B" => 0, "Alpha" => 100));
            $MyData->setPalette("Fail", array("R" => 254, "G" => 15, "B" => 0, "Alpha" => 100));
            $MyData->setAxisName(0, "Time (ms)");
            //$MyData->setAxisUnit(0,"ms");
            $MyData->addPoints($testMethods, " ");
            $MyData->setAbscissa(" ");
            /* Create the pChart object */
            //
            // ~40px for each test
            //
            $myPicture = new pImage($chartWidth, $chartHeight, $MyData);
            $myPicture->Antialias = false;
            $myPicture->drawGradientArea(0, 0, $chartWidth, $chartHeight, DIRECTION_VERTICAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
            /* Write the picture title */
            $myPicture->setFontProperties(array("FontName" => CINTIENT_INSTALL_DIR . "lib/pChart/fonts/pf_arma_five.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255));
            $myPicture->drawText(10, 13, "Unit tests on " . $classXml->getName(), array("R" => 255, "G" => 255, "B" => 255));
            /* Draw the scale and the chart */
            $myPicture->setGraphArea(240, 40, 640, $chartHeight - 20);
            $myPicture->drawFilledRectangle(240, 40, 640, $chartHeight - 20, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -100, "Alpha" => 10));
            $myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL, "DrawSubTicks" => true, "MinDivHeight" => 20, 'GridTicks' => 2, 'DrawXLines' => true, 'DrawYLines' => ALL));
            $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
            $myPicture->drawStackedBarChart(array("Interleave" => 2, "Gradient" => false));
            $myPicture->drawLegend(15, $chartHeight - 15, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
            $myPicture->setShadow(FALSE);
            /* Write the chart legend */
            //$myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
            /* Render the picture (choose the best way) */
            $myPicture->autoOutput("pictures/example.drawStackedBarChart.png");
            $class->setTestMethods($methods);
            $classes[] = $class;
        }
        //
        // We're exactly at the test class (file) root level, with level 1 being
        // the unit test (method of the original class) and level 2 being
        // the various datasets used in the test (each a test case).
        //
        /* @ 700x230 Stacked bar chart drawing example. */
        exit;
    }
Example #7
0
$myPicture->drawScale($Settings);
$Config = array("DisplayValues" => 0, "AroundZero" => 0, "BreakVoid" => 1, "RecordImageMap" => FALSE);
$GraphType = 'SplineChart';
switch ($GraphType) {
    case 'AreaChart':
        $myPicture->drawAreaChart($Config);
        break;
    case 'FilledSplineChart':
        $myPicture->drawFilledSplineChart($Config);
        break;
    case 'SplineChart':
        $myPicture->drawSplineChart($Config);
        break;
    case 'BarChart':
        $myPicture->drawBarChart($Config, 'tetimes');
        break;
    case 'StackedBarChart':
        $myPicture->drawStackedBarChart($Config);
        break;
    case 'PlotChart':
        $myPicture->drawPlotChart($Config);
        break;
    default:
        break;
}
$Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 8, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL);
$myPicture->drawLegend($Graphwidth - 65, 40, $Config);
$myPicture->setFontProperties(array("FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 10));
$TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 0, "G" => 0, "B" => 0);
$myPicture->drawText(200, 15, $GraphLabel, $TextSettings);
$myPicture->render(__DIR__ . '/temp/' . $Type . '_' . $SensorID . '.png');
$string = fgets($handler);
$myArray = explode(',', $string);
$i = 0;
while ($string = fgets($handler)) {
    $myArray = explode(',', $string);
    $components[$i] = $myArray[0];
    ++$i;
}
$MyData = new pData();
$MyData->importFromCSV("foundit.csv", array("GotHeader" => TRUE, "SkipColumns" => array(0)));
$MyData->setAxisName(0, "Bug Count");
$MyData->setAxisName(1, "Components");
$MyData->addPoints($components, "Components");
$MyData->setAbscissa("Components");
//$MyData->setSerieOnAxis("Component",1);
//$MyData->setAxisXY(1,AXIS_X);
/* Create the pChart object */
$myPicture = new pImage(3000, 700, $MyData);
$myPicture->drawGradientArea(0, 0, 3000, 700, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 3000, 700, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 3000, 680);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("Interleave" => 0.5, "Surrounding" => -15, "InnerSurrounding" => 15));
/* Write the chart legend */
$myPicture->drawLegend(800, 10, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->Render("foundit.png");
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(20, 40, 65, 100, 70, 55, 40, 22, 12), "Male");
$MyData->addPoints(array(-22, -44, -61, -123, -74, -60, -52, -34, -21), "Female");
$MyData->setAxisName(0, "Community members");
$MyData->addPoints(array("0-10", "10-20", "20-30", "30-40", "40-50", "50-60", "60-70", "70-80", "80-90"), "Labels");
$MyData->setSerieDescription("Labels", "Ages");
$MyData->setAbscissa("Labels");
$MyData->setAxisDisplay(0, AXIS_FORMAT_CUSTOM, "YAxisFormat");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL));
$myPicture->setShadow(FALSE);
$myPicture->drawStackedBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Gradient" => TRUE, "Surrounding" => -20, "InnerSurrounding" => 20));
/* Write the chart legend */
$myPicture->drawLegend(600, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.pyramid.png");
function YAxisFormat($Value)
{
    return abs($Value);
}
/* pChart library inclusions */
include "../class/pData.class.php";
include "../class/pDraw.class.php";
include "../class/pImage.class.php";
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(-4, VOID, VOID, 12, 8, 3), "Frontend #1");
$MyData->addPoints(array(3, 12, 15, 8, 5, -5), "Frontend #2");
$MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Frontend #3");
$MyData->setAxisName(0, "Average Usage");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Normalize all the data series to 100% */
$MyData->normalize(100, "%");
/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20));
/* Set the default font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
/* Draw the scale and the chart */
$myPicture->setGraphArea(60, 20, 680, 190);
$myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$myPicture->drawStackedBarChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Gradient" => TRUE, "GradientMode" => GRADIENT_EFFECT_CAN, "Surrounding" => 30));
$myPicture->setShadow(FALSE);
/* Write the chart legend */
$myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawStackedBarChart.can.png");
    $myPicture->dumpImageMap("ImageMapStackedBarChart", IMAGE_MAP_STORAGE_FILE, "StackedBarChart", "../tmp");
}
/* Set the image map name */
$myPicture->initialiseImageMap("ImageMapStackedBarChart", IMAGE_MAP_STORAGE_FILE, "StackedBarChart", "../tmp");
/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Set the default font */
$myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6));
/* Define the chart area */
$myPicture->setGraphArea(60, 40, 650, 200);
/* Draw the scale */
$scaleSettings = array("Mode" => SCALE_MODE_ADDALL, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE);
$myPicture->drawScale($scaleSettings);
/* Write the chart legend */
$myPicture->drawLegend(580, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Turn on shadow computing */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
/* Draw the chart */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
$Settings = array("RecordImageMap" => TRUE);
$myPicture->drawStackedBarChart($Settings);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("../tmp/StackedBarChart.png");
        case "STACKEDBAR":
        case "BAR":
            if ($stackeddrawn) {
                break;
            }
            if ($barexists) {
                foreach ($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) {