作者mmm321 (家家)
看板PHP
標題[請益] JpGraph 無法調整顏色
時間Wed Mar 20 20:51:25 2013
今天剛開始接觸jpgraph
想要用來畫一些簡單的統計圖
沒想到一開始就遇到問題 > <
想要改變Bar的顏色,卻無法改,會一直維持範例的藍色
http://ppt.cc/yO~3
http://mach.ipm.virginia.edu/jpgraph/docs/html/exframes/frame_example18.html
想請教大家我是不是漏掉要設定什麼?
如果同一根Bar要畫第二筆資料,則會跟範例23一樣,第二次add的bar會是粉紅色的
http://ppt.cc/_i4z
另外想再請問,
如果我每一個Bar都想要是不同顏色的話,要怎麼設定呢?
EX:
http://ppt.cc/F1gw
麻煩大家指點了
以下是我目前的Code
php code:
require_once ('jpgraph/src/jpgraph.php');
require_once ('jpgraph/src/jpgraph_bar.php');
$graph = new Graph(1024,768,"auto");
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,20,40);
$b1plot = new BarPlot($data);
$b1plot->SetFillColor('orange');
$graph->Add($b1plot);
//$gbplot = new AccBarPlot(array($b1plot));
//$graph->Add($gbplot);
$graph->title->Set("TITLE");
$graph->xaxis->title->Set("X");
$graph->yaxis->title->Set("Y");
$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->Stroke();
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.239.247
1F:→ airtsubasa:物件設多個 放進array 03/20 21:39
2F:→ mmm321:請問A大,我用array放之後,他bar會一直疊上去,變成範例23那 03/20 21:43
3F:→ mmm321:樣,不知道是不是我方法錯誤了 >< 03/20 21:43
自問自答一下
第一個問題出在 $b1plot->value->Show(); 的位置
第二個問題也謝謝a大的提點
我一直將bar的資料放在array裡面,所以bar會一直往上疊
最後是將color放在array中,問題就解決了
$b1plot->SetFillColor($color20);
謝謝大家 :)
※ 編輯: mmm321 來自: 140.113.239.247 (03/20 22:33)