JpGraph: LinePlot->SetWeight will not work

Kevin Orriss picture Kevin Orriss · Nov 28, 2011 · Viewed 7.2k times · Source

I am using JpGraph version 3.5.0b1 to create some graphs for a PDF document and I have hit a problem that has taken half of my day trying to work out whats going wrong.

All i want to do is change the line thickness of my lineplot but no matter what I try, it always defaults to 1 (assuming 1 is the default).

I have done my research and know that I have to set it after I add it to the graph and also that if antialias is set to true then SetWeight is ignored. My code follows these rules and yet still nothing. I am able to change the colour of the line so I know its nothing to do with how I'm calling the methods.

Can anyone help me here please? I would be hugely grateful as it is starting to annoy me just a tad.

Anyway, here is a little snippet of my code:

$lineplot = new LinePlot($ydata, $xdata);
$graph->Add($lineplot);
$lineplot->SetColor("red");
$lineplot->SetWeight(2);

Answer

LWurm picture LWurm · Dec 18, 2012

SetWeight() will do nothing until you turn off anti-aliasing. JpGraph mentions this in their manual in the using anti-aliasing page.

I tested this in version 3.5.0b1 and the following must be done:

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