Open Menu dzosoft
Close Menu dzosoft
All About Computer Science and Technology

                twitter instagram facebook pinterest
search on the site

How to easily create charts using PHP used in particular by companies such as NASA, Sony or Airbus

How to easily create charts using PHP  used in particular by companies such as NASA, Sony or Airbus
How to create a chart in PHP and in a simple way? All you have to do is use the dedicated library to create graphics in PHP.
What amazed me with pChart is its simplicity of use, absolutely incredible, but the possibilities it opens up.
For example, I have used pChart in automated pages, these are created from a database by retrieving variables.



First download the various classes used in this example from 


/* I load the pChart libraries which is in the class folder so that it can display a graph*/

/*I create a new object containing my data for the chart */
 $myData = new pData();

/*I lay out my data series to use for the chart and I set the vertical axis title with set Axis Name*/  
 $myData->addPoints(array(500,400,200,55,450,360,200,10,75,550,150),"Probe 3");
 $myData->setSerieWeight("Probe 3",2);
 $myData->setAxisName(0,"Number of males");

/*I indicate the horizontal data of the graph. There must be the same number as for my previous data series (logic)*/
 $myData->setPalette("Probe 3",array("R"=>0,"G"=>0,"B"=>255));

/* I create the image that will contain my previously created graphic */
 $myPicture = new pImage(600,300,$myData);

/*I create a border in my image */

/* I indicate the title of my graphic, its positioning on the image and its font */ 
 $myPicture->drawText(200,25,"Evolution of the number of male births in my little village",array("FontSize"=>14,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));

/* I choose the background of my graph */

/* I determine the size of the graphic and its location in the image */

/* Parameters to draw the graph from the two abscissas */
 $scaleSettings = array("XMargin"=>10,"YMargin"=>10,"Floating"=>TRUE,"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);

/* I insert on the right side the name of the author and the rights */ 

/* I draw my graph according to the previous parameters*/

/* I add red dots (plots) by displaying over the data */

/* I indicate the path where I want my image to be created */

My graph will be created in the image folder under the name evolution-male-births.png and the result will be the following:
Here are several examples to show you results that can be created with pChart:
This library is available on , it is used in particular by companies such as NASA, Sony or Airbus
Leave comment

Save nickname and email in this browser for the next time.

All about computer science and technology