View unanswered posts | View active topics It is currently Sat Apr 27, 2024 11:25 pm



Reply to topic  [ 5 posts ] 
ScatterSplineChart oddities 
Author Message
Regular pChart user
Regular pChart user

Joined: Sat Jan 08, 2011 10:37 pm
Posts: 9
Post ScatterSplineChart oddities
My apologies if this has been addressed since the 2.1.0 release:

When experimenting with scatter charts and VOID values, I ran across what I think is a bit odd behavior. In short, the can render continuous curves if the VOIDs are on the X axis, but not if they are on the Y one. Example 1 illustrates a vertical spline, and example 2 a horizontal spline. The code I used is a variation of the drawScatterSplineChart example, and the 50% sample is VOID. I'm attaching the source, for reference.

(No, I'm not, as I'm not allowed to upload it. http://columbiegg.com/files/scatter-vertical.txt and http://columbiegg.com/files/scatter-horizontal.txt are the sources.)

Time to investigate!

Looking in pScatter.class.php, I find the spline scatter handling. In the function drawScatterSplineChart() is this fragment:

if ( $Y == VOID && $LastY != NULL )
{ $SplineSettings["Forces"] = $Forces; $this->pChartObject->drawSpline($WayPoints,$SplineSettings); $WayPoints = ""; $Forces = "";}

I'm not entirely sure I understand what it does or why, but it does affect the Y axis, while the X axis has no counterpart in the code. Simply commenting it out produces example 3; a continuous spline, but not as good looking as the one in example 1.

Right before the now inactive lines we find

if ( $X != VOID && $Y != VOID )
{ $WayPoints[] = array($X,$Y); $Forces[] = $Force; }

which make sure that if either X or Y is VOID, both are disregarded, and not included at all in the spline. For a scatter chart, this makes perfect sense. However, right after this statement, we find

$LastX = $X; $LastY = $Y;

which, in turn, make sure that any VOID values are carried over to the next round of the loop, despite the fact that they "do not exist".

If we move the latter into the former, like this:

if ( $X != VOID && $Y != VOID )
{ $WayPoints[] = array($X,$Y); $Forces[] = $Force; $LastX = $X; $LastY = $Y; }

we get example 4, which looks very much like example 1, only horizontal. The resulting file can be seen at http://columbiegg.com/files/pScatter.class.txt

Would this work as a general patch for scatter spline rendering? Like the original source, this patch does not obey any wishes about how VOIDs should be rendered; as lines or breaks.
The ScatterLine rendering exhibit the same behaviour, but I haven't looked into that.


Attachments:
File comment: Scatter examples
scatter-examples.png
scatter-examples.png [ 36.73 KiB | Viewed 8553 times ]
Sat Mar 26, 2011 12:58 am
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: ScatterSplineChart oddities
Hi,

That is correct, you've found a bug in the curve break interpretation. To correct it, you need to replace

Code:
if ( $Y == VOID && $LastY != NULL )

by
Code:
if ( $Y == VOID || $X == VOID )


This statement force the spline to be flushed and recomputed the next time we find valid data.

--this has been fixed in the 2.1.1 next sub release.

Thank you!

Kind regards,
JD.


Mon Mar 28, 2011 9:27 am
Profile WWW
Regular pChart user
Regular pChart user

Joined: Sat Jan 08, 2011 10:37 pm
Posts: 9
Post Re: ScatterSplineChart oddities
Short and concise, and a big step forward for predictability.


Mon Mar 28, 2011 5:34 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: ScatterSplineChart oddities
I plan to add support of missing points (by doing linear or cubic interpolation) for the scatter charts in the next subversions.

Experience always told me that a dataset without any missing points isn't a real dataset ;o)

JD.


Mon Mar 28, 2011 5:49 pm
Profile WWW
Regular pChart user
Regular pChart user

Joined: Sat Jan 08, 2011 10:37 pm
Posts: 9
Post Re: ScatterSplineChart oddities
jean-damien wrote:
Experience always told me that a dataset without any missing points isn't a real dataset ;o)


Guess how I found the bug? :)

Your hard work is appreciated!


Wed Mar 30, 2011 8:10 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron