diff --git a/application/Bootstrap.php b/application/Bootstrap.php index 5358dbc..eb3e0a9 100644 --- a/application/Bootstrap.php +++ b/application/Bootstrap.php @@ -49,7 +49,45 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap Zend_Registry::set('firebug', $logger); } - protected function _initDb(){} + protected function _initDb() + { + $c = new Zend_Config($this->getOptions()); + try { + $db = Zend_Db::factory($c->profil->db->sdv1); + $db->getConnection(); + } catch ( Exception $e ) { + if (APPLICATION_ENV == 'development') { + echo '
'; print_r($e); echo '
'; + } else { + echo "Le service rencontre actuellement un problème technique."; + } + exit; + } - protected function _initCache(){} + /** + * Set the default adapter to use with all model + */ + Zend_Db_Table::setDefaultAdapter($db); + + /** + * Set Firebug Database profiler + */ + if (APPLICATION_ENV == 'development') { + $profiler = new Zend_Db_Profiler_Firebug('All DB Queries'); + $profiler->setEnabled(true); + $db->setProfiler($profiler); + } + } + + protected function _initCache() + { + //MetadataCache pour la base de données + $cache = Zend_Cache::factory( + 'Core', + 'Apc', + array('lifetime' => 28800,'automatic_serialization' => true), + array() + ); + Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); + } } \ No newline at end of file diff --git a/application/configs/application.ini b/application/configs/application.ini index 8cc4f1b..cb32d73 100644 --- a/application/configs/application.ini +++ b/application/configs/application.ini @@ -13,6 +13,27 @@ resources.view.basePath = APPLICATION_PATH "/views" autoloaderNamespaces[] = "Application_" autoloaderNamespaces[] = "Scores_" +; Scores configuration +profil.server.name = local +profil.webservice.location = sdsrvdev01 +profil.mail.method = smtp +profil.mail.smtp_host = smtp.free.fr +profil.mail.email.support = supportdev@scores-decisions.com +profil.mail.email.supportdev = supportdev@scores-decisions.com +profil.mail.email.contact = supportdev@scores-decisions.com +profil.mail.email.production = supportdev@scores-decisions.com +profil.path.cache = APPLICATION_PATH "/../data/cache" +profil.path.files = APPLICATION_PATH "/../data/files" +profil.path.pages = APPLICATION_PATH "/../data/pages" +profil.path.data = "c:\Users\mricois\www\data\partner" +profil.wkhtmltopdf.path = "c:\Users\mricois\www\data\wkhtml\windows\wkhtmltopdf.exe" +profil.db.sdv1.adapter=mysqli +profil.db.sdv1.params.host=127.0.0.1 +profil.db.sdv1.params.username=root +profil.db.sdv1.params.password=bj10sx +profil.db.sdv1.params.dbname=partner +profil.db.sdv1.params.driver_options.MYSQLI_INIT_COMMAND = "SET NAMES utf8" + [staging : production] resources.frontController.params.displayExceptions = 1 diff --git a/application/controllers/ReportController.php b/application/controllers/ReportController.php index 0a6317b..2ea726a 100644 --- a/application/controllers/ReportController.php +++ b/application/controllers/ReportController.php @@ -1,34 +1,219 @@ view->inlineScript() + ->appendFile('/libs/jquery-2.0.3.min.js', 'text/javascript') + ->appendFile('/libs/bootstrap-v3.0.0/js/bootstrap.min.js', 'text/javascript'); + } + + /** + * + */ public function indexAction() { + $this->_helper->layout()->disableLayout(); + $request = $this->getRequest(); - //Get parameters - $siren = $request->getParam('siren'); - + //Define title //Control the prestation with the database - inject additionnaly parameters - //Launch report - - $report = new Scores_Partner_Report('indiscore3', '552144503', 'mricois', 'ju2loh6o'); - $html = $report->getContent(); - file_put_contents('test.html', $html); - - //Write links to get the HTML and/or PDF + //Get parameters + $siren = $request->getParam('siren'); + $this->view->SirenExiste = false; + if (intval($siren)>100) { + //Vérifier que le SIREN existe en base + require_once 'Scores/WsScores.php'; + $ws = new WsScores('mricois', 'ju2loh6o'); + $response = $ws->getIdentiteLight($siren); + if ($response !== false) { + $this->view->Siren = $response->Siren; + $this->view->RaisonSociale = $response->Nom; + $this->view->SirenExiste = true; + $this->view->ButtonUrl = $this->view->url(array( + 'controller'=>'report', + 'action'=>'cmd', + 'siren'=>$response->Siren + )); + } + } } + /** + * + */ + public function cmdAction() + { + $this->_helper->layout()->disableLayout(); + + $request = $this->getRequest(); + + $siren = $request->getParam('siren'); + + //Affichage du formulaires + $form = new Application_Form_Command(); + if ( $request->isPost() ) { + + $values = $request->getPost(); + $form->populate($values); + + if ( $form->isValid($values) ) { + + //Sauvegarde des informations + $commandM = new Application_Model_Command(); + try { + $commandM->insert($form->getValues()); + //Passage à la page suivante + $url = $this->view->url(array( + 'controller'=>'report', + 'action'=>'deliver', + 'id' => $form->getValue('cmdId'), + )); + $this->redirect($url); + } catch (Zend_Db_Adapter_Exception $e) { + $this->view->msg = "Impossible de passer la commande."; + } + } + } else { + + if (intval($siren)>100) { + //Get report + $report = new Scores_Partner_Report('indiscore3', $siren, 'mricois', 'ju2loh6o'); + $html = $report->getContent(); + + if ( $html !== false ) { + + $c = Zend_Registry::get('config'); + $pathCmd = $c->profil->path->data; + + $id = uniqid(); + //Write the file (name with commande id) + if ( file_put_contents($pathCmd . DIRECTORY_SEPARATOR . $id.'.html', $html) ) { + + $this->view->CmdID = $id; + + } + } + } + + } + + $this->view->form = $form; + $this->view->siren = $siren; + + } + + + public function deliverAction() + { + $this->_helper->layout()->disableLayout(); + + $request = $this->getRequest(); + + $c = Zend_Registry::get('config'); + $pathCmd = $c->profil->path->data; + + //Commande ID + $cmdId = $request->getParam('id'); + + //Est ce que la commande existe + $commandM = new Application_Model_Command(); + $where = $commandM->select()->where('cmdId=?', $cmdId); + $row = $commandM->fetchRow($where); + if ( $row!==null ) { + + $infos = new stdClass(); + $infos->NumCommande = $row->cmdId; + $infos->DateCommande = $row->dateInsert; + $infos->RaisonSociale = $row->rs; + $infos->NomPrenom = $row->nom . ' ' . $row->prenom; + $infos->Adresse = $row->adresse; + $infos->CpVille = $row->cp . ' ' . $row->ville; + $infos->Tel = $row->tel; + $infos->Mob = $row->mobile; + + $this->view->Infos = $infos; + + if ( file_exists($pathCmd . DIRECTORY_SEPARATOR . $row->cmdId . '.html') ) { + //Define links to get the HTML and/or PDF + $links = array( + 0 => array( + 'title' => 'Fichier PDF', + 'desc' => 'Télécharger le bilan financier', + 'url' => $this->view->url(array( + 'controller'=>'report', + 'action'=>'pdf', + 'id' => $row->cmdId + )) + ), + ); + } + } + } + + + /** + * Display in blank page the html + */ + public function htmlAction() + { + $this->_helper->layout()->disableLayout(); + } + + /** + * Distribute pdf file + */ public function pdfAction() { - //Unlink the file + $this->_helper->layout()->disableLayout(); - //if HTML exist, make a pdf + $request = $this->getRequest(); + + $file = false; + + //Commande ID + $cmdId = $request->getParam('id'); + + //Est ce que la commande existe + $commandM = new Application_Model_Command(); + $where = $commandM->select()->where('cmdId=?', $cmdId); + $row = $commandM->fetchRow($where); + if ( $row !== null ) { + + //Copy html from command directory to temporary storage + $c = Zend_Registry::get('config'); + $source = $c->profil->path->data . DIRECTORY_SEPARATOR . $row->cmdId . '.html'; + $dest = $c->profil->path->pages . DIRECTORY_SEPARATOR . $row->cmdId . '.html'; + if ( copy($source, $dest) ) { + $wkthml = new Scores_Wkhtml_Pdf(); + $file = $wkhtml->exec($dest); + } + + } //Distribute it to the output - + if ( $file ) { + if( file_exists($file) && filesize($file)>0 ) { + header('Content-Transfer-Encoding: none'); + header('Content-type: ' . $content_type.''); + header('Content-Length: ' . filesize($file)); + header('Content-MD5: ' . base64_encode(md5_file($file))); + header('Content-Disposition: filename="' . basename($file) . '"'); + header('Cache-Control: private, max-age=0, must-revalidate'); + header('Pragma: public'); + ini_set('zlib.output_compression', '0'); + echo file_get_contents($file); + } else { + echo "Erreur lors de l'affichage du fichier."; + } + } else { + echo "Erreur lors de la génération du fichier."; + } } } \ No newline at end of file diff --git a/application/models/Command.php b/application/models/Command.php new file mode 100644 index 0000000..8909af3 --- /dev/null +++ b/application/models/Command.php @@ -0,0 +1,5 @@ + + diff --git a/application/views/scripts/report/cmd.phtml b/application/views/scripts/report/cmd.phtml new file mode 100644 index 0000000..f4bc50e --- /dev/null +++ b/application/views/scripts/report/cmd.phtml @@ -0,0 +1,155 @@ + + + + + + +Kompass - Achat Bilan Financier + + + + + + +
+ + + + siren && $this->CmdID ) {?> + +
msg?>
+ +
+ + + +
+ + + form->email->hasErrors()) {?> +
+ form->email->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->rs->hasErrors()) {?> +
+ form->rs->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->nom->hasErrors()) {?> +
+ form->nom->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->prenom->hasErrors()) {?> +
+ form->prenom->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->adresse->hasErrors()) {?> +
+ form->adresse->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->cp->hasErrors()) {?> +
+ form->cp->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->ville->hasErrors()) {?> +
+ form->ville->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->tel->hasErrors()) {?> +
+ form->tel->getMessages() as $msg) {?> +
+ +
+ +
+ +
+ + + form->mobile->hasErrors()) {?> +
+ form->mobile->getMessages() as $msg) {?> +
+ +
+ +
+ + +
+ + + +
Erreur !
+ + + + + + +
+ + inlineScript(); ?> + + + diff --git a/application/views/scripts/report/deliver.phtml b/application/views/scripts/report/deliver.phtml new file mode 100644 index 0000000..1a7f834 --- /dev/null +++ b/application/views/scripts/report/deliver.phtml @@ -0,0 +1,87 @@ + + + + + + +Kompass - Achat Bilan Financier + + + + + + +
+ + + +
+
+ +
+
+

Détails de votre commande

+
+
+ +
+ Suivi commande
+ N° de commande
+
+ +
+ Infos->RaisonSociale?>
+ Infos->NomPrenom?>
+ Infos->Adresse?>
+ Infos->Tel)) {?> + Tel : Infos->Tel?>
+ + Infos->Mob)) {?> + Tel : Infos->Mob?> + +
+ +
+
+ +
+
+ +
+
+

Liste des fichiers

+
+
+ + links) ) {?> + + links as $link ) {?> + + + + + +
+
+ +
+
+ + + + +
+ + inlineScript(); ?> + + + diff --git a/application/views/scripts/report/index.phtml b/application/views/scripts/report/index.phtml index b3d9bbc..436edae 100644 --- a/application/views/scripts/report/index.phtml +++ b/application/views/scripts/report/index.phtml @@ -1 +1,43 @@ - + + + + + +Kompass - Achat Bilan Financier + + + + + + +
+ + + + SirenExiste === false ) {?> + +
Erreur ! Impossible de trouver la société.
+ + + +
Siren : Siren?>
+
Raison Sociale : RaisonSociale?>
+ +
Commander
+ + + + + + +
+ + inlineScript(); ?> + + + diff --git a/library/Application/Form/Command.php b/library/Application/Form/Command.php new file mode 100644 index 0000000..4bd8f89 --- /dev/null +++ b/library/Application/Form/Command.php @@ -0,0 +1,87 @@ +setName('commande'); + $this->setAction('/report/cmd'); + $this->setMethod('post'); + $this->addElement('hidden', 'cmdId', array( + 'required' => true, + ) + ); + $this->addElement('hidden', 'siren', array( + 'required' => true, + ) + ); + $this->addElement('text', 'email', array( + 'filters' => array('StringTrim'), + 'validators' => array('EmailAddress'), + 'label' => 'Email', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'rs', array( + 'filters' => array('StringTrim'), + 'label' => 'Raison Sociale', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'nom', array( + 'filters' => array('StringTrim'), + 'label' => 'Nom', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'prenom', array( + 'filters' => array('StringTrim'), + 'label' => 'Prénom', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'adresse', array( + 'filters' => array('StringTrim'), + 'label' => 'Adresse', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'cp', array( + 'filters' => array('StringTrim'), + 'label' => 'Code Postal', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'ville', array( + 'filters' => array('StringTrim'), + 'label' => 'Ville', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'tel', array( + 'filters' => array('StringTrim'), + 'label' => 'Téléphone', + 'Description' => '', + 'required' => true, + ) + ); + $this->addElement('text', 'mobile', array( + 'filters' => array('StringTrim'), + 'label' => ' Téléphone Mobile', + 'Description' => '', + 'required' => false, + ) + ); + $this->addElement('submit', 'submit',array( + 'label' => 'Commander', + 'ignore' => true, + ) + ); + } +} \ No newline at end of file diff --git a/library/Scores/Finance/Liasse.php b/library/Scores/Finance/Liasse.php new file mode 100644 index 0000000..19a4729 --- /dev/null +++ b/library/Scores/Finance/Liasse.php @@ -0,0 +1,236 @@ + 1, + 'K' => 1000, + 'M' => 1000000, + ); + + public function __construct($liasse, $unit = 'K') + { + $this->div = $this->unit[$unit]; + $this->setData($liasse); + } + + protected function setData($data) + { + $this->info = array( + 'dateFraicheBilan' => $data->DATE_FRAICHE_BILAN, + 'dateCloture' => $data->DATE_CLOTURE, + 'dateCloturePre' => $data->DATE_CLOTURE_PRE, + 'dureeMois' => $data->DUREE_MOIS, + 'dureeMoisPre' => $data->DUREE_MOIS_PRE, + 'monnaie' => $data->MONNAIE, + 'monnaieOri' => $data->MONNAIE_ORI, + 'monnaieLivUnite' => $data->MONNAIE_LIV_UNITE, + 'consolide' => $data->CONSOLIDE, + 'source' => $data->SOURCE, + ); + + //Affectaction des postes + foreach ($data->POSTES->item as $element){ + if (in_array($element->id, array( + 'YP', 'YP1', '376', // Effectifs 2033 et 2050 + 'M2G', 'M2H', // Autres effectifs + 'ZK', 'ZK1', // Taux + 'IJ', 'JG', 'JH', 'JJ', 'ZR', // pour holding/ste mere + 'XP' //numero de centre de gestion agréé + ))) + { + $this->postes[$element->id] = number_format($element->val, 0, '', ' '); + } else { + $this->postes[$element->id] = $this->dMontant($element->val); + } + } + + //Transformation Simplifié en Normal + if ( $data->CONSOLIDE == 'S'){ + $this->postes = $this->bilanSimplifie2Normal($this->postes); + } + } + + public function getInfo($key) + { + return $this->info[$key]; + } + + public function getPostes() + { + return $this->postes; + } + + protected function dMontant($montant) + { + return number_format($montant/$this->div, 0, '', ' '); + } + + function bilanSimplifie2Normal($bilanRS) + { + $tabBS2BN = array( + 'AH'=>'010', + 'AI'=>'012', + 'AI1'=>'013', + 'AJ'=>'014', + 'AK'=>'016', + 'AK1'=>'017', + 'AT'=>'028', + 'AU'=>'030', + 'AU1'=>'031', + 'BH'=>'040', + 'BI'=>'042', + 'BI1'=>'043', + 'BJ'=>'044', + 'BK'=>'048', + 'BK1'=>'049', + 'BL'=>'050', + 'BM'=>'052', + 'BM1'=>'053', + 'BT'=>'060', + 'BU'=>'062', + 'BU1'=>'063', + 'BV'=>'064', + 'BW'=>'066', + 'BW1'=>'067', + 'BX'=>'068', + 'BY'=>'070', + 'BY1'=>'071', + 'BZ'=>'072', + 'CA'=>'074', + 'CA1'=>'075', + 'CD'=>'080', + 'CE'=>'082', + 'CE1'=>'083', + 'CF'=>'084', + 'CG'=>'086', + 'CG1'=>'087', + 'CH'=>'092', + 'CI'=>'094', + 'CI1'=>'095', + 'CJ'=>'096', + 'CK'=>'098', + 'CK1'=>'099', + 'CO'=>'110', + '1A'=>'112', + '1A1'=>'113', + 'DA'=>'120', + 'DC'=>'124', + 'DD'=>'126', + 'DF'=>'130', + 'DG'=>'132', + 'DH'=>'134', + 'DI'=>'136', + 'DK'=>'140', + 'DL'=>'142', + 'DR'=>'154', + 'DP'=>'154', + 'DU'=>'156', + 'DV'=>'169', + 'DW'=>'164', + 'DX'=>'166', + 'EA'=>'172-169', + 'EB'=>'174', + 'EC'=>'176', + 'EE'=>'180', + 'EH'=>'156-195', + 'FA'=>'210-209', + 'FB'=>'209', + 'FC'=>'210', + 'FD'=>'214-215', + 'FE'=>'215', + 'FF'=>'214', + 'FH'=>'217', + 'FI'=>'218', + 'FK'=>'209+215+217', + 'FL'=>'210+214+218', + 'FM'=>'222', + 'FN'=>'224', + 'FO'=>'226', + 'FQ'=>'230', + 'FR'=>'232', + 'FS'=>'234', + 'FT'=>'236', + 'FU'=>'238', + 'FV'=>'240', + 'FW'=>'242', + 'FX'=>'244', + 'FY'=>'250', + 'FZ'=>'252', + 'GA'=>'254', + 'GE'=>'262', + 'GF'=>'264', + 'GG'=>'270', + 'GP'=>'280', + 'GU'=>'294', + 'GW'=>'270+280+294', + 'HD'=>'290', + 'HH'=>'300', + 'HI'=>'290-300', + 'HK'=>'306', + 'HL'=>'232+280+290', + 'HM'=>'264+294+300+306', + 'HN'=>'310', + 'YY'=>'374', + 'YZ'=>'378', + 'YP'=>'376', + + //@todo : Traiter N-1 + + + ); + + $bilanRN=array(); + foreach ($tabBS2BN as $posteRN => $formule) { + if (preg_match('/\+|\-/', $formule)) { + $tabTmp=preg_split('/\+|\-/', $formule, -1, PREG_SPLIT_OFFSET_CAPTURE); + //$bilanRN[$posteRN]=0; + $scalc=''; + foreach ($tabTmp as $i=>$tab) { + if ($i==0) { + $bilanRN[$posteRN]=$bilanRS[$tab[0]]; + $scalc.=$bilanRS[$tab[0]]; + } + else { + $signe=$formule[$tab[1]-1]; + $scalc.=$signe; + if ($signe=='+') $bilanRN[$posteRN]+=$bilanRS[$tab[0]]; + elseif ($signe=='-') $bilanRN[$posteRN]-=$bilanRS[$tab[0]]; + $scalc.=$bilanRS[$tab[0]]; + } + } + $bilanRN[$posteRN]=$bilanRN[$posteRN]; + } + else $bilanRN[$posteRN]=$bilanRS[$formule]; + } + if ($bilanRS['240']<>0) { + $bilanRN['BL']=$bilanRS['050']; + $bilanRN['BM']=$bilanRS['052']; + } else { + $bilanRN['BN']=$bilanRS['050']; + $bilanRN['BO']=$bilanRS['052']; + } + + if ($bilanRS['070']<>0 || $bilanRS['074']<>0 || $bilanRS['052']<>0 || $bilanRS['062']<>0) + $bilanRN['GC']=$bilanRS['256']; + elseif ($bilanRS['070']==0 && $bilanRS['074']==0 && $bilanRS['052']==0 && $bilanRS['062']==0 && $bilanRS['254']<>0) + $bilanRN['GD']=$bilanRS['256']; + + if ($bilanRS['584']<>0) { + $bilanRN['HB']=$bilanRS['584']; + $bilanRN['HA']=$bilanRS['290']-$bilanRS['584']; + } else + $bilanRN['HA']=$bilanRS['290']; + + if ($bilanRS['582']<>0) { + $bilanRN['HF']=$bilanRS['582']; + $bilanRN['HE']=$bilanRS['582']-$bilanRS['300']; + } else + $bilanRN['HE']=$bilanRS['300']; + + return $bilanRN; + } +} \ No newline at end of file diff --git a/library/Scores/Finance/Liasse/XLS.php b/library/Scores/Finance/Liasse/XLS.php new file mode 100644 index 0000000..f38a61d --- /dev/null +++ b/library/Scores/Finance/Liasse/XLS.php @@ -0,0 +1,126 @@ + '.xls', + 'Excel2007' => '.xlsx', + ); + protected $assoc = array(); + protected $values = array(); + + /** + * + * Enter description here ... + * @param string $modele + * Nom du modèle + * @param string $mode + * Type de fichier excel pour l'ecriture (Excel5 | Excel2007) + */ + public function __construct($modele = '', $mode = 'Excel5') + { + $c = Zend_Registry::get('config'); + $this->path = $c->profil->path->files . '/'; + if (!is_dir($this->path)){ + mkdir($this->path); + } + $this->modele = $modele; + if (empty($this->modele)){ + $this->modele = 'bdf_liasse_template'; + } + $this->mode = $mode; + } + + public function dataModel($siren, $raisonSociale, $values) + { + switch($this->modele) + { + case 'bdf_liasse_template': + //Ajout champs spéciaux + $values['TEXTE_SIRET'] = 'Siret : '.$siren; + $values['TEXTE_RS'] = 'Société : '.$raisonSociale; + $values['TEXTE_DATEN'] = 'Date de clôture : le ' . + substr($values['DATE_CLOTURE'],6,2) . '/' . + substr($values['DATE_CLOTURE'],4,2) . '/' . + substr($values['DATE_CLOTURE'],0,4) . + ' sur ' . $values['DUREE_MOIS'] . ' mois'; + break; + //Bilan Normal Cerfa + case 'liasse_2050': + $values['TEXTE_SIRET'] = $siren; + $values['TEXTE_RS'] = $raisonSociale; + $values['TEXTE_DATEN'] = + substr($values['DATE_CLOTURE'],6,2) . '/' . + substr($values['DATE_CLOTURE'],4,2) . '/' . + substr($values['DATE_CLOTURE'],0,4); + $values['TEXTE_DATEN1'] = + substr($values['DATE_CLOTURE_PRE'],6,2) . '/' . + substr($values['DATE_CLOTURE_PRE'],4,2) . '/' . + substr($values['DATE_CLOTURE_PRE'],0,4); + $values['TEXTE_DUREEN'] = $values['DUREE_MOIS']; + $values['TEXTE_DUREEN1'] = $values['DUREE_MOIS_PRE']; + break; + //Bilan Simplifié Cerfa + case 'liasse_2033': + $values['TEXTE_SIRET'] = $siren; + $values['TEXTE_RS'] = $raisonSociale; + $values['TEXTE_DATEN'] = + substr($values['DATE_CLOTURE'],6,2) . '/' . + substr($values['DATE_CLOTURE'],4,2) . '/' . + substr($values['DATE_CLOTURE'],0,4); + $values['TEXTE_DATEN1'] = + substr($values['DATE_CLOTURE_PRE'],6,2) . '/' . + substr($values['DATE_CLOTURE_PRE'],4,2) . '/' . + substr($values['DATE_CLOTURE_PRE'],0,4); + $values['TEXTE_DUREEN'] = $values['DUREE_MOIS']; + $values['TEXTE_DUREEN1'] = $values['DUREE_MOIS_PRE']; + break; + } + + //Association + $dataAssoc = parse_ini_file(realpath(dirname(__FILE__)).'/models/'.$this->modele.'.ini', true); + $assoc = array(); + foreach($dataAssoc as $sheet => $dataCell) + { + foreach($dataCell as $key => $cell) + { + $assoc[$key] = array($sheet, $cell); + } + } + $this->assoc = $assoc; + $this->values = $values; + } + + public function dataFile($file) + { + require_once 'Vendors/phpexcel/PHPExcel.php'; + $objPHPexcel = PHPExcel_IOFactory::load(realpath(dirname(__FILE__)).'/models/'.$this->modele.'.xls'); + foreach( $this->assoc as $key => $position ) + { + $sheet = $position[0]; + $cell = $position[1]; + if (array_key_exists($key, $this->values)) + { + $objWorksheet = $objPHPexcel->getSheet($sheet); + $objWorksheet->getCell($cell)->setValue($this->values[$key]); + } + /* + else + { + $objWorksheet = $objPHPexcel->getSheet($sheet); + $objWorksheet->getCell($cell)->setValue('_'); + //echo "La clé $key n'a pas de valeur!
"; + } + */ + } + $objPHPexcel->setActiveSheetIndex(0); + $objWriter = PHPExcel_IOFactory::createWriter($objPHPexcel, $this->mode); + $objWriter->save($this->path.'/'.$file); + } + + + +} +?> \ No newline at end of file diff --git a/library/Scores/Finance/Liasse/models/bdf_liasse_template.ini b/library/Scores/Finance/Liasse/models/bdf_liasse_template.ini new file mode 100644 index 0000000..cd07bd7 --- /dev/null +++ b/library/Scores/Finance/Liasse/models/bdf_liasse_template.ini @@ -0,0 +1,400 @@ +[0] +AA = "C5" +AB = "C6" +AC = "E6" +AD = "C7" +AE = "E7" +AF = "C8" +AG = "E8" +AH = "C9" +AI = "E9" +AJ = "C10" +AK = "E10" +AL = "C11" +AM = "E11" +AN = "C12" +AO = "E12" +AP = "C13" +AQ = "E13" +AR = "C14" +AS = "E14" +AT = "C15" +AU = "E15" +AV = "C16" +AW = "E16" +AX = "C17" +AY = "E17" +CS = "C18" +CT = "E18" +CU = "C19" +CV = "E19" +BB = "C20" +BC = "E20" +BD = "C21" +BE = "E21" +BF = "C22" +BG = "E22" +BH = "C23" +BI = "E23" +BJ = "C24" +BK = "E24" +BL = "C25" +BM = "E25" +BN = "C26" +BO = "E26" +BP = "C27" +BQ = "E27" +BR = "C28" +BS = "E28" +BT = "C29" +BU = "E29" +BV = "C30" +BW = "E30" +BX = "C31" +BY = "E31" +BZ = "C32" +CA = "E32" +CB = "C33" +CC = "E33" +CD = "C34" +CE = "E34" +CF = "C35" +CG = "E35" +CH = "C36" +CI = "E36" +CJ = "C37" +CK = "E37" +CL = "C38" +CM = "C39" +CN = "C40" +CO = "C41" +1A = "E41" +TEXTE_SIRET = "A1" +TEXTE_RS = "A2" +TEXTE_DATEN = "A3" + +[1] +DA = "C5" +DB = "C6" +DC = "C7" +DD = "C8" +DE = "C9" +DF = "C10" +DG = "C11" +DH = "C12" +DI = "C13" +DJ = "C14" +DK = "C15" +DL = "C16" +DM = "C17" +DN = "C18" +DO = "C19" +DP = "C20" +DQ = "C21" +DR = "C22" +DS = "C23" +DT = "C24" +DU = "C25" +DV = "C26" +DW = "C27" +DX = "C28" +DY = "C29" +DZ = "C30" +EA = "C31" +EB = "C32" +EC = "C33" +ED = "C34" +EE = "C35" +1B = "C37" +1C = "C38" +1D = "C39" +1E = "C40" +EF = "C41" +EJ = "C42" +EG = "C43" +EH = "C44" +EI = "C45" + +[2] +FA = "C7" +FB = "E7" +FC = "G7" +FD = "C8" +FE = "E8" +FF = "G8" +FG = "C9" +FH = "E9" +FI = "G9" +FJ = "C10" +FK = "E10" +FL = "G10" +FM = "G11" +FN = "G12" +FO = "G13" +FP = "G14" +FQ = "G14" +FR = "G16" +FS = "G17" +FT = "G18" +FU = "G19" +FV = "G20" +FW = "G21" +FX = "G22" +FY = "G23" +FZ = "G24" +GA = "G25" +GB = "G27" +GC = "G28" +GD = "G29" +GE = "G30" +GF = "G31" +GG = "G32" +GH = "G33" +GI = "G34" +GJ = "G35" +GK = "G36" +GL = "G37" +GM = "G38" +GN = "G39" +GO = "G40" +GP = "G41" +GQ = "G42" +GR = "G43" +GS = "G44" +GT = "G45" +GU = "G46" +GV = "G47" +GW = "G48" +HA = "G49" +HB = "G50" +HC = "G51" +HD = "G52" +HE = "G53" +HF = "G54" +HG = "G55" +HH = "G56" +HI = "G57" +HJ = "G58" +HK = "G59" +HL = "G60" +HM = "G61" +HN = "G62" +HO = "G63" +HY = "G64" +1G = "G66" +HP = "G67" +HQ = "G69" +1H = "G70" +1J = "G71" +1K = "G72" +HX = "G73" + +[3] +ZE = "D5" +YQ = "D8" +YR = "D9" +YS = "D10" +YT = "D11" +YU = "D13" +YV = "D15" +ZJ = "D17" +YW = "D18" +9Z = "D19" +YX = "D20" +YY = "D21" +YZ = "D22" +ZA = "D23" +0B = "D24" +0S = "D25" +YP = "D27" + +[4] +3T = "D5" +3U = "D6" +3V = "D7" +3W = "D8" +3X = "D9" +IA = "D10" +IE = "D11" +IJ = "D12" +3Y = "D13" +3Z = "D14" +4A = "D15" +4E = "D16" +4J = "D17" +4N = "D18" +4T = "D19" +4X = "D20" +5B = "D21" +5F = "D22" +5L = "D23" +5R = "D24" +5V = "D25" +5Z = "D26" +6A = "D27" +6E = "D28" +02 = "D29" +9U = "D30" +06 = "D31" +6N = "D32" +6T = "D33" +6X = "D34" +7B = "D35" +7C = "D36" +TA = "F5" +TD = "F6" +TG = "F7" +TJ = "F8" +TM = "F9" +IB = "F10" +IF = "F11" +IK = "F12" +TP = "F13" +TS = "F14" +4B = "F15" +4F = "F16" +4K = "F17" +4P = "F18" +4U = "F19" +4Y = "F20" +5C = "F21" +5H = "F22" +5M = "F23" +5S = "F24" +5W = "F25" +TV = "F26" +6B = "F27" +6F = "F28" +03 = "F29" +9V = "F30" +07 = "F31" +6P = "F32" +6U = "F33" +6Y = "F34" +TY = "F35" +UB = "F36" +UE = "F37" +UG = "F38" +UJ = "F39" +TB = "H5" +TE = "H6" +TH = "H7" +TK = "H8" +TN = "H9" +IC = "H10" +IG = "H11" +IL = "H12" +TQ = "H13" +TT = "H14" +4C = "H15" +4G = "H16" +4L = "H17" +4R = "H18" +4V = "H19" +4Z = "H20" +5D = "H21" +5J = "H22" +5N = "H23" +5T = "H24" +5X = "H25" +TW = "H26" +6C = "H27" +6G = "H28" +04 = "H29" +9W = "H30" +08 = "H31" +6R = "H32" +6V = "H33" +6Z = "H34" +TZ = "H35" +UC = "H36" +UF = "H37" +UH = "H38" +UK = "H39" +TC = "J5" +TF = "J6" +TI = "J7" +TL = "J8" +TO = "J9" +ID = "J10" +IH = "J11" +IM = "J12" +TR = "J13" +TU = "J14" +4D = "J15" +4H = "J16" +4M = "J17" +4S = "J18" +4W = "J19" +5A = "J20" +5E = "J21" +5K = "J22" +5P = "J23" +5U = "J24" +5Y = "J25" +TX = "J26" +6D = "J27" +6H = "J28" +05 = "J29" +9X = "J30" +09 = "J31" +6S = "J32" +6W = "J33" +7A = "J34" +UA = "J35" +UD = "J36" +10 = "J40" + +[5] +UQ = "E11" +UL = "G6" +UP = "G7" +UT = "G8" +VA = "G9" +UX = "G10" +UU = "G11" +UY = "G12" +UZ = "G13" +VM = "G14" +VB = "G15" +VN = "G16" +VP = "G17" +VC = "G18" +VR = "G19" +VS = "G20" +VT = "G21" +VD = "G22" +VE = "G23" +VF = "G24" +UM = "I6" +UR = "I7" +UV = "I8" +VU = "I21" +UN = "K6" +US = "K7" +UW = "K8" +VV = "K21" +7Y = "E27" +7Z = "E28" +VG = "E29" +VH = "E30" +8A = "E31" +8B = "E32" +8C = "E33" +8D = "E34" +8E = "E35" +VW = "E36" +VX = "E37" +VQ = "E38" +8J = "E39" +VI = "E40" +8K = "E41" +SZ = "E42" +8L = "E43" +VY = "E44" +VZ = "G44" +VZ3 = "H44" +VZ4 = "I44" +VJ = "E45" +VK = "E46" +VL = "K45" \ No newline at end of file diff --git a/library/Scores/Finance/Liasse/models/bdf_liasse_template.xls b/library/Scores/Finance/Liasse/models/bdf_liasse_template.xls new file mode 100644 index 0000000..8e3a15d Binary files /dev/null and b/library/Scores/Finance/Liasse/models/bdf_liasse_template.xls differ diff --git a/library/Scores/Finance/Liasse/models/liasse_2033.ini b/library/Scores/Finance/Liasse/models/liasse_2033.ini new file mode 100644 index 0000000..4a7dd06 --- /dev/null +++ b/library/Scores/Finance/Liasse/models/liasse_2033.ini @@ -0,0 +1,352 @@ +;2033 ACTIF PASSIF +[0] +TEXTE_SIRET = "D6" +TEXTE_RS = "F4" +TEXTE_DATEN = "W10" +TEXTE_DATEN1 = "Z10" +TEXTE_DUREEN = "G7" +TEXTE_DUREEN1 = "S7" +010 = "K12" +014 = "K13" +028 = "K14" +040 = "K15" +044 = "K16" +050 = "K17" +060 = "K18" +064 = "K19" +068 = "K20" +072 = "K21" +080 = "K22" +084 = "K23" +088 = "K24" +092 = "K25" +096 = "K26" +110 = "K27" +012 = "Q12" +016 = "Q13" +030 = "Q14" +042 = "Q15" +048 = "Q16" +052 = "Q17" +062 = "Q18" +066 = "Q19" +070 = "Q20" +074 = "Q21" +082 = "Q22" +086 = "Q23" +090 = "Q24" +094 = "Q25" +098 = "Q26" +112 = "Q27" +013 = "W12" +017 = "W13" +031 = "W14" +043 = "W15" +049 = "W16" +053 = "W17" +063 = "W18" +067 = "W19" +071 = "W20" +075 = "W21" +083 = "W22" +087 = "W23" +091 = "W24" +095 = "W25" +099 = "W26" +113 = "W27" +120 = "W29" +124 = "W30" +126 = "W31" +130 = "W32" +132 = "W33" +134 = "W34" +136 = "W35" +140 = "W36" +142 = "W37" +154 = "W38" +156 = "W39" +164 = "W40" +166 = "W41" +172 = "W42" +174 = "W43" +176 = "W44" +180 = "W45" +195 = "Z46" +182 = "Z47" +184 = "Z48" +N00 = "Z12" +N01 = "Z13" +N02 = "Z14" +N03 = "Z15" +N04 = "Z16" +N05 = "Z17" +N06 = "Z18" +N07 = "Z19" +N08 = "Z20" +N09 = "Z21" +N10 = "Z22" +N11 = "Z23" +N12 = "Z24" +N13 = "Z25" +N14 = "Z26" +N15 = "Z27" +N16 = "Z29" +N17 = "Z30" +N18 = "Z31" +N19 = "Z32" +N20 = "Z33" +N21 = "Z34" +N22 = "Z35" +N23 = "Z36" +N24 = "Z37" +N25 = "Z38" +N26 = "Z39" +N27 = "Z40" +N28 = "Z41" +N29 = "Z42" +N30 = "Z43" +N31 = "Z44" +N32 = "Z45" + +;2033 CDR +[1] +209 = "R8" +215 = "R9" +217 = "R10" +24B = "K20" +24A = "U20" +243 = "R21" +259 = "R26" +247 = "H40" +248 = "V40" +981 = "U41" +344 = "I42" +346 = "T42" +381 = "D48" +382 = "T48" +374 = "H49" +376 = "S49" +378 = "H50" +210 = "AA8" +214 = "AA9" +218 = "AA10" +222 = "AA11" +224 = "AA12" +226 = "AA13" +230 = "AA14" +232 = "AA15" +234 = "AA16" +236 = "AA17" +238 = "AA18" +240 = "AA19" +242 = "AA20" +244 = "AA21" +250 = "AA22" +252 = "AA23" +254 = "AA24" +256 = "AA25" +262 = "AA26" +264 = "AA27" +270 = "AA28" +280 = "AA29" +290 = "AA30" +294 = "AA31" +300 = "AA32" +306 = "AA33" +310 = "AA34" +312 = "AA35" +316 = "AA36" +318 = "AA37" +322 = "AA38" +324 = "AA39" +330 = "AA40" +352 = "AA43" +356 = "AA44" +366 = "AA46" +370 = "AA47" +380 = "Z50" +N33 = "AD8" +N34 = "AD9" +N35 = "AD10" +N36 = "AD11" +N37 = "AD12" +N38 = "AD13" +N39 = "AD14" +N40 = "AD15" +N41 = "AD16" +N42 = "AD17" +N43 = "AD18" +N44 = "AD19" +N45 = "AD20" +N46 = "AD21" +N47 = "AD22" +N48 = "AD23" +N49 = "AD24" +N50 = "AD25" +N51 = "AD26" +N52 = "AD27" +N53 = "AD28" +N54 = "AD29" +N55 = "AD30" +N56 = "AD31" +N57 = "AD32" +N58 = "AD33" +N59 = "AD34" +314 = "AE35" +342 = "AE41" +350 = "AE42" +354 = "AE43" +360 = "AE45" +368 = "AE46" +372 = "AE47" +388 = "AE48" +399 = "AE50" + + +;2033 IMMO AMORT. +[2] +400 = "H9" +410 = "H10" +420 = "H11" +430 = "H12" +440 = "H13" +450 = "H14" +460 = "H15" +470 = "H16" +480 = "H17" +490 = "H18" +402 = "P9" +412 = "P10" +422 = "P11" +432 = "P12" +442 = "P13" +452 = "P14" +462 = "P15" +472 = "P16" +482 = "P17" +492 = "P18" +404 = "W9" +414 = "W10" +424 = "W11" +434 = "W12" +444 = "W13" +454 = "W14" +464 = "W15" +474 = "W16" +484 = "W17" +494 = "W18" +406 = "AD9" +416 = "AD10" +426 = "AD11" +436 = "AD12" +446 = "AD13" +456 = "AD14" +466 = "AD15" +476 = "AD16" +486 = "AD17" +496 = "AD18" +500 = "K21" +510 = "K22" +520 = "K23" +530 = "K24" +540 = "K25" +550 = "K26" +560 = "K27" +570 = "K28" +502 = "T21" +512 = "T22" +522 = "T23" +532 = "T24" +543 = "T25" +552 = "T26" +562 = "T27" +572 = "T28" +504 = "AE21" +514 = "AE22" +524 = "AE23" +534 = "AE24" +544 = "AE25" +554 = "AE26" +564 = "AE27" +574 = "AE28" +506 = "AJ21" +516 = "AJ22" +526 = "AJ23" +536 = "AJ24" +546 = "AJ25" +556 = "AJ26" +566 = "AJ27" +576 = "AJ28" +578 = "I42" +580 = "O42" +582 = "U42" +584 = "Z42" +586 = "AG42" +588 = "AM42" +590 = "AG43" +592 = "AM43" +593 = "AM44" +596 = "AG45" +598 = "AM45" + +;2033 PROVISIONS +[3] +610 = "H9" +601 = "H10" +610 = "H11" +620 = "H12" +630 = "H13" +640 = "H14" +650 = "H15" +660 = "H16" +680 = "H17" +602 = "P9" +603 = "P10" +612 = "P11" +622 = "P12" +632 = "P13" +642 = "P14" +652 = "P15" +662 = "P16" +682 = "P17" +604 = "W9" +605 = "W10" +614 = "W11" +624 = "W12" +634 = "W13" +644 = "W14" +654 = "W15" +664 = "W16" +684 = "W17" +606 = "AD9" +607 = "AD10" +616 = "AD11" +626 = "AD12" +636 = "AD13" +646 = "AD14" +656 = "AD15" +666 = "AD16" +686 = "AD17" +700 = "G20" +710 = "G21" +720 = "G22" +730 = "G23" +740 = "G24" +750 = "G25" +760 = "G26" +770 = "G27" +705 = "K20" +715 = "K21" +725 = "K22" +735 = "K23" +745 = "K24" +755 = "K25" +765 = "K26" +775 = "K27" +780 = "AJ27" +982 = "AJ29" +983 = "AJ30" +984 = "AJ31" +860 = "AJ32" +870 = "AJ33" + diff --git a/library/Scores/Finance/Liasse/models/liasse_2033.xls b/library/Scores/Finance/Liasse/models/liasse_2033.xls new file mode 100644 index 0000000..a8e7dfb Binary files /dev/null and b/library/Scores/Finance/Liasse/models/liasse_2033.xls differ diff --git a/library/Scores/Finance/Liasse/models/liasse_2033_ori.xls b/library/Scores/Finance/Liasse/models/liasse_2033_ori.xls new file mode 100644 index 0000000..e71f262 Binary files /dev/null and b/library/Scores/Finance/Liasse/models/liasse_2033_ori.xls differ diff --git a/library/Scores/Finance/Liasse/models/liasse_2050.ini b/library/Scores/Finance/Liasse/models/liasse_2050.ini new file mode 100644 index 0000000..0591e25 --- /dev/null +++ b/library/Scores/Finance/Liasse/models/liasse_2050.ini @@ -0,0 +1,1067 @@ +; 2050 - Actif +[0] +TEXTE_RS = "E4" +;texte_adresse = "E5" +TEXTE_SIRET = "D6" +;texte_ape = "D7" +TEXTE_DUREEN = "K6" +TEXTE_DATEN1 = "K7" +TEXTE_DUREEN1 = "K8" +TEXTE_DATEN = "K9" + +; actif brut +AA = "G11" +AB = "G12" +AD = "G13" +AF = "G14" +AH = "G15" +AJ = "G16" +AL = "G17" +AN = "G18" +AP = "G19" +AR = "G20" +AT = "G21" +AV = "G22" +AX = "G23" +CS = "G24" +CU = "G25" +BB = "G26" +BD = "G27" +BF = "G28" +BH = "G29" +BJ = "G30" +BL = "G31" +BN = "G32" +BP = "G33" +BR = "G34" +BT = "G35" +BV = "G36" +BX = "G37" +BZ = "G38" +CB = "G39" +CD = "G40" +CF = "G41" +CH = "G42" +CJ = "G43" +CL = "G44" +CM = "G45" +CN = "G46" +CO = "G47" +; actif ammort. +AC = "I12" +AE = "I13" +AG = "I14" +AI = "I15" +AK = "I16" +AM = "I17" +AO = "I18" +AQ = "I19" +AS = "I20" +AU = "I21" +AW = "I22" +AY = "I23" +CT = "I24" +CV = "I25" +BC = "I26" +BE = "I27" +BG = "I28" +BI = "I29" +BK = "I30" +BM = "I31" +BO = "I32" +BQ = "I33" +BS = "I34" +BU = "I35" +BW = "I36" +BY = "I37" +CA = "I38" +CC = "I39" +CE = "I40" +CG = "I41" +CI = "I42" +CK = "I43" +1A = "I47" +CP = "I48" +; actif net N +AA2 = "J11" +AC1 = "J12" +AE1 = "J13" +AG1 = "J14" +AI1 = "J15" +AK1 = "J16" +AM1 = "J17" +AO1 = "J18" +AQ1 = "J19" +AS1 = "J20" +AU1 = "J21" +AW1 = "J22" +AY1 = "J23" +CT1 = "J24" +CV1 = "J25" +BC1 = "J26" +BE1 = "J27" +BG1 = "J28" +BI1 = "J29" +BK1 = "J30" +BM1 = "J31" +BO1 = "J32" +BQ1 = "J33" +BS1 = "J34" +BU1 = "J35" +BW1 = "J36" +BY1 = "J37" +CA1 = "J38" +CC1 = "J39" +CE1 = "J40" +CG1 = "J41" +CI1 = "J42" +CK1 = "J43" +CL2 = "J44" +CM2 = "J45" +CN2 = "J46" +1A1 = "J47" +; actif net N-1 +AA3 = "K11" +AC2 = "K12" +AE2 = "K13" +AG2 = "K14" +AI2 = "K15" +AK2 = "K16" +AM2 = "K17" +AO2 = "K18" +AQ2 = "K19" +AS2 = "K20" +AU2 = "K21" +AW2 = "K22" +AY2 = "K23" +CT2 = "K24" +CV2 = "K25" +BC2 = "K26" +BE2 = "K27" +BG2 = "K28" +BI2 = "K29" +BK2 = "K30" +BM2 = "K31" +BO2 = "K32" +BQ2 = "K33" +BS2 = "K34" +BU2 = "K35" +BW2 = "K36" +BY2 = "K37" +CA2 = "K38" +CC2 = "K39" +CE2 = "K40" +CG2 = "K41" +CI2 = "K42" +CK2 = "K43" +CL3 = "K44" +CM3 = "K45" +CN3 = "K46" +1A2 = "K47" +CR = "K48" + +; 2051 - Passif +[1] +DA = "I8" +DB = "I9" +DC = "I10" +DD = "I11" +DE = "I12" +DF = "I13" +DG = "I14" +DH = "I15" +DI = "I16" +DJ = "I17" +DK = "I18" +DL = "I19" +DM = "I20" +DN = "I21" +DO = "I22" +DP = "I23" +DQ = "I24" +DR = "I25" +DS = "I26" +DT = "I27" +DU = "I28" +DV = "I29" +DW = "I30" +DX = "I31" +DY = "I32" +DZ = "I33" +EA = "I34" +EB = "I35" +EC = "I36" +ED = "I37" +EE = "I38" +1B = "I39" +1C = "I40" +1D = "I41" +1E = "I42" +EF = "I43" +EG = "I44" +EH = "I45" +; passif dont +DA0 = "F8" +EK = "G10" +B1 = "G13" +EJ = "G14" +EI = "G29" +; passif N-1 +DA1 = "J8" +DB1 = "J9" +DC1 = "J10" +DD1 = "J11" +DE1 = "J12" +DF1 = "J13" +DG1 = "J14" +DH1 = "J15" +DI1 = "J16" +DJ1 = "J17" +DK1 = "J18" +DL1 = "J19" +DM1 = "J20" +DN1 = "J21" +DO1 = "J22" +DP1 = "J23" +DQ1 = "J24" +DR1 = "J25" +DS1 = "J26" +DT1 = "J27" +DU1 = "J28" +DV1 = "J29" +DW1 = "J30" +DX1 = "J31" +DY1 = "J32" +DZ1 = "J33" +EA1 = "J34" +EB1 = "J35" +EC1 = "J36" +ED1 = "J37" +EE1 = "J38" +1B1 = "J39" +1C1 = "J40" +1D1 = "J41" +1E1 = "J42" +EF1 = "J43" +EG1 = "J44" +EH1 = "J45" + +; 2052 - Compte de résultat +[2] +FA = "E8" +FB = "G8" +FC = "I8" +FD = "E9" +FE = "G9" +FF = "I9" +FG = "E10" +FH = "G10" +FI = "I10" +FJ = "E11" +FK = "G11" +FL = "I11" +FM = "I12" +FN = "I13" +FO = "I14" +FP = "I15" +FQ = "I16" +FR = "I17" +FS = "I18" +FT = "I19" +FU = "I20" +FV = "I21" +FW = "I22" +FX = "I23" +FY = "I24" +FZ = "I25" +GA = "I26" +GB = "I27" +GC = "I28" +GD = "I29" +GE = "I30" +;AZ = "" +GF = "I31" +GG = "I32" +GH = "I33" +GI = "I34" +GJ = "I35" +GK = "I36" +GL = "I37" +GM = "I38" +GN = "I39" +GO = "I40" +GP = "I41" +GQ = "I42" +GR = "I43" +GS = "I44" +GT = "I45" +GU = "I46" +GV = "I47" +GW = "I48" +; cdr année N-1 +FC1 = "J8" +FF1 = "J9" +FI1 = "J10" +FL1 = "J11" +FM1 = "J12" +FN1 = "J13" +FO1 = "J14" +FP1 = "J15" +FQ1 = "J16" +FR1 = "J17" +FS1 = "J18" +FT1 = "J19" +FU1 = "J20" +FV1 = "J21" +FW1 = "J22" +FX1 = "J23" +FY1 = "J24" +FZ1 = "J25" +GA1 = "J26" +GB1 = "J27" +GC1 = "J28" +GD1 = "J29" +GE1 = "J30" +GF1 = "J31" +GG1 = "J32" +GH1 = "J33" +GI1 = "J34" +GJ1 = "J35" +GK1 = "J36" +GL1 = "J37" +GM1 = "J38" +GN1 = "J39" +GO1 = "J40" +GP1 = "J41" +GQ1 = "J42" +GR1 = "J43" +GS1 = "J44" +GT1 = "J45" +GU1 = "J46" +GV1 = "J47" +GW1 = "J48" + +; 2053 - Compte de résultat (suite) +[3] +HA = "J7" +HB = "J8" +HC = "J9" +HD = "J10" +HE = "J11" +HF = "J12" +HG = "J13" +HH = "J14" +HI = "J15" +HJ = "J16" +HK = "J17" +HL = "J18" +HM = "J19" +HN = "J20" +HO = "J21" +HY = "J22" +1G = "J23" +HP = "J24" +HQ = "J25" +1H = "J26" +1J = "J27" +IK = "J28" +HX = "J29" +A1 = "J30" +A2 = "J31" +A3 = "J32" +A4 = "J33" +A6 = "E34" +A9 = "H34" +; renvois 7 +D3B = "J37" +D3E = "J38" +D3H = "J39" +D3L = "J40" +D3P = "J41" +; renvoi 8 +D7B = "J44" +D7E = "J45" +D7H = "J46" +D7L = "J47" +D7P = "J48" +; cdr suite N-1 +HA1 = "K7" +HB1 = "K8" +HC1 = "K9" +HD1 = "K10" +HE1 = "K11" +HF1 = "K12" +HG1 = "K13" +HH1 = "K14" +HI1 = "K15" +HJ1 = "K16" +HK1 = "K17" +HL1 = "K18" +HM1 = "K19" +HN1 = "K20" +HO1 = "K21" +HY1 = "K22" +1G1 = "K23" +HP1 = "K24" +HQ1 = "K25" +1H1 = "K26" +1J1 = "K27" +IK1 = "K28" +HX1 = "K29" +A11 = "K30" +A21 = "K31" +A31 = "K32" +A41 = "K33" +; renvois 7 +D3C = "K37" +D3F = "K38" +D3J = "K39" +D3M = "K40" +D3R = "K41" +; renvoi 8 +D7C = "K44" +D7F = "K45" +D7J = "K46" +D7M = "K47" +D7R = "K48" + +; 2054 - Annexe 5 Immobilisations +[4] +; immo brutes +KA = "H7" +KD = "H8" +KG = "H9" +KJ = "H10" +KM = "H11" +KP = "H12" +KS = "H13" +KV = "H14" +KY = "H15" +LB = "H16" +LE = "H17" +LH = "H18" +LK = "H19" +LN = "H20" +8G = "H21" +8U = "H22" +1P = "H23" +1T = "H24" +LQ = "H25" +0G = "H26" +; immo augm. réévaluation +KB = "J7" +KE = "J8" +KH = "J9" +KK = "J10" +KN = "J11" +KQ = "J12" +KT = "J13" +KW = "J14" +KZ = "J15" +LC = "J16" +LF = "J17" +LI = "J18" +LL = "J19" +LO = "J20" +8M = "J21" +8V = "J22" +1R = "J23" +1U = "J24" +LR = "J25" +0H = "J26" +; immo augm. acqui. +KC = "L7" +KF = "L8" +KI = "L9" +KL = "L10" +KO = "L11" +KR = "L12" +KU = "L13" +KX = "L14" +LA = "L15" +LD = "L16" +LG = "L17" +LJ = "L18" +LM = "L19" +LP = "L20" +8T = "L21" +8W = "L22" +1S = "L23" +1V = "L24" +LS = "L25" +0J = "L26" +; dimin. par vir. +NL = "F29" +N0 = "F30" +IP = "F31" +IQ = "F32" +IR = "F33" +IS = "F34" +IT = "F35" +IU = "F36" +IV = "F37" +IW = "F38" +IX = "F39" +MY = "F40" +NC = "F41" +NN = "F42" +IZ = "F43" +I0 = "F44" +I1 = "F45" +I2 = "F46" +NM = "F47" +NP = "F48" +; dimin. par cession. +LT = "H29" +LV = "H30" +LX = "H31" +MA = "H32" +MD = "H33" +MG = "H34" +MJ = "H35" +MM = "H36" +MP = "H37" +MS = "H38" +MV = "H39" +MZ = "H40" +ND = "H41" +NG = "H42" +0U = "H43" +0X = "H44" +2B = "H45" +2E = "H46" +NJ = "H47" +0K = "H48" +; immo. fin exercice +LU = "J29" +LW = "J30" +LY = "J31" +MB = "J32" +ME = "J33" +MH = "J34" +MK = "J35" +MN = "J36" +MQ = "J37" +MT = "J38" +MW = "J39" +NA = "J40" +NE = "J41" +NH = "J42" +0V = "J43" +0Y = "J44" +2C = "J45" +2F = "J46" +NK = "J47" +0L = "J48" +1W = "L29" +1X = "L30" +LZ = "L31" +MC = "L32" +MF = "L33" +MI = "L34" +ML = "L35" +MO = "L36" +MR = "L37" +MU = "L38" +MX = "L39" +NB = "L40" +NF = "L41" +NI = "L42" +0W = "L43" +0Z = "L44" +2D = "L45" +2G = "L46" +2H = "L47" +0M = "L48" + +; 2055 - Annexe 6 Ammortissements +[5] +; ammo début exo +PA = "G7" +PE = "G8" +PI = "G9" +PM = "G10" +PR = "G11" +PV = "G12" +PZ = "G13" +QD = "G14" +QH = "G15" +QL = "G16" +QP = "G17" +QU = "G18" +0N = "G19" +; ammo augm. dotations +PB = "I7" +PF = "I8" +PJ = "I9" +PN = "I10" +PS = "I11" +PW = "I12" +QA = "I13" +QE = "I14" +QI = "I15" +QM = "I16" +QR = "I17" +QV = "I18" +0P = "I19" +; ammo dimin. +PC = "K7" +PG = "K8" +PK = "K9" +PO = "K10" +PT = "K11" +PX = "K12" +QB = "K13" +QF = "K14" +QJ = "K15" +QN = "K16" +QS = "K17" +QW = "K18" +0Q = "K19" +; ammo mt fin exo +PD = "M7" +PH = "M8" +PL = "M9" +PQ = "M10" +PU = "M11" +PY = "M12" +QC = "M13" +QG = "M14" +QK = "M15" +QO = "M16" +QT = "M17" +QX = "M18" +0R = "M19" +; cadre B amort. linéaires +QY = "E22" +QZ = "E23" +RA = "E24" +RD = "E25" +RG = "E26" +RJ = "E27" +RM = "E28" +RP = "E29" +RS = "E30" +RV = "E31" +RY = "E32" +SB = "E33" +SG = "E34" +; cadre B amort. deg. +2J = "G22" +2N = "G23" +RB = "G24" +RE = "G25" +RH = "G26" +RK = "G27" +RN = "G28" +RQ = "G29" +RT = "G30" +RW = "G31" +RZ = "G32" +SC = "G33" +SH = "G34" +; cadre B amort. exceptio. +2K = "I22" +2P = "I23" +RC = "I24" +RF = "I25" +RI = "I26" +RL = "I27" +RO = "I28" +RR = "I29" +RU = "I30" +RX = "I31" +SA = "I32" +SD = "I33" +SJ = "I34" +; cadre C dotations +2L = "K22" +2R = "K23" +2T = "K24" +2V = "K25" +2X = "K26" +2Z = "K27" +3B = "K28" +3D = "K29" +3F = "K30" +3H = "K31" +3K = "K32" +SE = "K33" +SK = "K34" +; cadre C reprises +2M = "M22" +2S = "M23" +2U = "M24" +2W = "M25" +2Y = "M26" +3A = "M27" +3C = "M28" +3E = "M29" +3G = "M30" +3J = "M31" +3L = "M32" +SF = "M33" +SL = "M34" +; cadre D +SM0 = "G37" +SP0 = "G38" +SI = "I37" +SO = "I38" +SM = "K37" +SP = "K38" +SN = "M37" +SR = "M38" + +; 2056 - Provisions +[6] +; début exo. +3T = "F5" +3U = "F6" +3V = "F7" +3W = "F8" +3X = "F9" +IA = "F10" +IE = "F11" +IJ = "F12" +3Y = "F13" +3Z = "F14" +4A = "F15" +4E = "F16" +4J = "F17" +4N = "F18" +4T = "F19" +4X = "F20" +5B = "F21" +5F = "F22" +5L = "F23" +5R = "F24" +5V = "F25" +5Z = "F26" +6A = "F27" +6E = "F28" +O2 = "F29" +9U = "F30" +06 = "F31" +6N = "F32" +6T = "F33" +6X = "F34" +7B = "F35" +7C = "F36" +; augm. début exo +TA = "H5" +TD = "H6" +TG = "H7" +TJ = "H8" +TM = "H9" +IB = "H10" +IF = "H11" +IK = "H12" +TP = "H13" +TS = "H14" +4B = "H15" +4F = "H16" +4K = "H17" +4P = "H18" +4U = "H19" +4Y = "H20" +5C = "H21" +5H = "H22" +5M = "H23" +5S = "H24" +5W = "H25" +TV = "H26" +6B = "H27" +6F = "H28" +03 = "H29" +9V = "H30" +07 = "H31" +6P = "H32" +6U = "H33" +6Y = "H34" +TY = "H35" +UB = "H36" +UE = "H37" +UG = "H38" +UJ = "H39" +; dimin. reprise début ex. +TB = "J5" +TE = "J6" +TH = "J7" +TK = "J8" +TN = "J9" +IC = "J10" +IG = "J11" +IL = "J12" +TQ = "J13" +TT = "J14" +4C = "J15" +4G = "J16" +4L = "J17" +4R = "J18" +4V = "J19" +4Z = "J20" +5D = "J21" +5J = "J22" +5N = "J23" +5T = "J24" +5X = "J25" +TW = "J26" +6C = "J27" +6G = "J28" +04 = "J29" +9W = "J30" +08 = "J31" +6R = "J32" +6V = "J33" +6Z = "J34" +TZ = "J35" +UC = "J36" +UF = "J37" +UH = "J38" +UK = "J39" +; montant fin ex. +TC = "L5" +TF = "L6" +TI = "L7" +TL = "L8" +TO = "L9" +ID = "L10" +IH = "L11" +IM = "L12" +TR = "L13" +TU = "L14" +4D = "L15" +4H = "L16" +4M = "L17" +4S = "L18" +4W = "L19" +5A = "L20" +5E = "L21" +5K = "L22" +5P = "L23" +5U = "L24" +5Y = "L25" +TX = "L26" +6D = "L27" +6H = "L28" +05 = "L29" +9X = "L30" +09 = "L31" +6S = "L32" +6W = "L33" +7A = "L34" +UA = "L35" +UD = "L36" +10 = "L40" + +;2057 +[7] +; cadre A mont. bruts +UL = "I6" +UP = "I7" +UT = "I8" +VA = "I9" +UX = "I10" +UQ = "G11" +UU = "I11" +UY = "I12" +UZ = "I13" +VM = "I14" +VB = "I15" +VN = "I16" +VP = "I17" +VC = "I18" +VR = "I19" +VS = "I20" +VT = "I21" +VD = "I22" +VE = "I23" +VF = "I24" +; cadre A à 1 an maxi +UM = "L6" +UR = "L7" +UV = "L8" +VA1 = "L9" +UX1 = "L10" +UU1 = "L11" +UY1 = "L12" +UZ1 = "L13" +VM1 = "L14" +VB1 = "L15" +VN1 = "L16" +VP1 = "L17" +VC1 = "L18" +VR1 = "L19" +VS1 = "L20" +VU = "L21" +VD1 = "L22" +VE1 = "L23" +VF1 = "L24" +; cadre A à + d'un an +UN = "L6" +US = "L7" +UW = "L8" +VA2 = "L9" +UX2 = "L10" +UU2 = "L11" +UY2 = "L12" +UZ2 = "L13" +VM2 = "L14" +VB2 = "L15" +VN2 = "L16" +VP2 = "L17" +VC2 = "L18" +VR2 = "L19" +VS2 = "L20" +VV = "L21" +VD2 = "L22" +VE2 = "L23" +VF2 = "L24" +; cadre B mont brut +7Y = "G26" +7Z = "G27" +VG = "G28" +VH = "G29" +8A = "G30" +8B = "G31" +8C = "G32" +8D = "G33" +8E = "G34" +VW = "G35" +VX = "G36" +VQ = "G37" +8J = "G38" +VI = "G39" +8K = "G40" +SZ = "G41" +8L = "G42" +VY = "G43" +VJ = "G44" +VK = "G45" +; cadre B à 1 an +7Y1 = "J26" +7Z1 = "J27" +VG1 = "J28" +VH1 = "J29" +8A1 = "J30" +8B1 = "J31" +8C1 = "J32" +8D1 = "J33" +8E1 = "J34" +VW1 = "J35" +VX1 = "J36" +VQ1 = "J37" +8J1 = "J38" +VI1 = "J39" +8K1 = "J40" +SZ1 = "J41" +8L1 = "J42" +VZ = "J43" +; cadre B + d'un an +7Y2 = "L26" +7Z2 = "L27" +VG2 = "L28" +VH2 = "L29" +8A2 = "L30" +8B2 = "L31" +8C2 = "L32" +8D2 = "L33" +8E2 = "L34" +VW2 = "L35" +VX2 = "L36" +VQ2 = "L37" +8J2 = "L38" +VI2 = "L39" +8K2 = "L40" +SZ2 = "L41" +8L2 = "L42" +VZ1 = "L43" +; cadre B + de 5 ans +7Y3 = "N26" +7Z3 = "N27" +VG3 = "N28" +VH3 = "N29" +8A3 = "N30" +8B3 = "N31" +8C3 = "N32" +8D3 = "N33" +8E3 = "N34" +VW3 = "N35" +VX3 = "N36" +VQ3 = "N37" +8J3 = "N38" +VI3 = "N39" +8K3 = "N40" +SZ3 = "N41" +8L3 = "N42" +VZ2 = "N43" +VL = "N44" + +;2058C +[8] +; aff. résultat +0C = "T6" +0D = "T7" +0E = "T10" +0F = "T11" +ZB = "T12" +ZC = "T13" +ZD = "T14" +A5 = "T15" +ZE = "T16" +ZF = "T17" +ZG = "T18" +ZH = "T19" +; rens. divers N +YQ = "O22" +YR = "O23" +YS = "O24" +YT = "O25" +XQ = "O26" +YU = "O27" +SS = "O28" +YV = "O29" +ST = "O30" +ZJ = "O31" +YW = "O32" +ZS = "J33" +9Z = "O33" +YX = "O35" +YY = "O36" +YZ = "O37" +ZA = "O38" +0B = "O39" +0S = "O40" +; rens. divers N-1 +YQ1 = "S22" +YR1 = "S23" +YS1 = "S24" +YT1 = "S25" +XQ1 = "S26" +YU1 = "S27" +SS1 = "S28" +YV1 = "S29" +ST1 = "S30" +ZJ1 = "S31" +YW1 = "S32" +9Z1 = "S33" +YX1 = "S35" +YY1 = "S36" +YZ1 = "S37" +ZA1 = "S38" +0B1 = "S39" +0S1 = "S40" +; groupe +JA = "G41" +JD = "G42" +JB = "L41" +JE = "L42" +JC = "T41" +JF = "T42" +JG = "I43" +XP = "I44" +JH = "L43" +JJ = "Q43" +YP = "P45" +ZK = "P46" +ZR = "T47" \ No newline at end of file diff --git a/library/Scores/Finance/Liasse/models/liasse_2050.xls b/library/Scores/Finance/Liasse/models/liasse_2050.xls new file mode 100644 index 0000000..c41e271 Binary files /dev/null and b/library/Scores/Finance/Liasse/models/liasse_2050.xls differ diff --git a/library/Scores/Finance/Liasse/models/liasse_2050_ori.xls b/library/Scores/Finance/Liasse/models/liasse_2050_ori.xls new file mode 100644 index 0000000..3b094b2 Binary files /dev/null and b/library/Scores/Finance/Liasse/models/liasse_2050_ori.xls differ diff --git a/library/Scores/Finance/Ratios/Data.php b/library/Scores/Finance/Ratios/Data.php new file mode 100644 index 0000000..089582e --- /dev/null +++ b/library/Scores/Finance/Ratios/Data.php @@ -0,0 +1,362 @@ +RatiosSecteur->item)>0){ + foreach($ratios->RatiosSecteur->item as $item){ + foreach($item->liste->item as $ratiosItem){ + $this->ratiosSecteur[$item->annee][$ratiosItem->id] = $ratiosItem->val; + } + } + } + //Orgnaisation des informations des ratios + foreach($ratios->RatiosInfos->item as $item){ //@todo : protection + $this->ratiosInfos[$item->id] = $item; + } + + //Orgnaisation RatiosEntrep et RatiosEntrepEvol + if (count($ratios->BilansInfos->item)>0){ + foreach($ratios->BilansInfos->item as $item) + { + $typeBilan = $item->typeBilan; + if ($typeBilan == 'S') $typeBilan = 'N'; + + $this->bilansInfo[$typeBilan][$item->dateCloture] = $item; + foreach($item->RatiosEntrep->item as $ratiosItem){ + $this->ratiosEntrep[$typeBilan][$item->dateCloture][$ratiosItem->id] = $ratiosItem->val; + } + foreach($item->RatiosEntrepEvol->item as $ratiosItem){ + $this->ratiosEntrepEvol[$typeBilan][$item->dateCloture][$ratiosItem->id] = $ratiosItem->val; + } + //Comptage de bilans + $this->{'nbBilan'.$typeBilan}++; + } + } + } + + public function getNbBilan($type) + { + return $this->{'nbBilan'.$type}; + } + + /** + * Renvoi le ratio de l'entité + * @param string $type + * @param string $dateCloture + * @param string $id + */ + function dRatio($type, $dateCloture, $id){ + $ratio = $this->ratiosEntrep[$type][$dateCloture][$id]; + $return = ''; + $formatRatio = TRUE; + if ($ratio=='NS' || $ratio==0) { + $return.= 'NS'; + $formatRatio = FALSE; + }elseif(substr($ratio,0,1)=='<' ){ + $return.= '< '; + $ratio = substr($ratio,1)*1; + }elseif(substr($ratio,0,1)=='>'){ + $return.= '> '; + $ratio = substr($ratio,1)*1; + }elseif($ratio==NULL){ + $return.= '-'; + $formatRatio = FALSE; + } + + if($formatRatio == TRUE) { + if ( ($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)>0) ){ + $return.= number_format($ratio/1000, 0, '', ' ').' K€'; + }elseif (($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)<0)) { + $return.= number_format($ratio, 0, '', ' ').' €'; + }elseif (($this->ratiosInfos[$id]->unite=='Jours')) { + $return.= number_format($ratio, 0, '', ' ').' '.$this->ratiosInfos[$id]->unite; + }elseif (($this->ratiosInfos[$id]->unite=='AN')) { + $return.= round($ratio, 2).' '.$this->ratiosInfos[$id]->unite; + }elseif (($this->ratiosInfos[$id]->unite=='%')) { + $return.= round($ratio).' '.$this->ratiosInfos[$id]->unite; + }else{ + $return.= $ratio.' '.$this->ratiosInfos[$id]->unite; + } + } + return $return; + } + + /** + * Renvoi le ratio secteur + * @param string $dateCloture + * @param string $id + */ + function dSecteur($dateCloture, $id){ + $ratio = $this->ratiosSecteur[substr($dateCloture,0,4)][$id]; + $return = ''; + $formatRatio = TRUE; + if ($ratio=='NS') { + $return.= 'NS'; + $formatRatio = FALSE; + }elseif(substr($ratio,0,1)=='<' ){ + $return.= '< '; + $ratio = substr($ratio,1)*1; + }elseif(substr($ratio,0,1)=='>'){ + $return.= '> '; + $ratio = substr($ratio,1)*1; + }elseif($ratio==NULL){ + $return.= '-'; + $formatRatio = FALSE; + } + + if($formatRatio == TRUE) { + if ( ($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)>0) ){ + $return.= number_format($ratio/1000, 0, '', ' ').' K€'; + }elseif (($this->ratiosInfos[$id]->unite=='EUR') && ((abs($ratio)/1000)<0)) { + $return.= number_format($ratio, 0, '', ' ').' €'; + }elseif (($this->ratiosInfos[$id]->unite=='Jours')) { + $return.= number_format($ratio, 0, '', ' ').' '.$this->ratiosInfos[$id]->unite; + }elseif (($this->ratiosInfos[$id]->unite=='AN')) { + $return.= round($ratio, 2).' '.$this->ratiosInfos[$id]->unite; + }elseif (($this->ratiosInfos[$id]->unite=='%')) { + $return.= round($ratio).' '.$this->ratiosInfos[$id]->unite; + }else{ + $return.= $ratio.' '.$this->ratiosInfos[$id]->unite; + } + } + return $return; + } + + /** + * Renvoi la position de l'entité en comparant son ratio avec le ratio secteur + * Enter description here ... + * @param string $type + * @param string $dateCloture + * @param string $id + * @param string $compare + * @return string + */ + function dPosition($type, $dateCloture, $id, $compare) + { + $ratioS = $this->ratiosSecteur[substr($dateCloture,0,4)][$id]; + $ratioE = $this->ratiosEntrep[$type][$dateCloture][$id]; + $ecart = 1/100; + + if( $ratioS=='NS' || $ratioE=='NS' || $ratioS==NULL || $ratioE==NULL){ + $return = '-'; + }elseif($compare=='>'){ + if( $ratioE+$ecart > $ratioS ){ + $return = ''; + }elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){ + $return = '-'; + }else{ + $return = ''; + } + }elseif($compare=='<'){ + if($ratioE < $ratioS){ + $return = ''; + }elseif( ($ratioS-($ratioS*$ecart))<$ratioE && ($ratioS+($ratioS*$ecart))>$ratioE){ + $return = '-'; + }else{ + $return = ''; + } + } + return $return; + } + + /** + * Affiche l'évolution d'un ratio. + * @param string $type + * @param string $dateCloture + * @param string $id + */ + function dEvol($type, $dateCloture, $id){ + $ratio = $this->ratiosEntrepEvol[$type][$dateCloture][$id]; + if ($ratio=='NS') { + return 'NS'; + }elseif($ratio==NULL){ + return '-'; + }else{ + return $ratio.' %'; + } + } + + /** + * Enter description here ... + * @param unknown_type $type + * @param unknown_type $dateCloture + * @param unknown_type $id + * @param unknown_type $totalRatio + * @return string + */ + function dTotal($type, $dateCloture, $id, $totalRatio) + { + $ratio = isset($this->ratiosEntrep[$type][$dateCloture][$id]) ? + $this->ratiosEntrep[$type][$dateCloture][$id] : 0; + $total = isset($this->ratiosEntrep[$type][$dateCloture][$totalRatio]) ? + $this->ratiosEntrep[$type][$dateCloture][$totalRatio] : 0; + if($total!=0){ + return number_format($ratio*100/$total, 2); + }else{ + return '-'; + } + } + + /** + * Retourne le tableau pour l'affichage des graphiques d'évolution + * @param string $type + * @param string $id + */ + function dGraph($type, $id) + { + $evol = array(); + $bilansInfo = $this->bilansInfo[$type]; + ksort($bilansInfo); + foreach($bilansInfo as $item) { + $dateCloture = $item->dateCloture; + $div = 1; + $ratioE = $this->ratiosEntrep[$type][$dateCloture][$id]; + $ratioS = $this->ratiosSecteur[substr($dateCloture,0,4)][$id]; + if ( ($ratiosInfos[$nRatio]['unite']=='EUR') && ((abs($ratioE)/1000)>0) ){ + $unite = 'KEURO'; + $div = 1000; + }else{ + $unite = $this->ratiosInfos[$id]->unite; + } + //Données pour les graphiques évolutions + $data[] = array( + 'date' => $dateCloture, + 'entreprise' => (($ratioE!='NS') ? $ratioE/$div : 0 ), + 'secteur' => (($ratioS!='NS') ? $ratioS/$div : 0 ), + ); + } + $evol = array('data' => $data, 'unite' => $unite); + return $evol; + } + + /** + * Affiche le pourcentage d'un ratio par rapport au total. + * @param string $type + * @param string $dateCloture + * @param string $id + * @param string $totalRatio + * @return mixed + */ + function dPercent($type, $dateCloture, $id, $totalRatio){ + $ratio = $this->ratiosEntrep[$type][$dateCloture][$id]; + $totalRatio = $this->ratiosEntrep[$type][$dateCloture][$totalRatio]; + if ($ratio=='NS') { + $return = 'NS'; + }elseif($ratio==NULL){ + $return = '-'; + }else { + if ($totalRatio!=0 && $totalRatio!='NS'){ + $percent = $ratio*100/$totalRatio; + }else{ + $percent = 0; + } + if ($percent>=0 && $percent<10){ + $return = round($percent, 1); + } elseif ($percent>-10 && $percent<0) { + $return = round($percent, 1); + } else { + $return = round($percent, 0); + } + } + return $return; + } + + /** + * Retourne le pourcentage d'un ratio par rapport au total pour les graphiques + * @param string $type + * @param string $dateCloture + * @param string $id + * @param string $totalRatio + */ + function graphPercent($type, $dateCloture, $id, $totalRatio){ + $ratio = isset($this->ratiosEntrep[$type][$dateCloture][$id]) ? + $this->ratiosEntrep[$type][$dateCloture][$id] : 0; + $totalRatio = $this->ratiosEntrep[$type][$dateCloture][$totalRatio]; + if ( ($ratio!='NS' && $ratio!=NULL) && ($totalRatio!=0 && $totalRatio!='NS')){ + return $ratio*100/$totalRatio; + }else{ + return 0; + } + } + + /** + * Formatte le commentaire pour l'afficher dans l'infobulle. + * @param string $nRatios + * Identifiant du ratio + * @return string + */ + function wrapComment($nRatio){ + $text = $this->ratiosInfos[$nRatio]->commentaires; + $newtext = htmlentities($text, null, 'utf-8'); + $newtext = nl2br($newtext); + return $newtext; + } + + public function getBilansInfo($type) + { + return $this->bilansInfo[$type]; + } + + public function getRatiosInfos($id) { + return $this->ratiosInfos[$id]; + } + + public function getRatiosEntrep($type, $dateCloture, $id) { + return $this->ratiosEntrep[$type][$dateCloture][$id]; + } + + public function getRatiosEntrepEvol($type, $dateCloture, $id) { + return $this->ratiosEntrepEvol[$type][$dateCloture][$id]; + } + + public function getRatiosSecteur($annee, $id) { + return $this->ratiosSecteur[substr($annee,0,4)][$id]; + } + + public function getTableRatiosInfos() + { + return $this->ratiosInfos; + } + + public function getTableRatiosSecteur() + { + return $this->ratiosSecteur; + } + + public function getTableRatiosEntrep($type) + { + if (array_key_exists($type, $this->ratiosEntrep)){ + return $this->ratiosEntrep[$type]; + } + return false; + } + + public function getTableRatiosEntrepEvol($type) + { + if (array_key_exists($type, $this->ratiosEntrepEvol)){ + return $this->ratiosEntrepEvol[$type]; + } + return false; + } + + private function ignoreType($type, $typeDelete) { + foreach ($typeDelete as $t) { + if ($t == $type) return (false); + } + return (true); + } +} \ No newline at end of file diff --git a/library/Scores/Finance/Ratios/Graph.php b/library/Scores/Finance/Ratios/Graph.php new file mode 100644 index 0000000..49a5fc3 --- /dev/null +++ b/library/Scores/Finance/Ratios/Graph.php @@ -0,0 +1,384 @@ +path = $c->profil->path->pages . '/imgcache/'; + $this->siret = $siret; + $this->id = $id; + } + + /** + * Enregistre le graphique bilan passif sous forme d'image. + * @param array $data + * Tableau structuré des données + * @param string $filename + * Le nom de fichier généré + * @return string + * Retourne un message d'erreur ou le code HTML d'affichage. + */ + public function bilansgraphpassif($data, $typeBilan, $dateCloture) + { + $file = 'bilansgraphpassif-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png'; + $cache = new Cache(); + if( $cache->exist($this->path.$file) ){ + $return = $file; + } else { + $w = 665; + $h = 210; + $x = round($w/2); + $y = round($h/2); + $radius = 90; + $c = new PieChart($w, $h); + $labels = array('Fonds propres', + 'Provisions Risques', + 'Compte Courant', + 'Dettes Financières', + 'Dettes Fournisseurs', + 'Dettes fiscales', + 'Autres Dettes', + 'Trésorerie Passive'); + $textBoxObj = $c->addTitle("Composition du passif", "timesbi.ttf", 15); + $c->setPieSize($x, $y, $radius); + $c->setLabelLayout(SideLayout); + $t = $c->setLabelStyle(); + $t->setBackground(SameAsMainColor, Transparent, glassEffect()); + $t->setRoundedCorners(5); + $c->setLineColor(SameAsMainColor, 0x000000); + $c->setStartAngle(135); + $c->setLabelFormat("<*block,valign=absmiddle*>{label} <*font=timesbi.ttf,size=0*>({percent|0}%)"); + $c->setData($data, $labels); + $c->set3D(20); + if($c->makeChart($this->path.$file) === TRUE){ + $return = ''; + }else{ + $return = false; + } + } + return $return; + } + + /** + * Enregistre le graphique bilan SIG sous forme d'image. + */ + public function bilansgraphsig($data, $typeBilan, $dateCloture) + { + $file = 'bilansgraphsig-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png'; + $cache = new Cache(); + if( $cache->exist($this->path.$file) ){ + $return = $file; + } else { + $w = 665; + $h = 210; + $x = round($w/2); + $y = round($h/2); + $radius=70; + $c = new PieChart($w, $h); + $labels = array('Achats de marchandises.', + 'Autres achats externes', + 'Charges de fonctionnement', + 'Amortissement et provisions', + 'Perte financière', + 'Impôts sociétés', + 'RÉSULTAT NET', + ); + $textBoxObj = $c->addTitle("Solde Intermédiaire de Gestion", "timesbi.ttf", 15); + $c->setPieSize($x, $y, $radius); + $c->setLabelLayout(SideLayout); + $t = $c->setLabelStyle(); + $t->setBackground(SameAsMainColor, Transparent, glassEffect()); + $t->setRoundedCorners(5); + $c->setLineColor(SameAsMainColor, 0x000000); + $c->setLabelFormat("<*block,valign=absmiddle*>{label} <*font=arial.ttf,size=0*>({percent|0}%)"); + $c->setStartAngle(135); + $c->setData($data, $labels); + $c->set3D(20); + + if($c->makeChart($this->path.$file) === TRUE){ + $return = $file; + }else{ + $return = false; + } + } + return $return; + } + + /** + * Enregistre le graphique bilan actif sous forme d'image. + * @param array $data + * Tableau structuré des données + * @return mixed + */ + public function bilansgraphactif($data, $typeBilan, $dateCloture) + { + $file = 'bilansgraphactif-'.$this->siret.'-'.$this->id.'-'.$typeBilan.$dateCloture.'.png'; + $cache = new Cache(); + if( $cache->exist($this->path.$file) ){ + $return = $file; + } else { + $w = 665; + $h = 210; + $x = round($w/2); + $y = round($h/2); + $radius = 90; + $c = new PieChart($w, $h); + $labels = array('Immo. incorporelles', + 'Immo. corporelles', + 'Immo. financières', + 'Stock et encours', + 'Créances Clients', + 'Autres créances', + 'Trésorerie Active'); + $textBoxObj = $c->addTitle("Composition de l'actif", "timesbi.ttf", 15); + $c->setPieSize($x, $y, $radius); + $c->setLabelLayout(SideLayout); + $t = $c->setLabelStyle(); + $t->setBackground(SameAsMainColor, Transparent, glassEffect()); + $t->setRoundedCorners(5); + # Set the border color of the sector the same color as the fill color. Set the line # color of the join line to black (0x0) + $c->setLineColor(SameAsMainColor, 0x000000); + $c->setStartAngle(135); + $c->setLabelFormat("<*block,valign=absmiddle*>{label} <*font=timesbi.ttf,size=0*>({percent|0}%)"); + $c->setData($data, $labels); + $c->set3D(20); + if($c->makeChart($this->path.$file) === TRUE){ + $return = $file; + }else{ + $return = false; + } + } + return $return; + } + + + public function ratiosgraph($ratio, $data) + { + $file = 'ratiosgraph-'.$this->siret.'-'.$this->id.'-'.$ratio.'.png'; + $cache = new Cache(); + if( $cache->exist($this->path.$file) ){ + $return = $file; + }else{ + if(count($data)<=1){ + $return = 0; + }else{ + $labelsX = array(); + $labelsY = array(); + $dataX1 = array(); + $dataX2 = array(); + foreach($data['data'] as $value){ + $dataX1[] = $value['entreprise']; + $dataX2[] = $value['secteur']; + $labelsX[] = substr($value['date'],0,4); + } + $i=-100; while($i>100){ + $labelsY[] = $i; + } + $c = new XYChart(350, 250); + $c->setPlotArea(70, 10, 280, 200); + $c->yAxis->setTitle($data['unite']); + $c->xAxis->setTitle("Années"); + $c->xAxis->setWidth(2); + $c->yAxis->setWidth(2); + $legendObj = $c->addLegend(50, 10, false, "times.ttf", 9); + $legendObj->setBackground(Transparent); + $c->addLineLayer($dataX1, 0x0000ff, "Entreprise"); + $c->addLineLayer($dataX2, 0x008C00, "Secteur"); + $c->yAxis->setLabels($labelsY); + $c->yAxis->setLabelStep(10); + $c->xAxis->setLabels($labelsX); + if($c->makeChart($this->path.$file) === TRUE){ + $return = $file; + } + else{ $return = FALSE; + } + } + } + return $return; + } + + public function syntheseGraphEvol($data, $ratio, $unite) + { + $file = 'syntheseEvol-'.$this->siret.'-'.$this->id.'-'.$ratio.'.png'; + $cache = new Cache(); + if( $cache->exist($this->path.$file) ){ + $return = $file; + } else { + $unite = !empty($unite) ? $unite : 'KEUROS'; + $labelsX = array(); + $labelsY = array(); + $dataX = array(); + if(count($data)<=1){ + $return = 0; + } else { + foreach($data as $value){ + $dataX[] = $value['value']; + $labelsX[] = substr($value['date'],0,4); + } + $i=-100; + while($i>100){ + $labelsY[] = $i; + } + # Create a XYChart object of size 250 x 250 pixels + $c = new XYChart(400, 250); + $c->setPlotArea(70, 10, 280, 200); + $c->yAxis->setTitle($unite); + $c->xAxis->setTitle("Années"); + $c->xAxis->setWidth(2); + $c->yAxis->setWidth(2); + $c->addLineLayer($dataX); + # Set the labels. + $c->yAxis->setLabels($labelsY); + $c->yAxis->setLabelStep(10); + $c->xAxis->setLabels($labelsX); + if($c->makeChart($this->path.$file) === TRUE){ + $return = $file; + } else { + $return = false; + } + } + } + return $return; + } + + public function syntheseGraphLineCompare($data, $typeBilan) + { + $file = 'synthese-linecompare-'.$this->siret.'-'.$this->id.'-'.$typeBilan.'.png'; + $cache = new Cache(); + + if( $cache->exist($this->path.$file) ){ + $return = $this->path.$file; + } else { + //Tri des données par date et par ordre croissant + foreach ($data as $key => $row) { + $date[$key] = $row['date']; + } + array_multisort($date, SORT_ASC, $data); + + //Définition des valeurs pour le graph + $dataBFR = array(); + $dataFR = array(); + $dataCA = array(); + $i=0; + //Parcourir les années + foreach($data as $item){ + $anneeFin = substr($item['date'],0,4); + $moisFin = substr($item['date'],4,2); + $jourFin = substr($item['date'],6,2); + //Calcul de la date de début + $dateDebut = date("Ymd", mktime(0, 0, 0, $moisFin-$item['duree'], $jourFin, $anneeFin)); + $anneeDebut = substr($dateDebut,0,4); + $moisDebut = substr($dateDebut,4,2); + $jourDebut = substr($dateDebut,6,2); + //Affectation des abscisses + $dataBFR['x'][$i] = $dataFR['x'][$i] = $dataCA['x'][$i] = $dataEBE['x'][$i] = chartTime((int)$anneeDebut, (int)$moisDebut, (int)$jourDebut); + $dataBFR['x'][$i+1] = $dataFR['x'][$i+1] = $dataCA['x'][$i+1] = $dataEBE['x'][$i+1] = chartTime((int)$anneeFin, (int)$moisFin, (int)$jourFin); + //Affectation des ordonnées + $dataBFR['y'][$i] = $dataBFR['y'][$i+1] = $item['r236']; + $dataFR['y'][$i] = $dataFR['y'][$i+1] = $item['r235']; + $dataCA['y'][$i] = $dataCA['y'][$i+1] = $item['r6']; + $dataEBE['y'][$i] = $dataEBE['y'][$i+1] = $item['r146']; + $i+=2; + } + + $c = new XYChart(665, 350, 0xcccccc, 0x000000, 1); + $c->addTitle("Synthèse *", "timesbi.ttf", 15, 0x000000); + $c->addText(60, 320, "* Elements financier rapportés à 12 mois" ); + $c->setPlotArea(70, 80, 500, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc); + $c->yAxis->setTitle("KEUROS","timesbi.ttf",10); + $c->xAxis->setTitle( "<*block,valign=absmiddle*>Années<*/*>"); + $c->xAxis->setWidth(2); + $c->yAxis->setWidth(2); + + // Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9 pts + // Arial Bold font. Set the background and border color to Transparent. + $legendObj = $c->addLegend(55, 30, false, "times.ttf", 9); + $legendObj->setBackground(Transparent); + + // Add a blue (0000ff) step line layer to the chart and set the line width to 2 pixels + $layer1 = $c->addStepLineLayer($dataFR['y'], 0x0000ff, "FONDS DE ROULEMENT"); + $layer1->setXData($dataFR['x']); + $layer1->setLineWidth(2); + + // Add a red (ff0000) step line layer to the chart and set the line width to 2 pixels + $layer0 = $c->addStepLineLayer($dataBFR['y'], 0xff0000, "BESOIN EN FONDS DE ROULEMENT"); + $layer0->setXData($dataBFR['x']); + $layer0->setLineWidth(2); + + // Add a green (00ff00) step line layer to the chart and set the line width to 2 pixels + $layer2 = $c->addStepLineLayer($dataCA['y'], 0x00ff00, "CHIFFRE D'AFFAIRES"); + $layer2->setXData($dataCA['x']); + $layer2->setLineWidth(2); + + // Add a black (000000) step line layer style dash to the chart and set the line width to 2 pixels + $layer3 = $c->addStepLineLayer($dataEBE['y'], $c->dashLineColor(0x000000, DashLine), "EXCEDENT BRUT D'EXPLOITATION"); + $layer3->setXData($dataEBE['x']); + $layer3->setLineWidth(2); + + # If the FR line gets above the BFR line, color to area between the lines red (ff0000) + $c->addInterLineLayer($layer0->getLine(0), $layer1->getLine(0), 0xff0000, Transparent); + + # If the FR line gets below the lower BFR line, color to area between the lines light green (8099ff99) + $c->addInterLineLayer($layer0->getLine(0), $layer1->getLine(0), Transparent, 0x8044ff44); + + if($c->makeChart($this->path.$file) === TRUE){ + $return = $this->path.$file; + }else{ + $return = false; + } + } + return $return; + } + + /** + * Génére l'histogramme flux de trésorerie + * @param array $labels + * @param array $data + * @param string $typeBilan + * @return boolean|string + */ + function flux($labels, $data, $typeBilan) + { + $couleur = array(0xff8080, 0x80ff80, 0x8080ff); + $file = 'flux-'.$this->siret.'-'.$this->id.'-'.$typeBilan.'.png'; + $cache = new Cache(); + + if( $cache->exist($this->path.$file) ){ + $return = $this->path.$file; + } else { + if (count($data)<=1) { + $return = 0; + } else { + + $c = new XYChart(600, 300); + $c->setPlotArea(100, 70, 300, 200); + $legendObj = $c->addLegend(100, 20, false, "times.ttf", 9); + $legendObj->setBackground(Transparent); + $layer = $c->addBarLayer2(Stack); + $layer->setBorderColor(Transparent, softLighting(Left)); + $c->xAxis->setLabels($labels); + $cptCouleur = 0; + foreach ( $data as $d ) { + $layer->addDataSet($d['values'], $couleur[$cptCouleur], $d['titre']); + $cptCouleur++; + } + $layer->setBarGap(0.2, 0); + $c->yAxis->setAutoScale(0.2); + if( $c->makeChart($this->path.$file) === TRUE ){ + $return = $file; + } + else{ $return = FALSE; + } + } + } + return $return; + } + +} \ No newline at end of file diff --git a/library/Scores/Mobile/Detect.php b/library/Scores/Mobile/Detect.php new file mode 100644 index 0000000..e599f17 --- /dev/null +++ b/library/Scores/Mobile/Detect.php @@ -0,0 +1,23 @@ +data->Ratios->siret = $infos->Identite->siret; $this->data->Ratios->id = $infos->Identite->id; @@ -280,7 +278,7 @@ class Scores_Partner_Report $tabRatio = array( $ratio => $tabRatio[$ratio] ); } - $ratiosData = new RatiosData($infos->Ratios); + $ratiosData = new Scores_Finance_Ratios_Data($infos->Ratios); $nbBilanN = $ratiosData->getNbBilan('N'); $nbBilanC = $ratiosData->getNbBilan('C'); @@ -292,7 +290,7 @@ class Scores_Partner_Report if ($nbBilanN!=0 || $nbBilanC!=0) { //Génération Graphique evolution - $ratiosGraph = new RatiosGraph($this->siret, $this->id); + $ratiosGraph = new Scores_Finance_Ratios_Graph($siren); $infosAnnee = $ratiosData->getBilansInfo($typeBilan); $annees = array_keys($infosAnnee); @@ -331,7 +329,7 @@ class Scores_Partner_Report //Bilans $typeBilan = 'N'; $this->data->Bilans->typeBilan = $typeBilan; - $ratiosData = new RatiosData($infos->Ratios); + $ratiosData = new Scores_Finance_Ratios_Data($infos->Ratios); $nbBilanN = $ratiosData->getNbBilan('N'); $nbBilanC = $ratiosData->getNbBilan('C'); @@ -348,7 +346,7 @@ class Scores_Partner_Report $infosAnnee = $ratiosData->getBilansInfo($typeBilan); $annees = array_keys($infosAnnee); - $ratiosGraph = new RatiosGraph($this->siret, $this->id); + $ratiosGraph = new Scores_Finance_Ratios_Graph($siren); $tabRatioActif = array( 'r59' => array( 'titre' => 'Actif Immobilisé Net', 'class' => 'subhead'), @@ -546,7 +544,7 @@ class Scores_Partner_Report } //Formattage des données - $ratiosData = new RatiosData($infos->Ratios); + $ratiosData = new Scores_Finance_Ratios_Data($infos->Ratios); $nbBilanN = $ratiosData->getNbBilan('N'); $nbBilanC = $ratiosData->getNbBilan('C'); @@ -567,7 +565,7 @@ class Scores_Partner_Report sort($annees); if (count($annees)>1){ //Générer les différents graphiques d'évolutions - $ratiosGraph = new RatiosGraph($this->siret, $this->id); + $ratiosGraph = new Scores_Finance_Ratios_Graph($siren); $tabGraphEvol = array(); foreach($tabRatio as $idRatio => $infoRatio){ $dataGraphEvol = array(); diff --git a/library/Scores/Wkhtmltopdf.php b/library/Scores/Wkhtml/Pdf.php similarity index 98% rename from library/Scores/Wkhtmltopdf.php rename to library/Scores/Wkhtml/Pdf.php index 0688b23..377b1e8 100644 --- a/library/Scores/Wkhtmltopdf.php +++ b/library/Scores/Wkhtml/Pdf.php @@ -1,5 +1,5 @@ +#/ Represents a Financial Chart +#/ +class FinanceChart extends MultiChart +{ + var $m_totalWidth = 0; + var $m_totalHeight = 0; + var $m_antiAlias = true; + var $m_logScale = false; + var $m_axisOnRight = true; + + var $m_leftMargin = 40; + var $m_rightMargin = 40; + var $m_topMargin = 30; + var $m_bottomMargin = 35; + + var $m_plotAreaBgColor = 0xffffff; + var $m_plotAreaBorder = 0x888888; + var $m_plotAreaGap = 2; + + var $m_majorHGridColor = 0xdddddd; + var $m_minorHGridColor = 0xdddddd; + var $m_majorVGridColor = 0xdddddd; + var $m_minorVGridColor = 0xdddddd; + + var $m_legendFont = "normal"; + var $m_legendFontSize = 8; + var $m_legendFontColor = TextColor; + var $m_legendBgColor = 0x80cccccc; + + var $m_yAxisFont = "normal"; + var $m_yAxisFontSize = 8; + var $m_yAxisFontColor = TextColor; + var $m_yAxisMargin = 14; + + var $m_xAxisFont = "normal"; + var $m_xAxisFontSize = 8; + var $m_xAxisFontColor = TextColor; + var $m_xAxisFontAngle = 0; + + var $m_timeStamps = null; + var $m_highData = null; + var $m_lowData = null; + var $m_openData = null; + var $m_closeData = null; + var $m_volData = null; + var $m_volUnit = ""; + var $m_extraPoints = 0; + + var $m_yearFormat = "{value|yyyy}"; + var $m_firstMonthFormat = "<*font=bold*>{value|mmm yy}"; + var $m_otherMonthFormat = "{value|mmm}"; + var $m_firstDayFormat = "<*font=bold*>{value|d mmm}"; + var $m_otherDayFormat = "{value|d}"; + var $m_firstHourFormat = "<*font=bold*>{value|d mmm\nh:nna}"; + var $m_otherHourFormat = "{value|h:nna}"; + var $m_timeLabelSpacing = 50; + + var $m_generalFormat = "P3"; + + var $m_toolTipMonthFormat = "[{xLabel|mmm yyyy}]"; + var $m_toolTipDayFormat = "[{xLabel|mmm d, yyyy}]"; + var $m_toolTipHourFormat = "[{xLabel|mmm d, yyyy hh:nn:ss}]"; + + var $m_mainChart = null; + var $m_currentChart = null; + + #/ + #/ Create a FinanceChart with a given width. The height will be automatically determined + #/ as the chart is built. + #/ + #/ Width of the chart in pixels + function FinanceChart($width) { + $this->MultiChart($width, 1); + $this->m_totalWidth = $width; + $this->setMainChart($this); + } + + #/ + #/ Enable/Disable anti-alias. Enabling anti-alias makes the line smoother. Disabling + #/ anti-alias make the chart file size smaller, and so can be downloaded faster + #/ through the Internet. The default is to enable anti-alias. + #/ + #/ True to enable anti-alias. False to disable anti-alias. + function enableAntiAlias($antiAlias) { + $this->m_antiAlias = $antiAlias; + } + + #/ + #/ Set the margins around the plot area. + #/ + #/ The distance between the plot area and the chart left edge. + #/ The distance between the plot area and the chart top edge. + #/ The distance between the plot area and the chart right edge. + #/ The distance between the plot area and the chart bottom edge. + function setMargins($leftMargin, $topMargin, $rightMargin, $bottomMargin) { + $this->m_leftMargin = $leftMargin; + $this->m_rightMargin = $rightMargin; + $this->m_topMargin = $topMargin; + $this->m_bottomMargin = $bottomMargin; + } + + #/ + #/ Add a text title above the plot area. You may add multiple title above the plot area by + #/ calling this method multiple times. + #/ + #/ The alignment with respect to the region that is on top of the + #/ plot area. + #/ The text to add. + #/ The TextBox object representing the text box above the plot area. + function addPlotAreaTitle($alignment, $text) { + $ret = $this->addText($this->m_leftMargin, 0, $text, "bold", 10, TextColor, $alignment); + $ret->setSize($this->m_totalWidth - $this->m_leftMargin - $this->m_rightMargin + 1, + $this->m_topMargin - 1); + $ret->setMargin(0); + return $ret; + } + + #/ + #/ Set the plot area style. The default is to use pale yellow 0xfffff0 as the background, + #/ and light grey 0xdddddd as the grid lines. + #/ + #/ The plot area background color. + #/ Major horizontal grid color. + #/ Major vertical grid color. + #/ Minor horizontal grid color. In current version, minor + #/ horizontal grid is not used. + #/ Minor vertical grid color. + function setPlotAreaStyle($bgColor, $majorHGridColor, $majorVGridColor, $minorHGridColor, + $minorVGridColor) { + $this->m_plotAreaBgColor = $bgColor; + $this->m_majorHGridColor = $majorHGridColor; + $this->m_majorVGridColor = $majorVGridColor; + $this->m_minorHGridColor = $minorHGridColor; + $this->m_minorVGridColor = $minorVGridColor; + } + + #/ + #/ Set the plot area border style. The default is grey color (888888), with a gap + #/ of 2 pixels between charts. + #/ + #/ The color of the border. + #/ The gap between two charts. + function setPlotAreaBorder($borderColor, $borderGap) { + $this->m_plotAreaBorder = $borderColor; + $this->m_plotAreaGap = $borderGap; + } + + #/ + #/ Set legend style. The default is Arial 8 pt black color, with light grey background. + #/ + #/ The font of the legend text. + #/ The font size of the legend text in points. + #/ The color of the legend text. + #/ The background color of the legend box. + function setLegendStyle($font, $fontSize, $fontColor, $bgColor) { + $this->m_legendFont = $font; + $this->m_legendFontSize = $fontSize; + $this->m_legendFontColor = $fontColor; + $this->m_legendBgColor = $bgColor; + } + + #/ + #/ Set x-axis label style. The default is Arial 8 pt black color no rotation. + #/ + #/ The font of the axis labels. + #/ The font size of the axis labels in points. + #/ The color of the axis labels. + #/ The rotation of the axis labels. + function setXAxisStyle($font, $fontSize, $fontColor, $fontAngle) { + $this->m_xAxisFont = $font; + $this->m_xAxisFontSize = $fontSize; + $this->m_xAxisFontColor = $fontColor; + $this->m_xAxisFontAngle = $fontAngle; + } + + #/ + #/ Set y-axis label style. The default is Arial 8 pt black color, with 13 pixels margin. + #/ + #/ The font of the axis labels. + #/ The font size of the axis labels in points. + #/ The color of the axis labels. + #/ The margin at the top of the y-axis in pixels (to leave + #/ space for the legend box). + function setYAxisStyle($font, $fontSize, $fontColor, $axisMargin) { + $this->m_yAxisFont = $font; + $this->m_yAxisFontSize = $fontSize; + $this->m_yAxisFontColor = $fontColor; + $this->m_yAxisMargin = $axisMargin; + } + + #/ + #/ Set whether the main y-axis is on right of left side of the plot area. The default is + #/ on right. + #/ + #/ True if the y-axis is on right. False if the y-axis is on left. + function setAxisOnRight($b) { + $this->m_axisOnRight = $b; + } + + #/ + #/ Determines if log scale should be used for the main chart. The default is linear scale. + #/ + #/ True for using log scale. False for using linear scale. + function setLogScale($b) { + $this->m_logScale = $b; + if ($this->m_mainChart != null) { + if ($this->m_logScale) { + $this->m_mainChart->yAxis->setLogScale(); + } else { + $this->m_mainChart->yAxis->setLinearScale(); + } + } + } + + #/ + #/ Set the date/time formats to use for the x-axis labels under various cases. + #/ + #/ The format for displaying labels on an axis with yearly ticks. The + #/ default is "yyyy". + #/ The format for displaying labels on an axis with monthly ticks. + #/ This parameter applies to the first available month of a year (usually January) only, so it can + #/ be formatted differently from the other labels. + #/ The format for displaying labels on an axis with monthly ticks. + #/ This parameter applies to months other than the first available month of a year. + #/ The format for displaying labels on an axis with daily ticks. + #/ This parameter applies to the first available day of a month only, so it can be formatted + #/ differently from the other labels. + #/ The format for displaying labels on an axis with daily ticks. + #/ This parameter applies to days other than the first available day of a month. + #/ The format for displaying labels on an axis with hourly + #/ resolution. This parameter applies to the first tick of a day only, so it can be formatted + #/ differently from the other labels. + #/ The format for displaying labels on an axis with hourly. + #/ resolution. This parameter applies to ticks at hourly boundaries, except the first tick + #/ of a day. + function setDateLabelFormat($yearFormat, $firstMonthFormat, $otherMonthFormat, $firstDayFormat, + $otherDayFormat, $firstHourFormat, $otherHourFormat) { + if ($yearFormat != null) { + $this->m_yearFormat = $yearFormat; + } + if ($firstMonthFormat != null) { + $this->m_firstMonthFormat = $firstMonthFormat; + } + if ($otherMonthFormat != null) { + $this->m_otherMonthFormat = $otherMonthFormat; + } + if ($firstDayFormat != null) { + $this->m_firstDayFormat = $firstDayFormat; + } + if ($otherDayFormat != null) { + $this->m_otherDayFormat = $otherDayFormat; + } + if ($firstHourFormat != null) { + $this->m_firstHourFormat = $firstHourFormat; + } + if ($otherHourFormat != null) { + $this->m_otherHourFormat = $otherHourFormat; + } + } + + #/ + #/ Set the minimum label spacing between two labels on the time axis + #/ + #/ The minimum label spacing in pixels. + function setDateLabelSpacing($labelSpacing) { + if ($labelSpacing > 0) { + $this->m_timeLabelSpacing = $labelSpacing; + } else { + $this->m_timeLabelSpacing = 0; + } + } + + #/ + #/ Set the tool tip formats for display date/time + #/ + #/ The tool tip format to use if the data point spacing is one + #/ or more months (more than 30 days). + #/ The tool tip format to use if the data point spacing is 1 day + #/ to less than 30 days. + #/ The tool tip format to use if the data point spacing is less + #/ than 1 day. + function setToolTipDateFormat($monthFormat, $dayFormat, $hourFormat) { + if ($monthFormat != null) { + $this->m_toolTipMonthFormat = $monthFormat; + } + if ($dayFormat != null) { + $this->m_toolTipDayFormat = $dayFormat; + } + if ($hourFormat != null) { + $this->m_toolTipHourFormat = $hourFormat; + } + } + + #/ + #/ Get the tool tip format for display date/time + #/ + #/ The tool tip format string. + function getToolTipDateFormat() { + if ($this->m_timeStamps == null) { + return $this->m_toolTipHourFormat; + } + if (count($this->m_timeStamps) <= $this->m_extraPoints) { + return $this->m_toolTipHourFormat; + } + $resolution = ($this->m_timeStamps[count($this->m_timeStamps) - 1] - $this->m_timeStamps[0]) + / count($this->m_timeStamps); + if ($resolution >= 30 * 86400) { + return $this->m_toolTipMonthFormat; + } else if ($resolution >= 86400) { + return $this->m_toolTipDayFormat; + } else { + return $this->m_toolTipHourFormat; + } + } + + #/ + #/ Set the number format for use in displaying values in legend keys and tool tips. + #/ + #/ The default number format. + function setNumberLabelFormat($formatString) { + if ($formatString != null) { + $this->m_generalFormat = $formatString; + } + } + + #/ + #/ A utility function to compute triangular moving averages + #/ + #/ An array of numbers as input. + #/ The moving average period. + #/ An array representing the triangular moving average of the input array. + function computeTriMovingAvg($data, $period) { + $p = $period / 2 + 1; + $tmpArrayMath1 = new ArrayMath($data); + $tmpArrayMath1->movAvg($p); + $tmpArrayMath1->movAvg($p); + return $tmpArrayMath1->result(); + } + + #/ + #/ A utility function to compute weighted moving averages + #/ + #/ An array of numbers as input. + #/ The moving average period. + #/ An array representing the weighted moving average of the input array. + function computeWeightedMovingAvg($data, $period) { + $acc = new ArrayMath($data); + for($i = 2; $i < $period + 1; ++$i) { + $tmpArrayMath1 = new ArrayMath($data); + $tmpArrayMath1->movAvg($i); + $tmpArrayMath1->mul($i); + $acc->add($tmpArrayMath1->result()); + } + $divObj = $acc->div((1 + $period) * $period / 2); + return $divObj->result(); + } + + #/ + #/ A utility function to obtain the first visible closing price. + #/ + #/ The first closing price. + #/ are cd.NoValue. + function firstCloseValue() { + for($i = $this->m_extraPoints; $i < count($this->m_closeData); ++$i) { + if (($this->m_closeData[$i] != NoValue) && ($this->m_closeData[$i] != 0)) { + return $this->m_closeData[$i]; + } + } + return NoValue; + } + + #/ + #/ A utility function to obtain the last valid position (that is, position not + #/ containing cd.NoValue) of a data series. + #/ + #/ An array of numbers as input. + #/ The last valid position in the input array, or -1 if all positions + #/ are cd.NoValue. + function lastIndex($data) { + $i = count($data) - 1; + while ($i >= 0) { + if ($data[$i] != NoValue) { + break; + } + $i = $i - 1; + } + return $i; + } + + #/ + #/ Set the data used in the chart. If some of the data are not available, some artifical + #/ values should be used. For example, if the high and low values are not available, you + #/ may use closeData as highData and lowData. + #/ + #/ An array of dates/times for the time intervals. + #/ The high values in the time intervals. + #/ The low values in the time intervals. + #/ The open values in the time intervals. + #/ The close values in the time intervals. + #/ The volume values in the time intervals. + #/ The number of leading time intervals that are not + #/ displayed in the chart. These intervals are typically used for computing + #/ indicators that require extra leading data, such as moving averages. + function setData($timeStamps, $highData, $lowData, $openData, $closeData, $volData, $extraPoints + ) { + $this->m_timeStamps = $timeStamps; + $this->m_highData = $highData; + $this->m_lowData = $lowData; + $this->m_openData = $openData; + $this->m_closeData = $closeData; + if ($extraPoints > 0) { + $this->m_extraPoints = $extraPoints; + } else { + $this->m_extraPoints = 0; + } + + #/////////////////////////////////////////////////////////////////////// + # Auto-detect volume units + #/////////////////////////////////////////////////////////////////////// + $tmpArrayMath1 = new ArrayMath($volData); + $maxVol = $tmpArrayMath1->max(); + $units = array("", "K", "M", "B"); + $unitIndex = count($units) - 1; + while (($unitIndex > 0) && ($maxVol < pow(1000, $unitIndex))) { + $unitIndex = $unitIndex - 1; + } + + $tmpArrayMath1 = new ArrayMath($volData); + $tmpArrayMath1->div(pow(1000, $unitIndex)); + $this->m_volData = $tmpArrayMath1->result(); + $this->m_volUnit = $units[$unitIndex]; + } + + #//////////////////////////////////////////////////////////////////////////// + # Format x-axis labels + #//////////////////////////////////////////////////////////////////////////// + function setXLabels(&$a) { + $a->setLabels2($this->m_timeStamps); + if ($this->m_extraPoints < count($this->m_timeStamps)) { + $tickStep = (int)((count($this->m_timeStamps) - $this->m_extraPoints) * + $this->m_timeLabelSpacing / ($this->m_totalWidth - $this->m_leftMargin - + $this->m_rightMargin)) + 1; + $timeRangeInSeconds = $this->m_timeStamps[count($this->m_timeStamps) - 1] - + $this->m_timeStamps[$this->m_extraPoints]; + $secondsBetweenTicks = $timeRangeInSeconds / ($this->m_totalWidth - $this->m_leftMargin + - $this->m_rightMargin) * $this->m_timeLabelSpacing; + + if ($secondsBetweenTicks * (count($this->m_timeStamps) - $this->m_extraPoints) <= + $timeRangeInSeconds) { + $tickStep = 1; + if (count($this->m_timeStamps) > 1) { + $secondsBetweenTicks = $this->m_timeStamps[count($this->m_timeStamps) - 1] - + $this->m_timeStamps[count($this->m_timeStamps) - 2]; + } else { + $secondsBetweenTicks = 86400; + } + } + + if (($secondsBetweenTicks > 360 * 86400) || (($secondsBetweenTicks > 90 * 86400) && ( + $timeRangeInSeconds >= 720 * 86400))) { + #yearly ticks + $a->setMultiFormat2(StartOfYearFilter(), $this->m_yearFormat, $tickStep); + } else if (($secondsBetweenTicks >= 30 * 86400) || (($secondsBetweenTicks > 7 * 86400) + && ($timeRangeInSeconds >= 60 * 86400))) { + #monthly ticks + $monthBetweenTicks = (int)($secondsBetweenTicks / 31 / 86400) + 1; + $a->setMultiFormat(StartOfYearFilter(), $this->m_firstMonthFormat, + StartOfMonthFilter($monthBetweenTicks), $this->m_otherMonthFormat); + $a->setMultiFormat2(StartOfMonthFilter(), "-", 1, false); + } else if (($secondsBetweenTicks >= 86400) || (($secondsBetweenTicks > 6 * 3600) && ( + $timeRangeInSeconds >= 86400))) { + #daily ticks + $a->setMultiFormat(StartOfMonthFilter(), $this->m_firstDayFormat, StartOfDayFilter( + 1, 0.5), $this->m_otherDayFormat, $tickStep); + } else { + #hourly ticks + $a->setMultiFormat(StartOfDayFilter(1, 0.5), $this->m_firstHourFormat, + StartOfHourFilter(1, 0.5), $this->m_otherHourFormat, $tickStep); + } + } + } + + #//////////////////////////////////////////////////////////////////////////// + # Create tool tip format string for showing OHLC data + #//////////////////////////////////////////////////////////////////////////// + function getHLOCToolTipFormat() { + return sprintf("title='%s Op:{open|%s}, Hi:{high|%s}, Lo:{low|%s}, Cl:{close|%s}'", + $this->getToolTipDateFormat(), $this->m_generalFormat, $this->m_generalFormat, + $this->m_generalFormat, $this->m_generalFormat); + } + + #/ + #/ Add the main chart - the chart that shows the HLOC data. + #/ + #/ The height of the main chart in pixels. + #/ An XYChart object representing the main chart created. + function addMainChart($height) { + $this->m_mainChart = $this->addIndicator($height); + $this->m_mainChart->yAxis->setMargin(2 * $this->m_yAxisMargin); + if ($this->m_logScale) { + $this->m_mainChart->yAxis->setLogScale(); + } else { + $this->m_mainChart->yAxis->setLinearScale(); + } + return $this->m_mainChart; + } + + #/ + #/ Add a candlestick layer to the main chart. + #/ + #/ The candle color for an up day. + #/ The candle color for a down day. + #/ The CandleStickLayer created. + function addCandleStick($upColor, $downColor) { + $this->addOHLCLabel($upColor, $downColor, true); + $ret = $this->m_mainChart->addCandleStickLayer($this->m_highData, $this->m_lowData, + $this->m_openData, $this->m_closeData, $upColor, $downColor); + $ret->setHTMLImageMap("", "", $this->getHLOCToolTipFormat()); + if (count($this->m_highData) - $this->m_extraPoints > 60) { + $ret->setDataGap(0); + } + + if (count($this->m_highData) > $this->m_extraPoints) { + $expectedWidth = (int)(($this->m_totalWidth - $this->m_leftMargin - $this->m_rightMargin + ) / (count($this->m_highData) - $this->m_extraPoints)); + if ($expectedWidth <= 5) { + $ret->setDataWidth($expectedWidth + 1 - $expectedWidth % 2); + } + } + + return $ret; + } + + #/ + #/ Add a HLOC layer to the main chart. + #/ + #/ The color of the HLOC symbol for an up day. + #/ The color of the HLOC symbol for a down day. + #/ The HLOCLayer created. + function addHLOC($upColor, $downColor) { + $this->addOHLCLabel($upColor, $downColor, false); + $ret = $this->m_mainChart->addHLOCLayer($this->m_highData, $this->m_lowData, + $this->m_openData, $this->m_closeData); + $ret->setColorMethod(HLOCUpDown, $upColor, $downColor); + $ret->setHTMLImageMap("", "", $this->getHLOCToolTipFormat()); + $ret->setDataGap(0); + return $ret; + } + + function addOHLCLabel($upColor, $downColor, $candleStickMode) { + $i = $this->lastIndex($this->m_closeData); + if ($i >= 0) { + $openValue = NoValue; + $closeValue = NoValue; + $highValue = NoValue; + $lowValue = NoValue; + + if ($i < count($this->m_openData)) { + $openValue = $this->m_openData[$i]; + } + if ($i < count($this->m_closeData)) { + $closeValue = $this->m_closeData[$i]; + } + if ($i < count($this->m_highData)) { + $highValue = $this->m_highData[$i]; + } + if ($i < count($this->m_lowData)) { + $lowValue = $this->m_lowData[$i]; + } + + $openLabel = ""; + $closeLabel = ""; + $highLabel = ""; + $lowLabel = ""; + $delim = ""; + if ($openValue != NoValue) { + $openLabel = sprintf("Op:%s", $this->formatValue($openValue, $this->m_generalFormat) + ); + $delim = ", "; + } + if ($highValue != NoValue) { + $highLabel = sprintf("%sHi:%s", $delim, $this->formatValue($highValue, + $this->m_generalFormat)); + $delim = ", "; + } + if ($lowValue != NoValue) { + $lowLabel = sprintf("%sLo:%s", $delim, $this->formatValue($lowValue, + $this->m_generalFormat)); + $delim = ", "; + } + if ($closeValue != NoValue) { + $closeLabel = sprintf("%sCl:%s", $delim, $this->formatValue($closeValue, + $this->m_generalFormat)); + $delim = ", "; + } + $label = "$openLabel$highLabel$lowLabel$closeLabel"; + + $useUpColor = ($closeValue >= $openValue); + if ($candleStickMode != true) { + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->delta(); + $closeChanges = $tmpArrayMath1->result(); + $lastChangeIndex = $this->lastIndex($closeChanges); + $useUpColor = ($lastChangeIndex < 0); + if ($useUpColor != true) { + $useUpColor = ($closeChanges[$lastChangeIndex] >= 0); + } + } + + $udcolor = $downColor; + if ($useUpColor) { + $udcolor = $upColor; + } + $legendObj = $this->m_mainChart->getLegend(); + $legendObj->addKey($label, $udcolor); + } + } + + #/ + #/ Add a closing price line on the main chart. + #/ + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addCloseLine($color) { + return $this->addLineIndicator2($this->m_mainChart, $this->m_closeData, $color, + "Closing Price"); + } + + #/ + #/ Add a weight close line on the main chart. + #/ + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addWeightedClose($color) { + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->add($this->m_lowData); + $tmpArrayMath1->add($this->m_closeData); + $tmpArrayMath1->add($this->m_closeData); + $tmpArrayMath1->div(4); + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, + "Weighted Close"); + } + + #/ + #/ Add a typical price line on the main chart. + #/ + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addTypicalPrice($color) { + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->add($this->m_lowData); + $tmpArrayMath1->add($this->m_closeData); + $tmpArrayMath1->div(3); + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, + "Typical Price"); + } + + #/ + #/ Add a median price line on the main chart. + #/ + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addMedianPrice($color) { + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->add($this->m_lowData); + $tmpArrayMath1->div(2); + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, + "Median Price"); + } + + #/ + #/ Add a simple moving average line on the main chart. + #/ + #/ The moving average period + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addSimpleMovingAvg($period, $color) { + $label = "SMA ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movAvg($period); + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, $label + ); + } + + #/ + #/ Add an exponential moving average line on the main chart. + #/ + #/ The moving average period + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addExpMovingAvg($period, $color) { + $label = "EMA ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->expAvg(2.0 / ($period + 1)); + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, $label + ); + } + + #/ + #/ Add a triangular moving average line on the main chart. + #/ + #/ The moving average period + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addTriMovingAvg($period, $color) { + $label = "TMA ($period)"; + $tmpArrayMath1 = new ArrayMath($this->computeTriMovingAvg($this->m_closeData, $period)); + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, $label + ); + } + + #/ + #/ Add a weighted moving average line on the main chart. + #/ + #/ The moving average period + #/ The color of the line. + #/ The LineLayer object representing the line created. + function addWeightedMovingAvg($period, $color) { + $label = "WMA ($period)"; + $tmpArrayMath1 = new ArrayMath($this->computeWeightedMovingAvg($this->m_closeData, $period)) + ; + return $this->addLineIndicator2($this->m_mainChart, $tmpArrayMath1->result(), $color, $label + ); + } + + #/ + #/ Add a parabolic SAR indicator to the main chart. + #/ + #/ Initial acceleration factor + #/ Acceleration factor increment + #/ Maximum acceleration factor + #/ The symbol used to plot the parabolic SAR + #/ The symbol size in pixels + #/ The fill color of the symbol + #/ The edge color of the symbol + #/ The LineLayer object representing the layer created. + function addParabolicSAR($accInitial, $accIncrement, $accMaximum, $symbolType, $symbolSize, + $fillColor, $edgeColor) { + $isLong = true; + $acc = $accInitial; + $extremePoint = 0; + $psar = array_pad(array(), count($this->m_lowData), 0); + + $i_1 = -1; + $i_2 = -1; + + for($i = 0; $i < count($this->m_lowData); ++$i) { + $psar[$i] = NoValue; + if (($this->m_lowData[$i] != NoValue) && ($this->m_highData[$i] != NoValue)) { + if (($i_1 >= 0) && ($i_2 < 0)) { + if ($this->m_lowData[$i_1] <= $this->m_lowData[$i]) { + $psar[$i] = $this->m_lowData[$i_1]; + $isLong = true; + if ($this->m_highData[$i_1] > $this->m_highData[$i]) { + $extremePoint = $this->m_highData[$i_1]; + } else { + $extremePoint = $this->m_highData[$i]; + } + } else { + $extremePoint = $this->m_lowData[$i]; + $isLong = false; + if ($this->m_highData[$i_1] > $this->m_highData[$i]) { + $psar[$i] = $this->m_highData[$i_1]; + } else { + $psar[$i] = $this->m_highData[$i]; + } + } + } else if (($i_1 >= 0) && ($i_2 >= 0)) { + if ($acc > $accMaximum) { + $acc = $accMaximum; + } + + $psar[$i] = $psar[$i_1] + $acc * ($extremePoint - $psar[$i_1]); + + if ($isLong) { + if ($this->m_lowData[$i] < $psar[$i]) { + $isLong = false; + $psar[$i] = $extremePoint; + $extremePoint = $this->m_lowData[$i]; + $acc = $accInitial; + } else { + if ($this->m_highData[$i] > $extremePoint) { + $extremePoint = $this->m_highData[$i]; + $acc = $acc + $accIncrement; + } + + if ($this->m_lowData[$i_1] < $psar[$i]) { + $psar[$i] = $this->m_lowData[$i_1]; + } + if ($this->m_lowData[$i_2] < $psar[$i]) { + $psar[$i] = $this->m_lowData[$i_2]; + } + } + } else { + if ($this->m_highData[$i] > $psar[$i]) { + $isLong = true; + $psar[$i] = $extremePoint; + $extremePoint = $this->m_highData[$i]; + $acc = $accInitial; + } else { + if ($this->m_lowData[$i] < $extremePoint) { + $extremePoint = $this->m_lowData[$i]; + $acc = $acc + $accIncrement; + } + + if ($this->m_highData[$i_1] > $psar[$i]) { + $psar[$i] = $this->m_highData[$i_1]; + } + if ($this->m_highData[$i_2] > $psar[$i]) { + $psar[$i] = $this->m_highData[$i_2]; + } + } + } + } + + $i_2 = $i_1; + $i_1 = $i; + } + } + + $ret = $this->addLineIndicator2($this->m_mainChart, $psar, $fillColor, "Parabolic SAR"); + $ret->setLineWidth(0); + + $ret = $this->addLineIndicator2($this->m_mainChart, $psar, $fillColor, ""); + $ret->setLineWidth(0); + $dataSetObj = $ret->getDataSet(0); + $dataSetObj->setDataSymbol($symbolType, $symbolSize, $fillColor, $edgeColor); + return $ret; + } + + #/ + #/ Add a comparison line to the main price chart. + #/ + #/ The data series to compare to + #/ The color of the comparison line + #/ The name of the comparison line + #/ The LineLayer object representing the line layer created. + function addComparison($data, $color, $name) { + $firstIndex = $this->m_extraPoints; + while (($firstIndex < count($data)) && ($firstIndex < count($this->m_closeData))) { + if (($data[$firstIndex] != NoValue) && ($this->m_closeData[$firstIndex] != NoValue) && ( + $data[$firstIndex] != 0) && ($this->m_closeData[$firstIndex] != 0)) { + break; + } + $firstIndex = $firstIndex + 1; + } + if (($firstIndex >= count($data)) || ($firstIndex >= count($this->m_closeData))) { + return null; + } + + $scaleFactor = $this->m_closeData[$firstIndex] / $data[$firstIndex]; + $tmpArrayMath1 = new ArrayMath($data); + $tmpArrayMath1->mul($scaleFactor); + $layer = $this->m_mainChart->addLineLayer($tmpArrayMath1->result(), Transparent); + $layer->setHTMLImageMap("{disable}"); + + $a = $this->m_mainChart->addAxis(Right, 0); + $a->setColors(Transparent, Transparent); + $a->syncAxis($this->m_mainChart->yAxis, 1 / $scaleFactor, 0); + + $ret = $this->addLineIndicator2($this->m_mainChart, $data, $color, $name); + $ret->setUseYAxis($a); + return $ret; + } + + #/ + #/ Display percentage axis scale + #/ + #/ The Axis object representing the percentage axis. + function setPercentageAxis() { + $firstClose = $this->firstCloseValue(); + if ($firstClose == NoValue) { + return null; + } + + $axisAlign = Left; + if ($this->m_axisOnRight) { + $axisAlign = Right; + } + + $ret = $this->m_mainChart->addAxis($axisAlign, 0); + $this->configureYAxis($ret, 300); + $ret->syncAxis($this->m_mainChart->yAxis, 100 / $firstClose); + $ret->setRounding(false, false); + $ret->setLabelFormat("{={value}-100|@}%"); + $this->m_mainChart->yAxis->setColors(Transparent, Transparent); + $plotAreaObj = $this->m_mainChart->getPlotArea(); + $plotAreaObj->setGridAxis(null, $ret); + return $ret; + } + + #/ + #/ Add a generic band to the main finance chart. This method is used internally by other methods to add + #/ various bands (eg. Bollinger band, Donchian channels, etc). + #/ + #/ The data series for the upper band line. + #/ The data series for the lower band line. + #/ The color of the upper and lower band line. + #/ The color to fill the region between the upper and lower band lines. + #/ The name of the band. + #/ An InterLineLayer object representing the filled region. + function addBand($upperLine, $lowerLine, $lineColor, $fillColor, $name) { + $i = count($upperLine) - 1; + if ($i >= count($lowerLine)) { + $i = count($lowerLine) - 1; + } + + while ($i >= 0) { + if (($upperLine[$i] != NoValue) && ($lowerLine[$i] != NoValue)) { + $name = sprintf("%s: %s - %s", $name, $this->formatValue($lowerLine[$i], + $this->m_generalFormat), $this->formatValue($upperLine[$i], + $this->m_generalFormat)); + break; + } + $i = $i - 1; + } + + $layer = $this->m_mainChart->addLineLayer2(); + $layer->addDataSet($upperLine, $lineColor, $name); + $layer->addDataSet($lowerLine, $lineColor); + return $this->m_mainChart->addInterLineLayer($layer->getLine(0), $layer->getLine(1), + $fillColor); + } + + #/ + #/ Add a Bollinger band on the main chart. + #/ + #/ The period to compute the band. + #/ The half-width of the band in terms multiples of standard deviation. Typically 2 is used. + #/ The color of the lines defining the upper and lower limits. + #/ The color to fill the regional within the band. + #/ The InterLineLayer object representing the band created. + function addBollingerBand($period, $bandWidth, $lineColor, $fillColor) { + #Bollinger Band is moving avg +/- (width * moving std deviation) + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movStdDev($period); + $tmpArrayMath1->mul($bandWidth); + $stdDev = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movAvg($period); + $movAvg = $tmpArrayMath1->result(); + $label = "Bollinger ($period, $bandWidth)"; + $tmpArrayMath1 = new ArrayMath($movAvg); + $tmpArrayMath1->add($stdDev); + $tmpArrayMath2 = new ArrayMath($movAvg); + $tmpArrayMath2->sub($stdDev); + $tmpArrayMath2->selectGTZ(null, 0); + return $this->addBand($tmpArrayMath1->result(), $tmpArrayMath2->result(), $lineColor, + $fillColor, $label); + } + + #/ + #/ Add a Donchian channel on the main chart. + #/ + #/ The period to compute the band. + #/ The color of the lines defining the upper and lower limits. + #/ The color to fill the regional within the band. + #/ The InterLineLayer object representing the band created. + function addDonchianChannel($period, $lineColor, $fillColor) { + #Donchian Channel is the zone between the moving max and moving min + $label = "Donchian ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->movMax($period); + $tmpArrayMath2 = new ArrayMath($this->m_lowData); + $tmpArrayMath2->movMin($period); + return $this->addBand($tmpArrayMath1->result(), $tmpArrayMath2->result(), $lineColor, + $fillColor, $label); + } + + #/ + #/ Add a price envelop on the main chart. The price envelop is a defined as a ratio around a + #/ moving average. For example, a ratio of 0.2 means 20% above and below the moving average. + #/ + #/ The period for the moving average. + #/ The ratio above and below the moving average. + #/ The color of the lines defining the upper and lower limits. + #/ The color to fill the regional within the band. + #/ The InterLineLayer object representing the band created. + function addEnvelop($period, $range, $lineColor, $fillColor) { + #Envelop is moving avg +/- percentage + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movAvg($period); + $movAvg = $tmpArrayMath1->result(); + $label = sprintf("Envelop (SMA %s +/- %s%%)", $period, (int)($range * 100)); + $tmpArrayMath1 = new ArrayMath($movAvg); + $tmpArrayMath1->mul(1 + $range); + $tmpArrayMath2 = new ArrayMath($movAvg); + $tmpArrayMath2->mul(1 - $range); + return $this->addBand($tmpArrayMath1->result(), $tmpArrayMath2->result(), $lineColor, + $fillColor, $label); + } + + #/ + #/ Add a volume bar chart layer on the main chart. + #/ + #/ The height of the bar chart layer in pixels. + #/ The color to used on an 'up' day. An 'up' day is a day where + #/ the closing price is higher than that of the previous day. + #/ The color to used on a 'down' day. A 'down' day is a day + #/ where the closing price is lower than that of the previous day. + #/ The color to used on a 'flat' day. A 'flat' day is a day + #/ where the closing price is the same as that of the previous day. + #/ The XYChart object representing the chart created. + function addVolBars($height, $upColor, $downColor, $flatColor) { + return $this->addVolBars2($this->m_mainChart, $height, $upColor, $downColor, $flatColor); + } + + function addVolBars2(&$c, $height, $upColor, $downColor, $flatColor) { + $barLayer = $c->addBarLayer2(Overlay); + $barLayer->setBorderColor(Transparent); + + if ($c == $this->m_mainChart) { + $this->configureYAxis($c->yAxis2, $height); + $drawAreaObj = $c->getDrawArea(); + $topMargin = $drawAreaObj->getHeight() - $this->m_topMargin - $this->m_bottomMargin - + $height + $this->m_yAxisMargin; + if ($topMargin < 0) { + $topMargin = 0; + } + $c->yAxis2->setTopMargin($topMargin); + $barLayer->setUseYAxis2(); + } + + $a = $c->yAxis2; + if ($c != $this->m_mainChart) { + $a = $c->yAxis; + } + $tmpArrayMath1 = new ArrayMath($this->m_volData); + if ($tmpArrayMath1->max() < 10) { + $a->setLabelFormat(sprintf("{value|1}%s", $this->m_volUnit)); + } else { + $a->setLabelFormat(sprintf("{value}%s", $this->m_volUnit)); + } + + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->delta(); + $tmpArrayMath1->replace(NoValue, 0); + $closeChange = $tmpArrayMath1->result(); + $i = $this->lastIndex($this->m_volData); + $label = "Vol"; + if ($i >= 0) { + $label = sprintf("%s: %s%s", $label, $this->formatValue($this->m_volData[$i], + $this->m_generalFormat), $this->m_volUnit); + } + + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->selectGTZ($closeChange); + $upDS = $barLayer->addDataSet($tmpArrayMath1->result(), $upColor); + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->selectLTZ($closeChange); + $dnDS = $barLayer->addDataSet($tmpArrayMath1->result(), $downColor); + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->selectEQZ($closeChange); + $flatDS = $barLayer->addDataSet($tmpArrayMath1->result(), $flatColor); + + if (($i < 0) || ($closeChange[$i] == 0) || ($closeChange[$i] == NoValue)) { + $flatDS->setDataName($label); + } else if ($closeChange[$i] > 0) { + $upDS->setDataName($label); + } else { + $dnDS->setDataName($label); + } + + return $barLayer; + } + + #/ + #/ Add a blank indicator chart to the finance chart. Used internally to add other indicators. + #/ Override to change the default formatting (eg. axis fonts, etc.) of the various indicators. + #/ + #/ The height of the chart in pixels. + #/ The XYChart object representing the chart created. + function addIndicator($height) { + #create a new chart object + $ret = new XYChart($this->m_totalWidth, $height + $this->m_topMargin + + $this->m_bottomMargin, Transparent); + $ret->setTrimData($this->m_extraPoints); + + if ($this->m_currentChart != null) { + #if there is a chart before the newly created chart, disable its x-axis, and copy + #its x-axis labels to the new chart + $this->m_currentChart->xAxis->setColors(Transparent, Transparent); + $ret->xAxis->copyAxis($this->m_currentChart->xAxis); + + #add chart to MultiChart and update the total height + $this->addChart(0, $this->m_totalHeight + $this->m_plotAreaGap, $ret); + $this->m_totalHeight = $this->m_totalHeight + $height + 1 + $this->m_plotAreaGap; + } else { + #no existing chart - create the x-axis labels from scratch + $this->setXLabels($ret->xAxis); + + #add chart to MultiChart and update the total height + $this->addChart(0, $this->m_totalHeight, $ret); + $this->m_totalHeight = $this->m_totalHeight + $height + 1; + } + + #the newly created chart becomes the current chart + $this->m_currentChart = $ret; + + #update the size + $this->setSize($this->m_totalWidth, $this->m_totalHeight + $this->m_topMargin + + $this->m_bottomMargin); + + #configure the plot area + $plotAreaObj = $ret->setPlotArea($this->m_leftMargin, $this->m_topMargin, + $this->m_totalWidth - $this->m_leftMargin - $this->m_rightMargin, $height, + $this->m_plotAreaBgColor, -1, $this->m_plotAreaBorder); + $plotAreaObj->setGridColor($this->m_majorHGridColor, $this->m_majorVGridColor, + $this->m_minorHGridColor, $this->m_minorVGridColor); + $ret->setAntiAlias($this->m_antiAlias); + + #configure legend box + if ($this->m_legendFontColor != Transparent) { + $box = $ret->addLegend($this->m_leftMargin, $this->m_topMargin, false, + $this->m_legendFont, $this->m_legendFontSize); + $box->setFontColor($this->m_legendFontColor); + $box->setBackground($this->m_legendBgColor); + $box->setMargin2(5, 0, 2, 1); + $box->setSize($this->m_totalWidth - $this->m_leftMargin - $this->m_rightMargin + 1, 0); + } + + #configure x-axis + $a = $ret->xAxis; + $a->setIndent(true); + $a->setTickLength(2, 0); + $a->setColors(Transparent, $this->m_xAxisFontColor, $this->m_xAxisFontColor, + $this->m_xAxisFontColor); + $a->setLabelStyle($this->m_xAxisFont, $this->m_xAxisFontSize, $this->m_xAxisFontColor, + $this->m_xAxisFontAngle); + + #configure y-axis + $ret->setYAxisOnRight($this->m_axisOnRight); + $this->configureYAxis($ret->yAxis, $height); + + return $ret; + } + + function configureYAxis(&$a, $height) { + $a->setAutoScale(0, 0.05, 0); + if ($height < 100) { + $a->setTickDensity(15); + } + $a->setMargin($this->m_yAxisMargin); + $a->setLabelStyle($this->m_yAxisFont, $this->m_yAxisFontSize, $this->m_yAxisFontColor, 0); + $a->setTickLength(-4, -2); + $a->setColors(Transparent, $this->m_yAxisFontColor, $this->m_yAxisFontColor, + $this->m_yAxisFontColor); + } + + #/ + #/ Add a generic line indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The data series of the indicator line. + #/ The color of the indicator line. + #/ The name of the indicator. + #/ The XYChart object representing the chart created. + function addLineIndicator($height, $data, $color, $name) { + $c = $this->addIndicator($height); + $this->addLineIndicator2($c, $data, $color, $name); + return $c; + } + + #/ + #/ Add a line to an existing indicator chart. + #/ + #/ The indicator chart to add the line to. + #/ The data series of the indicator line. + #/ The color of the indicator line. + #/ The name of the indicator. + #/ The LineLayer object representing the line created. + function addLineIndicator2(&$c, $data, $color, $name) { + return $c->addLineLayer($data, $color, $this->formatIndicatorLabel($name, $data)); + } + + #/ + #/ Add a generic bar indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The data series of the indicator bars. + #/ The color of the indicator bars. + #/ The name of the indicator. + #/ The XYChart object representing the chart created. + function addBarIndicator($height, $data, $color, $name) { + $c = $this->addIndicator($height); + $this->addBarIndicator2($c, $data, $color, $name); + return $c; + } + + #/ + #/ Add a bar layer to an existing indicator chart. + #/ + #/ The indicator chart to add the bar layer to. + #/ The data series of the indicator bars. + #/ The color of the indicator bars. + #/ The name of the indicator. + #/ The BarLayer object representing the bar layer created. + function addBarIndicator2(&$c, $data, $color, $name) { + $layer = $c->addBarLayer($data, $color, $this->formatIndicatorLabel($name, $data)); + $layer->setBorderColor(Transparent); + return $layer; + } + + #/ + #/ Add an upper/lower threshold range to an existing indicator chart. + #/ + #/ The indicator chart to add the threshold range to. + #/ The line layer that the threshold range applies to. + #/ The upper threshold. + #/ The color to fill the region of the line that is above the + #/ upper threshold. + #/ The lower threshold. + #/ The color to fill the region of the line that is below + #/ the lower threshold. + function addThreshold(&$c, &$layer, $topRange, $topColor, $bottomRange, $bottomColor) { + $topMark = $c->yAxis->addMark($topRange, $topColor, $this->formatValue($topRange, + $this->m_generalFormat)); + $bottomMark = $c->yAxis->addMark($bottomRange, $bottomColor, $this->formatValue( + $bottomRange, $this->m_generalFormat)); + + $c->addInterLineLayer($layer->getLine(), $topMark->getLine(), $topColor, Transparent); + $c->addInterLineLayer($layer->getLine(), $bottomMark->getLine(), Transparent, $bottomColor); + } + + function formatIndicatorLabel($name, $data) { + $i = $this->lastIndex($data); + if ($name == null) { + return $name; + } + if (($name == "") || ($i < 0)) { + return $name; + } + $ret = sprintf("%s: %s", $name, $this->formatValue($data[$i], $this->m_generalFormat)); + return $ret; + } + + #/ + #/ Add an Accumulation/Distribution indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addAccDist($height, $color) { + #Close Location Value = ((C - L) - (H - C)) / (H - L) + #Accumulation Distribution Line = Accumulation of CLV * volume + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $range = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->mul(2); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->sub($this->m_highData); + $tmpArrayMath1->mul($this->m_volData); + $tmpArrayMath1->financeDiv($range, 0); + $tmpArrayMath1->acc(); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, + "Accumulation/Distribution"); + } + + function computeAroonUp($period) { + $aroonUp = array_pad(array(), count($this->m_highData), 0); + for($i = 0; $i < count($this->m_highData); ++$i) { + $highValue = $this->m_highData[$i]; + if ($highValue == NoValue) { + $aroonUp[$i] = NoValue; + } else { + $currentIndex = $i; + $highCount = $period; + $count = $period; + + while (($count > 0) && ($currentIndex >= $count)) { + $currentIndex = $currentIndex - 1; + $currentValue = $this->m_highData[$currentIndex]; + if ($currentValue != NoValue) { + $count = $count - 1; + if ($currentValue > $highValue) { + $highValue = $currentValue; + $highCount = $count; + } + } + } + + if ($count > 0) { + $aroonUp[$i] = NoValue; + } else { + $aroonUp[$i] = $highCount * 100.0 / $period; + } + } + } + + return $aroonUp; + } + + function computeAroonDn($period) { + $aroonDn = array_pad(array(), count($this->m_lowData), 0); + for($i = 0; $i < count($this->m_lowData); ++$i) { + $lowValue = $this->m_lowData[$i]; + if ($lowValue == NoValue) { + $aroonDn[$i] = NoValue; + } else { + $currentIndex = $i; + $lowCount = $period; + $count = $period; + + while (($count > 0) && ($currentIndex >= $count)) { + $currentIndex = $currentIndex - 1; + $currentValue = $this->m_lowData[$currentIndex]; + if ($currentValue != NoValue) { + $count = $count - 1; + if ($currentValue < $lowValue) { + $lowValue = $currentValue; + $lowCount = $count; + } + } + } + + if ($count > 0) { + $aroonDn[$i] = NoValue; + } else { + $aroonDn[$i] = $lowCount * 100.0 / $period; + } + } + } + + return $aroonDn; + } + + #/ + #/ Add an Aroon Up/Down indicators chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicators. + #/ The color of the Aroon Up indicator line. + #/ The color of the Aroon Down indicator line. + #/ The XYChart object representing the chart created. + function addAroon($height, $period, $upColor, $downColor) { + $c = $this->addIndicator($height); + $this->addLineIndicator2($c, $this->computeAroonUp($period), $upColor, "Aroon Up"); + $this->addLineIndicator2($c, $this->computeAroonDn($period), $downColor, "Aroon Down"); + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add an Aroon Oscillator indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addAroonOsc($height, $period, $color) { + $label = "Aroon Oscillator ($period)"; + $tmpArrayMath1 = new ArrayMath($this->computeAroonUp($period)); + $tmpArrayMath1->sub($this->computeAroonDn($period)); + $c = $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + $c->yAxis->setLinearScale(-100, 100); + return $c; + } + + function computeTrueRange() { + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->shift(); + $previousClose = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $ret = $tmpArrayMath1->result(); + $temp = 0; + + for($i = 0; $i < count($this->m_highData); ++$i) { + if (($ret[$i] != NoValue) && ($previousClose[$i] != NoValue)) { + $temp = abs($this->m_highData[$i] - $previousClose[$i]); + if ($temp > $ret[$i]) { + $ret[$i] = $temp; + } + $temp = abs($previousClose[$i] - $this->m_lowData[$i]); + if ($temp > $ret[$i]) { + $ret[$i] = $temp; + } + } + } + + return $ret; + } + + #/ + #/ Add an Average Directional Index indicators chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the Positive Directional Index line. + #/ The color of the Negatuve Directional Index line. + #/ The color of the Average Directional Index line. + #/ The XYChart object representing the chart created. + function addADX($height, $period, $posColor, $negColor, $color) { + #pos/neg directional movement + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->delta(); + $pos = $tmpArrayMath1->selectGTZ(); + $tmpArrayMath1 = new ArrayMath($this->m_lowData); + $tmpArrayMath1->delta(); + $tmpArrayMath1->mul(-1); + $neg = $tmpArrayMath1->selectGTZ(); + $tmpArrayMath1 = new ArrayMath($pos->result()); + $tmpArrayMath1->sub($neg->result()); + $delta = $tmpArrayMath1->result(); + $pos->selectGTZ($delta); + $neg->selectLTZ($delta); + + #initial value + $posData = $pos->result(); + $negData = $neg->result(); + if ((count($posData) > 1) && ($posData[1] != NoValue) && ($negData[1] != NoValue)) { + $posData[1] = ($posData[1] * 2 + $negData[1]) / 3; + $negData[1] = ($negData[1] + $posData[1]) / 2; + $pos = new ArrayMath($posData); + $neg = new ArrayMath($negData); + } + + #pos/neg directional index + $tr = $this->computeTrueRange(); + $tmpArrayMath1 = new ArrayMath($tr); + $tmpArrayMath1->expAvg(1.0 / $period); + $tr = $tmpArrayMath1->result(); + $expAvgObj = $pos->expAvg(1.0 / $period); + $financeDivObj = $expAvgObj->financeDiv($tr, 0); + $financeDivObj->mul(100); + $expAvgObj = $neg->expAvg(1.0 / $period); + $financeDivObj = $expAvgObj->financeDiv($tr, 0); + $financeDivObj->mul(100); + + #directional movement index ??? what happen if division by zero??? + $tmpArrayMath1 = new ArrayMath($pos->result()); + $tmpArrayMath1->add($neg->result()); + $totalDM = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($pos->result()); + $tmpArrayMath1->sub($neg->result()); + $tmpArrayMath1->abs(); + $tmpArrayMath1->financeDiv($totalDM, 0); + $tmpArrayMath1->mul(100); + $dx = $tmpArrayMath1->expAvg(1.0 / $period); + + $c = $this->addIndicator($height); + $label1 = "+DI ($period)"; + $label2 = "-DI ($period)"; + $label3 = "ADX ($period)"; + $this->addLineIndicator2($c, $pos->result(), $posColor, $label1); + $this->addLineIndicator2($c, $neg->result(), $negColor, $label2); + $this->addLineIndicator2($c, $dx->result(), $color, $label3); + return $c; + } + + #/ + #/ Add an Average True Range indicators chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the True Range line. + #/ The color of the Average True Range line. + #/ The XYChart object representing the chart created. + function addATR($height, $period, $color1, $color2) { + $trueRange = $this->computeTrueRange(); + $c = $this->addLineIndicator($height, $trueRange, $color1, "True Range"); + $label = "Average True Range ($period)"; + $tmpArrayMath1 = new ArrayMath($trueRange); + $tmpArrayMath1->expAvg(2.0 / ($period + 1)); + $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color2, $label); + return $c; + } + + #/ + #/ Add a Bollinger Band Width indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The band width to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addBollingerWidth($height, $period, $width, $color) { + $label = "Bollinger Width ($period, $width)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movStdDev($period); + $tmpArrayMath1->mul($width * 2); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Community Channel Index indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The distance beween the middle line and the upper and lower threshold lines. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addCCI($height, $period, $color, $deviation, $upColor, $downColor) { + #typical price + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->add($this->m_lowData); + $tmpArrayMath1->add($this->m_closeData); + $tmpArrayMath1->div(3); + $tp = $tmpArrayMath1->result(); + + #simple moving average of typical price + $tmpArrayMath1 = new ArrayMath($tp); + $tmpArrayMath1->movAvg($period); + $smvtp = $tmpArrayMath1->result(); + + #compute mean deviation + $movMeanDev = array_pad(array(), count($smvtp), 0); + for($i = 0; $i < count($smvtp); ++$i) { + $avg = $smvtp[$i]; + if ($avg == NoValue) { + $movMeanDev[$i] = NoValue; + } else { + $currentIndex = $i; + $count = $period - 1; + $acc = 0; + + while (($count >= 0) && ($currentIndex >= $count)) { + $currentValue = $tp[$currentIndex]; + $currentIndex = $currentIndex - 1; + if ($currentValue != NoValue) { + $count = $count - 1; + $acc = $acc + abs($avg - $currentValue); + } + } + + if ($count > 0) { + $movMeanDev[$i] = NoValue; + } else { + $movMeanDev[$i] = $acc / $period; + } + } + } + + $c = $this->addIndicator($height); + $label = "CCI ($period)"; + $tmpArrayMath1 = new ArrayMath($tp); + $tmpArrayMath1->sub($smvtp); + $tmpArrayMath1->financeDiv($movMeanDev, 0); + $tmpArrayMath1->div(0.015); + $layer = $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color, $label); + $this->addThreshold($c, $layer, $deviation, $upColor, -$deviation, $downColor); + return $c; + } + + #/ + #/ Add a Chaikin Money Flow indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addChaikinMoneyFlow($height, $period, $color) { + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $range = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->movAvg($period); + $volAvg = $tmpArrayMath1->result(); + $label = "Chaikin Money Flow ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->mul(2); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->sub($this->m_highData); + $tmpArrayMath1->mul($this->m_volData); + $tmpArrayMath1->financeDiv($range, 0); + $tmpArrayMath1->movAvg($period); + $tmpArrayMath1->financeDiv($volAvg, 0); + return $this->addBarIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Chaikin Oscillator indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addChaikinOscillator($height, $color) { + #first compute acc/dist line + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $range = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->mul(2); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->sub($this->m_highData); + $tmpArrayMath1->mul($this->m_volData); + $tmpArrayMath1->financeDiv($range, 0); + $tmpArrayMath1->acc(); + $accdist = $tmpArrayMath1->result(); + + #chaikin osc = exp3(accdist) - exp10(accdist) + $tmpArrayMath1 = new ArrayMath($accdist); + $tmpArrayMath1->expAvg(2.0 / (10 + 1)); + $expAvg10 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($accdist); + $tmpArrayMath1->expAvg(2.0 / (3 + 1)); + $tmpArrayMath1->sub($expAvg10); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, + "Chaikin Oscillator"); + } + + #/ + #/ Add a Chaikin Volatility indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to smooth the range. + #/ The period to compute the rate of change of the smoothed range. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addChaikinVolatility($height, $period1, $period2, $color) { + $label = "Chaikin Volatility ($period1, $period2)"; + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->expAvg(2.0 / ($period1 + 1)); + $tmpArrayMath1->rate($period2); + $tmpArrayMath1->sub(1); + $tmpArrayMath1->mul(100); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Close Location Value indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addCLV($height, $color) { + #Close Location Value = ((C - L) - (H - C)) / (H - L) + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $range = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->mul(2); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->sub($this->m_highData); + $tmpArrayMath1->financeDiv($range, 0); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, + "Close Location Value"); + } + + #/ + #/ Add a Detrended Price Oscillator indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addDPO($height, $period, $color) { + $label = "DPO ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movAvg($period); + $tmpArrayMath1->shift($period / 2 + 1); + $tmpArrayMath1->sub($this->m_closeData); + $tmpArrayMath1->mul(-1); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Donchian Channel Width indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addDonchianWidth($height, $period, $color) { + $label = "Donchian Width ($period)"; + $tmpArrayMath2 = new ArrayMath($this->m_lowData); + $tmpArrayMath2->movMin($period); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->movMax($period); + $tmpArrayMath1->sub($tmpArrayMath2->result()); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Ease of Movement indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to smooth the indicator. + #/ The color of the indicator line. + #/ The color of the smoothed indicator line. + #/ The XYChart object representing the chart created. + function addEaseOfMovement($height, $period, $color1, $color2) { + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->financeDiv($this->m_volData, 0); + $boxRatioInverted = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->add($this->m_lowData); + $tmpArrayMath1->div(2); + $tmpArrayMath1->delta(); + $tmpArrayMath1->mul($boxRatioInverted); + $result = $tmpArrayMath1->result(); + + $c = $this->addLineIndicator($height, $result, $color1, "EMV"); + $label = "EMV EMA ($period)"; + $tmpArrayMath1 = new ArrayMath($result); + $tmpArrayMath1->movAvg($period); + $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color2, $label); + return $c; + } + + #/ + #/ Add a Fast Stochastic indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the %K line. + #/ The period to compute the %D line. + #/ The color of the %K line. + #/ The color of the %D line. + #/ The XYChart object representing the chart created. + function addFastStochastic($height, $period1, $period2, $color1, $color2) { + $tmpArrayMath1 = new ArrayMath($this->m_lowData); + $tmpArrayMath1->movMin($period1); + $movLow = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->movMax($period1); + $tmpArrayMath1->sub($movLow); + $movRange = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->sub($movLow); + $tmpArrayMath1->financeDiv($movRange, 0.5); + $tmpArrayMath1->mul(100); + $stochastic = $tmpArrayMath1->result(); + + $label1 = "Fast Stochastic %K ($period1)"; + $c = $this->addLineIndicator($height, $stochastic, $color1, $label1); + $label2 = "%D ($period2)"; + $tmpArrayMath1 = new ArrayMath($stochastic); + $tmpArrayMath1->movAvg($period2); + $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color2, $label2); + + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add a MACD indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The first moving average period to compute the indicator. + #/ The second moving average period to compute the indicator. + #/ The moving average period of the signal line. + #/ The color of the indicator line. + #/ The color of the signal line. + #/ The color of the divergent bars. + #/ The XYChart object representing the chart created. + function addMACD($height, $period1, $period2, $period3, $color, $signalColor, $divColor) { + $c = $this->addIndicator($height); + + #MACD is defined as the difference between two exponential averages (typically 12/26 days) + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->expAvg(2.0 / ($period1 + 1)); + $expAvg1 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->expAvg(2.0 / ($period2 + 1)); + $tmpArrayMath1->sub($expAvg1); + $macd = $tmpArrayMath1->result(); + + #Add the MACD line + $label1 = "MACD ($period1, $period2)"; + $this->addLineIndicator2($c, $macd, $color, $label1); + + #MACD signal line + $tmpArrayMath1 = new ArrayMath($macd); + $tmpArrayMath1->expAvg(2.0 / ($period3 + 1)); + $macdSignal = $tmpArrayMath1->result(); + $label2 = "EXP ($period3)"; + $this->addLineIndicator2($c, $macdSignal, $signalColor, $label2); + + #Divergence + $tmpArrayMath1 = new ArrayMath($macd); + $tmpArrayMath1->sub($macdSignal); + $this->addBarIndicator2($c, $tmpArrayMath1->result(), $divColor, "Divergence"); + + return $c; + } + + #/ + #/ Add a Mass Index indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addMassIndex($height, $color, $upColor, $downColor) { + #Mass Index + $f = 2.0 / (10); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->sub($this->m_lowData); + $tmpArrayMath1->expAvg($f); + $exp9 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($exp9); + $tmpArrayMath1->expAvg($f); + $exp99 = $tmpArrayMath1->result(); + + $tmpArrayMath1 = new ArrayMath($exp9); + $tmpArrayMath1->financeDiv($exp99, 1); + $tmpArrayMath1->movAvg(25); + $tmpArrayMath1->mul(25); + $c = $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, "Mass Index"); + $c->yAxis->addMark(27, $upColor); + $c->yAxis->addMark(26.5, $downColor); + return $c; + } + + #/ + #/ Add a Money Flow Index indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The distance beween the middle line and the upper and lower threshold lines. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addMFI($height, $period, $color, $range, $upColor, $downColor) { + #Money Flow Index + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->add($this->m_lowData); + $tmpArrayMath1->add($this->m_closeData); + $tmpArrayMath1->div(3); + $typicalPrice = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($typicalPrice); + $tmpArrayMath1->mul($this->m_volData); + $moneyFlow = $tmpArrayMath1->result(); + + $tmpArrayMath1 = new ArrayMath($typicalPrice); + $tmpArrayMath1->delta(); + $selector = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($moneyFlow); + $tmpArrayMath1->selectGTZ($selector); + $tmpArrayMath1->movAvg($period); + $posMoneyFlow = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($moneyFlow); + $tmpArrayMath1->selectLTZ($selector); + $tmpArrayMath1->movAvg($period); + $tmpArrayMath1->add($posMoneyFlow); + $posNegMoneyFlow = $tmpArrayMath1->result(); + + $c = $this->addIndicator($height); + $label = "Money Flow Index ($period)"; + $tmpArrayMath1 = new ArrayMath($posMoneyFlow); + $tmpArrayMath1->financeDiv($posNegMoneyFlow, 0.5); + $tmpArrayMath1->mul(100); + $layer = $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color, $label); + $this->addThreshold($c, $layer, 50 + $range, $upColor, 50 - $range, $downColor); + + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add a Momentum indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addMomentum($height, $period, $color) { + $label = "Momentum ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->delta($period); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Negative Volume Index indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the signal line. + #/ The color of the indicator line. + #/ The color of the signal line. + #/ The XYChart object representing the chart created. + function addNVI($height, $period, $color, $signalColor) { + $nvi = array_pad(array(), count($this->m_volData), 0); + + $previousNVI = 100; + $previousVol = NoValue; + $previousClose = NoValue; + for($i = 0; $i < count($this->m_volData); ++$i) { + if ($this->m_volData[$i] == NoValue) { + $nvi[$i] = NoValue; + } else { + if (($previousVol != NoValue) && ($this->m_volData[$i] < $previousVol) && ( + $previousClose != NoValue) && ($this->m_closeData[$i] != NoValue)) { + $nvi[$i] = $previousNVI + $previousNVI * ($this->m_closeData[$i] - + $previousClose) / $previousClose; + } else { + $nvi[$i] = $previousNVI; + } + + $previousNVI = $nvi[$i]; + $previousVol = $this->m_volData[$i]; + $previousClose = $this->m_closeData[$i]; + } + } + + $c = $this->addLineIndicator($height, $nvi, $color, "NVI"); + if (count($nvi) > $period) { + $label = "NVI SMA ($period)"; + $tmpArrayMath1 = new ArrayMath($nvi); + $tmpArrayMath1->movAvg($period); + $this->addLineIndicator2($c, $tmpArrayMath1->result(), $signalColor, $label); + } + return $c; + } + + #/ + #/ Add an On Balance Volume indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addOBV($height, $color) { + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->delta(); + $closeChange = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->selectGTZ($closeChange); + $upVolume = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->selectLTZ($closeChange); + $downVolume = $tmpArrayMath1->result(); + + $tmpArrayMath1 = new ArrayMath($upVolume); + $tmpArrayMath1->sub($downVolume); + $tmpArrayMath1->acc(); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, "OBV"); + } + + #/ + #/ Add a Performance indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addPerformance($height, $color) { + $closeValue = $this->firstCloseValue(); + if ($closeValue != NoValue) { + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->mul(100 / $closeValue); + $tmpArrayMath1->sub(100); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, "Performance") + ; + } else { + #chart is empty !!! + return $this->addIndicator($height); + } + } + + #/ + #/ Add a Percentage Price Oscillator indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The first moving average period to compute the indicator. + #/ The second moving average period to compute the indicator. + #/ The moving average period of the signal line. + #/ The color of the indicator line. + #/ The color of the signal line. + #/ The color of the divergent bars. + #/ The XYChart object representing the chart created. + function addPPO($height, $period1, $period2, $period3, $color, $signalColor, $divColor) { + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->expAvg(2.0 / ($period1 + 1)); + $expAvg1 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->expAvg(2.0 / ($period2 + 1)); + $expAvg2 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($expAvg2); + $tmpArrayMath1->sub($expAvg1); + $tmpArrayMath1->financeDiv($expAvg2, 0); + $ppo = $tmpArrayMath1->mul(100); + $tmpArrayMath1 = new ArrayMath($ppo->result()); + $tmpArrayMath1->expAvg(2.0 / ($period3 + 1)); + $ppoSignal = $tmpArrayMath1->result(); + + $label1 = "PPO ($period1, $period2)"; + $label2 = "EMA ($period3)"; + $c = $this->addLineIndicator($height, $ppo->result(), $color, $label1); + $this->addLineIndicator2($c, $ppoSignal, $signalColor, $label2); + $subtractObj = $ppo->sub($ppoSignal); + $this->addBarIndicator2($c, $subtractObj->result(), $divColor, "Divergence"); + return $c; + } + + #/ + #/ Add a Positive Volume Index indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the signal line. + #/ The color of the indicator line. + #/ The color of the signal line. + #/ The XYChart object representing the chart created. + function addPVI($height, $period, $color, $signalColor) { + #Positive Volume Index + $pvi = array_pad(array(), count($this->m_volData), 0); + + $previousPVI = 100; + $previousVol = NoValue; + $previousClose = NoValue; + for($i = 0; $i < count($this->m_volData); ++$i) { + if ($this->m_volData[$i] == NoValue) { + $pvi[$i] = NoValue; + } else { + if (($previousVol != NoValue) && ($this->m_volData[$i] > $previousVol) && ( + $previousClose != NoValue) && ($this->m_closeData[$i] != NoValue)) { + $pvi[$i] = $previousPVI + $previousPVI * ($this->m_closeData[$i] - + $previousClose) / $previousClose; + } else { + $pvi[$i] = $previousPVI; + } + + $previousPVI = $pvi[$i]; + $previousVol = $this->m_volData[$i]; + $previousClose = $this->m_closeData[$i]; + } + } + + $c = $this->addLineIndicator($height, $pvi, $color, "PVI"); + if (count($pvi) > $period) { + $label = "PVI SMA ($period)"; + $tmpArrayMath1 = new ArrayMath($pvi); + $tmpArrayMath1->movAvg($period); + $this->addLineIndicator2($c, $tmpArrayMath1->result(), $signalColor, $label); + } + return $c; + } + + #/ + #/ Add a Percentage Volume Oscillator indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The first moving average period to compute the indicator. + #/ The second moving average period to compute the indicator. + #/ The moving average period of the signal line. + #/ The color of the indicator line. + #/ The color of the signal line. + #/ The color of the divergent bars. + #/ The XYChart object representing the chart created. + function addPVO($height, $period1, $period2, $period3, $color, $signalColor, $divColor) { + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->expAvg(2.0 / ($period1 + 1)); + $expAvg1 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_volData); + $tmpArrayMath1->expAvg(2.0 / ($period2 + 1)); + $expAvg2 = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($expAvg2); + $tmpArrayMath1->sub($expAvg1); + $tmpArrayMath1->financeDiv($expAvg2, 0); + $pvo = $tmpArrayMath1->mul(100); + $tmpArrayMath1 = new ArrayMath($pvo->result()); + $tmpArrayMath1->expAvg(2.0 / ($period3 + 1)); + $pvoSignal = $tmpArrayMath1->result(); + + $label1 = "PVO ($period1, $period2)"; + $label2 = "EMA ($period3)"; + $c = $this->addLineIndicator($height, $pvo->result(), $color, $label1); + $this->addLineIndicator2($c, $pvoSignal, $signalColor, $label2); + $subtractObj = $pvo->sub($pvoSignal); + $this->addBarIndicator2($c, $subtractObj->result(), $divColor, "Divergence"); + return $c; + } + + #/ + #/ Add a Price Volumne Trend indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addPVT($height, $color) { + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->rate(); + $tmpArrayMath1->sub(1); + $tmpArrayMath1->mul($this->m_volData); + $tmpArrayMath1->acc(); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, "PVT"); + } + + #/ + #/ Add a Rate of Change indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addROC($height, $period, $color) { + $label = "ROC ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->rate($period); + $tmpArrayMath1->sub(1); + $tmpArrayMath1->mul(100); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + function RSIMovAvg($data, $period) { + #The "moving average" in classical RSI is based on a formula that mixes simple + #and exponential moving averages. + + if ($period <= 0) { + $period = 1; + } + + $count = 0; + $acc = 0; + + for($i = 0; $i < count($data); ++$i) { + if (abs($data[$i] / NoValue - 1) > 1e-005) { + $count = $count + 1; + $acc = $acc + $data[$i]; + if ($count < $period) { + $data[$i] = NoValue; + } else { + $data[$i] = $acc / $period; + $acc = $data[$i] * ($period - 1); + } + } + } + + return $data; + } + + function computeRSI($period) { + #RSI is defined as the average up changes for the last 14 days, divided by the + #average absolute changes for the last 14 days, expressed as a percentage. + + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->delta(); + $tmpArrayMath1->abs(); + $absChange = $this->RSIMovAvg($tmpArrayMath1->result(), $period); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->delta(); + $tmpArrayMath1->selectGTZ(); + $absUpChange = $this->RSIMovAvg($tmpArrayMath1->result(), $period); + $tmpArrayMath1 = new ArrayMath($absUpChange); + $tmpArrayMath1->financeDiv($absChange, 0.5); + $tmpArrayMath1->mul(100); + return $tmpArrayMath1->result(); + } + + #/ + #/ Add a Relative Strength Index indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The distance beween the middle line and the upper and lower threshold lines. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addRSI($height, $period, $color, $range, $upColor, $downColor) { + $c = $this->addIndicator($height); + $label = "RSI ($period)"; + $layer = $this->addLineIndicator2($c, $this->computeRSI($period), $color, $label); + + #Add range if given + if (($range > 0) && ($range < 50)) { + $this->addThreshold($c, $layer, 50 + $range, $upColor, 50 - $range, $downColor); + } + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add a Slow Stochastic indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the %K line. + #/ The period to compute the %D line. + #/ The color of the %K line. + #/ The color of the %D line. + #/ The XYChart object representing the chart created. + function addSlowStochastic($height, $period1, $period2, $color1, $color2) { + $tmpArrayMath1 = new ArrayMath($this->m_lowData); + $tmpArrayMath1->movMin($period1); + $movLow = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->movMax($period1); + $tmpArrayMath1->sub($movLow); + $movRange = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->sub($movLow); + $tmpArrayMath1->financeDiv($movRange, 0.5); + $tmpArrayMath1->mul(100); + $stochastic = $tmpArrayMath1->movAvg(3); + + $label1 = "Slow Stochastic %K ($period1)"; + $label2 = "%D ($period2)"; + $c = $this->addLineIndicator($height, $stochastic->result(), $color1, $label1); + $movAvgObj = $stochastic->movAvg($period2); + $this->addLineIndicator2($c, $movAvgObj->result(), $color2, $label2); + + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add a Moving Standard Deviation indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addStdDev($height, $period, $color) { + $label = "Moving StdDev ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->movStdDev($period); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + #/ + #/ Add a Stochastic RSI indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The distance beween the middle line and the upper and lower threshold lines. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addStochRSI($height, $period, $color, $range, $upColor, $downColor) { + $rsi = $this->computeRSI($period); + $tmpArrayMath1 = new ArrayMath($rsi); + $tmpArrayMath1->movMin($period); + $movLow = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($rsi); + $tmpArrayMath1->movMax($period); + $tmpArrayMath1->sub($movLow); + $movRange = $tmpArrayMath1->result(); + + $c = $this->addIndicator($height); + $label = "StochRSI ($period)"; + $tmpArrayMath1 = new ArrayMath($rsi); + $tmpArrayMath1->sub($movLow); + $tmpArrayMath1->financeDiv($movRange, 0.5); + $tmpArrayMath1->mul(100); + $layer = $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color, $label); + + #Add range if given + if (($range > 0) && ($range < 50)) { + $this->addThreshold($c, $layer, 50 + $range, $upColor, 50 - $range, $downColor); + } + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add a TRIX indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The XYChart object representing the chart created. + function addTRIX($height, $period, $color) { + $f = 2.0 / ($period + 1); + $label = "TRIX ($period)"; + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->expAvg($f); + $tmpArrayMath1->expAvg($f); + $tmpArrayMath1->expAvg($f); + $tmpArrayMath1->rate(); + $tmpArrayMath1->sub(1); + $tmpArrayMath1->mul(100); + return $this->addLineIndicator($height, $tmpArrayMath1->result(), $color, $label); + } + + function computeTrueLow() { + #the lower of today's low or yesterday's close. + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->shift(); + $previousClose = $tmpArrayMath1->result(); + $ret = array_pad(array(), count($this->m_lowData), 0); + for($i = 0; $i < count($this->m_lowData); ++$i) { + if (($this->m_lowData[$i] != NoValue) && ($previousClose[$i] != NoValue)) { + if ($this->m_lowData[$i] < $previousClose[$i]) { + $ret[$i] = $this->m_lowData[$i]; + } else { + $ret[$i] = $previousClose[$i]; + } + } else { + $ret[$i] = NoValue; + } + } + + return $ret; + } + + #/ + #/ Add an Ultimate Oscillator indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The first moving average period to compute the indicator. + #/ The second moving average period to compute the indicator. + #/ The third moving average period to compute the indicator. + #/ The color of the indicator line. + #/ The distance beween the middle line and the upper and lower threshold lines. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addUltimateOscillator($height, $period1, $period2, $period3, $color, $range, $upColor, + $downColor) { + $trueLow = $this->computeTrueLow(); + $tmpArrayMath1 = new ArrayMath($this->m_closeData); + $tmpArrayMath1->sub($trueLow); + $buyingPressure = $tmpArrayMath1->result(); + $trueRange = $this->computeTrueRange(); + + $tmpArrayMath2 = new ArrayMath($trueRange); + $tmpArrayMath2->movAvg($period1); + $tmpArrayMath1 = new ArrayMath($buyingPressure); + $tmpArrayMath1->movAvg($period1); + $tmpArrayMath1->financeDiv($tmpArrayMath2->result(), 0.5); + $tmpArrayMath1->mul(4); + $rawUO1 = $tmpArrayMath1->result(); + $tmpArrayMath2 = new ArrayMath($trueRange); + $tmpArrayMath2->movAvg($period2); + $tmpArrayMath1 = new ArrayMath($buyingPressure); + $tmpArrayMath1->movAvg($period2); + $tmpArrayMath1->financeDiv($tmpArrayMath2->result(), 0.5); + $tmpArrayMath1->mul(2); + $rawUO2 = $tmpArrayMath1->result(); + $tmpArrayMath2 = new ArrayMath($trueRange); + $tmpArrayMath2->movAvg($period3); + $tmpArrayMath1 = new ArrayMath($buyingPressure); + $tmpArrayMath1->movAvg($period3); + $tmpArrayMath1->financeDiv($tmpArrayMath2->result(), 0.5); + $tmpArrayMath1->mul(1); + $rawUO3 = $tmpArrayMath1->result(); + + $c = $this->addIndicator($height); + $label = "Ultimate Oscillator ($period1, $period2, $period3)"; + $tmpArrayMath1 = new ArrayMath($rawUO1); + $tmpArrayMath1->add($rawUO2); + $tmpArrayMath1->add($rawUO3); + $tmpArrayMath1->mul(100.0 / 7); + $layer = $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color, $label); + $this->addThreshold($c, $layer, 50 + $range, $upColor, 50 - $range, $downColor); + + $c->yAxis->setLinearScale(0, 100); + return $c; + } + + #/ + #/ Add a Volume indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The color to used on an 'up' day. An 'up' day is a day where + #/ the closing price is higher than that of the previous day. + #/ The color to used on a 'down' day. A 'down' day is a day + #/ where the closing price is lower than that of the previous day. + #/ The color to used on a 'flat' day. A 'flat' day is a day + #/ where the closing price is the same as that of the previous day. + #/ The XYChart object representing the chart created. + function addVolIndicator($height, $upColor, $downColor, $flatColor) { + $c = $this->addIndicator($height); + $this->addVolBars2($c, $height, $upColor, $downColor, $flatColor); + return $c; + } + + #/ + #/ Add a William %R indicator chart. + #/ + #/ The height of the indicator chart in pixels. + #/ The period to compute the indicator. + #/ The color of the indicator line. + #/ The distance beween the middle line and the upper and lower threshold lines. + #/ The fill color when the indicator exceeds the upper threshold line. + #/ The fill color when the indicator falls below the lower threshold line. + #/ The XYChart object representing the chart created. + function addWilliamR($height, $period, $color, $range, $upColor, $downColor) { + $tmpArrayMath1 = new ArrayMath($this->m_lowData); + $tmpArrayMath1->movMin($period); + $movLow = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($this->m_highData); + $tmpArrayMath1->movMax($period); + $movHigh = $tmpArrayMath1->result(); + $tmpArrayMath1 = new ArrayMath($movHigh); + $tmpArrayMath1->sub($movLow); + $movRange = $tmpArrayMath1->result(); + + $c = $this->addIndicator($height); + $tmpArrayMath1 = new ArrayMath($movHigh); + $tmpArrayMath1->sub($this->m_closeData); + $tmpArrayMath1->financeDiv($movRange, 0.5); + $tmpArrayMath1->mul(-100); + $layer = $this->addLineIndicator2($c, $tmpArrayMath1->result(), $color, "William %R"); + $this->addThreshold($c, $layer, -50 + $range, $upColor, -50 - $range, $downColor); + $c->yAxis->setLinearScale(-100, 0); + return $c; + } +} diff --git a/library/Vendors/ChartDirector/README.TXT b/library/Vendors/ChartDirector/README.TXT new file mode 100644 index 0000000..df77210 --- /dev/null +++ b/library/Vendors/ChartDirector/README.TXT @@ -0,0 +1,5 @@ +- Récupérer l'extension de ChartDirector pour PHP et le placer dans le répertoire des extensions +- Copier le répertoire "fonts" dans le répertoire des extensions PHP + Attention, pour que les fonts soient accessible placer le répertoire des extensions en chmod 755 +- Placer la clé dans le répertoire des extensions PHP + diff --git a/library/Vendors/ChartDirector/phpchartdir.php b/library/Vendors/ChartDirector/phpchartdir.php new file mode 100644 index 0000000..ad12ef7 --- /dev/null +++ b/library/Vendors/ChartDirector/phpchartdir.php @@ -0,0 +1,3719 @@ +Trying to load "'.$ext.'" from the PHP extension directory '.listExtDir().'.
'; + @cdSetHint(ini_get("extension_dir")); + if (dl($ext)) + return true; + + $ver = explode('.', phpversion()); + $ver = $ver[0] * 10000 + $ver[1] * 100 + $ver[2]; + if ((!$cdDebug) && ($ver >= 50205)) + return false; + + $scriptPath = dirname(__FILE__); + $tryPath = getRelExtPath($scriptPath); + if (!$tryPath) + return false; + + if ($cdDebug || (error_reporting() != 0)) + echo '
Trying to load "'.$ext.'" from '.listRelExtDir($scriptPath).'.
'; + @cdSetHint($scriptPath); + return dl($tryPath."/$ext"); +} + +function cdFilterMsg($msg) +{ + global $cdRelOp; + for ($j = 0; $j <= 10; ++$j) + { + $pos = strpos($msg, $cdRelOp); + if ($pos === false) + return $msg; + for ($i = $pos - 1; $i >= 0; --$i) + { + if (strstr(" \t\n\r'\"", $msg{$i})) + break; + } + $msg = substr($msg, 0, $i + 1)."/".substr($msg, $pos + strlen($cdRelOp)); + } + + return $msg; +} + +function listExtDir() +{ + $extdir = ini_get("extension_dir"); + if (($extdir{0} != "/") && ($extdir{0} != "\\") && ($extdir{1} != ":")) + return '"'.$extdir.'" (note: directory ambiguous)'; + elseif (isOnWindows() && ($extdir{1} != ":")) + return '"'.$extdir.'" (note: drive ambiguous)'; + else + return '"'.$extdir.'"'; +} + +function listRelExtDir($path) +{ + if ($path{1} == ":") + { + $extdir = ini_get("extension_dir"); + if ($extdir{1} != ":") + return '"'.substr($path, 2).'" (note: drive ambiguous)'; + } + return '"'.$path.'"'; +} + +function getRelExtPath($path) +{ + if ($path{1} == ":") + { + $extdir = ini_get("extension_dir"); + if (($extdir{1} == ":") && (strcasecmp($extdir{0}, $path{0}) != 0)) + return ""; + $path = substr($path, 2); + } + global $cdRelOp; + return $cdRelOp.substr($path, 1); +} + +function cdErrorHandler($errno, $errstr, $errfile, $errline) +{ + global $cdDebug; + if ($cdDebug || ((error_reporting() != 0) && (($errno & 0x3F7) != 0))) + echo "
".cdFilterMsg($errstr)."
"; +} + +if (!extension_loaded("ChartDirector PHP API")) +{ + $ver = explode('.', phpversion()); + $ver = $ver[0] * 10000 + $ver[1] * 100 + $ver[2]; + + if ($ver >= 50400) + $ext = "phpchartdir540.dll"; + else if ($ver >= 50300) + $ext = "phpchartdir530.dll"; + else if ($ver >= 50200) + $ext = "phpchartdir520.dll"; + else if ($ver >= 50100) + $ext = "phpchartdir510.dll"; + else if ($ver >= 50003) + $ext = "phpchartdir503.dll"; + else if ($ver >= 50000) + $ext = "phpchartdir500.dll"; + else if ($ver >= 40201) + $ext = "phpchartdir421.dll"; + else if ($ver >= 40100) + $ext = "phpchartdir410.dll"; + else if ($ver >= 40005) + $ext = "phpchartdir405.dll"; + else if ($ver >= 40004) + $ext = "phpchartdir404.dll"; + else + user_error("ChartDirector requires PHP 4.0.4 or above, but the current PHP version is ".phpversion().".", E_USER_ERROR); + + $old_error_handler = set_error_handler("cdErrorHandler"); + $old_html_errors = ini_set("html_errors", "0"); + ob_start(); +?> +
+Error Loading ChartDirector for PHP Extension +

+It appears this PHP system has not loaded the ChartDirector extension by using an extension +statement in the PHP configuration file (typically called "php.ini"). An attempt has been made +to dynamically load ChartDirector on the fly, but it was not successful. Please refer to the +Installation section of the ChartDirector for PHP documentation on how to resolve this problem. +

Error Log

+ 1) && (($ver < 50300) || (!isOnWindows()))) + $success = @cdLoadDLL($extList[1]); + } + else + $success = false; + + if ($success) + { + $dllVersion = (callmethod("getVersion") >> 16) & 0x7fff; + if ($dllVersion != $cdPhpVersion) + { + echo '
Version mismatch: "phpchartdir.php" is of version '.($cdPhpVersion >> 8). + '.'.($cdPhpVersion & 0xff).', but "'.(isOnWindows() ? "chartdir.dll" : "libchartdir.so"). + '" is of version '.($dllVersion >> 8).'.'.($dllVersion & 0xff).'.
'; + $success = 0; + } + } + + ini_set("html_errors", $old_html_errors); + restore_error_handler(); + if ($success) + ob_end_clean(); + else + ob_end_flush(); + + if (!$success) + { + if ($hasDL) + { + $dir_valid = 1; + if (!isOnWindows()) + { + $dir_valid = @opendir(ini_get("extension_dir")); + if ($dir_valid) + closedir($dir_valid); + } + + if (!$dir_valid) + { +?> +
+ +It appears the PHP extension directory of this system is configured as , +but this directory does not exist or is inaccessible. PHP will then refuse to load extensions from +any directory due to invalid directory configuration. Please ensure that directory exists and is +accessible by the web server. +
+ +The version and type of PHP in this system does not support dynmaic loading of PHP extensions. All +PHP extensions must be loaded by using extension statements in the PHP configuration file. + +

+System Information + + +__del__(); + $cd_garbage = array(); +} +register_shutdown_function("garbageCollector"); + +function decodePtr($p) { + if (is_null($p)) + return '$$pointer$$null'; + if (is_object($p)) + return $p->ptr; + else + return $p; +} + +#/////////////////////////////////////////////////////////////////////////////////// +#// constants +#/////////////////////////////////////////////////////////////////////////////////// +define("BottomLeft", 1); +define("BottomCenter", 2); +define("BottomRight", 3); +define("Left", 4); +define("Center", 5); +define("Right", 6); +define("TopLeft", 7); +define("TopCenter", 8); +define("TopRight", 9); +define("Top", TopCenter); +define("Bottom", BottomCenter); +define("TopLeft2", 10); +define("TopRight2", 11); +define("BottomLeft2", 12); +define("BottomRight2", 13); + +define("Transparent", 0xff000000); +define("Palette", 0xffff0000); +define("BackgroundColor", 0xffff0000); +define("LineColor", 0xffff0001); +define("TextColor", 0xffff0002); +define("DataColor", 0xffff0008); +define("SameAsMainColor", 0xffff0007); + +define("HLOCDefault", 0); +define("HLOCOpenClose", 1); +define("HLOCUpDown", 2); + +define("DiamondPointer", 0); +define("TriangularPointer", 1); +define("ArrowPointer", 2); +define("ArrowPointer2", 3); +define("LinePointer", 4); +define("PencilPointer", 5); + +define("ChartBackZ", 0x100); +define("ChartFrontZ", 0xffff); +define("PlotAreaZ", 0x1000); +define("GridLinesZ", 0x2000); + +define("XAxisSymmetric", 1); +define("XAxisSymmetricIfNeeded", 2); +define("YAxisSymmetric", 4); +define("YAxisSymmetricIfNeeded", 8); +define("XYAxisSymmetric", 16); +define("XYAxisSymmetricIfNeeded", 32); + +define("XAxisAtOrigin", 1); +define("YAxisAtOrigin", 2); +define("XYAxisAtOrigin", 3); + +define("NoValue", 1.7e308); +define("MinorTickOnly", -1.7e308); +define("MicroTickOnly", -1.6e308); +define("LogTick", 1.6e308); +define("LinearTick", 1.5e308); +define("TickInc", 1.0e200); +define("TouchBar", -1.69e-100); +define("AutoGrid", -2); + +define("NoAntiAlias", 0); +define("AntiAlias", 1); +define("AutoAntiAlias", 2); +define("ClearType", 3); +function ClearTypeMono($gamma = 0) { return callmethod("ClearTypeMono", $gamma); } +function ClearTypeColor($gamma = 0) { return callmethod("ClearTypeColor", $gamma); } +define("CompatAntiAlias", 6); + +define("BoxFilter", 0); +define("LinearFilter", 1); +define("QuadraticFilter", 2); +define("BSplineFilter", 3); +define("HermiteFilter", 4); +define("CatromFilter", 5); +define("MitchellFilter", 6); +define("SincFilter", 7); +define("LanczosFilter", 8); +define("GaussianFilter", 9); +define("HanningFilter", 10); +define("HammingFilter", 11); +define("BlackmanFilter", 12); +define("BesselFilter", 13); + +define("TryPalette", 0); +define("ForcePalette", 1); +define("NoPalette", 2); +define("Quantize", 0); +define("OrderedDither", 1); +define("ErrorDiffusion", 2); + +define("PNG", 0); +define("GIF", 1); +define("JPG", 2); +define("WMP", 3); +define("BMP", 4); +define("SVG", 5); +define("SVGZ", 6); + +define("Overlay", 0); +define("Stack", 1); +define("Depth", 2); +define("Side", 3); +define("Percentage", 4); + +$defaultPalette = array( + 0xffffff, 0x000000, 0x000000, 0x808080, + 0x808080, 0x808080, 0x808080, 0x808080, + 0xff3333, 0x33ff33, 0x6666ff, 0xffff00, + 0xff66ff, 0x99ffff, 0xffcc33, 0xcccccc, + 0xcc9999, 0x339966, 0x999900, 0xcc3300, + 0x669999, 0x993333, 0x006600, 0x990099, + 0xff9966, 0x99ff99, 0x9999ff, 0xcc6600, + 0x33cc33, 0xcc99ff, 0xff6666, 0x99cc66, + 0x009999, 0xcc3333, 0x9933ff, 0xff0000, + 0x0000ff, 0x00ff00, 0xffcc99, 0x999999, + -1 +); +function defaultPalette() { global $defaultPalette; return $defaultPalette; } + +$whiteOnBlackPalette = array( + 0x000000, 0xffffff, 0xffffff, 0x808080, + 0x808080, 0x808080, 0x808080, 0x808080, + 0xff0000, 0x00ff00, 0x0000ff, 0xffff00, + 0xff00ff, 0x66ffff, 0xffcc33, 0xcccccc, + 0x9966ff, 0x339966, 0x999900, 0xcc3300, + 0x99cccc, 0x006600, 0x660066, 0xcc9999, + 0xff9966, 0x99ff99, 0x9999ff, 0xcc6600, + 0x33cc33, 0xcc99ff, 0xff6666, 0x99cc66, + 0x009999, 0xcc3333, 0x9933ff, 0xff0000, + 0x0000ff, 0x00ff00, 0xffcc99, 0x999999, + -1 +); +function whiteOnBlackPalette() { global $whiteOnBlackPalette; return $whiteOnBlackPalette; } + +$transparentPalette = array( + 0xffffff, 0x000000, 0x000000, 0x808080, + 0x808080, 0x808080, 0x808080, 0x808080, + 0x80ff0000, 0x8000ff00, 0x800000ff, 0x80ffff00, + 0x80ff00ff, 0x8066ffff, 0x80ffcc33, 0x80cccccc, + 0x809966ff, 0x80339966, 0x80999900, 0x80cc3300, + 0x8099cccc, 0x80006600, 0x80660066, 0x80cc9999, + 0x80ff9966, 0x8099ff99, 0x809999ff, 0x80cc6600, + 0x8033cc33, 0x80cc99ff, 0x80ff6666, 0x8099cc66, + 0x80009999, 0x80cc3333, 0x809933ff, 0x80ff0000, + 0x800000ff, 0x8000ff00, 0x80ffcc99, 0x80999999, + -1 +); +function transparentPalette() { global $transparentPalette; return $transparentPalette; } + +define("NoSymbol", 0); +define("SquareSymbol", 1); +define("DiamondSymbol", 2); +define("TriangleSymbol", 3); +define("RightTriangleSymbol", 4); +define("LeftTriangleSymbol", 5); +define("InvertedTriangleSymbol", 6); +define("CircleSymbol", 7); +define("CrossSymbol", 8); +define("Cross2Symbol", 9); +define("PolygonSymbol", 11); +define("Polygon2Symbol", 12); +define("StarSymbol", 13); +define("CustomSymbol", 14); + +define("NoShape", 0); +define("SquareShape", 1); +define("DiamondShape", 2); +define("TriangleShape", 3); +define("RightTriangleShape", 4); +define("LeftTriangleShape", 5); +define("InvertedTriangleShape", 6); +define("CircleShape", 7); +define("CircleShapeNoShading", 10); +define("GlassSphereShape", 15); +define("GlassSphere2Shape", 16); +define("SolidSphereShape", 17); + +function cdBound($a, $b, $c) { + if ($b < $a) + return $a; + if ($b > $c) + return $c; + return $b; +} + +function CrossShape($width = 0.5) { + return CrossSymbol | (((int)(cdBound(0, $width, 1) * 4095 + 0.5)) << 12); +} +function Cross2Shape($width = 0.5) { + return Cross2Symbol | (((int)(cdBound(0, $width, 1) * 4095 + 0.5)) << 12); +} +function PolygonShape($side) { + return PolygonSymbol | (cdBound(0, $side, 100) << 12); +} +function Polygon2Shape($side) { + return Polygon2Symbol | (cdBound(0, $side, 100) << 12); +} +function StarShape($side) { + return StarSymbol | (cdBound(0, $side, 100) << 12); +} + +define("DashLine", 0x0505); +define("DotLine", 0x0202); +define("DotDashLine", 0x05050205); +define("AltDashLine", 0x0A050505); + +$goldGradient = array(0, 0xFFE743, 0x60, 0xFFFFE0, 0xB0, 0xFFF0B0, 0x100, 0xFFE743); +$silverGradient = array(0, 0xC8C8C8, 0x60, 0xF8F8F8, 0xB0, 0xE0E0E0, 0x100, 0xC8C8C8); +$redMetalGradient = array(0, 0xE09898, 0x60, 0xFFF0F0, 0xB0, 0xF0D8D8, 0x100, 0xE09898); +$blueMetalGradient = array(0, 0x9898E0, 0x60, 0xF0F0FF, 0xB0, 0xD8D8F0, 0x100, 0x9898E0); +$greenMetalGradient = array(0, 0x98E098, 0x60, 0xF0FFF0, 0xB0, 0xD8F0D8, 0x100, 0x98E098); +function goldGradient() { global $goldGradient; return $goldGradient; } +function silverGradient() { global $silverGradient; return $silverGradient; } +function redMetalGradient() { global $redMetalGradient; return $redMetalGradient; } +function blueMetalGradient() { global $blueMetalGradient; return $blueMetalGradient; } +function greenMetalGradient() { global $greenMetalGradient; return $greenMetalGradient; } + +function metalColor($c, $angle = 90) { + return callmethod("metalColor", $c, $angle); +} +function goldColor($angle = 90) { + return metalColor(0xffee44, $angle); +} +function silverColor($angle = 90) { + return metalColor(0xdddddd, $angle); +} +function brushedMetalColor($c, $texture = 2, $angle = 90) { + return metalColor($c, $angle) | (($texture & 0x3) << 18); +} +function brushedSilverColor($texture = 2, $angle = 90) { + return brushedMetalColor(0xdddddd, $texture, $angle); +} +function brushedGoldColor($texture = 2, $angle = 90) { + return brushedMetalColor(0xffee44, $texture, $angle); +} + +define("NormalLegend", 0); +define("ReverseLegend", 1); +define("NoLegend", 2); + +define("SideLayout", 0); +define("CircleLayout", 1); + +define("PixelScale", 0); +define("XAxisScale", 1); +define("YAxisScale", 2); +define("EndPoints", 3); +define("AngularAxisScale", XAxisScale); +define("RadialAxisScale", YAxisScale); + +define("MonotonicNone", 0); +define("MonotonicX", 1); +define("MonotonicY", 2); +define("MonotonicXY", 3); +define("MonotonicAuto", 4); + +define("ConstrainedLinearRegression", 0); +define("LinearRegression", 1); +define("ExponentialRegression", -1); +define("LogarithmicRegression", -2); + +function PolynomialRegression($n) { + return $n; +} + +define("SmoothShading", 0); +define("TriangularShading", 1); +define("RectangularShading", 2); +define("TriangularFrame", 3); +define("RectangularFrame", 4); +define("DataBound", -1.69E-100); + +define("StartOfHourFilterTag", 1); +define("StartOfDayFilterTag", 2); +define("StartOfWeekFilterTag", 3); +define("StartOfMonthFilterTag", 4); +define("StartOfYearFilterTag", 5); +define("RegularSpacingFilterTag", 6); +define("AllPassFilterTag", 7); +define("NonePassFilterTag", 8); +define("SelectItemFilterTag", 9); + +function StartOfHourFilter($labelStep = 1, $initialMargin = 0.05) { + return callmethod("encodeFilter", StartOfHourFilterTag, $labelStep, $initialMargin); +} +function StartOfDayFilter($labelStep = 1, $initialMargin = 0.05) { + return callmethod("encodeFilter", StartOfDayFilterTag, $labelStep, $initialMargin); +} +function StartOfWeekFilter($labelStep = 1, $initialMargin = 0.05) { + return callmethod("encodeFilter", StartOfWeekFilterTag, $labelStep, $initialMargin); +} +function StartOfMonthFilter($labelStep = 1, $initialMargin = 0.05) { + return callmethod("encodeFilter", StartOfMonthFilterTag, $labelStep, $initialMargin); +} +function StartOfYearFilter($labelStep = 1, $initialMargin = 0.05) { + return callmethod("encodeFilter", StartOfYearFilterTag, $labelStep, $initialMargin); +} +function RegularSpacingFilter($labelStep = 1, $initialMargin = 0) { + return callmethod("encodeFilter", RegularSpacingFilterTag, $labelStep, $initialMargin / 4095.0); +} +function AllPassFilter() { + return callmethod("encodeFilter", AllPassFilterTag, 0, 0); +} +function NonePassFilter() { + return callmethod("encodeFilter", NonePassFilterTag, 0, 0); +} +function SelectItemFilter($item) { + return callmethod("encodeFilter", SelectItemFilterTag, $item, 0); +} + +define("NormalGlare", 3); +define("ReducedGlare", 2); +define("NoGlare", 1); + +function glassEffect($glareSize = NormalGlare, $glareDirection = Top, $raisedEffect = 5) { + return callmethod("glassEffect", $glareSize, $glareDirection, $raisedEffect); +} +function softLighting($direction = Top, $raisedEffect = 4) { + return callmethod("softLighting", $direction, $raisedEffect); +} +function barLighting($startBrightness = 0.75, $endBrightness = 1.5) { + return callmethod("barLighting", $startBrightness, $endBrightness); +} +function cylinderEffect($orientation = Center, $ambientIntensity = 0.5, $diffuseIntensity = 0.5, $specularIntensity = 0.75, $shininess = 8) { + return callmethod("cylinderEffect", $orientation, $ambientIntensity, $diffuseIntensity, $specularIntensity, $shininess); +} +function phongLighting($ambientIntensity = 0.5, $diffuseIntensity = 0.5, $specularIntensity = 0.75, $shininess = 8) { + return callmethod("phongLighting", $ambientIntensity, $diffuseIntensity, $specularIntensity, $shininess); +} + +function cd_lower_bound($a, $v) { + $minI = 0; + $maxI = count($a); + while ($minI < $maxI) { + $midI = (int)(($minI + $maxI) / 2); + if ($a[$midI] < $v) + $minI = $midI + 1; + else + $maxI = $midI; + } + return $minI; +} + +function cd_bSearch($a, $v) { + if ((!$a) || (count($a) == 0)) + return -1; + $ret = cd_lower_bound($a, $v); + if ($ret == count($a)) + return $ret - 1; + if (($ret == 0) || ($a[$ret] == $v)) + return $ret; + return $ret - ($a[$ret] - $v) / ($a[$ret] - $a[$ret - 1]); +} + +define("DefaultShading", 0); +define("FlatShading", 1); +define("LocalGradientShading", 2); +define("GlobalGradientShading", 3); +define("ConcaveShading", 4); +define("RoundedEdgeNoGlareShading", 5); +define("RoundedEdgeShading", 6); +define("RadialShading", 7); +define("RingShading", 8); + +define("AggregateSum", 0); +define("AggregateAvg", 1); +define("AggregateStdDev", 2); +define("AggregateMin", 3); +define("AggregateMed", 4); +define("AggregateMax", 5); +define("AggregatePercentile", 6); +define("AggregateFirst", 7); +define("AggregateLast", 8); +define("AggregateCount", 9); + +class TTFText +{ + function TTFText($ptr) { + $this->ptr = $ptr; + autoDestroy($this); + } + function __del__() { + callmethod("TTFText.destroy", $this->ptr); + } + function getWidth() { + return callmethod("TTFText.getWidth", $this->ptr); + } + function getHeight() { + return callmethod("TTFText.getHeight", $this->ptr); + } + function getLineHeight() { + return callmethod("TTFText.getLineHeight", $this->ptr); + } + function getLineDistance() { + return callmethod("TTFText.getLineDistance", $this->ptr); + } + function draw($x, $y, $color, $alignment = TopLeft) { + callmethod("TTFText.draw", $this->ptr, $x, $y, $color, $alignment); + } +} + +class DrawArea { + function DrawArea($ptr = Null) { + if (is_null($ptr)) { + $this->ptr = callmethod("DrawArea.create"); + autoDestroy($this); + } + else { + $this->ptr = $ptr; + } + } + function __del__() { + callmethod("DrawArea.destroy", $this->ptr); + } + + function enableVectorOutput() { + callmethod("DrawArea.enableVectorOutput", $this->ptr); + } + function setSize($width, $height, $bgColor = 0xffffff) { + callmethod("DrawArea.setSize", $this->ptr, $width, $height, $bgColor); + } + function resize($newWidth, $newHeight, $f = LinearFilter, $blur = 1) { + callmethod("DrawArea.resize", $this->ptr, $newWidth, $newHeight, $f, $blur); + } + function getWidth() { + return callmethod("DrawArea.getWidth", $this->ptr); + } + function getHeight() { + return callmethod("DrawArea.getHeight", $this->ptr); + } + function setClipRect($left, $top, $right, $bottom) { + return callmethod("DrawArea.setClipRect", $this->ptr, $left, $top, $right, $bottom); + } + function setBgColor($c) { + callmethod("DrawArea.setBgColor", $this->ptr, $c); + } + function move($xOffset, $yOffset, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.move", $this->ptr, $xOffset, $yOffset, $bgColor, $ft, $blur); + } + function rotate($angle, $bgColor = 0xffffff, $cx = -1, $cy = -1, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.rotate", $this->ptr, $angle, $bgColor, $cx, $cy, $ft, $blur); + } + function hFlip() { + callmethod("DrawArea.hFlip", $this->ptr); + } + function vFlip() { + callmethod("DrawArea.vFlip", $this->ptr); + } + function cloneTo($d, $x, $y, $align, $newWidth = -1, $newHeight = -1, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.clone", $this->ptr, $d->ptr, $x, $y, $align, $newWidth, $newHeight, $ft, $blur); + } + function initDynamicLayer() { + callmethod("DrawArea.initDynamicLayer", $this->ptr); + } + function removeDynamicLayer($keepOriginal = false) { + callmethod("DrawArea.removeDynamicLayer", $this->ptr, $keepOriginal); + } + + function pixel($x, $y, $c) { + callmethod("DrawArea.pixel", $this->ptr, $x, $y, $c); + } + function getPixel($x, $y) { + return callmethod("DrawArea.getPixel", $this->ptr, $x, $y); + } + + function hline($x1, $x2, $y, $c) { + callmethod("DrawArea.hline", $this->ptr, $x1, $x2, $y, $c); + } + function vline($y1, $y2, $x, $c) { + callmethod("DrawArea.vline", $this->ptr, $y1, $y2, $x, $c); + } + function line($x1, $y1, $x2, $y2, $c, $lineWidth = 1) { + callmethod("DrawArea.line", $this->ptr, $x1, $y1, $x2, $y2, $c, $lineWidth); + } + function arc($cx, $cy, $rx, $ry, $a1, $a2, $c) { + callmethod("DrawArea.arc", $this->ptr, $cx, $cy, $rx, $ry, $a1, $a2, $c); + } + + function rect($x1, $y1, $x2, $y2, $edgeColor, $fillColor, $raisedEffect = 0) { + callmethod("DrawArea.rect", $this->ptr, $x1, $y1, $x2, $y2, $edgeColor, $fillColor, $raisedEffect); + } + function polygon($points, $edgeColor, $fillColor) { + $x = array(); + $y = array(); + reset($points); + while (list(, $coor) = each($points)) { + $x[] = $coor[0]; + $y[] = $coor[1]; + } + callmethod("DrawArea.polygon", $this->ptr, $x, $y, $edgeColor, $fillColor); + } + function surface($x1, $y1, $x2, $y2, $depthX, $depthY, $edgeColor, $fillColor) { + callmethod("DrawArea.surface", $this->ptr, $x1, $y1, $x2, $y2, $depthX, $depthY, $edgeColor, $fillColor); + } + function sector($cx, $cy, $rx, $ry, $a1, $a2, $edgeColor, $fillColor) { + callmethod("DrawArea.sector", $this->ptr, $cx, $cy, $rx, $ry, $a1, $a2, $edgeColor, $fillColor); + } + function cylinder($cx, $cy, $rx, $ry, $a1, $a2, $depthX, $depthY, $edgeColor, $fillColor) { + callmethod("DrawArea.cylinder", $this->ptr, $cx, $cy, $rx, $ry, $a1, $a2, $depthX, $depthY, $edgeColor, $fillColor); + } + function circle($cx, $cy, $rx, $ry, $edgeColor, $fillColor) { + callmethod("DrawArea.circle", $this->ptr, $cx, $cy, $rx, $ry, $edgeColor, $fillColor); + } + function circleShape($cx, $cy, $rx, $ry, $edgeColor, $fillColor) { + callmethod("DrawArea.circle", $this->ptr, $cx, $cy, $rx, $ry, $edgeColor, $fillColor); + } + + function fill($x, $y, $color, $borderColor = Null) { + if (is_null($borderColor)) + callmethod("DrawArea.fill", $this->ptr, $x, $y, $color); + else + $this->fill2($x, $y, $color, $borderColor); + } + function fill2($x, $y, $color, $borderColor) { + callmethod("DrawArea.fill2", $this->ptr, $x, $y, $color, $borderColor); + } + + function text($str, $font, $fontSize, $x, $y, $color) { + callmethod("DrawArea.text", $this->ptr, $str, $font, $fontSize, $x, $y, $color); + } + function text2($str, $font, $fontIndex, $fontHeight, $fontWidth, $angle, $vertical, $x, $y, $color, $alignment = TopLeft) { + callmethod("DrawArea.text2", $this->ptr, $str, $font, $fontIndex, $fontHeight, $fontWidth, $angle, $vertical, $x, $y, $color, $alignment); + } + function text3($str, $font, $fontSize) { + return new TTFText(callmethod("DrawArea.text3", $this->ptr, $str, $font, $fontSize)); + } + function text4($text, $font, $fontIndex, $fontHeight, $fontWidth, $angle, $vertical) { + return new TTFText(callmethod("DrawArea.text4", $this->ptr, $text, $font, $fontIndex, $fontHeight, $fontWidth, $angle, $vertical)); + } + + function merge($d, $x, $y, $align, $transparency) { + callmethod("DrawArea.merge", $this->ptr, $d->ptr, $x, $y, $align, $transparency); + } + function tile($d, $transparency) { + callmethod("DrawArea.tile", $this->ptr, $d->ptr, $transparency); + } + + function setSearchPath($path) { + callmethod("DrawArea.setSearchPath", $this->ptr, $path); + } + function loadGIF($filename) { + return callmethod("DrawArea.loadGIF", $this->ptr, $filename); + } + function loadPNG($filename) { + return callmethod("DrawArea.loadPNG", $this->ptr, $filename); + } + function loadJPG($filename) { + return callmethod("DrawArea.loadJPG", $this->ptr, $filename); + } + function loadWMP($filename) { + return callmethod("DrawArea.loadWMP", $this->ptr, $filename); + } + function load($filename) { + return callmethod("DrawArea.load", $this->ptr, $filename); + } + + function rAffineTransform($a, $b, $c, $d, $e, $f, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.rAffineTransform", $this->ptr, $a, $b, $c, $d, $e, $f, $bgColor, $ft, $blur); + } + function affineTransform($a, $b, $c, $d, $e, $f, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.affineTransform", $this->ptr, $a, $b, $c, $d, $e, $f, $bgColor, $ft, $blur); + } + function sphereTransform($xDiameter, $yDiameter, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.sphereTransform", $this->ptr, $xDiameter, $yDiameter, $bgColor, $ft, $blur); + } + function hCylinderTransform($yDiameter, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.hCylinderTransform", $this->ptr, $yDiameter, $bgColor, $ft, $blur); + } + function vCylinderTransform($xDiameter, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.vCylinderTransform", $this->ptr, $xDiameter, $bgColor, $ft, $blur); + } + function vTriangleTransform($tHeight = -1, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.vTriangleTransform", $this->ptr, $tHeight, $bgColor, $ft, $blur); + } + function hTriangleTransform($tWidth = -1, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.hTriangleTransform", $this->ptr, $tWidth, $bgColor, $ft, $blur); + } + function shearTransform($xShear, $yShear = 0, $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.shearTransform", $this->ptr, $xShear, $yShear, $bgColor, $ft, $blur); + } + function waveTransform($period, $amplitude, $direction = 0, $startAngle = 0, $longitudinal = 0, + $bgColor = 0xffffff, $ft = LinearFilter, $blur = 1) { + callmethod("DrawArea.waveTransform", $this->ptr, $period, $amplitude, $direction, $startAngle, + $longitudinal, $bgColor, $ft, $blur); + } + + function out($filename) { + return callmethod("DrawArea.out", $this->ptr, $filename); + } + function outGIF($filename) { + return callmethod("DrawArea.outGIF", $this->ptr, $filename); + } + function outPNG($filename) { + return callmethod("DrawArea.outPNG", $this->ptr, $filename); + } + function outJPG($filename, $quality = 80) { + return callmethod("DrawArea.outJPG", $this->ptr, $filename, $quality); + } + function outWMP($filename) { + return callmethod("DrawArea.outWMP", $this->ptr, $filename); + } + function outBMP($filename) { + return callmethod("DrawArea.outBMP", $this->ptr, $filename); + } + function outSVG($filename, $options = "") { + return callmethod("DrawArea.outSVG", $this->ptr, $filename, $options); + } + function outGIF2() { + return callmethod("DrawArea.outGIF2", $this->ptr); + } + function outPNG2() { + return callmethod("DrawArea.outPNG2", $this->ptr); + } + function outJPG2($quality = 80) { + return callmethod("DrawArea.outJPG2", $this->ptr, $quality); + } + function outWMP2() { + return callmethod("DrawArea.outWMP2", $this->ptr); + } + function outBMP2() { + return callmethod("DrawArea.outBMP2", $this->ptr); + } + function outSVG2($options = "") { + return callmethod("DrawArea.outSVG2", $this->ptr, $options); + } + + function setPaletteMode($p) { + callmethod("DrawArea.setPaletteMode", $this->ptr, $p); + } + function setDitherMethod($m) { + callmethod("DrawArea.setDitherMethod", $this->ptr, $m); + } + function setTransparentColor($c) { + callmethod("DrawArea.setTransparentColor", $this->ptr, $c); + } + function setAntiAliasText($a) { + callmethod("DrawArea.setAntiAliasText", $this->ptr, $a); + } + function setAntiAlias($shapeAntiAlias = 1, $textAntiAlias = AutoAntiAlias) { + callmethod("DrawArea.setAntiAlias", $this->ptr, $shapeAntiAlias, $textAntiAlias); + } + function setInterlace($i) { + callmethod("DrawArea.setInterlace", $this->ptr, $i); + } + + function setColorTable($colors, $offset) { + callmethod("DrawArea.setColorTable", $this->ptr, $colors, $offset); + } + function getARGBColor($c) { + return callmethod("DrawArea.getARGBColor", $this->ptr, $c); + } + function dashLineColor($color, $dashPattern = DashLine) { + return callmethod("DrawArea.dashLineColor", $this->ptr, $color, $dashPattern); + } + function patternColor($c, $h = 0, $startX = 0, $startY = 0) { + if (!is_array($c)) + return $this->patternColor2($c, $h, $startX); + return callmethod("DrawArea.patternColor", $this->ptr, $c, $h, $startX, $startY); + } + function patternColor2($filename, $startX = 0, $startY = 0) { + return callmethod("DrawArea.patternColor2", $this->ptr, $filename, $startX, $startY); + } + function gradientColor($startX, $startY = 90, $endX = 1, $endY = 0, $startColor = 0, $endColor = Null) { + if (is_array($startX)) + return $this->gradientColor2($startX, $startY, $endX, $endY, $startColor); + return callmethod("DrawArea.gradientColor", $this->ptr, $startX, $startY, $endX, $endY, $startColor, $endColor); + } + function gradientColor2($c, $angle = 90, $scale = 1, $startX = 0, $startY = 0) { + return callmethod("DrawArea.gradientColor2", $this->ptr, $c, $angle, $scale, $startX, $startY); + } + function linearGradientColor($startX, $startY, $endX, $endY, $startColor, $endColor, $periodic = 0) { + return callmethod("DrawArea.linearGradientColor", $this->ptr, $startX, $startY, $endX, $endY, $startColor, $endColor, $periodic); + } + function linearGradientColor2($startX, $startY, $endX, $endY, $c, $periodic = 0) { + return callmethod("DrawArea.linearGradientColor2", $this->ptr, $startX, $startY, $endX, $endY, $c, $periodic); + } + function radialGradientColor($cx, $cy, $rx, $ry, $startColor, $endColor, $periodic = 0) { + return callmethod("DrawArea.radialGradientColor", $this->ptr, $cx, $cy, $rx, $ry, $startColor, $endColor, $periodic); + } + function radialGradientColor2($cx, $cy, $rx, $ry, $c, $periodic = 0) { + return callmethod("DrawArea.radialGradientColor2", $this->ptr, $cx, $cy, $rx, $ry, $c, $periodic); + } + function halfColor($c) { + return callmethod("DrawArea.halfColor", $this->ptr, $c); + } + function adjustBrightness($c, $brightness) { + return callmethod("DrawArea.adjustBrightness", $this->ptr, $c, $brightness); + } + function reduceColors($colorCount, $blackAndWhite = 0) { + return callmethod("DrawArea.reduceColors", $this->ptr, $colorCount, $blackAndWhite); + } + + function setDefaultFonts($normal, $bold = "", $italic = "", $boldItalic = "") { + callmethod("DrawArea.setDefaultFonts", $this->ptr, $normal, $bold, $italic, $boldItalic); + } + function setFontTable($index, $font) { + callmethod("DrawArea.setFontTable", $this->ptr, $index, $font); + } +} + +class Box { + function Box($ptr) { + $this->ptr = $ptr; + } + function setPos($x, $y) { + callmethod("Box.setPos", $this->ptr, $x, $y); + } + function setSize($w, $h) { + callmethod("Box.setSize", $this->ptr, $w, $h); + } + function getLeftX() { + return callmethod("Box.getLeftX", $this->ptr); + } + function getTopY() { + return callmethod("Box.getTopY", $this->ptr); + } + function getWidth() { + return callmethod("Box.getWidth", $this->ptr); + } + function getHeight() { + return callmethod("Box.getHeight", $this->ptr); + } + function setBackground($color, $edgeColor = -1, $raisedEffect = 0) { + callmethod("Box.setBackground", $this->ptr, $color, $edgeColor, $raisedEffect); + } + function setRoundedCorners($r1 = 10, $r2 = -1, $r3 = -1, $r4 = -1) { + callmethod("Box.setRoundedCorners", $this->ptr, $r1, $r2, $r3, $r4); + } + function getImageCoor($offsetX = 0, $offsetY = 0) { + return callmethod("Box.getImageCoor", $this->ptr, $offsetX, $offsetY); + } +} + +class TextBox extends Box { + function TextBox($ptr) { + $this->ptr = $ptr; + } + function setText($text) { + callmethod("TextBox.setText", $this->ptr, $text); + } + function setAlignment($a) { + callmethod("TextBox.setAlignment", $this->ptr, $a); + } + function setFontStyle($font, $fontIndex = 0) { + callmethod("TextBox.setFontStyle", $this->ptr, $font, $fontIndex); + } + function setFontSize($fontHeight, $fontWidth = 0) { + callmethod("TextBox.setFontSize", $this->ptr, $fontHeight, $fontWidth); + } + function setFontAngle($angle, $vertical = 0) { + callmethod("TextBox.setFontAngle", $this->ptr, $angle, $vertical); + } + function setFontColor($color) { + callmethod("TextBox.setFontColor", $this->ptr, $color); + } + function setMargin2($leftMargin, $rightMargin, $topMargin, $bottomMargin) { + callmethod("TextBox.setMargin2", $this->ptr, + $leftMargin, $rightMargin, $topMargin, $bottomMargin); + } + function setMargin($m) { + callmethod("TextBox.setMargin", $this->ptr, $m); + } + function setWidth($width) { + callmethod("TextBox.setWidth", $this->ptr, $width); + } + function setHeight($height) { + callmethod("TextBox.setHeight", $this->ptr, $height); + } + function setMaxWidth($maxWidth) { + callmethod("TextBox.setMaxWidth", $this->ptr, $maxWidth); + } + function setZOrder($z) { + callmethod("TextBox.setZOrder", $this->ptr, $z); + } + function setTruncate($maxWidth, $maxLines = 1) { + callmethod("TextBox.setTruncate", $this->ptr, $maxWidth, $maxLines); + } +} + +class Line { + function Line($ptr) { + $this->ptr = $ptr; + } + function setPos($x1, $y1, $x2, $y2) { + callmethod("Line.setPos", $this->ptr, $x1, $y1, $x2, $y2); + } + function setColor($c) { + callmethod("Line.setColor", $this->ptr, $c); + } + function setWidth($w) { + callmethod("Line.setWidth", $this->ptr, $w); + } + function setZOrder($z) { + callmethod("Line.setZOrder", $this->ptr, $z); + } +} + +class CDMLTable { + function CDMLTable($ptr) { + $this->ptr = $ptr; + } + function setPos($x, $y, $alignment = TopLeft) { + callmethod("CDMLTable.setPos", $this->ptr, $x, $y, $alignment); + } + function insertCol($col) { + return new TextBox(callmethod("CDMLTable.insertCol", $this->ptr, $col)); + } + function appendCol() { + return new TextBox(callmethod("CDMLTable.appendCol", $this->ptr)); + } + function getColCount() { + return callmethod("CDMLTable.getColCount", $this->ptr); + } + + function insertRow($row) { + return new TextBox(callmethod("CDMLTable.insertRow", $this->ptr, $row)); + } + function appendRow() { + return new TextBox(callmethod("CDMLTable.appendRow", $this->ptr)); + } + function getRowCount() { + return callmethod("CDMLTable.getRowCount", $this->ptr); + } + + function setText($col, $row, $text) { + return new TextBox(callmethod("CDMLTable.setText", $this->ptr, $col, $row, $text)); + } + function setCell($col, $row, $width, $height, $text) { + return new TextBox(callmethod("CDMLTable.setCell", $this->ptr, $col, $row, $width, $height, $text)); + } + function getCell($col, $row) { + return new TextBox(callmethod("CDMLTable.getCell", $this->ptr, $col, $row)); + } + function getColStyle($col) { + return new TextBox(callmethod("CDMLTable.getColStyle", $this->ptr, $col)); + } + function getRowStyle($row) { + return new TextBox(callmethod("CDMLTable.getRowStyle", $this->ptr, $row)); + } + function getStyle() { + return new TextBox(callmethod("CDMLTable.getStyle", $this->ptr)); + } + function layout() { + callmethod("CDMLTable.layout", $this->ptr); + } + function getColWidth($col) { + return callmethod("CDMLTable.getColWidth", $this->ptr, $col); + } + function getRowHeight($row) { + return callmethod("CDMLTable.getRowHeight", $this->ptr, $row); + } + function getWidth() { + return callmethod("CDMLTable.getWidth", $this->ptr); + } + function getHeight() { + return callmethod("CDMLTable.getHeight", $this->ptr); + } + function setZOrder($z) { + callmethod("CDMLTable.setZOrder", $this->ptr, $z); + } +} + +class LegendBox extends TextBox { + function LegendBox($ptr) { + $this->ptr = $ptr; + } + function setCols($noOfCols) { + callmethod("LegendBox.setCols", $this->ptr, $noOfCols); + } + function setReverse($b = 1) { + callmethod("LegendBox.setReverse", $this->ptr, $b); + } + function setLineStyleKey($b = 1) { + callmethod("LegendBox.setLineStyleKey", $this->ptr, $b); + } + function addKey($text, $color, $lineWidth = 0, $drawarea = Null) { + callmethod("LegendBox.addKey", $this->ptr, $text, $color, $lineWidth, decodePtr($drawarea)); + } + function addKey2($pos, $text, $color, $lineWidth = 0, $drawarea = Null) { + callmethod("LegendBox.addKey2", $this->ptr, $pos, $text, $color, $lineWidth, decodePtr($drawarea)); + } + function setKeySize($width, $height = -1, $gap = -1) { + callmethod("LegendBox.setKeySize", $this->ptr, $width, $height, $gap); + } + function setKeySpacing($keySpacing, $lineSpacing = -1) { + callmethod("LegendBox.setKeySpacing", $this->ptr, $keySpacing, $lineSpacing); + } + function setKeyBorder($edgeColor, $raisedEffect = 0) { + callmethod("LegendBox.setKeyBorder", $this->ptr, $edgeColor, $raisedEffect); + } + function getImageCoor2($dataItem, $offsetX = 0, $offsetY = 0) { + return callmethod("LegendBox.getImageCoor", $this->ptr, $dataItem, $offsetX, $offsetY); + } + function getHTMLImageMap($url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("LegendBox.getHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } +} + +class BaseChart { + function __del__() { + callmethod("BaseChart.destroy", $this->ptr); + } + #////////////////////////////////////////////////////////////////////////////////////// + #// set overall chart + #////////////////////////////////////////////////////////////////////////////////////// + function enableVectorOutput() { + callmethod("BaseChart.enableVectorOutput", $this->ptr); + } + function setSize($width, $height) { + callmethod("BaseChart.setSize", $this->ptr, $width, $height); + } + function getWidth() { + return callmethod("BaseChart.getWidth", $this->ptr); + } + function getHeight() { + return callmethod("BaseChart.getHeight", $this->ptr); + } + function getAbsOffsetX() { + return callmethod("BaseChart.getAbsOffsetX", $this->ptr); + } + function getAbsOffsetY() { + return callmethod("BaseChart.getAbsOffsetY", $this->ptr); + } + function setBorder($color) { + callmethod("BaseChart.setBorder", $this->ptr, $color); + } + function setRoundedFrame($extColor = 0xffffff, $r1 = 10, $r2 = -1, $r3 = -1, $r4 = -1) { + callmethod("BaseChart.setRoundedFrame", $this->ptr, $extColor, $r1, $r2, $r3, $r4); + } + function setBackground($bgColor, $edgeColor = -1, $raisedEffect = 0) { + callmethod("BaseChart.setBackground", $this->ptr, $bgColor, $edgeColor, $raisedEffect); + } + function setWallpaper($img) { + callmethod("BaseChart.setWallpaper", $this->ptr, $img); + } + function setBgImage($img, $align = Center) { + callmethod("BaseChart.setBgImage", $this->ptr, $img, $align); + } + function setDropShadow($color = 0xaaaaaa, $offsetX = 5, $offsetY = 0x7fffffff, $blurRadius = 5) { + callmethod("BaseChart.setDropShadow", $this->ptr, $color, $offsetX, $offsetY, $blurRadius); + } + function setTransparentColor($c) { + callmethod("BaseChart.setTransparentColor", $this->ptr, $c); + } + function setAntiAlias($antiAliasShape = 1, $antiAliasText = AutoAntiAlias) { + callmethod("BaseChart.setAntiAlias", $this->ptr, $antiAliasShape, $antiAliasText); + } + function setSearchPath($path) { + callmethod("BaseChart.setSearchPath", $this->ptr, $path); + } + function initDynamicLayer() { + return new DrawArea(callmethod("BaseChart.initDynamicLayer", $this->ptr)); + } + function removeDynamicLayer() { + callmethod("BaseChart.removeDynamicLayer", $this->ptr); + } + + function addTitle2($alignment, $text, $font = "", $fontSize = 12, $fontColor = TextColor, + $bgColor = Transparent, $edgeColor = Transparent) { + return new TextBox(callmethod("BaseChart.addTitle2", $this->ptr, + $alignment, $text, $font, $fontSize, $fontColor, $bgColor, $edgeColor)); + } + function addTitle($text, $font = "", $fontSize = 12, $fontColor = TextColor, + $bgColor = Transparent, $edgeColor = Transparent) { + return new TextBox(callmethod("BaseChart.addTitle", $this->ptr, + $text, $font, $fontSize, $fontColor, $bgColor, $edgeColor)); + } + function addLegend($x, $y, $vertical = 1, $font = "", $fontSize = 10) { + return new LegendBox(callmethod("BaseChart.addLegend", $this->ptr, + $x, $y, $vertical, $font, $fontSize)); + } + function addLegend2($x, $y, $noOfCols, $font = "", $fontSize = 10) { + return new LegendBox(callmethod("BaseChart.addLegend2", $this->ptr, + $x, $y, $noOfCols, $font, $fontSize)); + } + function getLegend() { + return new LegendBox(callmethod("BaseChart.getLegend", $this->ptr)); + } + #////////////////////////////////////////////////////////////////////////////////////// + #// drawing primitives + #////////////////////////////////////////////////////////////////////////////////////// + function getDrawArea() { + return new DrawArea(callmethod("BaseChart.getDrawArea", $this->ptr)); + } + function addDrawObj($obj) { + callmethod("BaseChart.addDrawObj", $obj->ptr); + return $obj; + } + function addText($x, $y, $text, $font = "", $fontSize = 8, $fontColor = TextColor, + $alignment = TopLeft, $angle = 0, $vertical = 0) { + return new TextBox(callmethod("BaseChart.addText", $this->ptr, + $x, $y, $text, $font, $fontSize, $fontColor, $alignment, $angle, $vertical)); + } + function addLine($x1, $y1, $x2, $y2, $color = LineColor, $lineWidth = 1) { + return new Line(callmethod("BaseChart.addLine", $this->ptr, + $x1, $y1, $x2, $y2, $color, $lineWidth)); + } + function addTable($x, $y, $alignment, $col, $row) { + return new CDMLTable(callmethod("BaseChart.addTable", $this->ptr, $x, $y, $alignment, $col, $row)); + } + function addExtraField($texts) { + callmethod("BaseChart.addExtraField", $this->ptr, $texts); + } + function addExtraField2($numbers) { + callmethod("BaseChart.addExtraField2", $this->ptr, $numbers); + } + + #////////////////////////////////////////////////////////////////////////////////////// + #// $color management methods + #////////////////////////////////////////////////////////////////////////////////////// + function setColor($paletteEntry, $color) { + callmethod("BaseChart.setColor", $this->ptr, $paletteEntry, $color); + } + function setColors($colors) { + if (count($colors) <= 0 or $colors[count($colors) - 1] != -1) + $colors[] = -1; + callmethod("BaseChart.setColors", $this->ptr, $colors); + } + function setColors2($paletteEntry, $colors) { + if (count($colors) <= 0 or $colors[count($colors) - 1] != -1 ) + $colors[] = -1; + callmethod("BaseChart.setColors2", $this->ptr, $paletteEntry, $colors); + } + function getColor($paletteEntry) { + return callmethod("BaseChart.getColor", $this->ptr, $paletteEntry); + } + function dashLineColor($color, $dashPattern = DashLine) { + return callmethod("BaseChart.dashLineColor", $this->ptr, $color, $dashPattern); + } + function patternColor($c, $h = 0, $startX = 0, $startY = 0) { + if (!is_array($c)) + return $this->patternColor2($c, $h, $startX); + return callmethod("BaseChart.patternColor", $this->ptr, $c, $h, $startX, $startY); + } + function patternColor2($filename, $startX = 0, $startY = 0) { + return callmethod("BaseChart.patternColor2", $this->ptr, $filename, $startX, $startY); + } + function gradientColor($startX, $startY = 90, $endX = 1, $endY = 0, $startColor = 0, $endColor = Null) { + if (is_array($startX)) + return $this->gradientColor2($startX, $startY, $endX, $endY, $startColor); + return callmethod("BaseChart.gradientColor", $this->ptr, $startX, $startY, $endX, $endY, $startColor, $endColor); + } + function gradientColor2($c, $angle = 90, $scale = 1, $startX = 0, $startY = 0) { + return callmethod("BaseChart.gradientColor2", $this->ptr, $c, $angle, $scale, $startX, $startY); + } + function linearGradientColor($startX, $startY, $endX, $endY, $startColor, $endColor, $periodic = 0) { + return callmethod("BaseChart.linearGradientColor", $this->ptr, $startX, $startY, $endX, $endY, $startColor, $endColor, $periodic); + } + function linearGradientColor2($startX, $startY, $endX, $endY, $c, $periodic = 0) { + return callmethod("BaseChart.linearGradientColor2", $this->ptr, $startX, $startY, $endX, $endY, $c, $periodic); + } + function radialGradientColor($cx, $cy, $rx, $ry, $startColor, $endColor, $periodic = 0) { + return callmethod("BaseChart.radialGradientColor", $this->ptr, $cx, $cy, $rx, $ry, $startColor, $endColor, $periodic); + } + function radialGradientColor2($cx, $cy, $rx, $ry, $c, $periodic = 0) { + return callmethod("BaseChart.radialGradientColor2", $this->ptr, $cx, $cy, $rx, $ry, $c, $periodic); + } + + #////////////////////////////////////////////////////////////////////////////////////// + #// locale support + #////////////////////////////////////////////////////////////////////////////////////// + function setDefaultFonts($normal, $bold = "", $italic = "", $boldItalic = "") { + callmethod("BaseChart.setDefaultFonts", $this->ptr, $normal, $bold, $italic, $boldItalic); + } + function setFontTable($index, $font) { + callmethod("BaseChart.setFontTable", $this->ptr, $index, $font); + } + function setNumberFormat($thousandSeparator = '~', $decimalPointChar = '.', $signChar = '-') { + callmethod("BaseChart.setNumberFormat", $this->ptr, $thousandSeparator , $decimalPointChar, $signChar); + } + function setMonthNames($names) { + callmethod("BaseChart.setMonthNames", $this->ptr, $names); + } + function setWeekDayNames($names) { + callmethod("BaseChart.setWeekDayNames", $this->ptr, $names); + } + function setAMPM($AM, $PM) { + callmethod("BaseChart.setAMPM", $this->ptr, $AM, $PM); + } + function formatValue($value, $formatString) { + return callmethod("BaseChart.formatValue", $this->ptr, $value, $formatString); + } + + #////////////////////////////////////////////////////////////////////////////////////// + #// chart creation methods + #////////////////////////////////////////////////////////////////////////////////////// + function layoutLegend() { + return new LegendBox(callmethod("BaseChart.layoutLegend", $this->ptr)); + } + function layout() { + callmethod("BaseChart.layout", $this->ptr); + } + function makeChart($filename) { + return callmethod("BaseChart.makeChart", $this->ptr, $filename); + } + function makeChart2($format) { + return callmethod("BaseChart.makeChart2", $this->ptr, $format); + } + function makeChart3() { + return new DrawArea(callmethod("BaseChart.makeChart3", $this->ptr)); + } + function makeSession($id, $format = PNG) { + if (!defined('PHP_VERSION_ID')) + session_register($id); + else if (!session_id()) + session_start(); + global $HTTP_SESSION_VARS; + if (isset($HTTP_SESSION_VARS)) + $HTTP_SESSION_VARS[$id] = $GLOBALS[$id] = $this->makeChart2($format); + else + $_SESSION[$id] = $GLOBALS[$id] = $this->makeChart2($format); + $ret = "img=".$id."&id=".uniqid(session_id())."&".SID; + if (($format == SVG) || ($format == SVGZ)) + $ret .= "&stype=.svg"; + return $ret; + } + function getHTMLImageMap($url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("BaseChart.getHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } + function getJsChartModel($options = "") { + return callmethod("BaseChart.getJsChartModel", $this->ptr, $options); + } + + function halfColor($c) { + return callmethod("BaseChart.halfColor", $this->ptr, $c); + } + function adjustBrightness($c, $brightness) { + return callmethod("BaseChart.adjustBrightness", $this->ptr, $c, $brightness); + } + function autoColor() { + return callmethod("BaseChart.autoColor", $this->ptr); + } + function getChartMetrics() { + return callmethod("BaseChart.getChartMetrics", $this->ptr); + } +} + +class MultiChart extends BaseChart { + function MultiChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("MultiChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + $this->charts = array(); + $this->mainChart = null; + autoDestroy($this); + } + function addChart($x, $y, $c) { + if ($c) { + callmethod("MultiChart.addChart", $this->ptr, $x, $y, $c->ptr); + $this->charts[] = $c; + } + } + function getChart($i = 0) { + if ($i == -1) + return $this->mainChart; + if (($i >= 0) && ($i < count($this->charts))) + return $this->charts[$i]; + return null; + } + function getChartCount() { + return count($this->charts); + } + function setMainChart($c) { + $this->mainChart = $c; + callmethod("MultiChart.setMainChart", $this->ptr, $c->ptr); + } +} + +class Sector { + function Sector($ptr) { + $this->ptr = $ptr; + } + function setExplode($distance = -1) { + callmethod("Sector.setExplode", $this->ptr, $distance); + } + function setLabelFormat($formatString) { + callmethod("Sector.setLabelFormat", $this->ptr, $formatString); + } + function setLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor) { + return new TextBox(callmethod("Sector.setLabelStyle", $this->ptr, $font, $fontSize, $fontColor)); + } + function setLabelPos($pos, $joinLineColor = -1) { + callmethod("Sector.setLabelPos", $this->ptr, $pos, $joinLineColor); + } + function setJoinLine($joinLineColor, $joinLineWidth = 1) { + callmethod("Sector.setJoinLine", $this->ptr, $joinLineColor, $joinLineWidth); + } + function setColor($color, $edgeColor = -1, $joinLineColor = -1) { + callmethod("Sector.setColor", $this->ptr, $color, $edgeColor, $joinLineColor); + } + function setStyle($shadingMethod, $edgeColor = -1, $edgeWidth = -1) { + callmethod("Sector.setStyle", $this->ptr, $shadingMethod, $edgeColor, $edgeWidth); + } + function getImageCoor($offsetX = 0, $offsetY = 0) { + return callmethod("Sector.getImageCoor", $this->ptr, $offsetX, $offsetY); + } + function getLabelCoor($offsetX = 0, $offsetY = 0) { + return callmethod("Sector.getLabelCoor", $this->ptr, $offsetX, $offsetY); + } + function setLabelLayout($layoutMethod, $pos = -1) { + callmethod("Sector.setLabelLayout", $this->ptr, $layoutMethod, $pos); + } +} + +class PieChart extends BaseChart { + function PieChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("PieChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + autoDestroy($this); + } + function setPieSize($x, $y, $r) { + callmethod("PieChart.setPieSize", $this->ptr, $x, $y, $r); + } + function setDonutSize($x, $y, $r, $r2) { + callmethod("PieChart.setDonutSize", $this->ptr, $x, $y, $r, $r2); + } + function set3D($depth = -1, $angle = -1, $shadowMode = 0) { + if (is_array($depth)) + $this->set3D2($depth, $angle, $shadowMode); + else + callmethod("PieChart.set3D", $this->ptr, $depth, $angle, $shadowMode); + } + function set3D2($depths, $angle = 45, $shadowMode = 0) { + callmethod("PieChart.set3D2", $this->ptr, $depths, $angle, $shadowMode); + } + function setSectorStyle($shadingMethod, $edgeColor = -1, $edgeWidth = -1) { + callmethod("PieChart.setSectorStyle", $this->ptr, $shadingMethod, $edgeColor, $edgeWidth); + } + function setStartAngle($startAngle, $clockWise = 1) { + callmethod("PieChart.setStartAngle", $this->ptr, $startAngle, $clockWise); + } + function setExplode($sectorNo = -1, $distance = -1) { + callmethod("PieChart.setExplode", $this->ptr, $sectorNo, $distance); + } + function setExplodeGroup($startSector, $endSector, $distance = -1) { + callmethod("PieChart.setExplodeGroup", $this->ptr, $startSector, $endSector, $distance); + } + + function setLabelFormat($formatString) { + callmethod("PieChart.setLabelFormat", $this->ptr, $formatString); + } + function setLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor) { + return new TextBox(callmethod("PieChart.setLabelStyle", $this->ptr, $font, + $fontSize, $fontColor)); + } + function setLabelPos($pos, $joinLineColor = -1) { + callmethod("PieChart.setLabelPos", $this->ptr, $pos, $joinLineColor); + } + function setLabelLayout($layoutMethod, $pos = -1, $topBound = -1, $bottomBound = -1) { + callmethod("PieChart.setLabelLayout", $this->ptr, $layoutMethod, $pos, $topBound, $bottomBound); + } + function setJoinLine($joinLineColor, $joinLineWidth = 1) { + callmethod("PieChart.setJoinLine", $this->ptr, $joinLineColor, $joinLineWidth); + } + function setLineColor($edgeColor, $joinLineColor = -1) { + callmethod("PieChart.setLineColor", $this->ptr, $edgeColor, $joinLineColor); + } + + function setData($data, $labels = Null) { + callmethod("PieChart.setData", $this->ptr, $data, $labels); + } + function sector($sectorNo) { + return new Sector(callmethod("PieChart.sector", $this->ptr, $sectorNo)); + } + function getSector($sectorNo) { + return $this->sector($sectorNo); + } +} + +class Mark extends TextBox { + function Mark($ptr) { + $this->ptr = $ptr; + } + function setValue($value) { + callmethod("Mark.setValue", $this->ptr, $value); + } + function setMarkColor($lineColor, $textColor = -1, $tickColor = -1) { + callmethod("Mark.setMarkColor", $this->ptr, $lineColor, $textColor, $tickColor); + } + function setLineWidth($w) { + callmethod("Mark.setLineWidth", $this->ptr, $w); + } + function setDrawOnTop($b) { + callmethod("Mark.setDrawOnTop", $this->ptr, $b); + } + function getLine() { + return callmethod("Mark.getLine", $this->ptr); + } +} + +class Axis { + function Axis($ptr) { + $this->ptr = $ptr; + } + function setLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("Axis.setLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + function setLabelFormat($formatString) { + callmethod("Axis.setLabelFormat", $this->ptr, $formatString); + } + function setLabelGap($d) { + callmethod("Axis.setLabelGap", $this->ptr, $d); + } + function setMultiFormat($filter1, $format1, $filter2 = 1, $format2 = Null, $labelSpan = 1, $promoteFirst = 1) { + if (is_null($format2)) + $this->setMultiFormat2($filter1, $format1, $filter2, 1); + else + callmethod("Axis.setMultiFormat", $this->ptr, $filter1, $format1, $filter2, $format2, $labelSpan, $promoteFirst); + } + function setMultiFormat2($filterId, $formatString, $labelSpan = 1, $promoteFirst = 1) { + callmethod("Axis.setMultiFormat2", $this->ptr, $filterId, $formatString, $labelSpan, $promoteFirst); + } + function setFormatCondition($condition, $operand = 0) { + callmethod("Axis.setFormatCondition", $this->ptr, $condition, $operand); + } + + function setTitle($text, $font = "", $fontSize = 8, $fontColor = TextColor) { + return new TextBox(callmethod("Axis.setTitle", $this->ptr, $text, $font, $fontSize, $fontColor)); + } + function setTitlePos($alignment, $titleGap = 3) { + callmethod("Axis.setTitlePos", $this->ptr, $alignment, $titleGap); + } + function setColors($axisColor, $labelColor = TextColor, $titleColor = -1, $tickColor = -1) { + callmethod("Axis.setColors", $this->ptr, $axisColor, $labelColor, $titleColor, $tickColor); + } + + function setTickLength($majorTickLen, $minorTickLen = Null) { + if (is_null($minorTickLen)) + callmethod("Axis.setTickLength", $this->ptr, $majorTickLen); + else + $this->setTickLength2($majorTickLen, $minorTickLen); + } + function setTickLength2($majorTickLen, $minorTickLen) { + callmethod("Axis.setTickLength2", $this->ptr, $majorTickLen, $minorTickLen); + } + function setTickWidth($majorTickWidth, $minorTickWidth = -1) { + callmethod("Axis.setTickWidth", $this->ptr, $majorTickWidth, $minorTickWidth); + } + function setTickColor($majorTickColor, $minorTickColor = -1) { + callmethod("Axis.setTickColor", $this->ptr, $majorTickColor, $minorTickColor); + } + + function setWidth($width) { + callmethod("Axis.setWidth", $this->ptr, $width); + } + function setLength($length) { + callmethod("Axis.setLength", $this->ptr, $length); + } + function setOffset($x, $y) { + callmethod("Axis.setOffset", $this->ptr, $x, $y); + } + function setTopMargin($topMargin) { + $this->setMargin($topMargin); + } + function setMargin($topMargin, $bottomMargin = 0) { + callmethod("Axis.setMargin", $this->ptr, $topMargin, $bottomMargin); + } + function setIndent($indent) { + callmethod("Axis.setIndent", $this->ptr, $indent); + } + function setTickOffset($offset) { + callmethod("Axis.setTickOffset", $this->ptr, $offset); + } + function setLabelOffset($offset) { + callmethod("Axis.setLabelOffset", $this->ptr, $offset); + } + + function setAutoScale($topExtension = 0.1, $bottomExtension = 0.1, $zeroAffinity = 0.8) { + callmethod("Axis.setAutoScale", $this->ptr, $topExtension, $bottomExtension, $zeroAffinity); + } + function setRounding($roundMin, $roundMax) { + callmethod("Axis.setRounding", $this->ptr, $roundMin, $roundMax); + } + function setTickDensity($majorTickDensity, $minorTickSpacing = -1) { + callmethod("Axis.setTickDensity", $this->ptr, $majorTickDensity, $minorTickSpacing); + } + function setReverse($b = 1) { + callmethod("Axis.setReverse", $this->ptr, $b); + } + function setMinTickInc($inc) { + callmethod("Axis.setMinTickInc", $this->ptr, $inc); + } + + function setLabels($labels, $formatString = Null) { + if (is_null($formatString)) + return new TextBox(callmethod("Axis.setLabels", $this->ptr, $labels)); + else + return $this->setLabels2($labels, $formatString); + } + function setLabels2($labels, $formatString = "") { + return new TextBox(callmethod("Axis.setLabels2", $this->ptr, $labels, $formatString)); + } + function makeLabelTable() { + return new CDMLTable(callmethod("Axis.makeLabelTable", $this->ptr)); + } + function getLabelTable() { + return new CDMLTable(callmethod("Axis.getLabelTable", $this->ptr)); + } + + function setLabelStep($majorTickStep, $minorTickStep = 0, $majorTickOffset = 0, $minorTickOffset = -0x7fffffff) { + callmethod("Axis.setLabelStep", $this->ptr, $majorTickStep, $minorTickStep, $majorTickOffset, $minorTickOffset); + } + + function setLinearScale($lowerLimit = Null, $upperLimit = Null, $majorTickInc = 0, $minorTickInc = 0) { + if (is_null($lowerLimit)) + $this->setLinearScale3(); + else if (is_null($upperLimit)) + $this->setLinearScale3($lowerLimit); + else if (is_array($majorTickInc)) + $this->setLinearScale2($lowerLimit, $upperLimit, $majorTickInc); + else + callmethod("Axis.setLinearScale", $this->ptr, $lowerLimit, $upperLimit, $majorTickInc, $minorTickInc); + } + function setLinearScale2($lowerLimit, $upperLimit, $labels) { + callmethod("Axis.setLinearScale2", $this->ptr, $lowerLimit, $upperLimit, $labels); + } + function setLinearScale3($formatString = "") { + callmethod("Axis.setLinearScale3", $this->ptr, $formatString); + } + + function setLogScale($lowerLimit = Null, $upperLimit = Null, $majorTickInc = 0, $minorTickInc = 0) { + if (is_null($lowerLimit)) + $this->setLogScale3(); + else if (is_null($upperLimit)) + $this->setLogScale3($lowerLimit); + else if (is_array($majorTickInc)) + $this->setLogScale2($lowerLimit, $upperLimit, $majorTickInc); + else + callmethod("Axis.setLogScale", $this->ptr, $lowerLimit, $upperLimit, $majorTickInc, $minorTickInc); + } + function setLogScale2($lowerLimit, $upperLimit, $labels = 0) { + if (is_array($labels)) + callmethod("Axis.setLogScale2", $this->ptr, $lowerLimit, $upperLimit, $labels); + else + #compatibility with ChartDirector Ver 2.5 + $this->setLogScale($lowerLimit, $upperLimit, $labels); + } + function setLogScale3($formatString = "") { + if (!is_string($formatString)) { + #compatibility with ChartDirector Ver 2.5 + if ($formatString) + $this->setLogScale3(); + else + $this->setLinearScale3(); + } + else + callmethod("Axis.setLogScale3", $this->ptr, $formatString); + } + + function setDateScale($lowerLimit = Null, $upperLimit = Null, $majorTickInc = 0, $minorTickInc = 0) { + if (is_null($lowerLimit)) + $this->setDateScale3(); + else if (is_null($upperLimit)) + $this->setDateScale3($lowerLimit); + else if (is_array($majorTickInc)) + $this->setDateScale2($lowerLimit, $upperLimit, $majorTickInc); + else + callmethod("Axis.setDateScale", $this->ptr, $lowerLimit, $upperLimit, $majorTickInc, $minorTickInc); + } + function setDateScale2($lowerLimit, $upperLimit, $labels) { + callmethod("Axis.setDateScale2", $this->ptr, $lowerLimit, $upperLimit, $labels); + } + function setDateScale3($formatString = "") { + callmethod("Axis.setDateScale3", $this->ptr, $formatString); + } + + function syncAxis($axis, $slope = 1, $intercept = 0) { + callmethod("Axis.syncAxis", $this->ptr, $axis->ptr, $slope, $intercept); + } + function copyAxis($axis) { + callmethod("Axis.copyAxis", $this->ptr, $axis->ptr); + } + + function addLabel($pos, $label) { + callmethod("Axis.addLabel", $this->ptr, $pos, $label); + } + function addMark($lineColor, $value, $text = "", $font = "", $fontSize = 8) { + return new Mark(callmethod("Axis.addMark", $this->ptr, $lineColor, $value, $text, $font, $fontSize)); + } + function addZone($startValue, $endValue, $color) { + callmethod("Axis.addZone", $this->ptr, $startValue, $endValue, $color); + } + + function getCoor($v) { + return callmethod("Axis.getCoor", $this->ptr, $v); + } + function getX() { + return callmethod("Axis.getX", $this->ptr); + } + function getY() { + return callmethod("Axis.getY", $this->ptr); + } + function getAlignment() { + return callmethod("Axis.getAlignment", $this->ptr); + } + function getLength() { + return callmethod("Axis.getLength", $this->ptr); + } + function getMinValue() { + return callmethod("Axis.getMinValue", $this->ptr); + } + function getMaxValue() { + return callmethod("Axis.getMaxValue", $this->ptr); + } + function getThickness() { + return callmethod("Axis.getThickness", $this->ptr); + } + function getScaleType() { + return callmethod("Axis.getScaleType", $this->ptr); + } + + function getTicks() { + return callmethod("Axis.getTicks", $this->ptr); + } + function getLabel($i) { + return callmethod("Axis.getLabel", $this->ptr, $i); + } + function getFormattedLabel($v, $formatString = "") { + return callmethod("Axis.getFormattedLabel", $this->ptr, $v, $formatString); + } + + function getAxisImageMap($noOfSegments, $mapWidth, $url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("Axis.getAxisImageMap", $this->ptr, $noOfSegments, $mapWidth, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } + function getHTMLImageMap($url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("Axis.getHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } +} + +class AngularAxis { + function AngularAxis($ptr) { + $this->ptr = $ptr; + } + function setLabelStyle($font = "bold", $fontSize = 10, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("AngularAxis.setLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + function setLabelGap($d) { + callmethod("AngularAxis.setLabelGap", $this->ptr, $d); + } + + function setLabels($labels, $formatString = Null) { + if (is_null($formatString)) + return new TextBox(callmethod("AngularAxis.setLabels", $this->ptr, $labels)); + else + return $this->setLabels2($labels, $formatString); + } + function setLabels2($labels, $formatString = "") { + return new TextBox(callmethod("AngularAxis.setLabels2", $this->ptr, $labels, $formatString)); + } + function addLabel($pos, $label) { + callmethod("AngularAxis.addLabel", $this->ptr, $pos, $label); + } + + function setLinearScale($lowerLimit, $upperLimit, $majorTickInc = 0, $minorTickInc = 0) { + if (is_array($majorTickInc)) + $this->setLinearScale2($lowerLimit, $upperLimit, $majorTickInc); + else + callmethod("AngularAxis.setLinearScale", $this->ptr, $lowerLimit, $upperLimit, $majorTickInc, $minorTickInc); + } + function setLinearScale2($lowerLimit, $upperLimit, $labels) { + callmethod("AngularAxis.setLinearScale2", $this->ptr, $lowerLimit, $upperLimit, $labels); + } + + function addZone($startValue, $endValue, $startRadius, $endRadius = -1, $fillColor = Null, $edgeColor = -1) { + if (is_null($fillColor)) + $this->addZone2($startValue, $endValue, $startRadius, $endRadius); + else + callmethod("AngularAxis.addZone", $this->ptr, $startValue, $endValue, $startRadius, $endRadius, $fillColor, $edgeColor); + } + function addZone2($startValue, $endValue, $fillColor, $edgeColor = -1) { + callmethod("AngularAxis.addZone2", $this->ptr, $startValue, $endValue, $fillColor, $edgeColor); + } + + function getCoor($v) { + return callmethod("AngularAxis.getCoor", $this->ptr, $v); + } + function getTicks() { + return callmethod("AngularAxis.getTicks", $this->ptr); + } + function getLabel($i) { + return callmethod("AngularAxis.getLabel", $this->ptr, $i); + } + + function getAxisImageMap($noOfSegments, $mapWidth, $url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("AngularAxis.getAxisImageMap", $this->ptr, $noOfSegments, $mapWidth, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } + function getHTMLImageMap($url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("AngularAxis.getHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } +} + +class ColorAxis extends Axis { + function ColorAxis($ptr) { + $this->ptr = $ptr; + } + function setColorGradient($isContinuous = 1, $colors = Null, $overflowColor = -1, $underflowColor = -1) { + callmethod("ColorAxis.setColorGradient", $this->ptr, $isContinuous, $colors, $overflowColor, $underflowColor); + } + function setAxisPos($x, $y, $alignment) { + callmethod("ColorAxis.setAxisPos", $this->ptr, $x, $y, $alignment); + } + function setLevels($maxLevels) { + callmethod("ColorAxis.setLevels", $this->ptr, $maxLevels); + } + function setCompactAxis($b = 1) { + callmethod("ColorAxis.setCompactAxis", $this->ptr, $b); + } + function setAxisBorder($edgeColor, $raisedEffect = 0) { + callmethod("ColorAxis.setAxisBorder", $this->ptr, $edgeColor, $raisedEffect); + } + function setBoundingBox($fillColor, $edgeColor = Transparent, $raisedEffect = 0) { + callmethod("ColorAxis.setBoundingBox", $this->ptr, $fillColor, $edgeColor, $raisedEffect); + } + function setBoxMargin($m) { + callmethod("ColorAxis.setBoxMargin", $this->ptr, $m); + } + function setBoxMargin2($leftMargin, $rightMargin, $topMargin, $bottomMargin) { + callmethod("ColorAxis.setBoxMargin2", $this->ptr, $leftMargin, $rightMargin, $topMargin, $bottomMargin); + } + function setRoundedCorners($r1 = 10, $r2 = -1, $r3 = -1, $r4 = -1) { + callmethod("ColorAxis.setRoundedCorners", $this->ptr, $r1, $r2, $r3, $r4); + } + function getBoxWidth() { + return callmethod("ColorAxis.getBoxWidth", $this->ptr); + } + function getBoxHeight() { + return callmethod("ColorAxis.getBoxHeight", $this->ptr); + } + function getColor($z) { + return callmethod("ColorAxis.getColor", $this->ptr, $z); + } +} + +class DataSet { + function DataSet($ptr) { + $this->ptr = $ptr; + } + function setData($data) { + callmethod("DataSet.setData", $this->ptr, $data); + } + function getValue($i) { + return callmethod("DataSet.getValue", $this->ptr, $i); + } + function getPosition($i) { + return callmethod("DataSet.getPosition", $this->ptr, $i); + } + + function setDataName($name) { + callmethod("DataSet.setDataName", $this->ptr, $name); + } + function getDataName() { + return callmethod("DataSet.getDataName", $this->ptr); + } + function setDataColor($dataColor, $edgeColor = -1, $shadowColor = -1, $shadowEdgeColor = -1) { + callmethod("DataSet.setDataColor", $this->ptr, $dataColor, $edgeColor, $shadowColor, $shadowEdgeColor); + } + function getDataColor() { + return callmethod("DataSet.getDataColor", $this->ptr); + } + function setUseYAxis2($b = 1) { + callmethod("DataSet.setUseYAxis2", $this->ptr, $b); + } + function setUseYAxis($a) { + callmethod("DataSet.setUseYAxis", $this->ptr, $a->ptr); + } + function getUseYAxis() { + return new Axis(callmethod("DataSet.getUseYAxis", $this->ptr)); + } + function setLineWidth($w) { + callmethod("DataSet.setLineWidth", $this->ptr, $w); + } + + function setDataLabelFormat($formatString) { + callmethod("DataSet.setDataLabelFormat", $this->ptr, $formatString); + } + function setDataLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("DataSet.setDataLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + + function setDataSymbol($symbol, $size = Null, $fillColor = -1, $edgeColor = -1, $lineWidth = 1) { + if (is_array($symbol)) { + if (is_null($size)) + $size = 11; + $this->setDataSymbol4($symbol, $size, $fillColor, $edgeColor); + return; + } + if (!is_numeric($symbol)) + return $this->setDataSymbol2($symbol); + if (is_null($size)) + $size = 5; + callmethod("DataSet.setDataSymbol", $this->ptr, $symbol, $size, $fillColor, $edgeColor, $lineWidth); + } + function setDataSymbol2($image) { + if (!is_string($image)) + return $this->setDataSymbol3($image); + callmethod("DataSet.setDataSymbol2", $this->ptr, $image); + } + function setDataSymbol3($image) { + callmethod("DataSet.setDataSymbol3", $this->ptr, $image->ptr); + } + function setDataSymbol4($polygon, $size = 11, $fillColor = -1, $edgeColor = -1) { + callmethod("DataSet.setDataSymbol4", $this->ptr, $polygon, $size, $fillColor, $edgeColor); + } + function getLegendIcon() { + return callmethod("DataSet.getLegendIcon", $this->ptr); + } +} + +class Layer { + function Layer($ptr) { + $this->ptr = $ptr; + } + function moveFront($layer = Null) { + callmethod("Layer.moveFront", $this->ptr, decodePtr($layer)); + } + function moveBack($layer = Null) { + callmethod("Layer.moveBack", $this->ptr, decodePtr($layer)); + } + function setBorderColor($color, $raisedEffect = 0) { + callmethod("Layer.setBorderColor", $this->ptr, $color, $raisedEffect); + } + function set3D($d = -1, $zGap = 0) { + callmethod("Layer.set3D", $this->ptr, $d, $zGap); + } + function set3D2($xDepth, $yDepth, $xGap, $yGap) { + callmethod("Layer.set3D2", $this->ptr, $xDepth, $yDepth, $xGap, $yGap); + } + function setLineWidth($w) { + callmethod("Layer.setLineWidth", $this->ptr, $w); + } + function setLegend($m) { + callmethod("Layer.setLegend", $this->ptr, $m); + } + function setLegendOrder($dataSetOrder, $layerOrder = -1) { + callmethod("Layer.setLegendOrder", $this->ptr, $dataSetOrder, $layerOrder); + } + function getLegendIcon($dataSetNo) { + return callmethod("Layer.getLegendIcon", $this->ptr, $dataSetNo); + } + function setDataCombineMethod($m) { + callmethod("Layer.setDataCombineMethod", $this->ptr, $m); + } + function setBaseLine($baseLine) { + callmethod("Layer.setBaseLine", $this->ptr, $baseLine); + } + function addDataSet($data, $color = -1, $name = "") { + return new DataSet(callmethod("Layer.addDataSet", $this->ptr, $data, $color, $name)); + } + function addDataGroup($name = "") { + callmethod("Layer.addDataGroup", $this->ptr, $name); + } + function addExtraField($texts) { + callmethod("Layer.addExtraField", $this->ptr, $texts); + } + function addExtraField2($numbers) { + callmethod("Layer.addExtraField2", $this->ptr, $numbers); + } + function getDataSet($i) { + return new DataSet(callmethod("Layer.getDataSet", $this->ptr, $i)); + } + function getDataSetByZ($i) { + return new DataSet(callmethod("Layer.getDataSetByZ", $this->ptr, $i)); + } + function getDataSetCount() { + return callmethod("Layer.getDataSetCount", $this->ptr); + } + function setUseYAxis2($b = 1) { + callmethod("Layer.setUseYAxis2", $this->ptr, $b); + } + function setUseYAxis($a) { + callmethod("Layer.setUseYAxis", $this->ptr, $a->ptr); + } + + function setXData($xData, $maxValue = Null) { + if (is_null($maxValue)) + callmethod("Layer.setXData", $this->ptr, $xData); + else + $this->setXData2($xData, $maxValue); + } + function setXData2($minValue, $maxValue) { + callmethod("Layer.setXData2", $this->ptr, $minValue, $maxValue); + } + function getXPosition($i) { + return callmethod("Layer.getXPosition", $this->ptr, $i); + } + function getNearestXValue($target) { + return callmethod("Layer.getNearestXValue", $this->ptr, $target); + } + function getXIndexOf($xValue, $tolerance = 0) { + return callmethod("Layer.getXIndexOf", $this->ptr, $xValue, $tolerance); + } + function alignLayer($layer, $dataSet) { + callmethod("Layer.alignLayer", $this->ptr, $layer->ptr, $dataSet); + } + + function getMinX() { + return callmethod("Layer.getMinX", $this->ptr); + } + function getMaxX() { + return callmethod("Layer.getMaxX", $this->ptr); + } + function getMaxY($yAxis = 1) { + return callmethod("Layer.getMaxY", $this->ptr, $yAxis); + } + function getMinY($yAxis = 1) { + return callmethod("Layer.getMinY", $this->ptr, $yAxis); + } + function getDepthX() { + return callmethod("Layer.getDepthX", $this->ptr); + } + function getDepthY() { + return callmethod("Layer.getDepthY", $this->ptr); + } + function getXCoor($v) { + return callmethod("Layer.getXCoor", $this->ptr, $v); + } + function getYCoor($v, $yAxis = 1) { + if (is_object($yAxis)) + return callmethod("Layer.getYCoor2", $this->ptr, $v, $yAxis->ptr); + else + return callmethod("Layer.getYCoor", $this->ptr, $v, $yAxis); + } + function xZoneColor($threshold, $belowColor, $aboveColor) { + return callmethod("Layer.xZoneColor", $this->ptr, $threshold, $belowColor, $aboveColor); + } + function yZoneColor($threshold, $belowColor, $aboveColor, $yAxis = 1) { + if (is_object($yAxis)) + return callmethod("Layer.yZoneColor2", $this->ptr, $threshold, $belowColor, $aboveColor, $yAxis->ptr); + else + return callmethod("Layer.yZoneColor", $this->ptr, $threshold, $belowColor, $aboveColor, $yAxis); + } + + function setDataLabelFormat($formatString) { + callmethod("Layer.setDataLabelFormat", $this->ptr, $formatString); + } + function setDataLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("Layer.setDataLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + function setAggregateLabelFormat($formatString) { + callmethod("Layer.setAggregateLabelFormat", $this->ptr, $formatString); + } + function setAggregateLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("Layer.setAggregateLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + function addCustomDataLabel($dataSet, $dataItem, $label, $font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("Layer.addCustomDataLabel", $this->ptr, $dataSet, $dataItem, $label, $font, $fontSize, $fontColor, $fontAngle)); + } + function addCustomAggregateLabel($dataItem, $label, $font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("Layer.addCustomAggregateLabel", $this->ptr, $dataItem, $label, $font, $fontSize, $fontColor, $fontAngle)); + } + function addCustomGroupLabel($dataGroup, $dataItem, $label, $font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("Layer.addCustomGroupLabel", $this->ptr, $dataGroup, $dataItem, $label, $font, $fontSize, $fontColor, $fontAngle)); + } + + function getImageCoor($dataSet, $dataItem = Null, $offsetX = 0, $offsetY = 0) { + if (is_null($dataItem)) + return $this->getImageCoor2($dataSet, $offsetX, $offsetY); + return callmethod("Layer.getImageCoor", $this->ptr, $dataSet, $dataItem, $offsetX, $offsetY); + } + function getImageCoor2($dataItem, $offsetX = 0, $offsetY = 0) { + return callmethod("Layer.getImageCoor2", $this->ptr, $dataItem, $offsetX, $offsetY); + } + function getHTMLImageMap($url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("Layer.getHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } + function setHTMLImageMap($url, $queryFormat = "", $extraAttr = "") { + return callmethod("Layer.setHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr); + } +} + +class BarLayer extends Layer { + function BarLayer($ptr) { + $this->ptr = $ptr; + } + function setBarGap($barGap, $subBarGap = 0.2) { + callmethod("BarLayer.setBarGap", $this->ptr, $barGap, $subBarGap); + } + function setBarWidth($barWidth, $subBarWidth = -1) { + callmethod("BarLayer.setBarWidth", $this->ptr, $barWidth, $subBarWidth); + } + function setMinLabelSize($s) { + callmethod("BarLayer.setMinLabelSize", $this->ptr, $s); + } + function setMinImageMapSize($s) { + callmethod("BarLayer.setMinImageMapSize", $this->ptr, s); + } + function setBarShape($shape, $dataGroup = -1, $dataItem = -1) { + if (is_array($shape)) + $this->setBarShape2($shape, $dataGroup, $dataItem); + else + callmethod("BarLayer.setBarShape", $this->ptr, $shape, $dataGroup, $dataItem); + } + function setBarShape2($shape, $dataGroup = -1, $dataItem = -1) { + callmethod("BarLayer.setBarShape2", $this->ptr, $shape, $dataGroup, $dataItem); + } + function setIconSize($height, $width = -1) { + callmethod("BarLayer.setIconSize", $this->ptr, $height, $width); + } + function setOverlapRatio($overlapRatio, $firstOnTop = 1) { + callmethod("BarLayer.setOverlapRatio", $this->ptr, $overlapRatio, $firstOnTop); + } +} + +class LineLayer extends Layer { + function LineLayer($ptr) { + $this->ptr = $ptr; + } + function setSymbolScale($zDataX, $scaleTypeX = PixelScale, $zDataY = Null, $scaleTypeY = PixelScale) { + callmethod("LineLayer.setSymbolScale", $this->ptr, $zDataX, $scaleTypeX, $zDataY, $scaleTypeY); + } + function setGapColor($lineColor, $lineWidth = -1) { + callmethod("LineLayer.setGapColor", $this->ptr, $lineColor, $lineWidth); + } + function setImageMapWidth($width) { + callmethod("LineLayer.setImageMapWidth", $this->ptr, $width); + } + function setFastLineMode($b = true) { + callmethod("LineLayer.setFastLineMode", $this->ptr, $b); + } + function getLine($dataSet = 0) { + return callmethod("LineLayer.getLine", $this->ptr, $dataSet); + } +} + +class ScatterLayer extends LineLayer { + function ScatterLayer($ptr) { + $this->ptr = $ptr; + } +} + +class InterLineLayer extends LineLayer { + function InterLineLayer($ptr) { + $this->ptr = $ptr; + } + function setGapColor($gapColor12, $gapColor21 = -1) { + return callmethod("InterLineLayer.setGapColor", $this->ptr, $gapColor12, $gapColor21); + } +} + +class SplineLayer extends LineLayer { + function SplineLayer($ptr) { + $this->ptr = $ptr; + } + function setTension($tension) { + return callmethod("SplineLayer.setTension", $this->ptr, $tension); + } + function setMonotonicity($m) { + callmethod("SplineLayer.setMonotonicity", $this->ptr, $m); + } +} + +class StepLineLayer extends LineLayer { + function StepLineLayer($ptr) { + $this->ptr = $ptr; + } + function setAlignment($a) { + return callmethod("StepLineLayer.getLine", $this->ptr, $a); + } +} + +class AreaLayer extends Layer { + function AreaLayer($ptr) { + $this->ptr = $ptr; + } + function setMinLabelSize($s) { + callmethod("AreaLayer.setMinLabelSize", $this->ptr, $s); + } + function setGapColor($fillColor) { + callmethod("AreaLayer.setGapColor", $this->ptr, $fillColor); + } +} + +class TrendLayer extends Layer { + function TrendLayer($ptr) { + $this->ptr = $ptr; + } + function setImageMapWidth($width) { + callmethod("TrendLayer.setImageMapWidth", $this->ptr, $width); + } + function getLine() { + return callmethod("TrendLayer.getLine", $this->ptr); + } + function setRegressionType($regressionType) { + callmethod("TrendLayer.setRegressionType", $this->ptr, $regressionType); + } + function addConfidenceBand($confidence, $upperFillColor, $upperEdgeColor = Transparent, $upperLineWidth = 1, + $lowerFillColor = -1, $lowerEdgeColor = -1, $lowerLineWidth = -1) { + callmethod("TrendLayer.addConfidenceBand", $this->ptr, $confidence, $upperFillColor, $upperEdgeColor, $upperLineWidth, + $lowerFillColor, $lowerEdgeColor, $lowerLineWidth); + } + function addPredictionBand($confidence, $upperFillColor, $upperEdgeColor = Transparent, $upperLineWidth = 1, + $lowerFillColor = -1, $lowerEdgeColor = -1, $lowerLineWidth = -1) { + callmethod("TrendLayer.addPredictionBand", $this->ptr, $confidence, $upperFillColor, $upperEdgeColor, $upperLineWidth, + $lowerFillColor, $lowerEdgeColor, $lowerLineWidth); + } + function getSlope() { + return callmethod("TrendLayer.getSlope", $this->ptr); + } + function getIntercept() { + return callmethod("TrendLayer.getIntercept", $this->ptr); + } + function getCorrelation() { + return callmethod("TrendLayer.getCorrelation", $this->ptr); + } + function getStdError() { + return callmethod("TrendLayer.getStdError", $this->ptr); + } + function getCoefficient($i) { + return callmethod("TrendLayer.getCoefficient", $this->ptr, $i); + } +} + +class BaseBoxLayer extends Layer +{ + function BaseBoxLayer($ptr) { + $this->ptr = $ptr; + } + function setDataGap($gap) { + callmethod("BaseBoxLayer.setDataGap", $this->ptr, $gap); + } + function setDataWidth($width) { + callmethod("BaseBoxLayer.setDataWidth", $this->ptr, $width); + } + function setMinImageMapSize($s) { + callmethod("BaseBoxLayer.setMinImageMapSize", $this->ptr, s); + } +} + +class HLOCLayer extends BaseBoxLayer { + function HLOCLayer($ptr) { + $this->ptr = $ptr; + } + function setColorMethod($colorMethod, $riseColor, $fallColor = -1, $leadValue = -1.7E308) { + callmethod("HLOCLayer.setColorMethod", $this->ptr, $colorMethod, $riseColor, $fallColor, $leadValue); + } +} + +class CandleStickLayer extends BaseBoxLayer { + function CandleStickLayer($ptr) { + $this->ptr = $ptr; + } +} + +class BoxWhiskerLayer extends BaseBoxLayer { + function BoxWhiskerLayer($ptr) { + $this->ptr = $ptr; + } + function setBoxColors($colors, $names = Null) { + callmethod("BoxWhiskerLayer.setBoxColors", $this->ptr, $colors, $names); + } + function setBoxColor($item, $boxColor) { + callmethod("BoxWhiskerLayer.setBoxColor", $this->ptr, $item, $boxColor); + } + function setWhiskerBrightness($whiskerBrightness) { + callmethod("BoxWhiskerLayer.setWhiskerBrightness", $this->ptr, $whiskerBrightness); + } +} + +class VectorLayer extends Layer +{ + function VectorLayer($ptr) { + $this->ptr = $ptr; + } + function setVector($lengths, $directions, $lengthScale = PixelScale) { + callmethod("VectorLayer.setVector", $this->ptr, $lengths, $directions, $lengthScale); + } + function setArrowHead($width, $height = 0) { + if (is_array($width)) + $this->setArrowHead2($width); + else + callmethod("VectorLayer.setArrowHead", $this->ptr, $width, $height); + } + function setArrowHead2($polygon) { + callmethod("VectorLayer.setArrowHead2", $this->ptr, $polygon); + } + function setArrowStem($polygon) { + callmethod("VectorLayer.setArrowStem", $this->ptr, $polygon); + } + function setArrowAlignment($alignment) { + callmethod("VectorLayer.setArrowAlignment", $this->ptr, $alignment); + } + function setIconSize($height, $width = 0) { + callmethod("VectorLayer.setIconSize", $this->ptr, $height, $width); + } + function setVectorMargin($startMargin, $endMargin = NoValue) { + callmethod("VectorLayer.setVectorMargin", $this->ptr, $startMargin, $endMargin); + } +} + +class ContourLayer extends Layer +{ + function ContourLayer($ptr) { + $this->ptr = $ptr; + $this->colorAxis = $this->colorAxis(); + } + function setZData($zData) { + callmethod("ContourLayer.setZData", $this->ptr, $zData); + } + function setZBounds($minZ, $maxZ) { + callmethod("ContourLayer.setZBounds", $this->ptr, $minZ, $maxZ); + } + function setSmoothInterpolation($b) { + callmethod("ContourLayer.setSmoothInterpolation", $this->ptr, $b); + } + function setContourColor($contourColor, $minorContourColor = -1) { + callmethod("ContourLayer.setContourColor", $this->ptr, $contourColor, $minorContourColor); + } + function setContourWidth($contourWidth, $minorContourWidth = -1) { + callmethod("ContourLayer.setContourWidth", $this->ptr, $contourWidth, $minorContourWidth); + } + function setExactContour($contour = true, $markContour = Null) { + if (is_null($markContour)) + $markContour = $contour; + callmethod("ContourLayer.setExactContour", $this->ptr, $contour, $markContour); + } + function setColorAxis($x, $y, $alignment, $length, $orientation) { + return new ColorAxis(callmethod("ContourLayer.setColorAxis", $this->ptr, $x, $y, $alignment, $length, $orientation)); + } + function colorAxis() { + return new ColorAxis(callmethod("ContourLayer.colorAxis", $this->ptr)); + } +} + +class PlotArea { + function PlotArea($ptr) { + $this->ptr = $ptr; + } + function setBackground($color, $altBgColor = -1, $edgeColor = -1) { + callmethod("PlotArea.setBackground", $this->ptr, $color, $altBgColor, $edgeColor); + } + function setBackground2($img, $align = Center) { + callmethod("PlotArea.setBackground2", $this->ptr, $img, $align); + } + function set4QBgColor($Q1Color, $Q2Color, $Q3Color, $Q4Color, $edgeColor = -1) { + callmethod("PlotArea.set4QBgColor", $this->ptr, $Q1Color, $Q2Color, $Q3Color, $Q4Color, $edgeColor); + } + function setAltBgColor($horizontal, $color1, $color2, $edgeColor = -1) { + callmethod("PlotArea.setAltBgColor", $this->ptr, $horizontal, $color1, $color2, $edgeColor); + } + function setGridColor($hGridColor, $vGridColor = Transparent, $minorHGridColor = -1, $minorVGridColor = -1) { + callmethod("PlotArea.setGridColor", $this->ptr, $hGridColor, $vGridColor, $minorHGridColor, $minorVGridColor); + } + function setGridWidth($hGridWidth, $vGridWidth = -1, $minorHGridWidth = -1, $minorVGridWidth = -1) { + callmethod("PlotArea.setGridWidth", $this->ptr, $hGridWidth, $vGridWidth, $minorHGridWidth, $minorVGridWidth); + } + function setGridAxis($xGridAxis, $yGridAxis) { + callmethod("PlotArea.setGridAxis", $this->ptr, decodePtr($xGridAxis), decodePtr($yGridAxis)); + } + function moveGridBefore($layer = Null) { + callmethod("PlotArea.moveGridBefore", $this->ptr, decodePtr($layer)); + } + function getLeftX() { + return callmethod("PlotArea.getLeftX", $this->ptr); + } + function getTopY() { + return callmethod("PlotArea.getTopY", $this->ptr); + } + function getRightX() { + return callmethod("PlotArea.getRightX", $this->ptr); + } + function getBottomY() { + return callmethod("PlotArea.getBottomY", $this->ptr); + } + function getWidth() { + return callmethod("PlotArea.getWidth", $this->ptr); + } + function getHeight() { + return callmethod("PlotArea.getHeight", $this->ptr); + } +} + +class XYChart extends BaseChart { + function XYChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("XYChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + $this->xAxis = $this->xAxis(); + $this->xAxis2 = $this->xAxis2(); + $this->yAxis = $this->yAxis(); + $this->yAxis2 = $this->yAxis2(); + autoDestroy($this); + } + function addAxis($align, $offset) { + return new Axis(callmethod("XYChart.addAxis", $this->ptr, $align, $offset)); + } + function yAxis() { + return new Axis(callmethod("XYChart.yAxis", $this->ptr)); + } + function yAxis2() { + return new Axis(callmethod("XYChart.yAxis2", $this->ptr)); + } + function syncYAxis($slope = 1, $intercept = 0) { + callmethod("XYChart.syncYAxis", $this->ptr, $slope, $intercept); + } + function setYAxisOnRight($b = 1) { + callmethod("XYChart.setYAxisOnRight", $this->ptr, $b); + } + function xAxis() { + return new Axis(callmethod("XYChart.xAxis", $this->ptr)); + } + function xAxis2() { + return new Axis(callmethod("XYChart.xAxis2", $this->ptr)); + } + function setXAxisOnTop($b = 1) { + callmethod("XYChart.setXAxisOnTop", $this->ptr, $b); + } + function swapXY($b = 1) { + callmethod("XYChart.swapXY", $this->ptr, $b); + } + function setAxisAtOrigin($originMode = XYAxisAtOrigin, $symmetryMode = 0) { + callmethod("XYChart.setAxisAtOrigin", $this->ptr, $originMode, $symmetryMode); + } + + function getXCoor($v) { + return callmethod("XYChart.getXCoor", $this->ptr, $v); + } + function getYCoor($v, $yAxis = Null) { + return callmethod("XYChart.getYCoor", $this->ptr, $v, decodePtr($yAxis)); + } + function getXValue($xCoor) { + return callmethod("XYChart.getXValue", $this->ptr, $xCoor); + } + function getNearestXValue($xCoor) { + return callmethod("XYChart.getNearestXValue", $this->ptr, $xCoor); + } + function getYValue($yCoor, $yAxis = Null) { + return callmethod("XYChart.getYValue", $this->ptr, $yCoor, decodePtr($yAxis)); + } + + function xZoneColor($threshold, $belowColor, $aboveColor) { + return callmethod("XYChart.xZoneColor", $this->ptr, $threshold, $belowColor, $aboveColor); + } + function yZoneColor($threshold, $belowColor, $aboveColor, $axis = Null) { + return callmethod("XYChart.yZoneColor", $this->ptr, $threshold, $belowColor, $aboveColor, decodePtr($axis)); + } + + function setPlotArea($x, $y, $width, $height, $bgColor = Transparent, $altBgColor = -1, + $edgeColor = -1, $hGridColor = 0xc0c0c0, $vGridColor = Transparent) { + return new PlotArea(callmethod("XYChart.setPlotArea", $this->ptr, + $x, $y, $width, $height, $bgColor, $altBgColor, $edgeColor, $hGridColor, $vGridColor)); + } + function getPlotArea() { + return new PlotArea(callmethod("XYChart.getPlotArea", $this->ptr)); + } + function setClipping($margin = 0) { + callmethod("XYChart.setClipping", $this->ptr, $margin); + } + function setTrimData($startPos, $len = 0x7fffffff) { + callmethod("XYChart.setTrimData", $this->ptr, $startPos, $len); + } + + function addBarLayer($data = Null, $color = -1, $name = "", $depth = 0) { + if (!is_null($data)) + return new BarLayer(callmethod("XYChart.addBarLayer", $this->ptr, $data, $color, $name, $depth)); + else + return $this->addBarLayer2(); + } + function addBarLayer2($dataCombineMethod = Side, $depth = 0) { + return new BarLayer(callmethod("XYChart.addBarLayer2", $this->ptr, $dataCombineMethod, $depth)); + } + function addBarLayer3($data, $colors = Null, $names = Null, $depth = 0) { + return new BarLayer(callmethod("XYChart.addBarLayer3", $this->ptr, $data, $colors, $names, $depth)); + } + function addLineLayer($data = Null, $color = -1, $name = "", $depth = 0) { + if (!is_null($data)) + return new LineLayer(callmethod("XYChart.addLineLayer", $this->ptr, $data, $color, $name, $depth)); + else + return $this->addLineLayer2(); + } + function addLineLayer2($dataCombineMethod = Overlay, $depth = 0) { + return new LineLayer(callmethod("XYChart.addLineLayer2", $this->ptr, $dataCombineMethod, $depth)); + } + function addAreaLayer($data = Null, $color = -1, $name = "", $depth = 0) { + if (!is_null($data)) + return new AreaLayer(callmethod("XYChart.addAreaLayer", $this->ptr, $data, $color, $name, $depth)); + else + return $this->addAreaLayer2(); + } + function addAreaLayer2($dataCombineMethod = Stack, $depth = 0) { + return new AreaLayer(callmethod("XYChart.addAreaLayer2", $this->ptr, $dataCombineMethod, $depth)); + } + function addHLOCLayer($highData = Null, $lowData = Null, $openData = Null, $closeData = Null, $color = -1) { + if (!is_null($highData)) + return $this->addHLOCLayer3($highData, $lowData, $openData, $closeData, $color, $color); + else + return $this->addHLOCLayer2(); + } + function addHLOCLayer2() { + return new HLOCLayer(callmethod("XYChart.addHLOCLayer2", $this->ptr)); + } + function addHLOCLayer3($highData, $lowData, $openData, $closeData, $upColor, $downColor, $colorMode = -1, $leadValue = -1.7E308) { + return new HLOCLayer(callmethod("XYChart.addHLOCLayer3", $this->ptr, $highData, $lowData, $openData, $closeData, $upColor, $downColor, $colorMode, $leadValue)); + } + function addScatterLayer($xData, $yData, $name = "", $symbol = SquareSymbol, $symbolSize = 5, $fillColor = -1, $edgeColor = -1) { + return new ScatterLayer(callmethod("XYChart.addScatterLayer", $this->ptr, $xData, $yData, $name, $symbol, $symbolSize, $fillColor, $edgeColor)); + } + function addCandleStickLayer($highData, $lowData, $openData, $closeData, $riseColor = 0xffffff, $fallColor = 0x0, $edgeColor = LineColor) { + return new CandleStickLayer(callmethod("XYChart.addCandleStickLayer", $this->ptr, $highData, $lowData, $openData, $closeData, $riseColor, $fallColor, $edgeColor)); + } + function addBoxWhiskerLayer($boxTop, $boxBottom, $maxData = Null, $minData = Null, $midData = Null, $fillColor = -1, $whiskerColor = LineColor, $edgeColor = LineColor) { + return new BoxWhiskerLayer(callmethod("XYChart.addBoxWhiskerLayer", $this->ptr, $boxTop, $boxBottom, $maxData, $minData, $midData, $fillColor, $whiskerColor, $edgeColor)); + } + function addBoxWhiskerLayer2($boxTop, $boxBottom, $maxData = Null, $minData = Null, $midData = Null, $fillColors = Null, $whiskerBrightness = 0.5, $names = Null) { + return new BoxWhiskerLayer(callmethod("XYChart.addBoxWhiskerLayer2", $this->ptr, $boxTop, $boxBottom, $maxData, $minData, $midData, $fillColors, $whiskerBrightness, $names)); + } + function addBoxLayer($boxTop, $boxBottom, $color = -1, $name = "") { + return new BoxWhiskerLayer(callmethod("XYChart.addBoxLayer", $this->ptr, $boxTop, $boxBottom, $color, $name)); + } + function addTrendLayer($data, $color = -1, $name = "", $depth = 0) { + return new TrendLayer(callmethod("XYChart.addTrendLayer", $this->ptr, $data, $color, $name, $depth)); + } + function addTrendLayer2($xData, $yData, $color = -1, $name = "", $depth = 0) { + return new TrendLayer(callmethod("XYChart.addTrendLayer2", $this->ptr, $xData, $yData, $color, $name, $depth)); + } + function addSplineLayer($data = Null, $color = -1, $name = "") { + return new SplineLayer(callmethod("XYChart.addSplineLayer", $this->ptr, $data, $color, $name)); + } + function addStepLineLayer($data = Null, $color = -1, $name = "") { + return new StepLineLayer(callmethod("XYChart.addStepLineLayer", $this->ptr, $data, $color, $name)); + } + function addInterLineLayer($line1, $line2, $color12, $color21 = -1) { + return new InterLineLayer(callmethod("XYChart.addInterLineLayer", $this->ptr, $line1, $line2, $color12, $color21)); + } + function addVectorLayer($xData, $yData, $lengths, $directions, $lengthScale = PixelScale, $color = -1, $name = "") { + return new VectorLayer(callmethod("XYChart.addVectorLayer", $this->ptr, $xData, $yData, $lengths, $directions, $lengthScale, $color, $name)); + } + function addContourLayer($xData, $yData, $zData) { + return new ContourLayer(callmethod("XYChart.addContourLayer", $this->ptr, $xData, $yData, $zData)); + } + + function getLayer($i) { + return new Layer(callmethod("XYChart.getLayer", $this->ptr, $i)); + } + function getLayerByZ($i) { + return new Layer(callmethod("XYChart.getLayerByZ", $this->ptr, $i)); + } + function getLayerCount() { + return callmethod("XYChart.getLayerCount", $this->ptr); + } + + function layoutAxes() { + callmethod("XYChart.layoutAxes", $this->ptr); + } + function packPlotArea($leftX, $topY, $rightX, $bottomY, $minWidth = 0, $minHeight = 0) { + callmethod("XYChart.packPlotArea", $this->ptr, $leftX, $topY, $rightX, $bottomY, $minWidth, $minHeight); + } +} + +class ThreeDChart extends BaseChart +{ + function setPlotRegion($cx, $cy, $xWidth, $yDepth, $zHeight) { + callmethod("ThreeDChart.setPlotRegion", $this->ptr, $cx, $cy, $xWidth, $yDepth, $zHeight); + } + function setViewAngle($elevation, $rotation = 0, $twist = 0) { + callmethod("ThreeDChart.setViewAngle", $this->ptr, $elevation, $rotation, $twist); + } + function setPerspective($perspective) { + callmethod("ThreeDChart.setPerspective", $this->ptr, $perspective); + } + + function xAxis() { + return new Axis(callmethod("ThreeDChart.xAxis", $this->ptr)); + } + function yAxis() { + return new Axis(callmethod("ThreeDChart.yAxis", $this->ptr)); + } + function zAxis() { + return new Axis(callmethod("ThreeDChart.zAxis", $this->ptr)); + } + function setZAxisPos($pos) { + callmethod("ThreeDChart.setZAxisPos", $this->ptr, $pos); + } + + function setColorAxis($x, $y, $alignment, $length, $orientation) { + return new ColorAxis(callmethod("ThreeDChart.setColorAxis", $this->ptr, $x, $y, $alignment, $length, $orientation)); + } + function colorAxis() { + return new ColorAxis(callmethod("ThreeDChart.colorAxis", $this->ptr)); + } + + function setWallVisibility($xyVisible, $yzVisible, $zxVisible) { + callmethod("ThreeDChart.setWallVisibility", $this->ptr, $xyVisible, $yzVisible, $zxVisible); + } + function setWallColor($xyColor, $yzColor = -1, $zxColor = -1, $borderColor = -1) { + callmethod("ThreeDChart.setWallColor", $this->ptr, $xyColor, $yzColor, $zxColor, $borderColor); + } + function setWallThickness($xyThickness, $yzThickness = -1, $zxThickness = -1) { + callmethod("ThreeDChart.setWallThickness", $this->ptr, $xyThickness, $yzThickness, $zxThickness); + } + function setWallGrid($majorXGridColor, $majorYGridColor = -1, $majorZGridColor = -1, + $minorXGridColor = -1, $minorYGridColor = -1, $minorZGridColor = -1) { + callmethod("ThreeDChart.setWallGrid", $this->ptr, $majorXGridColor, $majorYGridColor, $majorZGridColor, + $minorXGridColor, $minorYGridColor, $minorZGridColor); + } +} + +class SurfaceChart extends ThreeDChart +{ + function SurfaceChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("SurfaceChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + $this->xAxis = $this->xAxis(); + $this->yAxis = $this->yAxis(); + $this->zAxis = $this->zAxis(); + $this->colorAxis = $this->colorAxis(); + autoDestroy($this); + } + + function setData($xData, $yData, $zData) { + callmethod("SurfaceChart.setData", $this->ptr, $xData, $yData, $zData); + } + function setInterpolation($xSamples, $ySamples = -1, $isSmooth = 1) { + callmethod("SurfaceChart.setInterpolation", $this->ptr, $xSamples, $ySamples, $isSmooth); + } + + function setLighting($ambientIntensity, $diffuseIntensity, $specularIntensity, $shininess) { + callmethod("SurfaceChart.setLighting", $this->ptr, $ambientIntensity, $diffuseIntensity, $specularIntensity, $shininess); + } + function setShadingMode($shadingMode, $wireWidth = 1) { + callmethod("SurfaceChart.setShadingMode", $this->ptr, $shadingMode, $wireWidth); + } + + function setSurfaceAxisGrid($majorXGridColor, $majorYGridColor = -1, $minorXGridColor = -1, $minorYGridColor = -1) { + callmethod("SurfaceChart.setSurfaceAxisGrid", $this->ptr, $majorXGridColor, $majorYGridColor, + $minorXGridColor, $minorYGridColor); + } + function setSurfaceDataGrid($xGridColor, $yGridColor = -1) { + callmethod("SurfaceChart.setSurfaceDataGrid", $this->ptr, $xGridColor, $yGridColor); + } + function setContourColor($contourColor, $minorContourColor = -1) { + callmethod("SurfaceChart.setContourColor", $this->ptr, $contourColor, $minorContourColor); + } + + function setBackSideBrightness($brightness) { + callmethod("SurfaceChart.setBackSideBrightness", $this->ptr, $brightness); + } + function setBackSideColor($color) { + callmethod("SurfaceChart.setBackSideColor", $this->ptr, $color); + } + function setBackSideLighting($ambientLight, $diffuseLight, $specularLight, $shininess) { + callmethod("SurfaceChart.setBackSideLighting", $this->ptr, $ambientLight, $diffuseLight, $specularLight, $shininess); + } +} + +class ThreeDScatterGroup { + function ThreeDScatterGroup($ptr) { + $this->ptr = $ptr; + } + function setDataSymbol($symbol, $size = Null, $fillColor = -1, $edgeColor = -1, $lineWidth = 1) { + if (is_array($symbol)) { + if (is_null($size)) + $size = 11; + $this->setDataSymbol4($symbol, $size, $fillColor, $edgeColor); + return; + } + if (!is_numeric($symbol)) + return $this->setDataSymbol2($symbol); + if (is_null($size)) + $size = 5; + callmethod("ThreeDScatterGroup.setDataSymbol", $this->ptr, $symbol, $size, $fillColor, $edgeColor, $lineWidth); + } + function setDataSymbol2($image) { + if (!is_string($image)) + return $this->setDataSymbol3($image); + callmethod("ThreeDScatterGroup.setDataSymbol2", $this->ptr, $image); + } + function setDataSymbol3($image) { + callmethod("ThreeDScatterGroup.setDataSymbol3", $this->ptr, $image->ptr); + } + function setDataSymbol4($polygon, $size = 11, $fillColor = -1, $edgeColor = -1) { + callmethod("ThreeDScatterGroup.setDataSymbol4", $this->ptr, $polygon, $size, $fillColor, $edgeColor); + } + function setDropLine($dropLineColor = LineColor, $dropLineWidth = 1) { + callmethod("ThreeDScatterGroup.setDropLine", $this->ptr, $dropLineColor, $dropLineWidth); + } + function setLegendIcon($width, $height = -1, $color = -1) { + callmethod("ThreeDScatterGroup.setLegendIcon", $this->ptr, $width, $height, $color); + } +} + +class ThreeDScatterChart extends ThreeDChart +{ + function ThreeDScatterChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("ThreeDScatterChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + $this->xAxis = $this->xAxis(); + $this->yAxis = $this->yAxis(); + $this->zAxis = $this->zAxis(); + $this->colorAxis = $this->colorAxis(); + autoDestroy($this); + } + + function addScatterGroup($xData, $yData, $zData, $name = "", $symbol = CircleSymbol, $symbolSize = 5, $fillColor = -1, $edgeColor = -1) { + return new ThreeDScatterGroup(callmethod("ThreeDScatterChart.addScatterGroup", $this->ptr, $xData, $yData, $zData, $name, $symbol, $symbolSize, $fillColor, $edgeColor)); + } +} + +class PolarLayer +{ + function PolarLayer($ptr) { + $this->ptr = $ptr; + } + function setData($data, $color = -1, $name = "") { + callmethod("PolarLayer.setData", $this->ptr, $data, $color, $name); + } + function setAngles($angles) { + callmethod("PolarLayer.setAngles", $this->ptr, $angles); + } + + function setBorderColor($edgeColor) { + callmethod("PolarLayer.setBorderColor", $this->ptr, $edgeColor); + } + function setLineWidth($w) { + callmethod("PolarLayer.setLineWidth", $this->ptr, $w); + } + + function setDataSymbol($symbol, $size = Null, $fillColor = -1, $edgeColor = -1, $lineWidth = 1) { + if (is_array($symbol)) { + if (is_null($size)) + $size = 11; + $this->setDataSymbol4($symbol, $size, $fillColor, $edgeColor); + return; + } + if (!is_numeric($symbol)) + return $this->setDataSymbol2($symbol); + if (is_null($size)) + $size = 7; + callmethod("PolarLayer.setDataSymbol", $this->ptr, $symbol, $size, $fillColor, $edgeColor, $lineWidth); + } + function setDataSymbol2($image) { + if (!is_string($image)) + return $this->setDataSymbol3($image); + callmethod("PolarLayer.setDataSymbol2", $this->ptr, $image); + } + function setDataSymbol3($image) { + callmethod("PolarLayer.setDataSymbol3", $this->ptr, $image->ptr); + } + function setDataSymbol4($polygon, $size = 11, $fillColor = -1, $edgeColor = -1) { + callmethod("PolarLayer.setDataSymbol4", $this->ptr, $polygon, $size, $fillColor, $edgeColor); + } + function setSymbolScale($zData, $scaleType = PixelScale) { + callmethod("PolarLayer.setSymbolScale", $this->ptr, $zData, $scaleType); + } + + function setImageMapWidth($width) { + callmethod("PolarLayer.setImageMapWidth", $this->ptr, $width); + } + function getImageCoor($dataItem, $offsetX = 0, $offsetY = 0) { + return callmethod("PolarLayer.getImageCoor", $this->ptr, $dataItem, $offsetX, $offsetY); + } + function getHTMLImageMap($url, $queryFormat = "", $extraAttr = "", $offsetX = 0, $offsetY = 0) { + return callmethod("PolarLayer.getHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr, $offsetX, $offsetY); + } + function setHTMLImageMap($url, $queryFormat = "", $extraAttr = "") { + callmethod("PolarLayer.setHTMLImageMap", $this->ptr, $url, $queryFormat, $extraAttr); + } + function setDataLabelFormat($formatString) { + callmethod("PolarLayer.setDataLabelFormat", $this->ptr, $formatString); + } + function setDataLabelStyle($font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("PolarLayer.setDataLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + function addCustomDataLabel($i, $label, $font = "", $fontSize = 8, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("PolarLayer.addCustomDataLabel", $this->ptr, $i, $label, $font, $fontSize, $fontColor, $fontAngle)); + } +} + +class PolarAreaLayer extends PolarLayer { + function PolarAreaLayer($ptr) { + $this->ptr = $ptr; + } +} + +class PolarLineLayer extends PolarLayer { + function PolarLineLayer($ptr) { + $this->ptr = $ptr; + } + function setCloseLoop($b) { + callmethod("PolarLineLayer.setCloseLoop", $this->ptr, $b); + } + function setGapColor($lineColor, $lineWidth = -1) { + callmethod("PolarLineLayer.setGapColor", $this->ptr, $lineColor, $lineWidth); + } +} + +class PolarSplineLineLayer extends PolarLineLayer { + function PolarSplineLineLayer($ptr) { + $this->ptr = $ptr; + } + function setTension($tension) { + callmethod("PolarSplineLineLayer.setTension", $this->ptr, $tension); + } +} + +class PolarSplineAreaLayer extends PolarAreaLayer { + function PolarSplineAreaLayer($ptr) { + $this->ptr = $ptr; + } + function setTension($tension) { + callmethod("PolarSplineAreaLayer.setTension", $this->ptr, $tension); + } +} + +class PolarVectorLayer extends PolarLayer +{ + function PolarVectorLayer($ptr) { + $this->ptr = $ptr; + } + function setVector($lengths, $directions, $lengthScale = PixelScale) { + callmethod("PolarVectorLayer.setVector", $this->ptr, $lengths, $directions, $lengthScale); + } + function setArrowHead($width, $height = 0) { + if (is_array($width)) + $this->setArrowHead2($width); + else + callmethod("PolarVectorLayer.setArrowHead", $this->ptr, $width, $height); + } + function setArrowHead2($polygon) { + callmethod("PolarVectorLayer.setArrowHead2", $this->ptr, $polygon); + } + function setArrowStem($polygon) { + callmethod("PolarVectorLayer.setArrowStem", $this->ptr, $polygon); + } + function setArrowAlignment($alignment) { + callmethod("PolarVectorLayer.setArrowAlignment", $this->ptr, $alignment); + } + function setIconSize($height, $width = 0) { + callmethod("PolarVectorLayer.setIconSize", $this->ptr, $height, $width); + } + function setVectorMargin($startMargin, $endMargin = NoValue) { + callmethod("PolarVectorLayer.setVectorMargin", $this->ptr, $startMargin, $endMargin); + } +} + +class PolarChart extends BaseChart +{ + function PolarChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("PolarChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + $this->angularAxis = $this->angularAxis(); + $this->radialAxis = $this->radialAxis(); + autoDestroy($this); + } + function setPlotArea($x, $y, $r, $bgColor = Transparent, $edgeColor = Transparent, $edgeWidth = 1) { + callmethod("PolarChart.setPlotArea", $this->ptr, $x, $y, $r, $bgColor, $edgeColor, $edgeWidth); + } + function setPlotAreaBg($bgColor1, $bgColor2 = -1, $altRings = 1) { + callmethod("PolarChart.setPlotAreaBg", $this->ptr, $bgColor1, $bgColor2, $altRings); + } + function setGridColor($rGridColor = 0x80000000, $rGridWidth = 1, $aGridColor = 0x80000000, $aGridWidth = 1) { + callmethod("PolarChart.setGridColor", $this->ptr, $rGridColor, $rGridWidth, $aGridColor, $aGridWidth); + } + function setGridStyle($polygonGrid, $gridOnTop = 1) { + callmethod("PolarChart.setGridStyle", $this->ptr, $polygonGrid, $gridOnTop); + } + function setStartAngle($startAngle, $clockwise = 1) { + callmethod("PolarChart.setStartAngle", $this->ptr, $startAngle, $clockwise); + } + + function angularAxis() { + return new AngularAxis(callmethod("PolarChart.angularAxis", $this->ptr)); + } + function radialAxis() { + return new Axis(callmethod("PolarChart.radialAxis", $this->ptr)); + } + function getXCoor($r, $a) { + return callmethod("PolarChart.getXCoor", $this->ptr, $r, $a); + } + function getYCoor($r, $a) { + return callmethod("PolarChart.getYCoor", $this->ptr, $r, $a); + } + + function addAreaLayer($data, $color = -1, $name = "") { + return new PolarAreaLayer(callmethod("PolarChart.addAreaLayer", $this->ptr, $data, $color, $name)); + } + function addLineLayer($data, $color = -1, $name = "") { + return new PolarLineLayer(callmethod("PolarChart.addLineLayer", $this->ptr, $data, $color, $name)); + } + function addSplineLineLayer($data, $color = -1, $name = "") { + return new PolarSplineLineLayer(callmethod("PolarChart.addSplineLineLayer", $this->ptr, $data, $color, $name)); + } + function addSplineAreaLayer($data, $color = -1, $name = "") { + return new PolarSplineAreaLayer(callmethod("PolarChart.addSplineAreaLayer", $this->ptr, $data, $color, $name)); + } + function addVectorLayer($rData, $aData, $lengths, $directions, $lengthScale = PixelScale, $color = -1, $name = "") { + return new PolarVectorLayer(callmethod("PolarChart.addVectorLayer", $this->ptr, $rData, $aData, $lengths, $directions, $lengthScale, $color, $name)); + } +} + +class PyramidLayer +{ + function PyramidLayer($ptr) { + $this->ptr = $ptr; + } + + function setCenterLabel($labelTemplate = "{skip}", $font = "{skip}", $fontSize = -1, $fontColor = -1) { + return new TextBox(callmethod("PyramidLayer.setCenterLabel", $this->ptr, $labelTemplate, $font, $fontSize, $fontColor)); + } + function setRightLabel($labelTemplate = "{skip}", $font = "{skip}", $fontSize = -1, $fontColor = -1) { + return new TextBox(callmethod("PyramidLayer.setRightLabel", $this->ptr, $labelTemplate, $font, $fontSize, $fontColor)); + } + function setLeftLabel($labelTemplate = "{skip}", $font = "{skip}", $fontSize = -1, $fontColor = -1) { + return new TextBox(callmethod("PyramidLayer.setLeftLabel", $this->ptr, $labelTemplate, $font, $fontSize, $fontColor)); + } + + function setColor($color) { + callmethod("PyramidLayer.setColor", $this->ptr, $color); + } + function setJoinLine($color , $width = -1) { + callmethod("PyramidLayer.setJoinLine", $this->ptr, $color, $width); + } + function setJoinLineGap($pyramidGap, $pyramidMargin = -0x7fffffff, $textGap = -0x7fffffff) { + callmethod("PyramidLayer.setJoinLineGap", $this->ptr, $pyramidGap, $pyramidMargin, $textGap); + } + function setLayerBorder($color, $width = -1) { + callmethod("PyramidLayer.setLayerBorder", $this->ptr, $color, $width); + } + function setLayerGap($layerGap) { + callmethod("PyramidLayer.setLayerGap", $this->ptr, $layerGap); + } +} + +class PyramidChart extends BaseChart +{ + function PyramidChart($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("PyramidChart.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + autoDestroy($this); + } + + function setPyramidSize($cx, $cy, $radius, $height) { + callmethod("PyramidChart.setPyramidSize", $this->ptr, $cx, $cy, $radius, $height); + } + function setConeSize($cx, $cy, $radius, $height) { + callmethod("PyramidChart.setConeSize", $this->ptr, $cx, $cy, $radius, $height); + } + function setFunnelSize($cx, $cy, $radius, $height, $tubeRadius = 0.2, $tubeHeight = 0.3) { + callmethod("PyramidChart.setFunnelSize", $this->ptr, $cx, $cy, $radius, $height, $tubeRadius, $tubeHeight); + } + function setData($data, $labels = Null) { + callmethod("PyramidChart.setData", $this->ptr, $data, $labels); + } + function setCenterLabel($labelTemplate = "{skip}", $font = "{skip}", $fontSize = -1, $fontColor = -1) { + return new TextBox(callmethod("PyramidChart.setCenterLabel", $this->ptr, $labelTemplate, $font, $fontSize, $fontColor)); + } + function setRightLabel($labelTemplate = "{skip}", $font = "{skip}", $fontSize = -1, $fontColor = -1) { + return new TextBox(callmethod("PyramidChart.setRightLabel", $this->ptr, $labelTemplate, $font, $fontSize, $fontColor)); + } + function setLeftLabel($labelTemplate = "{skip}", $font = "{skip}", $fontSize = -1, $fontColor = -1) { + return new TextBox(callmethod("PyramidChart.setLeftLabel", $this->ptr, $labelTemplate, $font, $fontSize, $fontColor)); + } + + function setPyramidSides($noOfSides) { + callmethod("PyramidChart.setPyramidSides", $this->ptr, $noOfSides); + } + function setViewAngle($elevation, $rotation = 0, $twist = 0) { + callmethod("PyramidChart.setViewAngle", $this->ptr, $elevation, $rotation, $twist); + } + + function setGradientShading($startBrightness, $endBrightness) { + callmethod("PyramidChart.setGradientShading", $this->ptr, $startBrightness, $endBrightness); + } + function setLighting($ambientIntensity = 0.5, $diffuseIntensity = 0.5, $specularIntensity = 1, $shininess = 8) { + callmethod("PyramidChart.setLighting", $this->ptr, $ambientIntensity, $diffuseIntensity, $specularIntensity, $shininess); + } + + function setJoinLine($color, $width = -1) { + callmethod("PyramidChart.setJoinLine", $this->ptr, $color, $width); + } + function setJoinLineGap($pyramidGap, $pyramidMargin = -0x7fffffff, $textGap = -0x7fffffff) { + callmethod("PyramidChart.setJoinLineGap", $this->ptr, $pyramidGap, $pyramidMargin, $textGap); + } + function setLayerBorder($color, $width = -1) { + callmethod("PyramidChart.setLayerBorder", $this->ptr, $color, $width); + } + function setLayerGap($layerGap) { + callmethod("PyramidChart.setLayerGap", $this->ptr, $layerGap); + } + + function getLayer($layerNo) { + return new PyramidLayer(callmethod("PyramidChart.getLayer", $this->ptr, $layerNo)); + } +} + +class MeterPointer +{ + function MeterPointer($ptr) { + $this->ptr = $ptr; + } + function setColor($fillColor, $edgeColor = -1) { + callmethod("MeterPointer.setColor", $this->ptr, $fillColor, $edgeColor); + } + function setPos($value) { + callmethod("MeterPointer.setPos", $this->ptr, $value); + } + function setShape($pointerType, $lengthRatio = NoValue, $widthRatio = NoValue) { + if (is_array($pointerType)) + $this->setShape2($pointerType, $lengthRatio, $widthRatio); + else + callmethod("MeterPointer.setShape", $this->ptr, $pointerType, $lengthRatio, $widthRatio); + } + function setShape2($pointerCoor, $lengthRatio = NoValue, $widthRatio = NoValue) { + callmethod("MeterPointer.setShape2", $this->ptr, $pointerCoor, $lengthRatio, $widthRatio); + } + function setZOrder($z) { + callmethod("MeterPointer.setZOrder", $this->ptr, $z); + } +} + +class BaseMeter extends BaseChart +{ + function addPointer($value, $fillColor = LineColor, $edgeColor = -1) { + return new MeterPointer(callmethod("BaseMeter.addPointer", $this->ptr, $value, $fillColor, $edgeColor)); + } + function setScale($lowerLimit, $upperLimit, $majorTickInc = 0, $minorTickInc = 0, $microTickInc = 0) { + if (is_array($majorTickInc)) { + if ($minorTickInc != 0) + $this->setScale3($lowerLimit, $upperLimit, $majorTickInc, $minorTickInc); + else + $this->setScale2($lowerLimit, $upperLimit, $majorTickInc); + } else + callmethod("BaseMeter.setScale", $this->ptr, $lowerLimit, $upperLimit, $majorTickInc, $minorTickInc, $microTickInc); + } + function setScale2($lowerLimit, $upperLimit, $labels) { + callmethod("BaseMeter.setScale2", $this->ptr, $lowerLimit, $upperLimit, $labels); + } + function setScale3($lowerLimit, $upperLimit, $labels, $formatString = "") { + callmethod("BaseMeter.setScale3", $this->ptr, $lowerLimit, $upperLimit, $labels, $formatString); + } + function addLabel($pos, $label) { + callmethod("BaseMeter.addLabel", $this->ptr, $pos, $label); + } + function getLabel($i) { + return callmethod("BaseMeter.getLabel", $this->ptr, $i); + } + function getTicks() { + return callmethod("BaseMeter.getTicks", $this->ptr); + } + function setLabelStyle($font = "bold", $fontSize = -1, $fontColor = TextColor, $fontAngle = 0) { + return new TextBox(callmethod("BaseMeter.setLabelStyle", $this->ptr, $font, $fontSize, $fontColor, $fontAngle)); + } + function setLabelPos($labelInside, $labelOffset = 0) { + callmethod("BaseMeter.setLabelPos", $this->ptr, $labelInside, $labelOffset); + } + function setLabelFormat($formatString) { + callmethod("BaseMeter.setLabelFormat", $this->ptr, $formatString); + } + function setTickLength($majorLen, $minorLen = -0x7fffffff, $microLen = -0x7fffffff) { + callmethod("BaseMeter.setTickLength", $this->ptr, $majorLen, $minorLen, $microLen); + } + function setLineWidth($axisWidth, $majorTickWidth = 1, $minorTickWidth = 1, $microTickWidth = 1) { + callmethod("BaseMeter.setLineWidth", $this->ptr, $axisWidth, $majorTickWidth, $minorTickWidth, $microTickWidth); + } + function setMeterColors($axisColor, $labelColor = -1, $tickColor = -1) { + callmethod("BaseMeter.setMeterColors", $this->ptr, $axisColor, $labelColor, $tickColor); + } + function getCoor($v) { + return callmethod("BaseMeter.getCoor", $this->ptr, $v); + } +} + +class AngularMeter extends BaseMeter +{ + function AngularMeter($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("AngularMeter.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + autoDestroy($this); + } + function addRing($startRadius, $endRadius, $fillColor, $edgeColor = -1) { + callmethod("AngularMeter.addRing", $this->ptr, $startRadius, $endRadius, $fillColor, $edgeColor); + } + function addRingSector($startRadius, $endRadius, $a1, $a2, $fillColor, $edgeColor = -1) { + callmethod("AngularMeter.addRingSector", $this->ptr, $startRadius, $endRadius, $a1, $a2, $fillColor, $edgeColor); + } + function setCap($radius, $fillColor, $edgeColor = LineColor) { + callmethod("AngularMeter.setCap", $this->ptr, $radius, $fillColor, $edgeColor); + } + function setMeter($cx, $cy, $radius, $startAngle, $endAngle) { + callmethod("AngularMeter.setMeter", $this->ptr, $cx, $cy, $radius, $startAngle, $endAngle); + } + function addZone($startValue, $endValue, $startRadius, $endRadius = -1, $fillColor = Null, $edgeColor = -1) { + if (is_null($fillColor)) + $this->addZone2($startValue, $endValue, $startRadius, $endRadius); + else + callmethod("AngularMeter.addZone", $this->ptr, $startValue, $endValue, $startRadius, $endRadius, $fillColor, $edgeColor); + } + function addZone2($startValue, $endValue, $fillColor, $edgeColor = -1) { + callmethod("AngularMeter.addZone2", $this->ptr, $startValue, $endValue, $fillColor, $edgeColor); + } +} + +class LinearMeter extends BaseMeter +{ + function LinearMeter($width, $height, $bgColor = BackgroundColor, $edgeColor = Transparent, $raisedEffect = 0) { + $this->ptr = callmethod("LinearMeter.create", $width, $height, $bgColor, $edgeColor, $raisedEffect); + autoDestroy($this); + } + function setMeter($leftX, $topY, $width, $height, $axisPos = Left, $isReversed = 0) { + callmethod("LinearMeter.setMeter", $this->ptr, $leftX, $topY, $width, $height, $axisPos, $isReversed); + } + function setRail($railColor, $railWidth = 2, $railOffset = 6) { + callmethod("LinearMeter.setRail", $this->ptr, $railColor, $railWidth, $railOffset); + } + function addZone($startValue, $endValue, $color, $label = "") { + return new TextBox(callmethod("LinearMeter.addZone", $this->ptr, $startValue, $endValue, $color, $label)); + } +} + +function getCopyright() { + return callmethod("getCopyright"); +} + +function getVersion() { + return callmethod("getVersion"); +} + +function getDescription() { + return cdFilterMsg(callmethod("getDescription")); +} + +function getBootLog() { + return cdFilterMsg(callmethod("getBootLog")); +} + +function libgTTFTest($font = "", $fontIndex = 0, $fontHeight = 8, $fontWidth = 8, $angle = 0) { + return cdFilterMsg(callmethod("testFont", $font, $fontIndex, $fontHeight, $fontWidth, $angle)); +} + +function testFont($font = "", $fontIndex = 0, $fontHeight = 8, $fontWidth = 8, $angle = 0) { + return cdFilterMsg(callmethod("testFont", $font, $fontIndex, $fontHeight, $fontWidth, $angle)); +} + +function setLicenseCode($licCode) { + return callmethod("setLicenseCode", $licCode); +} + +function chartTime($y, $m = Null, $d = 1, $h = 0, $n = 0, $s = 0) { + if (is_null($m)) + return chartTime2($y); + else + return callmethod("chartTime", $y, $m, $d, $h, $n, $s); +} + +function chartTime2($t) { + return callmethod("chartTime2", $t); +} + +function getChartYMD($t) { + return callmethod("getChartYMD", $t); +} + +function getChartWeekDay($t) { + return ((int)($t / 86400 + 1)) % 7; +} + +class RanTable +{ + function RanTable($seed, $noOfCols, $noOfRows) { + $this->ptr = callmethod("RanTable.create", $seed, $noOfCols, $noOfRows); + autoDestroy($this); + } + function __del__() { + callmethod("RanTable.destroy", $this->ptr); + } + + function setCol($colNo, $minValue, $maxValue, $p4 = Null, $p5 = -1E+308, $p6 = 1E+308) { + if (is_null($p4)) + callmethod("RanTable.setCol", $this->ptr, $colNo, $minValue, $maxValue); + else + $this->setCol2($colNo, $minValue, $maxValue, $p4, $p5, $p6); + } + function setCol2($colNo, $startValue, $minDelta, $maxDelta, $lowerLimit = -1E+308, $upperLimit = 1E+308) { + callmethod("RanTable.setCol2", $this->ptr, $colNo, $startValue, $minDelta, $maxDelta, $lowerLimit, $upperLimit); + } + function setDateCol($i, $startTime, $tickInc, $weekDayOnly = 0) { + callmethod("RanTable.setDateCol", $this->ptr, $i, $startTime, $tickInc, $weekDayOnly); + } + function setHLOCCols($i, $startValue, $minDelta, $maxDelta, $lowerLimit = 0, $upperLimit = 1E+308) { + callmethod("RanTable.setHLOCCols", $this->ptr, $i, $startValue, $minDelta, $maxDelta, $lowerLimit, $upperLimit); + } + function selectDate($colNo, $minDate, $maxDate) { + return callmethod("RanTable.selectDate", $this->ptr, $colNo, $minDate, $maxDate); + } + function getCol($i) { + return callmethod("RanTable.getCol", $this->ptr, $i); + } +} + +class RanSeries +{ + function RanSeries($seed) { + $this->ptr = callmethod("RanSeries.create", $seed); + autoDestroy($this); + } + function __del__() { + callmethod("RanSeries.destroy", $this->ptr); + } + function getSeries($len, $minValue, $maxValue, $p4 = Null, $p5 = -1E+308, $p6 = 1E+308) { + if (is_null($p4)) + return callmethod("RanSeries.getSeries", $this->ptr, $len, $minValue, $maxValue); + else + return $this->getSeries2($len, $minValue, $maxValue, $p4, $p5, $p6); + } + function getSeries2($len, $startValue, $minDelta, $maxDelta, $lowerLimit = -1E+308, $upperLimit = 1E+308) { + return callmethod("RanSeries.getSeries2", $this->ptr, $len, $startValue, $minDelta, $maxDelta, $lowerLimit, $upperLimit); + } + function getDateSeries($len, $startTime, $tickInc, $weekDayOnly = false) { + return callmethod("RanSeries.getDateSeries", $this->ptr, $len, $startTime, $tickInc, $weekDayOnly); + } +} + +class FinanceSimulator +{ + function FinanceSimulator($seed, $startTime, $endTime, $resolution) { + if (is_int($seed)) + $this->ptr = callmethod("FinanceSimulator.create", $seed, $startTime, $endTime, $resolution); + else + $this->ptr = callmethod("FinanceSimulator.create2", $seed, $startTime, $endTime, $resolution); + autoDestroy($this); + } + function __del__() { + callmethod("FinanceSimulator.destroy", $this->ptr); + } + function getTimeStamps() { + return callmethod("FinanceSimulator.getTimeStamps", $this->ptr); + } + function getHighData() { + return callmethod("FinanceSimulator.getHighData", $this->ptr); + } + function getLowData() { + return callmethod("FinanceSimulator.getLowData", $this->ptr); + } + function getOpenData() { + return callmethod("FinanceSimulator.getOpenData", $this->ptr); + } + function getCloseData() { + return callmethod("FinanceSimulator.getCloseData", $this->ptr); + } + function getVolData() { + return callmethod("FinanceSimulator.getVolData", $this->ptr); + } +} + +class ArrayMath +{ + function ArrayMath($a) { + $this->ptr = callmethod("ArrayMath.create", $a); + autoDestroy($this); + } + function __del__() { + callmethod("ArrayMath.destroy", $this->ptr); + } + + function add($b) { + if (!is_array($b)) + $this->add2($b); + else + callmethod("ArrayMath.add", $this->ptr, $b); + return $this; + } + function add2($b) { + callmethod("ArrayMath.add2", $this->ptr, $b); + return $this; + } + function sub($b) { + if (!is_array($b)) + $this->sub2($b); + else + callmethod("ArrayMath.sub", $this->ptr, $b); + return $this; + } + function sub2($b) { + callmethod("ArrayMath.sub2", $this->ptr, $b); + return $this; + } + function mul($b) { + if (!is_array($b)) + $this->mul2($b); + else + callmethod("ArrayMath.mul", $this->ptr, $b); + return $this; + } + function mul2($b) { + callmethod("ArrayMath.mul2", $this->ptr, $b); + return $this; + } + function div($b) { + if (!is_array($b)) + $this->div2($b); + else + callmethod("ArrayMath.div", $this->ptr, $b); + return $this; + } + function div2($b) { + callmethod("ArrayMath.div2", $this->ptr, $b); + return $this; + } + function financeDiv($b, $zeroByZeroValue) { + callmethod("ArrayMath.financeDiv", $this->ptr, $b, $zeroByZeroValue); + return $this; + } + function shift($offset = 1, $fillValue = NoValue) { + callmethod("ArrayMath.shift", $this->ptr, $offset, $fillValue); + return $this; + } + function delta($offset = 1) { + callmethod("ArrayMath.delta", $this->ptr, $offset); + return $this; + } + function rate($offset = 1) { + callmethod("ArrayMath.rate", $this->ptr, $offset); + return $this; + } + function abs() { + callmethod("ArrayMath.abs", $this->ptr); + return $this; + } + function acc() { + callmethod("ArrayMath.acc", $this->ptr); + return $this; + } + + function selectGTZ($b = Null, $fillValue = 0) { callmethod("ArrayMath.selectGTZ", $this->ptr, $b, $fillValue); return $this; } + function selectGEZ($b = Null, $fillValue = 0) { callmethod("ArrayMath.selectGEZ", $this->ptr, $b, $fillValue); return $this; } + function selectLTZ($b = Null, $fillValue = 0) { callmethod("ArrayMath.selectLTZ", $this->ptr, $b, $fillValue); return $this; } + function selectLEZ($b = Null, $fillValue = 0) { callmethod("ArrayMath.selectLEZ", $this->ptr, $b, $fillValue); return $this; } + function selectEQZ($b = Null, $fillValue = 0) { callmethod("ArrayMath.selectEQZ", $this->ptr, $b, $fillValue); return $this; } + function selectNEZ($b = Null, $fillValue = 0) { callmethod("ArrayMath.selectNEZ", $this->ptr, $b, $fillValue); return $this; } + + function selectStartOfHour($majorTickStep = 1, $initialMargin = 300) { + callmethod("ArrayMath.selectStartOfHour", $this->ptr, $majorTickStep, $initialMargin); + return $this; + } + function selectStartOfDay($majorTickStep = 1, $initialMargin = 10800) { + callmethod("ArrayMath.selectStartOfDay", $this->ptr, $majorTickStep, $initialMargin); + return $this; + } + function selectStartOfWeek($majorTickStep = 1, $initialMargin = 172800) { + callmethod("ArrayMath.selectStartOfWeek", $this->ptr, $majorTickStep, $initialMargin); + return $this; + } + function selectStartOfMonth($majorTickStep = 1, $initialMargin = 432000) { + callmethod("ArrayMath.selectStartOfMonth", $this->ptr, $majorTickStep, $initialMargin); + return $this; + } + function selectStartOfYear($majorTickStep = 1, $initialMargin = 5184000) { + callmethod("ArrayMath.selectStartOfYear", $this->ptr, $majorTickStep, $initialMargin); + return $this; + } + function selectRegularSpacing($majorTickStep, $minorTickStep = 0, $initialMargin = 0) { + callmethod("ArrayMath.selectRegularSpacing", $this->ptr, $majorTickStep, $minorTickStep, $initialMargin); + return $this; + } + + function trim($startIndex = 0, $len = -1) { + callmethod("ArrayMath.trim", $this->ptr, $startIndex, $len); + return $this; + } + function insert($a, $insertPoint = -1) { + callmethod("ArrayMath.insert", $this->ptr, $a, $insertPoint); + return $this; + } + function insert2($c, $len, $insertPoint= -1) { + callmethod("ArrayMath.insert2", $this->ptr, $c, $len, $insertPoint); + return $this; + } + function replace($a, $b) { + callmethod("ArrayMath.replace", $this->ptr, $a, $b); + return $this; + } + + function movAvg($interval) { + callmethod("ArrayMath.movAvg", $this->ptr, $interval); + return $this; + } + function expAvg($smoothingFactor) { + callmethod("ArrayMath.expAvg", $this->ptr, $smoothingFactor); + return $this; + } + function movMed($interval) { + callmethod("ArrayMath.movMed", $this->ptr, $interval); + return $this; + } + function movPercentile($interval, $percentile) { + callmethod("ArrayMath.movPercentile", $this->ptr, $interval, $percentile); + return $this; + } + function movMax($interval) { + callmethod("ArrayMath.movMax", $this->ptr, $interval); + return $this; + } + function movMin($interval) { + callmethod("ArrayMath.movMin", $this->ptr, $interval); + return $this; + } + function movStdDev($interval) { + callmethod("ArrayMath.movStdDev", $this->ptr, $interval); + return $this; + } + function movCorr($interval, $b = Null) { + callmethod("ArrayMath.movCorr", $this->ptr, $interval, $b); + return $this; + } + function lowess($smoothness = 0.25, $iteration = 0) { + callmethod("ArrayMath.lowess", $this->ptr, $smoothness, $iteration); + return $this; + } + function lowess2($b, $smoothness = 0.25, $iteration = 0) { + callmethod("ArrayMath.lowess2", $this->ptr, $b, $smoothness, $iteration); + return $this; + } + + function result() { + return callmethod("ArrayMath.result", $this->ptr); + } + function max() { + return callmethod("ArrayMath.max", $this->ptr); + } + function min() { + return callmethod("ArrayMath.min", $this->ptr); + } + function avg() { + return callmethod("ArrayMath.avg", $this->ptr); + } + function sum() { + return callmethod("ArrayMath.sum", $this->ptr); + } + function stdDev() { + return callmethod("ArrayMath.stdDev", $this->ptr); + } + function med() { + return callmethod("ArrayMath.med", $this->ptr); + } + function percentile($p) { + return callmethod("ArrayMath.percentile", $this->ptr, $p); + } + function maxIndex() { + return callmethod("ArrayMath.maxIndex", $this->ptr); + } + function minIndex() { + return callmethod("ArrayMath.minIndex", $this->ptr); + } + + function aggregate($srcArray, $aggregateMethod, $param = 50) { + return callmethod("ArrayMath.aggregate", $this->ptr, $srcArray, $aggregateMethod, $param); + } +} + +#/////////////////////////////////////////////////////////////////////////////////// +#// WebChartViewer implementation +#/////////////////////////////////////////////////////////////////////////////////// +define("MouseUsageDefault", 0); +define("MouseUsageScroll", 2); +define("MouseUsageZoomIn", 3); +define("MouseUsageZoomOut", 4); + +define("DirectionHorizontal", 0); +define("DirectionVertical", 1); +define("DirectionHorizontalVertical", 2); + +class WebChartViewer +{ + function WebChartViewer($id) { + global $_REQUEST; + $this->ptr = callmethod("WebChartViewer.create"); + autoDestroy($this); + $this->putAttrS(":id", $id); + $s = $id."_JsChartViewerState"; + if (isset($_REQUEST[$s])) + $this->putAttrS(":state", get_magic_quotes_gpc() ? stripslashes($_REQUEST[$s]) : $_REQUEST[$s]); + } + function __del__() { + callmethod("WebChartViewer.destroy", $this->ptr); + } + + function getId() { return $this->getAttrS(":id"); } + + function setImageUrl($url) { $this->putAttrS(":url", $url); } + function getImageUrl() { return $this->getAttrS(":url"); } + + function setImageMap($imageMap) { $this->putAttrS(":map", $imageMap); } + function getImageMap() { return $this->getAttrS(":map"); } + + function setChartMetrics($metrics) { $this->putAttrS(":metrics", $metrics); } + function getChartMetrics() { return $this->getAttrS(":metrics"); } + + function setChartModel($model) { $this->putAttrS(":model", $model); } + function getChartModel() { return $this->getAttrS(":model"); } + + function setFullRange($id, $minValue, $maxValue) { + callmethod("WebChartViewer.setFullRange", $this->ptr, $id, $minValue, $maxValue); + } + function getValueAtViewPort($id, $ratio, $isLogScale = false) { + return callmethod("WebChartViewer.getValueAtViewPort", $this->ptr, $id, $ratio, $isLogScale); + } + function getViewPortAtValue($id, $value, $isLogScale = false) { + return callmethod("WebChartViewer.getViewPortAtValue", $this->ptr, $id, $value, $isLogScale); + } + function syncLinearAxisWithViewPort($id, $axis) { + callmethod("WebChartViewer.syncAxisWithViewPort", $this->ptr, $axis->ptr, $id, 3); + } + function syncLogAxisWithViewPort($id, $axis) { + callmethod("WebChartViewer.syncAxisWithViewPort", $this->ptr, $axis->ptr, $id, 4); + } + function syncDateAxisWithViewPort($id, $axis) { + callmethod("WebChartViewer.syncAxisWithViewPort", $this->ptr, $axis->ptr, $id, 5); + } + + function makeDelayedMap($imageMap, $compress = 0) { + global $HTTP_SESSION_VARS, $_SERVER; + if ($compress) { + if (!isset($_SERVER['HTTP_ACCEPT_ENCODING']) || !strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) + $compress = 0; + } + + $mapId = $this->getId()."_map"; + if (!defined('PHP_VERSION_ID')) + session_register($mapId); + else if (!session_id()) + session_start(); + + $b = ""; + if ($compress) + $b = callmethod("WebChartViewer.compressMap", $this->ptr, $b, 4); + + if (isset($HTTP_SESSION_VARS)) + $HTTP_SESSION_VARS[$mapId] = $GLOBALS[$mapId] = $b; + else + $_SESSION[$mapId] = $GLOBALS[$mapId] = $b; + + return "img=".$mapId."&isMap=1&id=".uniqid(session_id())."&".SID; + } + + function renderHTML($extraAttrs = null) { + global $_SERVER; + $url = isset($_SERVER["SCRIPT_NAME"]) ? $_SERVER["SCRIPT_NAME"] : ""; + $query = isset($_SERVER["QUERY_STRING"]) ? $_SERVER["QUERY_STRING"] : ""; + return callmethod("WebChartViewer.renderHTML", $this->ptr, $url, $query, $extraAttrs); + } + function partialUpdateChart($msg = null, $timeout = 0) { + header("Content-type: text/html; charset=utf-8"); + return callmethod("WebChartViewer.partialUpdateChart", $this->ptr, $msg, $timeout); + } + function isPartialUpdateRequest() { global $_REQUEST; return isset($_REQUEST["cdPartialUpdate"]); } + function isFullUpdateRequest() { + if ($this->isPartialUpdateRequest()) + return 0; + global $_REQUEST; + $s = "_JsChartViewerState"; + foreach($_REQUEST as $k => $v) { + if (substr($k, -strlen($s)) == $s) + return 1; + } + return 0; + } + function isStreamRequest() { global $_REQUEST; return isset($_REQUEST["cdDirectStream"]); } + function isViewPortChangedEvent() { return $this->getAttrF(25, 0) != 0; } + function getSenderClientId() { + global $_REQUEST; + if ($this->isPartialUpdateRequest()) + return $_REQUEST["cdPartialUpdate"]; + elseif ($this->isStreamRequest()) + return $_REQUEST["cdDirectStream"]; + else + return null; + } + + function getAttrS($attr, $defaultValue = "") { + return callmethod("WebChartViewer.getAttrS", $this->ptr, $attr, $defaultValue); + } + function getAttrF($attr, $defaultValue = 0) { + return callmethod("WebChartViewer.getAttrF", $this->ptr, $attr, $defaultValue); + } + function putAttrF($attr, $value) { + callmethod("WebChartViewer.putAttrF", $this->ptr, $attr, $value); + } + function putAttrS($attr, $value) { + callmethod("WebChartViewer.putAttrS", $this->ptr, $attr, $value); + } + + function getViewPortLeft() { return $this->getAttrF(4, 0); } + function setViewPortLeft($left) { $this->putAttrF(4, $left); } + + function getViewPortTop() { return $this->getAttrF(5, 0); } + function setViewPortTop($top) { $this->putAttrF(5, $top); } + + function getViewPortWidth() { return $this->getAttrF(6, 1); } + function setViewPortWidth($width) { $this->putAttrF(6, $width); } + + function getViewPortHeight() { return $this->getAttrF(7, 1); } + function setViewPortHeight($height) { $this->putAttrF(7, $height); } + + function getSelectionBorderWidth() { return (int)($this->getAttrF(8, 2)); } + function setSelectionBorderWidth($lineWidth) { $this->putAttrF(8, $lineWidth); } + + function getSelectionBorderColor() { return $this->getAttrS(9, "Black"); } + function setSelectionBorderColor($color) { $this->putAttrS(9, $color); } + + function getMouseUsage() { return (int)($this->getAttrF(10, MouseUsageDefault)); } + function setMouseUsage($usage) { $this->putAttrF(10, $usage); } + + function getScrollDirection() { return (int)($this->getAttrF(11, DirectionHorizontal)); } + function setScrollDirection($direction) { $this->putAttrF(11, $direction); } + + function getZoomDirection() { return (int)($this->getAttrF(12, DirectionHorizontal)); } + function setZoomDirection($direction) { $this->putAttrF(12, $direction); } + + function getZoomInRatio() { return $this->getAttrF(13, 2); } + function setZoomInRatio($ratio) { if ($ratio > 0) $this->putAttrF(13, $ratio); } + + function getZoomOutRatio() { return $this->getAttrF(14, 0.5); } + function setZoomOutRatio($ratio) { if ($ratio > 0) $this->putAttrF(14, $ratio); } + + function getZoomInWidthLimit() { return $this->getAttrF(15, 0.01); } + function setZoomInWidthLimit($limit) { $this->putAttrF(15, $limit); } + + function getZoomOutWidthLimit() { return $this->getAttrF(16, 1); } + function setZoomOutWidthLimit($limit) { $this->putAttrF(16, $limit); } + + function getZoomInHeightLimit() { return $this->getAttrF(17, 0.01); } + function setZoomInHeightLimit($limit) { $this->putAttrF(17, $limit); } + + function getZoomOutHeightLimit() { return $this->getAttrF(18, 1); } + function setZoomOutHeightLimit($limit) { $this->putAttrF(18, $limit); } + + function getMinimumDrag() { return (int)($this->getAttrF(19, 5)); } + function setMinimumDrag($offset) { $this->putAttrF(19, $offset); } + + function getZoomInCursor() { return $this->getAttrS(20, ""); } + function setZoomInCursor($cursor) { $this->putAttrS(20, $cursor); } + + function getZoomOutCursor() { return $this->getAttrS(21, ""); } + function setZoomOutCursor($cursor) { $this->putAttrS(21, $cursor); } + + function getScrollCursor() { return $this->getAttrS(22, ""); } + function setScrollCursor($cursor) { $this->putAttrS(22, $cursor); } + + function getNoZoomCursor() { return $this->getAttrS(26, ""); } + function setNoZoomCursor($cursor) { $this->putAttrS(26, $cursor); } + + function getCustomAttr($key) { return $this->getAttrS($key, ""); } + function setCustomAttr($key, $value) { $this->putAttrS($key, $value); } +} + +?> diff --git a/library/Vendors/ChromePHP/ChromePhp.php b/library/Vendors/ChromePHP/ChromePhp.php new file mode 100644 index 0000000..73cf3bc --- /dev/null +++ b/library/Vendors/ChromePHP/ChromePhp.php @@ -0,0 +1,622 @@ + + */ +class ChromePhp +{ + /** + * @var string + */ + const COOKIE_NAME = 'chromephp_log'; + + /** + * @var string + */ + const VERSION = '2.2.3'; + + /** + * @var string + */ + const LOG_PATH = 'log_path'; + + /** + * @var string + */ + const URL_PATH = 'url_path'; + + /** + * @var string + */ + const STORE_LOGS = 'store_logs'; + + /** + * @var string + */ + const BACKTRACE_LEVEL = 'backtrace_level'; + + /** + * @var string + */ + const MAX_TRANSFER = 'max_transfer'; + + /** + * @var string + */ + const LOG = 'log'; + + /** + * @var string + */ + const WARN = 'warn'; + + /** + * @var string + */ + const ERROR = 'error'; + + /** + * @var string + */ + const GROUP = 'group'; + + /** + * @var string + */ + const INFO = 'info'; + + /** + * @var string + */ + const GROUP_END = 'groupEnd'; + + /** + * @var string + */ + const GROUP_COLLAPSED = 'groupCollapsed'; + + /** + * @var string + */ + const COOKIE_SIZE_WARNING = 'cookie size of 4kb exceeded! try ChromePhp::useFile() to pull the log data from disk'; + + /** + * @var string + */ + protected $_php_version; + + /** + * @var int + */ + protected $_timestamp; + + /** + * @var array + */ + protected $_json = array( + 'version' => self::VERSION, + 'columns' => array('label', 'log', 'backtrace', 'type'), + 'rows' => array() + ); + + /** + * @var array + */ + protected $_backtraces = array(); + + /** + * @var bool + */ + protected $_error_triggered = false; + + /** + * @var array + */ + protected $_settings = array( + self::LOG_PATH => null, + self::URL_PATH=> null, + self::STORE_LOGS => false, + self::BACKTRACE_LEVEL => 1, + self::MAX_TRANSFER => 3000 + ); + + /** + * @var ChromePhp + */ + protected static $_instance; + + /** + * Prevent recursion when working with objects referring to each other + * + * @var array + */ + protected $_processed = array(); + + /** + * constructor + */ + private function __construct() + { + $this->_deleteCookie(); + $this->_php_version = phpversion(); + $this->_timestamp = $this->_php_version >= 5.1 ? $_SERVER['REQUEST_TIME'] : time(); + $this->_json['request_uri'] = $_SERVER['REQUEST_URI']; + } + + /** + * gets instance of this class + * + * @return ChromePhp + */ + public static function getInstance() + { + if (self::$_instance === null) { + self::$_instance = new ChromePhp(); + } + return self::$_instance; + } + + /** + * logs a variable to the console + * + * @param string label + * @param mixed value + * @param string severity ChromePhp::LOG || ChromePhp::WARN || ChromePhp::ERROR + * @return void + */ + public static function log() + { + $args = func_get_args(); + $severity = count($args) == 3 ? array_pop($args) : ''; + + // save precious bytes in the cookie + if ($severity == self::LOG) { + $severity = ''; + } + + return self::_log($args + array('type' => $severity)); + } + + /** + * logs a warning to the console + * + * @param string label + * @param mixed value + * @return void + */ + public static function warn() + { + return self::_log(func_get_args() + array('type' => self::WARN)); + } + + /** + * logs an error to the console + * + * @param string label + * @param mixed value + * @return void + */ + public static function error() + { + return self::_log(func_get_args() + array('type' => self::ERROR)); + } + + /** + * sends a group log + * + * @param string value + */ + public static function group() + { + return self::_log(func_get_args() + array('type' => self::GROUP)); + } + + /** + * sends an info log + * + * @param string value + */ + public static function info() + { + return self::_log(func_get_args() + array('type' => self::INFO)); + } + + /** + * sends a collapsed group log + * + * @param string value + */ + public static function groupCollapsed() + { + return self::_log(func_get_args() + array('type' => self::GROUP_COLLAPSED)); + } + + /** + * ends a group log + * + * @param string value + */ + public static function groupEnd() + { + return self::_log(func_get_args() + array('type' => self::GROUP_END)); + } + + /** + * internal logging call + * + * @param string $type + * @return void + */ + protected static function _log(array $args) + { + $type = $args['type']; + unset($args['type']); + + // nothing passed in, don't do anything + if (count($args) == 0 && $type != self::GROUP_END) { + return; + } + + // default to single + $label = null; + $value = isset($args[0]) ? $args[0] : ''; + + $logger = self::getInstance(); + + if ($logger->_error_triggered) { + return; + } + + // if there are two values passed in then the first one is the label + if (count($args) == 2) { + $label = $args[0]; + $value = $args[1]; + } + + $logger->_processed = array(); + $value = $logger->_convert($value); + + $backtrace = debug_backtrace(false); + $level = $logger->getSetting(self::BACKTRACE_LEVEL); + + $backtrace_message = 'unknown'; + if (isset($backtrace[$level]['file']) && isset($backtrace[$level]['line'])) { + $backtrace_message = $backtrace[$level]['file'] . ' : ' . $backtrace[$level]['line']; + } + + $logger->_addRow($label, $value, $backtrace_message, $type); + } + + /** + * converts an object to a better format for logging + * + * @param Object + * @return array + */ + protected function _convert($object) + { + // if this isn't an object then just return it + if (!is_object($object)) { + return $object; + } + + //Mark this object as processed so we don't convert it twice and it + //Also avoid recursion when objects refer to each other + $this->_processed[] = $object; + + $object_as_array = array(); + + // first add the class name + $object_as_array['class'] = get_class($object); + + // loop through object vars + $object_vars = get_object_vars($object); + foreach ($object_vars as $key => $value) { + + // same instance as parent object + if ($value === $object || in_array($value, $this->_processed, true)) { + $value = 'recursion - parent object [' . get_class($value) . ']'; + } + $object_as_array[$key] = $this->_convert($value); + } + + $reflection = new ReflectionClass($object); + + // loop through the properties and add those + foreach ($reflection->getProperties() as $property) { + + // if one of these properties was already added above then ignore it + if (array_key_exists($property->getName(), $object_vars)) { + continue; + } + $type = $this->_getPropertyKey($property); + + if ($this->_php_version >= 5.3) { + $property->setAccessible(true); + } + + try { + $value = $property->getValue($object); + } catch (ReflectionException $e) { + $value = 'only PHP 5.3 can access private/protected properties'; + } + + // same instance as parent object + if ($value === $object || in_array($value, $this->_processed, true)) { + $value = 'recursion - parent object [' . get_class($value) . ']'; + } + + $object_as_array[$type] = $this->_convert($value); + } + return $object_as_array; + } + + /** + * takes a reflection property and returns a nicely formatted key of the property name + * + * @param ReflectionProperty + * @return string + */ + protected function _getPropertyKey(ReflectionProperty $property) + { + $static = $property->isStatic() ? ' static' : ''; + if ($property->isPublic()) { + return 'public' . $static . ' ' . $property->getName(); + } + + if ($property->isProtected()) { + return 'protected' . $static . ' ' . $property->getName(); + } + + if ($property->isPrivate()) { + return 'private' . $static . ' ' . $property->getName(); + } + } + + /** + * adds a value to the cookie + * + * @var mixed + * @return void + */ + protected function _addRow($label, $log, $backtrace, $type) + { + // if this is logged on the same line for example in a loop, set it to null to save space + if (in_array($backtrace, $this->_backtraces)) { + $backtrace = null; + } + + if ($backtrace !== null) { + $this->_backtraces[] = $backtrace; + } + + $this->_clearRows(); + $row = array($label, $log, $backtrace, $type); + + // if we are in cookie mode and the row won't fit then don't add it + if ($this->getSetting(self::LOG_PATH) === null && !$this->_willFit($row)) { + return $this->_cookieMonster(); + } + + $this->_json['rows'][] = $row; + $this->_writeCookie(); + } + + /** + * clears existing rows in special cases + * + * for ajax requests chrome will be listening for cookie changes + * this means we can send the cookie data one row at a time as it comes in + * + * @return void + */ + protected function _clearRows() + { + // if we are in file mode we want the file to have all the log data + if ($this->getSetting(self::LOG_PATH) !== null) { + return; + } + + // X-Requested-With header not present or not equal to XMLHttpRequest + if (!isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { + return; + } + + if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') { + return; + } + + $this->_json['rows'] = array(); + } + + /** + * determines if this row will fit in the cookie + * + * @param array $row + * @return bool + */ + protected function _willFit($row) + { + $json = $this->_json; + $json['rows'][] = $row; + + // if we don't have multibyte string length available just use regular string length + // this doesn't have to be perfect, just want to prevent sending more data + // than chrome or apache can handle in a cookie + $encoded_string = $this->_encode($json); + $size = function_exists('mb_strlen') ? mb_strlen($encoded_string) : strlen($encoded_string); + + // if the size is greater than the max transfer size + if ($size > $this->getSetting(self::MAX_TRANSFER)) { + return false; + } + + return true; + } + + /** + * writes the cookie + * + * @return bool + */ + protected function _writeCookie() + { + // if we are going to use a file then use that + // here we only want to json_encode + if ($this->getSetting(self::LOG_PATH) !== null) { + return $this->_writeToFile(json_encode($this->_json)); + } + + return $this->_setCookie($this->_json); + } + + /** + * deletes the main cookie + * + * @return bool + */ + protected function _deleteCookie() + { + return setcookie(self::COOKIE_NAME, null, 1); + } + + /** + * encodes the data to be sent along with the request + * + * @param array $data + * @return string + */ + protected function _encode($data) + { + return base64_encode(utf8_encode(json_encode($data))); + } + + /** + * sets the main cookie + * + * @param array + * @return bool + */ + protected function _setCookie($data) + { + return setcookie(self::COOKIE_NAME, $this->_encode($data), time() + 30); + } + + /** + * adds a setting + * + * @param string key + * @param mixed value + * @return void + */ + public function addSetting($key, $value) + { + $this->_settings[$key] = $value; + } + + /** + * add ability to set multiple settings in one call + * + * @param array $settings + * @return void + */ + public function addSettings(array $settings) + { + foreach ($settings as $key => $value) { + $this->addSetting($key, $value); + } + } + + /** + * gets a setting + * + * @param string key + * @return mixed + */ + public function getSetting($key) + { + if (!isset($this->_settings[$key])) { + return null; + } + return $this->_settings[$key]; + } + + /** + * this will allow you to specify a path on disk and a uri to access a static file that can store json + * + * this allows you to log data that is more than 4k + * + * @param string path to directory on disk to keep log files + * @param string url path to url to access the files + */ + public static function useFile($path, $url) + { + $logger = self::getInstance(); + $logger->addSetting(self::LOG_PATH, rtrim($path, '/')); + $logger->addSetting(self::URL_PATH, rtrim($url, '/')); + } + + /** + * handles cases when there is too much data + * + * @param string + * @return void + */ + protected function _cookieMonster() + { + $this->_error_triggered = true; + + $this->_json['rows'][] = array(null, self::COOKIE_SIZE_WARNING, 'ChromePhp', self::WARN); + + return $this->_writeCookie(); + } + + /** + * writes data to a file + * + * @param string + * @return void + */ + protected function _writeToFile($json) + { + // if the log path is not setup then create it + if (!is_dir($this->getSetting(self::LOG_PATH))) { + mkdir($this->getSetting(self::LOG_PATH)); + } + + $file_name = 'last_run.json'; + if ($this->getSetting(self::STORE_LOGS)) { + $file_name = 'run_' . $this->_timestamp . '.json'; + } + + file_put_contents($this->getSetting(self::LOG_PATH) . '/' . $file_name, $json); + + $data = array( + 'uri' => $this->getSetting(self::URL_PATH) . '/' . $file_name, + 'request_uri' => $_SERVER['REQUEST_URI'], + 'time' => $this->_timestamp, + 'version' => self::VERSION + ); + + return $this->_setCookie($data); + } +} +?> \ No newline at end of file diff --git a/library/Vendors/GoogleMapAPI/GoogleMapAPI.class.php b/library/Vendors/GoogleMapAPI/GoogleMapAPI.class.php new file mode 100644 index 0000000..2bdcdae --- /dev/null +++ b/library/Vendors/GoogleMapAPI/GoogleMapAPI.class.php @@ -0,0 +1,1390 @@ + + * @package GoogleMapAPI + * @version 2.5 + */ + +/* $Id: GoogleMapAPI.class.php,v 1.63 2007/08/03 16:29:40 mohrt Exp $ */ + +/* + +For best results with GoogleMaps, use XHTML compliant web pages with this header: + + + + +For database caching, you will want to use this schema: + +CREATE TABLE GEOCODES ( + address varchar(255) NOT NULL default '', + lon float default NULL, + lat float default NULL, + PRIMARY KEY (address) +); + +*/ + +class GoogleMapAPI { + + /** + * PEAR::DB DSN for geocode caching. example: + * $dsn = 'mysql://user:pass@localhost/dbname'; + * + * @var string + */ + var $dsn = null; + + /** + * YOUR GooglMap API KEY for your site. + * (http://maps.google.com/apis/maps/signup.html) + * + * @var string + */ + var $api_key = ''; + + /** + * current map id, set when you instantiate + * the GoogleMapAPI object. + * + * @var string + */ + var $map_id = null; + + /** + * sidebar
used along with this map. + * + * @var string + */ + var $sidebar_id = null; + + /** + * GoogleMapAPI uses the Yahoo geocode lookup API. + * This is the application ID for YOUR application. + * This is set upon instantiating the GoogleMapAPI object. + * (http://developer.yahoo.net/faq/index.html#appid) + * + * @var string + */ + var $app_id = null; + + /** + * use onLoad() to load the map javascript. + * if enabled, be sure to include on your webpage: + * + * + * @var string + */ + var $onload = true; + + /** + * map center latitude (horizontal) + * calculated automatically as markers + * are added to the map. + * + * @var float + */ + var $center_lat = null; + + /** + * map center longitude (vertical) + * calculated automatically as markers + * are added to the map. + * + * @var float + */ + var $center_lon = null; + + /** + * enables map controls (zoom/move/center) + * + * @var boolean + */ + var $map_controls = true; + + /** + * determines the map control type + * small -> show move/center controls + * large -> show move/center/zoom controls + * + * @var string + */ + var $control_size = 'large'; + + /** + * enables map type controls (map/satellite/hybrid) + * + * @var boolean + */ + var $type_controls = true; + + /** + * default map type (G_NORMAL_MAP/G_SATELLITE_MAP/G_HYBRID_MAP) + * + * @var boolean + */ + var $map_type = 'G_NORMAL_MAP'; + + /** + * enables scale map control + * + * @var boolean + */ + var $scale_control = true; + + /** + * enables overview map control + * + * @var boolean + */ + var $overview_control = false; + + /** + * determines the default zoom level + * + * @var integer + */ + var $zoom = 16; + + /** + * determines the map width + * + * @var integer + */ + var $width = '500px'; + + /** + * determines the map height + * + * @var integer + */ + var $height = '500px'; + + /** + * message that pops up when the browser is incompatible with Google Maps. + * set to empty string to disable. + * + * @var integer + */ + var $browser_alert = 'Sorry, the Google Maps API is not compatible with this browser.'; + + /** + * message that appears when javascript is disabled. + * set to empty string to disable. + * + * @var string + */ + var $js_alert = 'Javascript must be enabled in order to use Google Maps.'; + + /** + * determines if sidebar is enabled + * + * @var boolean + */ + var $sidebar = true; + + /** + * determines if to/from directions are included inside info window + * + * @var boolean + */ + var $directions = true; + + /** + * determines if map markers bring up an info window + * + * @var boolean + */ + var $info_window = true; + + /** + * determines if info window appears with a click or mouseover + * + * @var string click/mouseover + */ + var $window_trigger = 'click'; + + /** + * what server geocode lookups come from + * + * available: YAHOO Yahoo! API. US geocode lookups only. + * GOOGLE Google Maps. This can do international lookups, + * but not an official API service so no guarantees. + * Note: GOOGLE is the default lookup service, please read + * the Yahoo! terms of service before using their API. + * + * @var string service name + */ + var $lookup_service = 'GOOGLE'; + var $lookup_server = array('GOOGLE' => 'maps.google.com', 'YAHOO' => 'api.local.yahoo.com'); + + var $driving_dir_text = array( + 'dir_to' => 'Start address: (include addr, city st/region)', + 'to_button_value' => 'Get Directions', + 'to_button_type' => 'submit', + 'dir_from' => 'End address: (include addr, city st/region)', + 'from_button_value' => 'Get Directions', + 'from_button_type' => 'submit', + 'dir_text' => 'Directions: ', + 'dir_tohere' => 'To here', + 'dir_fromhere' => 'From here' + ); + + + /** + * version number + * + * @var string + */ + var $_version = '2.5'; + + /** + * list of added markers + * + * @var array + */ + var $_markers = array(); + + /** + * maximum longitude of all markers + * + * @var float + */ + var $_max_lon = -1000000; + + /** + * minimum longitude of all markers + * + * @var float + */ + var $_min_lon = 1000000; + + /** + * max latitude + * + * @var float + */ + var $_max_lat = -1000000; + + /** + * min latitude + * + * @var float + */ + var $_min_lat = 1000000; + + /** + * determines if we should zoom to minimum level (above this->zoom value) that will encompass all markers + * + * @var boolean + */ + var $zoom_encompass = true; + + /** + * factor by which to fudge the boundaries so that when we zoom encompass, the markers aren't too close to the edge + * + * @var float + */ + var $bounds_fudge = 0.01; + + /** + * use the first suggestion by a google lookup if exact match not found + * + * @var float + */ + var $use_suggest = false; + + + /** + * list of added polylines + * + * @var array + */ + var $_polylines = array(); + + /** + * icon info array + * + * @var array + */ + var $_icons = array(); + + /** + * database cache table name + * + * @var string + */ + var $_db_cache_table = 'GEOCODES'; + + + /** + * class constructor + * + * @param string $map_id the id for this map + * @param string $app_id YOUR Yahoo App ID + */ + function GoogleMapAPI($map_id = 'map', $app_id = 'MyMapApp') { + $this->map_id = $map_id; + $this->sidebar_id = 'sidebar_' . $map_id; + $this->app_id = $app_id; + } + + /** + * sets the PEAR::DB dsn + * + * @param string $dsn + */ + function setDSN($dsn) { + $this->dsn = $dsn; + } + + /** + * sets YOUR Google Map API key + * + * @param string $key + */ + function setAPIKey($key) { + $this->api_key = $key; + } + + /** + * sets the width of the map + * + * @param string $width + */ + function setWidth($width) { + if(!preg_match('!^(\d+)(.*)$!',$width,$_match)) + return false; + + $_width = $_match[1]; + $_type = $_match[2]; + if($_type == '%') + $this->width = $_width . '%'; + else + $this->width = $_width . 'px'; + + return true; + } + + /** + * sets the height of the map + * + * @param string $height + */ + function setHeight($height) { + if(!preg_match('!^(\d+)(.*)$!',$height,$_match)) + return false; + + $_height = $_match[1]; + $_type = $_match[2]; + if($_type == '%') + $this->height = $_height . '%'; + else + $this->height = $_height . 'px'; + + return true; + } + + /** + * sets the default map zoom level + * + * @param string $level + */ + function setZoomLevel($level) { + $this->zoom = (int) $level; + } + + /** + * enables the map controls (zoom/move) + * + */ + function enableMapControls() { + $this->map_controls = true; + } + + /** + * disables the map controls (zoom/move) + * + */ + function disableMapControls() { + $this->map_controls = false; + } + + /** + * sets the map control size (large/small) + * + * @param string $size + */ + function setControlSize($size) { + if(in_array($size,array('large','small'))) + $this->control_size = $size; + } + + /** + * enables the type controls (map/satellite/hybrid) + * + */ + function enableTypeControls() { + $this->type_controls = true; + } + + /** + * disables the type controls (map/satellite/hybrid) + * + */ + function disableTypeControls() { + $this->type_controls = false; + } + + /** + * set default map type (map/satellite/hybrid) + * + */ + function setMapType($type) { + switch($type) { + case 'hybrid': + $this->map_type = 'G_HYBRID_MAP'; + break; + case 'satellite': + $this->map_type = 'G_SATELLITE_MAP'; + break; + case 'map': + default: + $this->map_type = 'G_NORMAL_MAP'; + break; + } + } + + /** + * enables onload + * + */ + function enableOnLoad() { + $this->onload = true; + } + + /** + * disables onload + * + */ + function disableOnLoad() { + $this->onload = false; + } + + /** + * enables sidebar + * + */ + function enableSidebar() { + $this->sidebar = true; + } + + /** + * disables sidebar + * + */ + function disableSidebar() { + $this->sidebar = false; + } + + /** + * enables map directions inside info window + * + */ + function enableDirections() { + $this->directions = true; + } + + /** + * disables map directions inside info window + * + */ + function disableDirections() { + $this->directions = false; + } + + /** + * set browser alert message for incompatible browsers + * + * @params $message string + */ + function setBrowserAlert($message) { + $this->browser_alert = $message; + } + + /** + * set