PChart is an open-source chart generation library, mainly involving three classes: pChart. class, pData. class, pCache. class, which can generate more than 20 simple or complex charts. It supports PNG, JPG, and GIF common image formats. The data source can be from Database, CSV, or hand-written. To use this PHP program, you need to enable the GD service. Let's take a look at the workflow of pChart:
There are three main steps:
- * Reading is used to generate chart data (databases and files)
- * Design chart styles (rounded corners, background colors, etc)
- * Create tags, questions, and legends and generate charts
Here is a simple bar chart:
The Code is as follows:
<? Php // Standard comprehensions include ("pChart/pData. class "); include (" pChart/pChart. class "); // Dataset definition $ DataSet = new pData; // chart data $ DataSet-> AddPoint (array, 4), "Serie1"); $ DataSet-> AddPoint (array (,-, 3), "Serie2 "); $ DataSet-> AddPoint (array (, 2,-1,-4,-,), "Serie3"); $ DataSet-> AddAllSeries (); $ DataSet-> SetAbsciseLabelSerie (); // data legend $ DataSet-> SetSerieName ("Microsoft", "Serie1"); $ DataSet-> SetSerieName ("IBM ", "Serie2"); $ DataSet-> SetSerieName ("Google", "Serie3"); // Initialise the graph $ Test = new pChart (700,230 ); // set the chart size and style $ Test-> setFontProperties ("Fonts/tahoma. ttf ", 8); $ Test-> setGraphArea (680,200, 693); $ Test-> drawFilledRoundedRectangle (,