pChart 2.x forum
http://wiki.pchart.net/forum/

Bug in pDraw.class.php
http://wiki.pchart.net/forum/viewtopic.php?f=5&t=2134
Page 1 of 1

Author:  gladder [ Sat Aug 13, 2011 6:31 pm ]
Post subject:  Bug in pDraw.class.php

Hi Board,

I think pDraw.class.php is messed up. Using custom colors for lincharts is not working. using config
array(
"DisplayColor" => DISPLAY_MANUAL,
"DisplayR"=>100,
"DisplayG"=>100,
"DisplayB"=>100
)

does not take effect.

To fix this you have to change:
$this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));

to
$this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));

Maybe line 3372 should get changed from
$DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;

to
$DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_AUTO;

to implement a better default value? This could have side effects for sure and is an idea only.

Bye!

Author:  gladder [ Sat Aug 13, 2011 6:57 pm ]
Post subject:  Re: Bug in pDraw.class.php

Hi Board,

this FIX I've just posted has bad side-effects. the palette of the series gets ignored now. So the fix has to be different:
Be sure to fix the original file - the fix above has to be ignored...

change line 3372 from
$DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
to
$DisplayColor = isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_AUTO;

change line 3392 from
if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
to
if ( $DisplayColor == DISPLAY_MANUAL ) { $R = $DisplayR; $G = $DisplayG; $B = $DisplayB; }

change line 3417 from
$this->drawText($X,$Y-$Offset-$Weight,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
to
$this->drawText($X,$Y-$Offset-$Weight,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$R,"G"=>$G,"B"=>$B,"Align"=>$Align));

change line 3445 from
{ $this->drawText($X+$DisplayOffset+$Weight,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
to
{ $this->drawText($X+$DisplayOffset+$Weight,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$R,"G"=>$G,"B"=>$B,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }


NOTE: This whole issue does also regard to many other functions in pDraw.class.php. It seems to be a kind of a design error regarding the manual color definition of charts not using the setPalette function of the drawn series...

Bye!

Author:  jean-damien [ Sat Aug 13, 2011 7:00 pm ]
Post subject:  Re: Bug in pDraw.class.php

There is no bug there ;o)

The color of the lines on the line chart depends of the color mapped to the data serie.

The DisplayR, DisplayG, DisplayB parameters only apply to the labels. (http://wiki.pchart.net/doc.chart.drawlinechart.html)

Kind regards,
JD.

Author:  jean-damien [ Sat Aug 13, 2011 7:02 pm ]
Post subject:  Re: Bug in pDraw.class.php

I think that you are looking for the setPalette() function.

JD.

Author:  gladder [ Tue Aug 16, 2011 7:05 pm ]
Post subject:  Re: Bug in pDraw.class.php

hum...

Well, i should RTFM instead of reading the source code. setPalette() works fine though... But in my opinion, declaring manual RGB values should also overwrite the chart colors defined with setPalette - maybe this is a feature request :)

Thanks for your reply!

Bye

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/