/trunk/api/jpgraph_1.12.2/jpgraph_log.php |
---|
New file |
0,0 → 1,241 |
<?php |
/*======================================================================= |
// File: JPGRAPH_LOG.PHP |
// Description: Log scale plot extension for JpGraph |
// Created: 2001-01-08 |
// Author: Johan Persson (johanp@aditus.nu) |
// Ver: $Id: jpgraph_log.php,v 1.1 2004/06/15 10:13:19 jpm Exp $ |
// |
// License: This code is released under QPL |
// Copyright (C) 2001,2002 Johan Persson |
//======================================================================== |
*/ |
DEFINE('LOGLABELS_PLAIN',0); |
DEFINE('LOGLABELS_MAGNITUDE',1); |
//=================================================== |
// CLASS LogScale |
// Description: Logarithmic scale between world and screen |
//=================================================== |
class LogScale extends LinearScale { |
//--------------- |
// CONSTRUCTOR |
// Log scale is specified using the log of min and max |
function LogScale($min,$max,$type="y") { |
$this->LinearScale($min,$max,$type); |
$this->ticks = new LogTicks(); |
$this->name = 'log'; |
} |
//---------------- |
// PUBLIC METHODS |
// Translate between world and screen |
function Translate($a) { |
if( $a < 0 ) { |
JpGraphError::Raise("Negative data values can not be used in a log scale."); |
exit(1); |
} |
if( $a==0 ) $a=1; |
$a=log10($a); |
return ceil($this->off + ($a*1.0 - $this->scale[0]) * $this->scale_factor); |
} |
// Relative translate (don't include offset) usefull when we just want |
// to know the relative position (in pixels) on the axis |
function RelTranslate($a) { |
if( $a==0 ) $a=1; |
$a=log10($a); |
return round(($a*1.0 - $this->scale[0]) * $this->scale_factor); |
} |
// Use bcpow() for increased precision |
function GetMinVal() { |
if( function_exists("bcpow") ) |
return round(bcpow(10,$this->scale[0],15),14); |
else |
return round(pow(10,$this->scale[0])); |
} |
function GetMaxVal() { |
if( function_exists("bcpow") ) |
return round(bcpow(10,$this->scale[1],15),14); |
else |
return round(pow(10,$this->scale[1])); |
} |
// Logarithmic autoscaling is much simplier since we just |
// set the min and max to logs of the min and max values. |
// Note that for log autoscale the "maxstep" the fourth argument |
// isn't used. This is just included to give the method the same |
// signature as the linear counterpart. |
function AutoScale(&$img,$min,$max,$dummy) { |
if( $min==0 ) $min=1; |
assert($max>0); |
$smin = floor(log10($min)); |
$smax = ceil(log10($max)); |
$this->Update($img,$smin,$smax); |
} |
//--------------- |
// PRIVATE METHODS |
} // Class |
//=================================================== |
// CLASS LogTicks |
// Description: |
//=================================================== |
class LogTicks extends Ticks{ |
var $label_logtype=LOGLABELS_MAGNITUDE; |
//--------------- |
// CONSTRUCTOR |
function LogTicks() { |
} |
//--------------- |
// PUBLIC METHODS |
function IsSpecified() { |
return true; |
} |
function SetLabelLogType($aType) { |
$this->label_logtype = $aType; |
} |
// For log scale it's meaningless to speak about a major step |
// We just return -1 to make the framework happy (specifically |
// StrokeLabels() ) |
function GetMajor() { |
return -1; |
} |
function SetTextLabelStart($aStart) { |
JpGraphError::Raise('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.'); |
} |
function SetXLabelOffset($dummy) { |
// For log scales we dont care about XLabel offset |
} |
// Draw ticks on image "img" using scale "scale". The axis absolute |
// position in the image is specified in pos, i.e. for an x-axis |
// it specifies the absolute y-coord and for Y-ticks it specified the |
// absolute x-position. |
function Stroke(&$img,&$scale,$pos) { |
$start = $scale->GetMinVal(); |
$limit = $scale->GetMaxVal(); |
$nextMajor = 10*$start; |
$step = $nextMajor / 10.0; |
$img->SetLineWeight($this->weight); |
if( $scale->type == "y" ) { |
// member direction specified if the ticks should be on |
// left or right side. |
$a=$pos + $this->direction*$this->GetMinTickAbsSize(); |
$a2=$pos + $this->direction*$this->GetMajTickAbsSize(); |
$count=1; |
$this->maj_ticks_pos[0]=$scale->Translate($start); |
$this->maj_ticklabels_pos[0]=$scale->Translate($start); |
if( $this->supress_first ) |
$this->maj_ticks_label[0]=""; |
else { |
if( $this->label_formfunc != '' ) { |
$f = $this->label_formfunc; |
$this->maj_ticks_label[0]=$f($start); |
} |
elseif( $this->label_logtype == LOGLABELS_PLAIN ) |
$this->maj_ticks_label[0]=$start; |
else |
$this->maj_ticks_label[0]='10^'.round(log10($start)); |
} |
$i=1; |
for($y=$start; $y<=$limit; $y+=$step,++$count ) { |
$ys=$scale->Translate($y); |
$this->ticks_pos[]=$ys; |
$this->ticklabels_pos[]=$ys; |
if( $count % 10 == 0 ) { |
if( $this->majcolor!="" ) { |
$img->PushColor($this->majcolor); |
$img->Line($pos,$ys,$a2,$ys); |
$img->PopColor(); |
} |
else |
$img->Line($pos,$ys,$a2,$ys); |
$this->maj_ticks_pos[$i]=$ys; |
$this->maj_ticklabels_pos[$i]=$ys; |
if( $this->label_formfunc != '' ) { |
$f = $this->label_formfunc; |
$this->maj_ticks_label[$i]=$f($nextMajor); |
} |
elseif( $this->label_logtype == 0 ) |
$this->maj_ticks_label[$i]=$nextMajor; |
else |
$this->maj_ticks_label[$i]='10^'.round(log10($nextMajor)); |
++$i; |
$nextMajor *= 10; |
$step *= 10; |
$count=1; |
} |
else { |
if( $this->mincolor!="" ) $img->PushColor($this->mincolor); |
$img->Line($pos,$ys,$a,$ys); |
if( $this->mincolor!="" ) $img->PopCOlor(); |
} |
} |
} |
else { |
$a=$pos - $this->direction*$this->GetMinTickAbsSize(); |
$a2=$pos - $this->direction*$this->GetMajTickAbsSize(); |
$count=1; |
$this->maj_ticks_pos[0]=$scale->Translate($start); |
$this->maj_ticklabels_pos[0]=$scale->Translate($start); |
if( $this->supress_first ) |
$this->maj_ticks_label[0]=""; |
else { |
if( $this->label_formfunc != '' ) { |
$f = $this->label_formfunc; |
$this->maj_ticks_label[0]=$f($start); |
} |
elseif( $this->label_logtype == 0 ) |
$this->maj_ticks_label[0]=$start; |
else |
$this->maj_ticks_label[0]='10^'.round(log10($start)); |
} |
$i=1; |
for($x=$start; $x<=$limit; $x+=$step,++$count ) { |
$xs=$scale->Translate($x); |
$this->ticks_pos[]=$xs; |
$this->ticklabels_pos[]=$xs; |
if( $count % 10 == 0 ) { |
$img->Line($xs,$pos,$xs,$a2); |
$this->maj_ticks_pos[$i]=$xs; |
$this->maj_ticklabels_pos[$i]=$xs; |
if( $this->label_formfunc != '' ) { |
$f = $this->label_formfunc; |
$this->maj_ticks_label[$i]=$f($nextMajor); |
} |
elseif( $this->label_logtype == 0 ) |
$this->maj_ticks_label[$i]=$nextMajor; |
else |
$this->maj_ticks_label[$i]='10^'.round(log10($nextMajor)); |
++$i; |
$nextMajor *= 10; |
$step *= 10; |
$count=1; |
} |
else |
$img->Line($xs,$pos,$xs,$a); |
} |
} |
return true; |
} |
} // Class |
/* EOF */ |
?> |
/trunk/api/jpgraph_1.12.2/jpgraph_regstat.php |
---|
New file |
0,0 → 1,105 |
<?php |
/*======================================================================= |
// File: JPGRAPH_REGSTAT.PHP |
// Description: Regression and statistical analysis helper classes |
// Created: 2002-12-01 |
// Author: Johan Persson (johanp@aditus.nu) |
// Ver: $Id: jpgraph_regstat.php,v 1.1 2004/06/15 10:13:19 jpm Exp $ |
// |
// License: This code is released under QPL |
// Copyright (C) 2002 Johan Persson |
//======================================================================== |
*/ |
//------------------------------------------------------------------------ |
// CLASS Spline |
// Create a new data array from an existing data array but with more points. |
// The new points are interpolated using a cubic spline algorithm |
//------------------------------------------------------------------------ |
class Spline { |
// 3:rd degree polynom approximation |
var $xdata,$ydata; // Data vectors |
var $y2; // 2:nd derivate of ydata |
var $n=0; |
function Spline($xdata,$ydata) { |
$this->y2 = array(); |
$this->xdata = $xdata; |
$this->ydata = $ydata; |
$n = count($ydata); |
$this->n = $n; |
// Natural spline 2:derivate == 0 at endpoints |
$this->y2[0] = 0.0; |
$this->y2[$n-1] = 0.0; |
$delta[0] = 0.0; |
// Calculate 2:nd derivate |
for($i=1; $i < $n-1; ++$i) { |
$d = ($xdata[$i+1]-$xdata[$i-1]); |
if( $d == 0 ) { |
JpGraphError::Raise('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.'); |
} |
$s = ($xdata[$i]-$xdata[$i-1])/$d; |
$p = $s*$this->y2[$i-1]+2.0; |
$this->y2[$i] = ($s-1.0)/$p; |
$delta[$i] = ($ydata[$i+1]-$ydata[$i])/($xdata[$i+1]-$xdata[$i]) - |
($ydata[$i]-$ydata[$i-1])/($xdata[$i]-$xdata[$i-1]); |
$delta[$i] = (6.0*$delta[$i]/($xdata[$i+1]-$xdata[$i-1])-$s*$delta[$i-1])/$p; |
} |
// Backward substitution |
for( $j=$n-2; $j >= 0; --$j ) { |
$this->y2[$j] = $this->y2[$j]*$this->y2[$j+1] + $delta[$j]; |
} |
} |
// Return the two new data vectors |
function Get($num=50) { |
$n = $this->n ; |
$step = ($this->xdata[$n-1]-$this->xdata[0]) / ($num-1); |
$xnew=array(); |
$ynew=array(); |
$xnew[0] = $this->xdata[0]; |
$ynew[0] = $this->ydata[0]; |
for( $j=1; $j < $num; ++$j ) { |
$xnew[$j] = $xnew[0]+$j*$step; |
$ynew[$j] = $this->Interpolate($xnew[$j]); |
} |
return array($xnew,$ynew); |
} |
// Return a single interpolated Y-value from an x value |
function Interpolate($xpoint) { |
$max = $this->n-1; |
$min = 0; |
// Binary search to find interval |
while( $max-$min > 1 ) { |
$k = ($max+$min) / 2; |
if( $this->xdata[$k] > $xpoint ) |
$max=$k; |
else |
$min=$k; |
} |
// Each interval is interpolated by a 3:degree polynom function |
$h = $this->xdata[$max]-$this->xdata[$min]; |
if( $h == 0 ) { |
JpGraphError::Raise('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.'); |
} |
$a = ($this->xdata[$max]-$xpoint)/$h; |
$b = ($xpoint-$this->xdata[$min])/$h; |
return $a*$this->ydata[$min]+$b*$this->ydata[$max]+ |
(($a*$a*$a-$a)*$this->y2[$min]+($b*$b*$b-$b)*$this->y2[$max])*($h*$h)/6.0; |
} |
} |
// EOF |
?> |
/trunk/api/fpdf/font/timesbi.php |
---|
New file |
0,0 → 1,15 |
<?php |
$fpdf_charwidths['timesBI']=array( |
chr(0)=>250,chr(1)=>250,chr(2)=>250,chr(3)=>250,chr(4)=>250,chr(5)=>250,chr(6)=>250,chr(7)=>250,chr(8)=>250,chr(9)=>250,chr(10)=>250,chr(11)=>250,chr(12)=>250,chr(13)=>250,chr(14)=>250,chr(15)=>250,chr(16)=>250,chr(17)=>250,chr(18)=>250,chr(19)=>250,chr(20)=>250,chr(21)=>250, |
chr(22)=>250,chr(23)=>250,chr(24)=>250,chr(25)=>250,chr(26)=>250,chr(27)=>250,chr(28)=>250,chr(29)=>250,chr(30)=>250,chr(31)=>250,' '=>250,'!'=>389,'"'=>555,'#'=>500,'$'=>500,'%'=>833,'&'=>778,'\''=>278,'('=>333,')'=>333,'*'=>500,'+'=>570, |
','=>250,'-'=>333,'.'=>250,'/'=>278,'0'=>500,'1'=>500,'2'=>500,'3'=>500,'4'=>500,'5'=>500,'6'=>500,'7'=>500,'8'=>500,'9'=>500,':'=>333,';'=>333,'<'=>570,'='=>570,'>'=>570,'?'=>500,'@'=>832,'A'=>667, |
'B'=>667,'C'=>667,'D'=>722,'E'=>667,'F'=>667,'G'=>722,'H'=>778,'I'=>389,'J'=>500,'K'=>667,'L'=>611,'M'=>889,'N'=>722,'O'=>722,'P'=>611,'Q'=>722,'R'=>667,'S'=>556,'T'=>611,'U'=>722,'V'=>667,'W'=>889, |
'X'=>667,'Y'=>611,'Z'=>611,'['=>333,'\\'=>278,']'=>333,'^'=>570,'_'=>500,'`'=>333,'a'=>500,'b'=>500,'c'=>444,'d'=>500,'e'=>444,'f'=>333,'g'=>500,'h'=>556,'i'=>278,'j'=>278,'k'=>500,'l'=>278,'m'=>778, |
'n'=>556,'o'=>500,'p'=>500,'q'=>500,'r'=>389,'s'=>389,'t'=>278,'u'=>556,'v'=>444,'w'=>667,'x'=>500,'y'=>444,'z'=>389,'{'=>348,'|'=>220,'}'=>348,'~'=>570,chr(127)=>350,chr(128)=>500,chr(129)=>350,chr(130)=>333,chr(131)=>500, |
chr(132)=>500,chr(133)=>1000,chr(134)=>500,chr(135)=>500,chr(136)=>333,chr(137)=>1000,chr(138)=>556,chr(139)=>333,chr(140)=>944,chr(141)=>350,chr(142)=>611,chr(143)=>350,chr(144)=>350,chr(145)=>333,chr(146)=>333,chr(147)=>500,chr(148)=>500,chr(149)=>350,chr(150)=>500,chr(151)=>1000,chr(152)=>333,chr(153)=>1000, |
chr(154)=>389,chr(155)=>333,chr(156)=>722,chr(157)=>350,chr(158)=>389,chr(159)=>611,chr(160)=>250,chr(161)=>389,chr(162)=>500,chr(163)=>500,chr(164)=>500,chr(165)=>500,chr(166)=>220,chr(167)=>500,chr(168)=>333,chr(169)=>747,chr(170)=>266,chr(171)=>500,chr(172)=>606,chr(173)=>333,chr(174)=>747,chr(175)=>333, |
chr(176)=>400,chr(177)=>570,chr(178)=>300,chr(179)=>300,chr(180)=>333,chr(181)=>576,chr(182)=>500,chr(183)=>250,chr(184)=>333,chr(185)=>300,chr(186)=>300,chr(187)=>500,chr(188)=>750,chr(189)=>750,chr(190)=>750,chr(191)=>500,chr(192)=>667,chr(193)=>667,chr(194)=>667,chr(195)=>667,chr(196)=>667,chr(197)=>667, |
chr(198)=>944,chr(199)=>667,chr(200)=>667,chr(201)=>667,chr(202)=>667,chr(203)=>667,chr(204)=>389,chr(205)=>389,chr(206)=>389,chr(207)=>389,chr(208)=>722,chr(209)=>722,chr(210)=>722,chr(211)=>722,chr(212)=>722,chr(213)=>722,chr(214)=>722,chr(215)=>570,chr(216)=>722,chr(217)=>722,chr(218)=>722,chr(219)=>722, |
chr(220)=>722,chr(221)=>611,chr(222)=>611,chr(223)=>500,chr(224)=>500,chr(225)=>500,chr(226)=>500,chr(227)=>500,chr(228)=>500,chr(229)=>500,chr(230)=>722,chr(231)=>444,chr(232)=>444,chr(233)=>444,chr(234)=>444,chr(235)=>444,chr(236)=>278,chr(237)=>278,chr(238)=>278,chr(239)=>278,chr(240)=>500,chr(241)=>556, |
chr(242)=>500,chr(243)=>500,chr(244)=>500,chr(245)=>500,chr(246)=>500,chr(247)=>570,chr(248)=>500,chr(249)=>556,chr(250)=>556,chr(251)=>556,chr(252)=>556,chr(253)=>444,chr(254)=>500,chr(255)=>444); |
?> |
Property changes: |
Added: svn:executable |
+* |
\ No newline at end of property |