View unanswered posts | View active topics It is currently Sun Apr 28, 2024 8:06 pm



Reply to topic  [ 1 post ] 
[SOLVED] threshold on bar chart 
Author Message
New pChart user
New pChart user

Joined: Tue Nov 15, 2011 10:47 pm
Posts: 1
Post [SOLVED] threshold on bar chart
It seems one can not add a threshold on a barchart.
Consider the following code:
Code:
/* Create and populate the pData object */
$MyData = new pData();
$MyData->addPoints(array(0.6,0.4),"frequences");
$MyData->setAxisName(0,"Fréquences");

/* Define the absissa serie */
$MyData->addPoints(array("service 1", "service 2")),"services");
$MyData->setSerieDescription("services","Services");
$MyData->setAbscissa("services");

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

/* Add a border to the picture */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

/* Set the default font */
$myPicture->setFontProperties(array("FontName"=>"lib/pChart/fonts/verdana.ttf","FontSize"=>6));

/* Define the chart area */
$myPicture->setGraphArea(60,40,650,200);

/* Draw the scale */
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"Mode"=>SCALE_MODE_START0);
$myPicture->drawScale($scaleSettings);

/* Draw the chart */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$settings = array("Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayPos"=>LABEL_POS_INSIDE,"DisplayValues"=>TRUE,"DisplayR"=>255,"DisplayG"=>255,"DisplayB"=>255,"DisplayShadow"=>TRUE,"Surrounding"=>10);
$myPicture->drawBarChart();

$myPicture->drawThreshold(0.5,array("WriteCaption"=>true,"Caption"=>"Objectif","R"=>255,"G"=>0,"B"=>0));


the threshold is only drawn between the 2 bars (it would be drawn on a single point if the graph would have a single bar).

In order to have the threshold drawn correctly, You have to force margins in scale settings (it seems when there are no margins, getAbscissaMargin is not accurate)
Code:
/* Draw the scale */
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"Mode"=>SCALE_MODE_START0,"XMargin"=>5,"YMargin"=>5);
$myPicture->drawScale($scaleSettings);


but when used this way, the bars are totally wrong

(both images are attached)

Is there a way to have a threshold on a bar chart?

Sorry, I later found the "NoMargin" option for threshold, that seems to be designed for the need i expressed :-)


Attachments:
File comment: image with "XMargin"=>5,"YMargin"=>5
pChart4ec2a349092cd.png
pChart4ec2a349092cd.png [ 8.99 KiB | Viewed 4005 times ]
File comment: image without "XMargin"=>5,"YMargin"=>5
pChart4ec2aafb23224.png
pChart4ec2aafb23224.png [ 7.44 KiB | Viewed 4005 times ]
Tue Nov 15, 2011 11:03 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 39 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:  
cron