drawLegend - when Description contains "\n"
Maybe this was never supposed to be allowed, but in Version 1.2x you could use a wordwrap with "\n" to get long Descriptions fit into the legend - so they expand only to y-Axis.
In Version 2.0.4. This will not work.
I have very long descriptions, that will never fit into the Legend if they don't wrap with a "\n".
So I made a small change to the function
drawLegend() that will fullfill my requirement, but it is not perfect (see later)
Changes will affect only LEGEND_VERTICAL:
"Align"=>TEXT_ALIGN_TOPLEFT
Coordinates will be dependant from FontSize and number of "\n" in the Description.
Sad, i could not made it work perfect for all fontsizes. The Scalefactor (1.2) is only a dirty-hack
I hope someone else may find a better Solution.
Code:
pChart2.0.4/class $ diff pDraw.class pDraw.class.ori
1301,1302c1301,1302
< $this->drawFilledRectangle($X+1,$Y+1+$this->FontSize/2,$X+$BoxSize+1,$Y+$BoxSize+1+$this->FontSize/2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
< $this->drawFilledRectangle($X,$Y+$this->FontSize/2,$X+$BoxSize,$Y+$BoxSize+$this->FontSize/2,array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20));
---
> $this->drawFilledRectangle($X+1,$Y+1,$X+$BoxSize+1,$Y+$BoxSize+1,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
> $this->drawFilledRectangle($X,$Y,$X+$BoxSize,$Y+$BoxSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20));
1305,1306c1305,1306
< $this->drawText($X+$BoxSize+4,$Y+$BoxSize/2,$Serie["Description"],array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_TOPLEFT));
< $Y=$Y+$YStep*(1+preg_match_all("/\n/",$Serie["Description"],$a=array()))*1.2;
---
> $this->drawText($X+$BoxSize+4,$Y+$BoxSize/2,$Serie["Description"],array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT));
> $Y=$Y+$YStep;