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

[PATCH] drawScatterBestFit return Slope and Intercept
http://wiki.pchart.net/forum/viewtopic.php?f=5&t=2319
Page 1 of 1

Author:  mila76 [ Wed Jan 04, 2012 11:53 pm ]
Post subject:  [PATCH] drawScatterBestFit return Slope and Intercept

Return an array with 'm' and 'b'. [SeriesYName]['b'] and [SeriesYName]['m']
I'm not sure is the best way... maybe a functiont getMB or something like that?

Code:
--- pScatter.class.php   (revisione 180)
+++ pScatter.class.php   (copia locale)
@@ -864,6 +864,7 @@
           {
            $M = (($n*$Sxy)-($Sx*$Sy)) / (($n*$Sxx)-($Sx*$Sx));
            $B = (($Sy)-($M*$Sx))/($n);
+           $Result[$Series["Y"]] = array("m" => $M, "b" => $B);

            $X1 = $this->getPosArray($Data["Axis"][$SerieXAxis]["ScaleMin"],$SerieXAxis);
            $Y1 = $this->getPosArray($M * $Data["Axis"][$SerieXAxis]["ScaleMin"] + $B,$SerieYAxis);
@@ -881,6 +882,7 @@
          $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Color);
         }
       }
+      return $Result;
     }

    function writeScatterLabel($ScatterSerieID,$Points,$Format="")

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