Ajout de tous les fichiers de l'extranet

Modification de certains chemins
Ajout du framework dans l'extranet
This commit is contained in:
Michael RICOIS 2009-02-17 13:14:53 +00:00
parent e80ba2b3a2
commit 893f4da173
4686 changed files with 526302 additions and 0 deletions

5
.buildpath Normal file
View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path=""/>
<buildpathentry combineaccessrules="false" kind="prj" path="/default"/>
</buildpath>

22
.project Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>extranet</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.dltk.core.scriptbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.php.core.PHPNature</nature>
</natures>
</projectDescription>

18
ChangeLog Normal file
View File

@ -0,0 +1,18 @@
TODO
****
Créer la bdd et le script pour la recherche AJAX NAF
Modifier la méthode de connection à la bdd dans le script pages/nafajax.php
ChangeLog
*********
* Ajout des fichiers pour la recherche ajax sur le code NAF
* Ajout du fichier mysql.php dans le dossier ./batch
* Modification ./batch/getActes.php
* Ajout du répertoire framework dans l'extranet en dehors du www
* Modification ./framework/fwk.php
TODO : Modifier les chemins dans la fonction debugLog
* Modification des chemins dans ./config/prepend.php

85
MODIFS.txt Normal file
View File

@ -0,0 +1,85 @@
.htaccess : Modifier les liens
index.php : 38 / 51 / 139 / 140 / 142
framework/fwk.php : Modifier les liens
Recherche /var/www/
batch/getActes.php
includes/partenaires/insee/classMInsee.php
includes/partenaires/GoogleMapAPI.class.php
includes/partenaires/insee.php
www/pages/actes.php
www/pages/attentes.php
www/pages/avis.php
www/pages/fichier.php
www/pages/greffes.php
www/pages/inpi.php
www/pages/kbis.php
www/pages/main.php
www/pages/kbis.php
www/pages/main.php
www/pages/scorescf.php
www/pages/survliste.php
www/pages/survlisteann.php
www/pages/visuEntreprises.php
www/tools/checkip.php
www/index.php
framework/common/fwk.php
TODO : chemin vers les fichiers (PDF et autres)
Attention aux chemins dans windows != des chemins unix (include_path)
Attention aux variables de sessions (pour le login)
Créer config
Environnement de développement Windows et
Environnement de développemet Linux
Extranet
********
Struture des répertoires actuels
--------------------------------
extranet
batch
config
includes
log
www
framework
common
jpgraph-1.22
jpgraph-2.2
fwk.php => include en dur dans
default
_includes
mysql.php
Proposition de structure
------------------------
/var/www/extranet-v20090216
www => lien symbolique vers la version courante
www20080610 => contient les fichiers du site
css => tous les fichiers css
img => images générales du site
includes => fonctions nécessaires au site mais qui ne peuvent être incluses dans le framework
js => tous les fichiers javascripts
misc => blabla
modules => modules du sites (méthodes, présentation contenu, fournisseurs, )
pages => Toutes les pages du sites
www20090216 => De même
...
bin => executables nécessaires pour le traitement des fichiers
batch
config => fichiers de config (mots de pass,...), en dehors du www donc protégé
framework => contient le framework (fonctions complexes, librairies)
log => contient les logs
DATA - Organiser les données en fonctions des fournisseurs et autres ???
data/pdf
data/xml

145
batch/getActes.php Normal file
View File

@ -0,0 +1,145 @@
#!/usr/bin/php -q
<?php
define ('ACTES_IGNUM_LOCAL_DIR','/var/www/site_extranet/www/pdf/scan/');
define ('ACTES_IG_LOCAL_DIR','/var/www/site_extranet/www/pdf/');
define ('ACTES_IGNUM_FTP_URL', 'ftp2.scores-decisions.com');
define ('ACTES_IGNUM_FTP_USER', 'mpc2500');
define ('ACTES_IGNUM_FTP_PASS', 'passmpc78');
require_once realpath(dirname(__FILE__) . '/../framework/fwk.php');
//define ('INCLUDE_PATH', '/var/www/site_extranet/includes/');
define ( 'INCLUDE_PATH' , realpath(dirname(__FILE__) . '/../includes/') );
require_once realpath(dirname(__FILE__) . '/mysql.php');
//include '/var/www/default/_includes/curl.php';
include_once(FWK_PATH.'common/ftp.php');
$tempsMinEntreRequetes=5;
$tempsMaxEntreRequetes=30;
set_time_limit(0);
$eol="\n";
$lastJO=$dateDebut=$dateFin=$verif=false;
$strInfoProg='Usage : '.basename($argv[0]). " [OPTION]
Vérifie les actes numérisés reçus en provenance des Greffes.
Sans aucun paramètre, récupération des actes.
";/*Sinon:
-d:JJ/MM/AAAA Date de début de publication
-f:JJ/MM/AAAA Date de fin de publication
-l Dernier JO Association uniquement (*)
-n:X Intervalle MIN en secondes entre les requêtes sur le site des JO (défaut=$tempsMinEntreRequetes)
-i:X \" MAX \" \" \" \" \" \" \" \" \" \" (défaut=$tempsMaxEntreRequetes)
-v Vérifier que toutes les annonces du JO sont en base !
";*/
$argv=$_SERVER['argv'];
if ($_SERVER['argc']==1) $lastJO=true;
else {
for ($i=1; isset($argv[$i]); $i++) {
if (substr($argv[$i],0,1)=='-') {
switch (substr($argv[$i],1,1)) {
case 'd':
$dateDebut=substr($argv[$i],3,10);
$dateDeb=dateT('d/m/Y', 'Ymd', $dateDebut);
break;
case 'n':
$tempsMinEntreRequetes=trim(substr($argv[$i],3))*1;
if ($tempsMinEntreRequetes<0) $tempsMinEntreRequetes=0;
break;
case '-':
die($strInfoProg);
break;
default: die('Option '. $argv[$i] . " inconnue !\n");
}
}
}
}
$con = mysql_pconnect('localhost', 'root', 'catsysyo92');
if (!($con === false)) {
if (mysql_select_db('sdv1', $con) === false)
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error() . $eol;
}
else
echo date ('Y/m/d - H:i:s') .' - ERREUR : MySql n°'. mysql_errno() .') : '. mysql_error(). $eol;
$tabCommandes=mysql_select('commandes', 'idCommande, idUser, login, emailCommande, siren, refDocument, dateCommande', 'dateReception=0', false, MYSQL_ASSOC);
$nbCommandes=count($tabCommandes);
$tabTmp=array();
foreach ($tabCommandes as $commande) {
$tabTmp['g'.$commande['idCommande']]=$commande;
}
$tabCommandes=$tabTmp;
unset($tabTmp);
echo date('Y/m/d - H:i:s') ." - Il y a $nbCommandes actes en attente de réception courrier ou numérisation !$eol";
//print_r($tabCommandes);
//die();
/**
** Connexion au site FTP
**/
echo date('Y/m/d - H:i:s') ." - Récupération des fichiers numérisés en attente de traitement...".EOL;
$ret=ftp_mget(ACTES_IGNUM_FTP_URL, ACTES_IGNUM_FTP_USER, ACTES_IGNUM_FTP_PASS, '*.pdf', ACTES_IGNUM_LOCAL_DIR, false);
if ($ret===false)
die (date ('Y/m/d - H:i:s')." - ERREUR : Récupération des actes numérisés impossible !".EOL);
else
echo date ('Y/m/d - H:i:s')." - FIN de la récupération des flux Hugin en FTP ($ret fichiers récupérés).".EOL;
/**
** Connexion au site FTP
**/
echo date('Y/m/d - H:i:s') ." - Traitement des actes non encore traités !".EOL;
$tabFichiers=array();
$dh = opendir(ACTES_IGNUM_LOCAL_DIR);
while (false !== ($filename = readdir($dh))) {
if ($filename<>'.' && $filename<>'..' && strtolower(substr($filename, -4))=='.pdf')
$tabFichiers[] = $filename;
}
rsort($tabFichiers);
$tabActes=array();
foreach ($tabFichiers as $k => $nomFichier) {
if (strtolower(substr($nomFichier,0,1))=='g') {
echo date ('Y/m/d - H:i:s')." - Fichier $nomFichier disponible pour traitement.".EOL;
$numFichier=str_replace('.pdf','', $nomFichier);
$tabActes[] = $nomFichier;
if (isset($tabCommandes[$numFichier]) && is_array($tabCommandes[$numFichier])) {
$commande=$tabCommandes[$numFichier];
echo date ('Y/m/d - H:i:s')." - Le fichier $nomFichier correspond à la commande ".$commande['refDocument'].' de '.$commande['login'].'.'.EOL;
$numFichierSuiv=str_replace('.pdf','', $tabFichiers[$k+1]);
if (strpos($numFichierSuiv, $numFichier) === false) {
/** Le fichier $nomFichier est une commande livrée en un seul fichier **/
$siren=$commande['siren'];
$ref=$commande['refDocument'];
$nomCible="acte-$siren-$ref.pdf";
if (file_exists(ACTES_IG_LOCAL_DIR.$nomCible))
echo date ('Y/m/d - H:i:s')." - La commande $nomCible est déjà mise à disposition !".EOL;
else {
if (rename(ACTES_IGNUM_LOCAL_DIR.$nomFichier, ACTES_IG_LOCAL_DIR.$nomCible)) {
echo date ('Y/m/d - H:i:s')." - La commande $nomCible a été mise à disposition.".EOL;
if (trim($commande['emailCommande'])<>'') {
$subject="Actes ou Statuts disponible pour $siren";
$message ="Le document commandé pour le siren $siren est disponible en téléchargement sur le site de Scores & Décisions à l'adresse suivante :\r\n\r\n";
$message.="http://extranet.scores-decisions.com/pdf/$nomCible\r\n";
$headers = 'From: infoslegales@scores-decisions.com' . "\r\n" .
'Reply-To: infoslegales@scores-decisions.com';
if (mail($commande['emailCommande'], $subject, $message, $headers))
echo date ('Y/m/d - H:i:s').' - Un email a été envoyé à '.$commande['emailCommande']." pour la commande $nomCible.".EOL;
else
echo date ('Y/m/d - H:i:s').' - ERREUR : Impossible d\'envoyer l\'email à '.$commande['emailCommande']." pour la commande $nomCible.".EOL;
}
mysql_update('commandes', array('dateReception'=>date('YmdHis')),'idCommande='.$commande['idCommande']);
//print_r($tabCommandes[$numFichier]);
}
else die('Impossible de déplacer '.ACTES_IGNUM_LOCAL_DIR.$nomFichier.' en '.ACTES_IG_LOCAL_DIR.$nomCible.' !'.EOL);
}
}
else
// On traitera plus tard le multi fichier !
echo date ('Y/m/d - H:i:s')." - @TODO : La commande $numFichier est en plusieur fichiers !".EOL;
// die();
}
}
}
?>

76
batch/mysql.php Normal file
View File

@ -0,0 +1,76 @@
<?
//error_reporting(E_ALL);
function mysql_trace($query, $res='') {
if (!$fp=fopen('mysql_insert.log', 'a'))
return false;
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $res : $query\n"))
return false;
if (!fclose($fp))
return false;
return true;
}
/** Retourne la dernière valeur de l'auto-incrément ou 0 si pas d'auto-incrément
** Penser à bien tester la valeur !== false
**/
function mysql_insert($table, $toAdd, $debug=false){
$fields = implode(array_keys($toAdd), '`,`');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=addslashes($array_values);
$values = "'".implode(array_values($tmp), "','")."'"; # better
$values = str_replace("'NULL'", 'NULL', $values);
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
$res = mysql_query($query);// OR die(mysql_error());
if ($res!==false)
{
if (mysql_insert_id()>0)
$res=mysql_insert_id();
else
$res=true;
}
if ($debug) mysql_trace($query, $res);
return $res;
//-- Example of usage
//$tToAdd = array('id'=>3, 'name'=>'Yo', 'salary' => 5000);
//insertIntoDB('myTable', $tToAdd)
}
function mysql_update($table, $update, $where, $debug=false){
$fields = array_keys($update);
$values = array_values($update);
$i=0;
$query='UPDATE `'.$table.'` SET ';
while($fields[$i]){
if($i>0){$query.=', ';}
$query.=' `'.$fields[$i]."`='".addslashes($values[$i])."'";
$i++;
}
$query = str_replace("'NULL'", 'NULL', $query);
$query.=' WHERE '.$where.' LIMIT 1;';
if ($debug) mysql_trace($query, mysql_errno());
mysql_query($query);// or die(mysql_error());
return true;
//Example
// mysql_update('myTable', $anarray, "type = 'main'")
}
function mysql_select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH) {
$query="SELECT $fields FROM $table WHERE $where;";
// if ($debug) mysql_trace($query, count($tab));
$result=mysql_query($query) or die(mysql_error());
$tab=array();
while ($ligne = mysql_fetch_array($result, $assoc))
$tab[]=$ligne;
mysql_free_result($result);
if ($debug) mysql_trace($query, count($tab));
// echo $query;
return $tab;
}
?>

21
config/append.php Normal file
View File

@ -0,0 +1,21 @@
<?php
die();
if( LOG_BENCH != 'NONE' )
{
$timer->setMarker('Fin du script (append.php)');
$mem=memory_get_usage();
$memko=$mem/1024;
if ( LOG_BENCH == 'FILE' || LOG_BENCH == 'BOTH' ) {
$strInfo=DATETIME_LOG.';'.$mem.';'.$_SERVER["PHP_SELF"].';'.$_SERVER['QUERY_STRING']."\n";
$f = fopen( LOG_PATH.'memory.log', 'a+' );
fwrite($f, $strInfo);
fclose($f);
}
if ( LOG_BENCH == 'WEB' || LOG_BENCH == 'BOTH' ) {
echo '<br/><hr><br/>Mémoire utilisée par le script "'. $_SERVER['PHP_SELF'].'" = '.$mem . " octets ($memko ko)";
echo "<br/>Temps d'exécution de la page :<br/>";
$timer->display();
}
}
?>

68
config/config.inc Normal file
View File

@ -0,0 +1,68 @@
<?
/** Environnement du site **/
define ('ENVIRONNEMENT', 'PRD'); // PRD REC DEV
/** Log des requêtes MySQL ? **/
define ('LOG_MYSQL', 'ALL'); // NONE ou ALL
/** Log des performances des pages PHP (mémoire et temps d'exécution **/
define ('LOG_BENCH', 'BOTH'); // NONE, WEB, FILE, BOTH
/** Paramètres de la base de données **/
/*
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_DB', 'sdv1');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', 'catsysyo92');
*/
/** Paramètres de la base de données **/
define ('MYSQL_HOST', 'localhost');
define ('MYSQL_DB', 'extranet');
define ('MYSQL_USER', 'root');
define ('MYSQL_PASS', '');
//define ('PATH_SITE', 'C:\\wamp\\www\\extranet\\');
define ('PATH_SITE', realpath(dirname(__FILE__) . '/../'));
define ('PATH_WWW', PATH_SITE.'/www/');
define ('PATH_LOGS', PATH_SITE.'/log/');
define ('PATH_PDF', PATH_WWW.'/pdf/');
define ('PATH_LOGOS', PATH_WWW.'/img/logos/');
define ('EXTRANET_URL', 'http://extranet.scores-decisions.com/');
define ('IPARI_URL', 'http://tville.scores-decisions.com:8080/ipari/');
define ('SITEINST_URL1', 'http://www.scores-decisions.com/');
define ('SITEINST_URL2', 'http://www2.scores-decisions.com/');
/* define ('WEBSERVICE_URL', 'http://tville.scores-decisions.com/ws/');
define ('WEBSERVICE_URI', 'http://tville.scores-decisions.com/');
*/
// define ('WEBSERVICE_URL', 'http://88.185.121.243/ws/');
// define ('WEBSERVICE_URI', 'http://88.185.121.243/');
/** Celeste **/
define ('WEBSERVICE_URL', 'http://78.31.45.206/ws/');
define ('WEBSERVICE_URI', 'http://78.31.45.206/');
/* Free Saulnier 2 **/
// define ('WEBSERVICE_URL', 'http://88.162.202.159/ws/');
// define ('WEBSERVICE_URI', 'http://88.162.202.159/');
/** INFOGREFFE **/
//define('INFOGREFFE_WS_URL', 'https://wv2rcte.experian.fr/WSContextInfogreffe/INFOGREFFE');
define('INFOGREFFE_WS_URL', 'https://webservices.infogreffe.fr/WSContextInfogreffe/INFOGREFFE');
//define('INFOGREFFE_WS_URI', 'https://wv2rcte.experian.fr/');
define('INFOGREFFE_WS_URI', 'https://webservices.infogreffe.fr/');
//define('INFOGREFFE_WS_USER', '85009006');
//define('INFOGREFFE_WS_PASS', '17628');
define('INFOGREFFE_WS_USER', '85000109');
define('INFOGREFFE_WS_PASS', '166');
/** Paramètres de la base de données **/
define ('FTPACTES_HOST', 'ftp2.scores-decisions.com');
define ('FTPACTES_USER', 'inpi');
define ('FTPACTES_PASS', 'coface');
define('INFOGREFFE_WS_REF', 'ref');
?>

134
config/prepend.php Normal file
View File

@ -0,0 +1,134 @@
<?php
/**
* Fonction globale récupérant le microtime de la machine en format float.
* @return float Valeur courante du microtime() de la machine en format décimal
*/
function getmicrotime(){
list($usec, $sec) = explode (' ', microtime());
return ( (float)$sec + (float)$usec );
}
/**********************************************************************
* Ce script est chargé par tous les scripts PHP
**********************************************************************
* $Id: $
* $Author: $
* $Revision: $
**********************************************************************/
/** On ne prend l'heure qu'une seule fois par script PHP et on initialise des constantes.
*
* DATETIME YmdHis
* DATETIME_LOG Y-m-d H:i:s Date du jour pour les insertions en BDD
* NOW His Heure d'exécution du script
* NOW_FORMAT H:i:s Heure d'exécution du script
* TODAY Ymd Année, Mois, Jour d'ex�cution du script
* TODAY_FORMAT Y-m-d
* TODAY_AFF d/m/Y
*/
define ('DATETIME', date('YmdHis'));
define ('DATETIME_LOG', substr(DATETIME,0,4).'-'.substr(DATETIME, 4,2).'-'.substr(DATETIME, 6,2).' '.substr(DATETIME,8,2).'-'.substr(DATETIME,10,2).'-'.substr(DATETIME,12,2) );
define ('TODAY', substr(DATETIME,0,8));
define ('NOW', substr(DATETIME,8,6));
define ('TODAY_FORMAT', substr(DATETIME,0,4).'-'.substr(DATETIME,4,2).'-'.substr(DATETIME,6,2));
define ('TODAY_AFF', substr(DATETIME,6,2).'/'.substr(DATETIME,4,2).'/'.substr(DATETIME,0,4));
define ('NOW_FORMAT', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
/**
* Les librairies suivantes sont chargées automatiquement car tous les scripts les utilisent !
*/
if( !defined('ROOT_PATH') )
{
define ('ROOT_PATH', realpath(dirname(__FILE__) . '/../') );
define ('WWW_PATH', realpath(ROOT_PATH.'/www/') );
define ('LOG_PATH', realpath(ROOT_PATH.'/log/') );
define ('INCLUDE_PATH', realpath(ROOT_PATH.'/includes/') );
define ('PEAR_PATH', realpath('C:\\wamp\\bin\\php\\php5.2.8\\PEAR\\') );
include_once realpath(INCLUDE_PATH.'/phplib/db_mysql.inc');
include_once realpath(INCLUDE_PATH.'/auth/sessions.inc');
//include_once realpath(INCLUDE_PATH.'/auth/sessions.local.inc');
include_once realpath(ROOT_PATH.'/config/config.inc');
}
/*
if ( LOG_BENCH != 'NONE' ){
include_once realpath(PEAR_PATH . '/Benchmark/Timer.php');
}else{
class Benchmark_Timer
{
function start() {}
function setMarker() {}
function stop() {}
function getProfiling() {}
function display() {}
}
}
*/
/* @todo: A enlever pour la prod
$timer = new Benchmark_Timer();
$timer->start();
$timer->setMarker('Debut du script (prepend.php)');
*/
/** Instance de la connexion � la base de donn�es
* Cette instance est utilis�e par tous les scripts pour acc�der � la base de donn�es
*/
class DB extends DB_MySQL
{
function DB() {
$this->Host = MYSQL_HOST;
$this->Database = MYSQL_DB;
$this->User = MYSQL_USER;
$this->Password = MYSQL_PASS;
}
function getRow() {
$ret= $this->Record;
for( $i= 0; $i<count($this->Record); $i++ ) { if( !isset($ret[$i]) ) break; unset($ret[$i]); }
return $ret;
}
function query($q) {
if ( LOG_MYSQL != 'NONE' ) $time_start=getmicrotime();
$ret=DB_MySQL::query($q);
if ( LOG_MYSQL == 'NONE' ) return $ret;
$time_end= getmicrotime();
$time_total= $time_end-$time_start;
$time_total= substr((string)$time_total,0,10);
$now= date('Y/m/d H:i:s', $time_start);
if ($ret<1)
$mysqlerror = mysql_errno() .' : '. mysql_error();
else
$mysqlerror = '';
$sqlAction=strtoupper(substr(trim($q),0,6));
if ( LOG_MYSQL=='SELECT' && $sqlAction=='SELECT' )
$logOption='_select';
elseif ( LOG_MYSQL=='UPDATE' && ( $sqlAction=='UPDATE' || $sqlAction=='INSERT' || $sqlAction=='DELETE' ) )
$logOption='_update';
else
$logOption='';
$fh=@fopen( LOG_PATH . 'db_mysql'.$logOption.'.log', 'a+');
if ($fh) {
@fwrite($fh, "$now\t$time_total\t" . MYSQL_HOST ."\t". MYSQL_USER ."\t". MYSQL_DB ."\t$mysqlerror\t$q\r\n");
@fclose($fh);
}
$mySqlErrTab=explode(' : ', $mysqlerror);
$mySqlErrno=(int)$mySqlErrTab[0];
if ( $mySqlErrno > 0 && $mySqlErrno !=1062 ) {
// mail_admin( 'Erreur MySQL '.$mySqlErrno, $mysqlerror ."\n\n". $q );
}
return $ret;
}
}
?>

View File

@ -0,0 +1,39 @@
<?
class WChiffes {
private static $tabChiffresEnLEttres = array( 0=>'zéro',
1=>'un',
2=>'deux',
3=>'trois',
4=>'quatre',
5=>'cinq',
6=>'six',
7=>'sept',
8=>'huit',
9=>'neuf',
10=>'dix',
11=>'onze',
12=>'douze',
13=>'treize',
14=>'quatorze',
15=>'quinze',
16=>'seize',
17=>'dix sept',
18=>'dix huit',
19=>'dix neuf',
20=>'vingt',
30=>'trente',
40=>'quarante',
50=>'cinquante',
60=>'soixante',
70=>'soixante dix',
80=>'quatre vingt',
90=>'quatre vingt dix');
public function ChiffresEnLettres($chiffre) {
return array_search($chiffre, self::$tabChiffresEnLEttres);
}
}
?>

167
framework/common/curl.php Normal file
View File

@ -0,0 +1,167 @@
<?
//include_once('/var/www/default/_includes/timer.php');
/** Parse une page Html et retourne son contenu dans un tableau :
** "code" => Code réponse Serveur
** "header" => Headers du serveur
** "body" => Page HTML
**/
function parse_response($this_response) {
// Split response into header and body sections
list($response_headers, $response_body) = explode("\r\n\r\n", $this_response, 2);
$response_header_lines = explode("\r\n", $response_headers);
// First line of headers is the HTTP response code
$http_response_line = array_shift($response_header_lines);
if(preg_match('@^HTTP/[0-9]\.[0-9] ([0-9]{3})@',$http_response_line, $matches)) { $response_code = $matches[1]; }
// put the rest of the headers in an array
$response_header_array = array();
$nbRMID=0;
foreach($response_header_lines as $header_line)
{
list($header,$value) = explode(': ', $header_line, 2);
if ($header=='Set-cookie' && substr($value,0,5)=='RMID=' && $nbRMID<5)//{
$nbRMID++;
// echo ("Je gicle le RMID n°$nbRMID\r\n");}
else
$response_header_array[$header] .= $value."\n";
}
return array('code' => $response_code, 'header' => $response_header_array, 'body' => $response_body);
}
/** Récupère une page HTML en fonction des paramètres :
** $url Url distante de la page à récupérer
** $strCookies Chaine de caractère contenant les cookies
** $postData Tableau des données à passer en POST uniquement
** $referer Referer à indiquer lors de l'appel de la page
** $debug Activer le débogage (True/False)
**
** ... et retourne son contenu dans un tableau :
** "code" => Code réponse Serveur
** "header" => Headers du serveur
** "body" => Page HTML
**/
function getUrl($url, $strCookies='', $postData='', $referer='', $debug=false, $host='', $proxy='', $timeout=0, $acceptRedir=0) {
$ch = curl_init();
if ($host=='') {
$tabTmp = parse_url($url);
$hostUrl = $tabTmp['host'];
$this_header = array('Host: '. $hostUrl);
} else
$this_header = array('Host: '. $host);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
if ($proxy<>'') curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'username:password'); // Pas nécessaire en authentification NT
if (((int)$timeout)<>0) curl_setopt($ch, CURLOPT_TIMEOUT, (int)$timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if ($acceptRedir>0) {
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, $acceptRedir);
}
$user_agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt($ch, CURLOPT_REFERER, $referer);
// Add each cookie that has been returned in the response
// If cookies need to be added/deleted or value changed, then add code here
if ($strCookies!='') {
//die('"'.$strCookies.'"');
//echo $strCookies."\r\n";
$cookies = explode("\n", $strCookies);
// Create the basic header
foreach($cookies as $this_cookie) {
if (trim($this_cookie)<>'')
array_push($this_header, 'Cookie: '.$this_cookie);
}
}
if ($postData!='') {
if (is_array($postData))
$post_data=$postData;
$o="";
foreach ($post_data as $k=>$v)
{
$o.= "$k=".utf8_encode($v)."&";
}
$post_data=substr($o,0,-1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
//if in_array('',$this_header
/*array_push($this_header, "Content-type: application/x-www-form-urlencoded");
array_push($this_header, "Content-Length: 44");*/
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $this_header);
//print_r($this_header);
$page=curl_exec($ch);
$response = parse_response($page);
if ($debug){
$url2=str_replace('http://', '', $url);
$url2=str_replace('/', '_', $url2);
$url2=str_replace('?', '(param)', $url2);
$url2=str_replace('&', '(et)', $url2);
$fp=fopen('insee/'. date('Ymd-His') .'-'. microtime_float(true) .'-'. $url2 . '.html', 'a');
fwrite($fp, $url."\r\n");
fwrite($fp, $page);
fclose($fp);
//echo strip_tags(html_entity_decode($response['body']), '<td>');
}
//print_r(curl_getinfo($ch));
curl_close($ch);
return $response;
}
/** Recherche un texte dans une page HTML
**
**/
function getTextInHtml($pageHtml, $strToFind, $strDeb, $strEnd, $include_strDeb=false, $include_strEnd=false, $ltrim=true, $rtrim=true, &$fin, $nbOcc=1) {
$tabRet=array();
$deb=$nbOccTrouve=0;
while( is_int(($deb=strpos($pageHtml,$strToFind,$fin))) ) {
$deb++;
$deb2 = strpos($pageHtml,$strDeb, $deb);
$fin = strpos($pageHtml,$strEnd, $deb2);
if (!$include_strDeb)
$deb2+=strlen($strDeb);
$s_temp = substr($pageHtml, $deb2, ($fin-$deb2));
if ($ltrim) $s_temp=ltrim($s_temp);
if ($rtrim) $s_temp=rtrim($s_temp);
if ($nbOcc==1) return $s_temp;
//echo $s_temp."\r\n";
//$a_temp = explode('" class="basic">', $s_temp);
$tabUrl[$nbOccTrouve]=$s_temp;
$nbOccTrouve++;
if ($nbOcc==$nbOccTrouve) {
// echo "j'ai trouvé le nb demandé, je sort\r\n";
break;
};
}
return $tabUrl;
/*<span class="mongrasvert">
<li>Le type de voie a été modifié<br>
<li>L'orthographe du mot directeur a été modifiée<br>
<li>Le code postal a été forcé à partir du département et de la localité<br> </span>
*/
}
?>

124
framework/common/dates.php Normal file
View File

@ -0,0 +1,124 @@
<?
include_once('chiffres.php');
/**
* Classe de gestion des méthodes relatives à la date et à l'heure
*
* <p>détail de la classe</p>
*
* @name nom de la classe
* @author Nom de l'auteur <adresse@Email.dom>
* @link
* @copyright Prénom Nom Année
* @version 1.0.0
* @package Nom du package
*/
class WDate {
private static $tabMoisEnLettres = array( 1=>'Janvier',
2=>'Février',
3=>'Mars',
4=>'Avril',
5=>'Mai',
6=>'Juin',
7=>'Juillet',
8=>'Août',
9=>'Septembre',
10=>'Octobre',
11=>'Novembre',
12=>'Décembre');
/** Retourne le numéro du mois donné au format texte (janvier, mars, etc...)
* @param string Mois en toute lettres (janvier, mars, etc...)
* @return string Mois en Chiffe (1, 3, 12) / false en cas d'erreur
*/
public function getNumMois($moisEnLettres) {
foreach (self::$tabMoisEnLettres as $num=>$mois)
$tabMoisSansAccents[$num]=strtr($mois, 'ééû','eeu');
return array_search(ucfirst(strtolower(strtr($moisEnLettres, 'ééû','eeu'))), $tabMoisSansAccents);
}
/** Retourne le libellé nu numéro du mois passé en paramètre
* @param int $moisEnChiffre
* @return string Libellé du mois / false si le mois passé en paramètre est invalide
*/
public function getLibelleMois($moisEnChiffre) {
if ($moisEnChiffre>0 && $moisEnChiffre<13)
return self::$tabMoisEnLettres[$moisEnChiffre];
return false;
}
/**
* Conversion de formats de dates selon les formats de dates définits en php
* @param string Format de la date d'entrée
* @param string Format de la date de sortie
* @param string Date d'entrée
* @return string Date formatée
*/
public function dateT($formatIN, $formatOUT, $date) {
$M='';
switch ($formatIN) {
case 'd M Y': $tmp=explode(' ', $date); $d=str_replace('1er', '1', $tmp[0]); $m=getNumMois($tmp[1]); $Y=$tmp[2]; break;
case 'dMY': $Y=substr($date,-4);
if (substr($date,0,3)=='1er') { $d=1; $posM=3; }
elseif (is_numeric(substr($date,1,1))) { $d=substr($date,0,2); $posM=2; }
else { $d=substr($date,0,1); $posM=1; }
$M=substr($date, $posM, strlen($date)-4-$posM);
$m=self::getNumMois($M);
break;
case 'Ymd': $d=substr($date,6,2); $m=substr($date,4,2); $Y=substr($date,0,4); break;
case 'Y-m-d': $d=substr($date,8,2); $m=substr($date,5,2); $Y=substr($date,0,4); break;
case 'd/m/Y': $d=substr($date,0,2); $m=substr($date,3,2); $Y=substr($date,6,4); break;
default: return $date;
}
if ($m*1>0 && $m*1<10) $m='0'.($m*1); if ($d*1>0 && $d*1<10) $d='0'.($d*1);
switch ($formatOUT) {
case 'd/m/Y': return $d.'/'.$m.'/'.$Y; break;
case 'm/Y': return $m.'/'.$Y; break;
// case 'M Y': return $this->tabMoisEnLettres[$m].' '.$Y; break;
case 'Y': return $Y; break;
case 'm': return $m; break;
case 'd': return $d; break;
case 'Ym': return $Y.$m; break;
case 'Ymd': return $Y.$m.$d; break;
case 'Y-m-d': return $Y.'-'.$m.'-'.$d; break;
case 'Y/m/d': return $Y.'/'.$m.'/'.$d; break;
default: return $date;
}
}
/** Calcul de la date après application de la période textuelle (deux ans, six mois, quinze jours, etc...)
* @todo Fonction ne fonctionnant qu'avec un chiffre en un seul mot du genre dix mais pas quatre vingt dix !!!
* @param date $dateIN au format Ymd
* @param string $period (ex : cinq mois, six ans, un jour)
* @return date
*/
function period2Days($dateIN, $period) {
$dateV=self::dateT('Ymd', 'Ymd', $dateIN);
if ($dateV<>$dateIN) return NULL;
$d=substr($dateIN,6,2);
$m=substr($dateIN,4,2);
$Y=substr($dateIN,0,4);
$period=trim(strtr($period, "-.,", ' '));
if ($period=='') return NULL;
$tabP=explode(' ', $period);
$chiffre=WChiffes::ChiffresEnLettres($tabP[0]);
switch (end($tabP)) {
case 'mois': $dateOUT=date('Ymd', mktime(0, 0, 0, $m+$chiffre, $d, $Y)); break;
case 'an':
case 'ans': $dateOUT=date('Ymd', mktime(0, 0, 0, $m, $d, $Y+$chiffre)); break;
case 'jour':
case 'jours': $dateOUT=date('Ymd', mktime(0, 0, 0, $m, $d+$chiffre, $Y)); break;
default: $dateOUT=NULL;
}
return $dateOUT;
}
}
?>

56
framework/common/ftp.php Normal file
View File

@ -0,0 +1,56 @@
<?php
function ftp_mget($ftp_url, $ftp_user, $ftp_pass, $ftp_dir, $local_dir, $debug=null) {
$conn_id = @ftp_connect($ftp_url);
if (!$conn_id) {
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de se connecter au serveur FTP ($ftp_url) !".EOL;
return false;
}
$login_result = @ftp_login($conn_id, $ftp_user, $ftp_pass);
if (!$login_result) {
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de s'authentifier sur le serveur FTP (user=$ftp_user)!".EOL;
return false;
}
// Récupération du contenu d'un dossier
$contents = ftp_nlist($conn_id, $ftp_dir);
$nbFic=0; // Nombre de fichiers récupérés
if (is_array($contents))
foreach($contents as $k => $server_file) {
$tailleDist = ftp_size($conn_id, $server_file);
$dateDist = ftp_mdtm($conn_id, $server_file);
$tailleLoc=0;
if ($dateDist != -1) {
$tabFichiers[$server_file]['dateDispo']=date('Y-m-d H:i:s', $dateDist);
if ($debug<>null) echo date ('Y/m/d - H:i:s') ." - Le fichier distant $server_file a été modifié le ".date("d/m/Y à H:i:s.",$dateDist)."\n";
} else {
$tabFichiers[$server_file]['dateDispo']=NULL;
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Impossible de récupérer l'heure de modification du fichier distant $server_file !\n";
}
$tabFichiers[$server_file]['taille']=$tailleDist;
if ($tailleDist != -1) {
if ($debug<>null) echo date ('Y/m/d - H:i:s') ." - Taille du fichier distant $server_file est de $tailleDist octets\n";
}
if (file_exists($local_dir . $server_file)) {
$dateLoc=filemtime($local_dir . $server_file);
$tabFichiers[$server_file]['dateDownload']=date('Y-m-d H:i:s', $dateLoc);
$tailleLoc=filesize($local_dir . $server_file);
if ($debug<>null) echo date ('Y/m/d - H:i:s') ." - Taille du fichier local $server_file = $tailleLoc octets\n";
}
if ($tailleDist<>$tailleLoc) {
if (ftp_get($conn_id, $local_dir. $server_file, $server_file, FTP_BINARY)) {
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - Fichier distant $server_file téléchargé avec succès".EOL;
$nbFic++;
} else {
if ($debug<>null) echo date ('Y/m/d - H:i:s')." - ERREUR : Fichier distant $server_file non téléchargé !".EOL;
return false;
}
}
}
// Fermeture de la connexion
ftp_close($conn_id);
return $nbFic;
}
?>

151
framework/common/mysql.php Normal file
View File

@ -0,0 +1,151 @@
<?php
class WDB {
private $host;
private $database;
private $user;
private $password;
private $con_id; // Connection ID with MySQL
private $result;
public function __construct($database='', $host='', $user='', $password='') {
if ($host=='') $this->host=MYSQL_HOST;
else $this->host=$host;
if ($user=='') $this->user=MYSQL_USER;
else $this->user=$user;
if ($password=='') $this->password=MYSQL_PASS;
else $this->password=$password;
if ($database=='') $this->database=MYSQL_DEFAULT_DB;
else $this->database=$database;
$this->con_id = mysql_pconnect($this->host, $this->user, $this->password);
if (!($this->con_id === false)) {
if (mysql_select_db($this->database, $this->con_id) === false) {
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
echo date ('Y/m/d - H:i:s'). mysql_error();
die();
}
}
}
public function setCharSet($charSet) {
return (mysql_query("SET CHARACTER SET $charSet;", $this->con_id));
}
/** INSERTION d'un tableau dans une table.
** Les index doivent avoir les mêmes noms que les champs.
** @param string Table
** @param array Valeurs insérer
** @return int Dernière valeur de l'auto-incrément, 1 si pas d'auto-incrément et 0 si erreur
**/
public function insert($table, $toAdd, $debug=false){
$fields = implode(array_keys($toAdd), '`,`');
foreach (array_values($toAdd) as $key=>$array_values)
$tmp[$key]=checkaddslashes($array_values);
$values = "'".implode(array_values($tmp), "','")."'"; # better
$query = 'INSERT INTO `'.$table.'` (`'.$fields.'`) VALUES ('.$values.');';
if ($debug) $tdeb=microtime_float();
$res = mysql_query($query, $this->con_id);
if ($res!==false)
{
if (mysql_insert_id()>0)
$res=mysql_insert_id();
else
$res=true;
}
if ($debug) $this->trace($query, $res, $tdeb);
return $res;
}
public function update($table, $update, $where, $debug=false){
$fields = array_keys($update);
$values = array_values($update);
$i=0;
$query='UPDATE `'.$table.'` SET ';
while(isset($fields[$i])){
if($i>0) { $query.=', '; }
$query.=' `'.$fields[$i]."`='".addslashes($values[$i])."'";
$i++;
}
$query.=' WHERE '.$where.' LIMIT 1;';
if ($debug) $tdeb=microtime_float();
$res=mysql_query($query, $this->con_id);
if ($debug) $this->trace($query, $res, $tdeb);
return true;
}
public function delete($table, $where, $debug=false) {
$query='DELETE FROM `'.$table.'` WHERE '.$where.' LIMIT 1;';
if ($debug) $tdeb=microtime_float();
$res=mysql_query($query, $this->con_id);
if ($debug) $this->trace($query, $res, $tdeb);
return true;
}
public function select($table, $fields, $where, $debug=false, $assoc=MYSQL_BOTH, $huge=false) {
if (mysql_select_db($this->database, $this->con_id) === false) {
echo date('Y/m/d - H:i:s') ." - ERREUR ".mysql_errno()." : Connection à la base de données impossible !".EOL;
echo date ('Y/m/d - H:i:s'). mysql_error();
die();
}
$query="SELECT $fields FROM $table WHERE $where;";
if ($debug) $tdeb=microtime_float();
$this->result=mysql_query($query, $this->con_id);// or die(mysql_error());
if (mysql_errno()) die(mysql_errno() .' : '. mysql_error());
// echo $query;
if (!$huge) {
$tab=array();
while ($ligne = mysql_fetch_array($this->result, $assoc))
$tab[]=$ligne;
if ($debug) $this->trace($query, sizeof($tab), $tdeb);
return $tab;
} else {
$nbRows=mysql_num_rows($this->result);
if ($debug) $this->trace($query, $nbRows, $tdeb);
return $nbRows;
}
}
public function fetch($assoc=MYSQL_BOTH) {
return mysql_fetch_array($this->result, $assoc);
}
public function trace($query, $res='', $tdeb=-1) {
if (!$fp=fopen('mysql_insert.log', 'a'))
return false;
$errnum=mysql_errno($this->con_id);
if ($tdeb>-1) $duree=substr(''.microtime_float()-$tdeb, 0, 5);
else $duree='N/D';
if (!fwrite($fp, date('Y/m/d - H:i:s') ." - $errnum - $res - $duree - $query\n"))
return false;
if (!fclose($fp))
return false;
return true;
}
/** Exécute la requête passé en paramètre **/
public function query($query, $debug=false){
return mysql_query($query, $this->con_id);
}
/** Retourne le libellé de la dernière erreur **/
public function getLastErrorMsg() {
return mysql_error($this->con_id);
}
/** Retourne le numéro de la dernière erreur **/
public function getLastErrorNum() {
return mysql_errno($this->con_id);
}
/** Retourne le libellé et le numéro de la dernière erreur **/
public function getLastError() {
return mysql_error($this->con_id).' ('.mysql_errno($this->con_id).')';
}
}
?>

View File

@ -0,0 +1,419 @@
<?
define ('BEFORE', 0);
define ('AFTER', 1);
define ('BOTH', 2);
define ('ALIGN_LEFT', 0);
define ('ALIGN_RIGHT', 1);
/**Initialisation d'une chaîne de caractère
*
* @param string $chaine Chaîne de caractère initiale
* @param int $taille Taille de la chaîne de caractère à initialiser
* @param string $caractere_pour_combler Caractère à utiliser pour combler la chaîne de caractère (espace par défaut)
* @param string $align Aligner la chaîne de caractère à droite (right) ou à gauche (left, par défaut)
* @return string
*/
function initstr($chaine, $taille, $caractere_pour_combler=' ', $align=ALIGN_LEFT) {
if ($align==ALIGN_RIGHT) {
$str2='';
for ($i=0;$i<($taille-strlen($chaine));$i++)
$str2.=$caractere_pour_combler;
$str=$str2.$chaine;
} else {
if (strlen($chaine)>=$taille)
return substr($chaine,0,$taille);
$str=$chaine;
for ($i=strlen($chaine);$i<$taille;$i++)
$str = $str . $caractere_pour_combler;
}
return $str;
}
/**
* Ajout d'anti-slashs s'il y a lieu en vu d'une insertion en BDD
*
* @param string $str Chaine de caractère
* @return unknown
*/
function checkaddslashes($str){
return addslashes(preg_replace('/\\[^nrt\']/i', '\\', $str));
}
function checkaddslashes2($str){
if(strpos(str_replace("\'",''," $str"),"'")!=false)
return addslashes($str);
else
return $str;
}
function trimAccent ($strWithAccent) {
$strWithAccent = htmlentities(strtolower($strWithAccent ));
$strWithAccent = preg_replace("/&(.)(acute|cedil|circ|ring|tilde|uml|grave);/", "$1", $strWithAccent );
$strWithAccent = preg_replace("/([^a-z0-9]+)/", " ", html_entity_decode($strWithAccent ));
$strWithAccent = trim($strWithAccent , "-");
return $strWithAccent;
}
//function SRSaufVoyelle ($strIn, $mot1, $mot2) {
function str_replace_except_voy($mot1, $mot2, $strIn, $rule=0) {
$Voyelle=array('a','e','i','o','u','y', '1', '2', '3', '4');
if ($mot1==$mot2) return $strIn;
if (strpos($mot2,$mot1)===false)
{
//foreach ($Voyelle as $k => $voy)
$posMot1=strpos($strIn, $mot1);
while ($posMot1!==false) {
$lettreAV=$strIn[$posMot1-1];
$lettreAP=$strIn[$posMot1+strlen($mot1)];
//echo "Lettre AV=$lettreAV<br/>";
//echo "Lettre AP=$lettreAP<br/>";
if ( ( $rule==0 && !in_array($lettreAV, $Voyelle) ) ||
( $rule==1 && !in_array($lettreAP, $Voyelle) ) ||
( $rule==2 && !in_array($lettreAV, $Voyelle) && !in_array($lettreAP, $Voyelle) ))
$strIn=substr($strIn,0,$posMot1) . $mot2 . substr($strIn,$posMot1+strlen($mot1),strlen($strIn));
//echo "Le Mot devient : $strIn<br/>";
$posMot1=strpos($strIn, $mot1, $posMot1+strlen($mot1));
}
return $strIn;
}
//echo "Erreur : $mot2 contient $mot1 !<br>";
return $strIn;
}
/** Retourne le phonex d'un mot
**/
function phonex($strIn) {
if ($strIn=='') return 0.0;
$tabSonAIA=array('aina', 'eina', 'aima', 'eima');
$tabSonAIE=array('ainr', 'eine', 'aime', 'eime');
$tabSonAII=array('aini', 'eini', 'aimi', 'eimi');
$tabSonAIO=array('aino', 'eino', 'aimo', 'eimo');
$tabSonAIU=array('ainu', 'einu', 'aimu', 'eimu');
$tabCarPhon=array('1', '2', '3', '4', '5', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'n', 'o', 'r', 's', 't', 'u', 'w', 'x', 'y', 'z');
/** On traite tout en minuscule **/
$strIn=strtolower($strIn);
/** On remplace les 'Y' par des 'I' **/
$strIn=str_replace('y', 'i', $strIn);
/** On supprime les accents **/
$strIn=trimAccent($strIn);
/** On retire les 'H' muets sauf ceux précédés par 'C' ou 'S' **/
$strIn = preg_replace ('/(?<![CS])H/', '', $strIn);
/** On remplace les 'PH' par des 'F' **/
$strIn=str_replace('ph', 'f', $strIn);
/** On remplace les 'G' par des 'K' devant AN AM AIN AIM **/
$strIn=str_replace('gan', 'kan', $strIn);
$strIn=str_replace('gain', 'kain', $strIn);
$strIn=str_replace('gam', 'kam4', $strIn);
$strIn=str_replace('gaim', 'kaim', $strIn);
/** On remplace le son AI **/
for ($i=0; $i>4; $i++) {
$strIn=str_replace($tabSonAIA[$i], 'yna', $strIn);
$strIn=str_replace($tabSonAIE[$i], 'yne', $strIn);
$strIn=str_replace($tabSonAII[$i], 'yni', $strIn);
$strIn=str_replace($tabSonAIO[$i], 'yno', $strIn);
$strIn=str_replace($tabSonAIU[$i], 'ynu', $strIn);
}
/** Remplacement des groupes de 3 lettres **/
$strIn=str_replace('eau', 'o', $strIn);
$strIn=str_replace('oua', '2', $strIn);
$strIn=str_replace('ein', '4', $strIn);
$strIn=str_replace('ain', '4', $strIn);
/** Remplacement du son 'é' **/
$strIn=str_replace('ai', 'y', $strIn);
$strIn=str_replace('ei', 'y', $strIn);
$strIn=str_replace('er', 'yr', $strIn);
$strIn=str_replace('ess', 'yss', $strIn);
$strIn=str_replace('et', 'yt', $strIn);
$strIn=str_replace('ez', 'yz', $strIn);
/** Remplacement des groupes de 2 lettres sauf si voyelle ou son (1 à 4) AVANT **/
$strIn=str_replace_except_voy('an', '1', $strIn, BEFORE);
$strIn=str_replace_except_voy('am', '1', $strIn, BEFORE);
$strIn=str_replace_except_voy('en', '1', $strIn, BEFORE);
$strIn=str_replace_except_voy('em', '1', $strIn, BEFORE);
$strIn=str_replace_except_voy('in', '4', $strIn, BEFORE);
/** Remplacement du son 'SCH' **/
$strIn=str_replace('sch', '5', $strIn);
/** Remplacement du 'S' sauf si voyelle ou son (1 à 4) avant ou après **/
$strIn=str_replace_except_voy('in', '4', $strIn, BOTH);
/** Remplacement de groupe de 2 lettres diverses **/
$strIn=str_replace('oe', 'e', $strIn);
$strIn=str_replace('eu', 'e', $strIn);
$strIn=str_replace('au', 'o', $strIn);
$strIn=str_replace('oi', '2', $strIn);
$strIn=str_replace('oy', '2', $strIn);
$strIn=str_replace('ou', '3', $strIn);
$strIn=str_replace('ch', '5', $strIn);
$strIn=str_replace('sh', '5', $strIn);
$strIn=str_replace('ss', 's', $strIn);
$strIn=str_replace('sc', 's', $strIn);
/** Remplacement du 'C' par 'S' s'il est suivi d'un 'E' ou d'un 'I' **/
$strIn=str_replace('ce', 'se', $strIn);
$strIn=str_replace('ci', 'si', $strIn);
/** Remplacement divers **/
$strIn=str_replace('c', 'k', $strIn);
$strIn=str_replace('q', 'k', $strIn);
$strIn=str_replace('qu', 'k', $strIn);
$strIn=str_replace('ga', 'ka', $strIn);
$strIn=str_replace('go', 'ko', $strIn);
$strIn=str_replace('gu', 'ku', $strIn);
$strIn=str_replace('gy', 'ky', $strIn);
$strIn=str_replace('g2', 'k2', $strIn);
$strIn=str_replace('g1', 'k1', $strIn);
$strIn=str_replace('g3', 'k3', $strIn);
$strIn=str_replace('a', 'o', $strIn);
$strIn=str_replace('d', 't', $strIn);
$strIn=str_replace('p', 't', $strIn);
$strIn=str_replace('j', 'g', $strIn);
$strIn=str_replace('b', 'f', $strIn);
$strIn=str_replace('v', 'f', $strIn);
$strIn=str_replace('m', 'n', $strIn);
/** Supression des lettres dupliquées **/
$let=$strIn[0];
$strIn2=$let;
for ($i=1; $i<strlen($strIn); $i++)
{ if ($strIn==$let)
continue;
else {
$let=$strIn[$i];
$strIn2.=$strIn[$i];
}
}
$strIn=$strIn2;
/** Supression des terminaisons **/
$strIn2=substr($strIn,-1);
if ($strIn2=='t' || $strIn2=='k' || $strIn2=='s' || $strIn2=='z')
$strIn=substr($strIn,0,-1);
/** Supression des caractères non autorisés **/
$j=10;
$sout=array();
for ($i=0; $i<strlen($strIn); $i++)
{
if ($j<1) break;
for ($k=0; $k<22; $k++)
{
if ($strIn[$i]==$tabCarPhon[$k])
{
$sout[$j]=$k;
$j--;
}
}
}
print_r($tabCarPhon);
/** Couversion en flottant **/
$result=0.0;
for ($j=10; $j>0; $j--)
$result+=$sout[$j]*pow($j-1,10);
return $result;
}
/**
* CLASS soundex2
* soundex2 French version
* based on the algorithm described here : http://sqlpro.developpez.com/cours/soundex/ by Frédéric BROUARD
*
* author Johan Barbier <barbier_johan@hotmail.com>
*/
class csoundex2 {
/**
* public sString
* main string we work on
*/
var $sString = '';
/**
* vowels replacement array
*/
var $aReplaceVoy1 = array (
'E' => 'A',
'I' => 'A',
'O' => 'A',
'U' => 'A'
);
/**
* consonnants replacement array
*/
var $aReplaceGrp1 = array (
'GUI' => 'KI',
'GUE' => 'KE',
'GA' => 'KA',
'GO' => 'KO',
'GU' => 'K',
'CA' => 'KA',
'CO' => 'KO',
'CU' => 'KU',
'Q' => 'K',
'CC' => 'K',
'CK' => 'K'
);
/**
* other replacement array
*/
var $aReplaceGrp2 = array (
'ASA' => 'AZA',
'KN' => 'NN',
'PF' => 'FF',
'PH' => 'FF',
'SCH' => 'SSS'
);
/**
* endings replacement array
*/
var $aEnd = array (
'A',
'T',
'D',
'S'
);
/**
* public function build
* core function of the class, go through the whole process
* @Param string sString : the string we want to check
*/
function build ($sString) {
/**
* let's check it's a real string...
*/
if (is_string ($sString) && !empty ($sString)) {
$this -> sString = $sString;
} else {
trigger_error ('Parameter string must not be empty', E_USER_ERROR);
}
/**
* remove starting and ending spaces
*/
$this -> sString = trim ($this -> sString);
/**
* remove special french characters
*/
$this -> trimAccent ();
/**
* string to upper case
*/
$this -> sString = strtoupper ($this -> sString );
/**
* let's remove every space in the string
*/
$this -> sString = str_replace (' ', '', $this -> sString);
/**
* let's remove every '-' in the string
*/
$this -> sString = str_replace ('-', '', $this -> sString);
/**
* let's process through the first replacement array
*/
$this -> arrReplace ($this -> aReplaceGrp1);
/**
* let's process through th vowels replacement
*/
$sChar = substr ($this -> sString, 0, 1);
$this -> sString = substr ($this -> sString, 1, strlen ($this -> sString) - 1);
$this -> arrReplace ($this -> aReplaceVoy1);
$this -> sString = $sChar.$this -> sString;
/**
* let's process through the second replacement array
*/
$this -> arrReplace ($this -> aReplaceGrp2, true);
/**
* let's remove every 'H' but those prededed by a 'C' or an 'S'
*/
$this -> sString = preg_replace ('/(?<![CS])H/', '', $this -> sString);
/**
* let's remove every 'Y' but those preceded by an 'A'
*/
$this -> sString = preg_replace ('/(?<!A)Y/', '', $this -> sString);
/**
* remove endings in aEnd
*/
$length = strlen ($this -> sString) - 1;
if (in_array ($this -> sString{$length}, $this -> aEnd)) {
$this -> sString = substr ($this -> sString, 0, $length);
}
/**
* let's remove every 'A', but the one at the beginning of the string, if any.
*/
$sChar = '';
if ($this -> sString{0} === 'A') {
$sChar = 'A';
}
$this -> sString = str_replace ('A', '', $this -> sString);
$this -> sString = $sChar.$this -> sString;
/**
* let's have only 1 occurence of each letter
*/
$this -> sString = preg_replace( '/(.)\1/', '$1', $this -> sString );
/**
* let's have the final code : a 4 letters string
*/
$this -> getFinal ();
}
/**
* private function getFinal
* gets the first 4 letters, pads the string with white space if the string length < 4
*/
function getFinal () {
if (strlen ($this -> sString) < 4) {
$this -> sString = str_pad ($this -> sString, 4, ' ', STR_PAD_RIGHT);
} else {
$this -> sString = substr ($this -> sString, 0, 4);
}
}
/**
* private function trimAccent
* remove every special French letters
*/
function trimAccent () {
$this -> sString = htmlentities(strtolower($this -> sString ));
$this -> sString = preg_replace("/&(.)(acute|cedil|circ|ring|tilde|uml|grave);/", "$1", $this -> sString );
$this -> sString = preg_replace("/([^a-z0-9]+)/", "-", html_entity_decode($this -> sString ));
$this -> sString = trim($this -> sString , "-");
}
/**
* private function arrReplace
* replacement method, given an array
* @Param array tab : the replacement array to be used
* @Param bool pref : if false, just replace keys by values; if true, do the same but only with prefix
*/
function arrReplace ($tab, $pref = false) {
$fromRep = array_keys ($tab);
$toRep = array_values ($tab);
if (false === $pref) {
$this -> sString = str_replace ($fromRep, $toRep, $this -> sString);
} else {
foreach ($fromRep as $clef => $val) {
$length = strlen ($val);
if (substr ($this -> sString, 0, $length) === $val) {
$this -> sString = substr_replace ($this -> sString, $toRep[$clef], 0, $length);
}
}
}
}
}
function soundex2($str) {
$soundex2 = new csoundex2();
$soundex2 -> build ($str);
return $soundex2 -> sString;
}
?>

101
framework/fwk.php Normal file
View File

@ -0,0 +1,101 @@
<?
//define('FWK_PATH', 'C:\\wamp\\www\\framework\\');
define('FWK_PATH', realpath(dirname(__FILE__) . '/'));
include_once(realpath(FWK_PATH.'/common/mysql.php'));
include_once(realpath(FWK_PATH.'/common/strings.php') );
define ('REP_TEMP', '/tmp/');
// Environnement : DEV ou PRD
define ('ENV', 'DEV');
define ('EOL', "\n");
/** TimeStamp Unix
** Si $onlyMiliSec=true, retourne juste les milisec du timestamp
**/
function microtime_float($onlyMiliSec=false) {
list($usec, $sec) = explode(' ', microtime());
if (!$onlyMiliSec)
return ((float)$usec + (float)$sec);
else
return $usec;
}
/** Fait une pause aléatoire entre 0 et 15 secondes par défaut
**/
function randsleep($min_sec=0, $max_sec=15) {
sleep(rand($min_sec, $max_sec));
}
/** V�rification que la variable demand� respecte bien les r�gles pass�es en param�tres
* @param mixed Variable � tester
* @param int Longueur minimum en caract�re de la variable
* @param int Longueur mximum
* @param char(1) Type de variable <b>A</b>:Alphanum�rique / <b>N</b>:Num�rique
* @param mixed Message textuel d'erreur � afficher en cas d'erreur ou false
* @return mixed true, false ou Message d'erreur pass� en param�tre
*/
function valideData($variable, $taille_min, $taille_max, $type_variable, $erreur=false){
if ( strlen((string)$variable) < $taille_min )
return $erreur;
if ( strlen((string)$variable) > $taille_max )
return $erreur;
if ( $type_variable == 'A' )
if ( is_string($variable) == true )
return true;
else
return $erreur;
elseif ( $type_variable == 'N')
{
for ($i=0; $i < strlen((string)$variable); $i++)
{
$car = substr((string)$variable,$i,1);
if ($car<'0' || $car>'9')
return $erreur;
}
return true;
}
return $erreur;
}
function adapteOCtets($size) {
$kb = 1024; // Kilobyte
$mb = 1024 * $kb; // Megabyte
$gb = 1024 * $mb; // Gigabyte
$tb = 1024 * $gb; // Terabyte
if($size==0) return '0';
else if($size < $kb) return $size.'o';
else if($size < $mb) return round($size/$kb,2).'ko';
else if($size < $gb) return round($size/$mb,2).'Mo';
else if($size < $tb) return round($size/$gb,2).'Go';
else return round($size/$tb,2).'To';
}
/**
** Enregistrer une information dans la log
**
** @param string $debugLevel E=Error, W=Warning, N=Notice, I=Info, D=Debug
** @param string $message Message d'erreur à inscrire dans la log
** @param integer $line __LINE__
** @param string $file __FILE__
** @param string $function __FUNCTION__
** @param string $class __CLASS___
**/
function debugLog($debugLevel, $message, $line, $file, $function, $class) {
if (!file_exists('/var/www/debug.log')) {
$fp=fopen('/var/www/debug.log', 'a');
fwrite($fp, 'Date/Heure;Niveau;Script;Login;Password;Adresse IP;Action SOAP;Ligne;Fichier;Fonction;Classe;Domaine;POST DATA;Message'.EOL);
} else
$fp=fopen('/var/www/debug.log', 'a');
fwrite($fp, date('Y/m/d-H:i:s') .';'. $debugLevel .';'. $_SERVER['PHP_SELF'] .';'. $_SERVER['PHP_AUTH_USER'] .';'. $_SERVER['PHP_AUTH_PW'] .';'.
$_SERVER['REMOTE_ADDR'] .';'. $_SERVER['HTTP_SOAPACTION'] .';'.$line.';'. $file.';'. $function.';'. $class .';'.
gethostbyaddr($_SERVER['REMOTE_ADDR']) .';'. $HTTP_RAW_POST_DATA .';'. $message . EOL);
fclose($fp);
if ($debugLevel=='E') die($message);
}
?>

View File

@ -0,0 +1,119 @@
THE Q PUBLIC LICENSE version 1.0
Copyright (C) 1999 Trolltech AS, Norway.
Everyone is permitted to copy and
distribute this license document.
The intent of this license is to establish freedom to share and change
the software regulated by this license under the open source model.
This license applies to any software containing a notice placed by the
copyright holder saying that it may be distributed under the terms of
the Q Public License version 1.0. Such software is herein referred to
as the Software. This license covers modification and distribution of
the Software, use of third-party application programs based on the
Software, and development of free software which uses the Software.
Granted Rights
1. You are granted the non-exclusive rights set forth in this license
provided you agree to and comply with any and all conditions in
this license. Whole or partial distribution of the Software, or
software items that link with the Software, in any form signifies
acceptance of this license.
2. You may copy and distribute the Software in unmodified form
provided that the entire package, including - but not restricted to
- copyright, trademark notices and disclaimers, as released by the
initial developer of the Software, is distributed.
3. You may make modifications to the Software and distribute your
modifications, in a form that is separate from the Software, such
as patches. The following restrictions apply to modifications:
a. Modifications must not alter or remove any copyright notices in the
Software.
b. When modifications to the Software are released under this license,
a non-exclusive royalty-free right is granted to the initial developer
of the Software to distribute your modification in future versions of
the Software provided such versions remain available under these terms
in addition to any other license(s) of the initial developer.
4. You may distribute machine-executable forms of the Software or
machine-executable forms of modified versions of the Software,
provided that you meet these restrictions:
a. You must include this license document in the distribution.
b. You must ensure that all recipients of the machine-executable forms
are also able to receive the complete machine-readable source code to
the distributed Software, including all modifications, without any
charge beyond the costs of data transfer, and place prominent notices
in the distribution explaining this.
c. You must ensure that all modifications included in the
machine-executable forms are available under the terms of this
license.
5. You may use the original or modified versions of the Software to
compile, link and run application programs legally developed by you
or by others.
6. You may develop application programs, reusable components and other
software items that link with the original or modified versions of
the Software. These items, when distributed, are subject to the
following requirements:
a. You must ensure that all recipients of machine-executable forms of
these items are also able to receive and use the complete
machine-readable source code to the items without any charge beyond
the costs of data transfer.
b. You must explicitly license all recipients of your items to use and
re-distribute original and modified versions of the items in both
machine-executable and source code forms. The recipients must be able
to do so without any charges whatsoever, and they must be able to
re-distribute to anyone they choose.
c. If the items are not available to the general public, and the
initial developer of the Software requests a copy of the items, then
you must supply one.
Limitations of Liability
In no event shall the initial developers or copyright holders be
liable for any damages whatsoever, including - but not restricted to -
lost revenue or profits or other direct, indirect, special, incidental
or consequential damages, even if they have been advised of the
possibility of such damages, except to the extent invariable law, if
any, provides otherwise.
No Warranty
The Software and this license document are provided AS IS with NO
WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN,
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
Choice of Law
This license is governed by the Laws of Norway. Disputes shall be
settled by Oslo City Court.

View File

@ -0,0 +1,208 @@
README FOR JPGRAPH
==================
This package contains JpGraph, an Object Oriented PHP4 Graph Plotting library.
The library is Copyright (C) 2001-2007 Aditus Consulting and
released under dual license QPL 1.0 for open source and educational
use and JpGraph Professional License for commercial use.
Please see full license details at http://www.aditus.nu/jpgraph/
* --------------------------------------------------------------------
* PHP5 IS NOT SUPPORTED IN THE 1.x SERIES
* Please use the 2.x serie if PHP5 support is required
* --------------------------------------------------------------------
Included files
--------------
README This file
QPL.txt QPL 1.0 Licensee
/src
Changelog Changelog
jpg-config.inc.php Configuration setup for JpGraph
jpgraph.php Base library
jpgraph_errhandler.inc.php Base library. Error handler module.
gd_image.inc.php Base library. GD interface class
jpgraph_ttf.inc.php Base library. TTF font handling
jpgraph_led.php Extension: LED digits module
jpgraph_log.php Extension: logarithmic scales
jpgraph_date.php Extension: date/time scales
jpgraph_line.php Extension: line plots
jpgraph_bar.php Extension: bar plots
jpgraph_error.php Extension: error plots
jpgraph_scatter.php Extension: scatter/impulse plots
jpgraph_radar.php Extension: radar plots
jpgraph_pie.php Extension: pie plots
jpgraph_pie3d.php Extension: 3D pie plots
jpgraph_canvas.php Extension: drawing canvas
jpgraph_canvtools.php Extension: utility classes for working with canvas
jpgraph_gantt.php Extension: Gantt chart
jpgraph_regstat.php Extension: Statistics and cubic splines.
jpgraph_stock.php Extension: Stock and box plots.
jpgraph_gradient.php Extension: Color gradient class
jpgraph_gb2312.php Extension: Chinese GB2312 to Unicode translation
jpgraph_plotmark.php Extension: Handle plotmarks in plots
jpgraph_imgtrans.php Extension: Basic image transformation
jpgraph_flags.php Extension: Country flags
jpgraph_iconplot.php Extension: Use image icons in plots
jpgraph_plotband.php Extension: Plotbands in graphs
jpgraph_plotmark.inc.php Extension: Using plotmarks in graphs
jpgraph_antispam.php Extension: Antispam module
jpgraph_utils.inc.php Extension: Non mandatory Utility classes
jpgraph_mgraph.php Extension: Multi graph
imgdata_*.inc Extension: Encoded images for plot marks
flags*.dat Raw Image data: Pre-compiled data for country flags.
/src/Examples A directory with example sripts.
Run testsuit.php to get a list of all
files and you can easily click on a file to
see the code and the resulting image.
/docs Directory with all documentation
/docs/index.html Documentation portal
Requirements:
-------------
Miminum:
* PHP 4.3.5 or higher
(earlier versions might work but is unsupported)
* GD 1.8.x or GD 2.15 or higher
Recommended:
* PHP 4.4.0
* PHP Builtin GD 2.28 library
Installation
------------
0. Make sure that the PHP version is compatible with the stated requirements
and that the PHP installation has support for the GD library.
Please run phpinfo() to check if GD library
is supported in the installation.
If the GD library doesn't seem to be installed
please consult the PHP manual under section "Image" for
instructions on where to find this library. Please refer to
the manual section "Verifying your PHP installation"
1. Unzip and copy the files to a directory of your choice where Your
httpd sever can access them.
For a global site installation you should copy the files to
somewhere in the PHP search path.
2. Check that the default directory paths in jpg-config.inc
for cache directory and TTF directory suits your installation.
Note1: The default directories are different depending on if
the library is running on Windows or UNIX.
Note2: Apache/PHP must have write permission to your cache
directory if you enable the cache feature. By default the cache
is disabled.
3. Check that all rest of the DEFINE in jpg-config.inc
is setup to your preference. The default should be fine
for most users. (See also Note 3. below)
4. If any problems are encounted please start by reading the FAQ on
http://www.aditus.nu/jpgraph/jpgraphfaq.php.
Documentation
-------------
The installation includes HTML documentation and reference guide for the
library. The portal page for all the documentation is
<YOUR-INSTALLATION-DIRECTORY>/docs/index.html
Troubleshooting
---------------
0. Make sure your PHP installation has the minimum requirements and has
the GD library enabled (most modern installations fulfills the minimmum
requirements). See chapter 3.1 in the manual.
1. If an empty page is returned back when running an example check
the following
i) Increase the maximum memory allowed by PHP (in php.ini) to at least 32MB
ii) Enable all error messages and notices in php.ini (error_reporting = E_ALL)
III) Make sure output buffering is disabled in php.ini (output_buffering = Off)
this will make it possible to see the errors more easily
IV) Disable any PHP accelerometer you may have installed (e.g. Zend Cache)
Then try running the example again. Most likely an error message will
now be shown that will give further information on what is wrong.
For further clarifiction on the casues for the error messages see
the FAQ section on the WEB site.
2. If you are running IIS and Win2k and get the error "Can't find
font' when trying to use TTF fonts then try to change you paths
to UNIX style, i.e. "/usr/local/fonts/ttf/". Remember that the
path is absolute and not relative to the htdocs catalogue. Some
versions of GD for Windows also need you to set the environment
variable GDFONTPATH for GD to find the fonts.
3. If you are using the cache please make sure that you have
set the permissions correctly for the cache directory so that
Apache/PHP can write to that directory.
Bug reports and suggestions
---------------------------
Should be reported in the issue tracker at
http://www.aditus.nu/bugtraq
Change history:
------------------------------------------------------------------------
Date Ver Comment
-----------------------------------------------------------------------
2007-10-19 1.22 Minor Feature release
2007-03-25 1.21 Feature release
2006-09-24 1.20.5 Maintenance release
2006-05-26 1.20.4a Maintenance release
2006-02-18 1.20.3 Minor defect and feature release
2005-12-04 1.20 Major feature enhancements
2005-07-10 1.19 Various minor defects fixed
2005-06-06 1.18 Date scale and guide-lines for Pie
2005-01-16 1.17 Functional enhancement, bug fixes
2004-11-02 1.17-beta2 Functional enhancement, bug fixes
2004-09-12 1.17-beta Port to PHP5 in compatibility mode.
2004-06-20 1.16 Minor defect fixes
2004-05-04 1.15 Final 1.15
2004-04-19 1.15 BETA Defect fixes and code restructuring to make
jpgraph.php smaller.
2003-11-25 1.14 Additional error checking, country flags, icon etc
2003-08-19 1.13 BETA Improved Gantt graphs various other changes and bug fixes
2003-02-02 1.11 Stock charts and some minor oter changes.
2002-12-16 1.10 Alpha blending, cubic splines and field plots
2002-10-30 1.9.1 Fixed two stupid mistakes in 1.9
2002-10-25 1.9 TTF font change. Many small additional improvements
2002-09-17 1.8 Documentation update.
2002-09-09 1.8 BETA Functional improvements.
2002-07-05 1.7 Functional improvements. Rotated bar graphs.
2002-06-17 1.7 BETA Functional improvements.
2002-05-15 1.6.3 Enhancements to Gantt graphs anbd minor bug fixes.
2002-04-19 1.6.2 Addition of image maps for line and scatter plot
2002-04-07 1.6.1 Bug fixes for 3D pies and image maps for pie's
2002-04-01 1.6 Functional improvments
2002-04-01 1.6 BETA Beta candidate for 1.6
2002-03-01 1.5.3 Fix minor release problem in 1.5.2
2002-02-29 1.5.2 Minor bug fixes.
2002-02-11 1.5.1 Minor bug fixes.
2002-01-27 1.5 Functional improvements. Gantt charts.
2002-01-17 1.5-BETA2 Functional improvements, bug fixes
2001-12-16 1.5-BETA Functional improvements, gantt-charts, bug fixes.
2001-11-12 1.4 Functional improvements, bug fixes.
2001-09-23 1.3.1 Minor bug fixes
2001-09-13 1.3 Major functional enhancements and minor bugfixes
2001-04-29 1.2.2 Minor bug fixes. Addded background image support
2001-03-29 1.2.1 Minor bug fixes. Experimental support for 3D pie plots
2001-03-18 1.2 Second release see changes.txt
2001-02-18 1.1 Second release see changes.txt
2001-02-04 1.0 First public release
-------------------------------------------------------------------------
<EOF>

View File

@ -0,0 +1 @@
Revision: r946, Exported: 2007-10-20 10:26

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -0,0 +1,60 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1092Addingprogressindicatorstobars.html">
<LINK REL="Next" HREF="1011Usingmultiplecolumnsastitles.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1092Addingprogressindicatorstobars.html">Previous</A>
<A HREF="1011Usingmultiplecolumnsastitles.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_10">10.10 Grouping activities</A></H2>
<P> It is common to group activities. We have used this feature in the
examples of constrains. There is no special type for activity bars that
are used to illustrate grouping. The common way of illustrating this
(as have been used above) is to add &quot;half&quot; a triangle marker at both
ends of the bar. The special provision that JpGraph does is that if you
add a left or right marker of type MARK_LEFTTRIANGLE or
MARK_RIGHTTRIANGLE those triangles will be drawn under the bars to give
the effect as show in the examples above. In the example above we also
have made the grouping bars have slightly less heigh since the end
triangles will visually &quot;grow&quot; the bar.</P>
<P> So to get the effect we want for a group bar we have to use the two
lines:<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$groupbar</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
leftMark</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetType</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;MARK_LEFTTRIANGLE&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$groupbar</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetType</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;MARK_RIGHTTRIANGLE&quot;</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P></P>
<P> As of the current version There is not yet any formatting support to
accomplish the effect of indentation for the titles so this is
accomplished by using a fixed width font and adding spaces in front of
the title.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1092Addingprogressindicatorstobars.html">Previous</A>
<A HREF="1011Usingmultiplecolumnsastitles.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,70 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1011Usingmultiplecolumnsastitles.html">
<LINK REL="Next" HREF="10112SpecifyingCSIMentriesforcolumntitles.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1011Usingmultiplecolumnsastitles.html">Previous</A>
<A HREF="10112SpecifyingCSIMentriesforcolumntitles.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_11_1">10.11.1 Adding a title for the columns</A></H3>
<P> Precisely as before you can also have a title spanning all the
columns. This title is specified with the property<I> tableTitle</I> of
the scale. Specifying a table title will automatically adjust the
height of the column titles to fit the table title. The small code
snippet below shows how to add a title.<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">tableTitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">'Phase&nbsp;1'</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
tableTitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">12</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetTableTitleBackground</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'darkgreen@0.6'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
tableTitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Show</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">true</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> A full example of this is shown below<DIV class="example">
<BR> <A href="exframes/frame_gantthourminex1.html" target="blank"><IMG border="0"
HEIGHT="215" src="img/gantthourminex1.png" WIDTH="1200"></A>
<BR><B>Figure 161:</B> Adding a column titles stratching all title
columns. <A href="exframes/frame_gantthourminex1.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1011Usingmultiplecolumnsastitles.html">Previous</A>
<A HREF="10112SpecifyingCSIMentriesforcolumntitles.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10111Addingatitleforthecolumns.html">
<LINK REL="Next" HREF="1012MoregeneralGanttformatting.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10111Addingatitleforthecolumns.html">Previous</A>
<A HREF="1012MoregeneralGanttformatting.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_11_2">10.11.2 Specifying CSIM entries for column titles</A>
</H3>
<P> In exactly the same way as for a single title it is possible to
specify individual CSIM targets for each of the title columns. This is
accomplished by specifying an array for both the target and the alt
text instead of a single string as arguments for<I> SetCSIMTarget()</I>
The following code snippet shows how to specify that.<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$bar</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetCSIMTarget</FONT><FONT color="#007700">(array(</FONT><FONT
color="#DD0000">'sometarget1.html'</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">'sometarget1.html'</FONT><FONT color="#007700">),
<BR>array(</FONT><FONT color="#DD0000">'alttext1'</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">'alttext2'</FONT><FONT color="#007700">));</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10111Addingatitleforthecolumns.html">Previous</A>
<A HREF="1012MoregeneralGanttformatting.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,164 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1010Groupingactivities.html">
<LINK REL="Next" HREF="10111Addingatitleforthecolumns.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1010Groupingactivities.html">Previous</A>
<A HREF="10111Addingatitleforthecolumns.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_11">10.11 Using multiple columns as titles</A></H2>
<P> It is often of interest not only to show one title for a gantt bar
but often one wants to show, title, start date, end date, duration or
effort and so on. Up until now we have, to keep things simple only
shown a single title for each activity. We will now show you how you
can specify an arbitrary number of columns as titles for a Gantt chart
as well as adding icons in the graph columns.</P>
<P> First out is an example to help visualize what we will achieve<DIV class="example">
<BR> <A href="exframes/frame_gantticonex1.html" target="blank"><IMG border="0"
HEIGHT="197" src="img/gantticonex1.png" WIDTH="590"></A>
<BR><B>Figure 160:</B> A Gantt chart with multiple columns <A href="exframes/frame_gantticonex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> To use multiple columns there is two steps. First you need to set
the titles (name, color, fonts etc). Thereafter you need to add the
title columns for each individual bar.</P>
<P> To set the columns you will have to work with the<I> Activity
information</I> property of the scale. The following code excerpt show
this<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">actinfo</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetColTitles</FONT><FONT color="#007700">
(
<BR>&nbsp;&nbsp;&nbsp;&nbsp;array(</FONT><FONT color="#DD0000">'Note'</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">'Task'</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">'Duration'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
'Start'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
'Finish'</FONT><FONT color="#007700">),array(</FONT><FONT color="#0000BB">
30</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">100</FONT><FONT
color="#007700">));</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P>You will notice two things. We fist specify the titles using an
array. We have also specified a second array with the numbers 30 and
100. This is an optional array that specifies the minimum width of, in
this case, the first two columns. By default the columns will be wide
enough to hold the widest text string in the column. However for
esthetic reasons you might sometimes want to increase the minium width.
This is what we have done here for the first two columns.</P>
<P> Furthermore you can also adjust the background colors and the style
and colors of the vertical dividing grid lines. In the previous image
we used the lines<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT
color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">actinfo</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetBackgroundColor</FONT><FONT
color="#007700">(</FONT><FONT color="#DD0000">'green:0.5@0.5'</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
actinfo</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
actinfo</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">vgrid</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetStyle</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">'solid'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
actinfo</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">vgrid</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetColor</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">'gray'</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> The style for the grid lines can also be &quot;dashed&quot;, &quot;dotted&quot; or
&quot;longdashed&quot; as in other line formatting contexts within the library.
You can also adjust if you would like the small &quot;3D&quot; effect in the
titles. By default this is enabled. You can easily turn this of with a
call to<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">actinfo</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetStyle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">ACTINFO_2D</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> To adjust the colors of the vertical dividing lines in the title the
method SetColor() is used as in
&quot;$graph-&gt;scale-&gt;actinfo-&gt;SetColor('navy');&quot;.</P>
<P> The second thins is to actually populate the columns. This is done
(of course) as you add the activity bars to the graph. Previous we just
used a string as the title when we wasn't using columns. By simply
replacing this string with an array we specify the content of the
columns.</P>
<P> For example to specify two column titles we just create a
hypothetical Gantt bar as In the full example above we put all this in
arrays to make for better coding practice since we create several bars.</P>
<P> In addition to ordinary text you can also add an image or any of the
predefined icons available. In order to add that in a column you first
create an instance of<I> IconImage()</I> and then specify that instance
instead of the text. So in the previous code snippet if we wanted a
&quot;open folder&quot; image in the first column we would change the lines to<DIV
class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$iconopen&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
IconImage</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
GICON_FOLDEROPEN</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
0.6</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$title2</FONT><FONT color="#007700">=</FONT><FONT
color="#DD0000">&quot;&quot;</FONT><FONT color="#007700">;
<BR></FONT><FONT color="#0000BB">$bar&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttBar</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,array(</FONT><FONT
color="#0000BB">$iconopen</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$title2</FONT><FONT color="#007700">),</FONT><FONT color="#DD0000">
&quot;2003-11-23&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2003-12-05&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> The available builtin icons are</P>
<UL>
<LI>GICON_WARNINGRED</LI>
<LI>GICON_TEXT</LI>
<LI>GICON_ENDCONS</LI>
<LI>GICON_MAIL</LI>
<LI>GICON_STARTCONS</LI>
<LI>GICON_CALC</LI>
<LI>GICON_MAGNIFIER</LI>
<LI>GICON_LOCK</LI>
<LI>GICON_STOP</LI>
<LI>GICON_WARNINGYELLOW</LI>
<LI>GICON_FOLDEROPEN</LI>
<LI>GICON_FOLDER</LI>
<LI>GICON_TEXTIMPORTANT</LI>
</UL>
<P> In addition you can also use any of you own images if you specify
the argument as a string, for example<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$myicon&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">IconImage</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'myicon.png'</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> If you wonder, the second argument in the<I> IconImage()</I> call is
an optional scaling factor which you can use to adjust the size of the
image.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1010Groupingactivities.html">Previous</A>
<A HREF="10111Addingatitleforthecolumns.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,69 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1012MoregeneralGanttformatting.html">
<LINK REL="Next" HREF="10122Modifyingthedividerlines.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1012MoregeneralGanttformatting.html">Previous</A>
<A HREF="10122Modifyingthedividerlines.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_12_1">10.12.1 Adding a table title</A></H3>
<P> The (default) white area in the top left of the gantt table may have
a title. This is accessed by the 'tableTitle' property of the gantt
scale. Using this is straightforward as the following lines show.<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">tableTitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;(Rev:&nbsp;1.22)&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
tableTitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_FONT1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetTableTitleBackground</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;silver&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
tableTitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Show</FONT><FONT color="#007700">();</FONT><FONT color="#0000BB"></FONT></FONT>
</CODE></DIV></P>
<P> The example lines above also changes the default white background to
silver. Adding these lines to the previous example gives the following
result:<DIV class="example">
<BR> <A href="exframes/frame_ganttex16.html" target="blank"><IMG border="0"
HEIGHT="191" src="img/ganttex16.png" WIDTH="439"></A>
<BR><B>Figure 162:</B> Adding a table title. <A href="exframes/frame_ganttex16.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> From the above example you might notice that the width of the left
column (which holds all the titles) have automatically adjusted itself
to make the table title fit.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1012MoregeneralGanttformatting.html">Previous</A>
<A HREF="10122Modifyingthedividerlines.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,66 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10121Addingatabletitle.html">
<LINK REL="Next" HREF="10123Modifyingtheboxaroundtheplot.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10121Addingatabletitle.html">Previous</A>
<A HREF="10123Modifyingtheboxaroundtheplot.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_12_2">10.12.2 Modifying the divider lines</A></H3>
<P> The vertical and horizontal lines between the titles and the bars
can be modified by accessing the 'divider' and 'dividerh' properties of
the scale. Again, this is straightforward as the following example
shows:<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">divider</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetWeight</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">3</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
divider</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;navy&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
dividerh</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetWeight</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
dividerh</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;navy&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> The effect of this is shown in Figure 163 below<DIV class="example">
<BR> <A href="exframes/frame_ganttex17.html" target="blank"><IMG border="0"
HEIGHT="191" src="img/ganttex17.png" WIDTH="433"></A>
<BR><B>Figure 163:</B> Modifying the dividing line <A href="exframes/frame_ganttex17.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10121Addingatabletitle.html">Previous</A>
<A HREF="10123Modifyingtheboxaroundtheplot.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,55 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10122Modifyingthedividerlines.html">
<LINK REL="Next" HREF="10124Horizontalgridsandalternatinglinecolors.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10122Modifyingthedividerlines.html">Previous</A>
<A HREF="10124Horizontalgridsandalternatinglinecolors.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_12_3">10.12.3 Modifying the box around the plot</A></H3>
<P> In a similar manner to the other plots in JpGraph you modify the Box
round the plot with the standard graph method 'SetBox()' as in<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetBox</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">true</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;navy&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">)</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> which will result in a thicker plot box around the area as shown
below<DIV class="example">
<BR> <A href="exframes/frame_ganttex18.html" target="blank"><IMG border="0"
HEIGHT="191" src="img/ganttex18.png" WIDTH="433"></A>
<BR><B>Figure 164:</B> Modifying the box around the plotarea <A href="exframes/frame_ganttex18.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="note"><B>Note:</B> You might notice the slight
discrepancy in design that here you use a method and in the previous
cases accessed a property which you modified. This is the unfortunate
affect of the evolving design and development of this library once it
was realised that the original design could be improved upon.</DIV></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10122Modifyingthedividerlines.html">Previous</A>
<A HREF="10124Horizontalgridsandalternatinglinecolors.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,68 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10123Modifyingtheboxaroundtheplot.html">
<LINK REL="Next" HREF="10125AddingiconstoGanttgraphs.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10123Modifyingtheboxaroundtheplot.html">Previous</A>
<A HREF="10125AddingiconstoGanttgraphs.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_12_4">10.12.4 Horizontal grids and alternating line
colors</A></H3>
<P> In order to make large charts easier to read it is possible to
specify alternating an horizontal grid and optional alternating line
colors in the background for Gantt charts. The horizontal grid is
accessed through the<I> Graph::hgrid</I> property and the line (used in
the grid) is accessed through the<I> Graph::hgrid::line</I>
sub-property</P>
<P> In order to specify the alternating line colors the<I>
SetRowFillColor()</I> method is used. For example, to use alternating
blue background with blue grid line the following lines would have to
be added to the graph script<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Setup&nbsp;a&nbsp;horizontal&nbsp;grid
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">hgrid</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Show</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">hgrid</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
line</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetColor</FONT><FONT
color="#007700">(</FONT><FONT color="#DD0000">'lightblue'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">hgrid</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetRowFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'darkblue@0.9'</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> Below is an example of a Gantt graph using this formatting<DIV class="example">
<BR> <A href="exframes/frame_gantthgridex1.html" target="blank"><IMG border="0"
HEIGHT="253" src="img/gantthgridex1.png" WIDTH="500"></A>
<BR><B>Figure 165:</B> Adding a horizontal grid to the graph <A href="exframes/frame_gantthgridex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10123Modifyingtheboxaroundtheplot.html">Previous</A>
<A HREF="10125AddingiconstoGanttgraphs.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10124Horizontalgridsandalternatinglinecolors.html">
<LINK REL="Next" HREF="10126Adjustingthemarginswithautosizing.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10124Horizontalgridsandalternatinglinecolors.html">Previous</A>
<A HREF="10126Adjustingthemarginswithautosizing.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_12_5">10.12.5 Adding icons to Gantt graphs</A></H3>
As is illustrated in the image above it is also possible (just like for
normal Graph) to add small images (or icons) to a Gantt graph by
creating an IconPlot() instance and then adding it to the graph. In the
image above the following lines were used to add the small image of
&quot;tux&quot; in the left lower corner<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$icon&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">IconPlot</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'penguin.png'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
0.01</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0.95</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$icon</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetAnchor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'left'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
'bottom'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$icon</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT>
</CODE></DIV>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10124Horizontalgridsandalternatinglinecolors.html">Previous</A>
<A HREF="10126Adjustingthemarginswithautosizing.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,48 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10125AddingiconstoGanttgraphs.html">
<LINK REL="Next" HREF="1013SimplifyingthedrawingofGanttgraphs.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10125AddingiconstoGanttgraphs.html">Previous</A>
<A HREF="1013SimplifyingthedrawingofGanttgraphs.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_12_6">10.12.6 Adjusting the margins with auto-sizing</A></H3>
As of version 1.17 it is possible to use Graph::SetMargin() to specify
the margin for a Gantt graph even when the vertical height is
determined automatically. For example to generate a graph with no left,
right or bottom margin the following lines would be needed<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttGraph</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">500</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10125AddingiconstoGanttgraphs.html">Previous</A>
<A HREF="1013SimplifyingthedrawingofGanttgraphs.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10112SpecifyingCSIMentriesforcolumntitles.html">
<LINK REL="Next" HREF="10121Addingatabletitle.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10112SpecifyingCSIMentriesforcolumntitles.html">Previous</A>
<A HREF="10121Addingatabletitle.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_12">10.12 More general Gantt formatting</A></H2>
<P> In this section we will show a few more way by which you may
customize the gantt chart itself. This includes</P>
<UL>
<LI> Adding a table title (not to be confused with the graph title)</LI>
<LI> Adjusting appearance of the various lines in the bar chart</LI>
</UL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10112SpecifyingCSIMentriesforcolumntitles.html">Previous</A>
<A HREF="10121Addingatabletitle.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,140 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10126Adjustingthemarginswithautosizing.html">
<LINK REL="Next" HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10126Adjustingthemarginswithautosizing.html">Previous</A>
<A HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_13">10.13 Simplifying the drawing of Gantt graphs</A></H2>
<P> As we have shown in the previous examples constructing a Gantt chart
consists of a number of repetitive tasks; Create the individual
activity bars and add them to the graph.</P>
<P> Now when you have a basic understanding of how this works you are
ready to appreciate a small helper method. <A href="">
GanttGraph::CreateSimple()</A>. This method takes a few arrays of data
which specifies you Gantt chart and then constructs this chart. By
using this method you sacrifices a few adjustment possibilities for
simplicity. This method is nothing magical it just takes the data for
the activities,(start and end date, titles, progress, any constrains
and so on) and constructs the activities and adds them to the graph.</P>
<P> The activities are specified in data array which for each activity
have the following fields</P>
<UL>
<LI> What row the activity should be on</LI>
<LI> Activity type, controls the appearance. Can be one of
<OL>
<LI> ACTYPE_NORMAL, A standard activty bar</LI>
<LI> ACTYPE_GROUP, A Grouping bar</LI>
<LI> ACTYPE_MILESTONE, A milestone</LI>
<LI></LI>
</OL>
<P></P>
</LI>
<LI> Title text</LI>
<LI> Start date</LI>
<LI> End date (NOT FOR Milestones!)</LI>
<LI> Caption</LI>
</UL>
<P></P>
<P> So for example to create a Gantt chart consisting of two activities
which are grouped and a milestone one would have to use something
similar to the following code</P>
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$data&nbsp;</FONT><FONT color="#007700">=&nbsp;array(
<BR>&nbsp;&nbsp;array(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">ACTYPE_GROUP</FONT><FONT color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#DD0000">&quot;Phase&nbsp;1&quot;</FONT><FONT color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#DD0000">&quot;2001-10-26&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-11-23&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;&quot;</FONT><FONT color="#007700">),
<BR>&nbsp;&nbsp;array(</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">ACTYPE_NORMAL</FONT><FONT color="#007700">,&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#DD0000">&quot;&nbsp;&nbsp;Label&nbsp;2&quot;</FONT><FONT color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#DD0000">&quot;2001-10-26&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-11-13&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;[KJ]&quot;</FONT><FONT color="#007700">),
<BR>&nbsp;&nbsp;array(</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">ACTYPE_NORMAL</FONT><FONT color="#007700">,&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#DD0000">&quot;&nbsp;&nbsp;Label&nbsp;3&quot;</FONT><FONT color="#007700">,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#DD0000">&quot;2001-11-20&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-11-22&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;[EP]&quot;</FONT><FONT color="#007700">),
<BR>&nbsp;&nbsp;array(</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">ACTYPE_MILESTONE</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">&quot;&nbsp;&nbsp;Phase&nbsp;1&nbsp;Done&quot;</FONT><FONT color="#007700">,&nbsp;</FONT><FONT
color="#DD0000">&quot;2001-11-23&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;M2&quot;</FONT><FONT color="#007700">)&nbsp;);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Create&nbsp;the&nbsp;basic&nbsp;graph
<BR></FONT><FONT color="#0000BB">$graph&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttGraph</FONT><FONT color="#007700">
();
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;Gantt&nbsp;Graph&nbsp;using&nbsp;CreateSimple()&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;scale
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ShowHeaders</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
GANTT_HYEAR&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HMONTH&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HDAY&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HWEEK</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
week</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetStyle</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">WEEKSTYLE_FIRSTDAY</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;the&nbsp;specified&nbsp;activities
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">CreateSimple</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$data</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;and&nbsp;stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> This will then show up as<DIV class="example">
<BR> <A href="exframes/frame_ganttsimpleex1.html" target="blank"><IMG border="0"
HEIGHT="231" src="img/ganttsimpleex1.png" WIDTH="523"></A>
<BR><B>Figure 166:</B> Using the simplified way via CreateSimple()
method <A href="exframes/frame_ganttsimpleex1.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> You may (slightly) modify the appearance of the simple Gantt charts
by means of the methods <A href="">GanttGraph::SetSimpleFont()</A> and <A
href="">GanttGraph::SetSimpleStyle()</A> But not anything else, remember
that the purpose with this way of constructing graphs is to be simple.
If you need full advanced control you have to construct all the
activities in the &quot;normal&quot; way.</P>
<P> You can also specify constrains and progress for each bar by
supplying additional data arrays to GanttGraph::CreateSimple().</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10126Adjustingthemarginswithautosizing.html">Previous</A>
<A HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,64 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1013SimplifyingthedrawingofGanttgraphs.html">
<LINK REL="Next" HREF="1015Addingconstrainsbetweenyouractivities.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1013SimplifyingthedrawingofGanttgraphs.html">Previous</A>
<A HREF="1015Addingconstrainsbetweenyouractivities.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_14">10.14 Adding CSIM (Client side Image Maps) to Gantt
charts</A></H2>
<P> Gantt charts can have independent (different targets) hot spots in
both the activities and in the associated labels for each activity.</P>
<P> You specify the target and the associated &quot;Alt&quot; text for an activity
bar by calling the <A href="../ref/GanttPlotObject.html#_GANTTPLOTOBJECT_SETCSIMTARGET">
GanttBar::SetCSIMTarget()</A> and <A href="../ref/GanttPlotObject.html#_GANTTPLOTOBJECT_SETCSIMALT">
GanttBar::SetCSIMAlt()</A></P>
<P> In a similar way you set the target and Alt texts for the activity
title as the following code extract shows.<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;$bar</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetCSIMTarget</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">&quot;http://localhost/abc/&quot;</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$bar</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetCSIMAlt</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;Alt&nbsp;Text&nbsp;for&nbsp;the&nbsp;bar&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$bar</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetCSIMTarget</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;http://localhost/abc&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$bar</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetCSIMAlt</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;Alt&nbsp;Text&nbsp;for&nbsp;the&nbsp;title&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> The above code assumes that your activity is available in the
variable 'bar'. In the example directory there is a complete example of
how to use CSIM together with Gantt charts in the &quot;ganttcsimex1.php&quot;
file. (Please note that this example makes use of the simplified Gantt
chart specification using the CreateSimple() method.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1013SimplifyingthedrawingofGanttgraphs.html">Previous</A>
<A HREF="1015Addingconstrainsbetweenyouractivities.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,92 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">
<LINK REL="Next" HREF="1016Advancedformatting.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">Previous</A>
<A HREF="1016Advancedformatting.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_15">10.15 Adding constrains between your activities</A></H2>
<P> With Gantt charts there is often the need to illustrate constrains
between one or several activities. One of the most common constrain is
that on activity can't start before an other activity finish.</P>
<P> JpGraph support visualizing the following types of constrains</P>
<UL>
<LI> Start to End</LI>
<LI> Start to Start</LI>
<LI> End to Start</LI>
<LI> End to End</LI>
</UL>
<P> An example will clarify how to specify a constrain between two
activities.</P>
<P> Assume that we start with the Gantt schema as illustrated below<DIV class="example">
<BR> <A href="exframes/frame_ganttconstrainex0.html" target="blank"><IMG border="0"
HEIGHT="231" src="img/ganttconstrainex0.png" WIDTH="523"></A>
<BR><B>Figure 167:</B> The original Gantt schema we wich to add
constrains to <A href="exframes/frame_ganttconstrainex0.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> We would now like to add the constrains that the activity &quot;Label 3&quot;
cant start before activity &quot;Label 2&quot; has finished and that the
milestone &quot;Phase 1 done&quot; is depending on when activity &quot;Label 3&quot; is
done.</P>
<P> The principle of adding constrains is that you for each activity you
want to have a constrain you have to tell to what other activity this
constrain should be to. That other activity is specified by telling on
what row that activity lies. Depending on what type of constrain, e.g.
Start-to-End, an arrow will now connect the two activities in correct
way.</P>
<P> The way to do this is to call the <A href="../ref/GanttPlotObject.html#_GANTTPLOTOBJECT_SETCONSTRAIN">
SetConstrain()</A> method on the activity. In this method you specify
the type of constrain as well as to what other activity this constrain
should be to. If you read the class reference you can also see that you
can specify the type and size of arrow used. For now we will just use
the default sizes and type.</P>
<P> So for example to add an End-To-Start constrain between &quot;Label 2&quot;
and &quot;Label 3&quot; you could write<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$bar2</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetConstrain</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">2</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">CONSTRAIN_ENDSTART</FONT><FONT
color="#007700">)</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> The first parameter in the call above &quot;2&quot; is the row of the target
activity (i.e. the row where &quot;Label 3&quot;) activity is. In the example
below we have added the constrains we wanted.<DIV class="example">
<BR> <A href="exframes/frame_ganttconstrainex1.html" target="blank"><IMG border="0"
HEIGHT="253" src="img/ganttconstrainex1.png" WIDTH="523"></A>
<BR><B>Figure 168:</B> Adding constrains to a gantt chart <A href="exframes/frame_ganttconstrainex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> A note: The actual path followed by the arrow is controlled by some
heuristics to make it clear what the constrain is. It has been a design
decision that in order to keep the API simple the user has no further
detailed controlled on the actual path followed. However, in future
version the heuristics may be extended and provide some
user-controllable parameters.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1014AddingCSIMClientsideImageMapstoGanttcharts.html">Previous</A>
<A HREF="1016Advancedformatting.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1016Advancedformatting.html">
<LINK REL="Next" HREF="10162Specifyingstartdayofweek.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1016Advancedformatting.html">Previous</A>
<A HREF="10162Specifyingstartdayofweek.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_16_1">10.16.1 Showing only part of the graph</A></H3>
<P> You can choose to only display a vertical slice of the overall Gantt
chart by explicitly specifying a date range with the method
GanttGraph::SetDateRange(). This will cap any bars to only be displayed
in between the start and end date given as parameters. For example
specifying<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetDateRange</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;2001-12-20&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2002-01-20&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> will show the part of the Gantt chart between the 20 Dec 2001 and 20
of January 2002. Please note that the format depends on the locale
setting.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1016Advancedformatting.html">Previous</A>
<A HREF="10162Specifyingstartdayofweek.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,38 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10161Showingonlypartofthegraph.html">
<LINK REL="Next" HREF="1017Localizing.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10161Showingonlypartofthegraph.html">Previous</A>
<A HREF="1017Localizing.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_16_2">10.16.2 Specifying start day of week</A></H3>
<P> You can set the week start day with a call to
GanttScale::SetWeekStart(). This method takes an integer [0,6] as input
which represents the start day of the week, 0 means Sunday, 1 Monday, 2
Tuesday and so on. The default is to start the week on Monday.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10161Showingonlypartofthegraph.html">Previous</A>
<A HREF="1017Localizing.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1015Addingconstrainsbetweenyouractivities.html">
<LINK REL="Next" HREF="10161Showingonlypartofthegraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1015Addingconstrainsbetweenyouractivities.html">Previous</A>
<A HREF="10161Showingonlypartofthegraph.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_16">10.16 Advanced formatting</A></H2>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1015Addingconstrainsbetweenyouractivities.html">Previous</A>
<A HREF="10161Showingonlypartofthegraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10162Specifyingstartdayofweek.html">
<LINK REL="Next" HREF="1018AntialiasinginJpGraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10162Specifyingstartdayofweek.html">Previous</A>
<A HREF="1018AntialiasinginJpGraph.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_17">10.17 Localizing</A></H2>
<P> Depending on your installation of PHP you might have support for
several locales. By default the locale is set up to use the default
locale on the server.</P>
<P> To specifically set a locale you specify the wanted locale with a
locale string (ala standard PHP), for example American English is
specified with the string 'EN_US', British English with 'EN_UK' 'nl_NL'
for Dutch and so on. If your current installation does not support the
specified locale an error message will be given.<DIV class="phpscript"><CODE>
<FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetDateLocale</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;se_SE&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> The result is displayed below.<DIV class="example">
<BR> <A href="exframes/frame_ganttex19.html" target="blank"><IMG border="0"
HEIGHT="191" src="img/ganttex19.png" WIDTH="431"></A>
<BR><B>Figure 169:</B> Using swedish locale. (Can you spot the
difference from English?) <A href="exframes/frame_ganttex19.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10162Specifyingstartdayofweek.html">Previous</A>
<A HREF="1018AntialiasinginJpGraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1018AntialiasinginJpGraph.html">
<LINK REL="Next" HREF="1019Rotatingthegraphs.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1018AntialiasinginJpGraph.html">Previous</A>
<A HREF="1019Rotatingthegraphs.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_18_1">10.18.1 Enabling anti-aliased lines</A></H3>
<P> Anti-aliased lines are enabled by calling the method <A href="../ref/Image.html#_IMAGE_SETANTIALIASING">
SetAntiAliasing()</A> in the <A href="../ref/Image.html#_C_IMAGE">
Image class</A> in the script where you want to use anti-aliasing.</P>
<P> The anti-aliasing for lines works by &quot;smoothing&quot; out the edges on
the line by using a progressive scale of colors interpolated between
the background color and the line color.</P>
<P><DIV class="note"><B>Note:</B> The algorithm used for anti-aliasing
of lines is quite simple. It would be possible to achieve even better
result by doing some real 2D signal processing. However, doing real
time 2D signal processing on a HTTP server would be foolish so the
design is deliberately kept simple. To achieve best visual result
always use a dark line color on a light background.</DIV></P>
<P> An example will show that this, quite simple algorithm, gives a
reasonable good result. The figures below shows a radar plot with and
without anti-aliasing.</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_radarex8.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/radarex8.png" WIDTH="300"></A>
<BR><B>Figure 170:</B> Spiderplot without anti-aliasing <A href="exframes/frame_radarex8.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P><DIV class="example">
<BR> <A href="exframes/frame_radarex8.1.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/radarex8.1.png" WIDTH="300"></A>
<BR><B>Figure 171:</B> Spiderplot with anti-aliasing <A href="exframes/frame_radarex8.1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> One thing you need to keep in mind when deciding to use
anti-aliasing is that it could have potentially a dramatic effect on
the time it takes to generate the image. Line drawing with
anti-aliasing turned on is roughly 8 times slower than the normal line
drawing so treat this feature wisely.</P>
<P> Furthermore there are a couple of &quot;gotchas&quot; you should be aware of
when using anti-aliasing.</P>
<OL>
<LI> Anti-aliased lines uses up more of the available color-palette. The
exact number of colors used is dependent on the line-angle, a near
horizontal or near vertical line uses more colors (number of lines with
different angles uses more colors). Hence it might not be possible to
use anti-aliasing with color-gradient fill since the number of
available colors in the palette might not be enough. A normal palette
can keep around 256 colors. This means that you are advised to use a
true-color image when using anti-aliasing.</LI>
<LI> Anti-aliasing does not work very well together with background
images since it assumes a the same solid color on each side of the
line. Doing a more advanced anti-aliasing algorithm would simple take
to much processing power.</LI>
<LI>Anti-aliased lines will ignore the line width specified. They will
always have a width of roughly 1.</LI>
</OL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1018AntialiasinginJpGraph.html">Previous</A>
<A HREF="1019Rotatingthegraphs.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,40 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1017Localizing.html">
<LINK REL="Next" HREF="10181Enablingantialiasedlines.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1017Localizing.html">Previous</A>
<A HREF="10181Enablingantialiasedlines.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_18">10.18 Anti-aliasing in JpGraph</A></H2>
<P> From version 1.2 JpGraph supports drawing of anti-aliased lines.
There are a few caveats in order to use this which is discussed in this
section.</P>
<P><DIV class="note"><B>Note:</B> Note that anti-aliasing will not be
used for either horizontal, vertical or 45 degree lines since they are
by their nature are sampled at adequate rate.</DIV></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1017Localizing.html">Previous</A>
<A HREF="10181Enablingantialiasedlines.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,140 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10181Enablingantialiasedlines.html">
<LINK REL="Next" HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10181Enablingantialiasedlines.html">Previous</A>
<A HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_19">10.19 Rotating the graphs</A></H2>
<P> JpGraph provide the possibility for you to rotate the generated
graph an arbitrary angle. This will only affect the actual graph (axis,
axis titles, labels and so on) and not fixed elements on the graph like
title or footer.</P>
<P> Rotation is probably most used to rotate a graph 90 degrees, for
example a bar graph to get the effect of horizontal bars.</P>
<P></P>
<HR> <SMALL>
<P><STRONG> Performance note:</STRONG> Adding a rotation transformation
will make the graph generation slightly slower since each point of the
graph as to go through a transformation step before being stroked on to
the image. JpGraph optimizes this by using a pre-calculated
transformation matric and also optimizes the special case 90 degrees.</P>
</SMALL>
<HR>
<P> By default the center of the rotation will be the center of the plot
area, which may or may not coincide with the center of the entire
image.</P>
<P> To control the rotation you use the two methods</P>
<UL>
<LI> <A href="../ref/RotImage.html#_ROTIMAGE_SETANGLE">
Graph::image::SetAngle()</A>, Specify rotation angle in degrees.</LI>
<LI> <A href="../ref/RotImage.html#_ROTIMAGE_SETCENTER">
Graph::image::SetCenter()</A>, Specify center of rotation in absolute
image pixels</LI>
</UL>
<P> For example<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">image</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetAngle</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">45</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> There is actually a third method that you could use, adding a
translation to the graph<STRONG> after</STRONG> the rotation. Since
this probably a very little used method we don't discuss it further but
refer the reader to the class reference instead <A href="../ref/RotImage.html#_ROTIMAGE_SETTRANSLATION">
Graph:image::SetTranslation()</A></P>
<P> When you rotate an image you should be aware of that the individual
labels on the axis are not rotated. The design decision behind this is
<BR><STRONG> a)</STRONG> Bit mapped font can't be rotated
<BR><STRONG> b)</STRONG> Maintain readability</P>
<P> Please remember that you may still rotate the labels by calling the <A
href="../ref/Axis.html#_AXIS_SETLABELANGLE"> Axis::SetLabelAngle()</A>
method.</P>
<P> Since the anchor point for labels is by default the optimum for
graph at 0 degree you might want to adjust the anchor point and
alignment for the labels on the axis to get a better visual appearance
on you rotated graph. This is accomplished by the method <A href="../ref/Axis.html#_AXIS_SETLABELALIGN">
Axis::SetLabelAlign()</A> For a detailed discussion on how to do this
please see the section on horizontal bar graphs, ( <A href="3030barplot.html">
Working with bar plots</A> )</P>
<P> The table below shows some examples on different kinds of rotation
to give you an idea of how changing the angle and rotation center may
be used to generate different effects. The top left graph is the
original image. The point of rotation has been marked with a red-cross
in each of the images.</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_rotex0.html" target="blank"><IMG border="0" HEIGHT="170"
src="img/rotex0.png" WIDTH="270"></A>
<BR><B>Figure 172:</B> Original image <A href="exframes/frame_rotex0.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="example">
<BR> <A href="exframes/frame_rotex1.html" target="blank"><IMG border="0" HEIGHT="170"
src="img/rotex1.png" WIDTH="270"></A>
<BR><B>Figure 173:</B> Rotated 45 degrees around center of plot area <A href="exframes/frame_rotex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="example">
<BR> <A href="exframes/frame_rotex2.html" target="blank"><IMG border="0" HEIGHT="170"
src="img/rotex2.png" WIDTH="270"></A>
<BR><B>Figure 174:</B> Rotated 90 degrees around center of plot area <A href="exframes/frame_rotex2.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="example">
<BR> <A href="exframes/frame_rotex3.html" target="blank"><IMG border="0" HEIGHT="170"
src="img/rotex3.png" WIDTH="270"></A>
<BR><B>Figure 175:</B> Rotated 45 degrees around center of the image <A href="exframes/frame_rotex3.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="example">
<BR> <A href="exframes/frame_rotex4.html" target="blank"><IMG border="0" HEIGHT="170"
src="img/rotex4.png" WIDTH="270"></A>
<BR><B>Figure 176:</B> Rotated 90 degrees around center of the image <A href="exframes/frame_rotex4.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="example">
<BR> <A href="exframes/frame_rotex5.html" target="blank"><IMG border="0" HEIGHT="170"
src="img/rotex5.png" WIDTH="270"></A>
<BR><B>Figure 177:</B> Rotated -30 degrees around the lower left point
of the plot area <A href="exframes/frame_rotex5.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> As you can see from the images above if you rotate about any other
point than the center of the plot area the plot can be placed outside
the image after rotation.</P>
<P> Since the rotation, by design, only affects the plot area it is
often most effective to use when the color of the margin is the same as
the background color.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10181Enablingantialiasedlines.html">Previous</A>
<A HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,61 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10Workingwithcanvasgraphs.html">
<LINK REL="Next" HREF="102Creatingasimplecanvas.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10Workingwithcanvasgraphs.html">Previous</A>
<A HREF="102Creatingasimplecanvas.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_1">10.1 Introduction</A></H2>
<P> Canvas graph is really not a graph. It a blank sheet of paper which
you can use to draw arbitrary shapes and still have access to some of
the convenient features of JpGraph.</P>
<P> You can work with a canvas in different levels of complexity. You
can for example work directly with the Image class which provides a
large number of primitives for drawing but requires that you use
absolute pixel coordinates.</P>
<P> You can also make life a little bit easier by using a canvas scale.
This lets you define your own scale on the canvas which often makes it
easier by letting you work on a grid you have specified yourself. It
also makes it very easy to re-scale you image automatically by just
changing your scale. For example to half the size of you drawing you
just make the scale twice as large.</P>
<P> To give you some help in working with different canvas you should
include the &quot;jpgraph_canvtools.php&quot; file when working on canvases. This
is not strictly necessary but it will give you some nice abstraction to
help you create your masterpieces.</P>
<P> As another (concrete) example on the use of a canvas the figure
below is a listing of font styles available with JpGraph.<DIV class="example">
<BR> <A href="exframes/frame_listfontsex1.html" target="blank"><IMG border="0"
HEIGHT="450" src="img/img/img/img/img/img/listfontsex1.png" WIDTH="550"></A>
<BR><B>Figure 187:</B> Another example of using a canvas to draw a
number of text boxes <A href="exframes/frame_listfontsex1.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10Workingwithcanvasgraphs.html">Previous</A>
<A HREF="102Creatingasimplecanvas.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="10Ganttcharts.html">
<LINK REL="Next" HREF="102CapabilitiesinJpGraphGanttmodule.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="10Ganttcharts.html">Previous</A>
<A HREF="102CapabilitiesinJpGraphGanttmodule.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_1">10.1 Why use Gantt charts?</A></H2>
<P> The cynical view: To explain why your project is over-due and
over-budget.</P>
<P> The pragmatic view: To keep management of our back and know what we
have forgotten</P>
<P> The common view: As a tool to help identify project issues and
highlight problem areas.</P>
<P> Basically, Gantt charts are used to show the state of a number of
activities (possible grouped) against time.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="10Ganttcharts.html">Previous</A>
<A HREF="102CapabilitiesinJpGraphGanttmodule.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,67 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1019Rotatingthegraphs.html">
<LINK REL="Next" HREF="1021Timingthegenerationofgraphs.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1019Rotatingthegraphs.html">Previous</A>
<A HREF="1021Timingthegenerationofgraphs.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_20">10.20 Adjusting brightness and contrast for images
and backgrounds</A></H2>
<P><STRONG> The following section only applies to palette images. This
means it wont work on true-color images.</STRONG></P>
<P> It is often desirable to have a background image look a little bit
&quot;washed&quot; out so it doesn't take the concentration away from the actual
graph. There are basically two ways of accomplish this</P>
<OL>
<LI> Prepare the image with an external images editor to adjust the
level of brightness and contrasty to a desirable level</LI>
<LI> Use JpGraph:s built in adjustment for contrast, brightness and
color saturation.</LI>
</OL>
<P> To adjust the background image call The levels for both brightness
and contrast are real numbers in the range [-1, 1] You can choose to
adjust for example just the background image or you might also choose
to adjust the whole image. To change the background image just use the
method <A href="../ref/Graph.html#_GRAPH_ADJBACKGROUNDIMAGE">
Graph::AdjBackgroundImage()</A> to specify a suitable value. Let's show
some example on what we can do with this. The following example have
been generated by using the small utility &quot;adjimg.php&quot; which you can
find in the &quot;utils/&quot; directory.</P>
<P> <IMG alt="" border="0" HEIGHT="244" src="img/imgadj_orig.jpg" WIDTH="246">
<BR> Brightness=0, contrast=0, saturation = -1 (Original image)</P>
<P> <IMG alt="" border="0" HEIGHT="244" src="img/imgadj_b00c00sat-1.jpg" WIDTH="246">
<BR> Brightness=0, contrast=0, saturation = -1 (Black &amp; White image)</P>
<P> <IMG alt="" border="0" HEIGHT="244" src="img/imgadj_b03c-03sat0.jpg" WIDTH="246">
<BR> Brightness=0.3, contrast=-0.3, saturation=0</P>
<P> <IMG alt="" border="0" HEIGHT="244" src="img/imgadj_b04c-07sat0.jpg" WIDTH="246">
<BR> Brightness=0.4, contrast=-0.7, saturation=0</P>
<P> <IMG alt="" border="0" HEIGHT="244" src="img/imgadj_b04c-07sat-1.jpg" WIDTH="246">
<BR> Brightness=0.4, contrast=-0.7, saturation=-1</P>
<P> <IMG alt="" border="0" HEIGHT="244" src="img/imgadj_b0c0sat1.jpg" WIDTH="246">
<BR> Brightness=0, contrast=0, saturation=1</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1019Rotatingthegraphs.html">Previous</A>
<A HREF="1021Timingthegenerationofgraphs.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,65 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">
<LINK REL="Next" HREF="1022Usingcountryflagsinvariouscontext.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Previous</A>
<A HREF="1022Usingcountryflagsinvariouscontext.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_21">10.21 Timing the generation of graphs</A></H2>
<P> During development and optimization it can be very handy to have the
actual time it took to generate the image as a footnote. The following
example shows the usage of this feature<DIV class="example">
<BR> <A href="exframes/frame_example11.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/example11.png" WIDTH="300"></A>
<BR><B>Figure 178:</B> Timing of a graph <A href="exframes/frame_example11.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> To enable this feature you can proceed in two ways.</P>
<OL>
<LI> You can either set the global define BRAND_TIMING (in jpgraph.php)
to true. This will add the timing string to all graphs generated.</LI>
<LI> .. or you can enable it for a specific graph by setting the global
variable $gJpgBrandTiming as in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$gJpgBrandTiming</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">true</FONT><FONT color="#007700">;</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>in the beginning of the script.</P>
</LI>
</OL>
<P> If you like you might also change the way the timing is formatted by
setting the string defined by BRAND_TIMING_FORMAT (in jpgraph.php).
This string represents a standard printf() format string.<DIV class="note">
<B>Note:</B> JpGraph contains a utility class called JpgTimer which you
can use yourself should you need ms timing of part of your own code.
The API is really simple. The class supports multiple running timers
and you start a timer simply by calling the Push() method. This will
start a new timer and put it on the top of the timer stack. To stop the
timer, pop it from the stack and return the timing value simply call
Pop().</DIV></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1020Adjustingbrightnessandcontrastforimagesandbackgrounds.html">Previous</A>
<A HREF="1022Usingcountryflagsinvariouscontext.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,75 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1021Timingthegenerationofgraphs.html">
<LINK REL="Next" HREF="1023Addingiconsontothegraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1021Timingthegenerationofgraphs.html">Previous</A>
<A HREF="1023Addingiconsontothegraph.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_22">10.22 Using country flags in various context</A></H2>
<P> JpGraph has built-in support for over 200 country flags, i.e. they
are available to be used in graphs without any external image
definitions.</P>
<P> Country flags can be used in primarily two settings</P>
<OL>
<LI> As image markers in line and scatter graphs</LI>
<LI> As background images for graphs</LI>
<LI> As a special type of icons (using the IconPlot()) which can be
added to the graph in any arbitrary position. See next section</LI>
</OL>
<P> In order to make it easy to find the appropriate country flags they
can be specified with either full or partial name or as an numeric
index. The routines in JpGraph are &quot;smart&quot; enough to figure out which
way you are trying to specify a particular flag.</P>
<P> To specify a country flag as a marker you have to specify the
special mark type as one of MARK_FLAG1,MARK_FLAG2,MARK_FLAG3 or
MARK_FLAG4</P>
<P> Flags are internally stored in 4 different sizes which is indicated
by the number in the mark types. Flags may also be arbitrary scaled
when displayed. Since this is partially overlapping functionality you
might very well ask why the flags are stored in four different basic
sizes. The reason is of course performance. It you only want a very
small flag it takes processing time to scale down a large image to,
say, a small icon size. At the same time for large flags to be used as
background a small original flag might not have enough details to be
scaled up to a large size. Hence the reason for storing the flags in 4
different sizes.</P>
<P> The example below shows how to use country flags as markers<DIV class="example">
<BR> <A href="exframes/frame_markflagex1.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/markflagex1.png" WIDTH="300"></A>
<BR><B>Figure 179:</B> Using country flags as line plot markers <A href="exframes/frame_markflagex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> To use country flags as background one has to use the method
Graph::SetBackgroundCountryFlag(). With this method you can specify
both how much of the image should be filled as well as how much of the
flag should be mixed into the background.</P>
<P> To see a list of all supported country flags you can run the script
&quot;listallcountryflags.php&quot; in the Example directory. This will show you
a table with all flags.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1021Timingthegenerationofgraphs.html">Previous</A>
<A HREF="1023Addingiconsontothegraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,65 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1022Usingcountryflagsinvariouscontext.html">
<LINK REL="Next" HREF="11Workingwithcanvasgraphs.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1022Usingcountryflagsinvariouscontext.html">Previous</A>
<A HREF="11Workingwithcanvasgraphs.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_23">10.23 Adding icons onto the graph</A></H2>
<P> In addition to the standard background image you can also add an
arbitrary number of icons onto the background of the graph. These icons
are created with a call to the special Plot class<I> IconPlot</I>.</P>
<P> The image from icons are taken from a file or as one of the builtin
country flags.</P>
<P> You may control how much of the icon should be blended into the
background by specifying a percentage (1-100). The example below shows
how to mix in the picture of &quot;Tux&quot; into the background of a filled line
graph. Note: This example uses alpha blending and will therefore
require GD2.<DIV class="example">
<BR> <A href="exframes/frame_lineiconex1.html" target="blank"><IMG border="0"
HEIGHT="250" src="img/lineiconex1.png" WIDTH="400"></A>
<BR><B>Figure 180:</B> Adding an icon into the background <A href="exframes/frame_lineiconex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> To specify any of the roughly 200 country flags as an icon you first
create an empty Icon and then call the IconPlot::SetCountryFlag() with
the appropriate parameters. (See the class reference). This is
illustrated below by adding the Icelandic flag into the background as
an icon<DIV class="example">
<BR> <A href="exframes/frame_lineiconex2.html" target="blank"><IMG border="0"
HEIGHT="250" src="img/lineiconex2.png" WIDTH="400"></A>
<BR><B>Figure 181:</B> Adding an icon flag into the background <A href="exframes/frame_lineiconex2.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P><DIV class="note"><B>Note:</B> Some older versions of PHP pre-4.3.3
using the builtin GD have problems rendering blended images. If you
have this problem then you need to upgrade to a more recent version of
PHP.</DIV></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1022Usingcountryflagsinvariouscontext.html">Previous</A>
<A HREF="11Workingwithcanvasgraphs.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,74 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="101WhyuseGanttcharts.html">
<LINK REL="Next" HREF="103AsimpleGanttchart.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="101WhyuseGanttcharts.html">Previous</A>
<A HREF="103AsimpleGanttchart.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_2">10.2 Capabilities in JpGraph Gantt module</A></H2>
<P></P>
<UL>
<LI> Both automatic and manual scaling of date</LI>
<LI> Full support for independent CSIM for both labels and activity bars</LI>
<LI> Extremely flexible scales, possibility to use both months, weeks,
days, hours and minutes as scales. Furthermore (unlike MS Project) you
can have as may scales displayed at the same time as you like.</LI>
<LI> Support for visualization of grouped activities</LI>
<LI> Gantt charts can be automatically sized according to the number of
bars and scale used. This means you don't have to supply a specific
size when creating a graph.</LI>
<LI> Unlimited number of activities</LI>
<LI> Supports platform independent Week number calculation according to
ISO:8601</LI>
<LI> Rich possibility to display a variety of scales or combination of
scales supports both day, week, month, year. Each scale header is
totally configurable in terms of font, size, color, background etc</LI>
<LI> User configurable date format in the scale headlines</LI>
<LI> Visualization of constrains between activities, start-to-start,
start-to-end, end-to-start and end-to-end</LI>
<LI> Scales have &quot;intelligent&quot; grids</LI>
<LI> Supports title and subtitle with user specified font, size and
color</LI>
<LI> Activity bars can have multiple patterns and colors</LI>
<LI> Activity bar may have shadows</LI>
<LI> Activity bars can have internal progress bars displayed to show how
much of a given task has been accomplished</LI>
<LI> Activity titles can have individual fonts, colors and backgrounds</LI>
<LI> Activity bars can have captions</LI>
<LI> Activity bars can have specified left- and right end markers</LI>
<LI> Bar heights can be specified in absolute pixels or in percent of
the activity line width</LI>
<LI> Supports milestones with many different marks</LI>
<LI> Supports vertical marker lines with text</LI>
<LI> Can easily be localized</LI>
<LI> Full support for CSIM (or drill down graphs)</LI>
<LI> Alternate row colors</LI>
<LI> ... and more</LI>
</UL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="101WhyuseGanttcharts.html">Previous</A>
<A HREF="103AsimpleGanttchart.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,169 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="101Introduction.html">
<LINK REL="Next" HREF="103Addinglinesandrectanglestoacanvas.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="101Introduction.html">Previous</A>
<A HREF="103Addinglinesandrectanglestoacanvas.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_2">10.2 Creating a simple canvas</A></H2>
<P> In order to create a canvas graph you need to include the file
&quot;jpgraph_canvas.php&quot; in addition to the standard &quot;jpgraph.php&quot; file.
You might also want to include the &quot;jpgraph_canvtools.php&quot; to get
access to some supporting classes that may (or not) come in handy.</P>
<P> Creating a canvas gives you the opportunity draw arbitrary shapes on
a &quot;white&quot; piece of paper. Let's first show a simple example were we
just draw a text box. We first show you the code which we will walk
through<DIV class="phpscript">(File: canvasex01.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
//&nbsp;$Id:&nbsp;canvasex01.php,v&nbsp;1.3&nbsp;2002/10/23&nbsp;08:17:23&nbsp;aditus&nbsp;Exp&nbsp;$
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas&nbsp;we&nbsp;can&nbsp;work&nbsp;
<BR></FONT><FONT color="#0000BB">$g&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
400</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">300</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">'auto'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">11</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">11</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;need&nbsp;to&nbsp;stroke&nbsp;the&nbsp;plotarea&nbsp;and&nbsp;margin&nbsp;before&nbsp;we&nbsp;add&nbsp;the
<BR>//&nbsp;text&nbsp;since&nbsp;we&nbsp;otherwise&nbsp;would&nbsp;overwrite&nbsp;the&nbsp;text.
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Draw&nbsp;a&nbsp;text&nbsp;box&nbsp;in&nbsp;the&nbsp;middle
<BR></FONT><FONT color="#0000BB">$txt</FONT><FONT color="#007700">=</FONT><FONT
color="#DD0000">&quot;This\nis\na&nbsp;TEXT!!!&quot;</FONT><FONT color="#007700">;
<BR></FONT><FONT color="#0000BB">$t&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">Text</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$txt</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">40</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;How&nbsp;should&nbsp;the&nbsp;text&nbsp;box&nbsp;interpret&nbsp;the&nbsp;coordinates?
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Align</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'center'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">'top'</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;How&nbsp;should&nbsp;the&nbsp;paragraph&nbsp;be&nbsp;aligned?
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ParagraphAlign</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'center'</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Add&nbsp;a&nbsp;box&nbsp;around&nbsp;the&nbsp;text,&nbsp;white&nbsp;fill,&nbsp;black&nbsp;border&nbsp;and&nbsp;gray&nbsp;shadow
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetBox</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;white&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;black&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">&quot;gray&quot;</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;text
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$g</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV></P>
<P> The example above starts by creating a (400x200) sized image. We set
the margins to get a nice frame around the image. For canvases the
margins has no effect in the way you enter coordinates. Top left is
(0,0) and bottom right (including any potential margin and shadow) is
the maximum. In this case the coordinates are X:0-399, and Y:0-199</P>
<P> We then call the <A href="../ref/CanvasGraph.html#_CANVASGRAPH_INITFRAME">
InitFrame()</A> method which actually strokes the margin and plotarea
to the graph. Since everything is stroked in the order you issue the
commands you must make sure that the graphical objects you want on top
is stroked last. This is different from the way you normally work with
JpGraph since it queues up all you addition and then makes sure they
are stroked in the correct order.</P>
<P> We then create a <A href="../ref/Text.html#_C_TEXT">Text</A> object,
setup it's properties, including the absolute screen position where we
want the text, and then stroke it. Her it might be a need for a closer
explanation of the, perhaps misnamed, method <A href="../ref/Text.html#_TEXT_ALIGN">
Text::Align()</A> This method states<STRONG> how the text coordinates
should be interpreted</STRONG> , i.e when we specify (200,10) as the
coordinates for the text paragraph should that be interpreted as the
top left corner, bottom-left corner or something else (of the bounding
box)? In the code above we have chosen to interpret the X-coordinate as
being the center of the bounding box and the Y-coordinate as the top.
Hence the text will be aligned so that the (200,100) point in the graph
is aligned with the middle of the top line of the paragraphs bounding
box.</P>
<P> We also specify that the lines within the paragraph should be
centered with a call to <A href="../ref/Text.html#_TEXT_PARAGRAPHALIGN">
Text::ParagraphAlign()</A> Since we also choose to have a box around
the text we have to make use of the method <A href="../ref/Text.html#_TEXT_SETBOX">
Text::SetBox()</A> which is used to specify the fill color, the border
color and the shadow color (if you leave out shadow color or set it to
'', no shadow will be used).</P>
<P> Now we are ready to stroke the text onto the canvas. In order to do
so we must specify the basic Image drawing class we want to use.
Without discussing this further we just state that a suitable image
class can always be found as the<STRONG> img</STRONG> property of the
Graph class.</P>
<P> Finally we are ready to stroke the entire graph, which in effect
sends the canvas back to the browser. Below you can see the effect of
all this code</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_canvasex01.html" target="blank"><IMG border="0"
HEIGHT="300" src="img/img/img/img/img/img/canvasex01.png" WIDTH="400"></A>
<BR><B>Figure 188:</B> A simple canvas drawing with a text box in the
middle <A href="exframes/frame_canvasex01.html" target="blank">[src]</A>
&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="101Introduction.html">Previous</A>
<A HREF="103Addinglinesandrectanglestoacanvas.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,187 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="102Creatingasimplecanvas.html">
<LINK REL="Next" HREF="104Usingacanvasscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="102Creatingasimplecanvas.html">Previous</A>
<A HREF="104Usingacanvasscale.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_3">10.3 Adding lines and rectangles to a canvas</A></H2>
<P> A canvas also makes a good background for using standard graphic
primitives, for example circles and lines. What you first have to
remember is that you are (so far) working with absolute screen
coordinates and secondly all drawing primitives are found in the <A href="../ref/Image.html#_C_IMAGE">
Image Class</A> accessible as a property of the Graph class. So for
example to draw a line between coordinate (0,0) and (100,100) you would
have to add the line<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">100</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">100</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P></P>
<P> To your code. The following example shows some of the graphic
primitives you have access to in the Image class<DIV class="phpscript">
(File: canvasex02.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
//&nbsp;$Id:&nbsp;canvasex02.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas&nbsp;we&nbsp;can&nbsp;work&nbsp;
<BR></FONT><FONT color="#0000BB">$g&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
400</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">'auto'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">11</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">11</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;need&nbsp;to&nbsp;stroke&nbsp;the&nbsp;plotarea&nbsp;and&nbsp;margin&nbsp;before&nbsp;we&nbsp;add&nbsp;the
<BR>//&nbsp;text&nbsp;since&nbsp;we&nbsp;otherwise&nbsp;would&nbsp;overwrite&nbsp;the&nbsp;text.
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;black&nbsp;line
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'black'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">100</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">100</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;and&nbsp;a&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Circle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">100</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">100</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;..&nbsp;and&nbsp;a&nbsp;filled&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">'red'</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
FilledCircle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
200</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">100</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
FilledRectangle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
10</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;filled&nbsp;rounded&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
FilledRoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
300</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">350</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">80</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">10</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;with&nbsp;a&nbsp;darker&nbsp;border
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'darkgreen'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
RoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
300</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">350</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">80</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">10</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV></P>
<P> Pleas note the way to access these routines through the img property
of the Graph class. Please also keep in mind that the coordinates are
absolute.</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_canvasex02.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/img/img/img/img/img/canvasex02.png" WIDTH="400"></A>
<BR><B>Figure 189:</B> Example of graphic primitives <A href="exframes/frame_canvasex02.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P></P>
<HR> <SMALL>
<P><STRONG> A note on GD</STRONG> For those of you using GD 1.xx you
might notice that the large &quot;filled circle&quot; isn't completely filled.
This is because in GD 1.xx there are no low level primitives to fill an
ellipse or circle so JpGraph tries to make the best out of a bad
situation and manually fake a filled circle. For interest of speed
JpGraph does not contain a complete (for example) Bresenham-circle fill
but cheats by using some existing GD routines. This is not a perfect
solution and for large filled circles like this you get some
moire-patterns in the circle. If you upgrade to GD 2.x JpGraph will be
able to make full use of those new existing methods and the fill will
be perfect.</P>
</SMALL>
<HR>
<P> We refer you to the class reference to find out what other graphic
primitives are available for use.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="102Creatingasimplecanvas.html">Previous</A>
<A HREF="104Usingacanvasscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,243 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="102CapabilitiesinJpGraphGanttmodule.html">
<LINK REL="Next" HREF="104ThestructureofaGanttchart.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="102CapabilitiesinJpGraphGanttmodule.html">Previous</A>
<A HREF="104ThestructureofaGanttchart.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_3">10.3 A simple Gantt chart</A></H2>
<P> Time to show you an example of a Gantt chart and how easy it is to
make one. Lets make it the simplest possible Gantt chart. One activity,
named &quot;Project&quot;, which lasts from &quot;2001-11-01&quot; to &quot;2002-02-20&quot;.</P>
<P> All it takes to do this (using default values for everything) is the
following code.<DIV class="phpscript">(File: ganttex00.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#007700">include&nbsp;(</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">);
<BR>include&nbsp;(</FONT><FONT color="#DD0000">&quot;../jpgraph_gantt.php&quot;</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;A&nbsp;new&nbsp;graph&nbsp;with&nbsp;automatic&nbsp;size
<BR></FONT><FONT color="#0000BB">$graph&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttGraph</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;auto&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;&nbsp;A&nbsp;new&nbsp;activity&nbsp;on&nbsp;row&nbsp;'0'
<BR></FONT><FONT color="#0000BB">$activity&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttBar</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">&quot;Project&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-12-21&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2002-01-20&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$activity</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Display&nbsp;the&nbsp;Gantt&nbsp;chart
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT></FONT></CODE></DIV></P>
<P> The resulting image is shown in Figure
<!--?echo FigNbr(); ?-->
below.<DIV style="margin-left:-120px;"><DIV class="example">
<BR> <A href="exframes/frame_ganttex00.html" target="blank"><IMG border="0"
HEIGHT="112" src="img/ganttex00.png" WIDTH="486"></A>
<BR><B>Figure 143:</B> Your first simple Gantt chart. <A href="exframes/frame_ganttex00.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV>
<P></P>
</DIV></P>
<P> Let's note a few things with the above image and code:</P>
<UL>
<LI> You always need to include both jpgraph.php and jpgraph_gantt.php</LI>
<LI> A bar is specified a minimum of four parameters, vertical position
(more about that in a second), a title, start and end date.</LI>
<LI> If you don't specify a size for the image it will be automatically
decided based on the min and max dates for the bars rounded to a full
week.</LI>
<LI> By default the week and day scale are displayed.</LI>
<LI> Weekend background are displayed default in a slightly gray color</LI>
<LI> Sundays are written in red.</LI>
<LI> Weeks are numbered according to ISO 8601</LI>
<LI> Activity bars are rendered as blue stripes on a white background by
default.</LI>
</UL>
<P> So, lets start making this graph a little bit more interesting.
First we are going to add a title, then we will add a month scale and
finally we will change the color of the bar.</P>
<P> All that is taken care of in the code below.<DIV class="phpscript">
(File: ganttex01.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#007700">include&nbsp;(</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">);
<BR>include&nbsp;(</FONT><FONT color="#DD0000">&quot;../jpgraph_gantt.php&quot;</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#0000BB">$graph&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttGraph</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;auto&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;title&nbsp;and&nbsp;subtitle
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;A&nbsp;nice&nbsp;main&nbsp;title&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">12</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">subtitle</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;(Draft&nbsp;version)&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Show&nbsp;day,&nbsp;week&nbsp;and&nbsp;month&nbsp;scale
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ShowHeaders</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
GANTT_HDAY&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HWEEK&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HMONTH</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Instead&nbsp;of&nbsp;week&nbsp;number&nbsp;show&nbsp;the&nbsp;date&nbsp;for&nbsp;the&nbsp;first&nbsp;day&nbsp;in&nbsp;the&nbsp;week
<BR>//&nbsp;on&nbsp;the&nbsp;week&nbsp;scale
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
week</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetStyle</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">WEEKSTYLE_FIRSTDAY</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Make&nbsp;the&nbsp;week&nbsp;scale&nbsp;font&nbsp;smaller&nbsp;than&nbsp;the&nbsp;default
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
week</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetFont</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">FF_FONT0</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Use&nbsp;the&nbsp;short&nbsp;name&nbsp;of&nbsp;the&nbsp;month&nbsp;together&nbsp;with&nbsp;a&nbsp;2&nbsp;digit&nbsp;year
<BR>//&nbsp;on&nbsp;the&nbsp;month&nbsp;scale
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
month</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetStyle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
MONTHSTYLE_SHORTNAMEYEAR2</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Format&nbsp;the&nbsp;bar&nbsp;for&nbsp;the&nbsp;first&nbsp;activity
<BR>//&nbsp;($row,$title,$startdate,$enddate)
<BR></FONT><FONT color="#0000BB">$activity&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttBar</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">&quot;Project&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-12-21&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2002-01-20&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Yellow&nbsp;diagonal&nbsp;line&nbsp;pattern&nbsp;on&nbsp;a&nbsp;red&nbsp;background
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetPattern</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">BAND_RDIAG</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;yellow&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetFillColor</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">&quot;red&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Finally&nbsp;add&nbsp;the&nbsp;bar&nbsp;to&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$activity</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;...&nbsp;and&nbsp;display&nbsp;it
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT></FONT></CODE></DIV> The resulting image is shown in Figure
144 below.<DIV class="example">
<BR> <A href="exframes/frame_ganttex01.html" target="blank"><IMG border="0"
HEIGHT="152" src="img/ganttex01.png" WIDTH="486"></A>
<BR><B>Figure 144:</B> Making the Gantt chart a little bit more
interesting with title and more colors. <A href="exframes/frame_ganttex01.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> From the above example you might note a few things</P>
<UL>
<LI> The margins adjust automatically to the added title and subtitle</LI>
<LI> The height of the scale headers adjust automatically when you
change the font.</LI>
<LI> You have great flexibility in choosing what format the scale labels
will have. If you for example wanted the full 4 digit year in the month
header all you have to change is use the constant
MONTHSTYLE_SHORTNAMEYEAR2 in the code above to
MONTHSTYLE_SHORTNAMEYEAR4</LI>
<LI> You have full freedom of manipulating headers in terms of font,
color, background and size.</LI>
</UL>
<P> To show that this is really simple let's show the full year in the
month, and set the header style to be white text on a dark blue
background by adding the lines<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Use&nbsp;the&nbsp;short&nbsp;name&nbsp;of&nbsp;the&nbsp;month&nbsp;together&nbsp;with&nbsp;a&nbsp;4&nbsp;digit&nbsp;year
<BR>//&nbsp;on&nbsp;the&nbsp;month&nbsp;scale
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
month</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetStyle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
MONTHSTYLE_SHORTNAMEYEAR4</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
month</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetTextColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;white&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
month</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetBackgroundColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;blue&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P>to the code above. The resulting image is shown in Figure 145<DIV class="example">
<BR> <A href="exframes/frame_ganttex02.html" target="blank"><IMG border="0"
HEIGHT="112" src="img/ganttex02.png" WIDTH="381"></A>
<BR><B>Figure 145:</B> Enhancing the scale headers. <A href="exframes/frame_ganttex02.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="102CapabilitiesinJpGraphGanttmodule.html">Previous</A>
<A HREF="104ThestructureofaGanttchart.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,62 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="103AsimpleGanttchart.html">
<LINK REL="Next" HREF="105CreatingaGanttChart.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="103AsimpleGanttchart.html">Previous</A>
<A HREF="105CreatingaGanttChart.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_4">10.4 The structure of a Gantt chart</A></H2>
<P> A Gantt chart is made up of four distinct areas.</P>
<OL>
<LI>On the left side there is the activity title column.</LI>
<LI>On the top there is the scale headers (up to four headers may be
displayed)</LI>
<LI>The actual plot area where all the Gantt bars and markers go</LI>
<LI>The margin area, where for example the titles are shown</LI>
</OL>
<P> Since a Gantt chart inherits all the usual properties of a JpGraph
Graph() you have the access to the same method to formatting the image
as before. For example to have a shadow around the image you call
Graph::SetShadow() and to set the margin color you can use
Graph::SetMarginColor(). Please refer to the reference documentation
for a full list of supported features.</P>
<P> To create a Gantt chart you<STRONG> add</STRONG> objects to it. As
of this writing you may add the following object by the use of the
GanttChart::Add() method</P>
<UL>
<LI> Gantt bars (indicates the length of an activity)</LI>
<LI> Milestones, a single mark at a specific date</LI>
<LI> Vertical line, might be use to mark phases in projects</LI>
</UL>
<P> All these objects may be extensively modified in terms of
formatting. You can specify color (both fill- and frame color), size,
titles, style and patterns and so on. All these objects comes with (in
my mind) sensible default so you don't have to specify a lot of
parameters. But if you need a fine grain control or if you disagree
with my taste you<STRONG> can</STRONG>.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="103AsimpleGanttchart.html">Previous</A>
<A HREF="105CreatingaGanttChart.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,291 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="103Addinglinesandrectanglestoacanvas.html">
<LINK REL="Next" HREF="105SampleapplicationDrawingDBschema.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="103Addinglinesandrectanglestoacanvas.html">Previous</A>
<A HREF="105SampleapplicationDrawingDBschema.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_4">10.4 Using a canvas scale</A></H2>
<P> The previous method using absolute coordinates works. But nothing
more. It doesn't give you any chance to easily scale the image (unless
you manually recalculate all used coordinates) , it gets tedious to
work with pixel level resolution. Especially if you just like to draw a
few basic shapes.</P>
<P> To help with this you can use a scale for the canvas. This lets you
define a &quot;work-space&quot; of your choice. You can for example set the
coordinates to be between X:0-10, Y:0-10. This makes it easier to
position objects on the canvas. This also has two additional
advantages:</P>
<UL>
<LI> If you increase the size of the canvas all objects will be
automatically scale to keep their proportions without any changes.</LI>
<LI> You can shrink/enlarge your drawing (not the image) by just using
another scale. For example if you originally draw the image using a
(0:10, 0:10) scale and then change the scale to (0:20, 0:20) then the
effect will be that you drawings will &quot;shrink&quot; to half their size.</LI>
</UL>
<P></P>
<P> To use this type of scaling you must make sure you include the file
&quot;jpgraph_canvtools.php&quot; . In addition to the scaling class their are
also a couple of other utility classes that may come in handy,
especially the <A href="../ref/Shape.html#_C_SHAPE"> Shape</A> class.</P>
<P> Using the scale is quite simple. You first instantiate a scale
object passing the graph as a parameter and then specify the scale you
want to use. This means you need to add the lines<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$scale&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$xmax</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$ymax</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> to your code. You can then use one of the translation methods (for
example <A href="../ref/CanvasScale.html#_CANVASSCALE_TRANSLATE">
CanvasScale::Translate()</A>) in the canvas scale class to translate
between your world coordinates and the absolute screen coordinates.
This means you could take the code in the example above and just add
the lines, for example,<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;</FONT><FONT color="#007700">list(</FONT><FONT color="#0000BB">
$x1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$y1</FONT><FONT
color="#007700">)&nbsp;=&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Translate</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$x1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$y1</FONT><FONT
color="#007700">);
<BR>list(</FONT><FONT color="#0000BB">$x2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$y2</FONT><FONT color="#007700">)&nbsp;=&nbsp;</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">Translate</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$x2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$y2</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$x1</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$y1</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$x2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$y2</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> Since this pattern has to be repeated for every object that has to
be drawn it makes good sense to encapsulate this in a separate class.
This is exactly why the canvas tools file also have a utility class
called <A href="../ref/Shape.html#_C_SHAPE"> Shape</A> This class is
mainly a wrapper around the most commonly used methods in the basic
Image class (with one important exception) and does all these the
translation for you. Please see the class reference for a complete list
of the available methods To set up the Shape class you instantiate it
with the graphic context and the scale you want to use as argument as
in</P>
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$shape&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
Shape</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$g</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$scale</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> You are then ready to use all the methods in the shape class. Using
a scale and imitating the previous example we would get the source
shown below.<DIV class="phpscript">(File: canvasex03.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
//&nbsp;$Id:&nbsp;canvasex03.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvtools.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Define&nbsp;work&nbsp;space
<BR></FONT><FONT color="#0000BB">$xmax</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">20</FONT><FONT color="#007700">;
<BR></FONT><FONT color="#0000BB">$ymax</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">20</FONT><FONT color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas&nbsp;we&nbsp;can&nbsp;work&nbsp;
<BR></FONT><FONT color="#0000BB">$g&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
400</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">'auto'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">11</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">11</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;need&nbsp;to&nbsp;stroke&nbsp;the&nbsp;plotarea&nbsp;and&nbsp;margin&nbsp;before&nbsp;we&nbsp;add&nbsp;the
<BR>//&nbsp;text&nbsp;since&nbsp;we&nbsp;otherwise&nbsp;would&nbsp;overwrite&nbsp;the&nbsp;text.
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Create&nbsp;a&nbsp;new&nbsp;scale
<BR></FONT><FONT color="#0000BB">$scale&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$xmax</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$ymax</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;The&nbsp;shape&nbsp;class&nbsp;is&nbsp;wrapper&nbsp;around&nbsp;the&nbsp;Imgae&nbsp;class&nbsp;which&nbsp;translates
<BR>//&nbsp;the&nbsp;coordinates&nbsp;for&nbsp;us
<BR></FONT><FONT color="#0000BB">$shape&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Shape</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$g</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$scale</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'black'</FONT><FONT color="#007700">);
<BR>
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;black&nbsp;line
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'black'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">20</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">20</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;and&nbsp;a&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Circle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">14</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;..&nbsp;and&nbsp;a&nbsp;filled&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'red'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">FilledCircle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
11</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">8</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">FilledRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">15</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
8</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">19</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">14</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;filled&nbsp;rounded&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">FilledRoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
3</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">8</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;with&nbsp;a&nbsp;darker&nbsp;border
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'darkgreen'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">RoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
3</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">8</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
);
<BR>
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV> The source above gives the following result<DIV class="example">
<BR> <A href="exframes/frame_canvasex03.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/img/img/img/img/img/canvasex03.png" WIDTH="400"></A>
<BR><B>Figure 190:</B> Drawing shapes on a canvas using a scale. <A href="exframes/frame_canvasex03.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> If we like to make a smaller image we could just change the image
size and everything will be rescaled without any further code changes.
SO for example making the image half the size would give the result<DIV class="example">
<BR> <A href="exframes/frame_canvasex04.html" target="blank"><IMG border="0"
HEIGHT="100" src="img/img/img/img/img/img/canvasex04.png" WIDTH="200"></A>
<BR><B>Figure 191:</B> Shrinking the image to half the size is easy
since the scaling will maintain the relative position of the objects <A href="exframes/frame_canvasex04.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> If we instead wanted to keep the image size but shrink the shapes we
could just make the scale twice as large which would result in<DIV class="example">
<BR> <A href="exframes/frame_canvasex05.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/img/img/img/img/img/canvasex05.png" WIDTH="400"></A>
<BR><B>Figure 192:</B> Shrinking hte graphic object by making the scale
twice as large <A href="exframes/frame_canvasex05.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> We previously mentioned that the Shape class was a wrapper around
the image class with one exception. So what is the exception? Well,
glad you asked. The exception is that it contain an additional method
which draws an &quot;indented rectangle&quot;. An indented rectangle is a
rectangle where one of it's four corners have been moved into the
rectangle. You create an indented rectangle by calling either <A href="../ref/Shape.html#_SHAPE_INDENTEDRECTANGLE">
Shape::IndentedRectangle()</A> or A few examples illustrates what this
shape looks like.<DIV class="example">
<BR> <A href="exframes/frame_canvasex06.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/img/img/img/img/img/canvasex06.png" WIDTH="400"></A>
<BR><B>Figure 193:</B> Examples of filled indented rectangles <A href="exframes/frame_canvasex06.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> As a final note we mention the class <A href="../ref/CanvasRectangleText.html#_C_CANVASRECTANGLETEXT">
CanvasRectangleText</A> Which can be used to add a text with a rounded
rectangle (possibly filled) onto the canvas. The previous example where
all the available fonts were drawn were using this class. We don't
describe it further but refer the interested reader to the class
reference and the 'listfontsex1.php' example file.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="103Addinglinesandrectanglestoacanvas.html">Previous</A>
<A HREF="105SampleapplicationDrawingDBschema.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,68 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="104ThestructureofaGanttchart.html">
<LINK REL="Next" HREF="106PositioningobjectsintheGanttplot.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="104ThestructureofaGanttchart.html">Previous</A>
<A HREF="106PositioningobjectsintheGanttplot.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_5">10.5 Creating a GanttChart</A></H2>
<P> You create a new Gantt Chart with a call to GanttChart(). The
signature for GanttGraph is the same as for ordinary JpGraph graphs,
i.e<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;</FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
GanttGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aWidth</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aHeight</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aCachedName</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aTimeOut</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aInline</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P>The only real difference is that for GanttCharts you can specify one
or both of the dimension parameters (width and height) as -1 in which
case that dimension will be automatically sized determined by scale and
fonts chosen. The following examples shows some possible ways of
creating a new graph</P>
<UL>
<LI> $graph=new GanttGraph()
<BR> The size of the graph will be determined automatically, no caching
will be used and the graph will be generated in-line.</LI>
<LI> $graph=new GanttGraph(-1,-1,&quot;auto&quot;)
<BR> The size of the graph will be determined automatically, caching
will be used (the name will be based on the script name), no timeout
will be used and the graph will be generated in-line</LI>
<LI> $graph=new GanttGraph(450,-1,&quot;auto&quot;,5)
<BR> Same as the previous entry but the width is fixed to 450 points and
the cached image will have a timeout of 5 min.</LI>
<LI> $graph=new GanttGraph(-1,-1,&quot;auto&quot;,5,false)
<BR> The image will not be generated in-line, only the cache will be
updated if it has timed out, otherwise nothing will happen.</LI>
</UL>
<P> Since GanttGraph() inherits all the methods (that make sense for
GanttGraph) from Graph you can specify shadow, color etc of the general
frame.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="104ThestructureofaGanttchart.html">Previous</A>
<A HREF="106PositioningobjectsintheGanttplot.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,433 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="104Usingacanvasscale.html">
<LINK REL="Next" HREF="11AntiSpamChallenges.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="104Usingacanvasscale.html">Previous</A>
<A HREF="11AntiSpamChallenges.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_5">10.5 Sample application: Drawing DB schema</A></H2>
<P> As a final example we shortly discuss how the canvas type of graph
was used to generate the DB schema for the DDDA architecture.</P>
<P> The library php file &quot;utils/misc/imgdbschema.php&quot; included in the
distribution contains some utility classes to make the drawing of table
schemes easier. It contains two basic classes, Class ImgDBTable and
Class ImgDBSchema. The first class understand how to draw an image
illustrating a single table. The second class is responsible for
automatically extract all the relevant information from a DB to draw a
complete DB Schema.</P>
<P> Before going into this a little bit more we show what an example of
this might look like.<DIV class="example">
<BR> <A href="exframes/frame_dbschemaex1.html" target="blank"><IMG border="0"
HEIGHT="750" src="img/img/img/img/img/img/dbschemaex1.png" WIDTH="600"></A>
<BR><B>Figure 194:</B> Example of using the canvas graph style together
with the imgdbschema.php library to semi-automatically generate a DB
schema <A href="exframes/frame_dbschemaex1.html" target="blank">[src]</A>
&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> Before going on it should be noted that the ImgDBSchema assumes that
the DB can be accessed through a DB abstraction layer modeled after the
abstraction layer available in the 'jpdb.php' file in the DDDA
architecture. This abstraction layer assumes a MySQL database in the
bottom. This specific dependency of this particular abstraction layer
is the reason why these classes is not included in the generic canvas
tools file.</P>
<P> The second thing to note is that this library does not contain a
complete automatic-layout engine but rather a very simple automatic
system which, if nothing else is specified, just puts the table in a
rectangular grid. A complete graph layout engine would simple be to
much to write in this context. This is also a very difficult
optimization problem and sofar not even any of the available research
programs that tries this can achieve a satisfactory layout without
manual intervention.</P>
<P> The critical lines in the code to generate the above graph is<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$tblposadj</FONT><FONT
color="#007700">=array(</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">2</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">4</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,-</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">16</FONT><FONT color="#007700">,-</FONT><FONT color="#0000BB">
1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$dbschema&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">ImgDBSchema</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">&quot;jpgraph_doc&quot;</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">&quot;FormatTblName&quot;</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">&quot;FormatFldName&quot;</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$topm</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetTableWidth</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
img</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> The rest of the code in the file is just to setup the canvas, add an
indented rectangle to group some tables and generate a footer with the
date and time this image was generated.</P>
<P> The first line instantiates a new ImgDBSCheme layout engine asking
it to draw an image for the database 'jpgraph_doc'. The following two
arguments specify two callback functions for formatting the text for
header and each field in a table.</P>
<P> The next line specify the top left margin where the drawing of the
tables should be started.</P>
<P> The third line specify the width of a single table. The final lines
starts the engine and draws all tables in the database to the canvas.
The final argument requires some further explanation. This is an offset
(x,y) from the top left corner how each individual table should be
positioned. If the value is -1 indicates that the default value should
be used. If this array is not specified then the tables will simple
arranged line by line.</P>
<P> The full source code for drawing this DB schema example is shown
below.</P>
<P><DIV class="phpscript">(File: dbschemaex1.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
/*=======================================================================
<BR>//&nbsp;File:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBSCHEMAEX1.PHP
<BR>//&nbsp;Description:&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;a&nbsp;DB&nbsp;schema&nbsp;of&nbsp;the&nbsp;DDDA&nbsp;architecture
<BR>//&nbsp;Created:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2002-08-25
<BR>//&nbsp;Author:&nbsp;&nbsp;&nbsp;&nbsp;Johan&nbsp;Persson&nbsp;(johanp@aditus.nu)
<BR>
//&nbsp;Ver:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Id:&nbsp;dbschemaex1.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
<BR>//
<BR>//&nbsp;License:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;code&nbsp;is&nbsp;released&nbsp;under&nbsp;QPL
<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copyright&nbsp;(C)&nbsp;2001,2002&nbsp;Johan&nbsp;Persson
<BR>
//&nbsp;Note:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;actual&nbsp;drawing&nbsp;of&nbsp;the&nbsp;tables&nbsp;are&nbsp;semi-automatically
<BR>
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;but&nbsp;you&nbsp;can&nbsp;easily&nbsp;adjust&nbsp;the&nbsp;individual&nbsp;tables&nbsp;position
<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;the&nbsp;'tblposadj'&nbsp;array.&nbsp;
<BR>//
<BR>
//========================================================================
<BR>*/
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvtools.php&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../utils/misc/imgdbschema.inc&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../utils/jpdocgen/jpdb.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Global&nbsp;callback&nbsp;to&nbsp;format&nbsp;the&nbsp;table&nbsp;header&nbsp;names
<BR></FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
FormatTblName</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aName</FONT><FONT color="#007700">)&nbsp;{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;want&nbsp;to&nbsp;replace&nbsp;any&nbsp;specifi&nbsp;references&nbsp;to&nbsp;the
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;'JpGraph'&nbsp;project&nbsp;with&nbsp;the&nbsp;generic&nbsp;'&lt;project&gt;'
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#007700">return&nbsp;</FONT><FONT color="#0000BB">
str_replace</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'JpGraph'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
'&lt;project&gt;'</FONT><FONT color="#007700">,&nbsp;</FONT><FONT color="#0000BB">
$aName</FONT><FONT color="#007700">);
<BR>}
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Global&nbsp;callback&nbsp;to&nbsp;format&nbsp;each&nbsp;field&nbsp;name&nbsp;in&nbsp;the&nbsp;table
<BR></FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
FormatFldName</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aName</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$aTable</FONT><FONT
color="#007700">)&nbsp;{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</FONT><FONT color="#0000BB">$aName</FONT><FONT color="#007700">
;
<BR>}
<BR>
<BR>
<BR>class&nbsp;</FONT><FONT color="#0000BB">Driver&nbsp;</FONT><FONT color="#007700">
{
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$ig</FONT><FONT color="#007700">
,&nbsp;</FONT><FONT color="#0000BB">$img</FONT><FONT color="#007700">,&nbsp;</FONT><FONT
color="#0000BB">$iscale</FONT><FONT color="#007700">,&nbsp;</FONT><FONT color="#0000BB">
$ishape</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$iymax</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$ixmax</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$iwidth</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$iheight</FONT><FONT color="#007700">;
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</FONT><FONT color="#0000BB">Driver</FONT><FONT color="#007700">
()&nbsp;{
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Define&nbsp;Image&nbsp;size&nbsp;and&nbsp;coordinate&nbsp;grid&nbsp;space&nbsp;to&nbsp;work&nbsp;within
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iwidth&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">600</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iheight</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">750</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iymax&nbsp;&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">50</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ixmax&nbsp;&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">55</FONT><FONT color="#007700">;
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">iwidth</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iheight</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">'auto'</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">img&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
ig</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">;
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Define&nbsp;the&nbsp;scale&nbsp;to&nbsp;be&nbsp;used
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ig</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">ixmax</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
iymax</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ishape&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Shape</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
ig</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;A&nbsp;small&nbsp;frame&nbsp;around&nbsp;the&nbsp;canvas
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</FONT><FONT color="#0000BB">Run</FONT><FONT color="#007700">
()&nbsp;{
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$leftm</FONT><FONT color="#007700">
=</FONT><FONT color="#0000BB">1.5</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#FF8000">//&nbsp;Left&nbsp;margin&nbsp;(for&nbsp;table&nbsp;schemes)&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$topm</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">5</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Top&nbsp;margin&nbsp;(for&nbsp;table&nbsp;schemes)&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">
=</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#FF8000">//&nbsp;Individual&nbsp;table&nbsp;width
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">1</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Offset&nbsp;for&nbsp;top&nbsp;line
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Add&nbsp;the&nbsp;background&nbsp;color&nbsp;for&nbsp;the&nbsp;project&nbsp;specific&nbsp;tables
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ishape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">IndentedRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$topm</FONT><FONT color="#007700">-</FONT><FONT color="#0000BB">1</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">
*</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT
color="#0000BB">$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
6</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">45</FONT><FONT
color="#007700">,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">
+</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">CORNER_BOTTOMLEFT</FONT><FONT
color="#007700">,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#DD0000">'lightblue'</FONT><FONT
color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Stroke&nbsp;the&nbsp;tables&nbsp;(series&nbsp;of&nbsp;x,y&nbsp;offsets,&nbsp;If&nbsp;=-1&nbsp;then&nbsp;use&nbsp;the
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;automtic&nbsp;positioning
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">
=array(</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">$tlo</FONT><FONT
color="#007700">+</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT color="#0000BB">
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">$tlo</FONT><FONT
color="#007700">+</FONT><FONT color="#0000BB">4</FONT><FONT color="#007700">
,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,-</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">16</FONT><FONT color="#007700">,-</FONT><FONT color="#0000BB">
1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">ImgDBSchema</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">'jpgraph_doc'</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">'FormatTblName'</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">'FormatFldName'</FONT><FONT color="#007700">
);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$topm</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetTableWidth</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
img</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasRectangleText</FONT><FONT color="#007700">
();
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
''</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
''</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFontColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'navy'</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;explanation
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">12</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'Project&nbsp;specific&nbsp;tables'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
$leftm</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;title
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
''</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_VERDANA</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">26</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'DDDA&nbsp;-&nbsp;DB&nbsp;Schema'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
9</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0.5</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT color="#007700">
);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;version&nbsp;and&nbsp;date
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'yellow'</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_FONT1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;Generated:&nbsp;&quot;</FONT><FONT color="#007700">.</FONT><FONT color="#0000BB">
date</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">&quot;ymd&nbsp;H:i&quot;</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">time</FONT><FONT color="#007700">
()),</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
iymax</FONT><FONT color="#007700">*</FONT><FONT color="#0000BB">0.96</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">
);&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>}
<BR>
<BR></FONT><FONT color="#0000BB">$driver&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Driver</FONT><FONT color="#007700">
();
<BR></FONT><FONT color="#0000BB">$driver</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Run</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="104Usingacanvasscale.html">Previous</A>
<A HREF="11AntiSpamChallenges.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,71 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="105CreatingaGanttChart.html">
<LINK REL="Next" HREF="107Ganttbars.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="105CreatingaGanttChart.html">Previous</A>
<A HREF="107Ganttbars.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_6">10.6 Positioning objects in the Gantt plot</A></H2>
<P> Bars and Milestones need both a vertical position and a horizontal
position. The horizontal start position is specified as a date, e.g.
&quot;2001-06-23&quot;, and the vertical positions are specified as a number
[0,1,2,3,...]. This vertical number indicates the position from the top
where the object should be placed. To understand this you might imagine
a number of &quot;invisible&quot; horizontal bands with a certain height. If you
specify 0 as the vertical position the bar will be placed in the first
band, specify 3 and the bar will be placed in the fourth band and so
on.</P>
<P> It is perfectly legal, and perhaps even desirable to leave &quot;gaps&quot;
when laying out bands to group related activities. So, for example you
could have three activities/bars at positions 1,2,3 and then another 2
bars at position 6,7 leaving band 0,4,5 empty.</P>
<P> All these &quot;invisible bands&quot; have the same height (equ-spaced). The
height of each band is automatically determined and depends on both the
method of layout ( as specified by (GanttChart::SetLayout()) and the
individual heights of the individual bars and titles. The rules are
quite simple:</P>
<UL>
<LI> If you use layout=GANTT_FROMTOP (the default and most common) the
height will equal the height (+ a margin) of the highest gantt bar. The
height calculation of each bar takes into account both the actual bar,
the title, and any left- right-marks (more about that later) that may
be present. The name &quot;fromtop&quot; refers to that when you have explicitly
specified a height the bars will usually be added from band 0 and
onwards and hence being added from the top. (This might leave empty
space at the bottom of the plot area in the graph if the height of the
graph has been explicitly specified).</LI>
<LI> If you use layout=GANTT_EVEN the bars are evenly (hence the name)
spread out over the available height in the gantt chart and no
consideration is taken of the individual bars heights. Note that if you
use automatic sizing you cant use even layout. It just doesn't make
sense. Even layout is for those cases when you deliberately specify a
very large image and want the bars evenly distributed using the full
height.</LI>
</UL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="105CreatingaGanttChart.html">Previous</A>
<A HREF="107Ganttbars.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="107Ganttbars.html">
<LINK REL="Next" HREF="1072Specifyingstartandendpositionforabar.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="107Ganttbars.html">Previous</A>
<A HREF="1072Specifyingstartandendpositionforabar.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_7_1">10.7.1 Specifying vertical position</A></H3>
<P> As described above vertical positions are specified as a numeric
value [0..n] where 'n' is an arbitrary constant. (For practical
purposes n is most likely &lt; 100)</P>
<P> Using our previous example we will illustrate this parameter by
changing the position of our 'Project' activity to position 7. Therefor
we change the call to GanttBar() to<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$activity&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">GanttBar</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
7</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">&quot;Project&quot;</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">&quot;2001-12-21&quot;</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">&quot;2002-02-20&quot;</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> and we then get the chart as shown below in Figure 146.</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_ganttex03.html" target="blank"><IMG border="0"
HEIGHT="280" src="img/ganttex03.png" WIDTH="486"></A>
<BR><B>Figure 146:</B> Changing the vertical position to 7 <A href="exframes/frame_ganttex03.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> Note that the height of each position (vertical position) will
depend on the actual height of the bar.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="107Ganttbars.html">Previous</A>
<A HREF="1072Specifyingstartandendpositionforabar.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1071Specifyingverticalposition.html">
<LINK REL="Next" HREF="1073Milestones.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1071Specifyingverticalposition.html">Previous</A>
<A HREF="1073Milestones.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_7_2">10.7.2 Specifying start and end position for a bar</A>
</H3>
<P> Start of bars are given as a date string. The format depends on the
current locale. Examples of valid date strings are</P>
<UL>
<LI> &quot;2001-10-22&quot;</LI>
<LI> &quot;22 October 2001&quot;</LI>
<LI> &quot;22 Oct 2001&quot;</LI>
</UL>
<P> Even if several format are supported it is recommended to use all
numeric dates, i.e in the form &quot;2001-10-22&quot;.</P>
<P> Specifying the end position may be done in two different ways,
either by the end date in the same way as for the start date. The other
way is to specify the<B> length</B> of the activity in number of days
(and fractions thereof). Examples of valid end dates are:</P>
<UL>
<LI> &quot;2001-11-15&quot;</LI>
<LI> &quot;15 Nov 2001&quot;</LI>
<LI> 22, (specifies duration of 22 days)</LI>
<LI> 22.7, (specifies duration of 22.7 days)</LI>
</UL>
<P> Please note that duration is specified as numerical values and<B>
not</B> strings.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1071Specifyingverticalposition.html">Previous</A>
<A HREF="1073Milestones.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,144 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1072Specifyingstartandendpositionforabar.html">
<LINK REL="Next" HREF="1074Verticalline.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1072Specifyingstartandendpositionforabar.html">Previous</A>
<A HREF="1074Verticalline.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_7_3">10.7.3 Milestones</A></H3>
<P> Milestones are similar to bars but have no end date since milestones
just apply to one single date. Milestones are created much the same way
as activities but using method MileStone() instead.</P>
<P> The full signature for milestones are<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;</FONT><FONT color="#007700">
function&nbsp;</FONT><FONT color="#0000BB">MileStone</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$aVPos</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$aTitle</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aDate</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aCaption</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P></P>
<P></P>
<TABLE border="0">
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aVPos&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>The vertical position for the
bar, [0..n]</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aTitle&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Title for the activity</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aDate&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Date for the milestone</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aCaption&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Text to the right of the
milestone</TD></TR>
</TABLE>
<P> Valid milestones are for example</P>
<UL>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$milestone&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
MileStone</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">&quot;Code&nbsp;complete&quot;</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">&quot;2001-12-01&quot;</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
<P></P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$milestone&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
MileStone</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">&quot;Code&nbsp;complete&quot;</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">&quot;2001-12-01&quot;</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">&quot;(2001-12-01)&quot;</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
<P></P>
</LI>
</UL>
<P> By default milestones are rendered as a filled &quot;Diamond&quot; shape. This
may be optionally modified. The actual shape is specified by the 'mark'
property of milestone which is an instance of the PlotMark() class
(same class responsible for the marks in line graphs).</P>
<P> To change the shape of a milestone to, say a triangle, you use the
SetType() method as in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$milestone</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">mark</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetType</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
MARK_DTRIANGLE</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> Let's put this into practice and add a milestone to our previous
example by adding the following two lines of code which result in
Figure 147 shown below.<DIV class="example">
<BR> <A href="exframes/frame_ganttex04.html" target="blank"><IMG border="0"
HEIGHT="189" src="img/ganttex04.png" WIDTH="493"></A>
<BR><B>Figure 147:</B> Illustration of how to add a milestone to a gantt
chart <A href="exframes/frame_ganttex04.html" target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> You may note that by default the title color is red for milestones.
If you like to change this to be instead, say bold black, you would
invoke the SetColor() and SetFont() methods on the title property of
milestones as in<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT
color="#0000BB">&nbsp;$milestone</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetFont</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">FF_FONT1</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">FF_BOLD</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$milestone</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;black&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> and thew result would now (not surprisingly be)<DIV class="example">
<BR> <A href="exframes/frame_ganttex05.html" target="blank"><IMG border="0"
HEIGHT="189" src="img/ganttex05.png" WIDTH="502"></A>
<BR><B>Figure 148:</B> Modifying the milestone title color and font <A href="exframes/frame_ganttex05.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> To modify the caption you do exactly the same but act on property
'caption' instead of 'title', i.e.<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$milestone</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">caption</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_FONT1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FF_BOLD</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$milestone</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">caption</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;black&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P></P>
<P> It is worth noting that you modify the bar title and caption the
exact same way by acting on the 'title' and 'caption' property for the
bars.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1072Specifyingstartandendpositionforabar.html">Previous</A>
<A HREF="1074Verticalline.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,160 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1073Milestones.html">
<LINK REL="Next" HREF="1075Addingmarkerstoaganttbar.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1073Milestones.html">Previous</A>
<A HREF="1075Addingmarkerstoaganttbar.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_7_4">10.7.4 Vertical line</A></H3>
<P> The final object you may add to a Gantt chart is simple, but quite
useful, a straight vertical line extending over the whole plot height.
This could for example be used to illustrate different phases in a
project. You create a line object by a call to GanttVLine()</P>
<P> The full signature for GanttVLine() is<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;</FONT><FONT color="#007700">
function&nbsp;</FONT><FONT color="#0000BB">GanttVLine</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$aDate</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$aTitle</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aColor</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aWeight</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aStyle</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P></P>
<P></P>
<TABLE border="0">
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aDate&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Date for the milestone</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aTitle&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Title for the line. The title is
displayed at the bottom of the line</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aColor&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Color for the line</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aWeight&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Line width</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aStyle&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Line style,&quot;dashed&quot;, &quot;dotted&quot; and
so on</TD></TR>
</TABLE>
<P> Valid creations of lines are for example</P>
<UL>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$vline&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
GanttVLine</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;2001-12-24&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV>
<P></P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$vline&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
GanttVLine</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;2001-12-24&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;Phase&nbsp;1&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV>
<P></P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$vline&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
GanttVLine</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;2001-12-24&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;Phase&nbsp;1&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;darkred&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV>
<P></P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$vline&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
GanttVLine</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;2001-12-24&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;Phase&nbsp;1&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;darkred&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">5</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
<P></P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$vline&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
GanttVLine</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;2001-12-24&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;Phase&nbsp;1&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;darkred&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">5</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">&quot;dotted&quot;</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
<P></P>
</LI>
</UL>
<P> To add the line to the graph you just have to call GanttGraph::Add()
as with milestones and bars. Let's illustrate the use of vertical lines
by adding a line to the previous example.<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;$vline&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttVLine</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">&quot;2001-12-24&quot;</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">&quot;Phase&nbsp;1&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Add</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$vline</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> and the example (See 149) now becomes<DIV class="example">
<BR> <A href="exframes/frame_ganttex06.html" target="blank"><IMG border="0"
HEIGHT="189" src="img/ganttex06.png" WIDTH="502"></A>
<BR><B>Figure 149:</B> Adding a vertical line with a title to the Gantt
chart <A href="exframes/frame_ganttex06.html" target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> From the above figure you can see that by default the line is drawn
at the beginning of the day of the specified date and in a 'dashed'
style. This can (of course!) be modified so that the line is
drawn/aligned anywhere in the specified day. You modify this by
invoking the method SetDayOffset() with an argument specifying the
fraction of the day where you want the line positioned.</P>
<P> If you, for example, want to display the line in the middle of the
day just add the line<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$vline</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetDayOffset</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0.5</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT>
</CODE></DIV></P>
<P> to the previous code and the result will be<DIV class="example">
<BR> <A href="exframes/frame_ganttex07.html" target="blank"><IMG border="0"
HEIGHT="189" src="img/ganttex07.png" WIDTH="502"></A>
<BR><B>Figure 150:</B> Modifying the position of the line within the day
<A href="exframes/frame_ganttex07.html" target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> As usual you may modify the font, size and color by invoking the
appropriate method (SetFont(), SetColor()) on the 'title' property of
lines.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1073Milestones.html">Previous</A>
<A HREF="1075Addingmarkerstoaganttbar.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,125 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1074Verticalline.html">
<LINK REL="Next" HREF="1076Adjustingtheminimumdistancebetweenbars.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1074Verticalline.html">Previous</A>
<A HREF="1076Adjustingtheminimumdistancebetweenbars.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_7_5">10.7.5 Adding markers to a gantt bar</A></H3>
<P> You can easily add a variety of markers both to the start and end of
the gantt bar. They could for example be used as an alternate way to
illustrate important milestones or anticipated deliveries.</P>
<P> The left and right markers are accessed through the two properties
'leftMark' and 'rightMark'. They are both instances of the general
'PlotMark' class which is also used for the milestones (and in line
graphs). The 'PlotMark' class supports several different styles, for
example, diamond (the default for milestones), filled and unfilled
circles, squares, stares, and so on. Please refer to the reference
section for a complete listing.</P>
<P> Let's illustrate this by adding a right marker to the previous
example. We will use a style of a filled (red) circle with a white
title, say, &quot;M5&quot;. In order to accomplish this we must augment the
previous example with the following lines:<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Show</FONT><FONT color="#007700">();&nbsp;&nbsp;&nbsp;&nbsp;
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">&quot;M5&quot;</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetType</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
MARK_FILLEDCIRCLE</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetWidth</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
10</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;red&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;red&quot;</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">12</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">rightMark</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">title</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;white&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> This might seem like a lot of lines but this is as complicated as it
possible can get. As an illustration in the example belwo more or less
everything that is changeable has been changed, the default font,
font-color, fill-color, frame-color and width of marker. The two lines
only really necessary are the first two, showing the mark and setting a
title. One could still get a good result by using default values for
the rest of the properties.</P>
<P> The resulting image can be seen in Figure 151 below.<DIV class="example">
<BR> <A href="exframes/frame_ganttex08.html" target="blank"><IMG border="0"
HEIGHT="243" src="img/ganttex08.png" WIDTH="502"></A>
<BR><B>Figure 151:</B> Adding a right marker to a bar. <A href="exframes/frame_ganttex08.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> We have deliberately introduced a &quot;strangeness&quot; here. If the
previous two examples are compared it can bee seen that the last
example is larger than the previous one. Why?</P>
<P> The explanation is trivial once we recall that the height of bars
are sized relative to the horizontal spacing. The horizontal spacing
are based on the highest single bar including title size and, here come
the explanation, marker size. The horizontal spacing has grown since
the minimum height is now based on 10 points(=the height of the mark).
The bar still occupy the same percentage of the height so it seems to
have grown.</P>
<P> If this behavior is unwanted it is always possible to specify an
absolute size for the bar heigh, say 8 pixels, with a call<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$activity</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetHeight</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">8</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> and achieve the result in Figure 152 below.<DIV class="example">
<BR> <A href="exframes/frame_ganttex09.html" target="blank"><IMG border="0"
HEIGHT="243" src="img/ganttex09.png" WIDTH="502"></A>
<BR><B>Figure 152:</B> Specifying an absolute size for the height of the
bar. <A href="exframes/frame_ganttex09.html" target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> It is worth noting that the height reserved for each bar is still
the same since we haven't changed the height of the marker and the
reserved space is the maximum height used by any bar.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1074Verticalline.html">Previous</A>
<A HREF="1076Adjustingtheminimumdistancebetweenbars.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,97 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1075Addingmarkerstoaganttbar.html">
<LINK REL="Next" HREF="108Formattingthescaleheaders.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1075Addingmarkerstoaganttbar.html">Previous</A>
<A HREF="108Formattingthescaleheaders.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_7_6">10.7.6 Adjusting the minimum distance between bars</A>
</H3>
<P> Let's see what happens if we set the height of each bar to be 100%
of the reserved height by adding another activity/bar below the first
one and set the height of each bar to 100% by adding the lines (We omit
the added lines to add another bar since they are just a copy of the
first bar)<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$activity</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetHeight</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">1.0</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity2</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetHeight</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">1.0</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> to the previous example. (Note that a value in the range [0..1] is
interpretated as the fraction of the reserved height while a value &gt; 1
is interpretated as the absolute size in pixels.)<DIV class="example">
<BR> <A href="exframes/frame_ganttex10.html" target="blank"><IMG border="0"
HEIGHT="243" src="img/ganttex10.png" WIDTH="502"></A>
<BR><B>Figure 153:</B> Setting the height for each bar to 100% <A href="exframes/frame_ganttex10.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> Aha.. What we are trying to do doesn't really make sense. Since we
have specified that the bar will always occupy 100% of the available
reserved with there will be no distance between the bars. So what if we
specify the bar as 10 pixel absolute by changing the lines to<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$activity</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetHeight</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">10</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$activity2</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetHeight</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">10</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> we instead get<DIV class="example">
<BR> <A href="exframes/frame_ganttex11.html" target="blank"><IMG border="0"
HEIGHT="243" src="img/ganttex11.png" WIDTH="502"></A>
<BR><B>Figure 154:</B> Setting both bars height to 10 pixels <A href="exframes/frame_ganttex11.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> So what can we actually do? Well if you remember the reserved height
for each bar is the maximum height of all bars including titles. This
guarantees that no two bars will ever overlap. To guarantee that titles
don't end up too close together there is a<B> Vertical Label Margin</B>
which basically specifies some extra &quot;air&quot; in between the titles. The
amount of air is specified in percent of the title height. To set the
margin you use<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;GanttGraph</FONT><FONT color="#007700">::</FONT><FONT color="#0000BB">
SetLabelVMarginFactor</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aMargin</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> As an example let's set that margin in the previous example to 0 and
see what happens.<DIV class="example">
<BR> <A href="exframes/frame_ganttex12.html" target="blank"><IMG border="0"
HEIGHT="212" src="img/ganttex12.png" WIDTH="502"></A>
<BR><B>Figure 155:</B> Setting the vertical label margin to 0% <A href="exframes/frame_ganttex12.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> As you would perhaps expect the two bars just barely touches now
since there are no extra margin added. If the two bars hadn't had the
extra right marker it would have looked very compressed.</P>
<P> By default the vertical margin is set to 40%.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1075Addingmarkerstoaganttbar.html">Previous</A>
<A HREF="108Formattingthescaleheaders.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,82 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="106PositioningobjectsintheGanttplot.html">
<LINK REL="Next" HREF="1071Specifyingverticalposition.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="106PositioningobjectsintheGanttplot.html">Previous</A>
<A HREF="1071Specifyingverticalposition.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_7">10.7 Gantt bars</A></H2>
<P> The most common of all object in a Gantt chart is of course the
activity bar (GanttBar()). In terms of formatting this object has a
very large flexibility. The full signature for the GanttBar constructor
is<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;</FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
GanttBar</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aVPos</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$aTitle</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$aStart</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$aEnd</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$aCaption</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$aHeight</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P></P>
<P></P>
<TABLE border="0">
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aVPos&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>The vertical position for the
bar, [0..n]</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aTitle&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Title for the activity</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aStart&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Start date for the activity given
as string, e.g &quot;2001-09-22&quot;</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aEnd&nbsp;</FONT></FONT></CODE>
</TD><TD valign="top">&nbsp;</TD><TD>End date for activity given as<B> either</B>
a date (a string) or as the duration (in days) of the activity, e.g
both &quot;2001-10-15&quot; and 20.5 are valid inputs</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aCaption&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Text string (caption) to appear
at the end (right side) of the bar</TD></TR>
<TR><TD valign="top">
<!--span style=&quot;font-family:times;font-size:85%;font-weight:bold;&quot;-->
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$aHeight&nbsp;</FONT></FONT>
</CODE></TD><TD valign="top">&nbsp;</TD><TD>Height of bar given as<B> either</B>
a value in range [0,1] in which case this is interpretated as what
fraction of the vertical position should the bar occupy. The height can
also be given in absolute pixels [1..200]</TD></TR>
</TABLE>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="106PositioningobjectsintheGanttplot.html">Previous</A>
<A HREF="1071Specifyingverticalposition.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,83 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="108Formattingthescaleheaders.html">
<LINK REL="Next" HREF="1082Hourscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="108Formattingthescaleheaders.html">Previous</A>
<A HREF="1082Hourscale.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_8_1">10.8.1 Minute scale</A></H3>
<P> Minute scale is the lowest resolution you can use. It is often
convenient to use Minute scale with &quot;GanttScale::SetINtervall()&quot; since
by default the increment will be 1 minute. The style of minute scale
can be further adjusted by the use<I> style</I> parameters which can be
one of</P>
<OL>
<LI> &quot;MINUTESTYLE_MM&quot;, This will display minutes as a two digit number
with a leading zero if necessary</LI>
<LI> &quot;MINUTESTYLE_CUSTOM&quot;, This will let you specify you own custom
minute style by making a call to<I> HeaderProperty:: SetFormatString()</I>
</LI>
</OL>
<P> Minute scale is enabled by adding the GANTT_HMIN in the
GanttGraph::ShowHeaders() call. For example as in<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ShowHeaders</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">GANTT_HDAY&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HHOUR&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_HMIN</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> The code snippet below shows how to set up a minute scale with 30
min interval and some custom colors.<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
minute</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetIntervall</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
30</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
minute</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetBackgroundColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'lightyellow:1.5'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
minute</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_FONT0</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
minute</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetStyle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
MINUTESTYLE_MM</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
minute</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">grid</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">SetColor</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">'lightgray'</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="108Formattingthescaleheaders.html">Previous</A>
<A HREF="1082Hourscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,86 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1081Minutescale.html">
<LINK REL="Next" HREF="1083Dayscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1081Minutescale.html">Previous</A>
<A HREF="1083Dayscale.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_8_2">10.8.2 Hour scale</A></H3>
<P> The hour scale has more builtin formatting possibilities. The
following formatting options are available</P>
<OL>
<LI> &quot;HOURSTYLE_HM24&quot;, Will display the only the hour in military time
0-24 , for example 13:00</LI>
<LI> &quot;HOURSTYLE_H24&quot;, Will display the hour with both hour and minute in
military time 0-24, for example 13</LI>
<LI>&quot;HOURSTYLE_HMAMPM&quot;, Will display the hour and minutes with a
suitable am/pm postfix, for example 1:30pm</LI>
<LI> &quot;HOURSTYLE_HAMPM&quot;, Will display only the hour with a suitable am/pm
postfix, for example 1pm</LI>
<LI>&quot;HOURSTYLE_CUSTOM&quot;, Custom defined format as specified with a call
to HeaderProperty::SetFormatString()</LI>
</OL>
<P> For hours it is possible to specify the interval in either of two
ways. With an integer, e.g. 6, or as time interval, e.g. &quot;1:30&quot; which
makes the interval one and a half hour. The only restriction is that
the interval must be even dividable for 24 hours since one day is the
smallest possible interval to show. This means that it is allowed to
use, for example 2,4,6,&quot;1:30&quot; or &quot;0:45&quot; as intervals but not 7, &quot;2:45&quot;.</P>
<P> The code snippet below shows hot to set up a hour scale to with 45
minutes interval and some custom colors<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">hour</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetBackgroundColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'lightyellow:1.5'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
hour</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetFont</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">FF_FONT1</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
hour</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetStyle</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">HOURSTYLE_HMAMPM</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
hour</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetIntervall</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;0:45&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> The example below shows a gantt chart with the day and hour scale
enabled<DIV class="example">
<BR> <A href="exframes/frame_gantthourex1.html" target="blank"><IMG border="0"
HEIGHT="173" src="img/gantthourex1.png" WIDTH="545"></A>
<BR><B>Figure 156:</B> Using hour scale in the Gantt chart <A href="exframes/frame_gantthourex1.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1081Minutescale.html">Previous</A>
<A HREF="1083Dayscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1082Hourscale.html">
<LINK REL="Next" HREF="1084Weekscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1082Hourscale.html">Previous</A>
<A HREF="1084Weekscale.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_8_3">10.8.3 Day scale</A></H3>
<P> By default the day scale show the first letter of the week day but
it is also posible to format the day scale in a number of different
ways. Days can have one of the following scale formats.</P>
<UL>
<LI>DAYSTYLE_ONELETTER, On letter week day. Example &quot;M&quot;</LI>
<LI>DAYSTYLE_LONG, Full week day. Example &quot;Monday&quot;</LI>
<LI>DAYSTYLE_LONGDAYDATE1, Day with date. Example &quot;Monday 23 Jun&quot;</LI>
<LI>DAYSTYLE_LONGDAYDATE2, Day with date+year. Example &quot;Monday 23 Jun
2003&quot;</LI>
<LI>DAYSTYLE_SHORT, Short date. Example &quot;Mon&quot;</LI>
<LI>DAYSTYLE_SHORTDAYDATE1, Short date+date. Example &quot;Mon 23/6&quot;</LI>
<LI>DAYSTYLE_SHORTDAYDATE2, Short date+date. Example &quot;Mon 23 Jun&quot;</LI>
<LI>DAYSTYLE_SHORTDAYDATE3,Short date+date. Example &quot;Mon 23&quot;</LI>
<LI>DAYSTYLE_SHORTDATE1, Short date. Example &quot;23/6&quot;</LI>
<LI>DAYSTYLE_SHORTDATE2, Short date. Example &quot;23 Jun&quot;</LI>
<LI>DAYSTYLE_SHORTDATE3, Short date. Example &quot;Mon 23&quot;</LI>
<LI>DAYSTYLE_SHORTDATE4, Short date. Example &quot;23&quot;</LI>
<LI>DAYSTYLE_CUSTOM, Custom specified formatting string. Example &quot;M&quot;</LI>
</UL>
<P> The formatting is specified by using the SetStyle() method as in<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">day</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetStyle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
DAYSTYLE_LONG</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> The graphical formatting possibilities for days allow the
possibility to specify a different color for the weekend background and
also for the Sunday.</P>
<UL>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetWeekendColor</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>Set the background color for weekends. (Defaults to light gray)</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetSundayFontColor</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>The Sunday font color. (Defaults to red)</P>
</LI>
</UL>
<P> In addition to this there is also a possibility to choose whether or
not the weekend background should be extended vertically down over the
plot area. (the default). Since that is a property more of the whole
plot this behavior is modified with a call to the method<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;UseWeekendBackground</FONT><FONT
color="#007700">()</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P>of the scale, e.g.
<BR> &nbsp;<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">UseWeekendBackground</FONT><FONT
color="#007700">(</FONT><FONT color="#0000BB">false</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1082Hourscale.html">Previous</A>
<A HREF="1084Weekscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,73 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1083Dayscale.html">
<LINK REL="Next" HREF="1085Monthscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1083Dayscale.html">Previous</A>
<A HREF="1085Monthscale.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_8_4">10.8.4 Week scale</A></H3>
<P> Week scales, if enabled, by default shows the week number in range 1
to 53 (as defined by ISO-8601, see the reference section).</P>
<P> It might be worth pointing out here that the week number calculation
is carried out within JpGraph and does not rely on the underlying OS
date libraries. This makes the behavior consistent over several OS:s
(at least M$ Windows does<B> not</B> comply to ISO-8601 or supply any
way of doing this through the normal libraries, e.g. strftime())</P>
<P> You may modify the week behavior in three ways. You can specify
(with SetStyle()) a different date format using the constants</P>
<UL>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;WEEKSTYLE_WNBR</FONT></FONT></CODE></DIV>
<P> Show week number To further modify the formatting of the actual week
number you can optionally supply a format string with a call to<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;SetLabelFormatString</FONT><FONT
color="#007700">()</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> The format of the string should be a standard sprintf() syntax
expecting an integer (the week number). By default a 'W' is prefixed to
the number.</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;WEEKSTYLE_FIRSTDAY</FONT></FONT></CODE></DIV>
<P> Show date of first day in week.</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;WEEKSTYLE_FIRSTDAY2</FONT></FONT></CODE></DIV>
<P> Show date of first day in week and short month</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;WEEKSTYLE_FIRSTDAYWNBR</FONT></FONT></CODE></DIV>
<P> Show weeknumber of first day in week.</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;WEEKSTYLE_FIRSTDAY2WNBR</FONT></FONT></CODE></DIV>
<P> Show weeknumber of first day in week and month</P>
</LI>
</UL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1083Dayscale.html">Previous</A>
<A HREF="1085Monthscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,73 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1084Weekscale.html">
<LINK REL="Next" HREF="1086Yearscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1084Weekscale.html">Previous</A>
<A HREF="1086Yearscale.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_8_5">10.8.5 Month scale</A></H3>
<P> For month scale you can use the SetStyle() method to choose between
a variety of formats.</P>
<UL>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_SHORTNAME</FONT></FONT></CODE></DIV>
<P>Display the month name in its locale specific short form, i.e Jan,
Feb etc</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_SHORTNAMEYEAR2</FONT></FONT></CODE></DIV>
<P>Display the month name in its locale specific short form together
with a 2 digit year , i.e Jan '01, Feb '01 etc</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_SHORTNAMEYEAR4</FONT></FONT></CODE></DIV>
<P>Display the month name in its locale specific short form together
with a 4 digit year , i.e Jan 2001, Feb 2001 etc</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_LONGNAME</FONT></FONT></CODE></DIV>
<P>Display the month name in its locale specific long name, i.e.
January, February</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_LONGNAMEYEAR2</FONT></FONT></CODE></DIV>
<P>Display the month name in its locale specific long name together with
a 2 digit year , i.e January '01, February '01 etc</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_LONGNAMEYEAR4</FONT></FONT></CODE></DIV>
<P>Display the month name in its locale specific long name together with
a 4 digit year , i.e January 2001, February 2001 etc</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;MONTHSTYLE_FIRSTLETTER</FONT></FONT></CODE></DIV>
<P>The first letter of the month name</P>
</LI>
</UL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1084Weekscale.html">Previous</A>
<A HREF="1086Yearscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1085Monthscale.html">
<LINK REL="Next" HREF="109Moreformattingforbars.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1085Monthscale.html">Previous</A>
<A HREF="109Moreformattingforbars.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_8_6">10.8.6 Year scale</A></H3>
<P> Year scale has no extra formatting possibilities.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1085Monthscale.html">Previous</A>
<A HREF="109Moreformattingforbars.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,129 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1076Adjustingtheminimumdistancebetweenbars.html">
<LINK REL="Next" HREF="1081Minutescale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1076Adjustingtheminimumdistancebetweenbars.html">Previous</A>
<A HREF="1081Minutescale.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_8">10.8 Formatting the scale headers</A></H2>
<P> The scale headers allow you to view up to four different scales at
the same time. The four basic scales are:</P>
<UL>
<LI> Day scale</LI>
<LI> Week scale</LI>
<LI> Month scale</LI>
<LI> Year scale</LI>
</UL>
<P> You can choose what scale to include and exclude by using the
SetScale() method. For example, for a detailed gantt you might choose
to display days and weeks by specifying<DIV class="phpscript"><CODE><FONT
color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ShowHeaders</FONT><FONT color="#007700">
(&nbsp;</FONT><FONT color="#0000BB">GANTT_HWEEK&nbsp;</FONT><FONT color="#007700">
|&nbsp;</FONT><FONT color="#0000BB">GANTT_DAY&nbsp;</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> If you instead wanted &quot;the big picture&quot; it might be enough to show
year and months by specifying<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ShowHeaders</FONT><FONT color="#007700">(&nbsp;</FONT><FONT color="#0000BB">
GANTT_YEAR&nbsp;</FONT><FONT color="#007700">|&nbsp;</FONT><FONT color="#0000BB">
GANTT_MONTH&nbsp;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> You can choose freely the combination of scales that you want, but a
chart must at least have one scale of course.</P>
<P> Once you have decided what level of details you need you can then
fine tune the exact layout/formatting of each of the enabled scales as
described below.</P>
<P> These scale header are all accessed through the graph instance
variables 'scale' as in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
week</FONT></FONT></CODE></DIV></P>
<P> or<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">day</FONT></FONT></CODE></DIV>
</P>
<P>. All these headers share the following properties.</P>
<UL>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;Show</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB"></FONT></FONT>
</CODE></DIV>
<P> Determine if the scale should be shown or not</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetFont</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV>
<P>Font for text in header</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetFontColor</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P> Specify the color of the header text</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetStyle</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV>
<P>Specify what date format should be used, for example in the week
scale it is possible to show either week number, the start date of the
week and so on.</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetBackgroundColor</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>As it says, the background color for the header</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetFrameWeight</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>The line weight of the box around the scale</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetFrameColor</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>The line color for the frame</P>
</LI>
<LI><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;SetTitleVertMargin</FONT><FONT color="#007700">()</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV>
<P>The margin, in percent, below and above the title text</P>
</LI>
</UL>
<P> In addition to these methods each scale also has the property 'grid'
which determines the appearance of grid lines for that specific scale.
You may modify the appearance of grid lines by the &quot;normal&quot; line
methods, i.e. SetColor(),SetWeight() SetStyle() and Show(). So for
example to set the week grid line red you would use<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">week</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
grid</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">SetColor</FONT><FONT
color="#007700">(</FONT><FONT color="#DD0000">&quot;red&quot;</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> Each of the scales also have some specific formatting possibilities
as described below.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1076Adjustingtheminimumdistancebetweenbars.html">Previous</A>
<A HREF="1081Minutescale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,71 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="109Moreformattingforbars.html">
<LINK REL="Next" HREF="1092Addingprogressindicatorstobars.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="109Moreformattingforbars.html">Previous</A>
<A HREF="1092Addingprogressindicatorstobars.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_9_1">10.9.1 Adding caption to bars</A></H3>
<P> Caption for bars are placed at the far right side of the bars. They
can for example be used to indicate the resources assigned to a task,
the duration of the task or the progress of the activity.</P>
<P> Caption text for a bar is specified either when creating a bar or
later by accessing the 'caption' property of bars. So the two lines<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$activity&nbsp;</FONT><FONT
color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">GanttBar</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">&quot;Activity&nbsp;1&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-11-21&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;2001-12-20&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;[BS,ER]&quot;</FONT><FONT color="#007700">)</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> and<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$activity</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
caption</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">Set</FONT><FONT
color="#007700">(</FONT><FONT color="#DD0000">&quot;[BS,ER]&quot;</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> are both ways of specifying the caption &quot;[BS,ER]&quot; for the activity.
Since activity is a standard JpGraph text object you can easily modify
font, color and size with calls to SetFont() and SetColor(), (e.g.<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$activity</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">caption</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FF_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">9</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P></P>
<P> The figure below illustrates the use of caption<DIV class="example">
<BR> <A href="exframes/frame_ganttex13.html" target="blank"><IMG border="0"
HEIGHT="186" src="img/ganttex13.png" WIDTH="409"></A>
<BR><B>Figure 157:</B> Illustration of the use of captions <A href="exframes/frame_ganttex13.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="109Moreformattingforbars.html">Previous</A>
<A HREF="1092Addingprogressindicatorstobars.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,76 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1091Addingcaptiontobars.html">
<LINK REL="Next" HREF="1010Groupingactivities.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1091Addingcaptiontobars.html">Previous</A>
<A HREF="1010Groupingactivities.html">Next</A>
<HR NOSHADE>
<H3><A NAME="10_9_2">10.9.2 Adding progress indicators to bars</A></H3>
<P> To indicate the progress of a specific activity it is also possible
to add a progress indicator to each bar. This progress indicator
consists of a smaller bar within the bar. By default this progress bar
is black and 70% of the height of the bar. These parameter can (of
course) all be changed.</P>
<P> The properties for the progress indicator are accessed through the
'progress' property and it's methods.</P>
<P> To set the progress for a specific activity you only specify the
percent as a fraction. As in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$activity</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">progress</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">0.4</FONT><FONT
color="#007700">)</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> In Figure 158 the previous example is modified to indicate the
progress of each activity by the default progress indicator. A solid
bar. To make it clearer we have also modified the caption to reflect
the displayed progress. (At the same time we also modified the scale
headers just to illustrate some more formatting options).<DIV class="example">
<BR> <A href="exframes/frame_ganttex14.html" target="blank"><IMG border="0"
HEIGHT="191" src="img/ganttex14.png" WIDTH="409"></A>
<BR><B>Figure 158:</B> Adding progress indicators. <A href="exframes/frame_ganttex14.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> To specify a different format for the progress you use the
SetPattern() method as in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$activity</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">progress</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetPattern</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
BAND_RDIAG</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;blue&quot;</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P> In the reference section you can see the exact parameters and all
available methods.<DIV class="example">
<BR> <A href="exframes/frame_ganttex15.html" target="blank"><IMG border="0"
HEIGHT="191" src="img/ganttex15.png" WIDTH="409"></A>
<BR><B>Figure 159:</B> Changing the style of the progress indicators. <A href="exframes/frame_ganttex15.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1091Addingcaptiontobars.html">Previous</A>
<A HREF="1010Groupingactivities.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,36 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1086Yearscale.html">
<LINK REL="Next" HREF="1091Addingcaptiontobars.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1086Yearscale.html">Previous</A>
<A HREF="1091Addingcaptiontobars.html">Next</A>
<HR NOSHADE>
<H2><A NAME="10_9">10.9 More formatting for bars</A></H2>
<P> This section shows some further modification you might do to
activity bars.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1086Yearscale.html">Previous</A>
<A HREF="1091Addingcaptiontobars.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,35 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="937Afinalexample.html">
<LINK REL="Next" HREF="101WhyuseGanttcharts.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="937Afinalexample.html">Previous</A>
<A HREF="101WhyuseGanttcharts.html">Next</A>
<HR NOSHADE>
<H1><A NAME="10">10 Gantt charts</A></H1>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="937Afinalexample.html">Previous</A>
<A HREF="101WhyuseGanttcharts.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="923Addingiconsontothegraph.html">
<LINK REL="Next" HREF="101Introduction.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="923Addingiconsontothegraph.html">Previous</A>
<A HREF="101Introduction.html">Next</A>
<HR NOSHADE>
<H1><A NAME="10">10 Working with canvas graphs</A></H1>
<P> Canvas graphing is an advanced feature that comes in handy where you
need to draw some more arbitrary graphics. To give you a flavor of what
you can do the following example shows an architecture overview of
JpGraph which was drawn using a canvas.<DIV class="example">
<BR> <A href="exframes/frame_canvas_jpgarchex.html" target="blank"><IMG border="0"
HEIGHT="650" src="img/img/img/img/img/img/canvas_jpgarchex.png" WIDTH="700"></A>
<BR><B>Figure 186:</B> Example of what you can draw on a canvas <A href="exframes/frame_canvas_jpgarchex.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> Working with canvas requires more understanding of JpGraph as well
as more programming and fine tuning.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="923Addingiconsontothegraph.html">Previous</A>
<A HREF="101Introduction.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="11AntiSpamChallenges.html">
<LINK REL="Next" HREF="12CodedefinesinJpGraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="11AntiSpamChallenges.html">Previous</A>
<A HREF="12CodedefinesinJpGraph.html">Next</A>
<HR NOSHADE>
<H2><A NAME="11_1">11.1 Generating Anti-Spam challenge</A></H2>
<P> There are two basic alternatives on how to generate the content of
the anti-spam image</P>
<OL>
<LI> Submit a string that should be used</LI>
<LI> Automatically generate a random string. If this alternative is
chosen then the user of the library should save the created string and
compare it to what the user enters.</LI>
</OL>
<P> In order to write a script to generate a new challenge there are
four steps to be completed.</P>
<P><B> First</B> include the library file<I> jpgraph_antispam.php</I>.
Note that there is no need to include the &quot;jpgraph.php&quot; library since
all functionality is included in this library file.<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;</FONT><FONT color="#007700">
require_once&nbsp;</FONT><FONT color="#DD0000">&quot;jpgraph_antispam.php&quot;</FONT><FONT
color="#007700">;</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P><B> Secondly</B> a new instance of the class<I> AntiSpam</I> must be
created<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$spam&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
AntiSpam</FONT><FONT color="#007700">();</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P><B> Thirdly</B> the string to be used in the challenge must be
specified. To automatically generate a suitable string use<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;The&nbsp;argument&nbsp;determines&nbsp;the&nbsp;length&nbsp;of&nbsp;the&nbsp;generated&nbsp;string
<BR></FONT><FONT color="#0000BB">$chars&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">$spam</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Rand</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">5</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> If instead the string to be used should be specified this string
should be specified in the initial creation of the AntiSpam() or by
calling the<I> Set()</I> method as in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$spam</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">&quot;aui8k&quot;</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P>Please note that in order to minimize the risk for confusion the
letters 'O' and the number '0' (zero) is not allowed since they are too
alike and can be mistaken for each other.</P>
<P><B> The final and fourth step</B> is to output the image with a call
the method<I> Stroke()</I> on the created instance of the<I> AntiSpam</I>
class.<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;</FONT><FONT color="#007700">if(&nbsp;</FONT><FONT color="#0000BB">$spam</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">
()&nbsp;===&nbsp;</FONT><FONT color="#0000BB">false&nbsp;</FONT><FONT color="#007700">
)&nbsp;{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;die(</FONT><FONT color="#DD0000">&quot;Illegal&nbsp;or&nbsp;no&nbsp;data&nbsp;to&nbsp;plot&quot;</FONT><FONT
color="#007700">);
<BR>}</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P>Note that we have put a guard around the output since in the case of
an error this method will result a boolean false value. As with the
other graph types it is possible to write the generated image to a file
by submitting a file name as an argument to<I> Stroke()</I>.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="11AntiSpamChallenges.html">Previous</A>
<A HREF="12CodedefinesinJpGraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,61 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="11Workingwithcanvasgraphs.html">
<LINK REL="Next" HREF="112Creatingasimplecanvas.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="11Workingwithcanvasgraphs.html">Previous</A>
<A HREF="112Creatingasimplecanvas.html">Next</A>
<HR NOSHADE>
<H2><A NAME="11_1">11.1 Introduction</A></H2>
<P> Canvas graph is really not a graph. It a blank sheet of paper which
you can use to draw arbitrary shapes and still have access to some of
the convenient features of JpGraph.</P>
<P> You can work with a canvas in different levels of complexity. You
can for example work directly with the Image class which provides a
large number of primitives for drawing but requires that you use
absolute pixel coordinates.</P>
<P> You can also make life a little bit easier by using a canvas scale.
This lets you define your own scale on the canvas which often makes it
easier by letting you work on a grid you have specified yourself. It
also makes it very easy to re-scale you image automatically by just
changing your scale. For example to half the size of you drawing you
just make the scale twice as large.</P>
<P> To give you some help in working with different canvas you should
include the &quot;jpgraph_canvtools.php&quot; file when working on canvases. This
is not strictly necessary but it will give you some nice abstraction to
help you create your masterpieces.</P>
<P> As another (concrete) example on the use of a canvas the figure
below is a listing of font styles available with JpGraph.<DIV class="example">
<BR> <A href="exframes/frame_listfontsex1.html" target="blank"><IMG border="0"
HEIGHT="450" src="img/listfontsex1.png" WIDTH="550"></A>
<BR><B>Figure 183:</B> Another example of using a canvas to draw a
number of text boxes <A href="exframes/frame_listfontsex1.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="11Workingwithcanvasgraphs.html">Previous</A>
<A HREF="112Creatingasimplecanvas.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,169 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="111Introduction.html">
<LINK REL="Next" HREF="113Addinglinesandrectanglestoacanvas.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="111Introduction.html">Previous</A>
<A HREF="113Addinglinesandrectanglestoacanvas.html">Next</A>
<HR NOSHADE>
<H2><A NAME="11_2">11.2 Creating a simple canvas</A></H2>
<P> In order to create a canvas graph you need to include the file
&quot;jpgraph_canvas.php&quot; in addition to the standard &quot;jpgraph.php&quot; file.
You might also want to include the &quot;jpgraph_canvtools.php&quot; to get
access to some supporting classes that may (or not) come in handy.</P>
<P> Creating a canvas gives you the opportunity draw arbitrary shapes on
a &quot;white&quot; piece of paper. Let's first show a simple example were we
just draw a text box. We first show you the code which we will walk
through<DIV class="phpscript">(File: canvasex01.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
//&nbsp;$Id:&nbsp;canvasex01.php,v&nbsp;1.3&nbsp;2002/10/23&nbsp;08:17:23&nbsp;aditus&nbsp;Exp&nbsp;$
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas&nbsp;we&nbsp;can&nbsp;work&nbsp;
<BR></FONT><FONT color="#0000BB">$g&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
400</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">300</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">'auto'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">11</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">11</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;need&nbsp;to&nbsp;stroke&nbsp;the&nbsp;plotarea&nbsp;and&nbsp;margin&nbsp;before&nbsp;we&nbsp;add&nbsp;the
<BR>//&nbsp;text&nbsp;since&nbsp;we&nbsp;otherwise&nbsp;would&nbsp;overwrite&nbsp;the&nbsp;text.
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Draw&nbsp;a&nbsp;text&nbsp;box&nbsp;in&nbsp;the&nbsp;middle
<BR></FONT><FONT color="#0000BB">$txt</FONT><FONT color="#007700">=</FONT><FONT
color="#DD0000">&quot;This\nis\na&nbsp;TEXT!!!&quot;</FONT><FONT color="#007700">;
<BR></FONT><FONT color="#0000BB">$t&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">Text</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$txt</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">40</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;How&nbsp;should&nbsp;the&nbsp;text&nbsp;box&nbsp;interpret&nbsp;the&nbsp;coordinates?
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Align</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'center'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">'top'</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;How&nbsp;should&nbsp;the&nbsp;paragraph&nbsp;be&nbsp;aligned?
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ParagraphAlign</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'center'</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Add&nbsp;a&nbsp;box&nbsp;around&nbsp;the&nbsp;text,&nbsp;white&nbsp;fill,&nbsp;black&nbsp;border&nbsp;and&nbsp;gray&nbsp;shadow
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetBox</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;white&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
&quot;black&quot;</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">&quot;gray&quot;</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;text
<BR></FONT><FONT color="#0000BB">$t</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$g</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV></P>
<P> The example above starts by creating a (400x200) sized image. We set
the margins to get a nice frame around the image. For canvases the
margins has no effect in the way you enter coordinates. Top left is
(0,0) and bottom right (including any potential margin and shadow) is
the maximum. In this case the coordinates are X:0-399, and Y:0-199</P>
<P> We then call the <A href="../ref/CanvasGraph.html#_CANVASGRAPH_INITFRAME">
InitFrame()</A> method which actually strokes the margin and plotarea
to the graph. Since everything is stroked in the order you issue the
commands you must make sure that the graphical objects you want on top
is stroked last. This is different from the way you normally work with
JpGraph since it queues up all you addition and then makes sure they
are stroked in the correct order.</P>
<P> We then create a <A href="../ref/Text.html#_C_TEXT">Text</A> object,
setup it's properties, including the absolute screen position where we
want the text, and then stroke it. Her it might be a need for a closer
explanation of the, perhaps misnamed, method <A href="../ref/Text.html#_TEXT_ALIGN">
Text::Align()</A> This method states<STRONG> how the text coordinates
should be interpreted</STRONG> , i.e when we specify (200,10) as the
coordinates for the text paragraph should that be interpreted as the
top left corner, bottom-left corner or something else (of the bounding
box)? In the code above we have chosen to interpret the X-coordinate as
being the center of the bounding box and the Y-coordinate as the top.
Hence the text will be aligned so that the (200,100) point in the graph
is aligned with the middle of the top line of the paragraphs bounding
box.</P>
<P> We also specify that the lines within the paragraph should be
centered with a call to <A href="../ref/Text.html#_TEXT_PARAGRAPHALIGN">
Text::ParagraphAlign()</A> Since we also choose to have a box around
the text we have to make use of the method <A href="../ref/Text.html#_TEXT_SETBOX">
Text::SetBox()</A> which is used to specify the fill color, the border
color and the shadow color (if you leave out shadow color or set it to
'', no shadow will be used).</P>
<P> Now we are ready to stroke the text onto the canvas. In order to do
so we must specify the basic Image drawing class we want to use.
Without discussing this further we just state that a suitable image
class can always be found as the<STRONG> img</STRONG> property of the
Graph class.</P>
<P> Finally we are ready to stroke the entire graph, which in effect
sends the canvas back to the browser. Below you can see the effect of
all this code</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_canvasex01.html" target="blank"><IMG border="0"
HEIGHT="300" src="img/canvasex01.png" WIDTH="400"></A>
<BR><B>Figure 184:</B> A simple canvas drawing with a text box in the
middle <A href="exframes/frame_canvasex01.html" target="blank">[src]</A>
&nbsp;
<P></P>
</DIV></P>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="111Introduction.html">Previous</A>
<A HREF="113Addinglinesandrectanglestoacanvas.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,187 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="112Creatingasimplecanvas.html">
<LINK REL="Next" HREF="114Usingacanvasscale.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="112Creatingasimplecanvas.html">Previous</A>
<A HREF="114Usingacanvasscale.html">Next</A>
<HR NOSHADE>
<H2><A NAME="11_3">11.3 Adding lines and rectangles to a canvas</A></H2>
<P> A canvas also makes a good background for using standard graphic
primitives, for example circles and lines. What you first have to
remember is that you are (so far) working with absolute screen
coordinates and secondly all drawing primitives are found in the <A href="../ref/Image.html#_C_IMAGE">
Image Class</A> accessible as a property of the Graph class. So for
example to draw a line between coordinate (0,0) and (100,100) you would
have to add the line<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$graph</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">100</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">100</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P></P>
<P> To your code. The following example shows some of the graphic
primitives you have access to in the Image class<DIV class="phpscript">
(File: canvasex02.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
//&nbsp;$Id:&nbsp;canvasex02.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas&nbsp;we&nbsp;can&nbsp;work&nbsp;
<BR></FONT><FONT color="#0000BB">$g&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
400</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">'auto'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">11</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">11</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;need&nbsp;to&nbsp;stroke&nbsp;the&nbsp;plotarea&nbsp;and&nbsp;margin&nbsp;before&nbsp;we&nbsp;add&nbsp;the
<BR>//&nbsp;text&nbsp;since&nbsp;we&nbsp;otherwise&nbsp;would&nbsp;overwrite&nbsp;the&nbsp;text.
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;black&nbsp;line
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'black'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">100</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">100</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;and&nbsp;a&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Circle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">100</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">100</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;..&nbsp;and&nbsp;a&nbsp;filled&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">'red'</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
FilledCircle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
200</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">100</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
FilledRectangle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
10</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">50</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;filled&nbsp;rounded&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
FilledRoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
300</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">350</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">80</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">10</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;with&nbsp;a&nbsp;darker&nbsp;border
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'darkgreen'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
RoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
300</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">350</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">80</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">10</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV></P>
<P> Pleas note the way to access these routines through the img property
of the Graph class. Please also keep in mind that the coordinates are
absolute.</P>
<P><DIV class="example">
<BR> <A href="exframes/frame_canvasex02.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/canvasex02.png" WIDTH="400"></A>
<BR><B>Figure 185:</B> Example of graphic primitives <A href="exframes/frame_canvasex02.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P></P>
<HR> <SMALL>
<P><STRONG> A note on GD</STRONG> For those of you using GD 1.xx you
might notice that the large &quot;filled circle&quot; isn't completely filled.
This is because in GD 1.xx there are no low level primitives to fill an
ellipse or circle so JpGraph tries to make the best out of a bad
situation and manually fake a filled circle. For interest of speed
JpGraph does not contain a complete (for example) Bresenham-circle fill
but cheats by using some existing GD routines. This is not a perfect
solution and for large filled circles like this you get some
moire-patterns in the circle. If you upgrade to GD 2.x JpGraph will be
able to make full use of those new existing methods and the fill will
be perfect.</P>
</SMALL>
<HR>
<P> We refer you to the class reference to find out what other graphic
primitives are available for use.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="112Creatingasimplecanvas.html">Previous</A>
<A HREF="114Usingacanvasscale.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,291 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="113Addinglinesandrectanglestoacanvas.html">
<LINK REL="Next" HREF="115SampleapplicationDrawingDBschema.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="113Addinglinesandrectanglestoacanvas.html">Previous</A>
<A HREF="115SampleapplicationDrawingDBschema.html">Next</A>
<HR NOSHADE>
<H2><A NAME="11_4">11.4 Using a canvas scale</A></H2>
<P> The previous method using absolute coordinates works. But nothing
more. It doesn't give you any chance to easily scale the image (unless
you manually recalculate all used coordinates) , it gets tedious to
work with pixel level resolution. Especially if you just like to draw a
few basic shapes.</P>
<P> To help with this you can use a scale for the canvas. This lets you
define a &quot;work-space&quot; of your choice. You can for example set the
coordinates to be between X:0-10, Y:0-10. This makes it easier to
position objects on the canvas. This also has two additional
advantages:</P>
<UL>
<LI> If you increase the size of the canvas all objects will be
automatically scale to keep their proportions without any changes.</LI>
<LI> You can shrink/enlarge your drawing (not the image) by just using
another scale. For example if you originally draw the image using a
(0:10, 0:10) scale and then change the scale to (0:20, 0:20) then the
effect will be that you drawings will &quot;shrink&quot; to half their size.</LI>
</UL>
<P></P>
<P> To use this type of scaling you must make sure you include the file
&quot;jpgraph_canvtools.php&quot; . In addition to the scaling class their are
also a couple of other utility classes that may come in handy,
especially the <A href="../ref/Shape.html#_C_SHAPE"> Shape</A> class.</P>
<P> Using the scale is quite simple. You first instantiate a scale
object passing the graph as a parameter and then specify the scale you
want to use. This means you need to add the lines<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$scale&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$xmax</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$ymax</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> to your code. You can then use one of the translation methods (for
example <A href="../ref/CanvasScale.html#_CANVASSCALE_TRANSLATE">
CanvasScale::Translate()</A>) in the canvas scale class to translate
between your world coordinates and the absolute screen coordinates.
This means you could take the code in the example above and just add
the lines, for example,<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;</FONT><FONT color="#007700">list(</FONT><FONT color="#0000BB">
$x1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$y1</FONT><FONT
color="#007700">)&nbsp;=&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Translate</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$x1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$y1</FONT><FONT
color="#007700">);
<BR>list(</FONT><FONT color="#0000BB">$x2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$y2</FONT><FONT color="#007700">)&nbsp;=&nbsp;</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">scale</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">Translate</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$x2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$y2</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">img</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$x1</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$y1</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$x2</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$y2</FONT><FONT color="#007700">);</FONT><FONT color="#0000BB">
</FONT></FONT></CODE></DIV></P>
<P> Since this pattern has to be repeated for every object that has to
be drawn it makes good sense to encapsulate this in a separate class.
This is exactly why the canvas tools file also have a utility class
called <A href="../ref/Shape.html#_C_SHAPE"> Shape</A> This class is
mainly a wrapper around the most commonly used methods in the basic
Image class (with one important exception) and does all these the
translation for you. Please see the class reference for a complete list
of the available methods To set up the Shape class you instantiate it
with the graphic context and the scale you want to use as argument as
in</P>
<P><DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$shape&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
Shape</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">$g</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$scale</FONT><FONT color="#007700">
);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> You are then ready to use all the methods in the shape class. Using
a scale and imitating the previous example we would get the source
shown below.<DIV class="phpscript">(File: canvasex03.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
//&nbsp;$Id:&nbsp;canvasex03.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvtools.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Define&nbsp;work&nbsp;space
<BR></FONT><FONT color="#0000BB">$xmax</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">20</FONT><FONT color="#007700">;
<BR></FONT><FONT color="#0000BB">$ymax</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">20</FONT><FONT color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas&nbsp;we&nbsp;can&nbsp;work&nbsp;
<BR></FONT><FONT color="#0000BB">$g&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
400</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">200</FONT><FONT
color="#007700">,</FONT><FONT color="#DD0000">'auto'</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">11</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">11</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetShadow</FONT><FONT color="#007700">();
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;need&nbsp;to&nbsp;stroke&nbsp;the&nbsp;plotarea&nbsp;and&nbsp;margin&nbsp;before&nbsp;we&nbsp;add&nbsp;the
<BR>//&nbsp;text&nbsp;since&nbsp;we&nbsp;otherwise&nbsp;would&nbsp;overwrite&nbsp;the&nbsp;text.
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Create&nbsp;a&nbsp;new&nbsp;scale
<BR></FONT><FONT color="#0000BB">$scale&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$scale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$xmax</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$ymax</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;The&nbsp;shape&nbsp;class&nbsp;is&nbsp;wrapper&nbsp;around&nbsp;the&nbsp;Imgae&nbsp;class&nbsp;which&nbsp;translates
<BR>//&nbsp;the&nbsp;coordinates&nbsp;for&nbsp;us
<BR></FONT><FONT color="#0000BB">$shape&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Shape</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$g</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$scale</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'black'</FONT><FONT color="#007700">);
<BR>
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;black&nbsp;line
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'black'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Line</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">20</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">20</FONT><FONT color="#007700">);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;and&nbsp;a&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Circle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
5</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">14</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;..&nbsp;and&nbsp;a&nbsp;filled&nbsp;circle&nbsp;(x,y,diameter)
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'red'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">FilledCircle</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
11</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">8</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">FilledRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">15</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
8</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">19</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">14</FONT><FONT color="#007700">
);
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;add&nbsp;a&nbsp;filled&nbsp;rounded&nbsp;rectangle
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'green'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">FilledRoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
3</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">8</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#FF8000">//&nbsp;..&nbsp;with&nbsp;a&nbsp;darker&nbsp;border
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'darkgreen'</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$shape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">RoundedRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
3</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">8</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">6</FONT><FONT color="#007700">
);
<BR>
<BR>
<BR></FONT><FONT color="#FF8000">//&nbsp;Stroke&nbsp;the&nbsp;graph
<BR></FONT><FONT color="#0000BB">$g</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV> The source above gives the following result<DIV class="example">
<BR> <A href="exframes/frame_canvasex03.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/canvasex03.png" WIDTH="400"></A>
<BR><B>Figure 186:</B> Drawing shapes on a canvas using a scale. <A href="exframes/frame_canvasex03.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> If we like to make a smaller image we could just change the image
size and everything will be rescaled without any further code changes.
SO for example making the image half the size would give the result<DIV class="example">
<BR> <A href="exframes/frame_canvasex04.html" target="blank"><IMG border="0"
HEIGHT="100" src="img/canvasex04.png" WIDTH="200"></A>
<BR><B>Figure 187:</B> Shrinking the image to half the size is easy
since the scaling will maintain the relative position of the objects <A href="exframes/frame_canvasex04.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> If we instead wanted to keep the image size but shrink the shapes we
could just make the scale twice as large which would result in<DIV class="example">
<BR> <A href="exframes/frame_canvasex05.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/canvasex05.png" WIDTH="400"></A>
<BR><B>Figure 188:</B> Shrinking hte graphic object by making the scale
twice as large <A href="exframes/frame_canvasex05.html" target="blank">
[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> We previously mentioned that the Shape class was a wrapper around
the image class with one exception. So what is the exception? Well,
glad you asked. The exception is that it contain an additional method
which draws an &quot;indented rectangle&quot;. An indented rectangle is a
rectangle where one of it's four corners have been moved into the
rectangle. You create an indented rectangle by calling either <A href="../ref/Shape.html#_SHAPE_INDENTEDRECTANGLE">
Shape::IndentedRectangle()</A> or A few examples illustrates what this
shape looks like.<DIV class="example">
<BR> <A href="exframes/frame_canvasex06.html" target="blank"><IMG border="0"
HEIGHT="200" src="img/canvasex06.png" WIDTH="400"></A>
<BR><B>Figure 189:</B> Examples of filled indented rectangles <A href="exframes/frame_canvasex06.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> As a final note we mention the class <A href="../ref/CanvasRectangleText.html#_C_CANVASRECTANGLETEXT">
CanvasRectangleText</A> Which can be used to add a text with a rounded
rectangle (possibly filled) onto the canvas. The previous example where
all the available fonts were drawn were using this class. We don't
describe it further but refer the interested reader to the class
reference and the 'listfontsex1.php' example file.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="113Addinglinesandrectanglestoacanvas.html">Previous</A>
<A HREF="115SampleapplicationDrawingDBschema.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,432 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="114Usingacanvasscale.html">
<LINK REL="Next" HREF="12AntiSpamChallenges.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="114Usingacanvasscale.html">Previous</A>
<A HREF="12AntiSpamChallenges.html">Next</A>
<HR NOSHADE>
<H2><A NAME="11_5">11.5 Sample application: Drawing DB schema</A></H2>
<P> As a final example we shortly discuss how the canvas type of graph
was used to generate the DB schema for the DDDA architecture.</P>
<P> The library php file &quot;utils/misc/imgdbschema.php&quot; included in the
distribution contains some utility classes to make the drawing of table
schemes easier. It contains two basic classes, Class ImgDBTable and
Class ImgDBSchema. The first class understand how to draw an image
illustrating a single table. The second class is responsible for
automatically extract all the relevant information from a DB to draw a
complete DB Schema.</P>
<P> Before going into this a little bit more we show what an example of
this might look like.<DIV class="example">
<BR> <A href="exframes/frame_dbschemaex1.html" target="blank"><IMG border="0"
HEIGHT="750" src="img/dbschemaex1.png" WIDTH="600"></A>
<BR><B>Figure 190:</B> Example of using the canvas graph style together
with the imgdbschema.php library to semi-automatically generate a DB
schema <A href="exframes/frame_dbschemaex1.html" target="blank">[src]</A>
&nbsp;
<P></P>
</DIV></P>
<P></P>
<P> Before going on it should be noted that the ImgDBSchema assumes that
the DB can be accessed through a DB abstraction layer modeled after the
abstraction layer available in the 'jpdb.php' file in the DDDA
architecture. This abstraction layer assumes a MySQL database in the
bottom. This specific dependency of this particular abstraction layer
is the reason why these classes is not included in the generic canvas
tools file.</P>
<P> The second thing to note is that this library does not contain a
complete automatic-layout engine but rather a very simple automatic
system which, if nothing else is specified, just puts the table in a
rectangular grid. A complete graph layout engine would simple be to
much to write in this context. This is also a very difficult
optimization problem and sofar not even any of the available research
programs that tries this can achieve a satisfactory layout without
manual intervention.</P>
<P> The critical lines in the code to generate the above graph is<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$tblposadj</FONT><FONT
color="#007700">=array(</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">2</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">4</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,-</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">16</FONT><FONT color="#007700">,-</FONT><FONT color="#0000BB">
1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT
color="#007700">);
<BR></FONT><FONT color="#0000BB">$dbschema&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">ImgDBSchema</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">&quot;jpgraph_doc&quot;</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">&quot;FormatTblName&quot;</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">&quot;FormatFldName&quot;</FONT><FONT color="#007700">
);
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$topm</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetTableWidth</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">);
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
img</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">);</FONT><FONT
color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P></P>
<P> The rest of the code in the file is just to setup the canvas, add an
indented rectangle to group some tables and generate a footer with the
date and time this image was generated.</P>
<P> The first line instantiates a new ImgDBSCheme layout engine asking
it to draw an image for the database 'jpgraph_doc'. The following two
arguments specify two callback functions for formatting the text for
header and each field in a table.</P>
<P> The next line specify the top left margin where the drawing of the
tables should be started.</P>
<P> The third line specify the width of a single table. The final lines
starts the engine and draws all tables in the database to the canvas.
The final argument requires some further explanation. This is an offset
(x,y) from the top left corner how each individual table should be
positioned. If the value is -1 indicates that the default value should
be used. If this array is not specified then the tables will simple
arranged line by line.</P>
<P> The full source code for drawing this DB schema example is shown
below.</P>
<P><DIV class="phpscript">(File: dbschemaex1.php)
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
<BR></FONT><FONT color="#FF8000">
/*=======================================================================
<BR>//&nbsp;File:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBSCHEMAEX1.PHP
<BR>//&nbsp;Description:&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;a&nbsp;DB&nbsp;schema&nbsp;of&nbsp;the&nbsp;DDDA&nbsp;architecture
<BR>//&nbsp;Created:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2002-08-25
<BR>
//&nbsp;Ver:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Id:&nbsp;dbschemaex1.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
<BR>//
<BR>//&nbsp;License:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;code&nbsp;is&nbsp;released&nbsp;under&nbsp;QPL
<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copyright&nbsp;(C)&nbsp;2001,2002&nbsp;Johan&nbsp;Persson
<BR>
//&nbsp;Note:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;actual&nbsp;drawing&nbsp;of&nbsp;the&nbsp;tables&nbsp;are&nbsp;semi-automatically
<BR>
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;but&nbsp;you&nbsp;can&nbsp;easily&nbsp;adjust&nbsp;the&nbsp;individual&nbsp;tables&nbsp;position
<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;the&nbsp;'tblposadj'&nbsp;array.&nbsp;
<BR>//
<BR>
//========================================================================
<BR>*/
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvtools.php&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../imgdbschema.inc&quot;</FONT><FONT
color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpdb.php&quot;</FONT><FONT color="#007700">
;
<BR>
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Global&nbsp;callback&nbsp;to&nbsp;format&nbsp;the&nbsp;table&nbsp;header&nbsp;names
<BR></FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
FormatTblName</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aName</FONT><FONT color="#007700">)&nbsp;{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;We&nbsp;want&nbsp;to&nbsp;replace&nbsp;any&nbsp;specifi&nbsp;references&nbsp;to&nbsp;the
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;'JpGraph'&nbsp;project&nbsp;with&nbsp;the&nbsp;generic&nbsp;'&lt;project&gt;'
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#007700">return&nbsp;</FONT><FONT color="#0000BB">
str_replace</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'JpGraph'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
'&lt;project&gt;'</FONT><FONT color="#007700">,&nbsp;</FONT><FONT color="#0000BB">
$aName</FONT><FONT color="#007700">);
<BR>}
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;Global&nbsp;callback&nbsp;to&nbsp;format&nbsp;each&nbsp;field&nbsp;name&nbsp;in&nbsp;the&nbsp;table
<BR></FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
FormatFldName</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$aName</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$aTable</FONT><FONT
color="#007700">)&nbsp;{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</FONT><FONT color="#0000BB">$aName</FONT><FONT color="#007700">
;
<BR>}
<BR>
<BR>
<BR>class&nbsp;</FONT><FONT color="#0000BB">Driver&nbsp;</FONT><FONT color="#007700">
{
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$ig</FONT><FONT color="#007700">
,&nbsp;</FONT><FONT color="#0000BB">$img</FONT><FONT color="#007700">,&nbsp;</FONT><FONT
color="#0000BB">$iscale</FONT><FONT color="#007700">,&nbsp;</FONT><FONT color="#0000BB">
$ishape</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$iymax</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$ixmax</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$iwidth</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$iheight</FONT><FONT color="#007700">;
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</FONT><FONT color="#0000BB">Driver</FONT><FONT color="#007700">
()&nbsp;{
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Define&nbsp;Image&nbsp;size&nbsp;and&nbsp;coordinate&nbsp;grid&nbsp;space&nbsp;to&nbsp;work&nbsp;within
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iwidth&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">600</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iheight</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">750</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iymax&nbsp;&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">50</FONT><FONT color="#007700">;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ixmax&nbsp;&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">55</FONT><FONT color="#007700">;
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">iwidth</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iheight</FONT><FONT color="#007700">,</FONT><FONT
color="#DD0000">'auto'</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">img&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
ig</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">;
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Define&nbsp;the&nbsp;scale&nbsp;to&nbsp;be&nbsp;used
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">ig</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">ixmax</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
iymax</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ishape&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Shape</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
ig</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;A&nbsp;small&nbsp;frame&nbsp;around&nbsp;the&nbsp;canvas
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;teal&quot;</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</FONT><FONT color="#0000BB">Run</FONT><FONT color="#007700">
()&nbsp;{
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$leftm</FONT><FONT color="#007700">
=</FONT><FONT color="#0000BB">1.5</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#FF8000">//&nbsp;Left&nbsp;margin&nbsp;(for&nbsp;table&nbsp;schemes)&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$topm</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">5</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Top&nbsp;margin&nbsp;(for&nbsp;table&nbsp;schemes)&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">
=</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
color="#FF8000">//&nbsp;Individual&nbsp;table&nbsp;width
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">=</FONT><FONT
color="#0000BB">1</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Offset&nbsp;for&nbsp;top&nbsp;line
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Add&nbsp;the&nbsp;background&nbsp;color&nbsp;for&nbsp;the&nbsp;project&nbsp;specific&nbsp;tables
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ishape</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">IndentedRectangle</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$topm</FONT><FONT color="#007700">-</FONT><FONT color="#0000BB">1</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">
*</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT
color="#0000BB">$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
6</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">45</FONT><FONT
color="#007700">,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">
+</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">CORNER_BOTTOMLEFT</FONT><FONT
color="#007700">,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#DD0000">'lightblue'</FONT><FONT
color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;Stroke&nbsp;the&nbsp;tables&nbsp;(series&nbsp;of&nbsp;x,y&nbsp;offsets,&nbsp;If&nbsp;=-1&nbsp;then&nbsp;use&nbsp;the
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;automtic&nbsp;positioning
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">
=array(</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">$tlo</FONT><FONT
color="#007700">+</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT color="#0000BB">
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">$tlo</FONT><FONT
color="#007700">+</FONT><FONT color="#0000BB">4</FONT><FONT color="#007700">
,
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
,-</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">16</FONT><FONT color="#007700">,-</FONT><FONT color="#0000BB">
1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">ImgDBSchema</FONT><FONT color="#007700">
(</FONT><FONT color="#DD0000">'jpgraph_doc'</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">'FormatTblName'</FONT><FONT color="#007700">
,</FONT><FONT color="#DD0000">'FormatFldName'</FONT><FONT color="#007700">
);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$topm</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">SetTableWidth</FONT><FONT color="#007700">
(</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
img</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasRectangleText</FONT><FONT color="#007700">
();
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
''</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
''</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFontColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'navy'</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;explanation
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">12</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'Project&nbsp;specific&nbsp;tables'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
$leftm</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">3</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT color="#007700">
,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;title
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
''</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_VERDANA</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">26</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'DDDA&nbsp;-&nbsp;DB&nbsp;Schema'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
9</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0.5</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT color="#007700">
);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;version&nbsp;and&nbsp;date
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'yellow'</FONT><FONT color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
FF_FONT1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT
color="#007700">);
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
&quot;Generated:&nbsp;&quot;</FONT><FONT color="#007700">.</FONT><FONT color="#0000BB">
date</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">&quot;ymd&nbsp;H:i&quot;</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">time</FONT><FONT color="#007700">
()),</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
iymax</FONT><FONT color="#007700">*</FONT><FONT color="#0000BB">0.96</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">
);&nbsp;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
<BR>
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">();
<BR>&nbsp;&nbsp;&nbsp;&nbsp;}
<BR>}
<BR>
<BR></FONT><FONT color="#0000BB">$driver&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Driver</FONT><FONT color="#007700">
();
<BR></FONT><FONT color="#0000BB">$driver</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Run</FONT><FONT color="#007700">();
<BR>
<BR></FONT><FONT color="#0000BB">?&gt;
<BR></FONT>
<BR></FONT></CODE></DIV></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="114Usingacanvasscale.html">Previous</A>
<A HREF="12AntiSpamChallenges.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="105SampleapplicationDrawingDBschema.html">
<LINK REL="Next" HREF="111GeneratingAntiSpamchallenge.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="105SampleapplicationDrawingDBschema.html">Previous</A>
<A HREF="111GeneratingAntiSpamchallenge.html">Next</A>
<HR NOSHADE>
<H1><A NAME="11">11 Anti-Spam Challenges</A></H1>
<P> JpGraph includes a module to easily generate Anti-Spam challenges.
With this we mean an image consisting of numbers and letters which are
very hard to read for an OCR program. This is often used to secure sign
up for bulletin boards, on-line mail system or mailing lists since this
very effectively prevent automatic sign up by robots (spam-bots).</P>
<P> The module in JpGraph responsible for this is<I>
jpgraph_antispam.php</I> and behaves as a simplified plot module.</P>
<P> The example below illustrates how such an image can look like<DIV class="example">
<BR> <A href="exframes/frame_antispamex01.html" target="blank"><IMG border="0"
HEIGHT="34" src="img/img/img/img/img/img/antispamex01.png" WIDTH="101"></A>
<BR><B>Figure 195:</B> Simple illustration of spam challenge image <A href="exframes/frame_antispamex01.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P>Anti spam images have less functionality then the usual images
generated with JpGraph in order to keep this utility reasonable small.
The primary limitation is that there are now additional formatting
options for the images and the image generated will always use the<I>
JPEG</I> image format. Hence it is not possible to change this to use,
for example, PNG.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="105SampleapplicationDrawingDBschema.html">Previous</A>
<A HREF="111GeneratingAntiSpamchallenge.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,42 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1Aboutthismanual.html">
<LINK REL="Next" HREF="12Howwasthismanualproduced.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1Aboutthismanual.html">Previous</A>
<A HREF="12Howwasthismanualproduced.html">Next</A>
<HR NOSHADE>
<H2><A NAME="1_1">1.1 Version history</A></H2>
<P></P>
<P></P>
<TABLE border="1" cellpadding="2">
<TR><TH>Version</TH><TH>Date</TH><TH>Status</TH><TH>Who</TH><TH>Comment</TH>
</TR>
<TR><TD>R1.9</TD><TD>2007-03-18</TD><TD>Released</TD><TD>Johan Persson</TD><TD>
Additional info for JpGraph 1.21</TD></TR>
</TABLE>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1Aboutthismanual.html">Previous</A>
<A HREF="12Howwasthismanualproduced.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1023Addingiconsontothegraph.html">
<LINK REL="Next" HREF="111Introduction.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1023Addingiconsontothegraph.html">Previous</A>
<A HREF="111Introduction.html">Next</A>
<HR NOSHADE>
<H1><A NAME="11">11 Working with canvas graphs</A></H1>
<P> Canvas graphing is an advanced feature that comes in handy where you
need to draw some more arbitrary graphics. To give you a flavor of what
you can do the following example shows an architecture overview of
JpGraph which was drawn using a canvas.<DIV class="example">
<BR> <A href="exframes/frame_canvas_jpgarchex.html" target="blank"><IMG border="0"
HEIGHT="650" src="img/canvas_jpgarchex.png" WIDTH="700"></A>
<BR><B>Figure 182:</B> Example of what you can draw on a canvas <A href="exframes/frame_canvas_jpgarchex.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P> Working with canvas requires more understanding of JpGraph as well
as more programming and fine tuning.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1023Addingiconsontothegraph.html">Previous</A>
<A HREF="111Introduction.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="12AntiSpamChallenges.html">
<LINK REL="Next" HREF="13GeneratingLEDlikedigitswithJpGraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="12AntiSpamChallenges.html">Previous</A>
<A HREF="13GeneratingLEDlikedigitswithJpGraph.html">Next</A>
<HR NOSHADE>
<H2><A NAME="12_1">12.1 Generating Anti-Spam challenge</A></H2>
<P> There are two basic alternatives on how to generate the content of
the anti-spam image</P>
<OL>
<LI> Submit a string that should be used</LI>
<LI> Automatically generate a random string. If this alternative is
chosen then the user of the library should save the created string and
compare it to what the user enters.</LI>
</OL>
<P> In order to write a script to generate a new challenge there are
four steps to be completed.</P>
<P><B> First</B> include the library file<I> jpgraph_antispam.php</I>.
Note that there is no need to include the &quot;jpgraph.php&quot; library since
all functionality is included in this library file.<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;</FONT><FONT color="#007700">
require_once&nbsp;</FONT><FONT color="#DD0000">&quot;jpgraph_antispam.php&quot;</FONT><FONT
color="#007700">;</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P><B> Secondly</B> a new instance of the class<I> AntiSpam</I> must be
created<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;$spam&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">
AntiSpam</FONT><FONT color="#007700">();</FONT><FONT color="#0000BB"></FONT>
</FONT></CODE></DIV></P>
<P><B> Thirdly</B> the string to be used in the challenge must be
specified. To automatically generate a suitable string use<DIV class="phpscript">
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;</FONT><FONT color="#FF8000">
//&nbsp;The&nbsp;argument&nbsp;determines&nbsp;the&nbsp;length&nbsp;of&nbsp;the&nbsp;generated&nbsp;string
<BR></FONT><FONT color="#0000BB">$chars&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
color="#0000BB">$spam</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Rand</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">5</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P> If instead the string to be used should be specified this string
should be specified in the initial creation of the AntiSpam() or by
calling the<I> Set()</I> method as in<DIV class="phpscript"><CODE><FONT color="#000000">
<FONT color="#0000BB">&nbsp;$spam</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">&quot;aui8k&quot;</FONT><FONT
color="#007700">);</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV>
</P>
<P>Please note that in order to minimize the risk for confusion the
letters 'O' and the number '0' (zero) is not allowed since they are too
alike and can be mistaken for each other.</P>
<P><B> The final and fourth step</B> is to output the image with a call
the method<I> Stroke()</I> on the created instance of the<I> AntiSpam</I>
class.<DIV class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">
&nbsp;</FONT><FONT color="#007700">if(&nbsp;</FONT><FONT color="#0000BB">$spam</FONT><FONT
color="#007700">-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">
()&nbsp;===&nbsp;</FONT><FONT color="#0000BB">false&nbsp;</FONT><FONT color="#007700">
)&nbsp;{
<BR>&nbsp;&nbsp;&nbsp;&nbsp;die(</FONT><FONT color="#DD0000">&quot;Illegal&nbsp;or&nbsp;no&nbsp;data&nbsp;to&nbsp;plot&quot;</FONT><FONT
color="#007700">);
<BR>}</FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P>Note that we have put a guard around the output since in the case of
an error this method will result a boolean false value. As with the
other graph types it is possible to write the generated image to a file
by submitting a file name as an argument to<I> Stroke()</I>.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="12AntiSpamChallenges.html">Previous</A>
<A HREF="13GeneratingLEDlikedigitswithJpGraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="122GeneratingLEDlikedigitswithJpGraph.html">
<LINK REL="Next" HREF="13CodedefinesinJpGraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="122GeneratingLEDlikedigitswithJpGraph.html">Previous</A>
<A HREF="13CodedefinesinJpGraph.html">Next</A>
<HR NOSHADE>
<H3><A NAME="12_2_1">12.2.1 Adjusting the size of the LED digits</A></H3>
There are two parameters that can be used to alter the size of the LED
digits.
<UL>
<LI> The size (in pixels) of each &quot;led diode&quot;</LI>
<LI> The distance, specified as fractions of the &quot;led diode&quot; size
between each &quot;led diode&quot;</LI>
</UL>
These two parameters are given in the constructor which has the
signature <TT>DigitalLED74::DigitalLED74($aRadius=2,$aMargin=0.6)</TT>
as can be seen from the above signature the default size is 2 pixels in
size and a fraction of 0.6 as the distance.<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="122GeneratingLEDlikedigitswithJpGraph.html">Previous</A>
<A HREF="13CodedefinesinJpGraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,76 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="121GeneratingAntiSpamchallenge.html">
<LINK REL="Next" HREF="1221AdjustingthesizeoftheLEDdigits.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="121GeneratingAntiSpamchallenge.html">Previous</A>
<A HREF="1221AdjustingthesizeoftheLEDdigits.html">Next</A>
<HR NOSHADE>
<H2><A NAME="12_2">12.2 Generating LED-like digits with JpGraph</A></H2>
Starting with v1.21 it is possible to generate LED like digits with
JpGraph. This is accomplished by the usage of the &quot;jpgraph_led.php&quot;
module.
<P> The creation of LED digits and letters are extremely simple. The
following complete example demonstrates the creation of a LED display<DIV
class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;
<BR>
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_led.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;By&nbsp;default&nbsp;each&nbsp;&quot;LED&quot;&nbsp;circle&nbsp;has&nbsp;a&nbsp;radius&nbsp;of&nbsp;3&nbsp;pixels
<BR></FONT><FONT color="#0000BB">$led&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">DigitalLED74</FONT><FONT color="#007700">
();
<BR></FONT><FONT color="#0000BB">$led</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'0123456789.&nbsp;ABCDEFGHIJKL'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
LEDC_GREEN</FONT><FONT color="#007700">);&nbsp;
<BR></FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> The result of running this script can be seen by running the
&quot;Examples/ledex1.php&quot; Example in the example directory. As can be seen
from the above example the color to be used for the LED digits is
specified as the second argument to the DigitalLED74::Stroke() method.
Available color for LED digits is given by the table below</P>
<TABLE>
<TR><TD>Symbolic name</TD><TD>Color</TD></TR>
<TR><TD>LEDC_RED</TD><TD>Red</TD></TR>
<TR><TD>LEDC_GREEN</TD><TD>Green</TD></TR>
<TR><TD>LEDC_BLUE</TD><TD>Blue</TD></TR>
<TR><TD>LEDC_YELLOW</TD><TD>Yellow</TD></TR>
<TR><TD>GREY</TD><TD>Grey</TD></TR>
</TABLE>
Since the standard LED matrix of 7x4 dots does not lend itself to
accurately represent all normal ASCII characters only the following
numbers and letters can be displayed.
<TABLE>
<TR><TD>All digits, 0-9</TD></TR>
<TR><TD>Capital Letters, A-L</TD></TR>
</TABLE>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="121GeneratingAntiSpamchallenge.html">Previous</A>
<A HREF="1221AdjustingthesizeoftheLEDdigits.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,54 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="115SampleapplicationDrawingDBschema.html">
<LINK REL="Next" HREF="121GeneratingAntiSpamchallenge.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="115SampleapplicationDrawingDBschema.html">Previous</A>
<A HREF="121GeneratingAntiSpamchallenge.html">Next</A>
<HR NOSHADE>
<H1><A NAME="12">12 Anti-Spam Challenges</A></H1>
<P> JpGraph includes a module to easily generate Anti-Spam challenges.
With this we mean an image consisting of numbers and letters which are
very hard to read for an OCR program. This is often used to secure sign
up for bulletin boards, on-line mail system or mailing lists since this
very effectively prevent automatic sign up by robots (spam-bots).</P>
<P> The module in JpGraph responsible for this is<I>
jpgraph_antispam.php</I> and behaves as a simplified plot module.</P>
<P> The example below illustrates how such an image can look like<DIV class="example">
<BR> <A href="exframes/frame_antispamex01.html" target="blank"><IMG border="0"
HEIGHT="34" src="img/antispamex01.png" WIDTH="101"></A>
<BR><B>Figure 191:</B> Simple illustration of spam challenge image <A href="exframes/frame_antispamex01.html"
target="blank">[src]</A>&nbsp;
<P></P>
</DIV></P>
<P>Anti spam images have less functionality then the usual images
generated with JpGraph in order to keep this utility reasonable small.
The primary limitation is that there are now additional formatting
options for the images and the image generated will always use the<I>
JPEG</I> image format. Hence it is not possible to change this to use,
for example, PNG.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="115SampleapplicationDrawingDBschema.html">Previous</A>
<A HREF="121GeneratingAntiSpamchallenge.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,174 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="111GeneratingAntiSpamchallenge.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="111GeneratingAntiSpamchallenge.html">Previous</A>
<HR NOSHADE>
<H1><A NAME="12">12 Code defines in JpGraph</A></H1>
<P> Various settings in JpGraph are controlled by overall DEFINEs in the
configuration file &quot;jpg-config.inc&quot;. Most of these defines have default
values that should be valid for most usage.</P>
<P> In the rest of this chapter all constants are described with default
value and usage.</P>
<P></P>
<TABLE cellpadding="3" cellspacing="0" class="codedefines">
<TR><TH>Define, default value</TH><TH>Comment</TH></TR>
<TR><TD valign="top">&quot;CACHE_DIR&quot;, &quot;/tmp/jpgraph_cache/&quot;</TD><TD>The full
absolute name of directory to be used as a cache. This directory<STRONG>
must</STRONG> be readable and writable for PHP. Must end with '/'</TD></TR>
<TR><TD valign="top">&quot;TTF_DIR&quot;, &quot;/usr/local/fonts/ttf/&quot;</TD><TD>
Directory for JpGraph TTF fonts. Must end with '/' The fonts must follow
the naming conventions as used by the supplied TTF fonts in JpGraph.</TD>
</TR>
<TR><TD valign="top">&quot;CSIMCACHE_DIR&quot;, &quot;csimcache/&quot;</TD><TD>Directory for
cache directory for CSIM graphs. Must end with '/' Cache directory
specification for use with CSIM graphs that are using the cache. The
directory must be the filesystem name as seen by PHP and the 'http'
version must be the same directory but as seen by the HTTP server
relative to the 'htdocs' directory. If a relative path is specified it
is taken to be relative from where the image script is executed. Note:
The default setting is to create a subdirectory in the directory from
where the image script is executed and store all files there. As usual
this directory must be writable by the PHP process.</TD></TR>
<TR><TD valign="top">&quot;CSIMCACHE_HTTP_DIR&quot;, &quot;csimcache&quot;</TD><TD>Directory
for JpGraph TTF fonts. Must end with '/' Cache directory specification
for use with CSIM graphs that are using the cache. The directory must
be the filesystem name as seen by PHP and the 'http' version must be
the same directory but as seen by the HTTP server relative to the
'htdocs' directory. If a relative path is specified it is taken to be
relative from where the image script is executed. Note: The default
setting is to create a subdirectory in the directory from where the
image script is executed and store all files there. As usual this
directory must be writable by the PHP process.</TD></TR>
<TR><TD valign="top">&quot;CHINESE_TTF_FONT&quot;, &quot;bkai00mp.ttf&quot;</TD><TD> Actual
name of the TTF file used together with FF_CHINESE aka FF_BIG5 This is
the TTF file being used when the font family is specified as either
FF_CHINESE or FF_BIG5</TD></TR>
<TR><TD valign="top">&quot;LANGUAGE_CYRILLIC&quot;, false</TD><TD> Special unicode
Cyrillic language support.</TD></TR>
<TR><TD valign="top">&quot;CYRILLIC_FROM_WINDOWS&quot;, false</TD><TD> If you are
setting this config to true the conversion will assume that the input
text is windows 1251, if false it will assume koi8-r</TD></TR>
<TR><TD valign="top">'MINCHO_TTF_FONT', 'ipam.ttf'</TD><TD> Japanese
TrueType font used with FF_MINCHO</TD></TR>
<TR><TD valign="top">'PMINCHO_TTF_FONT', 'ipamp.ttf'</TD><TD> Japanese
TrueType font used with FF_PMINCHO</TD></TR>
<TR><TD valign="top">'GOTHIC_TTF_FONT', 'ipag.ttf'</TD><TD> Japanese
TrueType font used with FF_GOTHIC</TD></TR>
<TR><TD valign="top">'PGOTHIC_TTF_FONT', 'ipagp.ttf'</TD><TD> Japanese
TrueType font used with FF_PGOTHIC</TD></TR>
<TR><TD valign="top">&quot;INSTALL_PHP_ERR_HANDLER&quot;, false</TD><TD> Determine
if the library should also setup the default PHP error handler to
generate a graphic error message. This is useful during development to
be able to see the error message as an image instead as a &quot;red-cross&quot;
in a page where an image is expected.</TD></TR>
<TR><TD valign="top">&quot;CATCH_PHPERRMSG&quot;, true</TD><TD> Should the library
examine the global php_errmsg string and convert any error in it to a
graphical representation. This is handy for the occasions when, for
example, header files cannot be found and this results in the graph not
being created and just a &quot;red-cross&quot; image would be seen. This should
be turned off for a production site.</TD></TR>
<TR><TD valign="top">&quot;USE_LIBRARY_GD2&quot;,false</TD><TD>Specify if we
should use GD 2.x or GD 1.x If you have GD 2.x installed it is
recommended that you use it since it will give a slightly, slightly
better visual appearance for arcs. If you don't have GD2 installed this
must be set to false!</TD></TR>
<TR><TD valign="top">'USE_TRUECOLOR',true</TD><TD>Should the image be a
truecolor image? Note 1: Can only be used with GD 2.0.2 and above. Note
2: GD 2.0.1 + PHP 4.0.6 on Win32 crashes when trying to use truecolor.
Truecolor support is to be considered alpha since GD 2.x is still not
considered stable (especially on Win32). Note 3: MUST be enabled to get
background images working with GD2 Note 4: If enabled then truetype
fonts will look very ugly =&gt; You can't have both background images and
truetype fonts in the same image until these bugs has been fixed in GD
2.01</TD></TR>
<TR><TD valign="top">&quot;USE_CACHE&quot;,false</TD><TD>Should the cache be used
at all? By setting this to false no files will be generated in the
cache directory. The difference from READ_CACHE being that setting
READ_CACHE to false will still create the image in the cache directory
just not use it. By setting USE_CACHE=false no files will even be
generated in the cache directory.</TD></TR>
<TR><TD valign="top">&quot;READ_CACHE&quot;,true</TD><TD>Should we try to find an
image in the cache before generating it? Set this define to false to
bypass the reading of the cache and always regenerate the image. Note
that even if reading the cache is disabled the cached will still be
updated with the newly generated image. Set also &quot;USE_CACHE&quot; below.</TD>
</TR>
<TR><TD valign="top">&quot;DEFAULT_GFORMAT&quot;,&quot;auto&quot;</TD><TD>Default graphic
format set to &quot;auto&quot; which will automatically choose the best available
format in the order png,gif,jpg (The supported format depends on what
your PHP installation supports)</TD></TR>
<TR><TD valign="top">&quot;USE_IMAGE_ERROR_HANDLER&quot;,true</TD><TD> Determine
if the error handler should be image based or purely text based. Image
based makes it easier since the script will always return an image even
in case of errors.</TD></TR>
<TR><TD valign="top">&quot;USE_APPROX_COLORS&quot;,true</TD><TD>If the color
palette is full should JpGraph try to allocate the closest match? If
you plan on using background image or gradient fills it might be a good
idea to enable this. If not you will otherwise get an error saying that
the color palette is exhausted. The drawback of using approximations is
that the colors might not be exactly what you specified. Note1: This
does only apply to a palette image, not true color images since they
don't have the limitations of maximum number of colors.</TD></TR>
<TR><TD valign="top">&quot;ERR_DEPRECATED&quot;,false</TD><TD>Should usage of
deprecated functions and parameters give a fatal error? (Useful to
check if code is future proof.)</TD></TR>
<TR><TD valign="top">&quot;BRAND_TIMING&quot;,false</TD><TD>Should the time taken
to generate each picture be branded to the lower left in corner in each
generated image? Useful for performance measurements generating graphs</TD>
</TR>
<TR><TD valign="top">&quot;BRAND_TIME_FORMAT&quot;,&quot;Generated in: %01.3fs&quot;</TD><TD>
What format should be used for the timing string?</TD></TR>
</TABLE>
<P> The following defines should very rarely need to be changed</P>
<P></P>
<TABLE cellpadding="3" cellspacing="0" class="codedefines">
<TR><TH>Define, default value</TH><TH>Comment</TH></TR>
<TR><TD valign="top">&quot;CACHE_FILE_GROUP&quot;,&quot;wwwadmin&quot;</TD><TD>What group
should the cached file belong to (Set to &quot;&quot; will give the default group
for the &quot;PHP-user&quot;) Please note that the Apache user must be a member
of the specified group since otherwise it is impossible for Apache to
set the specified group.</TD></TR>
<TR><TD valign="top">&quot;CACHE_FILE_MOD&quot;,0664</TD><TD>What permissions
should the cached file have (Set to &quot;&quot; will give the default
permissions for the &quot;PHP-user&quot;)</TD></TR>
<TR><TD valign="top">&quot;USE_BRESENHAM&quot;,false</TD><TD>Decide if we should
use the Bresenham circle algorithm or the built in Arc(). Bresenham
gives better visual appearance of circles but is more CPU intensive and
slower then the built in Arc() function in GD. Turned off by default
for speed</TD></TR>
<TR><TD valign="top">&quot;_CSIM_SPECIALFILE&quot;,&quot;_csim_special_&quot;</TD><TD>
Special file name to indicate that we only want to calc the image map in
the call to Graph::Stroke() used internally from the GetHTMLCSIM()
method.</TD></TR>
<TR><TD valign="top">&quot;_CSIM_DISPLAY&quot;,&quot;_jpg_csimd&quot;</TD><TD>HTTP GET
argument that is used with image map to indicate to the script to just
generate the image and not the full CSIM HTML page.</TD></TR>
</TABLE>
&nbsp;
<P>&nbsp;</P>
<P>&amp;nbsp</P>
</DIV><HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="111GeneratingAntiSpamchallenge.html">Previous</A>
</BODY>
</HTML>

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="11Versionhistory.html">
<LINK REL="Next" HREF="2Introduction.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="11Versionhistory.html">Previous</A>
<A HREF="2Introduction.html">Next</A>
<HR NOSHADE>
<H2><A NAME="1_2">1.2 How was this manual produced?</A></H2>
<P> The bulk of the text was written directly in Emacs on a GNU/Linux
system in a mixture of PHP and HTML. A number of PHP functions were
used to automate the handling of formatting example code and figures.</P>
<P> To generate the images automatically in the img directory a custom
awk-script is used to extract all the used image script from the
manual. The script then uses the client version of PHP generate the
images from the scripts and stores them in the 'img' directory.</P>
<P> The final set of HTML files was then processes by HTMLDOC to
construct table of contents and chapter links.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="11Versionhistory.html">Previous</A>
<A HREF="2Introduction.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,44 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="13GeneratingLEDlikedigitswithJpGraph.html">
<LINK REL="Next" HREF="132ImprovingtheLEDswithsupersampling.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="13GeneratingLEDlikedigitswithJpGraph.html">Previous</A>
<A HREF="132ImprovingtheLEDswithsupersampling.html">Next</A>
<HR NOSHADE>
<H2><A NAME="13_1">13.1 Adjusting the size of the LED digits</A></H2>
There are two parameters that can be used to alter the size of the LED
digits.
<UL>
<LI> The size (in pixels) of each &quot;led diode&quot;</LI>
<LI> The distance, specified as fractions of the &quot;led diode&quot; size
between each &quot;led diode&quot;</LI>
</UL>
These two parameters are given in the constructor which has the
signature <TT>DigitalLED74::DigitalLED74($aRadius=2,$aMargin=0.6)</TT>
as can be seen from the above signature the default size is 2 pixels in
size and a fraction of 0.6 as the distance.<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="13GeneratingLEDlikedigitswithJpGraph.html">Previous</A>
<A HREF="132ImprovingtheLEDswithsupersampling.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="131AdjustingthesizeoftheLEDdigits.html">
<LINK REL="Next" HREF="14CodedefinesinJpGraph.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="131AdjustingthesizeoftheLEDdigits.html">Previous</A>
<A HREF="14CodedefinesinJpGraph.html">Next</A>
<HR NOSHADE>
<H2><A NAME="13_2">13.2 Improving the LEDs with supersampling</A></H2>
In order to improve the visual appearance the library uses
super-sampling in order to create an anti-aliased image of the LED
digits. The default level of super-sampling is 3 times (oversampling).
In order reduce the CPU load the amount of oversampling can be lowered.
The level of super-sampling is controlled via the method <TT>
DigitalLed74::SetSupersampling::($aSuperSampling=3)</TT>
<P> For example setting the oversampling to &quot;1&quot; is the same thing as
disabling super-sampling. This will generate a fast image but a LED
appearance that looks quite &quot;rugged&quot;.</P>
<P> Increasing the level of oversampling above &quot;4&quot; gives almost no
visual improvement to the resulting image, it will only increase the
CPU time needed to create the final image. Hence it is recommended that
the super-sampling is only specified as an integer in the range one to
four.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="131AdjustingthesizeoftheLEDdigits.html">Previous</A>
<A HREF="14CodedefinesinJpGraph.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,175 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="1221AdjustingthesizeoftheLEDdigits.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="1221AdjustingthesizeoftheLEDdigits.html">Previous</A>
<HR NOSHADE>
<H1><A NAME="13">13 Code defines in JpGraph</A></H1>
<P> Various settings in JpGraph are controlled by overall DEFINEs in the
configuration file &quot;jpg-config.inc.php&quot;. Most of these defines have
default values that should be valid for most usage.</P>
<P> In the rest of this chapter all constants are described with default
value and usage.</P>
<P></P>
<TABLE cellpadding="3" cellspacing="0" class="codedefines">
<TR><TH>Define, default value</TH><TH>Comment</TH></TR>
<TR><TD valign="top">&quot;CACHE_DIR&quot;, &quot;/tmp/jpgraph_cache/&quot;</TD><TD>The full
absolute name of directory to be used as a cache. This directory<STRONG>
must</STRONG> be readable and writable for PHP. Must end with '/'</TD></TR>
<TR><TD valign="top">&quot;TTF_DIR&quot;, &quot;/usr/local/fonts/ttf/&quot;</TD><TD>
Directory for JpGraph TTF fonts. Must end with '/' The fonts must follow
the naming conventions as used by the supplied TTF fonts in JpGraph.</TD>
</TR>
<TR><TD valign="top">&quot;CSIMCACHE_DIR&quot;, &quot;csimcache/&quot;</TD><TD>Directory for
cache directory for CSIM graphs. Must end with '/' Cache directory
specification for use with CSIM graphs that are using the cache. The
directory must be the filesystem name as seen by PHP and the 'http'
version must be the same directory but as seen by the HTTP server
relative to the 'htdocs' directory. If a relative path is specified it
is taken to be relative from where the image script is executed. Note:
The default setting is to create a subdirectory in the directory from
where the image script is executed and store all files there. As usual
this directory must be writable by the PHP process.</TD></TR>
<TR><TD valign="top">&quot;CSIMCACHE_HTTP_DIR&quot;, &quot;csimcache&quot;</TD><TD>Directory
for JpGraph TTF fonts. Must end with '/' Cache directory specification
for use with CSIM graphs that are using the cache. The directory must
be the filesystem name as seen by PHP and the 'http' version must be
the same directory but as seen by the HTTP server relative to the
'htdocs' directory. If a relative path is specified it is taken to be
relative from where the image script is executed. Note: The default
setting is to create a subdirectory in the directory from where the
image script is executed and store all files there. As usual this
directory must be writable by the PHP process.</TD></TR>
<TR><TD valign="top">&quot;CHINESE_TTF_FONT&quot;, &quot;bkai00mp.ttf&quot;</TD><TD> Actual
name of the TTF file used together with FF_CHINESE aka FF_BIG5 This is
the TTF file being used when the font family is specified as either
FF_CHINESE or FF_BIG5</TD></TR>
<TR><TD valign="top">&quot;LANGUAGE_CYRILLIC&quot;, false</TD><TD> Special unicode
Cyrillic language support.</TD></TR>
<TR><TD valign="top">&quot;CYRILLIC_FROM_WINDOWS&quot;, false</TD><TD> If you are
setting this config to true the conversion will assume that the input
text is windows 1251, if false it will assume koi8-r</TD></TR>
<TR><TD valign="top">'MINCHO_TTF_FONT', 'ipam.ttf'</TD><TD> Japanese
TrueType font used with FF_MINCHO</TD></TR>
<TR><TD valign="top">'PMINCHO_TTF_FONT', 'ipamp.ttf'</TD><TD> Japanese
TrueType font used with FF_PMINCHO</TD></TR>
<TR><TD valign="top">'GOTHIC_TTF_FONT', 'ipag.ttf'</TD><TD> Japanese
TrueType font used with FF_GOTHIC</TD></TR>
<TR><TD valign="top">'PGOTHIC_TTF_FONT', 'ipagp.ttf'</TD><TD> Japanese
TrueType font used with FF_PGOTHIC</TD></TR>
<TR><TD valign="top">&quot;INSTALL_PHP_ERR_HANDLER&quot;, false</TD><TD> Determine
if the library should also setup the default PHP error handler to
generate a graphic error message. This is useful during development to
be able to see the error message as an image instead as a &quot;red-cross&quot;
in a page where an image is expected.</TD></TR>
<TR><TD valign="top">&quot;CATCH_PHPERRMSG&quot;, true</TD><TD> Should the library
examine the global php_errmsg string and convert any error in it to a
graphical representation. This is handy for the occasions when, for
example, header files cannot be found and this results in the graph not
being created and just a &quot;red-cross&quot; image would be seen. This should
be turned off for a production site.</TD></TR>
<TR><TD valign="top">&quot;USE_LIBRARY_GD2&quot;,false</TD><TD>Specify if we
should use GD 2.x or GD 1.x If you have GD 2.x installed it is
recommended that you use it since it will give a slightly, slightly
better visual appearance for arcs. If you don't have GD2 installed this
must be set to false!</TD></TR>
<TR><TD valign="top">'USE_TRUECOLOR',true</TD><TD>Should the image be a
truecolor image? Note 1: Can only be used with GD 2.0.2 and above. Note
2: GD 2.0.1 + PHP 4.0.6 on Win32 crashes when trying to use truecolor.
Truecolor support is to be considered alpha since GD 2.x is still not
considered stable (especially on Win32). Note 3: MUST be enabled to get
background images working with GD2 Note 4: If enabled then truetype
fonts will look very ugly =&gt; You can't have both background images and
truetype fonts in the same image until these bugs has been fixed in GD
2.01</TD></TR>
<TR><TD valign="top">&quot;USE_CACHE&quot;,false</TD><TD>Should the cache be used
at all? By setting this to false no files will be generated in the
cache directory. The difference from READ_CACHE being that setting
READ_CACHE to false will still create the image in the cache directory
just not use it. By setting USE_CACHE=false no files will even be
generated in the cache directory.</TD></TR>
<TR><TD valign="top">&quot;READ_CACHE&quot;,true</TD><TD>Should we try to find an
image in the cache before generating it? Set this define to false to
bypass the reading of the cache and always regenerate the image. Note
that even if reading the cache is disabled the cached will still be
updated with the newly generated image. Set also &quot;USE_CACHE&quot; below.</TD>
</TR>
<TR><TD valign="top">&quot;DEFAULT_GFORMAT&quot;,&quot;auto&quot;</TD><TD>Default graphic
format set to &quot;auto&quot; which will automatically choose the best available
format in the order png,gif,jpg (The supported format depends on what
your PHP installation supports)</TD></TR>
<TR><TD valign="top">&quot;USE_IMAGE_ERROR_HANDLER&quot;,true</TD><TD> Determine
if the error handler should be image based or purely text based. Image
based makes it easier since the script will always return an image even
in case of errors.</TD></TR>
<TR><TD valign="top">&quot;USE_APPROX_COLORS&quot;,true</TD><TD>If the color
palette is full should JpGraph try to allocate the closest match? If
you plan on using background image or gradient fills it might be a good
idea to enable this. If not you will otherwise get an error saying that
the color palette is exhausted. The drawback of using approximations is
that the colors might not be exactly what you specified. Note1: This
does only apply to a palette image, not true color images since they
don't have the limitations of maximum number of colors.</TD></TR>
<TR><TD valign="top">&quot;ERR_DEPRECATED&quot;,false</TD><TD>Should usage of
deprecated functions and parameters give a fatal error? (Useful to
check if code is future proof.)</TD></TR>
<TR><TD valign="top">&quot;BRAND_TIMING&quot;,false</TD><TD>Should the time taken
to generate each picture be branded to the lower left in corner in each
generated image? Useful for performance measurements generating graphs</TD>
</TR>
<TR><TD valign="top">&quot;BRAND_TIME_FORMAT&quot;,&quot;Generated in: %01.3fs&quot;</TD><TD>
What format should be used for the timing string?</TD></TR>
</TABLE>
<P> The following defines should very rarely need to be changed</P>
<P></P>
<TABLE cellpadding="3" cellspacing="0" class="codedefines">
<TR><TH>Define, default value</TH><TH>Comment</TH></TR>
<TR><TD valign="top">&quot;CACHE_FILE_GROUP&quot;,&quot;wwwadmin&quot;</TD><TD>What group
should the cached file belong to (Set to &quot;&quot; will give the default group
for the &quot;PHP-user&quot;) Please note that the Apache user must be a member
of the specified group since otherwise it is impossible for Apache to
set the specified group.</TD></TR>
<TR><TD valign="top">&quot;CACHE_FILE_MOD&quot;,0664</TD><TD>What permissions
should the cached file have (Set to &quot;&quot; will give the default
permissions for the &quot;PHP-user&quot;)</TD></TR>
<TR><TD valign="top">&quot;USE_BRESENHAM&quot;,false</TD><TD>Decide if we should
use the Bresenham circle algorithm or the built in Arc(). Bresenham
gives better visual appearance of circles but is more CPU intensive and
slower then the built in Arc() function in GD. Turned off by default
for speed</TD></TR>
<TR><TD valign="top">&quot;_CSIM_SPECIALFILE&quot;,&quot;_csim_special_&quot;</TD><TD>
Special file name to indicate that we only want to calc the image map in
the call to Graph::Stroke() used internally from the GetHTMLCSIM()
method.</TD></TR>
<TR><TD valign="top">&quot;_CSIM_DISPLAY&quot;,&quot;_jpg_csimd&quot;</TD><TD>HTTP GET
argument that is used with image map to indicate to the script to just
generate the image and not the full CSIM HTML page.</TD></TR>
</TABLE>
&nbsp;
<P>&nbsp;</P>
<P>&amp;nbsp</P>
</DIV><HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="1221AdjustingthesizeoftheLEDdigits.html">Previous</A>
</BODY>
</HTML>

View File

@ -0,0 +1,76 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="121GeneratingAntiSpamchallenge.html">
<LINK REL="Next" HREF="131AdjustingthesizeoftheLEDdigits.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="121GeneratingAntiSpamchallenge.html">Previous</A>
<A HREF="131AdjustingthesizeoftheLEDdigits.html">Next</A>
<HR NOSHADE>
<H1><A NAME="13">13 Generating LED-like digits with JpGraph</A></H1>
Starting with v1.21 it is possible to generate LED like digits with
JpGraph. This is accomplished by the usage of the &quot;jpgraph_led.php&quot;
module.
<P> The creation of LED digits and letters are extremely simple. The
following complete example demonstrates the creation of a LED display<DIV
class="phpscript"><CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;
<BR>
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_led.php&quot;</FONT><FONT
color="#007700">;
<BR>
<BR></FONT><FONT color="#FF8000">
//&nbsp;By&nbsp;default&nbsp;each&nbsp;&quot;LED&quot;&nbsp;circle&nbsp;has&nbsp;a&nbsp;radius&nbsp;of&nbsp;3&nbsp;pixels
<BR></FONT><FONT color="#0000BB">$led&nbsp;</FONT><FONT color="#007700">
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">DigitalLED74</FONT><FONT color="#007700">
();
<BR></FONT><FONT color="#0000BB">$led</FONT><FONT color="#007700">-&gt;</FONT><FONT
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
'0123456789.&nbsp;ABCDEFGHIJKL'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
LEDC_GREEN</FONT><FONT color="#007700">);&nbsp;
<BR></FONT><FONT color="#0000BB"></FONT></FONT></CODE></DIV></P>
<P> The result of running this script can be seen by running the
&quot;Examples/ledex1.php&quot; Example in the example directory. As can be seen
from the above example the color to be used for the LED digits is
specified as the second argument to the DigitalLED74::Stroke() method.
Available color for LED digits is given by the table below</P>
<TABLE style="border:darkgray solid 1px;">
<TR><TD><B>Symbolic name</B></TD><TD><B>Color</B></TD></TR>
<TR><TD>LEDC_RED</TD><TD>Red</TD></TR>
<TR><TD>LEDC_GREEN</TD><TD>Green</TD></TR>
<TR><TD>LEDC_BLUE</TD><TD>Blue</TD></TR>
<TR><TD>LEDC_YELLOW</TD><TD>Yellow</TD></TR>
<TR><TD>GREY</TD><TD>Grey</TD></TR>
</TABLE>
<P> Since the standard LED matrix of 7x4 dots does not lend itself to
accurately represent all normal ASCII characters only the following
numbers and letters can be displayed.</P>
<TABLE style="border:darkgray solid 1px;">
<TR><TD>All digits, 0-9</TD></TR>
<TR><TD>Capital Letters, A-L</TD></TR>
</TABLE>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="121GeneratingAntiSpamchallenge.html">Previous</A>
<A HREF="131AdjustingthesizeoftheLEDdigits.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,174 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="132ImprovingtheLEDswithsupersampling.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="132ImprovingtheLEDswithsupersampling.html">Previous</A>
<HR NOSHADE>
<H1><A NAME="14">14 Code defines in JpGraph</A></H1>
<P> Various settings in JpGraph are controlled by overall DEFINEs in the
configuration file &quot;jpg-config.inc.php&quot;. Most of these defines have
default values that should be valid for most usage.</P>
<P> In the rest of this chapter all constants are described with default
value and usage.</P>
<P></P>
<TABLE cellpadding="3" cellspacing="0" class="codedefines">
<TR><TH>Define, default value</TH><TH>Comment</TH></TR>
<TR><TD valign="top">&quot;CACHE_DIR&quot;, &quot;/tmp/jpgraph_cache/&quot;</TD><TD>The full
absolute name of directory to be used as a cache. This directory<STRONG>
must</STRONG> be readable and writable for PHP. Must end with '/'</TD></TR>
<TR><TD valign="top">&quot;TTF_DIR&quot;, &quot;/usr/local/fonts/ttf/&quot;</TD><TD>
Directory for JpGraph TTF fonts. Must end with '/' The fonts must follow
the naming conventions as used by the supplied TTF fonts in JpGraph.</TD>
</TR>
<TR><TD valign="top">&quot;CSIMCACHE_DIR&quot;, &quot;csimcache/&quot;</TD><TD>Directory for
cache directory for CSIM graphs. Must end with '/' Cache directory
specification for use with CSIM graphs that are using the cache. The
directory must be the filesystem name as seen by PHP and the 'http'
version must be the same directory but as seen by the HTTP server
relative to the 'htdocs' directory. If a relative path is specified it
is taken to be relative from where the image script is executed. Note:
The default setting is to create a subdirectory in the directory from
where the image script is executed and store all files there. As usual
this directory must be writable by the PHP process.</TD></TR>
<TR><TD valign="top">&quot;CSIMCACHE_HTTP_DIR&quot;, &quot;csimcache&quot;</TD><TD>Directory
for JpGraph TTF fonts. Must end with '/' Cache directory specification
for use with CSIM graphs that are using the cache. The directory must
be the filesystem name as seen by PHP and the 'http' version must be
the same directory but as seen by the HTTP server relative to the
'htdocs' directory. If a relative path is specified it is taken to be
relative from where the image script is executed. Note: The default
setting is to create a subdirectory in the directory from where the
image script is executed and store all files there. As usual this
directory must be writable by the PHP process.</TD></TR>
<TR><TD valign="top">&quot;CHINESE_TTF_FONT&quot;, &quot;bkai00mp.ttf&quot;</TD><TD> Actual
name of the TTF file used together with FF_CHINESE aka FF_BIG5 This is
the TTF file being used when the font family is specified as either
FF_CHINESE or FF_BIG5</TD></TR>
<TR><TD valign="top">&quot;LANGUAGE_CYRILLIC&quot;, false</TD><TD> Special unicode
Cyrillic language support.</TD></TR>
<TR><TD valign="top">&quot;CYRILLIC_FROM_WINDOWS&quot;, false</TD><TD> If you are
setting this config to true the conversion will assume that the input
text is windows 1251, if false it will assume koi8-r</TD></TR>
<TR><TD valign="top">'MINCHO_TTF_FONT', 'ipam.ttf'</TD><TD> Japanese
TrueType font used with FF_MINCHO</TD></TR>
<TR><TD valign="top">'PMINCHO_TTF_FONT', 'ipamp.ttf'</TD><TD> Japanese
TrueType font used with FF_PMINCHO</TD></TR>
<TR><TD valign="top">'GOTHIC_TTF_FONT', 'ipag.ttf'</TD><TD> Japanese
TrueType font used with FF_GOTHIC</TD></TR>
<TR><TD valign="top">'PGOTHIC_TTF_FONT', 'ipagp.ttf'</TD><TD> Japanese
TrueType font used with FF_PGOTHIC</TD></TR>
<TR><TD valign="top">&quot;INSTALL_PHP_ERR_HANDLER&quot;, false</TD><TD> Determine
if the library should also setup the default PHP error handler to
generate a graphic error message. This is useful during development to
be able to see the error message as an image instead as a &quot;red-cross&quot;
in a page where an image is expected.</TD></TR>
<TR><TD valign="top">&quot;CATCH_PHPERRMSG&quot;, true</TD><TD> Should the library
examine the global php_errmsg string and convert any error in it to a
graphical representation. This is handy for the occasions when, for
example, header files cannot be found and this results in the graph not
being created and just a &quot;red-cross&quot; image would be seen. This should
be turned off for a production site.</TD></TR>
<TR><TD valign="top">&quot;USE_LIBRARY_GD2&quot;,false</TD><TD>Specify if we
should use GD 2.x or GD 1.x If you have GD 2.x installed it is
recommended that you use it since it will give a slightly, slightly
better visual appearance for arcs. If you don't have GD2 installed this
must be set to false!</TD></TR>
<TR><TD valign="top">'USE_TRUECOLOR',true</TD><TD>Should the image be a
truecolor image? Note 1: Can only be used with GD 2.0.2 and above. Note
2: GD 2.0.1 + PHP 4.0.6 on Win32 crashes when trying to use truecolor.
Truecolor support is to be considered alpha since GD 2.x is still not
considered stable (especially on Win32). Note 3: MUST be enabled to get
background images working with GD2 Note 4: If enabled then truetype
fonts will look very ugly =&gt; You can't have both background images and
truetype fonts in the same image until these bugs has been fixed in GD
2.01</TD></TR>
<TR><TD valign="top">&quot;USE_CACHE&quot;,false</TD><TD>Should the cache be used
at all? By setting this to false no files will be generated in the
cache directory. The difference from READ_CACHE being that setting
READ_CACHE to false will still create the image in the cache directory
just not use it. By setting USE_CACHE=false no files will even be
generated in the cache directory.</TD></TR>
<TR><TD valign="top">&quot;READ_CACHE&quot;,true</TD><TD>Should we try to find an
image in the cache before generating it? Set this define to false to
bypass the reading of the cache and always regenerate the image. Note
that even if reading the cache is disabled the cached will still be
updated with the newly generated image. Set also &quot;USE_CACHE&quot; below.</TD>
</TR>
<TR><TD valign="top">&quot;DEFAULT_GFORMAT&quot;,&quot;auto&quot;</TD><TD>Default graphic
format set to &quot;auto&quot; which will automatically choose the best available
format in the order png,gif,jpg (The supported format depends on what
your PHP installation supports)</TD></TR>
<TR><TD valign="top">&quot;USE_IMAGE_ERROR_HANDLER&quot;,true</TD><TD> Determine
if the error handler should be image based or purely text based. Image
based makes it easier since the script will always return an image even
in case of errors.</TD></TR>
<TR><TD valign="top">&quot;USE_APPROX_COLORS&quot;,true</TD><TD>If the color
palette is full should JpGraph try to allocate the closest match? If
you plan on using background image or gradient fills it might be a good
idea to enable this. If not you will otherwise get an error saying that
the color palette is exhausted. The drawback of using approximations is
that the colors might not be exactly what you specified. Note1: This
does only apply to a palette image, not true color images since they
don't have the limitations of maximum number of colors.</TD></TR>
<TR><TD valign="top">&quot;ERR_DEPRECATED&quot;,false</TD><TD>Should usage of
deprecated functions and parameters give a fatal error? (Useful to
check if code is future proof.)</TD></TR>
<TR><TD valign="top">&quot;BRAND_TIMING&quot;,false</TD><TD>Should the time taken
to generate each picture be branded to the lower left in corner in each
generated image? Useful for performance measurements generating graphs</TD>
</TR>
<TR><TD valign="top">&quot;BRAND_TIME_FORMAT&quot;,&quot;Generated in: %01.3fs&quot;</TD><TD>
What format should be used for the timing string?</TD></TR>
</TABLE>
<P> The following defines should very rarely need to be changed</P>
<P></P>
<TABLE cellpadding="3" cellspacing="0" class="codedefines">
<TR><TH>Define, default value</TH><TH>Comment</TH></TR>
<TR><TD valign="top">&quot;CACHE_FILE_GROUP&quot;,&quot;wwwadmin&quot;</TD><TD>What group
should the cached file belong to (Set to &quot;&quot; will give the default group
for the &quot;PHP-user&quot;) Please note that the Apache user must be a member
of the specified group since otherwise it is impossible for Apache to
set the specified group.</TD></TR>
<TR><TD valign="top">&quot;CACHE_FILE_MOD&quot;,0664</TD><TD>What permissions
should the cached file have (Set to &quot;&quot; will give the default
permissions for the &quot;PHP-user&quot;)</TD></TR>
<TR><TD valign="top">&quot;USE_BRESENHAM&quot;,false</TD><TD>Decide if we should
use the Bresenham circle algorithm or the built in Arc(). Bresenham
gives better visual appearance of circles but is more CPU intensive and
slower then the built in Arc() function in GD. Turned off by default
for speed</TD></TR>
<TR><TD valign="top">&quot;_CSIM_SPECIALFILE&quot;,&quot;_csim_special_&quot;</TD><TD>
Special file name to indicate that we only want to calc the image map in
the call to Graph::Stroke() used internally from the GetHTMLCSIM()
method.</TD></TR>
<TR><TD valign="top">&quot;_CSIM_DISPLAY&quot;,&quot;_jpg_csimd&quot;</TD><TD>HTTP GET
argument that is used with image map to indicate to the script to just
generate the image and not the full CSIM HTML page.</TD></TR>
</TABLE>
&nbsp;
<P>&nbsp;</P>
<P>&amp;nbsp</P>
</DIV><HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="132ImprovingtheLEDswithsupersampling.html">Previous</A>
</BODY>
</HTML>

View File

@ -0,0 +1,32 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Next" HREF="11Versionhistory.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="11Versionhistory.html">Next</A>
<HR NOSHADE>
<H1><A NAME="1">1 About this manual</A></H1>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="11Versionhistory.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,45 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="2Introduction.html">
<LINK REL="Next" HREF="22SoftwareLicense.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="2Introduction.html">Previous</A>
<A HREF="22SoftwareLicense.html">Next</A>
<HR NOSHADE>
<H2><A NAME="2_1">2.1 Version</A></H2>
<P> This manual covers versions up to 1.21 of JpGraph. A 2D graph
plotting library for PHP4 and PHP5.</P>
<P> The library exists in two main tracks, the 1.x track and the 2.x
track. From a functional perspective both branches are equivalent. The
difference is that 1.x is suitable for PHP4 and 2.x is suitable for
PHP5.</P>
<P> Please make sure you use the correct version ! The 1.x version will
not in general wotk on PHP5 installation and vice versa.</P>
<P> Even though the library is known to work with version of PHP prior
to 4.3 and 5.1 respectively the library is not tested nor is it
recommended to run with any older versions of PHP.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="2Introduction.html">Previous</A>
<A HREF="22SoftwareLicense.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,41 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="21Version.html">
<LINK REL="Next" HREF="23JpGraphFeatures.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="21Version.html">Previous</A>
<A HREF="23JpGraphFeatures.html">Next</A>
<HR NOSHADE>
<H2><A NAME="2_2">2.2 Software License</A></H2>
<P> JpGraph is released under a dual license. For non-comercial usage
the library is released uner QPL 1.0 (Qt-License) and under the JpGraph
Professional License for commercial use. Commercial use is defined as
either a) The library is included as an integral part of a product that
is sold with a cost that exceeds the cost of the distribution medium.
b) The library is offered as a WEB service for a fee c) The library is
used on an intranet in a company with more than 5 employees</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="21Version.html">Previous</A>
<A HREF="23JpGraphFeatures.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,86 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="22SoftwareLicense.html">
<LINK REL="Next" HREF="24Gettingthelatestversion.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="22SoftwareLicense.html">Previous</A>
<A HREF="24Gettingthelatestversion.html">Next</A>
<HR NOSHADE>
<H2><A NAME="2_3">2.3 JpGraph Features</A></H2>
<P> JpGraph library is an OO graph library which makes it easy to both
draw a &quot;quick and dirty&quot; graph with a minimum of code and quite complex
graphs which requires a very fine grain of control. The library tries
to assign sensible default values for most parameters hence making the
learning curve quite flat since for most of the time very few commands
is required to draw graphs with a pleasing esthetic look.</P>
<P> Some highlights of available features are</P>
<UL>
<LI> Flexible scales, supports text-lin, text-log, lin-lin, lin-log,
log-lin and log-log and integer scales.</LI>
<LI> Supports both PNG, GIF and JPG graphic formats. Note that the
available formats are dependent on the specific PHP installation where
the library is used.</LI>
<LI>Supports caching of generated graphs to lessen burden of a HTTP
server.</LI>
<LI> Supports batch mode to only generate images to a file</LI>
<LI>Supports client side image maps which makes it easy to produce drill
down images.</LI>
<LI>Intelligent auto-scaling which gravitates towards esthetic values,
i.e. multiples of 2:s and 5:s</LI>
<LI>Fully supports manual scaling, with fine grain control of position
of ticks.</LI>
<LI>Supports background images with different formatting options</LI>
<LI>Supports color and brightness adjustments of images directly in PHP.</LI>
<LI>User specified grace for auto-scaling</LI>
<LI> Supports up to two different y-scale, it is possible to have
different left and right y-scale and add plots to both</LI>
<LI>Supports, line-plots, filled line-plots, accumulated line-plots, bar
plots, accumulated bar plots, grouped bar plots, error plots, line
error plots, scatter plots, gantt-charts, radar plots, 2D and 3D pie
charts.</LI>
<LI>Supports unlimited number of plots in each graph, makes it easy to
compose complex graph which consists of several plot types</LI>
<LI>User specified position of axis</LI>
<LI>Supports color gradient fill in seven styles</LI>
<LI>Designed as a flexible OO framework which makes it easy to add new
types of plots</LI>
<LI>Supports automatic legend generation</LI>
<LI>Supports both vertical and horizontal grids</LI>
<LI>Supports anti-aliasing of lines</LI>
<LI>Supports background images as well as unlimited number of icons in
the graph</LI>
<LI>Supports rotation of linear graphs</LI>
<LI>More then 400 named colors</LI>
<LI>Designed modularly - you don't have to include code which isn't used</LI>
<LI> ...and many many more features</LI>
</UL>
<P> In addition to these high level features the library has been
designed to be orthogonal and consistent in its' naming convention. For
example, to specify color each object (i.e. axis, grids, texts, titles
etc) within the graph implements the method SetColor() with the same
signature.</P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="22SoftwareLicense.html">Previous</A>
<A HREF="24Gettingthelatestversion.html">Next</A>
</BODY>
</HTML>

View File

@ -0,0 +1,46 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
<LINK REL="Start" HREF="index.html">
<LINK REL="Contents" HREF="toc.html">
<LINK REL="Prev" HREF="23JpGraphFeatures.html">
<LINK REL="Next" HREF="25Plannedfutureaddition.html">
<STYLE TYPE="text/css"><!--
BODY { font-family: serif }
H1 { font-family: sans-serif }
H2 { font-family: sans-serif }
H3 { font-family: sans-serif }
H4 { font-family: sans-serif }
H5 { font-family: sans-serif }
H6 { font-family: sans-serif }
SUB { font-size: smaller }
SUP { font-size: smaller }
PRE { font-family: monospace }
A { text-decoration: none }
--></STYLE>
</HEAD>
<BODY>
<A HREF="toc.html">Contents</A>
<A HREF="23JpGraphFeatures.html">Previous</A>
<A HREF="25Plannedfutureaddition.html">Next</A>
<HR NOSHADE>
<H2><A NAME="2_4">2.4 Getting the latest version</A></H2>
<P> The latest version of jpgraph can always be found on <A href="http://www.aditus.nu/jpgraph/">
http://www.aditus.nu/jpgraph/</A></P>
<P> Information on version numbering schema</P>
<UL>
<LI>1.x -&gt; 1.x.y, Bug fix release 'y' for version 1.x does not introduce
new features</LI>
<LI>1.x -&gt; 1.(x+1), Added functionality. Mostly keeping backwards
compatibility unless a very good reason not to. All SC breaks will be
well announced in release notes and might be small things like a
misspelled method name compared to the proper English spelling.</LI>
</UL>
<P></P>
<HR NOSHADE>
<A HREF="toc.html">Contents</A>
<A HREF="23JpGraphFeatures.html">Previous</A>
<A HREF="25Plannedfutureaddition.html">Next</A>
</BODY>
</HTML>

Some files were not shown because too many files have changed in this diff Show More