|
|
Page 1 of 1
|
[ 5 posts ] |
|
Author |
Message |
yoh
pChart user
Joined: Wed Jan 05, 2011 4:48 pm Posts: 4 Location: France
|
Radar charts
Hi, I'm currently using pChart 2.0.10 and have a little bug when creating radar chart : As you can see, segments labels (1,2,3...) are a bit out of the line. I tried to solve it myself... Help! Here is my code : Code: $etiquettes = array('1','2','3','4'); // $etiquettes2 = array('1','2','3','4','5');
$valeurs = array('Serie 1', array(1,2,1,2)); // $valeurs2 = array('Serie 1', array(1,2,1,2,1));
$titre = 'Titre';
$MyData = new pData();
$MyData->addPoints($valeurs[1],"Serie1"); $MyData->setSerieDescription("Serie1",$valeurs[0]); // $MyData->addPoints($valeurs2[1],"Serie1"); // $MyData->setSerieDescription("Serie1",$valeurs2[0]);
/* Définition des noms de branches */ $MyData->addPoints($etiquettes,"Labels"); // $MyData->addPoints($etiquettes2,"Labels"); $MyData->setAbscissa("Labels");
/* Création de l'objet pChart */ $myPicture = new pImage(400,350,$MyData); $RectangleSettings = array("R"=>180,"G"=>180,"B"=>180,"Alpha"=>100);
/* Titre du graph */ $myPicture->setFontProperties(array("FontName"=>"./pChart2/fonts/verdana.ttf","FontSize"=>10)); $myPicture->drawText(195,20,$titre,array("R"=>100,"G"=>100,"B"=>100,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE)); $myPicture->drawRoundedRectangle(5,5,395,40,5,array("R"=>100,"G"=>100,"B"=>100));
/* Définition de la police par défaut */ $myPicture->setFontProperties(array("FontName"=>"./pChart2/fonts/verdana.ttf","FontSize"=>9,"R"=>80,"G"=>80,"B"=>80));
/* Création de l'objet pRadar */ $SplitChart = new pRadar();
/* Dessin du graph radar */ $myPicture->setGraphArea(10,50,390,310); $Options = array("SegmentHeight"=>1,"Segments"=>5,"DrawPoly"=>true,"DrawPoints"=>false,"Layout"=>RADAR_LAYOUT_STAR,"LabelsBGR"=>240,"LabelsBGG"=>240,"LabelsBGB"=>240,"LabelPos"=>RADAR_LABELS_HORIZONTAL,"BackgroundGradient"=>array("StartR"=>255,"StartG"=>255,"StartB"=>255,"StartAlpha"=>100,"EndR"=>235,"EndG"=>235,"EndB"=>235,"EndAlpha"=>20)); $SplitChart->drawRadar($myPicture,$MyData,$Options);
/* Sortie du graph (fichier) */ $myPicture->Render('radar.png'); If you have a solution... Thanks
_________________ Sorry for my english
|
Wed Jan 05, 2011 5:34 pm |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: Radar charts
Thanks for posting this bug! This issue only popup with RADAR_LAYOUT_STAR radar charts. To correct it, replace the code section that is writting the axis labels located after Code: $Options["FontSize"] = $AxisFontSize;
by : Code: $Angle = 360 / ($Points*2); for($j=1;$j<=$Segments;$j++) { $Label = $j * $SegmentHeight;
if ( $Layout == RADAR_LAYOUT_CIRCLE ) { $EdgeX1 = cos(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; $EdgeY1 = sin(deg2rad($Angle+$AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; } elseif ( $Layout == RADAR_LAYOUT_STAR ) { $EdgeX1 = cos(deg2rad($AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; $EdgeY1 = sin(deg2rad($AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY; $EdgeX2 = cos(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterX; $EdgeY2 = sin(deg2rad((360 / $Points) + $AxisRotation)) * ($EdgeHeight/$Segments)*$j + $CenterY;
$EdgeX1 = ($EdgeX2 - $EdgeX1)/2 + $EdgeX1; $EdgeY1 = ($EdgeY2 - $EdgeY1)/2 + $EdgeY1; }
$Object->drawText($EdgeX1,$EdgeY1,$Label,$Options); }
I'll apply this fix in the 2.0.11. Kind regards, JD.
|
Thu Jan 06, 2011 8:53 am |
|
|
yoh
pChart user
Joined: Wed Jan 05, 2011 4:48 pm Posts: 4 Location: France
|
Re: Radar charts
It works perfectly ! Thanks
_________________ Sorry for my english
|
Thu Jan 06, 2011 9:21 am |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: Radar charts
Thank you for having noticed it ;o)
|
Thu Jan 06, 2011 9:35 am |
|
|
jean-damien
Site Admin
Joined: Thu Dec 02, 2010 2:31 pm Posts: 409 Location: France
|
Re: Radar charts
I've posted the new 2.0.11 subversion on the pChart web site correcting this bug. You can get it here : http://www.pchart.net/download
|
Fri Jan 07, 2011 3:57 pm |
|
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 8 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
|
|
|