温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

PHP如何生成折线图和饼图

发布时间:2020-07-16 15:40:50 来源:亿速云 阅读:631 作者:Leah 栏目:编程语言

这篇文章运用简单易懂的例子给大家介绍PHP如何生成折线图和饼图,代码非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

生成折线图

include("pChart/pData.class");  
include("pChart/pChart.class");  
// Dataset definition
$DataSet = new pData;
$DataSet->AddPoint(array(100,320,200,10,43),"Serie1");
$DataSet->AddPoint(array(20190726,20190727,20190728,20190729,20190730),"Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
// Initialise the graph   
$Test = new pChart(700,230);
$Test->setFontProperties("Fonts/tahoma.ttf",8);
$Test->setGraphArea(85,30,650,200);
$Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
$Test->drawRoundedRectangle(5,5,695,225,5,230,230,230);
$Test->drawGraphArea(255,255,255,TRUE);
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,0,2);
$Test->drawGrid(4,TRUE,230,230,230,50);
$Test->setFontProperties("Fonts/tahoma.ttf",6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
$Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255);
//生成图表
$imageFile = "1.png";
$Test->Render($imageFile);
echo '<img src="'.$imageFile.'">';

PHP如何生成折线图和饼图

生成饼图

<?php
 /*
     Example13: A 2D exploded pie graph
 */
 // Standard inclusions   
 include("pChart/pData.class");
 include("pChart/pChart.class");
 // Dataset definition 
 $DataSet = new pData;
 $DataSet->AddPoint(array(100,320,200,10,43,417),"Serie1");
 $DataSet->AddPoint(array("20190726","20190727","20190728","20190729","20190730","20190731"),"Serie2");
 $DataSet->AddAllSeries();
 $DataSet->SetAbsciseLabelSerie("Serie2");
 // Initialise the graph
 $Test = new pChart(500,200);
 $Test->setFontProperties("Fonts/tahoma.ttf",8);
 $Test->drawFilledRoundedRectangle(7,7,293,193,5,240,240,240);
 $Test->drawRoundedRectangle(5,5,295,195,5,230,230,230);
 // Draw the pie chart
 $Test->AntialiasQuality = 0;
 $Test->setShadowProperties(2,2,200,200,200);
 $Test->drawFlatPieGraphWithShadow($DataSet->GetData(),$DataSet->GetDataDescription(),120,100,60,PIE_PERCENTAGE,8);
 $Test->clearShadow();
 $Test->drawPieLegend(230,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);
 $imageFile = 'example12.png';
 $Test->Render($imageFile);
echo '<img src="'.$imageFile.'">';
?>

PHP如何生成折线图和饼图

关于PHP如何生成折线图和饼图就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

php
AI