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.txtWould 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.