$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);
/* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(2, 7, 5, 18, VOID, 12, 10, 15, 8, 5, 6, 9), "Help Desk"); $MyData->setAxisName(0, "Incidents"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jui", "Aou", "Sep", "Oct", "Nov", "Dec"), "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" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 20)); $myPicture->drawGradientArea(0, 0, 60, 230, DIRECTION_HORIZONTAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Do some cosmetics */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawLine(60, 0, 60, 230, array("R" => 70, "G" => 70, "B" => 70)); $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(35, 115, "Recorded cases", array("R" => 255, "G" => 255, "B" => 255, "FontSize" => 20, "Angle" => 90, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Draw a spline chart */ $myPicture->setGraphArea(100, 30, 680, 190); $myPicture->drawFilledRectangle(100, 30, 680, 190, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 20)); $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->drawScale(array("AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE)); $myPicture->drawSplineChart(); /* Write the data bounds */ $myPicture->writeBounds(); $myPicture->setShadow(FALSE); /* Write the chart legend */ $myPicture->drawLegend(630, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.writeBounds.png");
$myData->setSerieDrawable($serie, FALSE); } } $myPicture->drawLineChart(); if ($plot == 1) { $myPicture->drawPlotChart(array("DisplayValues" => FALSE, "PlotSize" => $weight * 1.5 + 3, "PlotBorder" => TRUE, "BorderSize" => 0.8, "BorderAlpha" => 75, "Surrounding" => -30)); } if ($plot == 2) { $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "PlotSize" => $weight * 1.5 + 3, "PlotBorder" => TRUE, "BorderSize" => 0.8, "BorderAlpha" => 75, "Surrounding" => -30)); } } $myData->drawAll(); /* Write the data bounds */ $boundSetting = array("DrawBox" => FALSE, "MaxLabelTxt" => 'Max:', "MinLabelTxt" => 'Min:', "MinDisplayR" => 0, "MinDisplayG" => 0, "MinDisplayB" => 0, "DisplayOffset" => 5); if ($bound == 'min') { $myPicture->writeBounds(BOUND_MIN, $boundSetting); } if ($bound == 'max') { $myPicture->writeBounds(BOUND_MAX, $boundSetting); } if ($bound == 'both') { $myPicture->writeBounds(BOUND_BOTH, $boundSetting); } } } /* Render the picture (choose the best way) */ if ($resultType == 'charttable') { $myPicture->Render("pictures/chart_png_{$id}.png"); echo '<html>'; echo '<head>'; echo '<meta http-equiv="content-type" content="text/html; charset=utf-8" />';
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"); }