📄 jpgraph_error.php
字号:
<?php
class ErrorPlot extends Plot
{
private $errwidth = 2;
public function ErrorPlot( $datay, $datax = false )
{
$this->Plot( $datay, $datax );
$this->numpoints /= 2;
}
public function PreStrokeAdjust( $graph )
{
if ( $this->center )
{
$a = 0.5;
$b = 0.5;
++$this->numpoints;
}
else
{
$a = 0;
$b = 0;
}
$graph->xaxis->scale->ticks->SetXLabelOffset( $a );
$graph->SetTextScaleOff( $b );
}
public function Stroke( $img, $xscale, $yscale )
{
$numpoints = count( $this->coords[0] ) / 2;
$img->SetColor( $this->color );
$img->SetLineWeight( $this->weight );
if ( isset( $this->coords[1] ) )
{
if ( count( $this->coords[1] ) != $numpoints )
{
JpGraphError::raisel( 2003, count( $this->coords[1] ), $numpoints );
}
else
{
$exist_x = true;
}
}
else
{
$exist_x = false;
}
$i = 0;
for ( ; $i < $numpoints; ++$i )
{
if ( $exist_x )
{
$x = $this->coords[1][$i];
}
else
{
$x = $i;
}
if ( !is_numeric( $x ) && !is_numeric( $this->coords[0][$i * 2] ) && !is_numeric( $this->coords[0][$i * 2 + 1] ) )
{
$xt = $xscale->Translate( $x );
$yt1 = $yscale->Translate( $this->coords[0][$i * 2] );
$yt2 = $yscale->Translate( $this->coords[0][$i * 2 + 1] );
$img->Line( $xt, $yt1, $xt, $yt2 );
$img->Line( $xt - $this->errwidth, $yt1, $xt + $this->errwidth, $yt1 );
$img->Line( $xt - $this->errwidth, $yt2, $xt + $this->errwidth, $yt2 );
}
}
return true;
}
}
class ErrorLinePlot extends ErrorPlot
{
public $line = null;
public function ErrorLinePlot( $datay, $datax = false )
{
$this->ErrorPlot( $datay, $datax );
$n = count( $datay );
$i = 0;
for ( ; $i < $n; $i += 2 )
{
$ly[] = ( $datay[$i] + $datay[$i + 1] ) / 2;
}
$this->line = new LinePlot( $ly, $datax );
}
public function Legend( $graph )
{
if ( $this->legend != "" )
{
$graph->legend->Add( $this->legend, $this->color );
}
$this->line->Legend( $graph );
}
public function Stroke( $img, $xscale, $yscale )
{
parent::stroke( $img, $xscale, $yscale );
$this->line->Stroke( $img, $xscale, $yscale );
}
}
class LineErrorPlot extends ErrorPlot
{
public $line = null;
public function LineErrorPlot( $datay, $datax = false )
{
$ly = array( );
$ey = array( );
$n = count( $datay );
if ( $n % 3 != 0 )
{
JpGraphError::raisel( 4002 );
}
$i = 0;
for ( ; $i < $n; $i += 3 )
{
$ly[] = $datay[$i];
$ey[] = $datay[$i] + $datay[$i + 1];
$ey[] = $datay[$i] + $datay[$i + 2];
}
$this->ErrorPlot( $ey, $datax );
$this->line = new LinePlot( $ly, $datax );
}
public function Legend( $graph )
{
if ( $this->legend != "" )
{
$graph->legend->Add( $this->legend, $this->color );
}
$this->line->Legend( $graph );
}
public function Stroke( $img, $xscale, $yscale )
{
parent::stroke( $img, $xscale, $yscale );
$this->line->Stroke( $img, $xscale, $yscale );
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -