Open Menu dzosoft
Close Menu dzosoft



Dazzle with your smile!

Publish perfectly-optimized content in 1-click


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*/ include("class/pData.class.php"); include("class/pDraw.class.php"); include("class/pImage.class.php"); include("class/pPie.class.php"); include("class/pIndicator.class.php");
/*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->addPoints(array("2013","2014","2015","2016","2017","2018","2019","2020","2021","2022","2023"),"Labels"); $myData->setSerieDescription("Labels","Years"); $myData->setAbscissa("Labels"); $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 */ $myPicture->drawRectangle(2,2,599,299,array("R"=>0,"G"=>0,"B"=>255));
/* I indicate the title of my graphic, its positioning on the image and its font */ $myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>11)); $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 */ $myPicture->setFontProperties(array("FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6));
/* I determine the size of the graphic and its location in the image */ $myPicture->setGraphArea(60,40,550,280);
/* 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); $myPicture->drawScale($scaleSettings);
/* 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 */ $myPicture->autoOutput("images/evolution-male-births.png");

Here are several examples to show you results that can be created with pChart: Examples

This library is available on , it is used in particular by companies such as NASA, Sony or Airbus

It might also interest you

The 5 best tutorials for learning php in 2023

How to create a chat application with PHP and HTML in just few steps

How to install XAMPP (with Apache, MySQL & phpMyAdmin) on Windows

How to easily send an email with PHPMailer in PHP

How to make login with OTP Authentication in PHP

How to use ChatGPT with PHP

Leave comment

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

close publicity
Publish perfectly-optimized content in 1-click