Login Register Wishes Forum About
Sample scripts » Combo charts
Help topics
Latest updates
2028d  replaceImageMapTitle
2028d  replaceImageMapValues
2028d  createFunctionSerie
2028d  setAbsicssaPosition
2028d  negateValues
  Download as PDF
  Print this page
  Share this page
  Create an account
  Feed the updates!
Google AdSense
Combo charts

You may want to display your data series with different kind of charts using the same scale. This kind of data representation are called combo charts. To create one with pChart follow the following steps :

Create all your datasets.
Draw the chart scale.
Draw the chart legend.
Hide the series desired.
Draw your 1st chart.
Hide the series desired.
Draw your 2nd chart.

Using the setSerieDrawable() function you can easily activate / deactivate data series processing by all charting and drawing functions. You can re-use this scheme to draw as many different charts you want.

Keep in mind that you can‘t mix charts that need different scaling methods. If you need to do it, you‘ll have to force the scaling option that will create the biggest min / max range. (Usually SCALE_MODE_ADDALL )

Sample script

/* pChart library inclusions */

 /* Create the pData object with some random values*/
 $MyData = new pData(); 
 $MyData->addPoints(array(30,24,32),"This year");
 $MyData->addPoints(array(28,20,27),"Last year");

 /* Create the pChart object */
 $myPicture = new pImage(700,230,$MyData);

 /* Create a solid background */
 $Settings = array("R"=>179, "G"=>217, "B"=>91, "Dash"=>1, "DashR"=>199, "DashG"=>237, "DashB"=>111);

 /* Do a gradient overlay */
 $Settings = array("StartR"=>194, "StartG"=>231, "StartB"=>44, "EndR"=>43, "EndG"=>107, "EndB"=>58, "Alpha"=>50);

 /* Add a border to the picture */
 /* Write the picture title */ 
 $myPicture->drawText(10,13,"Chart title",array("R"=>255,"G"=>255,"B"=>255));

 /* Draw the scale */

 /* Graph title */
 $myPicture->drawText(50,52,"Chart subtitle",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMLEFT));

 /* Draw the bar chart chart */
 $MyData->setSerieDrawable("Last year",FALSE);

 /* Draw the line and plot chart */
 $MyData->setSerieDrawable("Last year",TRUE);
 $MyData->setSerieDrawable("This year",FALSE);

 /* Make sure all series are drawable before writing the scale */
 $MyData->setSerieDrawable("This year",TRUE);

 /* Write the legend */

 /* Render the picture (choose the best way) */
Last updated on 01/08/2011 
by Jean-Damien 
Linked resources
  There is no linked topic yet.
Community comments
  No comments have been posted yet.
© 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. 409 users have registered. This page has been rendered in 0,01 seconds. Wiki revision 1.37.