![]() |
Language Reference » Charting functions » drawStackedAreaChart
|
|
Latest updates
Toolbox
Google AdSense
|
drawStackedAreaChart - Draw a stacked area chart This function allows you to draw a stacked 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
drawStackedAreaChart($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 stacked bar 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 labels color with DisplayR,DisplayG,DisplayB.
You can specify an unique border color with BorderR,BorderG,BorderB,.
You can use the Surrounding option to define the border color. This value will be added to the R,G,B factors to define the border color.
You can force the area transparency playing with ForceTransparency. 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 ![]() /* 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(1,-2,-1,2,1,0),"Probe 1"); $MyData->addPoints(array(1,-2,-3,2,1,8),"Probe 2"); $MyData->addPoints(array(2,4,2,0,4,2),"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 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); $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,"drawStackedAreaChart() - draw a stacked area 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->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6)); $myPicture->setShadow(FALSE); $myPicture->drawStackedAreaChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Surrounding"=>20)); /* 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(FALSE); $myPicture->drawStackedAreaChart(array("Surrounding"=>10)); /* 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.drawStackedAreaChart.png"); 2nd Sample script ![]() /* pChart library inclusions */ include("../class/pData.class.php"); include("../class/pDraw.class&.phpquot;); include("../class/pImage.class&.phpquot;); /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(4,0,0,12,8,3,0,12,8),"Frontend #1"); $MyData->addPoints(array(3,12,15,8,5,5,12,15,8),"Frontend #2"); $MyData->addPoints(array(2,7,5,18,19,22,7,5,18),"Frontend #3"); $MyData->setAxisName(0,"Average Usage"); $MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun","Jui","Aug","Sep"),"Labels"); $MyData->setSerieDescription("Labels","Months"); $MyData->setAbscissa("Labels"); /* Normalize 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("XMargin"=>2,"DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL)); $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10)); $myPicture->drawStackedAreaChart(array("Surrounding"=>60)); $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.drawStackedAreaChart.normalized.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. 415 users have registered.
This page has been rendered in 0,01 seconds. Wiki revision 1.37.
|