|
|
Page 1 of 1
|
[ 8 posts ] |
|
Axes and values Label format
Author |
Message |
feschenhorn
New pChart user
Joined: Wed Sep 07, 2011 3:24 pm Posts: 3
|
Axes and values Label format
hi,
I want to create a "Age Pyramid" with the number of Male / female by ages range. I use the drawStackedBarChart method. For having a Female and a Male part, I used negative number for female and poisitive number of male. I want have only positive number for the label of axes and the lbale value in the graph. Is it possible to use the absolute values or a "picture" number format without the minus sign... Or is there a "Pyramid Graph" format in pChart.
Thank you for your help,
|
Wed Sep 07, 2011 3:32 pm |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: Axes and values Label format
Do you mean something like this?
Attachments:
example_drawStackedBarChart_pyramid.png [ 12.68 KiB | Viewed 13167 times ]
|
Wed Sep 07, 2011 3:51 pm |
|
|
feschenhorn
New pChart user
Joined: Wed Sep 07, 2011 3:24 pm Posts: 3
|
Re: Axes and values Label format
Yes, It's cool... Plus the label value in the bar...
How do you do this...
|
Thu Sep 08, 2011 6:23 am |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: Axes and values Label format
This code is using the AXIS_FORMAT_CUSTOM method that has been added in the 2.1.3 sub version. If you want it just drop me a private message with your email address and I'll send it to you. JD. Code: /* 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(20,40,65,100,70,55,40,22,12),"Male"); $MyData->addPoints(array(-22,-44,-61,-123,-74,-60,-52,-34,-21),"Female"); $MyData->setAxisName(0,"Community members"); $MyData->addPoints(array("0-10","10-20","20-30","30-40","40-50","50-60","60-70","70-80","80-90"),"Labels"); $MyData->setSerieDescription("Labels","Ages"); $MyData->setAbscissa("Labels"); $MyData->setAxisDisplay(0,AXIS_FORMAT_CUSTOM,"YAxisFormat");
/* 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("DrawSubTicks"=>TRUE,"Mode"=>SCALE_MODE_ADDALL)); $myPicture->setShadow(FALSE); $myPicture->drawStackedBarChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO,"Gradient"=>TRUE,"Surrounding"=>-20,"InnerSurrounding"=>20));
/* Write the chart legend */ $myPicture->drawLegend(600,210,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStackedBarChart.pyramid.png");
function YAxisFormat($Value) { return(abs($Value)); }
Attachments:
example_drawStackedBarChart_pyramidCAKRSQTI.png [ 14.8 KiB | Viewed 13158 times ]
example_drawStackedBarChart_pyramid.png [ 19 KiB | Viewed 13158 times ]
|
Thu Sep 08, 2011 7:05 am |
|
|
feschenhorn
New pChart user
Joined: Wed Sep 07, 2011 3:24 pm Posts: 3
|
Re: Axes and values Label format
Thank you, It's great... I will analyze your code... Very Happy to work with the pChart Library..
|
Thu Sep 08, 2011 10:56 am |
|
|
nighty
pChart user
Joined: Sat Sep 03, 2011 10:13 am Posts: 5
|
Re: Axes and values Label format
Just wanted to add a feature request to implement a label function, but as I see here you already implemented it. Great! Looking forward to the next subrelease.
|
Thu Sep 08, 2011 12:35 pm |
|
|
aszasz
New pChart user
Joined: Wed Aug 24, 2011 6:39 pm Posts: 1
|
Re: Axes and values Label format
How does one reverse the plotted age pyramid. There must be a simple answer to it, I just don't get it... Any help please...
Btw: Thanks for the library, I really love it...
|
Tue Oct 18, 2011 12:25 am |
|
|
ckng
pChart user
Joined: Mon Jan 30, 2012 2:23 pm Posts: 5
|
Re: Axes and values Label format
This should be added to the example
|
Wed Feb 01, 2012 2:57 pm |
|
|
|
Page 1 of 1
|
[ 8 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 6 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
|
|
|