我正在使用JpGraph版本3.5.0b1为PDF文档创建一些图表,我遇到了一个问题,这个问题花费了我一半的时间来尝试找出问题所在.
我想做的就是改变线条图的线条粗细,但无论我尝试什么,它总是默认为1(假设1是默认值).
我完成了我的研究,并且知道在将其添加到图形之后我必须设置它,并且如果antialias设置为true,则忽略SetWeight.我的代码遵循这些规则,但仍然没有.我能够改变线的颜色,所以我知道它与我如何调用方法无关.
有人可以帮我吗?我会非常感激,因为它开始让我感到烦恼.
无论如何,这里是我的代码的一小部分:
$lineplot = new LinePlot($ydata, $xdata);
$graph->Add($lineplot);
$lineplot->SetColor("red");
$lineplot->SetWeight(2);
Run Code Online (Sandbox Code Playgroud)
LWu*_*urm 11
在关闭消除锯齿之前,SetWeight()将不执行任何操作.JpGraph在使用抗锯齿页面的手册中提到了这一点.
我在3.5.0b1版本中对此进行了测试,必须完成以下操作:
// Ensure anti-aliasing is off. If it is not, you can SetWeight() all day and nothing will change.
$graph->img->SetAntiAliasing(false);
// Create linear plot
$lineplot = new LinePlot($ydata, $xdata);
// Add plot to graph
$graph->Add($lineplot);
// Set line weight. This must be done AFTER adding the plot to the graph in version 3.5.0b1. I haven't verified this in other versions.
$lineplot->SetWeight(2);
Run Code Online (Sandbox Code Playgroud)