php制作折线统计图,PHP生成折线图和饼图等 - pChart

58e8d81c4a0d115f2a9f9f245fa77d87.png

... $MyData->setAbscissa("Labels"); 在PHP里使用了pchart,但是标签不显示中文,或显示中文乱码,怎么解决? 回复讨论(解决方案) pchart 是基于 GD 的,而 GD 只能绘制 utf-8 编码的汉字 请...

pchart类库下载(地址:http://pchart.sourceforge.net/documentation.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 ''.%24imageFile.'';

生成饼图<?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 ''.%24imageFile.'';

?>

相关推荐:《PHP教程》

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值