2015-04-30 49 views
0

我想通過透明背景實現線條圖,但到目前爲止,我只能將背景設置爲特定的顏色。既然是PNG,那麼應該是jpGraph中的透明背景

$linePlot = new LinePlot($plotData); 
$linePlot->SetFillColor('#[email protected]'); 

$graph = new Graph(300, 100); 
$graph->SetScale('intint'); 

$graph->SetAlphaBlending(); 
$graph->SetMarginColor('black:1'); 
$graph->SetFrame(true,'black', 0); 

$graph->Add($linePlot); 
$graph->Stroke(); 

結果

Graph doesn't have transparent background

不是透明的,但黑色

回答

0
$graph->SetTheme($theme_class); 
$graph->img->SetAntiAliasing(false); 
$graph->title->Set('Filled Y-grid'); 
$graph->SetMarginColor('White:0.6'); 
$graph->SetFrame(true,'White:0.6',1); // The '1' here seems to be irrelevant 
            // I've tried much larger numbers with no 
            // change. This is supposed to be frame 
            // width (in pixels). 
$graph->SetBox(false); 

參考:change margin color for a jpgraph

+0

這就是我在搜索時已經查找的內容。它不呈現透明圖像。 – bytecode77

+0

您是否可以將其更改爲紅色或其他顏色而不是黑色? –

+0

是的,任何其他顏色,但沒有透明度。 – bytecode77

0

透明PNG圖像:$ graph-> img-> SetTransparent(「white」);很棒!