$myPicture->drawRectangle(0, 0, 846, 303, array("R" => 204, "G" => 204, "B" => 204));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../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);
Example #2
0
function PlotLine($rowX, $rowY, $name, $ch)
{
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pData.class.php";
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pDraw.class.php";
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pImage.class.php";
    include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pPie.class.php";
    //**************************************
    $myData = new pData();
    $myData->addPoints($rowX, "Serie1");
    $myData->setSerieDescription("Serie1", $name);
    //$myData->setSerieOnAxis("Serie1",0);
    $myData->addPoints($rowY, "Absissa");
    $myData->setAbscissa("Absissa");
    //$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa");
    //$myData->setAbscissa("Absissa");
    $myData->setAxisPosition(0, AXIS_POSITION_LEFT);
    //$myData->setAxisName(0,"1st axis");
    $myData->setAxisUnit(0, "");
    $myPicture = new pImage(700, 230, $myData);
    $Settings = array("R" => 240, "G" => 242, "B" => 241, "Dash" => 1, "DashR" => 260, "DashG" => 262, "DashB" => 261);
    $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
    $Settings = array("StartR" => 252, "StartG" => 255, "StartB" => 254, "EndR" => 252, "EndG" => 255, "EndB" => 254, "Alpha" => 50);
    $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
    $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
    $myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14));
    $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 252, "G" => 252, "B" => 252, "DrawBox" => 1, "BoxAlpha" => 30);
    //$myPicture->drawText(350,25,$name,$TextSettings);
    $myPicture->setShadow(FALSE);
    $myPicture->setGraphArea(50, 50, 675, 190);
    //$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
    $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL);
    $myPicture->drawScale($Settings);
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
    $Config = "";
    if ($ch == 1) {
        $myPicture->drawSplineChart($Config);
    }
    if ($ch == 2) {
        $myPicture->drawBarChart($Config);
    }
    if ($ch == 3) {
        $myPicture->drawLineChart($Config);
    }
    if ($ch == 4) {
        $myPicture->drawPlotChart($Config);
    }
    if ($ch == 5) {
        $myPicture->drawStepChart($Config);
    }
    if ($ch == 6) {
        $myPicture->drawAreaChart($Config);
    }
    if ($ch == 7) {
        $myPicture->drawFilledSplineChart($Config);
    }
    if ($ch == 8) {
        $myPicture->drawFilledStepChart($Config);
    }
    if ($ch == 9) {
        $myPicture->drawStackedAreaChart($Config);
    }
    $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL);
    $myPicture->drawLegend(563, 16, $Config);
    $myPicture->stroke();
}
$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");
Example #4
0
$myPicture->drawRectangle(0, 0, $Graphwidth - 1, $Graphheigth - 1, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setShadow(FALSE);
$myPicture->setGraphArea(50, 30, $Graphwidth - 70, $Graphheigth - 40);
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20));
$myPicture->setFontProperties(array("FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 8));
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10));
$Settings = array("Mode" => SCALE_MODE_FLOATING, "DrawSubTicks" => TRUE, "DrawArrows" => TRUE, "ArrowSize" => 6, "Pos" => SCALE_POS_LEFTRIGHT, "LabelSkip" => 0, "SkippedInnerTickWidth" => 10, "LabelingMethod" => LABELING_ALL, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 20, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 20, "LabelRotation" => 90, "DrawXLines" => 1, "DrawSubTicks" => 0, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 20, "DrawYLines" => ALL);
$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;
Example #5
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");
 }
Example #6
0
function diskGraph($queryInfo, $uid = 0, $label) {

	global $db, $MyData, $query, $info, $myCache;

	calculatePoints($query, $queryInfo, 'diskused', "Disk Used", "%");

	$MyData->loadPalette("pchart/palettes/openstatus.color", TRUE);
	$MyData->setSerieDescription("Labels","Time");
	$MyData->setAbscissa("Labels");
	$MyData->setXAxisDisplay(AXIS_FORMAT_TIME, $queryInfo[3]);
	$MyData->setAxisName(0, "");

	$myPicture = new pImage(700,230,$MyData);
	$ChartHash = $myCache->getHash($MyData);

	if ($myCache->isInCache($ChartHash)) {
		$myCache->strokeFromCache($ChartHash);
	} else {

		$myPicture->Antialias = TRUE;
		$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));
		$myPicture->setFontProperties(array("FontName"=>"pchart/fonts/calibri.ttf","FontSize"=>11));
		$myPicture->drawText(350,35, $label." - ".$queryInfo[1],array("FontSize"=>14,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
		$myPicture->drawText(350,15,"Server: ".$info['hostname'], array("FontSize"=>14, "Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
		$myPicture->setFontProperties(array("FontName"=>"pchart/fonts/calibri.ttf","FontSize"=>8));
		$myPicture->setGraphArea(60,40,650,200);

		$AxisBoundaries = array(0=>array("Min"=>0,"Max"=>100));
		$scaleSettings = array(
			"XMargin"=>10,
			"YMargin"=>10,
			"Floating"=>TRUE,
			"CycleBackground"=>FALSE,
			"LabelSkip"=>$queryInfo[2],
			"Mode"=>SCALE_MODE_MANUAL,
			"ManualScale"=>$AxisBoundaries,
			"DrawSubTicks"=>TRUE,
			"SkippedTickAlpha"=>0,
			"SubTickR"=>0,
			"SubTickG"=>0,
			"SubTickB"=>0
		);

		$myPicture->drawScale($scaleSettings);
		$myPicture->drawFilledSplineChart();
		$myCache->writeToCache($ChartHash,$myPicture);

	}
	$myPicture->autoOutput("cache/".$info['uid']."/diskused-".$queryInfo[4].".png");

}