forked from halo-battle/game
Upgrade jpgrah to 4.3.4
This commit is contained in:
parent
7c3999c5cd
commit
b5868f05f6
72 changed files with 19157 additions and 10327 deletions
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
/*=======================================================================
|
||||
// File: JPGRAPH_LINE.PHP
|
||||
// Description: Line plot extension for JpGraph
|
||||
// Created: 2001-01-08
|
||||
// Ver: $Id: jpgraph_line.php 981 2008-03-24 11:51:12Z ljp $
|
||||
//
|
||||
// Copyright (c) Aditus Consulting. All rights reserved.
|
||||
//========================================================================
|
||||
*/
|
||||
// File: JPGRAPH_LINE.PHP
|
||||
// Description: Line plot extension for JpGraph
|
||||
// Created: 2001-01-08
|
||||
// Ver: $Id: jpgraph_line.php 1921 2009-12-11 11:46:39Z ljp $
|
||||
//
|
||||
// Copyright (c) Asial Corporation. All rights reserved.
|
||||
//========================================================================
|
||||
*/
|
||||
|
||||
require_once('jpgraph_plotmark.inc.php');
|
||||
|
||||
|
|
@ -28,10 +28,11 @@ class LinePlot extends Plot
|
|||
protected $fill_color='blue';
|
||||
protected $step_style=false;
|
||||
protected $center=false;
|
||||
protected $line_style=1; // Default to solid
|
||||
protected $line_style=1; // Default to solid
|
||||
protected $filledAreas = array(); // array of arrays(with min,max,col,filled in them)
|
||||
public $barcenter=false; // When we mix line and bar. Should we center the line in the bar.
|
||||
protected $fillFromMin = false ;
|
||||
protected $fillFromMin = false;
|
||||
protected $fillFromMax = false;
|
||||
protected $fillgrad=false;
|
||||
protected $fillgrad_fromcolor='navy';
|
||||
protected $fillgrad_tocolor='silver';
|
||||
|
|
@ -40,20 +41,21 @@ class LinePlot extends Plot
|
|||
|
||||
//---------------
|
||||
// CONSTRUCTOR
|
||||
public function LinePlot($datay, $datax=false)
|
||||
public function __construct($datay, $datax=false)
|
||||
{
|
||||
$this->Plot($datay, $datax);
|
||||
parent::__construct($datay, $datax);
|
||||
$this->mark = new PlotMark() ;
|
||||
$this->color = ColorFactory::getColor();
|
||||
$this->fill_color = $this->color;
|
||||
}
|
||||
//---------------
|
||||
// PUBLIC METHODS
|
||||
|
||||
// Set style, filled or open
|
||||
public function SetFilled($aFlag=true)
|
||||
public function SetFilled($aFlg=true)
|
||||
{
|
||||
JpGraphError::RaiseL(10001);//('LinePlot::SetFilled() is deprecated. Use SetFillColor()');
|
||||
$this->filled = $aFlg;
|
||||
}
|
||||
|
||||
|
||||
public function SetBarCenter($aFlag=true)
|
||||
{
|
||||
$this->barcenter=$aFlag;
|
||||
|
|
@ -63,24 +65,30 @@ class LinePlot extends Plot
|
|||
{
|
||||
$this->line_style=$aStyle;
|
||||
}
|
||||
|
||||
|
||||
public function SetStepStyle($aFlag=true)
|
||||
{
|
||||
$this->step_style = $aFlag;
|
||||
}
|
||||
|
||||
|
||||
public function SetColor($aColor)
|
||||
{
|
||||
parent::SetColor($aColor);
|
||||
}
|
||||
|
||||
|
||||
public function SetFillFromYMin($f=true)
|
||||
{
|
||||
$this->fillFromMin = $f ;
|
||||
}
|
||||
|
||||
|
||||
public function SetFillFromYMax($f=true)
|
||||
{
|
||||
$this->fillFromMax = $f ;
|
||||
}
|
||||
|
||||
public function SetFillColor($aColor, $aFilled=true)
|
||||
{
|
||||
//$this->color = $aColor;
|
||||
$this->fill_color=$aColor;
|
||||
$this->filled=$aFilled;
|
||||
}
|
||||
|
|
@ -93,7 +101,7 @@ class LinePlot extends Plot
|
|||
$this->filled = $aFilled;
|
||||
$this->fillgrad = true;
|
||||
}
|
||||
|
||||
|
||||
public function Legend($graph)
|
||||
{
|
||||
if ($this->legend!="") {
|
||||
|
|
@ -143,17 +151,16 @@ class LinePlot extends Plot
|
|||
}
|
||||
$this->filledAreas[] = array($aMin,$aMax,$aColor,$aFilled,$aBorder);
|
||||
}
|
||||
|
||||
|
||||
// Gets called before any axis are stroked
|
||||
public function PreStrokeAdjust($graph)
|
||||
{
|
||||
|
||||
// If another plot type have already adjusted the
|
||||
// If another plot type have already adjusted the
|
||||
// offset we don't touch it.
|
||||
// (We check for empty in case the scale is a log scale
|
||||
// and hence doesn't contain any xlabel_offset)
|
||||
if (empty($graph->xaxis->scale->ticks->xlabel_offset) ||
|
||||
$graph->xaxis->scale->ticks->xlabel_offset == 0) {
|
||||
if (empty($graph->xaxis->scale->ticks->xlabel_offset) || $graph->xaxis->scale->ticks->xlabel_offset == 0) {
|
||||
if ($this->center) {
|
||||
++$this->numpoints;
|
||||
$a=0.5;
|
||||
|
|
@ -167,7 +174,7 @@ class LinePlot extends Plot
|
|||
//$graph->xaxis->scale->ticks->SupressMinorTickMarks();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function SetFastStroke($aFlg=true)
|
||||
{
|
||||
$this->iFastStroke = $aFlg;
|
||||
|
|
@ -210,7 +217,7 @@ class LinePlot extends Plot
|
|||
|
||||
$img->Polygon($cord, false, true);
|
||||
}
|
||||
|
||||
|
||||
public function Stroke($img, $xscale, $yscale)
|
||||
{
|
||||
$idx=0;
|
||||
|
|
@ -218,9 +225,8 @@ class LinePlot extends Plot
|
|||
if (isset($this->coords[1])) {
|
||||
if (count($this->coords[1])!=$numpoints) {
|
||||
JpGraphError::RaiseL(2003, count($this->coords[1]), $numpoints);
|
||||
}
|
||||
//("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$numpoints");
|
||||
else {
|
||||
} else {
|
||||
$exist_x = true;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -260,18 +266,22 @@ class LinePlot extends Plot
|
|||
$yscale->Translate($this->coords[0][$startpoint])
|
||||
);
|
||||
|
||||
|
||||
if ($this->filled) {
|
||||
$min = $yscale->GetMinVal();
|
||||
if ($min > 0 || $this->fillFromMin) {
|
||||
$fillmin = $yscale->scale_abs[0];
|
||||
}//Translate($min);
|
||||
else {
|
||||
$fillmin = $yscale->Translate(0);
|
||||
}
|
||||
if ($this->fillFromMax) {
|
||||
//$max = $yscale->GetMaxVal();
|
||||
$cord[$idx++] = $xscale->Translate($xs);
|
||||
$cord[$idx++] = $yscale->scale_abs[1];
|
||||
} else {
|
||||
$min = $yscale->GetMinVal();
|
||||
if ($min > 0 || $this->fillFromMin) {
|
||||
$fillmin = $yscale->scale_abs[0];//Translate($min);
|
||||
} else {
|
||||
$fillmin = $yscale->Translate(0);
|
||||
}
|
||||
|
||||
$cord[$idx++] = $xscale->Translate($xs);
|
||||
$cord[$idx++] = $fillmin;
|
||||
$cord[$idx++] = $xscale->Translate($xs);
|
||||
$cord[$idx++] = $fillmin;
|
||||
}
|
||||
}
|
||||
$xt = $xscale->Translate($xs);
|
||||
$yt = $yscale->Translate($this->coords[0][$startpoint]);
|
||||
|
|
@ -298,7 +308,7 @@ class LinePlot extends Plot
|
|||
}
|
||||
$xt = $xscale->Translate($x);
|
||||
$yt = $yscale->Translate($this->coords[0][$pnts]);
|
||||
|
||||
|
||||
$y=$this->coords[0][$pnts];
|
||||
if ($this->step_style) {
|
||||
// To handle null values within step style we need to record the
|
||||
|
|
@ -373,10 +383,14 @@ class LinePlot extends Plot
|
|||
|
||||
if ($this->filled) {
|
||||
$cord[$idx++] = $xt;
|
||||
if ($min > 0 || $this->fillFromMin) {
|
||||
$cord[$idx++] = $yscale->Translate($min);
|
||||
if ($this->fillFromMax) {
|
||||
$cord[$idx++] = $yscale->scale_abs[1];
|
||||
} else {
|
||||
$cord[$idx++] = $yscale->Translate(0);
|
||||
if ($min > 0 || $this->fillFromMin) {
|
||||
$cord[$idx++] = $yscale->Translate($min);
|
||||
} else {
|
||||
$cord[$idx++] = $yscale->Translate(0);
|
||||
}
|
||||
}
|
||||
if ($this->fillgrad) {
|
||||
$img->SetLineWeight(1);
|
||||
|
|
@ -388,9 +402,13 @@ class LinePlot extends Plot
|
|||
$img->SetColor($this->fill_color);
|
||||
$img->FilledPolygon($cord);
|
||||
}
|
||||
if ($this->line_weight > 0) {
|
||||
if ($this->weight > 0) {
|
||||
$img->SetLineWeight($this->weight);
|
||||
$img->SetColor($this->color);
|
||||
$img->Polygon($cord);
|
||||
// Remove first and last coordinate before drawing the line
|
||||
// sine we otherwise get the vertical start and end lines which
|
||||
// doesn't look appropriate
|
||||
$img->Polygon(array_slice($cord, 2, count($cord)-4));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -405,28 +423,26 @@ class LinePlot extends Plot
|
|||
$areaCoords[] = $minY;
|
||||
|
||||
$areaCoords =
|
||||
array_merge(
|
||||
$areaCoords,
|
||||
array_slice(
|
||||
array_merge(
|
||||
$areaCoords,
|
||||
array_slice(
|
||||
$cord,
|
||||
$this->filledAreas[$i][0] * $factor,
|
||||
($this->filledAreas[$i][1] - $this->filledAreas[$i][0] + ($this->step_style ? 0 : 1)) * $factor
|
||||
)
|
||||
);
|
||||
);
|
||||
$areaCoords[] = $areaCoords[sizeof($areaCoords)-2]; // last x
|
||||
$areaCoords[] = $minY; // last y
|
||||
|
||||
if ($this->filledAreas[$i][3]) {
|
||||
$img->SetColor($this->filledAreas[$i][2]);
|
||||
$img->FilledPolygon($areaCoords);
|
||||
$img->SetColor($this->color);
|
||||
}
|
||||
$areaCoords[] = $minY; // last y
|
||||
|
||||
if ($this->filledAreas[$i][3]) {
|
||||
$img->SetColor($this->filledAreas[$i][2]);
|
||||
$img->FilledPolygon($areaCoords);
|
||||
$img->SetColor($this->color);
|
||||
}
|
||||
// Check if we should draw the frame.
|
||||
// If not we still re-draw the line since it might have been
|
||||
// partially overwritten by the filled area and it doesn't look
|
||||
// very good.
|
||||
// TODO: The behaviour is undefined if the line does not have
|
||||
// any line at the position of the area.
|
||||
if ($this->filledAreas[$i][4]) {
|
||||
$img->Polygon($areaCoords);
|
||||
} else {
|
||||
|
|
@ -484,7 +500,7 @@ class AccLinePlot extends Plot
|
|||
private $iStartEndZero=true;
|
||||
//---------------
|
||||
// CONSTRUCTOR
|
||||
public function AccLinePlot($plots)
|
||||
public function __construct($plots)
|
||||
{
|
||||
$this->plots = $plots;
|
||||
$this->nbrplots = count($plots);
|
||||
|
|
@ -510,7 +526,7 @@ class AccLinePlot extends Plot
|
|||
$p->DoLegend($graph);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function Max()
|
||||
{
|
||||
list($xmax) = $this->plots[0]->Max();
|
||||
|
|
@ -570,11 +586,11 @@ class AccLinePlot extends Plot
|
|||
public function PreStrokeAdjust($graph)
|
||||
{
|
||||
|
||||
// If another plot type have already adjusted the
|
||||
// If another plot type have already adjusted the
|
||||
// offset we don't touch it.
|
||||
// (We check for empty in case the scale is a log scale
|
||||
// and hence doesn't contain any xlabel_offset)
|
||||
|
||||
|
||||
if (empty($graph->xaxis->scale->ticks->xlabel_offset) ||
|
||||
$graph->xaxis->scale->ticks->xlabel_offset == 0) {
|
||||
if ($this->center) {
|
||||
|
|
@ -603,7 +619,7 @@ class AccLinePlot extends Plot
|
|||
{
|
||||
$n=count($aData);
|
||||
$i=0;
|
||||
|
||||
|
||||
// If first point is undefined we will set it to the same as the first
|
||||
// valid data
|
||||
if ($aData[$i]==='-') {
|
||||
|
|
@ -661,8 +677,6 @@ class AccLinePlot extends Plot
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// To avoid duplicate of line drawing code here we just
|
||||
// change the y-values for each plot and then restore it
|
||||
// after we have made the stroke. We must do this copy since
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue