简体   繁体   English

jpGraph中的透明背景

[英]Transparent background in jpGraph

I'm trying to achieve a line graph with transparent background, but so far, I can only set the background to a specific color. 我正在尝试实现具有透明背景的折线图,但是到目前为止,我只能将背景设置为特定的颜色。 Since it's PNG, it should be possible though. 由于它是PNG,因此应该可以。

$linePlot = new LinePlot($plotData);
$linePlot->SetFillColor('#61a9f3@.6');

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

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

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

Result 结果

图形没有透明背景

Not transparent, but black 不透明,但黑色

for me i have to put black instead of white to get transparency ! 对我来说,我必须用黑色代替白色来获得透明度!

$graph->SetMarginColor('black:0');
$graph->SetFrame(true,'black:0', 1); //but this make labels/letters weird !!!
$graph->img->SetTransparent('black');

Now, when making multiple graphs in a picture, this doesn't work. 现在,在图片中制作多个图形时,这将不起作用。 I try making for each graph the transparency or to the final one (mgraph), and i get 'HTTP ERROR 500' (internal server !?!) 我尝试为每张图都设置透明性或使最后一张图(mgraph)透明,然后得到“ HTTP ERROR 500”(内部服务器!!!)

$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);

Reference: change margin color for a jpgraph 参考: 更改jpgraph的页边距颜色

Transparent PNG image: $graph->img->SetTransparent("white"); 透明的PNG图片: $ graph-> img-> SetTransparent(“ white”); works great!!! 很棒!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM