1

我需要一个简单的 php 库来绘制图表,但是一个直接从 php 呈现并在不使用 javascript 或 flash 的情况下在网络服务器上生成 jpg(或 png)文件的库。我尝试了 pChart,它很好,但它使用 javascript 进行渲染,所以对我来说没用。此外,我不想使用任何类型的 API,它将与某些服务或服务器进行通信。我需要它全部由php绘制。

4

1 回答 1

0

这是您的解决方案:http ://wiki.pchart.net/

例子:

<?php
 include("../class/pDraw.class.php"); 
 include("../class/pImage.class.php"); 
 include("../class/pData.class.php");

 /* Create your dataset object */ 
 $myData = new pData(); 
 
 /* Add data in your dataset */ 
 $myData->addPoints(array(1,3,4,3,5));

 /* Create a pChart object and associate your dataset */ 
 $myPicture = new pImage(700,230,$myData);

 /* Choose a nice font */
 $myPicture->setFontProperties(array("FontName"=>"../fonts/Forgotte.ttf","FontSize"=>11));

 /* Define the boundaries of the graph area */
 $myPicture->setGraphArea(60,40,670,190);

 /* Draw the scale, keep everything automatic */ 
 $myPicture->drawScale();

 /* Draw the scale, keep everything automatic */ 
 $myPicture->drawSplineChart();

 /* Render the picture (choose the best way) */
 $myPicture->autoOutput("pictures/example.basic.png");
?>

于 2016-10-11T13:56:56.510 回答