- Update lang files (Pandora Console)

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@59 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
raulmateos 2006-06-29 16:34:55 +00:00
parent f31555555b
commit d213cf4acf
37 changed files with 26097 additions and 25946 deletions

View File

@ -961,11 +961,11 @@ while ($row=mysql_fetch_array($result)){
   
<input type="text" name="other" size="5">
<tr><td class="datos"><?php echo $lang_label["min"]." ".$lang_label["alerts"] ?>
<tr><td class="datos"><?php echo $lang_label["min_alerts"] ?>
<td class="datos">
<input type="text" name="min_alerts" size="5" value="<?php if (isset($alerta_min_alerts)) {echo$alerta_min_alerts;} ?>">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo $lang_label["max"]." ".$lang_label["alerts"] ?>
<?php echo $lang_label["max_alerts"] ?>
&nbsp;&nbsp;&nbsp;
<input type="text" name="max_alerts" size="5" value="<?php if (isset($alerta_max_alerts)) {echo $alerta_max_alerts;} ?>">

View File

@ -7,9 +7,9 @@
// Raul Mateos <raulofpandora@gmail.com>, 2004-2006
// David Muniz , 2005-2006
$lang_label["view_agents"]="Agüeyar axentes";
$lang_label["view_agents"]="Ag&uuml;eyar axentes";
$lang_label["manage_incidents"]="Xesti&oacute;n d'incidentes";
$lang_label["view_users"]="Agüeyar usuarios";
$lang_label["view_users"]="Ag&uuml;eyar usuarios";
$lang_label["new_incident"]="Nuevu incidente";
$lang_label["search_incident"]="Buscar incidente";
$lang_label["index_myuser"]="Editar mi usuariu";
@ -201,7 +201,7 @@ $lang_label["db_stat_agent"]="Estad&iacute;stiques de la Base de Datos per axent
$lang_label["configure"]="Configurar";
$lang_label["event_main_view"]="Vista principal d'eventos";
$lang_label["event_name"]="Nome del eventu";
$lang_label["view_events"]="Agüeyar eventos";
$lang_label["view_events"]="Ag&uuml;eyar eventos";
$lang_label["timestamp"]="Fecha/Hora";
$lang_label["links_header"]="Enllaces";
$lang_label["godmode_header"]="Alministraci&oacute;n";
@ -247,8 +247,8 @@ $lang_label["add"]="A&ntilde;adir";
$lang_label["db_purge_event"]="Llimpieza de la Base de Datos d'eventos";
$lang_label["db_event"]="BD de eventos";
$lang_label["max_min"]="Max/Min";
$lang_label["max"]="M&aacute;ximo";
$lang_label["min"]="M&iacute;nimo";
$lang_label["max"]="Máximo";
$lang_label["min"]="Mínimo";
$lang_label["med"]="Media";
$lang_label["month_graph"]="Gr&aacute;ficu mensual";
$lang_label["week_graph"]="Gr&aacute;ficu selmanal";
@ -301,9 +301,9 @@ $lang_label["manage_config"]="Xestionar conf.";
$lang_label["config_manage"]="Xesti&oacute;n de Configuraciones";
$lang_label["get_info"]="Obtener info.";
$lang_label["are_you_sure"]="¿Ta ust&eacute; seguru?";
$lang_label["users_msg"]="Los perfiles d'usuariu en Pandora definen que usuarios puen aceder a Pandora y que puen facer cada unu. Los grupos definen ellementos en com&uacute;n, cada usuariu pue pertenecer a unu o m&aacute;s grupos, y tien asign&aacute;u un perfil a cada grupu que pertenezca. Un perfil ye una llista de lo que pue y nun pue facer cada grupu, como per exemplu «agüeyar incidentes» o «xestionar bases de datos». Abaxu se muestra una llista de los perfiles disponibles (defin&iacute;os por los alministraores llocales de Pandora)";
$lang_label["users_msg"]="Los perfiles d'usuariu en Pandora definen que usuarios puen aceder a Pandora y que puen facer cada unu. Los grupos definen ellementos en com&uacute;n, cada usuariu pue pertenecer a unu o m&aacute;s grupos, y tien asign&aacute;u un perfil a cada grupu que pertenezca. Un perfil ye una llista de lo que pue y nun pue facer cada grupu, como per exemplu «ag&uuml;eyar incidentes» o «xestionar bases de datos». Abaxu se muestra una llista de los perfiles disponibles (defin&iacute;os por los alministraores llocales de Pandora)";
$help_label["users_msg1"]="Esti usuariu ye especial y tien permisu pa tou, pasando per encima de los privilexios asignados mediante grupos/perfiles";
$help_label["users_msg2"]="Esti usuariu tien permisos segregaos pa agüeyar datos en los axentes de su grupu, crear incidentes dientru d'aquellos grupos sobre los que tenga acceso y a&ntilde;adir notes en incidentes o de terceros.";
$help_label["users_msg2"]="Esti usuariu tien permisos segregaos pa ag&uuml;eyar datos en los axentes de su grupu, crear incidentes dientru d'aquellos grupos sobre los que tenga acceso y a&ntilde;adir notes en incidentes o de terceros.";
$help_label["db_purge1"]="Esti bot&oacute;n resfresca la informaci&oacute;n sobre el usu de la Base de Datos a lo llargu del tiempu";
$help_label["db_purge0"]="Use esti control pa selecionar un axente. Ye necesariu selecionar un axente tantu pa obtener informaci&oacute;n de la Base de Datos como pa borrar datos de la misma";
$lang_label["profiles"]="Perfiles";
@ -314,7 +314,7 @@ $lang_label["create_profile"]="Crear perfil";
$lang_label["profile_name"]="Nome del perfil";
$lang_label["pandora_management"]="Xesti&oacute;n de Pandora";
$lang_label["manage_db"]="Xesti&oacute;n de BD";
$lang_label["incident_view"]="Agüeyar incidentes";
$lang_label["incident_view"]="Ag&uuml;eyar incidentes";
$lang_label["incident_edit"]="Editar incidentes";
$lang_label["agent_edit"]="Editar axentes";
$lang_label["alert_edit"]="Editar alertes";
@ -368,7 +368,7 @@ $lang_label["statistics"]="Estad&iacute;stiques";
$lang_label["incident_priority"]="Prioridaes de los incidentes";
$lang_label["copy"]="Copiar";
$lang_label["choose_agent"]="Escoxa axente";
$lang_label["press_db_info"]="Pulse equ&iacute; pa agüeyar informaci&oacute;n de la BD como texto";
$lang_label["press_db_info"]="Pulse equ&iacute; pa ag&uuml;eyar informaci&oacute;n de la BD como texto";
$lang_label["event_statistics"]="Estad&iacute;stiques de eventos";
$lang_label["deletedata"]="Borrar datos";
$lang_label["source"]="Orixen";
@ -554,5 +554,4 @@ $lang_label["graph_order"]="Orden del gr&aacute;ficu";
$lang_label["truetype"]="Fontes truetype";
$lang_label["right_left"]="dre. a manz.";
$lang_label["left_right"]="manz. a dre.";
$lang_label["enabled"]="habilit&aacute;u";
?>

View File

@ -245,9 +245,9 @@ $lang_label["doit"]="Fes-ho!";
$lang_label["add"]="Afegeix";
$lang_label["db_purge_event"]="Purgar la base de dades d'events";
$lang_label["db_event"]="Event de la base de dades";
$lang_label["max_min"]="Max/Min";
$lang_label["max"]="M&agrave;xim";
$lang_label["min"]="M&iacute;nim";
$lang_label["max_min"]="M&agrave;x/M&iacute;n";
$lang_label["max"]="Màxim";
$lang_label["min"]="Mínim";
$lang_label["med"]="Mitjana";
$lang_label["month_graph"]="Gr&agrave;fica mensual";
$lang_label["week_graph"]="Gr&agrave;fica setmanal";

File diff suppressed because one or more lines are too long

View File

@ -116,7 +116,7 @@ $lang_label["description"] ="Descripci&oacute;n";
$lang_label["last_fired"]="Lanzada por &uacute;ltima vez";
$lang_label["type"]="Tipo";
$lang_label["last_contact"]="&Uacute;ltimo contacto";
$lang_label["last_data_chunk"]="Contenido de los ultimos paquetes enviado por el agente : ";
$lang_label["last_data_chunk"]="Contenido de los &uacute;ltimos paquetes enviados por el agente: ";
$lang_label["graph"]="Gr&aacute;fica";
$lang_label["raw_data"]="Datos";
$lang_label["data"]="Datos";
@ -283,8 +283,8 @@ $lang_label["add"]="A&ntilde;adir";
$lang_label["db_purge_event"]="Limpieza de la Base de Datos de eventos";
$lang_label["db_event"]="BBDD de eventos";
$lang_label["max_min"]="M&aacute;x/M&iacute;n";
$lang_label["max"]="M&aacute;ximo";
$lang_label["min"]="M&iacute;nimo";
$lang_label["max"]="Máximo";
$lang_label["min"]="Mínimo";
$lang_label["med"]="Media";
$lang_label["month_graph"]="Gr&aacute;fica mensual";
$lang_label["week_graph"]="Gr&aacute;fica semanal";
@ -615,8 +615,6 @@ $lang_label["graph_order"]="Orden del gr&aacute;fico";
$lang_label["truetype"]="Fuentes truetype";
$lang_label["right_left"]="der. a izq.";
$lang_label["left_right"]="izq. a der.";
$lang_label["enabled"]="habilitado";
$lang_label["disabled"]="deshabilitado";
global $lang_label;
global $help_label;

View File

@ -609,14 +609,12 @@ $lang_label["del_server_ok"]="Serveur &eacute;limin&eacute; avec succ&egrave;s";
$lang_label["del_server_no"]=" Pandora a rencontr&eacute; un probl&egrave;me pour &eacute;liminer le serveur ";
$lang_label["groups"]="groupes";
$lang_label["other"]="Autre";
$lang_label["icon"]="Icône";
$lang_label["icon"]="Ic&ocirc;ne";
$lang_label["agent_exists"]="Cet agent existe d&eacute;j&agrave;";
$lang_label["graph_order"]="Ordre du tableau";
$lang_label["truetype"]="Polices truetype";
$lang_label["right_left"]="dr. a gau.";
$lang_label["left_right"]="gau. a dr.";
$lang_label["enabled"]="habilit&eacute;";
$lang_label["disabled"]="deshabilit&eacute;";
global $lang_label;
global $help_label;

View File

@ -249,9 +249,9 @@ $lang_label["add"] = "Adicionar";
$lang_label["db_purge_event"] = "Limpeza da Base de Dados de eventos";
$lang_label["db_event"] = "BD de eventos";
$lang_label["max_min"] = "M&aacute;x/M&iacute;n";
$lang_label["max"] = "M&aacute;ximo";
$lang_label["min"] = "M&iacute;nimo";
$lang_label["med"] = "M&eacute;dia";
$lang_label["max"] = "Máximo";
$lang_label["min"] = "Mínimo";
$lang_label["med"] = "Média";
$lang_label["month_graph"] = "Gr&aacute;fico mensal";
$lang_label["week_graph"] = "Gr&aacute;fico Semanal";
$lang_label["day_graph"] = "Gr&aacute;fico Di&aacute;rio";
@ -554,8 +554,8 @@ $lang_label["icon"] = "&iacute;cone";
$lang_label["agent_exists"] = "O agente j&aacute; existe";
$lang_label["graph_order"] = "Ordem do gr&aacute;fico";
$lang_label["truetype"] = "Fontes truetype";
$lang_label["right_left"]="Dir. &agrave;  Esq."; // direita &agrave;  esquerda
$lang_label["left_right"]="Esq. &agrave;  Dir."; // esquerda &agrave;  direita
$lang_label["right_left"]="Dir. &agrave;  Esq."; // direita à  esquerda
$lang_label["left_right"]="Esq. &agrave;  Dir."; // esquerda à  direita
global $lang_label;
global $help_label;

View File

@ -4,51 +4,49 @@
// Description: Base64 encoded images for small round markers
// Created: 2003-03-20
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: imgdata_balls.inc 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: imgdata_balls.inc 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Balls extends ImgData {
var $name = 'Round Balls';
var $an = array(MARK_IMG_LBALL => 'imgdata_large',
protected $name = 'Round Balls';
protected $an = array(MARK_IMG_LBALL => 'imgdata_large',
MARK_IMG_MBALL => 'imgdata_small',
MARK_IMG_SBALL => 'imgdata_xsmall',
MARK_IMG_BALL => 'imgdata_xsmall');
var $colors_1 = array('blue','lightblue','brown','darkgreen',
protected $colors,$index,$maxidx;
private $colors_1 = array('blue','lightblue','brown','darkgreen',
'green','purple','red','gray','yellow','silver','gray');
var $index_1 = array('blue'=>9,'lightblue'=>1,'brown'=>6,'darkgreen'=>7,
private $index_1 = array('blue'=>9,'lightblue'=>1,'brown'=>6,'darkgreen'=>7,
'green'=>8,'purple'=>4,'red'=>0,'gray'=>5,'silver'=>3,'yellow'=>2);
var $maxidx_1 = 9 ;
private $maxidx_1 = 9 ;
var $colors_2 = array('blue','bluegreen','brown','cyan',
private $colors_2 = array('blue','bluegreen','brown','cyan',
'darkgray','greengray','gray','green',
'greenblue','lightblue','lightred',
'purple','red','white','yellow');
var $index_2 = array('blue'=>9,'bluegreen'=>13,'brown'=>8,'cyan'=>12,
private $index_2 = array('blue'=>9,'bluegreen'=>13,'brown'=>8,'cyan'=>12,
'darkgray'=>5,'greengray'=>6,'gray'=>2,'green'=>10,
'greenblue'=>3,'lightblue'=>1,'lightred'=>14,
'purple'=>7,'red'=>0,'white'=>11,'yellow'=>4);
var $maxidx_2 = 14 ;
private $maxidx_2 = 14 ;
var $colors_3 = array('bluegreen','cyan','darkgray','greengray',
private $colors_3 = array('bluegreen','cyan','darkgray','greengray',
'gray','graypurple','green','greenblue','lightblue',
'lightred','navy','orange','purple','red','yellow');
var $index_3 = array('bluegreen'=>1,'cyan'=>11,'darkgray'=>14,'greengray'=>10,
private $index_3 = array('bluegreen'=>1,'cyan'=>11,'darkgray'=>14,'greengray'=>10,
'gray'=>3,'graypurple'=>4,'green'=>9,'greenblue'=>7,
'lightblue'=>13,'lightred'=>0,'navy'=>2,'orange'=>12,
'purple'=>8,'red'=>5,'yellow'=>6);
var $maxidx_3 = 14 ;
private $maxidx_3 = 14 ;
var $colors,$index,$maxidx;
var $imgdata_large ;
var $imgdata_small ;
var $imgdata_xsmall ;
protected $imgdata_large, $imgdata_small, $imgdata_xsmall ;
function GetImg($aMark,$aIdx) {

View File

@ -4,20 +4,20 @@
// Description: Base64 encoded images for round bevels
// Created: 2003-03-20
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: imgdata_bevels.inc 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: imgdata_bevels.inc 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Bevels extends ImgData {
var $name = 'Round Bevels';
var $an = array(MARK_IMG_BEVEL => 'imgdata');
protected $name = 'Round Bevels';
protected $an = array(MARK_IMG_BEVEL => 'imgdata');
var $colors = array('green','purple','orange','red','yellow');
var $index = array('green'=>1,'purple'=>4,'orange'=>2,'red'=>0,'yellow'=>3);
var $maxidx = 4 ;
protected $colors = array('green','purple','orange','red','yellow');
protected $index = array('green'=>1,'purple'=>4,'orange'=>2,'red'=>0,'yellow'=>3);
protected $maxidx = 4 ;
var $imgdata ;
protected $imgdata ;
function ImgData_Bevels() {
//==========================================================

View File

@ -4,21 +4,21 @@
// Description: Base64 encoded images for diamonds
// Created: 2003-03-20
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: imgdata_diamonds.inc 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: imgdata_diamonds.inc 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Diamonds extends ImgData {
var $name = 'Diamonds';
var $an = array(MARK_IMG_DIAMOND =>'imgdata');
var $colors = array('lightblue','darkblue','gray',
protected $name = 'Diamonds';
protected $an = array(MARK_IMG_DIAMOND =>'imgdata');
protected $colors = array('lightblue','darkblue','gray',
'blue','pink','purple','red','yellow');
var $index = array('lightblue' =>7,'darkblue'=>2,'gray'=>6,
protected $index = array('lightblue' =>7,'darkblue'=>2,'gray'=>6,
'blue'=>4,'pink'=>1,'purple'=>5,'red'=>0,'yellow'=>3);
var $maxidx = 7 ;
var $imgdata ;
protected $maxidx = 7 ;
protected $imgdata ;
function ImgData_Diamonds() {
//==========================================================

View File

@ -4,21 +4,21 @@
// Description: Base64 encoded images for pushpins
// Created: 2003-03-20
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: imgdata_pushpins.inc 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: imgdata_pushpins.inc 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_PushPins extends ImgData {
var $name = 'Push pins';
var $an = array(MARK_IMG_PUSHPIN => 'imgdata_small',
protected $name = 'Push pins';
protected $an = array(MARK_IMG_PUSHPIN => 'imgdata_small',
MARK_IMG_SPUSHPIN => 'imgdata_small',
MARK_IMG_LPUSHPIN => 'imgdata_large');
var $colors = array('blue','green','orange','pink','red');
var $index = array('red' => 0, 'orange' => 1, 'pink' => 2, 'blue' => 3, 'green' => 4 ) ;
var $maxidx = 4 ;
var $imgdata_large, $imgdata_small ;
protected $colors = array('blue','green','orange','pink','red');
protected $index = array('red' => 0, 'orange' => 1, 'pink' => 2, 'blue' => 3, 'green' => 4 ) ;
protected $maxidx = 4 ;
protected $imgdata_large, $imgdata_small ;
function ImgData_PushPins() {

View File

@ -4,21 +4,21 @@
// Description: Base64 encoded images for squares
// Created: 2003-03-20
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: imgdata_squares.inc 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: imgdata_squares.inc 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Squares extends ImgData {
var $name = 'Squares';
var $an = array(MARK_IMG_SQUARE =>'imgdata');
protected $name = 'Squares';
protected $an = array(MARK_IMG_SQUARE =>'imgdata');
var $colors = array('bluegreen','blue','green',
protected $colors = array('bluegreen','blue','green',
'lightblue','orange','purple','red','yellow');
var $index = array('bluegreen' =>2,'blue'=>5,'green'=>6,
protected $index = array('bluegreen' =>2,'blue'=>5,'green'=>6,
'lightblue'=>0,'orange'=>7,'purple'=>4,'red'=>3,'yellow'=>1);
var $maxidx = 7 ;
var $imgdata ;
protected $maxidx = 7 ;
protected $imgdata ;
function ImgData_Squares () {
//==========================================================

View File

@ -4,21 +4,21 @@
// Description: Base64 encoded images for stars
// Created: 2003-03-20
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: imgdata_stars.inc 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: imgdata_stars.inc 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class ImgData_Stars extends ImgData {
var $name = 'Stars';
var $an = array(MARK_IMG_STAR => 'imgdata');
protected $name = 'Stars';
protected $an = array(MARK_IMG_STAR => 'imgdata');
var $colors = array('bluegreen','lightblue','purple','blue','green','pink','red','yellow');
var $index = array('bluegreen'=>3,'lightblue'=>4,'purple'=>1,
protected $colors = array('bluegreen','lightblue','purple','blue','green','pink','red','yellow');
protected $index = array('bluegreen'=>3,'lightblue'=>4,'purple'=>1,
'blue'=>5,'green'=>0,'pink'=>7,'red'=>2,'yellow'=>6);
var $maxidx = 7 ;
var $imgdata ;
protected $maxidx = 7 ;
protected $imgdata ;
function ImgData_Stars() {
//==========================================================

File diff suppressed because it is too large Load Diff

View File

@ -4,14 +4,15 @@
// Description: Genarate anti-spam challenge
// Created: 2004-10-07
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_antispam-digits.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_antispam-digits.php 629 2006-05-26 00:05:28Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class HandDigits {
var $digits_thumb30x30 = array();
var $iHeight=30, $iWidth=30;
public $digits = array();
public $iHeight=30, $iWidth=30;
function HandDigits() {
//==========================================================
// d6-small.jpg

View File

@ -4,14 +4,15 @@
// Description: Genarate anti-spam challenge
// Created: 2004-10-07
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_antispam.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_antispam.php 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
class HandDigits {
var $chars = array();
var $iHeight=30, $iWidth=30;
public $chars = array();
public $iHeight=30, $iWidth=30;
function HandDigits() {
//==========================================================
@ -545,18 +546,14 @@ $this->chars['q'][1]=
class AntiSpam {
var $iData='';
var $iDD=null;
private $iData='';
private $iDD=null;
function AntiSpam($aData='') {
$this->iData = $aData;
$this->iDD = new HandDigits();
}
function Set($aData) {
$this->iData = $aData;
}
function Rand($aLen) {
$d='';
for($i=0; $i < $aLen; ++$i) {
@ -576,7 +573,7 @@ class AntiSpam {
return $d;
}
function Stroke($aStrokeFileName="") {
function Stroke() {
$n=strlen($this->iData);
if( $n==0 ) {
@ -606,19 +603,9 @@ class AntiSpam {
}
imagecopy($resimg,$img,2,2,0,0,$start, $this->iDD->iHeight);
if( $aStrokeFileName!="" ) {
if( file_exists($aStrokeFileName) ) {
if( !@unlink($aStrokeFileName) )
return false;
}
imagejpeg($resimg,$aStrokeFileName);
return;
}
header("Content-type: image/jpeg");
$res=imagejpeg($resimg);
return $res;
imagejpeg($resimg);
return true;
}
}

View File

@ -4,7 +4,7 @@
// Description: Bar plot extension for JpGraph
// Created: 2001-01-08
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_bar.php 334 2005-12-15 22:34:17Z ljp $
// Ver: $Id: jpgraph_bar.php 634 2006-05-26 00:59:09Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -29,22 +29,22 @@ DEFINE('PATTERN_STRIPE2',10);
// Description: Main code to produce a bar plot
//===================================================
class BarPlot extends Plot {
var $width=0.4; // in percent of major ticks
var $abswidth=-1; // Width in absolute pixels
var $fill=false,$fill_color="lightblue"; // Default is to fill with light blue
var $ybase=0; // Bars start at 0
var $align="center";
var $grad=false,$grad_style=1;
var $grad_fromcolor=array(50,50,200),$grad_tocolor=array(255,255,255);
var $bar_shadow=false;
var $bar_shadow_color="black";
var $bar_shadow_hsize=3,$bar_shadow_vsize=3;
var $valuepos='top';
var $iPattern=-1,$iPatternDensity=80,$iPatternColor='black';
public $fill=false,$fill_color="lightblue"; // Default is to fill with light blue
public $iPattern=-1,$iPatternDensity=80,$iPatternColor='black';
public $valuepos='top';
public $grad=false,$grad_style=1;
public $grad_fromcolor=array(50,50,200),$grad_tocolor=array(255,255,255);
protected $width=0.4; // in percent of major ticks
protected $abswidth=-1; // Width in absolute pixels
protected $ybase=0; // Bars start at 0
protected $align="center";
protected $bar_shadow=false;
protected $bar_shadow_color="black";
protected $bar_shadow_hsize=3,$bar_shadow_vsize=3;
//---------------
// CONSTRUCTOR
function BarPlot(&$datay,$datax=false) {
function BarPlot($datay,$datax=false) {
$this->Plot($datay,$datax);
++$this->numpoints;
}
@ -74,7 +74,7 @@ class BarPlot extends Plot {
$this->ybase=$aYStartValue;
}
function Legend(&$graph) {
function Legend($graph) {
if( $this->grad && $this->legend!="" && !$this->fill ) {
$color=array($this->grad_fromcolor,$this->grad_tocolor);
// In order to differentiate between gradients and cooors specified as an RGB triple
@ -110,11 +110,9 @@ class BarPlot extends Plot {
}
// Gets called before any axis are stroked
function PreStrokeAdjust(&$graph) {
function PreStrokeAdjust($graph) {
parent::PreStrokeAdjust($graph);
$cn = strtolower(get_class($this));
// If we are using a log Y-scale we want the base to be at the
// minimum Y-value unless the user have specifically set some other
// value than the default.
@ -137,9 +135,8 @@ class BarPlot extends Plot {
elseif( $this->align == "right" )
$graph->SetTextScaleOff(1-$this->width);
}
}
elseif( $cn !== 'accbarplot' && $cn !== 'groupbarplot') {
elseif( ($this instanceof AccBarPlot) || ($this instanceof GroupBarPlot) ) {
// We only set an absolute width for linear and int scale
// for text scale the width will be set to a fraction of
// the majstep width.
@ -166,8 +163,13 @@ class BarPlot extends Plot {
}
// Specify width as fractions of the major stepo size
function SetWidth($aFractionWidth) {
$this->width=$aFractionWidth;
function SetWidth($aWidth) {
if( $aWidth > 1 ) {
// Interpret this as absolute width
$this->abswidth=$aWidth;
}
else
$this->width=$aWidth;
}
// Specify width in absolute pixels. If specified this
@ -264,18 +266,18 @@ class BarPlot extends Plot {
break;
case PATTERN_STRIPE1:
$aPatternValue= 5;
$aDensity = 95;
$aDensity = 90;
break;
case PATTERN_STRIPE2:
$aPatternValue= 5;
$aDensity = 85;
$aDensity = 75;
break;
default:
JpGraphError::Raise('Unknown pattern specified in call to BarPlot::SetPattern()');
}
}
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
$numpoints = count($this->coords[0]);
if( isset($this->coords[1]) ) {
@ -305,7 +307,7 @@ class BarPlot extends Plot {
else
$abswidth=round($this->width*$xscale->scale_factor,0);
// Count potential pattern array to avoid doing the count for each iteration
// Count pontetial pattern array to avoid doing the count for each iteration
if( is_array($this->iPattern) ) {
$np = count($this->iPattern);
}
@ -331,7 +333,6 @@ class BarPlot extends Plot {
elseif($this->align=="right")
$x -= $abswidth;
}
*/
// Stroke fill color and fill gradient
$pts=array(
@ -511,7 +512,7 @@ class BarPlot extends Plot {
}
if( !empty($this->csimtargets[$i]) ) {
$this->csimareas .= '<area shape="poly" coords="'.$csimcoord.'" ';
$this->csimareas .= " href=\"".$this->csimtargets[$i]."\"";
$this->csimareas .= " href=\"".htmlentities($this->csimtargets[$i])."\"";
$sval='';
if( !empty($this->csimalts[$i]) ) {
$sval=sprintf($this->csimalts[$i],$this->coords[0][$i]);
@ -529,13 +530,11 @@ class BarPlot extends Plot {
// Description: Produce grouped bar plots
//===================================================
class GroupBarPlot extends BarPlot {
var $plots;
var $width=0.7;
var $nbrplots=0;
var $numpoints;
private $plots, $nbrplots=0;
//---------------
// CONSTRUCTOR
function GroupBarPlot($plots) {
$this->width=0.7;
$this->plots = $plots;
$this->nbrplots = count($plots);
if( $this->nbrplots < 1 ) {
@ -547,16 +546,16 @@ class GroupBarPlot extends BarPlot {
}
}
$this->numpoints = $plots[0]->numpoints;
$this->width=0.7;
}
//---------------
// PUBLIC METHODS
function Legend(&$graph) {
function Legend($graph) {
$n = count($this->plots);
for($i=0; $i < $n; ++$i) {
$c = strtolower(get_class($this->plots[$i]));
$sc = is_subclass_of($this->plots[$i],'BarPlot') || is_subclass_of($this->plots[$i],'barplot');
if( $c !== 'barplot' && !$sc ) {
$c = get_class($this->plots[$i]);
if( !($this->plots[$i] instanceof BarPlot) ) {
JpGraphError::Raise('One of the objects submitted to GroupBar is not a BarPlot. Make sure that you create the Group Bar plot from an array of BarPlot or AccBarPlot objects. (Class = '.$c.')');
}
$this->plots[$i]->DoLegend($graph);
@ -595,10 +594,11 @@ class GroupBarPlot extends BarPlot {
}
// Stroke all the bars next to each other
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
$tmp=$xscale->off;
$n = count($this->plots);
$subwidth = $this->width/$this->nbrplots ;
for( $i=0; $i < $n; ++$i ) {
$this->plots[$i]->ymin=$this->ybase;
$this->plots[$i]->SetWidth($subwidth);
@ -608,8 +608,7 @@ class GroupBarPlot extends BarPlot {
// If we assume it is always one the positioning will work
// fine with a text scale but this will not work with
// arbitrary linear scale
$xscale->off = $tmp+$i*round(/*$xscale->ticks->major_step* */
$xscale->scale_factor* $subwidth);
$xscale->off = $tmp+$i*round($xscale->scale_factor* $subwidth);
$this->plots[$i]->Stroke($img,$xscale,$yscale);
}
$xscale->off=$tmp;
@ -621,7 +620,7 @@ class GroupBarPlot extends BarPlot {
// Description: Produce accumulated bar plots
//===================================================
class AccBarPlot extends BarPlot {
var $plots=null,$nbrplots=0,$numpoints=0;
private $plots=null,$nbrplots=0;
//---------------
// CONSTRUCTOR
function AccBarPlot($plots) {
@ -641,11 +640,11 @@ class AccBarPlot extends BarPlot {
//---------------
// PUBLIC METHODS
function Legend(&$graph) {
function Legend($graph) {
$n = count($this->plots);
for( $i=$n-1; $i >= 0; --$i ) {
$c = strtolower(get_class($this->plots[$i]));
if( $c !== 'barplot' ) {
$c = get_class($this->plots[$i]);
if( !($this->plots[$i] instanceof BarPlot) ) {
JpGraphError::Raise('One of the objects submitted to AccBar is not a BarPlot. Make sure that you create the AccBar plot from an array of BarPlot objects.(Class='.$c.')');
}
$this->plots[$i]->DoLegend($graph);
@ -668,9 +667,15 @@ class AccBarPlot extends BarPlot {
// individual plots max y-value since that
// would in most cases give to large y-value.
$y=0;
if( !isset($this->plots[0]->coords[0][$i]) ) {
JpGraphError::RaiseL(2014);
}
if( $this->plots[0]->coords[0][$i] > 0 )
$y=$this->plots[0]->coords[0][$i];
for( $j = 1; $j < $this->nbrplots; $j++ ) {
if( !isset($this->plots[$j]->coords[0][$i]) ) {
JpGraphError::RaiseL(2014);
}
if( $this->plots[$j]->coords[0][$i] > 0 )
$y += $this->plots[$j]->coords[0][$i];
}
@ -700,9 +705,12 @@ class AccBarPlot extends BarPlot {
// It would be wrong to just add the
// individual plots max y-value since that
// would in most cases give to large y-value.
$y=$this->plots[0]->coords[0][$i];
$y=0;
if( $this->plots[0]->coords[0][$i] < 0 )
$y=$this->plots[0]->coords[0][$i];
for( $j = 1; $j < $this->nbrplots; $j++ ) {
$y += $this->plots[ $j ]->coords[0][$i];
if( $this->plots[$j]->coords[0][$i] < 0 )
$y += $this->plots[ $j ]->coords[0][$i];
}
$ymin[$i] = $y;
}
@ -714,7 +722,7 @@ class AccBarPlot extends BarPlot {
}
// Stroke acc bar plot
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
$pattern=NULL;
$img->SetLineWeight($this->weight);
for($i=0; $i < $this->numpoints-1; $i++) {
@ -856,6 +864,7 @@ class AccBarPlot extends BarPlot {
if( ! empty($this->plots[$j]->csimtargets[$i]) ) {
$this->csimareas.= '<area shape="poly" coords="'.$csimcoord.'" ';
$this->csimareas.= " href=\"".$this->plots[$j]->csimtargets[$i]."\"";
$sval='';
if( !empty($this->plots[$j]->csimalts[$i]) ) {
$sval=sprintf($this->plots[$j]->csimalts[$i],$this->plots[$j]->coords[0][$i]);
$this->csimareas .= " title=\"$sval\" ";

View File

@ -4,7 +4,7 @@
// Description: Canvas drawing extension for JpGraph
// Created: 2001-01-08
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_canvas.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_canvas.php 626 2006-05-08 19:06:19Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -35,38 +35,62 @@ class CanvasGraph extends Graph {
// Method description
function Stroke($aStrokeFileName="") {
if( $this->texts != null ) {
for($i=0; $i<count($this->texts); ++$i) {
for($i=0; $i < count($this->texts); ++$i) {
$this->texts[$i]->Stroke($this->img);
}
}
if( $this->iTables !== null ) {
for($i=0; $i < count($this->iTables); ++$i) {
$this->iTables[$i]->Stroke($this->img);
}
}
$this->StrokeTitles();
// Should we do any final image transformation
if( $this->iImgTrans ) {
if( !class_exists('ImgTrans') ) {
require_once('jpgraph_imgtrans.php');
// If the filename is the predefined value = '_csim_special_'
// we assume that the call to stroke only needs to do enough
// to correctly generate the CSIM maps.
// We use this variable to skip things we don't strictly need
// to do to generate the image map to improve performance
// a best we can. Therefor you will see a lot of tests !$_csim in the
// code below.
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE);
// We need to know if we have stroked the plot in the
// GetCSIMareas. Otherwise the CSIM hasn't been generated
// and in the case of GetCSIM called before stroke to generate
// CSIM without storing an image to disk GetCSIM must call Stroke.
$this->iHasStroked = true;
if( !$_csim ) {
// Should we do any final image transformation
if( $this->iImgTrans ) {
if( !class_exists('ImgTrans') ) {
require_once('jpgraph_imgtrans.php');
}
$tform = new ImgTrans($this->img->img);
$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist,
$this->iImgTransDirection,$this->iImgTransHighQ,
$this->iImgTransMinSize,$this->iImgTransFillColor,
$this->iImgTransBorder);
}
$tform = new ImgTrans($this->img->img);
$this->img->img = $tform->Skew3D($this->iImgTransHorizon,$this->iImgTransSkewDist,
$this->iImgTransDirection,$this->iImgTransHighQ,
$this->iImgTransMinSize,$this->iImgTransFillColor,
$this->iImgTransBorder);
}
// If the filename is given as the special _IMG_HANDLER
// then the image handler is returned and the image is NOT
// streamed back
if( $aStrokeFileName == _IMG_HANDLER ) {
return $this->img->img;
}
else {
// Finally stream the generated picture
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName);
return true;
// If the filename is given as the special _IMG_HANDLER
// then the image handler is returned and the image is NOT
// streamed back
if( $aStrokeFileName == _IMG_HANDLER ) {
return $this->img->img;
}
else {
// Finally stream the generated picture
$this->cache->PutAndStream($this->img,$this->cache_name,$this->inline,$aStrokeFileName);
return true;
}
}
}
} // Class
/* EOF */
?>

View File

@ -4,7 +4,7 @@
// Description: Some utilities for text and shape drawing on a canvas
// Created: 2002-08-23
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_canvtools.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_canvtools.php 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -23,12 +23,12 @@ DEFINE('CORNER_BOTTOMLEFT',3);
//===================================================
class CanvasScale {
var $g;
var $w,$h;
var $ixmin=0,$ixmax=10,$iymin=0,$iymax=10;
private $g;
private $w,$h;
private $ixmin=0,$ixmax=10,$iymin=0,$iymax=10;
function CanvasScale(&$graph,$xmin=0,$xmax=10,$ymin=0,$ymax=10) {
$this->g = &$graph;
function CanvasScale($graph,$xmin=0,$xmax=10,$ymin=0,$ymax=10) {
$this->g = $graph;
$this->w = $graph->img->width;
$this->h = $graph->img->height;
$this->ixmin = $xmin;
@ -68,12 +68,12 @@ class CanvasScale {
// Description: Methods to draw shapes on canvas
//===================================================
class Shape {
var $img,$scale;
private $img,$scale;
function Shape(&$aGraph,&$scale) {
$this->img = &$aGraph->img;
function Shape($aGraph,$scale) {
$this->img = $aGraph->img;
$this->img->SetColor('black');
$this->scale = &$scale;
$this->scale = $scale;
}
function SetColor($aColor) {
@ -374,11 +374,11 @@ class Shape {
// rounded, possible filled, rectangle.
//===================================================
class CanvasRectangleText {
var $ix,$iy,$iw,$ih,$ir=4;
var $iTxt,$iColor='black',$iFillColor='',$iFontColor='black';
var $iParaAlign='center';
var $iAutoBoxMargin=5;
var $iShadowWidth=3,$iShadowColor='';
private $ix,$iy,$iw,$ih,$ir=4;
private $iTxt,$iColor='black',$iFillColor='',$iFontColor='black';
private $iParaAlign='center';
private $iAutoBoxMargin=5;
private $iShadowWidth=3,$iShadowColor='';
function CanvasRectangleText($aTxt='',$xl=0,$yt=0,$w=0,$h=0) {
$this->iTxt = new Text($aTxt);

View File

@ -4,7 +4,7 @@
// Description: Classes to handle Date scaling
// Created: 2005-05-02
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_date.php 220 2005-10-15 16:53:53Z ljp $
// Ver: $Id: jpgraph_date.php 573 2006-03-04 10:41:59Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -48,9 +48,9 @@ DEFINE('SECPERMIN',60);
class DateScale extends LinearScale {
var $date_format = '';
var $iStartAlign = false, $iEndAlign = false;
var $iStartTimeAlign = false, $iEndTimeAlign = false;
private $date_format = '';
private $iStartAlign = false, $iEndAlign = false;
private $iStartTimeAlign = false, $iEndTimeAlign = false;
//---------------
// CONSTRUCTOR
@ -377,6 +377,7 @@ class DateScale extends LinearScale {
// Overrides the automatic determined date format. Must be a valid date() format string
function SetDateFormat($aFormat) {
$this->date_format = $aFormat;
$this->ticks->SetLabelDateFormat($this->date_format);
}
function SetDateAlign($aStartAlign,$aEndAlign=false) {
@ -396,7 +397,9 @@ class DateScale extends LinearScale {
}
function AutoScale(&$img,$aStartTime,$aEndTime,$aNumSteps) {
function AutoScale($img,$aStartTime,$aEndTime,$aNumSteps,$_adummy=false) {
// We need to have one dummy argument to make the signature of AutoScale()
// identical to LinearScale::AutoScale
if( $aStartTime == $aEndTime ) {
// Special case when we only have one data point.
// Create a small artifical intervall to do the autoscaling
@ -427,7 +430,8 @@ class DateScale extends LinearScale {
*/
if( $this->iStartTimeAlign !== false && $this->iStartAlign !== false ) {
JpGraphError::Raise('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both');
JpGraphError::RaiseL(3001);
//('It is only possible to use either SetDateAlign() or SetTimeAlign() but not both');
}
if( $this->iStartTimeAlign !== false ) {

View File

@ -4,7 +4,7 @@
// Description: Error plot extension for JpGraph
// Created: 2001-01-08
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_error.php 88 2005-08-07 17:18:51Z ljp $
// Ver: $Id: jpgraph_error.php 462 2006-02-04 12:07:05Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -16,10 +16,10 @@
// each datapoint
//===================================================
class ErrorPlot extends Plot {
var $errwidth=2;
private $errwidth=2;
//---------------
// CONSTRUCTOR
function ErrorPlot(&$datay,$datax=false) {
function ErrorPlot($datay,$datax=false) {
$this->Plot($datay,$datax);
$this->numpoints /= 2;
}
@ -27,7 +27,7 @@ class ErrorPlot extends Plot {
// PUBLIC METHODS
// Gets called before any axis are stroked
function PreStrokeAdjust(&$graph) {
function PreStrokeAdjust($graph) {
if( $this->center ) {
$a=0.5; $b=0.5;
++$this->numpoints;
@ -40,14 +40,15 @@ class ErrorPlot extends Plot {
}
// Method description
function Stroke(&$img,&$xscale,&$yscale) {
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::Raise("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$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
$exist_x = true;
}
@ -84,10 +85,10 @@ class ErrorPlot extends Plot {
// BACKWARD COMPATIBILITY
//===================================================
class ErrorLinePlot extends ErrorPlot {
var $line=null;
public $line=null;
//---------------
// CONSTRUCTOR
function ErrorLinePlot(&$datay,$datax=false) {
function ErrorLinePlot($datay,$datax=false) {
$this->ErrorPlot($datay,$datax);
// Calculate line coordinates as the average of the error limits
$n = count($datay);
@ -99,13 +100,13 @@ class ErrorLinePlot extends ErrorPlot {
//---------------
// PUBLIC METHODS
function Legend(&$graph) {
function Legend($graph) {
if( $this->legend != "" )
$graph->legend->Add($this->legend,$this->color);
$this->line->Legend($graph);
}
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
parent::Stroke($img,$xscale,$yscale);
$this->line->Stroke($img,$xscale,$yscale);
}
@ -117,16 +118,16 @@ class ErrorLinePlot extends ErrorPlot {
// Description: Combine a line and error plot
//===================================================
class LineErrorPlot extends ErrorPlot {
var $line=null;
public $line=null;
//---------------
// CONSTRUCTOR
// Data is (val, errdeltamin, errdeltamax)
function LineErrorPlot(&$datay,$datax=false) {
function LineErrorPlot($datay,$datax=false) {
$ly=array(); $ey=array();
$n = count($datay);
if( $n % 3 != 0 ) {
JpGraphError::Raise('Error in input data to LineErrorPlot.'.
'Number of data points must be a multiple of 3');
JpGraphError::RaiseL(4002);
//('Error in input data to LineErrorPlot. Number of data points must be a multiple of 3');
}
for($i=0; $i < $n; $i+=3 ) {
$ly[]=$datay[$i];
@ -139,13 +140,13 @@ class LineErrorPlot extends ErrorPlot {
//---------------
// PUBLIC METHODS
function Legend(&$graph) {
function Legend($graph) {
if( $this->legend != "" )
$graph->legend->Add($this->legend,$this->color);
$this->line->Legend($graph);
}
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
parent::Stroke($img,$xscale,$yscale);
$this->line->Stroke($img,$xscale,$yscale);
}

View File

@ -4,7 +4,7 @@
// Description: Class Jpfile. Handles plotmarks
// Created: 2003-06-28
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_flags.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_flags.php 472 2006-02-04 12:13:48Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -19,7 +19,7 @@ DEFINE('FLAGSIZE4',4);
class FlagImages {
var $iCountryNameMap = array(
private $iCountryNameMap = array(
'Afghanistan' => 'afgh',
'Republic of Angola' => 'agla',
'Republic of Albania' => 'alba',
@ -188,6 +188,7 @@ class FlagImages {
'Republic of Palau' => 'pala',
'Independent State of Papua New Guinea' => 'pang',
'Republic of Paraguay' => 'para',
'Republic of Peru' => 'peru',
'Republic of the Philippines' => 'phil',
'British Overseas Territory of the Pitcairn Islands' => 'piis',
'Republic of Poland' => 'pola',
@ -253,16 +254,16 @@ class FlagImages {
'Republic of Zimbabwe' => 'zbwe' ) ;
var $iFlagCount = -1;
var $iFlagSetMap = array(
private $iFlagCount = -1;
private $iFlagSetMap = array(
FLAGSIZE1 => 'flags_thumb35x35',
FLAGSIZE2 => 'flags_thumb60x60',
FLAGSIZE3 => 'flags_thumb100x100',
FLAGSIZE4 => 'flags'
);
var $iFlagData ;
var $iOrdIdx=array();
private $iFlagData ;
private $iOrdIdx=array();
function FlagImages($aSize=FLAGSIZE1) {
switch($aSize) {
@ -276,8 +277,8 @@ class FlagImages {
$this->iFlagData = unserialize($rawdata);
break;
default:
JpGraphError::Raise('Unknown flag size. ('.$aSize.')');
die();
JpGraphError::RaiseL(5001,$aSize);
//('Unknown flag size. ('.$aSize.')');
}
$this->iFlagCount = count($this->iCountryNameMap);
}
@ -297,7 +298,8 @@ class FlagImages {
return Image::CreateFromString($d);
}
else {
JpGraphError::Raise("Flag index \" $aIdx\" does not exist.");
JpGraphError::RaiseL(5002,$aIdx);
//("Flag index \" $aIdx\" does not exist.");
}
}
@ -322,7 +324,8 @@ class FlagImages {
return $tmp[0];
}
else {
JpGraphError::Raise('Invalid ordinal number specified for flag index.');
JpGraphError::RaiseL(5003,$aOrd);
//('Invalid ordinal number specified for flag index.');
}
}
@ -359,7 +362,8 @@ class FlagImages {
return $val;
}
else {
JpGraphError::Raise("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\".");
JpGraphError::RaiseL(5004,$aName);
//("The (partial) country name \"$aName\" does not have a cooresponding flag image. The flag may still exist but under another name, e.g. insted of \"usa\" try \"united states\".");
}
}
}

View File

@ -4,7 +4,7 @@
// Description: JpGraph Gantt plot extension
// Created: 2001-11-12
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_gantt.php 286 2005-11-28 22:09:25Z ljp $
// Ver: $Id: jpgraph_gantt.php 587 2006-03-04 18:57:09Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -12,7 +12,7 @@
require_once('jpgraph_plotband.php');
require_once('jpgraph_iconplot.php');
require_once('jpgraph_plotmark.inc');
require_once('jpgraph_plotmark.inc.php');
// Maximum size for Automatic Gantt chart
DEFINE('MAX_GANTTIMG_SIZE_W',4000);
@ -141,17 +141,17 @@ if (!function_exists('array_fill')) {
// Description:
//===================================================
class GanttActivityInfo {
var $iColor='black';
var $iBackgroundColor='lightgray';
var $iFFamily=FF_FONT1,$iFStyle=FS_NORMAL,$iFSize=10,$iFontColor='black';
var $iTitles=array();
var $iWidth=array(),$iHeight=-1;
var $iLeftColMargin=4,$iRightColMargin=1,$iTopColMargin=1,$iBottomColMargin=3;
var $iTopHeaderMargin = 4;
var $vgrid = null;
var $iStyle=1;
var $iShow=true;
var $iHeaderAlign='center';
public $iShow=true;
public $iLeftColMargin=4,$iRightColMargin=1,$iTopColMargin=1,$iBottomColMargin=3;
public $vgrid = null;
private $iColor='black';
private $iBackgroundColor='lightgray';
private $iFFamily=FF_FONT1,$iFStyle=FS_NORMAL,$iFSize=10,$iFontColor='black';
private $iTitles=array();
private $iWidth=array(),$iHeight=-1;
private $iTopHeaderMargin = 4;
private $iStyle=1;
private $iHeaderAlign='center';
function GanttActivityInfo() {
$this->vgrid = new LineProperty();
@ -236,12 +236,12 @@ class GanttActivityInfo {
return $w;
}
function GetColStart($aImg,&$ioStart,$aAddLeftMargin=false) {
function GetColStart($aImg,&$aStart,$aAddLeftMargin=false) {
$n = count($this->iTitles) ;
$adj = $aAddLeftMargin ? $this->iLeftColMargin : 0;
$ioStart=array($aImg->left_margin+$adj);
$aStart=array($aImg->left_margin+$adj);
for( $i=1; $i < $n; ++$i ) {
$ioStart[$i] = $ioStart[$i-1]+$this->iLeftColMargin+$this->iWidth[$i-1];
$aStart[$i] = $aStart[$i-1]+$this->iLeftColMargin+$this->iWidth[$i-1];
}
}
@ -268,7 +268,8 @@ class GanttActivityInfo {
$yTop = $aUseTextHeight ? $aYBottom-$h-$this->iTopColMargin-$this->iBottomColMargin : $aYTop ;
if( $h < 0 ) {
JpGraphError::Raise('Internal error. Height for ActivityTitles is < 0');
JpGraphError::RaiseL(6001);
//('Internal error. Height for ActivityTitles is < 0');
}
$aImg->SetLineWeight(1);
@ -329,16 +330,16 @@ class GanttActivityInfo {
// Description: Main class to handle gantt graphs
//===================================================
class GanttGraph extends Graph {
var $scale; // Public accessible
var $iObj=array(); // Gantt objects
var $iLabelHMarginFactor=0.2; // 10% margin on each side of the labels
var $iLabelVMarginFactor=0.4; // 40% margin on top and bottom of label
var $iLayout=GANTT_FROMTOP; // Could also be GANTT_EVEN
var $iSimpleFont = FF_FONT1,$iSimpleFontSize=11;
var $iSimpleStyle=GANTT_RDIAG,$iSimpleColor='yellow',$iSimpleBkgColor='red';
var $iSimpleProgressBkgColor='gray',$iSimpleProgressColor='darkgreen';
var $iSimpleProgressStyle=GANTT_SOLID;
var $hgrid=null;
public $scale; // Public accessible
public $hgrid=null;
private $iObj=array(); // Gantt objects
private $iLabelHMarginFactor=0.2; // 10% margin on each side of the labels
private $iLabelVMarginFactor=0.4; // 40% margin on top and bottom of label
private $iLayout=GANTT_FROMTOP; // Could also be GANTT_EVEN
private $iSimpleFont = FF_FONT1,$iSimpleFontSize=11;
private $iSimpleStyle=GANTT_RDIAG,$iSimpleColor='yellow',$iSimpleBkgColor='red';
private $iSimpleProgressBkgColor='gray',$iSimpleProgressColor='darkgreen';
private $iSimpleProgressStyle=GANTT_SOLID;
//---------------
// CONSTRUCTOR
// Create a new gantt graph
@ -349,7 +350,8 @@ class GanttGraph extends Graph {
if( $aHeight == -1 ) $aHeight=0;
if( $aWidth< 0 || $aHeight < 0 ) {
JpgraphError::Raise("You can't specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.");
JpgraphError::RaiseL(6002);
//("You can't specify negative sizes for Gantt graph dimensions. Use 0 to indicate that you want the library to automatically determine a dimension.");
}
Graph::Graph($aWidth,$aHeight,$aCachedName,$aTimeOut,$aInline);
$this->scale = new GanttScale($this->img);
@ -414,7 +416,8 @@ class GanttGraph extends Graph {
$n = count($constrains);
for( $j=0; $j < $n; ++$j ) {
if( empty($constrains[$j]) || (count($constrains[$j]) != 3) ) {
JpGraphError::Raise("Invalid format for Constrain parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)");
JpGraphError::RaiseL(6003,$j);
//("Invalid format for Constrain parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Constrain-To,Constrain-Type)");
}
if( $constrains[$j][0]==$data[$i][0] ) {
$a->SetConstrain($constrains[$j][1],$constrains[$j][2],'black',ARROW_S2,ARROWT_SOLID);
@ -426,11 +429,11 @@ class GanttGraph extends Graph {
for( $j=0; $j < $n; ++$j ) {
if( empty($progress[$j]) || (count($progress[$j]) != 2) ) {
JpGraphError::Raise("Invalid format for Progress parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)");
JpGraphError::RaiseL(6004,$j);
//("Invalid format for Progress parameter at index=$j in CreateSimple(). Parameter must start with index 0 and contain arrays of (Row,Progress)");
}
if( $progress[$j][0]==$data[$i][0] ) {
$a->progress->Set($progress[$j][1]);
$a->progress->SetHeight(0.5);
$a->progress->SetPattern($this->iSimpleProgressStyle,
$this->iSimpleProgressColor);
$a->progress->SetFillColor($this->iSimpleProgressBkgColor);
@ -490,8 +493,8 @@ class GanttGraph extends Graph {
// Add a new Gantt object
function Add($aObject) {
if( is_array($aObject) && count($aObject) > 0 ) {
$cl = get_class($aObject[0]);
if( $cl == 'iconplot' ) {
$cl = $aObject[0];
if( class_exists('IconPlot',false) && ($cl instanceof IconPlot) ) {
$this->AddIcon($aObject);
}
else {
@ -501,8 +504,7 @@ class GanttGraph extends Graph {
}
}
else {
$cl = get_class($aObject);
if( $cl == 'iconplot' ) {
if( class_exists('IconPlot',false) && ($aObject instanceof IconPlot) ) {
$this->AddIcon($aObject);
}
else {
@ -512,8 +514,9 @@ class GanttGraph extends Graph {
}
// Override inherit method from Graph and give a warning message
function SetScale() {
JpGraphError::Raise("SetScale() is not meaningfull with Gantt charts.");
function SetScale($aAxisType,$aYMin=1,$aYMax=1,$aXMin=1,$aXMax=1) {
JpGraphError::RaiseL(6005);
//("SetScale() is not meaningfull with Gantt charts.");
}
// Specify the date range for Gantt graphs (if this is not set it will be
@ -533,12 +536,11 @@ class GanttGraph extends Graph {
// multiple columns in the label section. When this was first written
// it only supported a single label, hence the name.
function GetMaxLabelWidth() {
$m=50;
$m=10;
if( $this->iObj != null ) {
$marg = $this->scale->actinfo->iLeftColMargin+$this->scale->actinfo->iRightColMargin;
$m = $this->iObj[0]->title->GetWidth($this->img)+$marg;
$n = count($this->iObj);
for($i=1; $i < $n; ++$i) {
$n = count($this->iObj);
for($i=0; $i < $n; ++$i) {
if( !empty($this->iObj[$i]->title) ) {
if( $this->iObj[$i]->title->HasTabs() ) {
list($tot,$w) = $this->iObj[$i]->title->GetWidth($this->img,true);
@ -554,11 +556,10 @@ class GanttGraph extends Graph {
// Get the maximum height of the titles for the bars
function GetMaxLabelHeight() {
$m=0;
$m=10;
if( $this->iObj != null ) {
$m = $this->iObj[0]->title->GetHeight($this->img);
$n = count($this->iObj);
for($i=1; $i < $n; ++$i) {
for($i=0; $i < $n; ++$i) {
if( !empty($this->iObj[$i]->title) ) {
$m=max($m,$this->iObj[$i]->title->GetHeight($this->img));
}
@ -581,7 +582,7 @@ class GanttGraph extends Graph {
// Get the maximum used line number (vertical position) for bars
function GetBarMaxLineNumber() {
$m=0;
$m=1;
if( $this->iObj != null ) {
$m = $this->iObj[0]->GetLineNbr();
$n = count($this->iObj);
@ -596,11 +597,11 @@ class GanttGraph extends Graph {
function GetBarMinMax() {
$start = 0 ;
$n = count($this->iObj);
while( $start < $n && $this->iObj[$start]->GetMaxDate() === false )
++$start;
if( $start >= $n ) {
JpgraphError::Raise('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]');
JpgraphError::RaiseL(6006);
//('Cannot autoscale Gantt chart. No dated activities exist. [GetBarMinMax() start >= n]');
}
$max=$this->scale->NormalizeDate($this->iObj[$start]->GetMaxDate());
@ -626,6 +627,7 @@ class GanttGraph extends Graph {
// the minimum width needed to display the headers. Some margins are
// also added to make it better looking.
function AutoSize() {
if( $this->img->img == null ) {
// The predefined left, right, top, bottom margins.
// Note that the top margin might incease depending on
@ -842,14 +844,12 @@ class GanttGraph extends Graph {
}
}
// Has the user specified a width or do we need to
// determine it?
$cw = $this->GetMaxActInfoColWidth() ;
$this->scale->actinfo->SetMinColWidth($cw);
if( $this->img->width <= 0 ) {
// Now determine the width for the activity titles column
// Firdst find out the maximum width of each object column
$cw = $this->GetMaxActInfoColWidth() ;
$this->scale->actinfo->SetMinColWidth($cw);
$titlewidth = max(max($this->GetMaxLabelWidth(),
$this->scale->tableTitle->GetWidth($this->img)),
$this->scale->actinfo->GetWidth($this->img));
@ -863,15 +863,17 @@ class GanttGraph extends Graph {
// into account
$width = $titlewidth + $nd*$fw + $lm+$rm;
}
else
else {
$width = $this->img->width;
}
$width = round($width);
$height = round($height);
// Make a sanity check on image size
if( $width > MAX_GANTTIMG_SIZE_W || $height > MAX_GANTTIMG_SIZE_H ) {
JpgraphError::Raise("Sanity check for automatic Gantt chart size failed. Either the width (=$width) or height (=$height) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities.");
JpgraphError::RaiseL(6007,$width,$height);
//("Sanity check for automatic Gantt chart size failed. Either the width (=$width) or height (=$height) is larger than MAX_GANTTIMG_SIZE. This could potentially be caused by a wrong date in one of the activities.");
}
$this->img->CreateImgCanvas($width,$height);
$this->img->SetMargin($lm,$rm,$tm,$bm);
}
@ -903,7 +905,6 @@ class GanttGraph extends Graph {
// Stroke the gantt chart
function Stroke($aStrokeFileName="") {
// If the filename is the predefined value = '_csim_special_'
// we assume that the call to stroke only needs to do enough
// to correctly generate the CSIM maps.
@ -914,6 +915,7 @@ class GanttGraph extends Graph {
$_csim = ($aStrokeFileName===_CSIM_SPECIALFILE);
// Should we autoscale dates?
if( !$this->scale->IsRangeSet() ) {
list($min,$max) = $this->GetBarMinMax();
$this->scale->SetRange($min,$max);
@ -972,13 +974,14 @@ class GanttGraph extends Graph {
$this->StrokeConstrains();
$this->footer->Stroke($this->img);
if( $this->iIconDepth == DEPTH_FRONT) {
$this->StrokeIcons();
}
// Should we do any final image transformation
if( $this->iImgTrans ) {
if( !class_exists('ImgTrans') ) {
if( !class_exists('ImgTrans',false) ) {
require_once('jpgraph_imgtrans.php');
}
@ -1029,10 +1032,8 @@ class GanttGraph extends Graph {
}
}
if( $targetobj == -1 ) {
JpGraphError::Raise('You have specifed a constrain from row='.
$this->iObj[$i]->iVPos.
' to row='.$vpos.' which does not have any activity.');
exit();
JpGraphError::RaiseL(6008,$this->iObj[$i]->iVPos,$vpos);
//('You have specifed a constrain from row='.$this->iObj[$i]->iVPos.' to row='.$vpos.' which does not have any activity.');
}
$c2 = $this->iObj[$targetobj]->iConstrainPos;
if( count($c1) == 4 && count($c2 ) == 4) {
@ -1074,9 +1075,8 @@ class GanttGraph extends Graph {
$link->SetPath(3);
break;
default:
JpGraphError::Raise('Unknown constrain type specified from row='.
$this->iObj[$i]->iVPos.
' to row='.$vpos);
JpGraphError::RaiseL(6009,$this->iObj[$i]->iVPos,$vpos);
//('Unknown constrain type specified from row='.$this->iObj[$i]->iVPos.' to row='.$vpos);
break;
}
@ -1125,8 +1125,7 @@ DEFINE('GICON_FOLDER',11);
DEFINE('GICON_TEXTIMPORTANT',12);
class PredefIcons {
var $iBuiltinIcon = null;
var $iLen = -1 ;
private $iBuiltinIcon = null, $iLen = -1 ;
function GetLen() {
return $this->iLen ;
@ -1134,7 +1133,8 @@ class PredefIcons {
function GetImg($aIdx) {
if( $aIdx < 0 || $aIdx >= $this->iLen ) {
JpGraphError::Raise('Illegal icon index for Gantt builtin icon ['.$aIdx.']');
JpGraphError::RaiseL(6010,$aIdx);
//('Illegal icon index for Gantt builtin icon ['.$aIdx.']');
}
return Image::CreateFromString(base64_decode($this->iBuiltinIcon[$aIdx][1]));
}
@ -1430,10 +1430,10 @@ $_gPredefIcons = new PredefIcons();
// Description: Holds properties for an icon image
//===================================================
class IconImage {
var $iGDImage=null;
var $iWidth,$iHeight;
var $ixalign='left',$iyalign='center';
var $iScale=1.0;
private $iGDImage=null;
private $iWidth,$iHeight;
private $ixalign='left',$iyalign='center';
private $iScale=1.0;
function IconImage($aIcon,$aScale=1) {
GLOBAL $_gPredefIcons ;
@ -1445,7 +1445,8 @@ class IconImage {
$this->iGDImage = $_gPredefIcons->GetImg($aIcon);
}
else {
JpGraphError::Raise('Argument to IconImage must be string or integer');
JpGraphError::RaiseL(6011);
//('Argument to IconImage must be string or integer');
}
$this->iScale = $aScale;
$this->iWidth = Image::GetWidth($this->iGDImage);
@ -1496,12 +1497,12 @@ class IconImage {
// Description: Holds properties for a text
//===================================================
class TextProperty {
var $iFFamily=FF_FONT1,$iFStyle=FS_NORMAL,$iFSize=10;
var $iColor="black";
var $iShow=true;
var $iText="";
var $iHAlign="left",$iVAlign="bottom";
var $csimtarget='',$csimalt='';
public $iShow=true;
public $csimtarget='',$csimalt='';
private $iFFamily=FF_FONT1,$iFStyle=FS_NORMAL,$iFSize=10;
private $iColor="black";
private $iText="";
private $iHAlign="left",$iVAlign="bottom";
//---------------
// CONSTRUCTOR
@ -1581,14 +1582,14 @@ class TextProperty {
// tabs then return both the total width as well as an array with a
// width for each column.
function GetWidth($aImg,$aUseTabs=false,$aTabExtraMargin=1.1) {
$errmsg = 'Unknown type in Gantt object title specification';
$extra_margin=4;
$aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
if( is_string($this->iText) ) {
if( strlen($this->iText) == 0 ) return 0;
$tmp = split("\t",$this->iText);
if( count($tmp) <= 1 || !$aUseTabs ) {
return $aImg->GetTextWidth($this->iText)+2*$extra_margin;
$w = $aImg->GetTextWidth($this->iText);
return $w + 2*$extra_margin;
}
else {
$tot=0;
@ -1615,7 +1616,7 @@ class TextProperty {
}
else {
if( is_object($tmp) === false ) {
JpGraphError::Raise($errmsg);
JpGraphError::RaiseL(6012);
}
$w += $tmp->GetWidth()+$extra_margin;
}
@ -1623,7 +1624,7 @@ class TextProperty {
return $w;
}
else {
JpGraphError::Raise($errmsg);
JpGraphError::RaiseL(6012);
}
}
@ -1631,7 +1632,6 @@ class TextProperty {
// column individually. If there is no columns just return the width of the single
// column as an array of one
function GetColWidth($aImg,$aMargin=0) {
$errmsg = 'Unknown type in Gantt object title specification';
$aImg->SetFont($this->iFFamily,$this->iFStyle,$this->iFSize);
if( is_array($this->iText) ) {
$n = count($this->iText);
@ -1642,7 +1642,7 @@ class TextProperty {
}
else {
if( is_object($tmp) === false ) {
JpGraphError::Raise($errmsg);
JpGraphError::RaiseL(6012);
}
$w[$i] = $tmp->GetWidth()+$aMargin;
}
@ -1726,15 +1726,16 @@ class TextProperty {
// for each type of the scale headers
//===================================================
class HeaderProperty {
var $iTitleVertMargin=3,$iFFamily=FF_FONT0,$iFStyle=FS_NORMAL,$iFSize=8;
var $iFrameColor="black",$iFrameWeight=1;
var $iShowLabels=true,$iShowGrid=true;
var $iBackgroundColor="white";
var $iWeekendBackgroundColor="lightgray",$iSundayTextColor="red"; // these are only used with day scale
var $iTextColor="black";
var $iLabelFormStr="%d";
var $grid,$iStyle=0;
var $iIntervall = 1;
public $grid;
public $iShowLabels=true,$iShowGrid=true;
public $iTitleVertMargin=3,$iFFamily=FF_FONT0,$iFStyle=FS_NORMAL,$iFSize=8;
public $iStyle=0;
public $iFrameColor="black",$iFrameWeight=1;
public $iBackgroundColor="white";
public $iWeekendBackgroundColor="lightgray",$iSundayTextColor="red"; // these are only used with day scale
public $iTextColor="black";
public $iLabelFormStr="%d";
public $iIntervall = 1;
//---------------
// CONSTRUCTOR
@ -1830,31 +1831,32 @@ class HeaderProperty {
// date headers (days, week, etc).
//===================================================
class GanttScale {
var $minute,$hour,$day,$week,$month,$year;
var $divider,$dividerh,$tableTitle;
var $iStartDate=-1,$iEndDate=-1;
public $minute,$hour,$day,$week,$month,$year;
public $divider,$dividerh,$tableTitle;
public $iStartDate=-1,$iEndDate=-1;
// Number of gantt bar position (n.b not necessariliy the same as the number of bars)
// we could have on bar in position 1, and one bar in position 5 then there are two
// bars but the number of bar positions is 5
var $iVertLines=-1;
public $actinfo;
public $iTopPlotMargin=10,$iBottomPlotMargin=15;
public $iVertLines=-1;
public $iVertHeaderSize=-1;
// The width of the labels (defaults to the widest of all labels)
var $iLabelWidth;
private $iLabelWidth;
// Out image to stroke the scale to
var $iImg;
var $iTableHeaderBackgroundColor="white",$iTableHeaderFrameColor="black";
var $iTableHeaderFrameWeight=1;
var $iAvailableHeight=-1,$iVertSpacing=-1,$iVertHeaderSize=-1;
var $iDateLocale;
var $iVertLayout=GANTT_EVEN;
var $iTopPlotMargin=10,$iBottomPlotMargin=15;
var $iUsePlotWeekendBackground=true;
var $iWeekStart = 1; // Default to have weekends start on Monday
var $actinfo;
private $iImg;
private $iTableHeaderBackgroundColor="white",$iTableHeaderFrameColor="black";
private $iTableHeaderFrameWeight=1;
private $iAvailableHeight=-1,$iVertSpacing=-1;
private $iDateLocale;
private $iVertLayout=GANTT_EVEN;
private $iUsePlotWeekendBackground=true;
private $iWeekStart = 1; // Default to have weekends start on Monday
//---------------
// CONSTRUCTOR
function GanttScale(&$aImg) {
$this->iImg = &$aImg;
function GanttScale($aImg) {
$this->iImg = $aImg;
$this->iDateLocale = new DateLocale();
$this->minute = new HeaderProperty();
@ -2116,7 +2118,7 @@ class GanttScale {
// Credit to Nicolas Hoizey <nhoizey@phpheaven.net> for this elegant
// version of Week Nbr calculation.
$day = $this->NormalizeDate($aDate) ;
$day = $this->NormalizeDate($aDate);
if( $aSunStart )
$day += 60*60*24;
@ -2212,7 +2214,8 @@ class GanttScale {
$img=$this->iImg;
$ph=$this->iAvailableHeight;
if( $aPos > $this->iVertLines )
JpGraphError::Raise("Illegal vertical position $aPos");
JpGraphError::RaiseL(6015,$aPos);
// 'Illegal vertical position %d'
if( $this->iVertLayout == GANTT_EVEN ) {
// Position the top bar at 1 vert spacing from the scale
return round($img->top_margin + $this->iVertHeaderSize + ($aPos+1)*$this->iVertSpacing);
@ -2234,14 +2237,16 @@ class GanttScale {
if( is_string($aDate) ) {
$t = strtotime($aDate);
if( $t === FALSE || $t === -1 ) {
JpGraphError::Raise("Date string ($aDate) specified for Gantt activity can not be interpretated. Please make sure it is a valid time string, e.g. 2005-04-23 13:30");
JpGraphError::RaiseL(6016,$aDate);
//("Date string ($aDate) specified for Gantt activity can not be interpretated. Please make sure it is a valid time string, e.g. 2005-04-23 13:30");
}
return $t;
}
elseif( is_int($aDate) || is_float($aDate) )
return $aDate;
else
JpGraphError::Raise("Unknown date format in GanttScale ($aDate).");
JpGraphError::RaiseL(6017,$aDate);
//Unknown date format in GanttScale ($aDate).");
}
@ -2285,7 +2290,8 @@ class GanttScale {
$minint = $this->minute->GetIntervall() ;
if( 60 % $minint !== 0 ) {
JpGraphError::Raise('Intervall for minutes must divide the hour evenly, e.g. 1,5,10,12,15,20,30 etc You have specified an intervall of '.$minint.' minutes.');
JpGraphError::RaiseL(6018,$minint);
//'Intervall for minutes must divide the hour evenly, e.g. 1,5,10,12,15,20,30 etc You have specified an intervall of '.$minint.' minutes.');
}
@ -2294,7 +2300,8 @@ class GanttScale {
$width = $this->GetHourWidth() / $n ;
if( $width < 8 ) {
// TO small width to draw minute scale
JpGraphError::Raise('The available width ('.$width.') for minutes are to small for this scale to be displayed. Please use auto-sizing or increase the width of the graph.');
JpGraphError::RaiseL(6019,$width);
//('The available width ('.$width.') for minutes are to small for this scale to be displayed. Please use auto-sizing or increase the width of the graph.');
}
$nh = ceil(24*60 / $this->TimeToMinutes($this->hour->GetIntervall()) );
@ -2379,7 +2386,8 @@ class GanttScale {
$tmp = $this->hour->GetIntervall() ;
$minint = $this->TimeToMinutes($tmp);
if( 1440 % $minint !== 0 ) {
JpGraphError::Raise('Intervall for hours must divide the day evenly, e.g. 0:30, 1:00, 1:30, 4:00 etc. You have specified an intervall of '.$tmp);
JpGraphError::RaiseL(6020,$tmp);
//('Intervall for hours must divide the day evenly, e.g. 0:30, 1:00, 1:30, 4:00 etc. You have specified an intervall of '.$tmp);
}
$n = ceil(24*60 / $minint );
@ -2598,7 +2606,8 @@ class GanttScale {
$txtOffset = 3;
}
else
JpGraphError::Raise("Unknown formatting style for week.");
JpGraphError::RaiseL(6021);
//("Unknown formatting style for week.");
for($i=0; $i<$this->GetNumberOfDays()/7; ++$i, $x+=$weekwidth) {
$img->PushColor($this->week->iTextColor);
@ -2848,12 +2857,14 @@ class GanttScale {
// Main entry point to stroke scale
function Stroke() {
if( !$this->IsRangeSet() )
JpGraphError::Raise("Gantt scale has not been specified.");
JpGraphError::RaiseL(6022);
//("Gantt scale has not been specified.");
$img=$this->iImg;
// If minutes are displayed then hour interval must be 1
if( $this->IsDisplayMinute() && $this->hour->GetIntervall() > 1 ) {
JpGraphError::Raise('If you display both hour and minutes the hour intervall must be 1 (Otherwise it doesn\' make sense to display minutes).');
JpGraphError::RaiseL(6023);
//('If you display both hour and minutes the hour intervall must be 1 (Otherwise it doesn\' make sense to display minutes).');
}
// Stroke all headers. As argument we supply the offset from the
@ -2895,11 +2906,11 @@ class GanttScale {
// Just a structure to store all the values for a constraint
//===================================================
class GanttConstraint {
var $iConstrainType;
var $iConstrainRow;
var $iConstrainColor;
var $iConstrainArrowSize;
var $iConstrainArrowType;
public $iConstrainRow;
public $iConstrainType;
public $iConstrainColor;
public $iConstrainArrowSize;
public $iConstrainArrowType;
//---------------
// CONSTRUCTOR
@ -2918,15 +2929,14 @@ class GanttConstraint {
// The common signature for a Gantt object
//===================================================
class GanttPlotObject {
var $iVPos=0; // Vertical position
var $iLabelLeftMargin=2; // Title margin
var $iStart=""; // Start date
var $title,$caption;
var $iCaptionMargin=5;
var $csimarea='',$csimtarget='',$csimalt='';
var $constraints = array();
var $iConstrainPos=array();
public $title,$caption;
public $csimarea='',$csimtarget='',$csimalt='';
public $constraints = array();
public $iCaptionMargin=5;
public $iConstrainPos=array();
protected $iStart=""; // Start date
public $iVPos=0; // Vertical position
protected $iLabelLeftMargin=2; // Title margin
function GanttPlotObject() {
$this->title = new TextProperty();
@ -2941,11 +2951,13 @@ class GanttPlotObject {
function SetCSIMTarget($aTarget,$aAlt='') {
if( !is_string($aTarget) ) {
$tv = substr(var_export($aTarget,true),0,40);
JpGraphError::Raise('CSIM Target must be specified as a string.'."\nStart of target is:\n$tv");
JpGraphError::RaiseL(6024,$tv);
//('CSIM Target must be specified as a string.'."\nStart of target is:\n$tv");
}
if( !is_string($aAlt) ) {
$tv = substr(var_export($aAlt,true),0,40);
JpGraphError::Raise('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv");
JpGraphError::RaiseL(6025,$tv);
//('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv");
}
$this->csimtarget=$aTarget;
@ -2955,7 +2967,8 @@ class GanttPlotObject {
function SetCSIMAlt($aAlt) {
if( !is_string($aAlt) ) {
$tv = substr(var_export($aAlt,true),0,40);
JpGraphError::Raise('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv");
JpGraphError::RaiseL(6025,$tv);
//('CSIM Alt text must be specified as a string.'."\nStart of alt text is:\n$tv");
}
$this->csimalt=$aAlt;
}
@ -3011,13 +3024,15 @@ class GanttPlotObject {
// displyed within a bar
//===================================================
class Progress {
var $iProgress=-1, $iColor="black", $iFillColor='black';
var $iPattern=GANTT_SOLID;
var $iDensity=98, $iHeight=0.65;
public $iProgress=-1;
public $iPattern=GANTT_SOLID;
public $iColor="black", $iFillColor='black';
public $iDensity=98, $iHeight=0.65;
function Set($aProg) {
if( $aProg < 0.0 || $aProg > 1.0 )
JpGraphError::Raise("Progress value must in range [0, 1]");
JpGraphError::RaiseL(6027);
//("Progress value must in range [0, 1]");
$this->iProgress = $aProg;
}
@ -3044,11 +3059,11 @@ DEFINE('GANTT_HGRID2',1);
// Responsible for drawinf horizontal gridlines and filled alternatibg rows
//===================================================
class HorizontalGridLine {
var $iGraph=NULL;
var $iRowColor1 = '', $iRowColor2 = '';
var $iShow=false;
var $line=null;
var $iStart=0; // 0=from left margin, 1=just along header
private $iGraph=NULL;
private $iRowColor1 = '', $iRowColor2 = '';
private $iShow=false;
private $line=null;
private $iStart=0; // 0=from left margin, 1=just along header
function HorizontalGridLine() {
$this->line = new LineProperty();
@ -3123,13 +3138,13 @@ class HorizontalGridLine {
// Responsible for formatting individual gantt bars
//===================================================
class GanttBar extends GanttPlotObject {
var $iEnd;
var $iHeightFactor=0.5;
var $iFillColor="white",$iFrameColor="black";
var $iShadow=false,$iShadowColor="darkgray",$iShadowWidth=1,$iShadowFrame="black";
var $iPattern=GANTT_RDIAG,$iPatternColor="blue",$iPatternDensity=95;
var $leftMark,$rightMark;
var $progress;
public $progress;
public $leftMark,$rightMark;
private $iEnd;
private $iHeightFactor=0.5;
private $iFillColor="white",$iFrameColor="black";
private $iShadow=false,$iShadowColor="darkgray",$iShadowWidth=1,$iShadowFrame="black";
private $iPattern=GANTT_RDIAG,$iPatternColor="blue",$iPatternDensity=95;
//---------------
// CONSTRUCTOR
function GanttBar($aPos,$aLabel,$aStart,$aEnd,$aCaption="",$aHeightFactor=0.6) {
@ -3215,7 +3230,8 @@ class GanttBar extends GanttPlotObject {
elseif(is_int($this->iHeightFactor) && $this->iHeightFactor>2 && $this->iHeightFactor < 200 )
$vs = $this->iHeightFactor;
else
JpGraphError::Raise("Specified height (".$this->iHeightFactor.") for gantt bar is out of range.");
JpGraphError::RaiseL(6028,$this->iHeightFactor);
//("Specified height (".$this->iHeightFactor.") for gantt bar is out of range.");
// Clip date to min max dates to show
$st = $aScale->NormalizeDate($this->iStart);
@ -3353,7 +3369,7 @@ class GanttBar extends GanttPlotObject {
// Responsible for formatting individual milestones
//===================================================
class MileStone extends GanttPlotObject {
var $mark;
public $mark;
//---------------
// CONSTRUCTOR
@ -3443,7 +3459,7 @@ class TextPropertyBelow extends TextProperty {
parent::TextProperty($aTxt);
}
function GetColWidth($aImg,$margin) {
function GetColWidth($aImg,$aMargin=0) {
// Since we are not stroking the title in the columns
// but rather under the graph we want this to return 0.
return array(0);
@ -3452,8 +3468,7 @@ class TextPropertyBelow extends TextProperty {
class GanttVLine extends GanttPlotObject {
var $iLine,$title_margin=3;
var $iDayOffset=1; // Defult to right edge of day
private $iLine,$title_margin=3, $iDayOffset=1;
//---------------
// CONSTRUCTOR
@ -3473,7 +3488,8 @@ class GanttVLine extends GanttPlotObject {
function SetDayOffset($aOff=0.5) {
if( $aOff < 0.0 || $aOff > 1.0 )
JpGraphError::Raise("Offset for vertical line must be in range [0,1]");
JpGraphError::RaiseL(6029);
//("Offset for vertical line must be in range [0,1]");
$this->iDayOffset = $aOff;
}
@ -3501,11 +3517,11 @@ class GanttVLine extends GanttPlotObject {
// Handles the drawing of a an arrow
//===================================================
class LinkArrow {
var $ix,$iy;
var $isizespec = array(
private $ix,$iy;
private $isizespec = array(
array(2,3),array(3,5),array(3,8),array(6,15),array(8,22));
var $iDirection=ARROW_DOWN,$iType=ARROWT_SOLID,$iSize=ARROW_S2;
var $iColor='black';
private $iDirection=ARROW_DOWN,$iType=ARROWT_SOLID,$iSize=ARROW_S2;
private $iColor='black';
function LinkArrow($x,$y,$aDirection,$aType=ARROWT_SOLID,$aSize=ARROW_S2) {
$this->iDirection = $aDirection;
@ -3545,7 +3561,8 @@ class LinkArrow {
$c = array($x,$y,$x-$dy,$y-$dx,$x-$dy,$y+$dx,$x,$y);
break;
default:
JpGraphError::Raise('Unknown arrow direction for link.');
JpGraphError::RaiseL(6030);
//('Unknown arrow direction for link.');
die();
break;
}
@ -3558,7 +3575,8 @@ class LinkArrow {
$aImg->Polygon($c);
break;
default:
JpGraphError::Raise('Unknown arrow type for link.');
JpGraphError::RaiseL(6031);
//('Unknown arrow type for link.');
die();
break;
}
@ -3571,10 +3589,10 @@ class LinkArrow {
//===================================================
class GanttLink {
var $ix1,$ix2,$iy1,$iy2;
var $iPathType=2,$iPathExtend=15;
var $iColor='black',$iWeight=1;
var $iArrowSize=ARROW_S2,$iArrowType=ARROWT_SOLID;
private $ix1,$ix2,$iy1,$iy2;
private $iPathType=2,$iPathExtend=15;
private $iColor='black',$iWeight=1;
private $iArrowSize=ARROW_S2,$iArrowType=ARROWT_SOLID;
function GanttLink($x1=0,$y1=0,$x2=0,$y2=0) {
$this->ix1 = $x1;
@ -3643,7 +3661,8 @@ class GanttLink {
$c = array($x1,$y1,$x2,$y1,$x2,$y2);
break;
default:
JpGraphError::Raise('Internal error: Unknown path type (='.$this->iPathType .') specified for link.');
JpGraphError::RaiseL(6032,$this->iPathType);
//('Internal error: Unknown path type (='.$this->iPathType .') specified for link.');
exit(1);
break;
}
@ -3676,7 +3695,8 @@ class GanttLink {
}
break;
default:
JpGraphError::Raise('Internal error: Unknown path type specified for link.');
JpGraphError::RaiseL(6032,$this->iPathType);
//('Internal error: Unknown path type specified for link.');
exit(1);
break;
}
@ -3703,7 +3723,8 @@ class GanttLink {
}
break;
default:
JpGraphError::Raise('Internal error: Unknown path type specified for link.');
JpGraphError::RaiseL(6032,$this->iPathType);
//('Internal error: Unknown path type specified for link.');
break;
}
}
@ -3731,8 +3752,8 @@ class GanttLink {
}
break;
default:
JpGraphError::Raise('Internal error: Unknown path type specified for link.');
exit(1);
JpGraphError::RaiseL(6032,$this->iPathType);
//('Internal error: Unknown path type specified for link.');
break;
}
}

View File

@ -4,7 +4,7 @@
// Description: PHP4 Graph Plotting library. Chinese font conversions
// Created: 2003-05-30
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_gb2312.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_gb2312.php 20 2005-05-30 20:34:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -15,7 +15,7 @@ class GB2312toUTF8 {
// This code table is used to translate GB2312 code (key) to
// it's corresponding Unicode value (data)
// --------------------------------------------------------------------
var $codetable = array(
private $codetable = array(
8481 => 12288, 8482 => 12289, 8483 => 12290, 8484 => 12539, 8485 => 713,
8486 => 711, 8487 => 168, 8488 => 12291, 8489 => 12293, 8490 => 8213,
8491 => 65374, 8492 => 8214, 8493 => 8230, 8494 => 8216, 8495 => 8217,

View File

@ -4,7 +4,7 @@
// Description: Create a color gradient
// Created: 2003-02-01
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_gradient.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_gradient.php 630 2006-05-26 00:09:30Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -22,7 +22,7 @@ DEFINE("GRAD_WIDE_MIDHOR",7);
DEFINE("GRAD_LEFT_REFLECTION",8);
DEFINE("GRAD_RIGHT_REFLECTION",9);
DEFINE("GRAD_RAISED_PANEL",10);
DEFINE("GRAD_DIAGONAL",11);
//===================================================
// CLASS Gradient
@ -30,8 +30,7 @@ DEFINE("GRAD_RAISED_PANEL",10);
// considered a "friend" class of Class Image.
//===================================================
class Gradient {
var $img=null;
var $numcolors=100;
private $img=null, $numcolors=100;
//---------------
// CONSTRUCTOR
function Gradient(&$img) {
@ -269,8 +268,57 @@ class Gradient {
}
break;
case GRAD_DIAGONAL:
// use the longer dimension to determine the required number of steps.
// first loop draws from one corner to the mid-diagonal and the second
// loop draws from the mid-diagonal to the opposing corner.
if($xr-$xl > $yb - $yt) {
// width is greater than height -> use x-dimension for steps
$steps = $xr-$xl;
$delta = $xr>=$xl ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
$n = count($colors);
for($x=$xl, $i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$y = $yt+($i/$steps)*($yb-$yt)*$delta;
$this->img->Line($x,$yt,$xl,$y);
$x += $delta;
}
for($x=$xl, $i = 0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$steps+$i];
$y = $yt+($i/$steps)*($yb-$yt)*$delta;
$this->img->Line($x,$yb,$xr,$y);
$x += $delta;
}
} else {
// height is greater than width -> use y-dimension for steps
$steps = $yb-$yt;
$delta = $yb>=$yt ? 1 : -1;
$this->GetColArray($from_color,$to_color,$steps*2,$colors,$this->numcolors);
$n = count($colors);
for($y=$yt, $i=0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$i];
$x = $xl+($i/$steps)*($xr-$xl)*$delta;
$this->img->Line($x,$yt,$xl,$y);
$y += $delta;
}
for($y=$yt, $i = 0; $i < $steps && $i < $n; ++$i) {
$this->img->current_color = $colors[$steps+$i];
$x = $xl+($i/$steps)*($xr-$xl)*$delta;
$this->img->Line($x,$yb,$xr,$y);
$x += $delta;
}
}
break;
default:
JpGraphError::Raise("Unknown gradient style (=$style).");
JpGraphError::RaiseL(7001,$style);
//("Unknown gradient style (=$style).");
break;
}
}

View File

@ -4,7 +4,7 @@
// Description: PHP4 Graph Plotting library. Extension module.
// Created: 2004-02-18
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_iconplot.php 184 2005-08-31 16:17:19Z ljp $
// Ver: $Id: jpgraph_iconplot.php 575 2006-03-04 11:04:59Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -16,14 +16,14 @@
// to the graph
//===================================================
class IconPlot {
var $iHorAnchor='left',$iVertAnchor='top';
var $iX=0,$iY=0;
var $iFile='';
var $iScale=1.0,$iMix=100;
var $iAnchors = array('left','right','top','bottom','center');
var $iCountryFlag='',$iCountryStdSize=3;
var $iScalePosY=null,$iScalePosX=null;
var $iImgString='';
public $iX=0,$iY=0,$iScale=1.0,$iMix=100;
private $iHorAnchor='left',$iVertAnchor='top';
private $iFile='';
private $iAnchors = array('left','right','top','bottom','center');
private $iCountryFlag='',$iCountryStdSize=3;
private $iScalePosY=null,$iScalePosX=null;
private $iImgString='';
function IconPlot($aFile="",$aX=0,$aY=0,$aScale=1.0,$aMix=100) {
$this->iFile = $aFile;
@ -31,22 +31,18 @@ class IconPlot {
$this->iY=$aY;
$this->iScale= $aScale;
if( $aMix < 0 || $aMix > 100 ) {
JpGraphError::Raise('Mix value for icon must be between 0 and 100.');
JpGraphError::RaiseL(8001); //('Mix value for icon must be between 0 and 100.');
}
$this->iMix = $aMix ;
}
function CreateFromString($aStr) {
$this->iImgString = $aStr;
}
function SetCountryFlag($aFlag,$aX=0,$aY=0,$aScale=1.0,$aMix=100,$aStdSize=3) {
$this->iCountryFlag = $aFlag;
$this->iX=$aX;
$this->iY=$aY;
$this->iScale= $aScale;
if( $aMix < 0 || $aMix > 100 ) {
JpGraphError::Raise('Mix value for icon must be between 0 and 100.');
JpGraphError::RaiseL(8001);//'Mix value for icon must be between 0 and 100.');
}
$this->iMix = $aMix;
$this->iCountryStdSize = $aStdSize;
@ -57,6 +53,10 @@ class IconPlot {
$this->iY=$aY;
}
function CreateFromString($aStr) {
$this->iImgString = $aStr;
}
function SetScalePos($aX,$aY) {
$this->iScalePosX = $aX;
$this->iScalePosY = $aY;
@ -68,7 +68,7 @@ class IconPlot {
function SetMix($aMix) {
if( $aMix < 0 || $aMix > 100 ) {
JpGraphError::Raise('Mix value for icon must be between 0 and 100.');
JpGraphError::RaiseL(8001);//('Mix value for icon must be between 0 and 100.');
}
$this->iMix = $aMix ;
}
@ -76,7 +76,7 @@ class IconPlot {
function SetAnchor($aXAnchor='left',$aYAnchor='center') {
if( !in_array($aXAnchor,$this->iAnchors) ||
!in_array($aYAnchor,$this->iAnchors) ) {
JpGraphError::Raise("Anchor position for icons must be one of 'top', 'bottom', 'left', 'right' or 'center'");
JpGraphError::RaiseL(8002);//("Anchor position for icons must be one of 'top', 'bottom', 'left', 'right' or 'center'");
}
$this->iHorAnchor=$aXAnchor;
$this->iVertAnchor=$aYAnchor;
@ -128,10 +128,14 @@ class IconPlot {
}
}
function GetWidthHeight() {
$dummy=0;
return $this->_Stroke($dummy,null,null,true);
}
function _Stroke($aImg,$x=null,$y=null) {
function _Stroke($aImg,$x=null,$y=null,$aReturnWidthHeight=false) {
if( $this->iFile != '' && $this->iCountryFlag != '' ) {
JpGraphError::Raise('It is not possible to specify both an image file and a country flag for the same icon.');
JpGraphError::RaiseL(8003);//('It is not possible to specify both an image file and a country flag for the same icon.');
}
if( $this->iFile != '' ) {
$gdimg = Graph::LoadBkgImage('',$this->iFile);
@ -139,14 +143,23 @@ class IconPlot {
elseif( $this->iImgString != '') {
$gdimg = Image::CreateFromString($this->iImgString);
}
else {
if( ! class_exists('FlagImages') ) {
JpGraphError::Raise('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.');
if( ! class_exists('FlagImages',false) ) {
JpGraphError::RaiseL(8004);//('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.');
}
$fobj = new FlagImages($this->iCountryStdSize);
$dummy='';
$gdimg = $fobj->GetImgByName($this->iCountryFlag,$dummy);
}
$iconw = imagesx($gdimg);
$iconh = imagesy($gdimg);
if( $aReturnWidthHeight ) {
return array(round($iconw*$this->iScale),round($iconh*$this->iScale));
}
if( $x !== null && $y !== null ) {
$this->iX = $x; $this->iY = $y;
}
@ -158,8 +171,6 @@ class IconPlot {
$h = imagesy($aImg->img);
$this->iY = round($h*$this->iY);
}
$iconw = imagesx($gdimg);
$iconh = imagesy($gdimg);
if( $this->iHorAnchor == 'center' )
$this->iX -= round($iconw*$this->iScale/2);

View File

@ -4,7 +4,7 @@
// Description: Extension for JpGraph to do some simple img transformations
// Created: 2003-09-06
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_imgtrans.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_imgtrans.php 478 2006-02-04 12:17:06Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -14,7 +14,7 @@
// Perform some simple image transformations.
//------------------------------------------------------------------------
class ImgTrans {
var $gdImg=null;
private $gdImg=null;
function ImgTrans($aGdImg) {
// Constructor
@ -30,7 +30,8 @@ class ImgTrans {
// Parameter check
if( $aHorizonPos < 0 || $aHorizonPos > 1.0 ) {
JpGraphError::Raise("Value for image transformation out of bounds.\nVanishing point on horizon must be specified as a value between 0 and 1.");
JpGraphError::RaiseL(9001);
//("Value for image transformation out of bounds.\nVanishing point on horizon must be specified as a value between 0 and 1.");
}
$w = imagesx($aGdImg);

View File

@ -4,13 +4,13 @@
// Description: Line plot extension for JpGraph
// Created: 2001-01-08
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_line.php 222 2005-11-04 04:31:40Z ljp $
// Ver: $Id: jpgraph_line.php 456 2006-02-04 12:02:41Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc');
require_once ('jpgraph_plotmark.inc.php');
// constants for the (filled) area
DEFINE("LP_AREA_FILLED", true);
@ -23,29 +23,29 @@ DEFINE("LP_AREA_NO_BORDER",true);
// Description:
//===================================================
class LinePlot extends Plot{
var $filled=false;
var $fill_color='blue';
var $mark=null;
var $step_style=false, $center=false;
var $line_style=1; // Default to solid
var $filledAreas = array(); // array of arrays(with min,max,col,filled in them)
var $barcenter=false; // When we mix line and bar. Should we center the line in the bar.
var $fillFromMin = false ;
var $fillgrad=false,$fillgrad_fromcolor='navy',$fillgrad_tocolor='silver',$fillgrad_numcolors=100;
var $iFastStroke=false;
public $mark=null;
protected $filled=false;
protected $fill_color='blue';
protected $step_style=false, $center=false;
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 $fillgrad=false,$fillgrad_fromcolor='navy',$fillgrad_tocolor='silver',$fillgrad_numcolors=100;
protected $iFastStroke=false;
//---------------
// CONSTRUCTOR
function LinePlot(&$datay,$datax=false) {
function LinePlot($datay,$datax=false) {
$this->Plot($datay,$datax);
$this->mark = new PlotMark();
$this->mark = new PlotMark() ;
}
//---------------
// PUBLIC METHODS
// Set style, filled or open
function SetFilled($aFlag=true) {
JpGraphError::Raise('LinePlot::SetFilled() is deprecated. Use SetFillColor()');
JpGraphError::RaiseL(10001);//('LinePlot::SetFilled() is deprecated. Use SetFillColor()');
}
function SetBarCenter($aFlag=true) {
@ -81,7 +81,7 @@ class LinePlot extends Plot{
$this->fillgrad = true;
}
function Legend(&$graph) {
function Legend($graph) {
if( $this->legend!="" ) {
if( $this->filled && !$this->fillgrad ) {
$graph->legend->Add($this->legend,
@ -93,8 +93,7 @@ class LinePlot extends Plot{
// In order to differentiate between gradients and cooors specified as an RGB triple
$graph->legend->Add($this->legend,$color,"",-2 /* -GRAD_HOR */,
$this->legendcsimtarget,$this->legendcsimalt);
}
else {
} else {
$graph->legend->Add($this->legend,
$this->color,$this->mark,$this->line_style,
$this->legendcsimtarget,$this->legendcsimalt);
@ -113,7 +112,7 @@ class LinePlot extends Plot{
}
// Gets called before any axis are stroked
function PreStrokeAdjust(&$graph) {
function PreStrokeAdjust($graph) {
// If another plot type have already adjusted the
// offset we don't touch it.
@ -137,7 +136,7 @@ class LinePlot extends Plot{
$this->iFastStroke = $aFlg;
}
function FastStroke(&$img,&$xscale,&$yscale,$aStartPoint=0,$exist_x=true) {
function FastStroke($img,$xscale,$yscale,$aStartPoint=0,$exist_x=true) {
// An optimized stroke for many data points with no extra
// features but 60% faster. You can't have values or line styles, or null
// values in plots.
@ -164,21 +163,21 @@ class LinePlot extends Plot{
// Just ignore
}
else {
JpGraphError::Raise('Plot too complicated for fast line Stroke. Use standard Stroke()');
return;
JpGraphError::RaiseL(10002);//('Plot too complicated for fast line Stroke. Use standard Stroke()');
}
++$pnts;
} // WHILE
$img->Polygon($cord,false,true);
}
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
$idx=0;
$numpoints=count($this->coords[0]);
if( isset($this->coords[1]) ) {
if( count($this->coords[1])!=$numpoints )
JpGraphError::Raise("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$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
$exist_x = true;
}
@ -212,18 +211,21 @@ class LinePlot extends Plot{
$img->SetStartPoint($xscale->Translate($xs),
$yscale->Translate($this->coords[0][$startpoint]));
if( $this->filled ) {
$cord[] = $xscale->Translate($xs);
$min = $yscale->GetMinVal();
if( $min > 0 || $this->fillFromMin )
$cord[] = $yscale->Translate($min);
$fillmin = $yscale->scale_abs[0];//Translate($min);
else
$cord[] = $yscale->Translate(0);
$fillmin = $yscale->Translate(0);
$cord[$idx++] = $xscale->Translate($xs);
$cord[$idx++] = $fillmin;
}
$xt = $xscale->Translate($xs);
$yt = $yscale->Translate($this->coords[0][$startpoint]);
$cord[] = $xt;
$cord[] = $yt;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
$yt_old = $yt;
$xt_old = $xt;
$y_old = $this->coords[0][$startpoint];
@ -261,10 +263,10 @@ class LinePlot extends Plot{
$yt_old = $yt;
$xt_old = $xt;
}
$cord[] = $xt;
$cord[] = $yt_old;
$cord[] = $xt;
$cord[] = $yt;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt_old;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
elseif( $firstnonumeric==false ) {
$firstnonumeric = true;
@ -273,19 +275,39 @@ class LinePlot extends Plot{
}
}
else {
if( is_numeric($y) || (is_string($y) && $y != "-") ) {
$tmp1=$this->coords[0][$pnts];
$tmp2=$this->coords[0][$pnts-1];
if( is_numeric($tmp1) && (is_numeric($tmp2) || $tmp2=="-" ) ) {
$tmp1=$y;
$prev=$this->coords[0][$pnts-1];
if( $tmp1==='' || $tmp1===NULL || $tmp1==='X' ) $tmp1 = 'x';
if( $prev==='' || $prev===null || $prev==='X' ) $prev = 'x';
if( is_numeric($y) || (is_string($y) && $y != '-') ) {
if( is_numeric($y) && (is_numeric($prev) || $prev === '-' ) ) {
$img->StyleLineTo($xt,$yt);
}
else {
$img->SetStartPoint($xt,$yt);
}
if( is_numeric($tmp1) &&
(is_numeric($tmp2) || $tmp2=="-" || ($this->filled && $tmp2=='') ) ) {
$cord[] = $xt;
$cord[] = $yt;
}
if( $this->filled && $tmp1 !== '-' ) {
if( $tmp1 === 'x' ) {
$cord[$idx++] = $cord[$idx-3];
$cord[$idx++] = $fillmin;
}
elseif( $prev === 'x' ) {
$cord[$idx++] = $xt;
$cord[$idx++] = $fillmin;
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
else {
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
}
else {
if( is_numeric($tmp1) && (is_numeric($prev) || $prev === '-' ) ) {
$cord[$idx++] = $xt;
$cord[$idx++] = $yt;
}
}
}
@ -299,11 +321,11 @@ class LinePlot extends Plot{
}
if( $this->filled ) {
$cord[] = $xt;
$cord[$idx++] = $xt;
if( $min > 0 || $this->fillFromMin )
$cord[] = $yscale->Translate($min);
$cord[$idx++] = $yscale->Translate($min);
else
$cord[] = $yscale->Translate(0);
$cord[$idx++] = $yscale->Translate(0);
if( $this->fillgrad ) {
$img->SetLineWeight(1);
$grad = new Gradient($img);
@ -385,8 +407,6 @@ class LinePlot extends Plot{
$this->StrokeDataValue($img,$this->coords[0][$pnts],$xt,$yt);
}
}
}
} // Class
@ -396,8 +416,8 @@ class LinePlot extends Plot{
// Description:
//===================================================
class AccLinePlot extends Plot {
var $plots=null,$nbrplots=0,$numpoints=0;
var $iStartEndZero=true;
protected $plots=null,$nbrplots=0;
private $iStartEndZero=true;
//---------------
// CONSTRUCTOR
function AccLinePlot($plots) {
@ -412,10 +432,9 @@ class AccLinePlot extends Plot {
//---------------
// PUBLIC METHODS
function Legend(&$graph) {
$n=count($this->plots);
for($i=0; $i < $n; ++$i )
$this->plots[$i]->DoLegend($graph);
function Legend($graph) {
foreach( $this->plots as $p )
$p->DoLegend($graph);
}
function Max() {
@ -472,7 +491,7 @@ class AccLinePlot extends Plot {
}
// Gets called before any axis are stroked
function PreStrokeAdjust(&$graph) {
function PreStrokeAdjust($graph) {
// If another plot type have already adjusted the
// offset we don't touch it.
@ -569,7 +588,7 @@ class AccLinePlot extends Plot {
// it wouldn't be possible to create an acc line plot
// with the same graphs, i.e AccLinePlot(array($pl,$pl,$pl));
// since this method would have a side effect.
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
$img->SetLineWeight($this->weight);
$this->numpoints = count($this->plots[0]->coords[0]);
// Allocate array

View File

@ -4,7 +4,7 @@
// Description: Log scale plot extension for JpGraph
// Created: 2001-01-08
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_log.php 56 2005-06-06 20:14:44Z ljp $
// Ver: $Id: jpgraph_log.php 480 2006-02-04 12:17:57Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -36,11 +36,13 @@ class LogScale extends LinearScale {
function Translate($a) {
if( !is_numeric($a) ) {
if( $a != '' && $a != '-' && $a != 'x' )
JpGraphError::Raise('Your data contains non-numeric values.');
JpGraphError::RaiseL(11001);
//('Your data contains non-numeric values.');
return 1;
}
if( $a < 0 ) {
JpGraphError::Raise("Negative data values can not be used in a log scale.");
JpGraphError::RaiseL(11002);
//("Negative data values can not be used in a log scale.");
exit(1);
}
if( $a==0 ) $a=1;
@ -53,7 +55,8 @@ class LogScale extends LinearScale {
function RelTranslate($a) {
if( !is_numeric($a) ) {
if( $a != '' && $a != '-' && $a != 'x' )
JpGraphError::Raise('Your data contains non-numeric values.');
JpGraphError::RaiseL(11001);
//('Your data contains non-numeric values.');
return 1;
}
if( $a==0 ) $a=1;
@ -81,11 +84,12 @@ class LogScale extends LinearScale {
// 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) {
function AutoScale($img,$min,$max,$maxsteps,$majend=true) {
if( $min==0 ) $min=1;
if( $max <= 0 ) {
JpGraphError::Raise('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.');
JpGraphError::RaiseL(11004);
//('Scale error for logarithmic scale. You have a problem with your data values. The max value must be greater than 0. It is mathematically impossible to have 0 in a logarithmic scale.');
}
$smin = floor(log10($min));
$smax = ceil(log10($max));
@ -100,7 +104,7 @@ class LogScale extends LinearScale {
// Description:
//===================================================
class LogTicks extends Ticks{
var $label_logtype=LOGLABELS_MAGNITUDE;
private $label_logtype=LOGLABELS_MAGNITUDE;
//---------------
// CONSTRUCTOR
function LogTicks() {
@ -123,7 +127,8 @@ class LogTicks extends Ticks{
}
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.');
JpGraphError::RaiseL(11005);
//('Specifying tick interval for a logarithmic scale is undefined. Remove any calls to SetTextLabelStart() or SetTextTickInterval() on the logarithmic scale.');
}
function SetXLabelOffset($dummy) {
@ -134,7 +139,7 @@ class LogTicks extends Ticks{
// 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) {
function Stroke($img,$scale,$pos) {
$start = $scale->GetMinVal();
$limit = $scale->GetMaxVal();
$nextMajor = 10*$start;

View File

@ -4,7 +4,7 @@
// Description: Pie plot extension for JpGraph
// Created: 2001-02-14
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_pie.php 88 2005-08-07 17:18:51Z ljp $
// Ver: $Id: jpgraph_pie.php 575 2006-03-04 11:04:59Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -23,36 +23,37 @@ DEFINE("PIE_VALUE_ADJPER",2);
// Description: Draws a pie plot
//===================================================
class PiePlot {
var $posx=0.5,$posy=0.5;
var $radius=0.3;
var $explode_radius=array(),$explode_all=false,$explode_r=20;
var $labels=null, $legends=null;
var $csimtargets=null; // Array of targets for CSIM
var $csimareas=''; // Generated CSIM text
var $csimalts=null; // ALT tags for corresponding target
var $data=null;
var $title;
var $startangle=0;
var $weight=1, $color="black";
var $legend_margin=6,$show_labels=true;
var $themearr = array(
public $posx=0.5,$posy=0.5;
protected $radius=0.3;
protected $explode_radius=array(),$explode_all=false,$explode_r=20;
protected $labels=null, $legends=null;
protected $csimtargets=null; // Array of targets for CSIM
protected $csimareas=''; // Generated CSIM text
protected $csimalts=null; // ALT tags for corresponding target
protected $data=null;
public $title;
protected $startangle=0;
protected $weight=1, $color="black";
protected $legend_margin=6,$show_labels=true;
protected $themearr = array(
"earth" => array(136,34,40,45,46,62,63,134,74,10,120,136,141,168,180,77,209,218,346,395,89,430),
"pastel" => array(27,415,128,59,66,79,105,110,42,147,152,230,236,240,331,337,405,38),
"water" => array(8,370,24,40,335,56,213,237,268,14,326,387,10,388),
"sand" => array(27,168,34,170,19,50,65,72,131,209,46,393));
var $theme="earth";
var $setslicecolors=array();
var $labeltype=0; // Default to percentage
var $pie_border=true,$pie_interior_border=true;
var $value;
var $ishadowcolor='',$ishadowdrop=4;
var $ilabelposadj=1;
var $legendcsimtargets = array();
var $legendcsimalts = array();
var $adjusted_data = array();
var $guideline = null,$guidelinemargin=10;
var $iShowGuideLineForSingle = false;
var $iGuideLineCurve = false,$iGuideVFactor=1.4,$iGuideLineRFactor=0.8;
protected $theme="earth";
protected $setslicecolors=array();
protected $labeltype=0; // Default to percentage
protected $pie_border=true,$pie_interior_border=true;
public $value;
protected $ishadowcolor='',$ishadowdrop=4;
protected $ilabelposadj=1;
protected $legendcsimtargets = array();
protected $legendcsimalts = array();
protected $adjusted_data = array();
public $guideline = null;
protected $guidelinemargin=10,$iShowGuideLineForSingle = false;
protected $iGuideLineCurve = false,$iGuideVFactor=1.4,$iGuideLineRFactor=0.8;
//---------------
// CONSTRUCTOR
function PiePlot($data) {
@ -109,7 +110,6 @@ class PiePlot {
}
function AddSliceToCSIM($i,$xc,$yc,$radius,$sa,$ea) {
//Slice number, ellipse centre (x,y), height, width, start angle, end angle
while( $sa > 2*M_PI ) $sa = $sa - 2*M_PI;
while( $ea > 2*M_PI ) $ea = $ea - 2*M_PI;
@ -131,10 +131,11 @@ class PiePlot {
$xp = floor(($radius*cos($ea))+$xc);
$yp = floor($yc-$radius*sin($ea));
$coords.= ", $xp, $yp";
//add coordinates every 0.2 radians
$a=$ea+0.2;
// If we cross the 260-limit with a slice we need to handle
// If we cross the 360-limit with a slice we need to handle
// the fact that end angle is smaller than start
if( $sa < $ea ) {
while ($a <= 2*M_PI) {
@ -146,6 +147,7 @@ class PiePlot {
$a -= 2*M_PI;
}
while ($a < $sa) {
$xp = floor($radius*cos($a)+$xc);
$yp = floor($yc-$radius*sin($a));
@ -173,12 +175,12 @@ class PiePlot {
if( in_array($aTheme,array_keys($this->themearr)) )
$this->theme = $aTheme;
else
JpGraphError::Raise("PiePLot::SetTheme() Unknown theme: $aTheme");
JpGraphError::RaiseL(15001,$aTheme);//("PiePLot::SetTheme() Unknown theme: $aTheme");
}
function ExplodeSlice($e,$radius=20) {
if( ! is_integer($e) )
JpGraphError::Raise('Argument to PiePlot::ExplodeSlice() must be an integer');
JpGraphError::RaiseL(15002);//('Argument to PiePlot::ExplodeSlice() must be an integer');
$this->explode_radius[$e]=$radius;
}
@ -189,21 +191,22 @@ class PiePlot {
function Explode($aExplodeArr) {
if( !is_array($aExplodeArr) ) {
JpGraphError::Raise("Argument to PiePlot::Explode() must be an array with integer distances.");
JpGraphError::RaiseL(15003);
//("Argument to PiePlot::Explode() must be an array with integer distances.");
}
$this->explode_radius = $aExplodeArr;
}
function SetStartAngle($aStart) {
if( $aStart < 0 || $aStart > 360 ) {
JpGraphError::Raise('Slice start angle must be between 0 and 360 degrees.');
JpGraphError::RaiseL(15004);//('Slice start angle must be between 0 and 360 degrees.');
}
$this->startangle = 360-$aStart;
$this->startangle *= M_PI/180;
}
function SetFont($family,$style=FS_NORMAL,$size=10) {
JpGraphError::Raise('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.');
JpGraphError::RaiseL(15005);//('PiePlot::SetFont() is deprecated. Use PiePlot->value->SetFont() instead.');
}
// Size in percentage
@ -211,13 +214,13 @@ class PiePlot {
if( ($aSize>0 && $aSize<=0.5) || ($aSize>10 && $aSize<1000) )
$this->radius = $aSize;
else
JpGraphError::Raise("PiePlot::SetSize() Radius for pie must either be specified as a fraction
[0, 0.5] of the size of the image or as an absolute size in pixels
in the range [10, 1000]");
JpGraphError::RaiseL(15006);
//("PiePlot::SetSize() Radius for pie must either be specified as a fraction [0, 0.5] of the size of the image or as an absolute size in pixels in the range [10, 1000]");
}
function SetFontColor($aColor) {
JpGraphError::Raise('PiePlot::SetFontColor() is deprecated. Use PiePlot->value->SetColor() instead.');
JpGraphError::RaiseL(15007);
//('PiePlot::SetFontColor() is deprecated. Use PiePlot->value->SetColor() instead.');
}
// Set label arrays
@ -238,7 +241,8 @@ class PiePlot {
// Should we display actual value or percentage?
function SetLabelType($t) {
if( $t < 0 || $t > 2 )
JpGraphError::Raise("PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not $t).");
JpGraphError::RaiseL(15008,$t);
//("PiePlot::SetLabelType() Type for pie plots must be 0 or 1 (not $t).");
$this->labeltype=$t;
}
@ -253,8 +257,8 @@ class PiePlot {
$this->pie_interior_border = $interior;
}
// Setup the legends (Framework method)
function Legend(&$graph) {
// Setup the legends
function Legend($graph) {
$colors = array_keys($graph->img->rgb->rgb_table);
sort($colors);
$ta=$this->themearr[$this->theme];
@ -262,14 +266,14 @@ class PiePlot {
if( $this->setslicecolors==null ) {
$numcolors=count($ta);
if( get_class($this)==='pieplot3d' ) {
if( class_exists('PiePlot3D',false) && ($this instanceof PiePlot3D) ) {
$ta = array_reverse(array_slice($ta,0,$n));
}
}
else {
$this->setslicecolors = array_slice($this->setslicecolors,0,$n);
$numcolors=count($this->setslicecolors);
if( $graph->pieaa && get_class($this)==='pieplot' ) {
if( $graph->pieaa && ($this instanceof PiePlot) ) {
$this->setslicecolors = array_reverse($this->setslicecolors);
}
}
@ -280,7 +284,7 @@ class PiePlot {
// Bail out with error if the sum is 0
if( $sum==0 )
JpGraphError::Raise("Illegal pie plot. Sum of all data is zero for Pie!");
JpGraphError::RaiseL(15009);//("Illegal pie plot. Sum of all data is zero for Pie!");
// Make sure we don't plot more values than data points
// (in case the user added more legends than data points)
@ -371,7 +375,7 @@ class PiePlot {
}
function Stroke(&$img,$aaoption=0) {
function Stroke($img,$aaoption=0) {
// aaoption is used to handle antialias
// aaoption == 0 a normal pie
// aaoption == 1 just the body
@ -395,12 +399,19 @@ class PiePlot {
$numcolors=count($ta);
}
else {
$this->setslicecolors = array_reverse(array_slice($this->setslicecolors,0,$n));
// We need to create an array of colors as long as the data
// since we need to reverse it to get the colors in the right order
$numcolors=count($this->setslicecolors);
$tt = array_slice($this->setslicecolors,$n % $numcolors);
$tt2 = array_slice($this->setslicecolors,0,$n % $numcolors);
$tt2 = array_merge($tt, $tt2);
$this->setslicecolors = $tt + $tt2;
if( $n > $numcolors ) {
$i = 2*$numcolors;
while( $n > $i ) {
$this->setslicecolors = array_merge($this->setslicecolors,$this->setslicecolors);
$i += $n;
}
$tt = array_slice($this->setslicecolors,0,$n % $numcolors);
$this->setslicecolors = array_merge($this->setslicecolors,$tt);
$this->setslicecolors = array_reverse($this->setslicecolors);
}
}
// Draw the slices
@ -410,7 +421,7 @@ class PiePlot {
// Bail out with error if the sum is 0
if( $sum==0 )
JpGraphError::Raise("Sum of all data is 0 for Pie.");
JpGraphError::RaiseL(15009);//("Sum of all data is 0 for Pie.");
// Set up the pie-circle
if( $this->radius <= 1 )
@ -503,7 +514,7 @@ class PiePlot {
}
// Format the titles for each slice
if( $aaoption!==2) {
if( $aaoption !== 2 ) {
for( $i=0; $i < $n; ++$i) {
if( $this->labeltype==0 ) {
if( $sum != 0 )
@ -524,13 +535,13 @@ class PiePlot {
}
}
If( $this->value->show && $aaoption !== 1 ) {
if( $this->value->show && $aaoption !== 1 ) {
$this->StrokeAllLabels($img,$xc,$yc,$radius);
}
// Adjust title position
if( $aaoption !== 1 ) {
$this->title->Pos($xc,
$this->title->SetPos($xc,
$yc-$this->title->GetFontHeight($img)-$radius-$this->title->margin,
"center","bottom");
$this->title->Stroke($img);
@ -693,7 +704,7 @@ class PiePlot {
// We use the font height as the base factor for how far we need to
// spread the labels in the Y-direction.
$img->SetFont($this->value->ff,$this->value->fs,$this->value->fsize);
$this->value->ApplyFont($img);
$fh = $img->GetFontHeight();
$origvstep=$fh*$this->iGuideVFactor;
$this->value->SetMargin(0);
@ -846,12 +857,11 @@ class PiePlot {
}
// Position the labels of each slice
function StrokeLabel($label,$img,$xc,$yc,$a,$radius) {
function StrokeLabel($label,$img,$xc,$yc,$a,$r) {
// Default value
if( $this->ilabelposadj === 'auto' )
$this->ilabelposadj = 0.65;
$r = $radius;
// We position the values diferently depending on if they are inside
// or outside the pie
@ -876,7 +886,7 @@ class PiePlot {
// that intersects with the extension of the corresponding axis. The code looks a little
// bit messy but this is really the only way of having a reasonable position of the
// axis titles.
$img->SetFont($this->value->ff,$this->value->fs,$this->value->fsize);
$this->value->ApplyFont($img);
$h=$img->GetTextHeight($label);
// For numeric values the format of the display value
// must be taken into account
@ -888,6 +898,7 @@ class PiePlot {
}
else
$w=$img->GetTextWidth($label);
if( $this->ilabelposadj > 1.0 && $this->ilabelposadj < 5.0) {
$r *= $this->ilabelposadj;
}
@ -924,10 +935,10 @@ class PiePlot {
// filled circle in the center
//===================================================
class PiePlotC extends PiePlot {
var $imidsize=0.5; // Fraction of total width
var $imidcolor='white';
var $midtitle='';
var $middlecsimtarget="",$middlecsimalt="";
private $imidsize=0.5; // Fraction of total width
private $imidcolor='white';
public $midtitle='';
private $middlecsimtarget="",$middlecsimalt="";
function PiePlotC($data,$aCenterTitle='') {
parent::PiePlot($data);
@ -960,7 +971,6 @@ class PiePlotC extends PiePlot {
}
function AddSliceToCSIM($i,$xc,$yc,$radius,$sa,$ea) {
//Slice number, ellipse centre (x,y), radius, start angle, end angle
while( $sa > 2*M_PI ) $sa = $sa - 2*M_PI;
while( $ea > 2*M_PI ) $ea = $ea - 2*M_PI;
@ -982,7 +992,7 @@ class PiePlotC extends PiePlot {
//add coordinates every 0.25 radians
$a=$ea+0.25;
// If we cross the 260-limit with a slice we need to handle
// If we cross the 360-limit with a slice we need to handle
// the fact that end angle is smaller than start
if( $sa < $ea ) {
while ($a <= 2*M_PI) {
@ -1079,7 +1089,7 @@ class PiePlotC extends PiePlot {
if( $this->value->show && $aaoption !== 1) {
$this->StrokeAllLabels($img,$xc,$yc,$radius);
$this->midtitle->Pos($xc,$yc,'center','center');
$this->midtitle->SetPos($xc,$yc,'center','center');
$this->midtitle->Stroke($img);
}
@ -1113,10 +1123,10 @@ class PiePlotC extends PiePlot {
// Description:
//===================================================
class PieGraph extends Graph {
var $posx, $posy, $radius;
var $legends=array();
var $plots=array();
var $pieaa = false ;
private $posx, $posy, $radius;
private $legends=array();
public $plots=array();
public $pieaa = false ;
//---------------
// CONSTRUCTOR
function PieGraph($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) {
@ -1131,13 +1141,13 @@ class PieGraph extends Graph {
function Add($aObj) {
if( is_array($aObj) && count($aObj) > 0 )
$cl = get_class($aObj[0]);
$cl = $aObj[0];
else
$cl = get_class($aObj);
$cl = $aObj;
if( $cl == 'text' )
if( $cl instanceof Text )
$this->AddText($aObj);
elseif( $cl == 'iconplot' )
elseif( class_exists('IconPlot',false) && ($cl instanceof IconPlot) )
$this->AddIcon($aObj);
else {
if( is_array($aObj) ) {
@ -1160,6 +1170,7 @@ class PieGraph extends Graph {
$this->SetMarginColor($c);
}
function DisplayCSIMAreas() {
$csim="";
foreach($this->plots as $p ) {
@ -1217,6 +1228,7 @@ class PieGraph extends Graph {
}
else {
$this->StrokeFrame();
$this->StrokeBackgroundGrad();
}
}
@ -1235,7 +1247,12 @@ class PieGraph extends Graph {
$ni = count($this->iIcons);
for($i=0; $i < $ni; ++$i) {
$this->iIcons[$i]->iScale *= 2 ;
if( $this->iIcons[$i]->iX > 1 )
$this->iIcons[$i]->iX *= 2 ;
if( $this->iIcons[$i]->iY > 1 )
$this->iIcons[$i]->iY *= 2 ;
}
$this->StrokeIcons();
for($i=0; $i < $n; ++$i) {
@ -1306,7 +1323,7 @@ class PieGraph extends Graph {
// Should we do any final image transformation
if( $this->iImgTrans ) {
if( !class_exists('ImgTrans') ) {
if( !class_exists('ImgTrans',false) ) {
require_once('jpgraph_imgtrans.php');
//JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.');
}

View File

@ -4,7 +4,7 @@
// Description: 3D Pie plot extension for JpGraph
// Created: 2001-03-24
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_pie3d.php 332 2005-12-14 18:21:37Z ljp $
// Ver: $Id: jpgraph_pie3d.php 571 2006-03-04 10:28:00Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -16,14 +16,14 @@
// angle between 20 and 70 degrees.
//===================================================
class PiePlot3D extends PiePlot {
var $labelhintcolor="red",$showlabelhint=true;
var $angle=50;
var $edgecolor="", $edgeweight=1;
var $iThickness=false;
private $labelhintcolor="red",$showlabelhint=true;
private $angle=50;
private $edgecolor="", $edgeweight=1;
private $iThickness=false;
//---------------
// CONSTRUCTOR
function PiePlot3d(&$data) {
function PiePlot3d($data) {
$this->radius = 0.5;
$this->data = $data;
$this->title = new Text("");
@ -45,7 +45,7 @@ class PiePlot3D extends PiePlot {
$this->setslicecolors = $aColors;
}
function Legend(&$aGraph) {
function Legend($aGraph) {
parent::Legend($aGraph);
$aGraph->legend->txtcol = array_reverse($aGraph->legend->txtcol);
}
@ -57,21 +57,28 @@ class PiePlot3D extends PiePlot {
// Should the slices be separated by a line? If color is specified as "" no line
// will be used to separate pie slices.
function SetEdge($aColor,$aWeight=1) {
function SetEdge($aColor='black',$aWeight=1) {
$this->edgecolor = $aColor;
$this->edgeweight = $aWeight;
}
// Dummy function to make Pie3D behave in a similair way to 2D
function ShowBorder($exterior=true,$interior=true) {
JpGraphError::RaiseL(14001);
//('Pie3D::ShowBorder() . Deprecated function. Use Pie3D::SetEdge() to control the edges around slices.');
}
// Specify projection angle for 3D in degrees
// Must be between 20 and 70 degrees
function SetAngle($a) {
if( $a<5 || $a>90 )
JpGraphError::Raise("PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.");
JpGraphError::RaiseL(14002);
//("PiePlot3D::SetAngle() 3D Pie projection angle must be between 5 and 85 degrees.");
else
$this->angle = $a;
}
function AddSliceToCSIM($i,$xc,$yc,$height,$width,$thick,$sa,$ea) { //Slice number, ellipse centre (x,y), height, width, start angle, end angle
function Add3DSliceToCSIM($i,$xc,$yc,$height,$width,$thick,$sa,$ea) { //Slice number, ellipse centre (x,y), height, width, start angle, end angle
$sa *= M_PI/180;
$ea *= M_PI/180;
@ -175,7 +182,7 @@ class PiePlot3D extends PiePlot {
// pie ellipse. Hence, no slice will cross 90 or 270
// point.
if( ($sa < 90 && $ea > 90) || ( ($sa > 90 && $sa < 270) && $ea > 270) ) {
JpGraphError::Raise('Internal assertion failed. Pie3D::Pie3DSlice');
JpGraphError::RaiseL(14003);//('Internal assertion failed. Pie3D::Pie3DSlice');
exit(1);
}
@ -378,7 +385,7 @@ class PiePlot3D extends PiePlot {
function SetStartAngle($aStart) {
if( $aStart < 0 || $aStart > 360 ) {
JpGraphError::Raise('Slice start angle must be between 0 and 360 degrees.');
JpGraphError::RaiseL(14004);//('Slice start angle must be between 0 and 360 degrees.');
}
$this->startangle = $aStart;
}
@ -572,7 +579,8 @@ class PiePlot3D extends PiePlot {
$j=0;
}
if( $cnt > $n ) {
JpGraphError::Raise("Pie3D Internal error (#1). Trying to wrap twice when looking for start index");
JpGraphError::RaiseL(14005);
//("Pie3D Internal error (#1). Trying to wrap twice when looking for start index");
}
++$cnt;
}
@ -598,7 +606,8 @@ class PiePlot3D extends PiePlot {
$j++;
if( $j >= $n ) $j=0;
if( $cnt > $n ) {
JpGraphError::Raise("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
JpGraphError::RaiseL(14006);
//("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
}
++$cnt;
}
@ -618,7 +627,8 @@ class PiePlot3D extends PiePlot {
$z,$adjcolors[$j],$shadow);
$j--;
if( $cnt > $n ) {
JpGraphError::Raise("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
JpGraphError::RaiseL(14006);
//("Pie3D Internal Error: Z-Sorting algorithm for 3D Pies is not working properly (2). Trying to wrap twice while stroking.");
}
if($j<0) $j=$n-1;
$cnt++;
@ -636,13 +646,15 @@ class PiePlot3D extends PiePlot {
if( $aaoption !== 1 ) {
// Now print possible labels and add csim
$img->SetFont($this->value->ff,$this->value->fs);
$this->value->ApplyFont($img);
$margin = $img->GetFontHeight()/2 + $this->value->margin ;
for($i=0; $i < count($data); ++$i ) {
$la = $labeldata[$i][0];
$x = $labeldata[$i][1] + cos($la*M_PI/180)*($d+$margin);
$y = $labeldata[$i][2] - sin($la*M_PI/180)*($h+$margin);
if( $la > 180 && $la < 360 ) $y += $z;
$x = $labeldata[$i][1] + cos($la*M_PI/180)*($d+$margin)*$this->ilabelposadj;
$y = $labeldata[$i][2] - sin($la*M_PI/180)*($h+$margin)*$this->ilabelposadj;
if( $this->ilabelposadj >= 1.0 ) {
if( $la > 180 && $la < 360 ) $y += $z;
}
if( $this->labeltype == 0 ) {
if( $sum > 0 )
$l = 100*$data[$i]/$sum;
@ -660,7 +672,7 @@ class PiePlot3D extends PiePlot {
$this->StrokeLabels($l,$img,$labeldata[$i][0]*M_PI/180,$x,$y,$z);
$this->AddSliceToCSIM($i,$labeldata[$i][1],$labeldata[$i][2],$h*2,$d*2,$z,
$this->Add3DSliceToCSIM($i,$labeldata[$i][1],$labeldata[$i][2],$h*2,$d*2,$z,
$originalangles[$i][0],$originalangles[$i][1]);
}
}
@ -801,8 +813,7 @@ class PiePlot3D extends PiePlot {
// Add a sanity check for width
if( $width < 1 ) {
JpGraphError::Raise("Width for 3D Pie is 0. Specify a size > 0");
exit();
JpGraphError::RaiseL(14007);//("Width for 3D Pie is 0. Specify a size > 0");
}
// Establish a thickness. By default the thickness is a fifth of the
@ -839,7 +850,7 @@ class PiePlot3D extends PiePlot {
// Adjust title position
if( $aaoption != 1 ) {
$this->title->Pos($xc,$yc-$this->title->GetFontHeight($img)-$width/2-$this->title->margin, "center","bottom");
$this->title->SetPos($xc,$yc-$this->title->GetFontHeight($img)-$width/2-$this->title->margin, "center","bottom");
$this->title->Stroke($img);
}
}
@ -857,7 +868,7 @@ class PiePlot3D extends PiePlot {
// that intersects with the extension of the corresponding axis. The code looks a little
// bit messy but this is really the only way of having a reasonable position of the
// axis titles.
$img->SetFont($this->value->ff,$this->value->fs,$this->value->fsize);
$this->value->ApplyFont($img);
$h=$img->GetTextHeight($label);
// For numeric values the format of the display value
// must be taken into account

View File

@ -4,7 +4,7 @@
// Description: PHP4 Graph Plotting library. Extension module.
// Created: 2004-02-18
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_plotband.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_plotband.php 484 2006-02-04 12:20:01Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -22,8 +22,8 @@ DEFINE("BAND_DIAGCROSS",8); // Diagonal crosses
// Utility class to hold coordinates for a rectangle
class Rectangle {
var $x,$y,$w,$h;
var $xe, $ye;
public $x,$y,$w,$h;
public $xe, $ye;
function Rectangle($aX,$aY,$aWidth,$aHeight) {
$this->x=$aX;
$this->y=$aY;
@ -38,16 +38,16 @@ class Rectangle {
// Class RectPattern
// Base class for pattern hierarchi that is used to display patterned
// bands on the graph. Any subclass that doesn't override Stroke()
// must at least implement method DoPattern(&$aImg) which is responsible
// must at least implement method DoPattern($aImg) which is responsible
// for drawing the pattern onto the graph.
//=====================================================================
class RectPattern {
var $color;
var $weight;
var $rect=null;
var $doframe=true;
var $linespacing; // Line spacing in pixels
var $iBackgroundColor=-1; // Default is no background fill
protected $color;
protected $weight;
protected $rect=null;
protected $doframe=true;
protected $linespacing; // Line spacing in pixels
protected $iBackgroundColor=-1; // Default is no background fill
function RectPattern($aColor,$aWeight=1) {
$this->color = $aColor;
@ -58,7 +58,7 @@ class RectPattern {
$this->iBackgroundColor=$aBackgroundColor;
}
function SetPos(&$aRect) {
function SetPos($aRect) {
$this->rect = $aRect;
}
@ -68,16 +68,18 @@ class RectPattern {
function SetDensity($aDens) {
if( $aDens < 1 || $aDens > 100 )
JpGraphError::Raise(" Desity for pattern must be between 1 and 100. (You tried $aDens)");
JpGraphError::RaiseL(16001,$aDens);
//(" Desity for pattern must be between 1 and 100. (You tried $aDens)");
// 1% corresponds to linespacing=50
// 100 % corresponds to linespacing 1
$this->linespacing = floor(((100-$aDens)/100.0)*50)+1;
}
function Stroke(&$aImg) {
function Stroke($aImg) {
if( $this->rect == null )
JpGraphError::Raise(" No positions specified for pattern.");
JpGraphError::RaiseL(16002);
//(" No positions specified for pattern.");
if( !(is_numeric($this->iBackgroundColor) && $this->iBackgroundColor==-1) ) {
$aImg->SetColor($this->iBackgroundColor);
@ -108,7 +110,7 @@ class RectPatternSolid extends RectPattern {
parent::RectPattern($aColor,$aWeight);
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
$aImg->SetColor($this->color);
$aImg->FilledRectangle($this->rect->x,$this->rect->y,
$this->rect->xe,$this->rect->ye);
@ -126,7 +128,7 @@ class RectPatternHor extends RectPattern {
$this->linespacing = $aLineSpacing;
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
$x0 = $this->rect->x;
$x1 = $this->rect->xe;
$y = $this->rect->y;
@ -142,7 +144,6 @@ class RectPatternHor extends RectPattern {
// Implements vertical line pattern
//=====================================================================
class RectPatternVert extends RectPattern {
var $linespacing=10; // Line spacing in pixels
function RectPatternVert($aColor="black",$aWeight=1,$aLineSpacing=7) {
parent::RectPattern($aColor,$aWeight);
@ -152,7 +153,7 @@ class RectPatternVert extends RectPattern {
//--------------------
// Private methods
//
function DoPattern(&$aImg) {
function DoPattern($aImg) {
$x = $this->rect->x;
$y0 = $this->rect->y;
$y1 = $this->rect->ye;
@ -169,14 +170,13 @@ class RectPatternVert extends RectPattern {
// Implements right diagonal pattern
//=====================================================================
class RectPatternRDiag extends RectPattern {
var $linespacing; // Line spacing in pixels
function RectPatternRDiag($aColor="black",$aWeight=1,$aLineSpacing=12) {
parent::RectPattern($aColor,$aWeight);
$this->linespacing = $aLineSpacing;
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
// --------------------
// | / / / / /|
// |/ / / / / |
@ -239,14 +239,13 @@ class RectPatternRDiag extends RectPattern {
// Implements left diagonal pattern
//=====================================================================
class RectPatternLDiag extends RectPattern {
var $linespacing; // Line spacing in pixels
function RectPatternLDiag($aColor="black",$aWeight=1,$aLineSpacing=12) {
$this->linespacing = $aLineSpacing;
parent::RectPattern($aColor,$aWeight);
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
// --------------------
// |\ \ \ \ \ |
// | \ \ \ \ \|
@ -304,7 +303,7 @@ class RectPatternLDiag extends RectPattern {
// Implements "3D" plane pattern
//=====================================================================
class RectPattern3DPlane extends RectPattern {
var $alpha=50; // Parameter that specifies the distance
private $alpha=50; // Parameter that specifies the distance
// to "simulated" horizon in pixel from the
// top of the band. Specifies how fast the lines
// converge.
@ -318,7 +317,7 @@ class RectPattern3DPlane extends RectPattern {
$this->alpha=$aHorizon;
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
// "Fake" a nice 3D grid-effect.
$x0 = $this->rect->x + $this->rect->w/2;
$y0 = $this->rect->y;
@ -421,8 +420,8 @@ class RectPattern3DPlane extends RectPattern {
// Vert/Hor crosses
//=====================================================================
class RectPatternCross extends RectPattern {
var $vert=null;
var $hor=null;
private $vert=null;
private $hor=null;
function RectPatternCross($aColor="black",$aWeight=1) {
parent::RectPattern($aColor,$aWeight);
$this->vert = new RectPatternVert($aColor,$aWeight);
@ -434,7 +433,7 @@ class RectPatternCross extends RectPattern {
$this->hor->SetOrder($aDepth);
}
function SetPos(&$aRect) {
function SetPos($aRect) {
parent::SetPos($aRect);
$this->vert->SetPos($aRect);
$this->hor->SetPos($aRect);
@ -445,7 +444,7 @@ class RectPatternCross extends RectPattern {
$this->hor->SetDensity($aDens);
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
$this->vert->DoPattern($aImg);
$this->hor->DoPattern($aImg);
}
@ -457,8 +456,8 @@ class RectPatternCross extends RectPattern {
//=====================================================================
class RectPatternDiagCross extends RectPattern {
var $left=null;
var $right=null;
private $left=null;
private $right=null;
function RectPatternDiagCross($aColor="black",$aWeight=1) {
parent::RectPattern($aColor,$aWeight);
$this->right = new RectPatternRDiag($aColor,$aWeight);
@ -470,7 +469,7 @@ class RectPatternDiagCross extends RectPattern {
$this->right->SetOrder($aDepth);
}
function SetPos(&$aRect) {
function SetPos($aRect) {
parent::SetPos($aRect);
$this->left->SetPos($aRect);
$this->right->SetPos($aRect);
@ -481,7 +480,7 @@ class RectPatternDiagCross extends RectPattern {
$this->right->SetDensity($aDens);
}
function DoPattern(&$aImg) {
function DoPattern($aImg) {
$this->left->DoPattern($aImg);
$this->right->DoPattern($aImg);
}
@ -523,7 +522,8 @@ class RectPatternFactory {
$obj = new RectPatternDiagCross($aColor,$aWeight);
break;
default:
JpGraphError::Raise(" Unknown pattern specification ($aPattern)");
JpGraphError::RaiseL(16003,$aPattern);
//(" Unknown pattern specification ($aPattern)");
}
return $obj;
}
@ -537,15 +537,16 @@ class RectPatternFactory {
// concrete class.
//=====================================================================
class PlotBand {
var $prect=null;
var $depth;
var $dir, $min, $max;
public $depth; // Determine if band should be over or under the plots
private $prect=null;
private $dir, $min, $max;
function PlotBand($aDir,$aPattern,$aMin,$aMax,$aColor="black",$aWeight=1,$aDepth=DEPTH_BACK) {
$f = new RectPatternFactory();
$this->prect = $f->Create($aPattern,$aColor,$aWeight);
if( is_numeric($aMin) && is_numeric($aMax) && ($aMin > $aMax) )
JpGraphError::Raise('Min value for plotband is larger than specified max value. Please correct.');
JpGraphError::RaiseL(16004);
//('Min value for plotband is larger than specified max value. Please correct.');
$this->dir = $aDir;
$this->min = $aMin;
$this->max = $aMax;
@ -553,7 +554,7 @@ class PlotBand {
}
// Set position. aRect contains absolute image coordinates
function SetPos(&$aRect) {
function SetPos($aRect) {
assert( $this->prect != null ) ;
$this->prect->SetPos($aRect);
}
@ -583,8 +584,12 @@ class PlotBand {
return $this->max;
}
function PreStrokeAdjust($aGraph) {
// Nothing to do
}
// Display band
function Stroke(&$aImg,&$aXScale,&$aYScale) {
function Stroke($aImg,$aXScale,$aYScale) {
assert( $this->prect != null ) ;
if( $this->dir == HORIZONTAL ) {
if( $this->min === 'min' ) $this->min = $aYScale->GetMinVal();

View File

@ -4,13 +4,13 @@
// Description: Polar plot extension for JpGraph
// Created: 2003-02-02
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_polar.php 21 2005-05-30 20:35:34Z ljp $
// Ver: $Id: jpgraph_polar.php 488 2006-02-04 12:26:03Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc');
require_once ('jpgraph_plotmark.inc.php');
require_once "jpgraph_log.php";
@ -35,22 +35,24 @@ DEFINE('POLAR_180',2);
// class PolarPlot
//--------------------------------------------------------------------------
class PolarPlot {
var $numpoints=0;
var $iColor='navy',$iFillColor='';
var $iLineWeight=1;
var $coord=null;
var $legendcsimtarget='';
var $legendcsimalt='';
var $legend="";
var $csimtargets=array(); // Array of targets for CSIM
var $csimareas=""; // Resultant CSIM area tags
var $csimalts=null; // ALT:s for corresponding target
var $line_style='solid',$mark;
public $line_style='solid',$mark;
public $legendcsimtarget='';
public $legendcsimalt='';
public $legend="";
public $csimtargets=array(); // Array of targets for CSIM
public $csimareas=""; // Resultant CSIM area tags
public $csimalts=null; // ALT:s for corresponding target
public $scale=null;
private $numpoints=0;
private $iColor='navy',$iFillColor='';
private $iLineWeight=1;
private $coord=null;
function PolarPlot($aData) {
$n = count($aData);
if( $n & 1 ) {
JpGraphError::Raise('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).');
JpGraphError::RaiseL(17001);
//('Polar plots must have an even number of data point. Each data point is a tuple (angle,radius).');
}
$this->numpoints = $n/2;
$this->coord = $aData;
@ -97,7 +99,7 @@ class PolarPlot {
// Private methods
function Legend(&$aGraph) {
function Legend($aGraph) {
$color = $this->iColor ;
if( $this->legend != "" ) {
if( $this->iFillColor!='' ) {
@ -149,17 +151,17 @@ class PolarPlot {
// class PolarAxis
//--------------------------------------------------------------------------
class PolarAxis extends Axis {
var $angle_step=15,$angle_color='lightgray',$angle_label_color='black';
var $angle_fontfam=FF_FONT1,$angle_fontstyle=FS_NORMAL,$angle_fontsize=10;
var $angle_fontcolor = 'navy';
var $gridminor_color='lightgray',$gridmajor_color='lightgray';
var $show_minor_grid = false, $show_major_grid = true ;
var $show_angle_mark=true, $show_angle_grid=true, $show_angle_label=true;
var $angle_tick_len=3, $angle_tick_len2=3, $angle_tick_color='black';
var $show_angle_tick=true;
var $radius_tick_color='black';
private $angle_step=15,$angle_color='lightgray',$angle_label_color='black';
private $angle_fontfam=FF_FONT1,$angle_fontstyle=FS_NORMAL,$angle_fontsize=10;
private $angle_fontcolor = 'navy';
private $gridminor_color='lightgray',$gridmajor_color='lightgray';
private $show_minor_grid = false, $show_major_grid = true ;
private $show_angle_mark=true, $show_angle_grid=true, $show_angle_label=true;
private $angle_tick_len=3, $angle_tick_len2=3, $angle_tick_color='black';
private $show_angle_tick=true;
private $radius_tick_color='black';
function PolarAxis(&$img,&$aScale) {
function PolarAxis($img,$aScale) {
parent::Axis($img,$aScale);
}
@ -480,7 +482,7 @@ class PolarAxis extends Axis {
}
}
function Stroke($pos) {
function Stroke($pos,$dummy=true) {
$this->img->SetLineWeight($this->weight);
$this->img->SetColor($this->color);
@ -490,16 +492,16 @@ class PolarAxis extends Axis {
$this->img->width-$this->img->right_margin,$pos+$this->weight-1);
$y=$pos+$this->img->GetFontHeight()+$this->title_margin+$this->title->margin;
if( $this->title_adjust=="high" )
$this->title->Pos($this->img->width-$this->img->right_margin,$y,"right","top");
$this->title->SetPos($this->img->width-$this->img->right_margin,$y,"right","top");
elseif( $this->title_adjust=="middle" || $this->title_adjust=="center" )
$this->title->Pos(($this->img->width-$this->img->left_margin-
$this->title->SetPos(($this->img->width-$this->img->left_margin-
$this->img->right_margin)/2+$this->img->left_margin,
$y,"center","top");
elseif($this->title_adjust=="low")
$this->title->Pos($this->img->left_margin,$y,"left","top");
$this->title->SetPos($this->img->left_margin,$y,"left","top");
else {
JpGraphError::Raise('Unknown alignment specified for X-axis title. ('.
$this->title_adjust.')');
JpGraphError::RaiseL(17002,$this->title_adjust);
//('Unknown alignment specified for X-axis title. ('.$this->title_adjust.')');
}
@ -573,10 +575,11 @@ class PolarAxis extends Axis {
}
class PolarScale extends LinearScale {
var $graph;
function PolarScale($aMax=0,&$graph) {
private $graph;
function PolarScale($aMax=0,$graph) {
parent::LinearScale(0,$aMax,'x');
$this->graph = &$graph;
$this->graph = $graph;
}
function _Translate($v) {
@ -605,10 +608,10 @@ class PolarScale extends LinearScale {
}
class PolarLogScale extends LogScale {
var $graph;
function PolarLogScale($aMax=1,&$graph) {
private $graph;
function PolarLogScale($aMax=1,$graph) {
parent::LogScale(0,$aMax,'x');
$this->graph = &$graph;
$this->graph = $graph;
$this->ticks->SetLabelLogType(LOGLABELS_MAGNITUDE);
}
@ -637,9 +640,9 @@ class PolarLogScale extends LogScale {
}
class PolarGraph extends Graph {
var $scale;
var $iType=POLAR_360;
var $axis;
public $scale;
public $axis;
public $iType=POLAR_360;
function PolarGraph($aWidth=300,$aHeight=200,$aCachedName="",$aTimeOut=0,$aInline=true) {
parent::Graph($aWidth,$aHeight,$aCachedName,$aTimeOut,$aInline) ;
@ -661,14 +664,14 @@ class PolarGraph extends Graph {
//JpGraphError::Raise('Set90AndMargin() is not supported for polar graphs.');
}
function SetScale($aScale,$rmax=0) {
function SetScale($aScale,$rmax=0,$dummy1=1,$dummy2=1,$dummy3=1) {
if( $aScale == 'lin' )
$this->scale = new PolarScale($rmax,$this);
elseif( $aScale == 'log' ) {
$this->scale = new PolarLogScale($rmax,$this);
}
else {
JpGraphError::Raise('Unknown scale type for polar graph. Must be "lin" or "log"');
JpGraphError::RaiseL(17004);//('Unknown scale type for polar graph. Must be "lin" or "log"');
}
$this->axis = new PolarAxis($this->img,$this->scale);
@ -690,7 +693,7 @@ class PolarGraph extends Graph {
$m = $this->plots[0]->Max();
$i=1;
while($i < $n) {
$m = max($this->plots[$i]->Max());
$m = max($this->plots[$i]->Max(),$m);
++$i;
}
return $m;

View File

@ -4,13 +4,13 @@
// Description: Radar plot extension for JpGraph
// Created: 2001-02-04
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_radar.php 213 2005-10-11 18:22:00Z ljp $
// Ver: $Id: jpgraph_radar.php 606 2006-03-23 18:37:57Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once('jpgraph_plotmark.inc');
require_once('jpgraph_plotmark.inc.php');
class RadarLogTicks extends Ticks {
//---------------
@ -21,7 +21,7 @@ class RadarLogTicks extends Ticks {
// PUBLIC METHODS
// TODO: Add Argument grid
function Stroke(&$aImg,&$grid,$aPos,$aAxisAngle,&$aScale,&$aMajPos,&$aMajLabel) {
function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) {
$start = $aScale->GetMinVal();
$limit = $aScale->GetMaxVal();
$nextMajor = 10*$start;
@ -72,6 +72,7 @@ class RadarLogTicks extends Ticks {
}
else
$l = $nextMajor;
$aMajLabel[]=$l;
$nextMajor *= 10;
$step *= 10;
@ -87,7 +88,13 @@ class RadarLogTicks extends Ticks {
}
}
class RadarLinearTicks extends LinearTicks {
class RadarLinearTicks extends Ticks { // extends LinearTicks {
private $minor_step=1, $major_step=2;
private $xlabel_offset=0,$xtick_offset=0;
private $maj_ticks_pos=array();
//---------------
// CONSTRUCTOR
function RadarLinearTicks() {
@ -97,8 +104,36 @@ class RadarLinearTicks extends LinearTicks {
//---------------
// PUBLIC METHODS
// TODO: Add argument grid
function Stroke(&$aImg,&$grid,$aPos,$aAxisAngle,&$aScale,&$aMajPos,&$aMajLabel) {
// Return major step size in world coordinates
function GetMajor() {
return $this->major_step;
}
// Return minor step size in world coordinates
function GetMinor() {
return $this->minor_step;
}
// Set Minor and Major ticks (in world coordinates)
function Set($aMajStep,$aMinStep=false) {
if( $aMinStep==false )
$aMinStep=$aMajStep;
if( $aMajStep <= 0 || $aMinStep <= 0 ) {
JpGraphError::Raise(" Minor or major step size is 0. Check that you haven't
got an accidental SetTextTicks(0) in your code.<p>
If this is not the case you might have stumbled upon a bug in JpGraph.
Please report this and if possible include the data that caused the
problem.");
}
$this->major_step=$aMajStep;
$this->minor_step=$aMinStep;
$this->is_set = true;
}
function Stroke($aImg,&$grid,$aPos,$aAxisAngle,$aScale,&$aMajPos,&$aMajLabel) {
// Prepare to draw linear ticks
$maj_step_abs = abs($aScale->scale_factor*$this->major_step);
$min_step_abs = abs($aScale->scale_factor*$this->minor_step);
@ -113,7 +148,9 @@ class RadarLinearTicks extends LinearTicks {
$label=$aScale->scale[0]+$this->major_step;
$aImg->SetLineWeight($this->weight);
// NEW
$aMajPos = array();
$aMajLabel = array();
for($i=1; $i<=$nbrmaj; ++$i) {
$xt=round($i*$maj_step_abs*cos($aAxisAngle))+$aScale->scale_abs[0];
$yt=$aPos-round($i*$maj_step_abs*sin($aAxisAngle));
@ -161,12 +198,12 @@ class RadarLinearTicks extends LinearTicks {
// CLASS RadarAxis
// Description: Implements axis for the radar graph
//===================================================
class RadarAxis extends Axis {
var $title_color="navy";
var $title=null;
class RadarAxis extends AxisPrototype {
private $title_color="navy";
public $title=null;
//---------------
// CONSTRUCTOR
function RadarAxis(&$img,&$aScale,$color=array(0,0,0)) {
function RadarAxis($img,$aScale,$color=array(0,0,0)) {
parent::Axis($img,$aScale,$color);
$this->len=$img->plotheight;
$this->title = new Text();
@ -175,8 +212,9 @@ class RadarAxis extends Axis {
}
//---------------
// PUBLIC METHODS
function SetTickLabels($l) {
$this->ticks_label = $l;
function SetTickLabels($aLabelArray,$aLabelColorArray=null) {
$this->ticks_label = $aLabelArray;
$this->ticks_label_colors = $aLabelColorArray;
}
@ -199,18 +237,25 @@ class RadarAxis extends Axis {
$this->img->Line($this->scale->scale_abs[0],$pos,$x,$y);
$this->scale->ticks->Stroke($this->img,$grid,$pos,$aAxisAngle,$this->scale,$majpos,$majlabel);
$ncolor=0;
if( isset($this->ticks_label_colors) )
$ncolor=count($this->ticks_label_colors);
// Draw labels
if( $lf && !$this->hide ) {
$this->img->SetFont($this->font_family,$this->font_style,$this->font_size);
$this->img->SetTextAlign("left","top");
$this->img->SetColor($this->color);
$this->img->SetColor($this->label_color);
// majpos contsins (x,y) coordinates for labels
// majpos contains (x,y) coordinates for labels
if( ! $this->hide_labels ) {
$n = floor(count($majpos)/2);
for($i=0; $i < $n; ++$i) {
if( $this->ticks_label != null )
$n = floor(count($majpos)/2);
for($i=0; $i < $n; ++$i) {
// Set specific label color if specified
if( $ncolor > 0 )
$this->img->SetColor($this->ticks_label_colors[$i % $ncolor]);
if( $this->ticks_label != null && isset($this->ticks_label[$i]) )
$this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$this->ticks_label[$i]);
else
$this->img->StrokeText($majpos[$i*2],$majpos[$i*2+1],$majlabel[$i]);
@ -239,8 +284,8 @@ class RadarAxis extends Axis {
$h=$this->img->GetTextHeight($title)*1.2;
$w=$this->img->GetTextWidth($title)*1.2;
while( $aAxisAngle > 2*M_PI ) $aAxisAngle -= 2*M_PI;
while( $aAxisAngle > 2*M_PI ) $aAxisAngle -= 2*M_PI;
if( $aAxisAngle>=7*M_PI/4 || $aAxisAngle <= M_PI/4 ) $dx=0;
if( $aAxisAngle>=M_PI/4 && $aAxisAngle <= 3*M_PI/4 ) $dx=($aAxisAngle-M_PI/4)*2/M_PI;
if( $aAxisAngle>=3*M_PI/4 && $aAxisAngle <= 5*M_PI/4 ) $dx=1;
@ -265,15 +310,38 @@ class RadarAxis extends Axis {
// CLASS RadarGrid
// Description: Draws grid for the radar graph
//===================================================
class RadarGrid extends Grid {
class RadarGrid { //extends Grid {
private $type='solid';
private $grid_color='#DDDDDD';
private $show=false, $weight=1;
//------------
// CONSTRUCTOR
function RadarGrid() {
}
// PUBLIC METHODS
function SetColor($aMajColor) {
$this->grid_color = $aMajColor;
}
function SetWeight($aWeight) {
$this->weight=$aWeight;
}
// Specify if grid should be dashed, dotted or solid
function SetLineStyle($aType) {
$this->type = $aType;
}
// Decide if both major and minor grid should be displayed
function Show($aShowMajor=true) {
$this->show=$aShowMajor;
}
//----------------
// PRIVATE METHODS
function Stroke(&$img,&$grid) {
function Stroke($img,$grid) {
if( !$this->show ) return;
$nbrticks = count($grid[0])/2;
$nbrpnts = count($grid);
@ -306,13 +374,13 @@ class RadarGrid extends Grid {
// Description: Plot a radarplot
//===================================================
class RadarPlot {
var $data=array();
var $fill=false, $fill_color=array(200,170,180);
var $color=array(0,0,0);
var $legend="";
var $weight=1;
var $linestyle='solid';
var $mark=null;
public $mark=null;
public $legend="";
private $data=array();
private $fill=false, $fill_color=array(200,170,180);
private $color=array(0,0,0);
private $weight=1;
private $linestyle='solid';
//---------------
// CONSTRUCTOR
function RadarPlot($data) {
@ -360,10 +428,11 @@ class RadarPlot {
}
function GetCSIMareas() {
JpGraphError::Raise("Client side image maps not supported for RadarPlots.");
JpGraphError::RaiseL(18001);
//("Client side image maps not supported for RadarPlots.");
}
function Stroke(&$img, $pos, &$scale, $startangle) {
function Stroke($img, $pos, $scale, $startangle) {
$nbrpnts = count($this->data);
$astep=2*M_PI/$nbrpnts;
$a=$startangle;
@ -410,7 +479,7 @@ class RadarPlot {
return count($this->data);
}
function Legend(&$graph) {
function Legend($graph) {
if( $this->legend=="" ) return;
if( $this->fill )
$graph->legend->Add($this->legend,$this->fill_color,$this->mark);
@ -425,11 +494,10 @@ class RadarPlot {
// Description: Main container for a radar graph
//===================================================
class RadarGraph extends Graph {
var $posx;
var $posy;
var $len;
var $plots=null, $axis_title=null;
var $grid,$axis=null;
public $grid,$axis=null;
private $posx,$posy;
private $len;
private $axis_title=null;
//---------------
// CONSTRUCTOR
function RadarGraph($width=300,$height=200,$cachedName="",$timeout=0,$inline=1) {
@ -448,8 +516,9 @@ class RadarGraph extends Graph {
// PUBLIC METHODS
function SupressTickMarks($f=true) {
if( ERR_DEPRECATED )
JpGraphError::Raise('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.');
$this->axis->scale->ticks->SupressTickMarks($f);
JpGraphError::RaiseL(18002);
//('RadarGraph::SupressTickMarks() is deprecated. Use HideTickMarks() instead.');
$this->axis->scale->ticks->SupressTickMarks($f);
}
function HideTickMarks($aFlag=true) {
@ -460,27 +529,29 @@ class RadarGraph extends Graph {
$this->yscale->ticks->SupressMinorTickMarks(!$aFlag);
}
function SetScale($axtype,$ymin=1,$ymax=1) {
function SetScale($axtype,$ymin=1,$ymax=1,$dummy1=null,$dumy2=null) {
if( $axtype != "lin" && $axtype != "log" ) {
JpGraphError::Raise("Illegal scale for radarplot ($axtype). Must be \"lin\" or \"log\"");
JpGraphError::RaiseL(18003,$axtype);
//("Illegal scale for radarplot ($axtype). Must be \"lin\" or \"log\"");
}
if( $axtype=="lin" ) {
$this->yscale = & new LinearScale($ymin,$ymax);
$this->yscale->ticks = & new RadarLinearTicks();
$this->yscale = new LinearScale($ymin,$ymax);
$this->yscale->ticks = new RadarLinearTicks();
$this->yscale->ticks->SupressMinorTickMarks();
}
elseif( $axtype=="log" ) {
$this->yscale = & new LogScale($ymin,$ymax);
$this->yscale->ticks = & new RadarLogTicks();
$this->yscale = new LogScale($ymin,$ymax);
$this->yscale->ticks = new RadarLogTicks();
}
$this->axis = & new RadarAxis($this->img,$this->yscale);
$this->grid = & new RadarGrid();
$this->axis = new RadarAxis($this->img,$this->yscale);
$this->grid = new RadarGrid();
}
function SetSize($aSize) {
if( $aSize<0.1 || $aSize>1 )
JpGraphError::Raise("Radar Plot size must be between 0.1 and 1. (Your value=$s)");
if( $aSize < 0.1 || $aSize>1 )
JpGraphError::RaiseL(18004,$aSize);
//("Radar Plot size must be between 0.1 and 1. (Your value=$s)");
$this->len=min($this->img->width,$this->img->height)*$aSize/2;
}
@ -488,7 +559,7 @@ class RadarGraph extends Graph {
$this->SetSize($aSize);
}
function SetTickDensity($densy=TICKD_NORMAL) {
function SetTickDensity($densy=TICKD_NORMAL,$dummy1=null) {
$this->ytick_factor=25;
switch( $densy ) {
case TICKD_DENSE:
@ -504,7 +575,8 @@ class RadarGraph extends Graph {
$this->ytick_factor=70;
break;
default:
JpGraphError::Raise("RadarPlot Unsupported Tick density: $densy");
JpGraphError::RaiseL(18005,$densy);
//("RadarPlot Unsupported Tick density: $densy");
}
}
@ -526,19 +598,20 @@ class RadarGraph extends Graph {
$this->axis_title = $title;
}
function Add(&$splot) {
function Add($splot) {
$this->plots[]=$splot;
}
function GetPlotsYMinMax() {
$min=$this->plots[0]->Min();
$max=$this->plots[0]->Max();
function GetPlotsYMinMax($aPlots) {
$min=$aPlots[0]->Min();
$max=$aPlots[0]->Max();
foreach( $this->plots as $p ) {
$max=max($max,$p->Max());
$min=min($min,$p->Min());
}
if( $min < 0 )
JpGraphError::Raise("Minimum data $min (Radar plots should only be used when all data points > 0)");
JpGraphError::RaiseL(18006,$min);
//("Minimum data $min (Radar plots should only be used when all data points > 0)");
return array($min,$max);
}
@ -547,9 +620,23 @@ class RadarGraph extends Graph {
$n = count($this->plots);
// Set Y-scale
if( !$this->yscale->IsSpecified() && count($this->plots)>0 ) {
list($min,$max) = $this->GetPlotsYMinMax();
list($min,$max) = $this->GetPlotsYMinMax($this->plots);
$this->yscale->AutoScale($this->img,0,$max,$this->len/$this->ytick_factor);
}
elseif( $this->yscale->IsSpecified() &&
( $this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified()) ) {
// The tick calculation will use the user suplied min/max values to determine
// the ticks. If auto_ticks is false the exact user specifed min and max
// values will be used for the scale.
// If auto_ticks is true then the scale might be slightly adjusted
// so that the min and max values falls on an even major step.
$min = $this->yscale->scale[0];
$max = $this->yscale->scale[1];
$this->yscale->AutoScale($this->img,$min,$max,
$this->len/$this->ytick_factor,
$this->yscale->auto_ticks);
}
// Set start position end length of scale (in absolute pixels)
$this->yscale->SetConstants($this->posx,$this->len);
@ -562,10 +649,12 @@ class RadarGraph extends Graph {
$this->axis_title[$i] = $i+1;
}
elseif(count($this->axis_title)<$nbrpnts)
JpGraphError::Raise("Number of titles does not match number of points in plot.");
JpGraphError::RaiseL(18007);
//("Number of titles does not match number of points in plot.");
for($i=0; $i < $n; ++$i )
if( $nbrpnts != $this->plots[$i]->GetCount() )
JpGraphError::Raise("Each radar plot must have the same number of data points.");
JpGraphError::RaiseL(18008);
//("Each radar plot must have the same number of data points.");
if( $this->background_image != "" ) {
$this->StrokeFrameBackground();
@ -610,7 +699,7 @@ class RadarGraph extends Graph {
// Should we do any final image transformation
if( $this->iImgTrans ) {
if( !class_exists('ImgTrans') ) {
if( !class_exists('ImgTrans',false) ) {
require_once('jpgraph_imgtrans.php');
}

View File

@ -4,7 +4,7 @@
// Description: Regression and statistical analysis helper classes
// Created: 2002-12-01
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_regstat.php 327 2005-12-10 08:24:50Z ljp $
// Ver: $Id: jpgraph_regstat.php 614 2006-04-19 19:36:32Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -18,9 +18,9 @@
class Spline {
// 3:rd degree polynom approximation
var $xdata,$ydata; // Data vectors
var $y2; // 2:nd derivate of ydata
var $n=0;
private $xdata,$ydata; // Data vectors
private $y2; // 2:nd derivate of ydata
private $n=0;
function Spline($xdata,$ydata) {
$this->y2 = array();
@ -29,6 +29,10 @@ class Spline {
$n = count($ydata);
$this->n = $n;
if( $this->n !== count($xdata) ) {
JpGraphError::RaiseL(19001);
//('Spline: Number of X and Y coordinates must be the same');
}
// Natural spline 2:derivate == 0 at endpoints
$this->y2[0] = 0.0;
@ -39,7 +43,8 @@ class Spline {
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.');
JpGraphError::RaiseL(19002);
//('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;
@ -89,7 +94,8 @@ class Spline {
$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.');
JpGraphError::RaiseL(19002);
//('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.');
}
@ -112,22 +118,30 @@ class Bezier {
* computed from control points data sets, based on Paul Bourke algorithm :
* http://astronomy.swin.edu.au/~pbourke/curves/bezier/
*/
var $datax = array();
var $datay = array();
private $datax = array();
private $datay = array();
private $n=0;
function Bezier($datax, $datay, $attraction_factor = 1) {
// Adding control point multiple time will raise their attraction power over the curve
$this->n = count($datax);
if( $this->n !== count($datay) ) {
JpGraphError::RaiseL(19003);
//('Bezier: Number of X and Y coordinates must be the same');
}
$idx=0;
foreach($datax as $datumx) {
for ($i = 0; $i < $attraction_factor; $i++) {
$this->datax[] = $datumx;
$this->datax[$idx++] = $datumx;
}
}
$idx=0;
foreach($datay as $datumy) {
for ($i = 0; $i < $attraction_factor; $i++) {
$this->datay[] = $datumy;
$this->datay[$idx++] = $datumy;
}
}
$this->n *= $attraction_factor;
}
function Get($steps) {
@ -146,7 +160,7 @@ class Bezier {
}
function GetPoint($mu) {
$n = count($this->datax)-1;
$n = $this->n - 1;
$k = 0;
$kn = 0;
$nn = 0;

View File

@ -4,22 +4,22 @@
// Description: Scatter (and impuls) plot extension for JpGraph
// Created: 2001-02-11
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_scatter.php 53 2005-06-06 18:12:54Z ljp $
// Ver: $Id: jpgraph_scatter.php 492 2006-02-04 12:29:02Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
*/
require_once ('jpgraph_plotmark.inc');
require_once ('jpgraph_plotmark.inc.php');
//===================================================
// CLASS FieldArrow
// Description: Draw an arrow at (x,y) with angle a
//===================================================
class FieldArrow {
var $iSize=10; // Length in pixels for arrow
var $iArrowSize = 2;
var $iColor='black';
var $isizespec = array(
public $iColor='black';
public $iSize=10; // Length in pixels for arrow
public $iArrowSize = 2;
private $isizespec = array(
array(2,1),array(3,2),array(4,3),array(6,4),array(7,4),array(8,5),array(10,6),array(12,7),array(16,8),array(20,10));
function FieldArrow() {
}
@ -62,13 +62,13 @@ class FieldArrow {
// Description: Render a field plot
//===================================================
class FieldPlot extends Plot {
var $iAngles;
var $iCallback='';
private $iAngles;
private $iCallback='';
function FieldPlot($datay,$datax,$angles) {
if( (count($datax) != count($datay)) )
JpGraphError::Raise("Fieldplots must have equal number of X and Y points.");
JpGraphError::RaiseL(20001);//("Fieldplots must have equal number of X and Y points.");
if( (count($datax) != count($angles)) )
JpGraphError::Raise("Fieldplots must have an angle specified for each X and Y points.");
JpGraphError::RaiseL(20002);//("Fieldplots must have an angle specified for each X and Y points.");
$this->iAngles = $angles;
@ -83,7 +83,7 @@ class FieldPlot extends Plot {
$this->iCallback = $aFunc;
}
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
// Remeber base color and size
$bc = $this->arrow->iColor;
@ -116,7 +116,7 @@ class FieldPlot extends Plot {
}
// Framework function
function Legend(&$aGraph) {
function Legend($aGraph) {
if( $this->legend != "" ) {
$aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt);
@ -129,13 +129,13 @@ class FieldPlot extends Plot {
// Description: Render X and Y plots
//===================================================
class ScatterPlot extends Plot {
var $impuls = false;
var $linkpoints = false, $linkpointweight=1, $linkpointcolor="black";
private $impuls = false;
private $linkpoints = false, $linkpointweight=1, $linkpointcolor="black";
//---------------
// CONSTRUCTOR
function ScatterPlot($datay,$datax=false) {
if( (count($datax) != count($datay)) && is_array($datax))
JpGraphError::Raise("Scatterplot must have equal number of X and Y points.");
JpGraphError::RaiseL(20003);//("Scatterplot must have equal number of X and Y points.");
$this->Plot($datay,$datax);
$this->mark = new PlotMark();
$this->mark->SetType(MARK_SQUARE);
@ -157,7 +157,7 @@ class ScatterPlot extends Plot {
$this->linkpointweight=$aWeight;
}
function Stroke(&$img,&$xscale,&$yscale) {
function Stroke($img,$xscale,$yscale) {
$ymin=$yscale->scale_abs[0];
if( $yscale->scale[0] < 0 )
@ -169,7 +169,7 @@ class ScatterPlot extends Plot {
for( $i=0; $i<$this->numpoints; ++$i ) {
// Skip null values
if( $this->coords[0][$i]==="" || $this->coords[0][$i]==='-' || $this->coords[0][$i]==='x')
if( $this->coords[0][$i]==='' || $this->coords[0][$i]==='-' || $this->coords[0][$i]==='x')
continue;
if( isset($this->coords[1]) )
@ -214,7 +214,7 @@ class ScatterPlot extends Plot {
}
// Framework function
function Legend(&$aGraph) {
function Legend($aGraph) {
if( $this->legend != "" ) {
$aGraph->legend->Add($this->legend,$this->mark->fill_color,$this->mark,0,
$this->legendcsimtarget,$this->legendcsimalt);

View File

@ -4,7 +4,7 @@
// Description: Stock plot extension for JpGraph
// Created: 2003-01-27
// Author: Johan Persson (johanp@aditus.nu)
// Ver: $Id: jpgraph_stock.php 41 2005-06-06 10:46:10Z ljp $
// Ver: $Id: jpgraph_stock.php 494 2006-02-04 12:31:05Z ljp $
//
// Copyright (c) Aditus Consulting. All rights reserved.
//========================================================================
@ -14,15 +14,16 @@
// CLASS StockPlot
//===================================================
class StockPlot extends Plot {
var $iTupleSize = 4;
var $iWidth=9;
var $iEndLines=1;
var $iStockColor1='white',$iStockColor2='darkred',$iStockColor3='darkred';
protected $iTupleSize = 4;
private $iWidth=9;
private $iEndLines=1;
private $iStockColor1='white',$iStockColor2='darkred',$iStockColor3='darkred';
//---------------
// CONSTRUCTOR
function StockPlot(&$datay,$datax=false) {
function StockPlot($datay,$datax=false) {
if( count($datay) % $this->iTupleSize ) {
JpGraphError::Raise('Data values for Stock charts must contain an even multiple of '.$this->iTupleSize.' data points.');
JpGraphError::RaiseL(21001,$this->iTupleSize);
//('Data values for Stock charts must contain an even multiple of '.$this->iTupleSize.' data points.');
}
$this->Plot($datay,$datax);
$this->numpoints /= $this->iTupleSize;
@ -47,7 +48,7 @@ class StockPlot extends Plot {
}
// Gets called before any axis are stroked
function PreStrokeAdjust(&$graph) {
function PreStrokeAdjust($graph) {
if( $this->center ) {
$a=0.5; $b=0.5;
$this->numpoints++;
@ -64,7 +65,8 @@ class StockPlot extends Plot {
if( $this->center ) $n--;
if( isset($this->coords[1]) ) {
if( count($this->coords[1])!=$n )
JpGraphError::Raise("Number of X and Y points are not equal. Number of X-points:".count($this->coords[1])." Number of Y-points:$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
$exist_x = true;
}
@ -156,7 +158,7 @@ class StockPlot extends Plot {
// CLASS BoxPlot
//===================================================
class BoxPlot extends StockPlot {
var $iPColor='black',$iNColor='white';
private $iPColor='black',$iNColor='white';
function BoxPlot($datay,$datax=false) {
$this->iTupleSize=5;
parent::StockPlot($datay,$datax);