pChart 2.x forum
http://wiki.pchart.net/forum/

Problems with a bar graph
http://wiki.pchart.net/forum/viewtopic.php?f=1&t=39804
Page 1 of 1

Author:  Rhum974 [ Mon Jun 03, 2013 6:57 am ]
Post subject:  Problems with a bar graph

Hello, I have a problem with my graph. Here is my problem: my bars start from the point of the horizontal axes at I'd like the middle of the bar is on the point of abscissa. Another thing, my bars are all the same color but my legend shows well 4 different colors. Could someone help me please?
Here is my code :
Code:
// Récupération des variables de l'URL
$dept = explode('|', $_GET["dept"]);
$poids = explode('|', $_GET["poids"]);
$CA = explode('|', $_GET["CA"]);
$obj = explode('|',$_GET["obj"]);
$prctg = explode('|', $_GET["prctg"]);

// Définition des variables de dessin
$largeur = 800;
$hauteur = 300;
$DataSet = new pData;
$DataSet->AddPoint($dept, "serie1");
$DataSet->AddPoint($prctg, "serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("serie1");
    for($nbr=0;$nbr<count($dept); $nbr++)
    {
$DataSet->SetSerieName($prctg[$nbr], $nbr));
    }

// Init du graph
$Bar = new pChart($largeur, $hauteur);
$Bar->setFontProperties("Config/pChart/Fonts/tahoma.ttf", 8);
$Bar->setGraphArea(40, 30, $largeur-100, $hauteur-30);
$Bar->drawFilledRoundedRectangle(7, 7, $largeur-14, $hauteur-7, 5, 225, 220, 200);
$Bar->drawRoundedRectangle(20, 20, $largeur-10, $hauteur-50, 50, 225, 220, 200);
$Bar->drawGraphArea(255, 255, 255, TRUE);
$Bar->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 0, 0, 0, TRUE, 0, 20, TRUE);
$Bar->drawGrid(4, TRUE, 225, 220, 200, 100);

// Dessin de l'axe des abscisses
$Bar->setFontProperties("Config/pChart/Fonts/tahoma.ttf", 6);
$Bar->drawTreshold(0, 143, 55, 72, TRUE, TRUE);

// Dessin du graph
$Bar->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);

// Fin du graph
$Bar->setFontProperties("Config/pChart/Fonts/tahoma.ttf", 8);
$Bar->drawLegend(610, 150, $DataSet->GetDataDescription(), 255, 255, 255);
$Bar->setFontProperties("Config/pChart/Fonts/tahoma.ttf", 10);
$Bar->drawTitle(50, 22, "Pourcentage sur objectif", 50, 50 ,50, 585);
$Bar->Render("prctg.png");
?>

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/