Again, short post. This php code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<?php session_start(); require_once "/srv/www/lib/pChart/class/pDraw.class.php"; require_once "/srv/www/lib/pChart/class/pImage.class.php"; require_once "/srv/www/lib/pChart/class/pData.class.php"; $squareSeries = array(); $cubeSeries = array(); $fourthSeries = array(); for ($i = 0; $i <= 4; $i++){ $squareSeries[$i] = pow($i,2); $cubeSeries[$i] = pow($i,3); $fourthSeries[$i] = pow($i, 4); } $myPowersData = new pData(); $myPowersData -> addPoints($squareSeries,"Square"); $myPowersData -> addPoints($cubeSeries,"Cube"); $myPowersData -> addPoints($fourthSeries,"Fourth"); $myPowersData-> setPalette("Square", array("R" => 240, "G" => 16, "B" => 16, "Alpha" => 100)); $myPowersData-> setPalette("Cube", array("R" => 16, "G" => 240, "B" => 16, "Alpha" => 100)); $myPowersData-> setPalette("Forth", array("R" => 16, "G" => 16, "B" => 240, "Alpha" => 100)); $myPowersImage = new pImage(500,300, $myPowersData); $myPowersImage -> setFontProperties(array( "FontName" => "/srv/www/lib/pChart/fonts/verdana.ttf", "FontSize" => 12)); $myPowersImage->setGraphArea(40,40, 460,260); $myPowersImage->drawScale(); $myPowersImage->drawLineChart(); header("Content-Type: image/png"); $myPowersImage->Render(null); |
I learned this using this resource:
http://phpmaster.com/charting-with-pchart/