JPGRAPH is a very convenient job of various charts in the PHP world, such as bar charts, pie charts, and radar charts. it is basically omnipotent to all charts. In PEAR, there is also a chart-making tool named image_graph. This tool is also very powerful, but jpgraph and image_graph are the biggest advantages in comparison, there are many examples and details. "> <LINKhref =" htt
JPGRAPH is a very convenient job of various charts in the PHP world, such as bar charts, pie charts, and radar charts. it is basically omnipotent to all charts.
In PEAR, there is also a chart-making tool named image_graph. This tool is also very powerful, but jpgraph and image_graph are the biggest advantages in comparison, there are many examples and very detailed documentation, which makes jpgraph quite convenient to use.
Finally, we decided to use jpgraph.
Below is a piece of code. At the same time, I encountered Chinese character garbled characters during usage. the reason has been found and I would like to explain it to you.
If you encounter any problems when using jpgraph, you can MAIL it to me. At the same time, if you have any usage experience, I hope you can send it to LAMPER for more people to share your experience.
-
- Include ("../jpgraph. php ");
- Include ("../jpgraph_line.php ");
- $ Ydata = array );
- $ Y2data = array (354,200,265, 99,111, 91,198,225,293,251 );
- $ Datax = array ("2006-01-01", "2006-01-01", "2006-01-01", "2006-01-01", "2006-01-01", "2006-01-01", "2006-01-01", "2006-01-01 ", "2006-01-01", "2006-01-01 ");
- // Create the graph. These two cballs are always required
- $ Graph = new Graph (800,400, "auto ");
- $ Graph-> img-> SetMargin (40, 40, 20, 40 );
- $ Graph-> title-> SetFont (FF_SIMSUN, FS_BOLD );
- $ Title = "display pv/Display ip ";
- $ Graph-> title-> Set ($ title );
- $ Graph-> SetScale ("textlin ");
- $ Graph-> SetY2Scale ("lin ");
- $ Graph-> xaxis-> title-> Set ("Time ");
- $ Graph-> xaxis-> title-> SetFont (FF_SIMSUN, FS_BOLD );
- $ Graph-> xaxis-> SetTickLabels ($ datax );
- $ Graph-> yaxis-> title-> Set ("display pv ");
- $ Graph-> yaxis-> SetColor ("blue ");
- $ Graph-> yaxis-> title-> SetFont (FF_SIMSUN, FS_BOLD );
- $ Graph-> y2axis-> title-> Set ("Show IP ");
- $ Graph-> y2axis-> SetColor ("orange ");
- $ Graph-> y2axis-> title-> SetFont (FF_SIMSUN, FS_BOLD );
- $ Lineplot = new LinePlot ($ ydata );
- $ Lineplot-> SetColor ("blue ");
- $ Lineplot-> SetWeight (2 );
- $ Lineplot-> SetLegend ("display pv ");
- $ Graph-> legend-> SetFont (FF_SIMSUN, FS_BOLD );
- $ Lineplot2 = new LinePlot ($ y2data );
- $ Lineplot2-> SetColor ("orange ");
- $ Lineplot2-> SetWeight (2 );
- $ Lineplot2-> SetLegend ("Show ip ");
- $ Graph-> Add ($ lineplot );
- $ Graph-> AddY2 ($ lineplot2 );
- // Display the graph
- $ Graph-> Stroke ();
- ?>
Note the SetFont method. if your file is encoded as gb2312, the first parameter of the SetFont method is FF_SIMSUN.
If your file is UTF-8 encoded, add $ title = iconv ("UTF-8", "gb2312", $ title)
In jpgraph. php, there is such a statement:
Elseif ($ aFF === FF_SIMSUN ){
// Do Chinese conversion
If ($ this-> g2312 = null ){
Include_once 'jpgraph _ gb2312.php ';
$ This-> g2312 = new GB2312toUTF8 ();
}
Return $ this-> g2312-> gb2utf8 ($ aTxt );
}
That is to say, when jpgraph displays Chinese characters by default, it regards the Chinese character encoding as gb2312 and converts it to UTF-8 before display.
In this case, if your file encoding is gb2312, the first parameter of the SetFont method is FF_SIMSUN.
If you are UTF-8 encoded, you must first convert the Chinese character encoding to gb2312 so that your Chinese characters can be properly displayed.