View unanswered posts | View active topics It is currently Fri May 10, 2024 2:51 pm



Reply to topic  [ 1 post ] 
A few problems with my chart: HELP! 
Author Message
New pChart user
New pChart user

Joined: Tue Jul 26, 2011 10:38 am
Posts: 1
 A few problems with my chart: HELP!
Hello,
first of all: I really like pChart. It's a great projects! Thanks to all the wonderful people, who work on it! ;)

I started working with pChart two days ago, so I am still kind of a newbie. I worked through the forum and the documentation, but I still have some problems with my chart, that I can't seem to solve.

1. The descriptions of my Y-axisses read from top to bottom and just won't rotate. As far as I can see, the descriptions should rotate automatically? As least, this is what it looks like in the example codes. Or am I wrong?
2. I have two grids that kind of overlay eachother (because I have two charts with one Y-axis each). Is it possible to set both Y-axisses a fixed number of ticks, so that the grid would fit for both axisses?? If not, can I at least color the second grid a little different or even erase it, so that it would not look so strange and confusing anymore?
3. I know that there are several topics about my third problem, but there seem to be only workarounds so far. I want to have the X-axis as a time series. This time interval can be very short (like two days or something) or very long ( first day of 2007 until today). Long story short: I can't really say how many points are portrayed on the X-axis. So to use "LabelSkip" is not really a great option. I would need something like: portray up to 10 labels for the X-axis ticks and set those in equal intervals. Is there anything like that? Or are only workarounds possible, to determine an appropriate "LabelSkip" value at runtime?

I would be really greatful for an answer. Here is an example chart and the code.

Code:
public function drawPartnerGrossRevenuesChart( $aGrossRevenues, $aGrossRevenuesAcc, $aDates, $sGrouping ) {

      /* Create dataset object */
      $myData = new pData();

      /* Load palette */
      $myData->loadPalette( "../include/pChart/palettes/wwg.color", TRUE );

      /* Create pChart object and associate dataset */
      $myPicture = new pImage(950,500,$myData);

      /* Set font */
      $myPicture->setFontProperties(array("FontName"=>"../include/pChart/fonts/calibri.ttf","FontSize"=>11));

      /* Define the boundaries of the graph area */
      $myPicture->setGraphArea(60,60,850,420);
      $myPicture->drawFilledRectangle(0,0,948,498,array("R"=>165,"G"=>165,"B"=>165,"Surrounding"=>-165,"Alpha"=>50));

      /* Draw title */
      if ( $sGrouping == "per month" ) {
         $sTitle = 'Monthly gross revenues';
         $sLabel = 'Months';
      }
      else {
         $sTitle = 'Daily gross revenues';
         $sLabel = 'Days';
      }
      $myPicture->drawText(475,40,$sTitle,array("FontSize"=>16,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));

      /* bar chart settings */
      $myData->addPoints( $aGrossRevenues, 'Gross revenues' );
      $myData->setSerieOnAxis( "Gross revenues", 0 );
      $myData->setAxisName( 0, "Gross revenues in €" );
      $myData->setAxisDisplay( 0, AXIS_FORMAT_CURRENCY, '€' );

      /* line chart settings */
      $myData->addPoints( $aGrossRevenuesAcc, 'Accumulated gross revenues');
      $myData->setSerieWeight("Accumulated gross revenues",1);
      $myData->setSerieOnAxis("Accumulated gross revenues",1);
      $myData->setAxisPosition(1,AXIS_POSITION_RIGHT);
      $myData->setAxisName(1,"Accumulated gross revenues in €");
      $myData->setAxisDisplay( 1, AXIS_FORMAT_CURRENCY, '€' );

      /* abscissa settings */
      $myData->addPoints( $aDates, "Labels");
      $myData->setSerieDescription("Labels", $sLabel );
      $myData->setAbscissa("Labels");

      /* Draw the scale */
      $myPicture->drawScale( array( "GridR"=>110, "GridG"=>110, "GridB"=>112, "LabelSkip"=>5, "Mode"=>SCALE_MODE_START0 ) );      
            
      /* Draw bar chart first, without line chart serie */
      $myData->setSerieDrawable("Accumulated gross revenues",FALSE);
      $myPicture->drawBarChart();

      /* Draw bar chart, without line chart serie */
      $myData->setSerieDrawable("Gross revenues",FALSE);
      $myData->setSerieDrawable("Accumulated gross revenues",TRUE);
      $myPicture->drawLineChart();

      /* Write the legend, also for the line chart series */
      $myData->setSerieDrawable("Gross revenues",TRUE);

      $myPicture->drawLegend(630,480,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

      /* Build the PNG file and send it to the web browser */
      $myPicture->Render( Path::getPath('$app/www/_assets/charts/basic.png') );
   }



Cheerio,
Andrea


Attachments:
File comment: chart
basic.png
basic.png [ 29.95 KiB | Viewed 3956 times ]
Thu Jul 28, 2011 2:05 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 16 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: