ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  lowess plotting off page...
Posted by Colin on Sep-27-2012 21:25
Attachments:
Just wondering if there is a fix (that does not involve interpolation of manufactured datapoints) that simply prevents the spline from drawing past x and/or not re-scaling y to negative.

Its fine if the spline dips below x, but can I set it to stop drawing/scaling until its back above 0 or x? Is my implementation ok?

        $curve = new ArrayMath($final);
        $curve->lowess(0.55,1);
        $splineLayerObj = $c->addSplineLayer($curve->result(), 0x000000);
        $splineLayerObj->setLineWidth(2);
        $c->setClipping();

I set negative values to 0 but that flattens the spline too drastically. See 2nd example attached.

It may be that the dataset is to small and varied to support the spline, but I'm hoping to find a good compromise here.

Thanks a lot!
CompBarDynamic.png
CompBarDynamic0.png

  Re: lowess plotting off page...
Posted by Peter Kwan on Sep-28-2012 03:10
Hi Colin,

If I were you, I will simply set the negative values to 0. Are you sure it would change the spline so drastically? In a spline, changing one point can only affect the next 3 points and the last 3 points. So changing the last data point to 0 should not affect the first few data points in your chart.

The code I would use is:

        $curve = new ArrayMath($final);
        $curve->lowess(0.55,1);
        $curveData = $curve->result();

        for ($i = 0; $i < count($curveData); ++$i)
               if ($curveData[$i] < 0) $curveData[$i] = 0;

        $splineLayerObj = $c->addSplineLayer($curveData, 0x000000);
        $splineLayerObj->setLineWidth(2);
        $c->setClipping();

Please let me know if the above code would work.

Regards
Peter Kwan

  Re: lowess plotting off page...
Posted by Colin on Sep-28-2012 03:26
Attachments:
Oh I see what I did wrong now, blargh! Stoopid maths.  Your recommendation worked perfectly.  Attached

Thanks again!
CompBarDynamicz.png