📄 jpgraph.php
字号:
$this->xscale = new DateScale( $aXMin, $aXMax, "x" );
}
else if ( $xt == "log" )
{
$this->xscale = new LogScale( $aXMin, $aXMax, "x" );
}
else
{
JpGraphError::raisel( 25022, $aAxisType );
}
$this->xaxis = new Axis( $this->img, $this->xscale );
$this->yaxis = new Axis( $this->img, $this->yscale );
$this->xgrid = new Grid( $this->xaxis );
$this->ygrid = new Grid( $this->yaxis );
$this->ygrid->Show( );
}
public function SetY2Scale( $aAxisType = "lin", $aY2Min = 1, $aY2Max = 1 )
{
if ( $aAxisType == "lin" )
{
$this->y2scale = new LinearScale( $aY2Min, $aY2Max );
}
else if ( $aAxisType == "int" )
{
$this->y2scale = new LinearScale( $aY2Min, $aY2Max );
$this->y2scale->SetIntScale( );
}
else if ( $aAxisType == "log" )
{
$this->y2scale = new LogScale( $aY2Min, $aY2Max );
}
else
{
JpGraphError::raisel( 25023, $aAxisType );
}
$this->y2axis = new Axis( $this->img, $this->y2scale );
$this->y2axis->scale->ticks->SetDirection( SIDE_LEFT );
$this->y2axis->SetLabelSide( SIDE_RIGHT );
$this->y2axis->SetPos( "max" );
$this->y2axis->SetTitleSide( SIDE_RIGHT );
$this->y2grid = new Grid( $this->y2axis );
}
public function SetYDeltaDist( $aDist )
{
$this->iYAxisDeltaPos = $aDist;
}
public function SetYScale( $aN, $aAxisType = "lin", $aYMin = 1, $aYMax = 1 )
{
if ( $aAxisType == "lin" )
{
$this->ynscale[$aN] = new LinearScale( $aYMin, $aYMax );
}
else if ( $aAxisType == "int" )
{
$this->ynscale[$aN] = new LinearScale( $aYMin, $aYMax );
$this->ynscale[$aN]->SetIntScale( );
}
else if ( $aAxisType == "log" )
{
$this->ynscale[$aN] = new LogScale( $aYMin, $aYMax );
}
else
{
JpGraphError::raisel( 25024, $aAxisType );
}
$this->ynaxis[$aN] = new Axis( $this->img, $this->ynscale[$aN] );
$this->ynaxis[$aN]->scale->ticks->SetDirection( SIDE_LEFT );
$this->ynaxis[$aN]->SetLabelSide( SIDE_RIGHT );
}
public function SetTickDensity( $aYDensity = TICKD_NORMAL, $aXDensity = TICKD_NORMAL )
{
$this->xtick_factor = 30;
$this->ytick_factor = 25;
switch ( $aYDensity )
{
case TICKD_DENSE :
$this->ytick_factor = 12;
break;
case TICKD_NORMAL :
$this->ytick_factor = 25;
break;
case TICKD_SPARSE :
$this->ytick_factor = 40;
break;
case TICKD_VERYSPARSE :
$this->ytick_factor = 100;
break;
default :
JpGraphError::raisel( 25025, $densy );
}
switch ( $aXDensity )
{
case TICKD_DENSE :
$this->xtick_factor = 15;
break;
case TICKD_NORMAL :
$this->xtick_factor = 30;
break;
case TICKD_SPARSE :
$this->xtick_factor = 45;
break;
case TICKD_VERYSPARSE :
$this->xtick_factor = 60;
break;
default :
do
{
JpGraphError::raisel( 25025, $densx );
}
}
public function GetCSIMareas( )
{
if ( !$this->iHasStroked )
{
$this->Stroke( _CSIM_SPECIALFILE );
}
$csim = $this->title->GetCSIMAreas( );
$csim .= $this->subtitle->GetCSIMAreas( );
$csim .= $this->subsubtitle->GetCSIMAreas( );
$csim .= $this->legend->GetCSIMAreas( );
if ( $this->y2axis != NULL )
{
$csim .= $this->y2axis->title->GetCSIMAreas( );
}
if ( $this->texts != null )
{
$n = count( $this->texts );
$i = 0;
for ( ; $i < $n; ++$i )
{
$csim .= $this->texts[$i]->GetCSIMAreas( );
}
}
if ( $this->y2texts != null && $this->y2scale != null )
{
$n = count( $this->y2texts );
$i = 0;
for ( ; $i < $n; ++$i )
{
$csim .= $this->y2texts[$i]->GetCSIMAreas( );
}
}
if ( $this->yaxis != null && $this->xaxis != null )
{
$csim .= $this->yaxis->title->GetCSIMAreas( );
$csim .= $this->xaxis->title->GetCSIMAreas( );
}
$n = count( $this->plots );
$i = 0;
for ( ; $i < $n; ++$i )
{
$csim .= $this->plots[$i]->GetCSIMareas( );
}
$n = count( $this->y2plots );
$i = 0;
for ( ; $i < $n; ++$i )
{
$csim .= $this->y2plots[$i]->GetCSIMareas( );
}
$n = count( $this->ynaxis );
$i = 0;
for ( ; $i < $n; ++$i )
{
$m = count( $this->ynplots[$i] );
$j = 0;
for ( ; $j < $m; ++$j )
{
$csim .= $this->ynplots[$i][$j]->GetCSIMareas( );
}
}
$n = count( $this->iTables );
$i = 0;
for ( ; $i < $n; ++$i )
{
$csim .= $this->iTables[$i]->GetCSIMareas( );
}
return $csim;
}
public function GetHTMLImageMap( $aMapName )
{
$im = "<map name=\"".$aMapName."\" id=\"{$aMapName}\" >\n";
$im .= $this->GetCSIMareas( );
$im .= "</map>";
return $im;
}
public function CheckCSIMCache( $aCacheName, $aTimeOut = 60 )
{
global $_SERVER;
if ( $aCacheName == "auto" )
{
$aCacheName = basename( $_SERVER['PHP_SELF'] );
}
$urlarg = $this->GetURLArguments( );
$this->csimcachename = CSIMCACHE_DIR.$aCacheName.$urlarg;
$this->csimcachetimeout = $aTimeOut;
if ( $this->csimcachename != "" )
{
$dir = dirname( $this->csimcachename );
$base = basename( $this->csimcachename );
$base = strtok( $base, "." );
$suffix = strtok( "." );
$basecsim = $dir."/".$base."?".$urlarg."_csim_.html";
$baseimg = $dir."/".$base."?".$urlarg.".".$this->img->img_format;
$timedout = false;
if ( file_exists( $basecsim ) && file_exists( $baseimg ) )
{
$diff = time( ) - filemtime( $basecsim );
if ( 0 < $this->csimcachetimeout && $this->csimcachetimeout * 60 < $diff )
{
$timedout = true;
@unlink( $basecsim );
@unlink( $baseimg );
}
else if ( $fh = @fopen( $basecsim, "r" ) )
{
fpassthru( $fh );
return true;
}
else
{
JpGraphError::raisel( 25027, $basecsim );
}
}
}
return false;
}
public function GetURLArguments( )
{
$urlarg = _CSIM_DISPLAY."=1";
reset( &$GLOBALS['_GET'] );
while ( list( $key, $value ) = each( &$GLOBALS['_GET'] ) )
{
if ( is_array( $value ) )
{
$n = count( $value );
$i = 0;
for ( ; do
{
$i < $n; ++$i, )
{
$urlarg .= "&".$key."%5B%5D=".urlencode( $value[$i] );
}
} while ( 1 );
}
else
{
$urlarg .= "&".$key."=".urlencode( $value );
}
}
reset( &$GLOBALS['_POST'] );
while ( list( $key, $value ) = each( &$GLOBALS['_POST'] ) )
{
if ( is_array( $value ) )
{
$n = count( $value );
$i = 0;
for ( ; do
{
$i < $n; ++$i, )
{
$urlarg .= "&".$key."%5B%5D=".urlencode( $value[$i] );
}
} while ( 1 );
}
else
{
$urlarg .= "&".$key."=".urlencode( $value );
}
}
return $urlarg;
}
public function StrokeCSIM( $aScriptName = "auto", $aCSIMName = "", $aBorder = 0 )
{
if ( $aCSIMName == "" )
{
srand( ( double )microtime( ) * 1000000 );
$r = rand( 0, 100000 );
$aCSIMName = "__mapname".$r."__";
}
if ( $aScriptName == "auto" )
{
$aScriptName = basename( $_SERVER['PHP_SELF'] );
}
$urlarg = $this->GetURLArguments( );
if ( empty( $_GET[_CSIM_DISPLAY] ) )
{
if ( $this->csimcachename != "" )
{
$dir = dirname( $this->csimcachename );
$base = basename( $this->csimcachename );
$base = strtok( $base, "." );
$suffix = strtok( "." );
$basecsim = $dir."/".$base."?".$urlarg."_csim_.html";
$baseimg = $base."?".$urlarg.".".$this->img->img_format;
if ( file_exists( $dir ) && !is_writeable( $dir ) )
{
JpgraphError::raisel( 25028, $dir );
}
$this->cache->MakeDirs( $dir );
$this->Stroke( CSIMCACHE_DIR.$baseimg );
$tmp = str_replace( "?", "%3f", $baseimg );
$htmlwrap = $this->GetHTMLImageMap( $aCSIMName )."\n<img src=\"".CSIMCACHE_HTTP_DIR.$tmp."\" ismap=\"ismap\" usemap=\"#".$aCSIMName."\" border=\"".$aBorder."\" width=\"".$this->img->width."\" height=\"".$this->img->height."\" alt=\"\" />\n";
if ( $fh = @fopen( $basecsim, "w" ) )
{
fwrite( $fh, $htmlwrap );
fclose( $fh );
echo $htmlwrap;
}
else
{
JpGraphError::raisel( 25029, $basecsim );
}
}
else
{
if ( $aScriptName == "" )
{
JpGraphError::raisel( 25030 );
}
echo $this->GetHTMLImageMap( $aCSIMName );
echo "<img src=\"".$aScriptName."?".$urlarg."\" ismap=\"ismap\" usemap=\"#".$aCSIMName."\" border=\"".$aBorder."\" width=\"".$this->img->width."\" height=\"".$this->img->height."\" alt=\"\" />\n";
}
}
else
{
$this->Stroke( );
}
}
public function GetTextsYMinMax( $aY2 = false )
{
if ( $aY2 )
{
$txts = $this->y2texts;
}
else
{
$txts = $this->texts;
}
$n = count( $txts );
$min = null;
$max = null;
$i = 0;
for ( ; $i < $n; ++$i )
{
if ( !( $txts[$i]->iScalePosY !== null ) && !( $txts[$i]->iScalePosX !== null ) )
{
if ( $min === null )
{
$min = $max = $txts[$i]->iScalePosY;
}
else
{
$min = min( $min, $txts[$i]->iScalePosY );
$max = max( $max, $txts[$i]->iScalePosY );
}
}
}
if ( $min !== null )
{
return array(
$min,
$max
);
}
return null;
}
public function GetTextsXMinMax( $aY2 = false )
{
if ( $aY2 )
{
$txts = $this->y2texts;
}
else
{
$txts = $this->texts;
}
$n = count( $txts );
$min = null;
$max = null;
$i = 0;
for ( ; $i < $n; ++$i )
{
if ( !( $txts[$i]->iScalePosY !== null ) && !( $txts[$i]->iScalePosX !== null ) )
{
if ( $min === null )
{
$min = $max = $txts[$i]->iScalePosX;
}
else
{
$min = min( $min, $txts[$i]->iScalePosX );
$max = max( $max, $txts[$i]->iScalePosX );
}
}
}
if ( $min !== null )
{
return array(
$min,
$max
);
}
return null;
}
public function GetXMinMax( )
{
list( $min, $ymin ) = $this->plots[0]->Min( );
list( $max, $ymax ) = $this->plots[0]->Max( );
foreach ( $this->plots as $p )
{
list( $xmin, $ymin ) = $p->Min( );
list( $xmax, $ymax ) = $p->Max( );
$min = min( $xmin, $min );
$max = max( $xmax, $max );
}
if ( $this->y2axis != null )
{
foreach ( $this->y2plots as $p )
{
list( $xmin, $ymin ) = $p->Min( );
list( $xmax, $ymax ) = $p->Max( );
$min = min( $xmin, $min );
$max = max( $xmax, $max );
}
}
$n = count( $this->ynaxis );
$i = 0;
for ( ; $i < $n; ++$i )
{
if ( $this->ynaxis[$i] != null )
{
foreach ( $this->ynplots[$i] as $p )
{
list( $xmin, $ymin ) = $p->Min( );
list( $xmax, $ymax ) = $p->Max( );
$min = min( $xmin, $min );
$max = max( $xmax, $max );
}
}
}
return array(
$min,
$max
);
}
public function AdjustMarginsForTitles( )
{
[exception occured]
================================
Exception code[ C0000005 ]
Compiler[ 00385B20 ]
Executor[ 00386028 ]
OpArray[ 01009E60 ]
File< D:\MYOA08\php-de\MYOA08\webroot\inc\jpgraph\jpgraph.php >
Class< Graph >
Function< AdjustMarginsForTitles >
Stack[ 00145AC8 ]
Step[ 7 ]
Offset[ 32 ]
LastOffset[ 174 ]
32 ADD [-] 0[0] $Tmp_9 - $Tmp_2 - $Tmp_11
================================
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -