我剛開始使用jpgraph和XAMPP我正在尋找一個barplot。 正當我在網上閱讀一些文章時,它說你可以傳入一組顏色來設置填充顏色,以便每個欄將是不同的顏色。然而,只要我通過它的顏色,圖形將不會從其淡藍色的默認顏色改變。Jpgraph不會改變我的barplot上的顏色
該圖響應數據的變化,但不響應顏色變化。 我試着用一個積累的條形圖例子,這似乎是顏色響應。
我不知道如何診斷這樣的問題。請幫助!
代碼下面(從與顏色的JpGraph的文檔例從橙色變爲#B0C4DE [橙色從原來的例子沒有顯示出來):
<?php // content="text/plain; charset=utf-8"
require_once(dirname(__FILE__)."\lib\jpgraph-3.5.0b1\src\jpgraph.php");
require_once(dirname(__FILE__)."\lib\jpgraph-3.5.0b1\src\jpgraph_line.php");
require_once(dirname(__FILE__)."\lib\jpgraph-3.5.0b1\src\jpgraph_bar.php");
$datay=array(2,3,5,25,15,6,3);
$datax=array('Jan','Feb','Mar','Apr','May','Jun','Jul');
// Size of graph
$width=400;
$height=500;
// Set the basic parameters of the graph
$graph = new Graph($width,$height,'auto');
$graph->SetScale('textlin');
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(50,20,50,30);
// Nice shadow
$graph->SetShadow();
// Setup title
$graph->title->Set('Horizontal bar graph ex 1');
$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,12);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right','center');
// Add some grace to y-axis so the bars doesn't go
// all the way to the end of the plot area
$graph->yaxis->scale->SetGrace(20);
// We don't want to display Y-axis
$graph->yaxis->Hide();
// Now create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor("#B0C4DE");
// ALSO tried:
// $bplot->SetColor(array("red","green","blue","gray"));
$bplot->SetShadow();
//You can change the width of the bars if you like
//$bplot->SetWidth(0.5);
// We want to display the value of each bar at the top
$bplot->value->Show();
$bplot->value->SetFont(FF_ARIAL,FS_BOLD,12);
$bplot->value->SetAlign('left','center');
$bplot->value->SetColor('black','darkred');
$bplot->value->SetFormat('%.1f mkr');
// Add the bar to the graph
$graph->Add($bplot);
// .. and stroke the graph
$graph->Stroke();
?>
我有同樣的問題。不考慮條形式的任何內容(值,顏色,...)。但它的線圖很好 –