![]() |
Language Reference » Charting functions » drawAreaChart
|
|
Latest updates
Toolbox
Google AdSense
|
drawAreaChart - Draw an area chart This function allows you to draw an area chart. All the drawing parameters are given trough a $Format array. To learn more about this please read the Format array guide. Calling this function
drawAreaChart($Format="");Where : Format is an array containing the drawing parameters of the chart. Customisation array - Tune up your chart! It is possible to customize the area chart rendering by playing with this array. Providing a detailled configuration is not mandatory. You can specify if the values must be written on the chart setting DisplayValues to TRUE or FALSE.
You can specify the text UP/RIGHT offset with DisplayOffset.
You can specify the labels color with DisplayR,DisplayG,DisplayB.
You can specify an override factor for the area transparency with ForceTransparency.
You can specify if the area are wrapped around the 0 line setting AroundZero to TRUE.
You can define thresholds using the Threshold array. Thresholds can be used to draw with different colors some part of your charts. Thresholds are defined through an array : $Threshold = ""; $Threshold[] = array("Min"=>0,"Max"=>5,"R"=>207,"G"=>240,"B"=>20,"Alpha"=>70); $Threshold[] = array("Min"=>5,"Max"=>10,"R"=>240,"G"=>232,"B"=>20,"Alpha"=>70); $Threshold[] = array("Min"=>10,"Max"=>20,"R"=>240,"G"=>191,"B"=>20,"Alpha"=>70); You can define if the labels color will be the same than the serie color of if you want to force it manually setting DisplayColor to : DISPLAY_MANUAL, color will be specified manually with DisplayR,DisplayG,DisplayB.
DISPLAY_AUTO, will use the serie color. Sample script ![]() /* Build a dataset */ $MyData = new pData(); $MyData->addPoints(array(-4,VOID,VOID,12,8,3),"Probe 1"); $MyData->addPoints(array(3,12,15,8,5,-5),"Probe 2"); $MyData->addPoints(array(2,7,5,18,19,22),"Probe 3"); $MyData->setSerieTicks("Probe 2",4); $MyData->setAxisName(0,"Temperatures"); $MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun"),"Labels"); $MyData->setSerieDescription("Labels","Months"); $MyData->setAbscissa("Labels"); /* Create 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)); $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->drawAreaChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO)); $myPicture->setShadow(FALSE); /* Create 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,"DrawSubTicks"=>TRUE)); $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); $myPicture->drawAreaChart(); $myPicture->setShadow(FALSE); /* Write the legend*/ $myPicture->drawLegend(510,205,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); Sample script #2 ![]() /* Create and populate the pData object */ $MyData = new pData(); for($i=0;$i<=30;$i++) { $MyData->addPoints(rand(1,15),"Probe 1"); } $MyData->setSerieTicks("Probe 2",4); $MyData->setAxisName(0,"Temperatures"); /* Create the pChart object */ $myPicture = new pImage(700,230,$MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Add a border to the picture */ $myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11)); $myPicture->drawText(150,35,"Average temperature",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6)); /* Define the chart area */ $myPicture->setGraphArea(60,40,650,200); /* Draw the scale */ $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200, "DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE); $myPicture->drawScale($scaleSettings); /* Write the chart legend */ $myPicture->drawLegend(600,20,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL)); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Enable shadow computing */ $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); /* Draw the area chart */ $Threshold = ""; $Threshold[] = array("Min"=>0,"Max"=>5,"R"=>207,"G"=>240,"B"=>20,"Alpha"=>70); $Threshold[] = array("Min"=>5,"Max"=>10,"R"=>240,"G"=>232,"B"=>20,"Alpha"=>70); $Threshold[] = array("Min"=>10,"Max"=>20,"R"=>240,"G"=>191,"B"=>20,"Alpha"=>70); $myPicture->drawAreaChart(array("Threshold"=>$Threshold)); /* Write the thresholds */ $myPicture->drawThreshold(5,array("WriteCaption"=>TRUE,"Caption"=>"Warn Zone","Alpha"=>70,"Ticks"=>2,"R"=>0,"G"=>0,"B"=>255)); $myPicture->drawThreshold(10,array("WriteCaption"=>TRUE,"Caption"=>"Error Zone","Alpha"=>70,"Ticks"=>2,"R"=>0,"G"=>0,"B"=>255)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawAreaChart.threshold.png");
© Copyrights
Components used on this web site : Famfamfam icons has been made by Mark James, Rounded corners lite has been coded by Cameron Cooke and Tim Hutchison, SyntaxHighlighter has
been written by Alex Gorbatchev. pChart and this web site have been created by Jean-Damien POGOLOTTI. This documentation contains 185 pages and 56 comments. 413 users have registered.
This page has been rendered in 0,02 seconds. Wiki revision 1.37.
|