Why does JPGraph LinePlot SetStyle draw a white line instead of the specified dashed red line?

268 Views Asked by At

I want to have a dashed line with a Lineplot in JPGraph. However, if I use the appropriate method the line is drawn white instead of the specified color.

I use this code:

$graph = new Graph($this->graphW, $this->graphH);

...

$lineplot = new LinePlot($this->target_data);
$graph->Add($lineplot);
$lineplot->setLegend($this->lang[15]);

$lineplot->SetStyle('dashed');
$lineplot->setColor('red');

$graph->Stroke();

And the result is the following: Broken code

However, if I add the following to the code:

$lineplot->SetStepStyle();

The result is this: Working code

So the question: How can I get the dashed line without the StepStyle and why doesn't it work without the SetpStyle?

1

There are 1 best solutions below

0
Dave On

Do all of the line styling before you add it to the graph.

$lineplot = new LinePlot($this->target_data);
$lineplot->setLegend($this->lang[15]);
$lineplot->SetStyle('dashed');
$lineplot->setColor('red');
$graph->Add($lineplot);  // moved this to after the styling was done
$graph->Stroke();