您好,登錄后才能下訂單哦!
這篇文章運(yùn)用簡單易懂的例子給大家介紹PHP如何生成折線圖和餅圖,代碼非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
生成折線圖
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 /* 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.'">'; ?>
關(guān)于PHP如何生成折線圖和餅圖就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。