[eluser]Unknown[/eluser]
do you wanna use pchart in your application?
Do you wanna no learn not complicated?
do you wanna a girlfriend?
well a girlfriend is harder to give it to you ;P
Notes: i have no ported the another libraries, just pdata,pimage and pdraw. Why? i don't kwow yet how to use pchart properly, i'm still learning.
1) download
http://www.megaupload.com/?d=MWMGA1GM
2) extract it in application/libraries
3)create a model
4) in the root folder, create a folder called images
well, he we are, you need to know 3 stuffs.
1º why is reference and how to use
2º how to work with libraries
3º that i'm god now.
yes, it will work if you don't use references but i think that is the right way.
let's go
create a function to acess in your browse
note: the function cannot be private or protected.
Code:
public function teste()
{
/* Create and populate the pData object */
$this->load->library("pdata");
// $MyData = new pData(); instead do it
$MyData =& $this->pdata; //this line passes pdata by reference to mydata variable
$MyData->addPoints(array(1, -2, -1, 2, 1, 0), "Probe 1");
$MyData->addPoints(array(1, -2, -3, 2, 1, 8), "Probe 2");
$MyData->addPoints(array(2, 4, 2, 0, 4, 2), "Probe 3");
$MyData->setSerieTicks("Probe 2", 4);
$MyData->setAxisName(0, "Temperatures");
$MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels");
$MyData->setSerieDescription("Labels", "Months");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$params = array("Xsize"=>700,"Ysize"=>230,"DataSet"=>$MyData);//this is the params of the constructor
$this->load->library("pimage",$params);
// $myPicture = new pImage(700, 230, $MyData);
$myPicture =& $this->pimage; //same way
/* Draw the background */
$Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190,
"DashG" => 203, "DashB" => 107);
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings);
/* Overlay with a gradient */
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1,
"EndG" => 138, "EndB" => 68, "Alpha" => 50);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings);
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" =>
0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50,
"Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "application/libraries/chart/fonts/Silkscreen.ttf",
"FontSize" => 6));
$myPicture->drawText(10, 13,
"drawStackedAreaChart() - draw a stacked area chart", array("R" => 255, "G" =>
255, "B" => 255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "application/libraries/chart/fonts/Forgotte.ttf",
"FontSize" => 11));
$myPicture->drawText(250, 55, "Average temperature", array("FontSize" => 20,
"Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and the 1st chart */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(60, 60, 450, 190, array("R" => 255, "G" => 255,
"B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("DrawSubTicks" => true, "Mode" => SCALE_MODE_ADDALL));
$myPicture->setFontProperties(array("FontName" => "application/libraries/chart/fonts/pf_arma_five.ttf",
"FontSize" => 6));
$myPicture->setShadow(false);
$myPicture->drawStackedAreaChart(array("DisplayValues" => true, "DisplayColor" =>
DISPLAY_AUTO, "Surrounding" => 20));
/* Draw the scale and the 2nd chart */
$myPicture->setGraphArea(500, 60, 670, 190);
$myPicture->drawFilledRectangle(500, 60, 670, 190, array("R" => 255, "G" => 255,
"B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "Mode" =>
SCALE_MODE_ADDALL, "DrawSubTicks" => true));
$myPicture->setShadow(false);
$myPicture->drawStackedAreaChart(array("Surrounding" => 10));
/* Write the chart legend */
$myPicture->drawLegend(510, 205, array("Style" => LEGEND_NOBORDER, "Mode" =>
LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("images/p.png");
echo "<img >config->item("base_url")."images/p.png' alt='teste' />";
}
be happy
paste this func in your controller then call in your brwoser.
any doubts send me an mensage.
final notes: be right that the path to the fonts is correct
All the credits to pchart, i just did a little things.
byebye