PHP Classes
elePHPant
Icontem

Power Graphic: Generate graphic charts of several types from data

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum (15)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2004-12-12 (12 years ago) RSS 2.0 feedStarStarStarStar 74%Total: 6,318 This week: 1All time: 327 This week: 597Down
Version License Categories
powergraphic 1.0.0Freely DistributableGraphics
Description Author

PowerGraphic is a class meant for generating graphic charts of several types from a data set of values to be represented in the chart.

The chart data set is passed as an array of values representing the chart labels the respective chart value.

Currently it can generate charts of the types: vertical bars, horizontal bars, dots, lines, pie and donut.

The presentation details of the chart may be specified as of of several available skins that specify pre-defined presentation styles.

Multiple charts can be combined in one chart output image. The resulting image is outputted as a true color image in the PNG format.

Recommendations

Draw graphs using PHP
How to draw graphs using PHP?

Name: Carlos Reche <contact>
Classes: 10 packages by
Country: Brazil Brazil
Innovation award
Innovation award
Nominee: 2x

Details

   PowerGraphic
   version 1.0



 Author: Carlos Reche
 E-mail: carlosreche@yahoo.com
 Sorocaba, SP - Brazil

 Created: Sep 20, 2004
 Last Modification: Sep 20, 2004



  Authors' comments:

  PowerGraphic creates 6 different types of graphics with how many parameters you want. You can
  change the appearance of the graphics in 3 different skins, and you can still cross data from 2 
  graphics in only 1! It's a powerful script, and I recommend you read all the instructions 
  to learn how to use all of this features. Don't worry, it's very simple to use it.

  This script is free. Please keep the credits.








   INSTRUNCTIONS OF HOW TO USE THIS SCRIPT  (Please, take a minute to read it. It's important!)


   NOTE: make sure that your PHP is compiled to work with GD Lib.

   NOTE: You may create test images using a form that comes with this script. Just add a "showform" 
   as a query string. (Example: "graphic.php?showform")


   PowerGraphic works with query strings (information sent after the "?" of an URL). Here is an 
   example of how you will have to send the graphic information. Let's suppose that you want to 
   show a graphic of your user's sex:

       <img src="graphic.php?title=Sex&type=5&x1=male&y1=50&x2=female&y2=55" />

   This will create a pie graphic (set by type=5) with title as "Sex" and default skin. 
   Let's see the other parameters:

       x1 = male
       y1 = 50 (quantity of males)
       x2 = female
       y2 = 55 (quantity of females)

   See how it's simple! :)
   For those who don't know, to create a query string you have to put an "?" at the end of the URL and join
   the parameters with "&". Example: "graphic.php?Parameter_1=Value_1&Parameter_2=Value_2" (and so on). You 
   can set how many parameters you want.

   The boring step would be to create this query string. Well, "would be", if I didn't create a function to do that. :)
   Let's see an example of how you can use this function in a PHP document:


///// START OF EXAMPLE /////

<?php

require "class.graphics.php";
$PG = new PowerGraphic;

$PG->title = "Sex";
$PG->type  = "5";
$PG->x1    = "male";
$PG->y1    = "50";
$PG->x2    = "female";
$PG->y2    = "55";

echo '<img src="graphic.php?' . $PG->create_query_string() . '" />';


// If you're going to create more than 1 graphic, it'll be important to reset the values before 
// create the next query string:
$PG->reset_values();

?>

///// END OF EXAMPLE /////



   Here is a list of all parameters you may set:

   title      =>  Title of the graphic
   axis_x     =>  Name of values from Axis X
   axis_y     =>  Name of values from Axis Y
   graphic_1  =>  Name of Graphic_1 (only shown if you are gonna cross data from 2 different graphics)
   graphic_2  =>  Name of Graphic_2 (same comment from above)

   type  =>  Type of graphic (values 1 to 6)
                1 => Vertical bars (default)
                2 => Horizontal bars
                3 => Dots
                4 => Lines
                5 => Pie
                6 => Donut

   skin   => Skin of the graphic (values 1 to 3)
                1 => Office (default)
                2 => Matrix
                3 => Spring

   credits => Only if you want to show my credits in the image. :)
                0 => doesn't show (default)
                1 => shows

   x[0]  =>  Name of the first parameter in Axis X
   x[1]  =>  Name of the second parameter in Axis X
   ... (etc)

   y[0]  =>  Value from "graphic_1" relative for "x[0]"
   y[1]  =>  Value from "graphic_1" relative for "x[1]"
   ... (etc)

   z[0]  =>  Value from "graphic_2" relative for "x[0]"
   z[1]  =>  Value from "graphic_2" relative for "x[1]"
   ... (etc)


   NOTE: You can't cross data between graphics if you use "pie" or "donut" graphic. Values for "z"
   won't be considerated.



   That's all! Hope you make a good use of it!
   It would be nice to receive feedback from others users. All comments are welcome!

   Regards,

   Carlos Reche


  Files folder image Files  
File Role Description
Plain text file class.graphic.php Class Main file
Accessible without login Plain text file example.php Example Example of how to use the class
Accessible without login Plain text file readme.txt Doc. ReadMe! File

 Version Control Unique User Downloads Download Rankings  
 0%
Total:6,318
This week:1
All time:327
This week:597Down
User Ratings User Comments (6)
 All time
Utility:96%StarStarStarStarStar
Consistency:91%StarStarStarStarStar
Documentation:85%StarStarStarStarStar
Examples:92%StarStarStarStarStar
Tests:-
Videos:-
Overall:74%StarStarStarStar
Rank:132
 
Tnks
2 years ago (Raymundo Mendez)
60%StarStarStarStar
It's a very good base for your own startig.
6 years ago (RossiRat)
67%StarStarStarStar
GREAT!
7 years ago (Emiliano)
75%StarStarStarStar
Only drawback is that X axis has a fixed width.
8 years ago (Fabian Arocena)
80%StarStarStarStarStar
Just what i was looking for.
9 years ago (Chiyana Simões)
70%StarStarStarStar
i'm starting to use it and this is that i was searching.
9 years ago (Danilo Juvinao)
75%StarStarStarStar