Ir direto para busca.
php-sp · PHP SP - Grupo de PHP do Estado de SP

Informações sobre o grupo

? Você já é um associado? Entre no Yahoo!

Dicas

Você sabia...
Você pode receber várias mensagens em um único e-mail. Basta configurar suas opções de entrega de e-mail.

Mensagens

  Ajuda
Avançado
mensagens 3610 - 3639 de 15751   Mais antigos  |  < Mais antigos  |  Mais recentes >  |  Mais recentes
mensagens 3610 - 3639 de 15751   Mais antigos  |  < Mais antigos  |  Mais recentes >  |  Mais recentes
mensagens: Exibir resumo de mensagens Classificar por data ^  
#3610 De: "Claudia A. V. Callegari" <claudia@...>
Data: Sex, 1 de Set de 2006 11:50 am
Assunto: Re: Dúvida com Data
claudiaphp
Enviar e-mail Enviar e-mail
 
Ola Roger !!

Seja Bem Vindo !!

Primeiro uma dica, para sua tabela.
Sempre que for utilizar campos para guardar valores referente dinheiro , use
tipo decimal  exemplo  decimal(10,2).
Isso porque internamente o mysql guarda esses valores como caracter e não
retornará valores inesperados quando forem  somados.
Essa dica é de um professor experiente da Mysql Brasil.

Quanto ao seu problema com a data, você pode fazer o seguinte.
Usar a função abaixo  (veri_data)  para checar se a data informada é válida  e
ao mesmo tempo converte-la para ser gravada.

Exemplo:

$data_conv=veri_data($_POST['data']) ;

if( ! $data_conv ) {
     echo " Data informada é inválida, digite  dd/mm/yyyy  ";
    //  break ;  ou retornar....  conforme seu codigo ...
}



  function veri_data($data) {
         // verifica se uma data é válida e retorna no formato do mysql
aaaa-mm-dd
         // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
dd\mm\aaaa

   $a= ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
   if(!$a) {
            return false;
   }
         if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
            return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
         else
            return false;
     }

Abraços

Claudia A. V. Callegari

   ----- Original Message -----
   From: php2005senac@...
   To: php-sp@...
   Sent: Thursday, August 31, 2006 1:34 PM
   Subject: [php-sp] Dúvida com Data


   Olá está é minha 1ª mensagem. Estou começando a programas com PHP. Começei a
   fazer um pequeno script com a seguinte estrutura em sua base de dados:

   Table structure for table `tabela_servidorVirtual`
   --

   DROP TABLE IF EXISTS `tabela_sv`;
   CREATE TABLE IF NOT EXISTS `tabela_sv` (
     `id_cliente` int(5) NOT NULL auto_increment,
     `nome_cliente` varchar(50) NOT NULL default '',
     `dominio_cliente` varchar(60) NOT NULL default '',
     `plano_cliente` varchar(50) NOT NULL default '',
     `espaco_atual` varchar(8) NOT NULL default '',
     `transferencia_atual` varchar(6) NOT NULL default '',
     `valor_plano` float NOT NULL default '0',
     `espaco_novo` varchar(8) NOT NULL default '',
     `transferencia_nova` varchar(6) NOT NULL default '',
     `plano_novo` varchar(50) NOT NULL default '',
     `data` date NOT NULL default '0000-00-00',
     `email_principal` varchar(100) NOT NULL default '',
     `email_secundario` varchar(100) NOT NULL default '',
     PRIMARY KEY  (`id_cliente`)
   ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3


   Se possível vocês poderiam me dizer se eu defini corretamente a minha
   tabale.

   A minha primeira dúvida é com relação a DATA, eu sei que no MySQL a data é
   YYYY-MM-DD como eu devo proceder para que no meu formulário eu coloque por
   exemplo:

   12/09/2006

   e esta data seja gravada no meu bando de dados.

   Obrigado a todos,

   Roger






[As partes desta mensagem que não continham texto foram removidas]

#3611 De: "Haroldo CentralSys" <haroldo.passos@...>
Data: Sex, 1 de Set de 2006 11:50 am
Assunto: Re: baaChart Dúvida
haroldobpassos
Enviar e-mail Enviar e-mail
 
Voce pode enviar a classe para avaliar?

Haroldo



2006/8/31, Sergio de Andrade <sergio.ophus@...>:
>
>  Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> trocando informações.
>
> Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> classe baaChart
> para gerar gráficos estatísticos.
> Para utilizar a a classe estou usando algo do tipo:
>
>
>
#-------------------------------------------------------------------------------\
--
>
> include('baaChart.php');
>     $mygraph = new baaChart(600);
>     $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
>     $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
>
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
>     $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
>     $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
>     $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
>     $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
>     $mygraph->setBgColor(0,0,0,1);  //transparent background
>     $mygraph->setChartBgColor(0,0,0,1);  //as background
>     $mygraph->setXAxis("Mes",1);
>     $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
>     $mygraph->drawGraph();
>
>
> #-----------------------------------------------------------------------------
>
> Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> deste
> bloco de chamadas, como por exemplo(um simples: print "teste";) o código
> não
> funciona.
> Alguem poderia me dar uma luz !?
>
>
>
> atenciosamente
> --
> Sergio de Andrade Lopes
> (11) 3244-3580
> (11) 8168-5560
> TI - Microinformática
> Associação Comercial São Paulo
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>


[As partes desta mensagem que não continham texto foram removidas]

#3612 De: <php2005senac@...>
Data: Sex, 1 de Set de 2006 12:16 pm
Assunto: Re: Dúvida com Data
php2005senac
Enviar e-mail Enviar e-mail
 
Olá Cláudia,

Muito obrigado,

Com relação a sua dica eu fiz isto:

ALTER TABLE `tabela_cliente` ADD `valor` DECIMAL( 10, 2 ) NOT NULL ;

Está certo?

Quanto a função (veri_data), onde eu devo inserir:

Eu tenho 2 páginas:
cadastro_cliente.php (formulário)
cadastro_cliente_ok.php (página que faz o insert no BD)

Obrigado,

Roger





----- Original Message -----
From: Claudia A. V. Callegari
To: php-sp@...
Sent: Friday, September 01, 2006 8:50 AM
Subject: Re: [php-sp] Dúvida com Data


Ola Roger !!

Seja Bem Vindo !!

Primeiro uma dica, para sua tabela.
Sempre que for utilizar campos para guardar valores referente dinheiro , use
tipo decimal  exemplo  decimal(10,2).
Isso porque internamente o mysql guarda esses valores como caracter e não
retornará valores inesperados quando forem  somados.
Essa dica é de um professor experiente da Mysql Brasil.

Quanto ao seu problema com a data, você pode fazer o seguinte.
Usar a função abaixo  (veri_data)  para checar se a data informada é válida
e ao mesmo tempo converte-la para ser gravada.

Exemplo:

$data_conv=veri_data($_POST['data']) ;

if( ! $data_conv ) {
     echo " Data informada é inválida, digite  dd/mm/yyyy  ";
    //  break ;  ou retornar....  conforme seu codigo ...
}



function veri_data($data) {
         // verifica se uma data é válida e retorna no formato do mysql
aaaa-mm-dd
         // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
dd\mm\aaaa

   $a= ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
   if(!$a) {
            return false;
   }
         if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
            return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
         else
            return false;
     }

Abraços

Claudia A. V. Callegari

   ----- Original Message -----
   From: php2005senac@...
   To: php-sp@...
   Sent: Thursday, August 31, 2006 1:34 PM
   Subject: [php-sp] Dúvida com Data


   Olá está é minha 1ª mensagem. Estou começando a programas com PHP. Começei
a
   fazer um pequeno script com a seguinte estrutura em sua base de dados:

   Table structure for table `tabela_servidorVirtual`
   --

   DROP TABLE IF EXISTS `tabela_sv`;
   CREATE TABLE IF NOT EXISTS `tabela_sv` (
     `id_cliente` int(5) NOT NULL auto_increment,
     `nome_cliente` varchar(50) NOT NULL default '',
     `dominio_cliente` varchar(60) NOT NULL default '',
     `plano_cliente` varchar(50) NOT NULL default '',
     `espaco_atual` varchar(8) NOT NULL default '',
     `transferencia_atual` varchar(6) NOT NULL default '',
     `valor_plano` float NOT NULL default '0',
     `espaco_novo` varchar(8) NOT NULL default '',
     `transferencia_nova` varchar(6) NOT NULL default '',
     `plano_novo` varchar(50) NOT NULL default '',
     `data` date NOT NULL default '0000-00-00',
     `email_principal` varchar(100) NOT NULL default '',
     `email_secundario` varchar(100) NOT NULL default '',
     PRIMARY KEY  (`id_cliente`)
   ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3


   Se possível vocês poderiam me dizer se eu defini corretamente a minha
   tabale.

   A minha primeira dúvida é com relação a DATA, eu sei que no MySQL a data é
   YYYY-MM-DD como eu devo proceder para que no meu formulário eu coloque por
   exemplo:

   12/09/2006

   e esta data seja gravada no meu bando de dados.

   Obrigado a todos,

   Roger






[As partes desta mensagem que não continham texto foram removidas]





No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/435 - Release Date: 31/8/2006

#3613 De: "Claudia A. V. Callegari" <claudia@...>
Data: Sex, 1 de Set de 2006 2:34 pm
Assunto: Re: Dúvida com Data
claudiaphp
Enviar e-mail Enviar e-mail
 
Considerando sua tabela, parece que o campo referente valor  é o  `valor_plano` 
, certo ?
Então o certo é você alterar este campo ....

ALTER TABLE  `tabela_cliente`  CHANGE  `valor_plano`  `valor_plano` 
DECIMAL(10,2) ;

A chamada à função deve estar na segunda página...  cadastro_cliente_ok.php
(página que faz o insert no BD)

$data_conv=veri_data($_POST['data'])   / / troque o nome do campo pelo campo que
você definiu no seu form.  da primeira página..

Abraços
Claudia A. V. Callegari


   ----- Original Message -----
   From: php2005senac@...
   To: php-sp@...
   Sent: Friday, September 01, 2006 9:16 AM
   Subject: Re: [php-sp] Dúvida com Data


   Olá Cláudia,

   Muito obrigado,

   Com relação a sua dica eu fiz isto:

   ALTER TABLE `tabela_cliente` ADD `valor` DECIMAL( 10, 2 ) NOT NULL ;

   Está certo?

   Quanto a função (veri_data), onde eu devo inserir:

   Eu tenho 2 páginas:
   cadastro_cliente.php (formulário)
   cadastro_cliente_ok.php (página que faz o insert no BD)

   Obrigado,

   Roger





   ----- Original Message -----
   From: Claudia A. V. Callegari
   To: php-sp@...
   Sent: Friday, September 01, 2006 8:50 AM
   Subject: Re: [php-sp] Dúvida com Data


   Ola Roger !!

   Seja Bem Vindo !!

   Primeiro uma dica, para sua tabela.
   Sempre que for utilizar campos para guardar valores referente dinheiro , use
   tipo decimal  exemplo  decimal(10,2).
   Isso porque internamente o mysql guarda esses valores como caracter e não
   retornará valores inesperados quando forem  somados.
   Essa dica é de um professor experiente da Mysql Brasil.

   Quanto ao seu problema com a data, você pode fazer o seguinte.
   Usar a função abaixo  (veri_data)  para checar se a data informada é válida
   e ao mesmo tempo converte-la para ser gravada.

   Exemplo:

   $data_conv=veri_data($_POST['data']) ;

   if( ! $data_conv ) {
       echo " Data informada é inválida, digite  dd/mm/yyyy  ";
      //  break ;  ou retornar....  conforme seu codigo ...
   }



   function veri_data($data) {
           // verifica se uma data é válida e retorna no formato do mysql
   aaaa-mm-dd
           // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
   dd\mm\aaaa

     $a= ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
     if(!$a) {
              return false;
     }
           if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
              return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
           else
              return false;
       }

   Abraços

   Claudia A. V. Callegari

     ----- Original Message -----
     From: php2005senac@...
     To: php-sp@...
     Sent: Thursday, August 31, 2006 1:34 PM
     Subject: [php-sp] Dúvida com Data


     Olá está é minha 1ª mensagem. Estou começando a programas com PHP. Começei
   a
     fazer um pequeno script com a seguinte estrutura em sua base de dados:

     Table structure for table `tabela_servidorVirtual`
     --

     DROP TABLE IF EXISTS `tabela_sv`;
     CREATE TABLE IF NOT EXISTS `tabela_sv` (
       `id_cliente` int(5) NOT NULL auto_increment,
       `nome_cliente` varchar(50) NOT NULL default '',
       `dominio_cliente` varchar(60) NOT NULL default '',
       `plano_cliente` varchar(50) NOT NULL default '',
       `espaco_atual` varchar(8) NOT NULL default '',
       `transferencia_atual` varchar(6) NOT NULL default '',
       `valor_plano` float NOT NULL default '0',
       `espaco_novo` varchar(8) NOT NULL default '',
       `transferencia_nova` varchar(6) NOT NULL default '',
       `plano_novo` varchar(50) NOT NULL default '',
       `data` date NOT NULL default '0000-00-00',
       `email_principal` varchar(100) NOT NULL default '',
       `email_secundario` varchar(100) NOT NULL default '',
       PRIMARY KEY  (`id_cliente`)
     ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3


     Se possível vocês poderiam me dizer se eu defini corretamente a minha
     tabale.

     A minha primeira dúvida é com relação a DATA, eu sei que no MySQL a data é
     YYYY-MM-DD como eu devo proceder para que no meu formulário eu coloque por
     exemplo:

     12/09/2006

     e esta data seja gravada no meu bando de dados.

     Obrigado a todos,

     Roger






   [As partes desta mensagem que não continham texto foram removidas]





   No virus found in this incoming message.
   Checked by AVG Free Edition.
   Version: 7.1.405 / Virus Database: 268.11.7/435 - Release Date: 31/8/2006



[As partes desta mensagem que não continham texto foram removidas]

#3614 De: André Mauricio Garcia <andre.moe@...>
Data: Qui, 31 de Ago de 2006 6:12 pm
Assunto: Re: baaChart Dúvida
moe_andre
Enviar e-mail Enviar e-mail
 
Nunca utilizei esta classe, mas já utilizei diversas outras.
Normalmente elas utilizam um "header" de imagem. Então é bem provável que vc
tenha que usá-la em um arquivo separado (imagem.php, por exemplo).
Caso vc inprima alguma coisa, como seu simples "print 'teste';" o header já não
poderá mais ser alterado, logo a classe pára de funcionar.

Att.
André


----- Original Message -----
   From: Sergio de Andrade
   To: php-sp@...
   Sent: Thursday, August 31, 2006 1:51 PM
   Subject: [php-sp] baaChart Dúvida


   Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
   trocando informações.

   Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
   classe baaChart
   para gerar gráficos estatísticos.
   Para utilizar a a classe estou usando algo do tipo:

  
#-------------------------------------------------------------------------------\
--

   include('baaChart.php');
       $mygraph = new baaChart(600);
       $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
       $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");

   $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
       $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
       $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
       $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
       $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
       $mygraph->setBgColor(0,0,0,1);  //transparent background
       $mygraph->setChartBgColor(0,0,0,1);  //as background
       $mygraph->setXAxis("Mes",1);
       $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
       $mygraph->drawGraph();

   #-----------------------------------------------------------------------------

   Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima deste
   bloco de chamadas, como por exemplo(um simples: print "teste";) o código não
   funciona.
   Alguem poderia me dar uma luz !?



   atenciosamente
   --
   Sergio de Andrade Lopes
   (11) 3244-3580
   (11) 8168-5560
   TI - Microinformática
   Associação Comercial São Paulo


   [As partes desta mensagem que não continham texto foram removidas]






[As partes desta mensagem que não continham texto foram removidas]

#3615 De: "Sergio de Andrade" <sergio.ophus@...>
Data: Qui, 31 de Ago de 2006 6:35 pm
Assunto: Re: Dúvida com Data
xr32004
Enviar e-mail Enviar e-mail
 
Roger, basta imprimir sua data da seguinte forma:

  print Date("d-m-Y", strtotime($row[10]));

sendo que "$row[10]" é a posição onde está alocado a coluna de data da sua
tabela.


espero ter ajudado.


Em 31/08/06, php2005senac@... <php2005senac@...> escreveu:
>
> Olá está é minha 1ª mensagem. Estou começando a programas com PHP. Começei
> a
> fazer um pequeno script com a seguinte estrutura em sua base de dados:
>
> Table structure for table `tabela_servidorVirtual`
> --
>
> DROP TABLE IF EXISTS `tabela_sv`;
> CREATE TABLE IF NOT EXISTS `tabela_sv` (
>   `id_cliente` int(5) NOT NULL auto_increment,
>   `nome_cliente` varchar(50) NOT NULL default '',
>   `dominio_cliente` varchar(60) NOT NULL default '',
>   `plano_cliente` varchar(50) NOT NULL default '',
>   `espaco_atual` varchar(8) NOT NULL default '',
>   `transferencia_atual` varchar(6) NOT NULL default '',
>   `valor_plano` float NOT NULL default '0',
>   `espaco_novo` varchar(8) NOT NULL default '',
>   `transferencia_nova` varchar(6) NOT NULL default '',
>   `plano_novo` varchar(50) NOT NULL default '',
>   `data` date NOT NULL default '0000-00-00',
>   `email_principal` varchar(100) NOT NULL default '',
>   `email_secundario` varchar(100) NOT NULL default '',
>   PRIMARY KEY  (`id_cliente`)
> ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3
>
>
> Se possível vocês poderiam me dizer se eu defini corretamente a minha
> tabale.
>
> A minha primeira dúvida é com relação a DATA, eu sei que no MySQL a data é
>
> YYYY-MM-DD como eu devo proceder para que no meu formulário eu coloque por
>
> exemplo:
>
> 12/09/2006
>
> e esta data seja gravada no meu bando de dados.
>
> Obrigado a todos,
>
> Roger
>
>
>
>
>
>



--
Sergio de Andrade Lopes
(11) 3244-3580
(11) 8168-5560
TI - Microinformática
Associação Comercial São Paulo


[As partes desta mensagem que não continham texto foram removidas]

#3616 De: "Sergio de Andrade" <sergio.ophus@...>
Data: Sex, 1 de Set de 2006 12:53 pm
Assunto: Re: baaChart Dúvida
xr32004
Enviar e-mail Enviar e-mail
 
Com certeza Aroldo..
A classe é o arquivo baaChart.php
O PHP que passa os parametros é o geraGrafico.php.



muito obrigado pela atenção.



2006/9/1, Haroldo CentralSys <haroldo.passos@...>:
>
> Voce pode enviar a classe para avaliar?
>
> Haroldo
>
>
>
> 2006/8/31, Sergio de Andrade <sergio.ophus@...>:
>
> >
> >  Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> > trocando informações.
> >
> > Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> > classe baaChart
> > para gerar gráficos estatísticos.
> > Para utilizar a a classe estou usando algo do tipo:
> >
> >
> >
>
#-------------------------------------------------------------------------------\
--
> >
> > include('baaChart.php');
> >     $mygraph = new baaChart(600);
> >     $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
> >     $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
> >
> >
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
> >     $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
> >     $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
> >     $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
> >     $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
> >     $mygraph->setBgColor(0,0,0,1);  //transparent background
> >     $mygraph->setChartBgColor(0,0,0,1);  //as background
> >     $mygraph->setXAxis("Mes",1);
> >     $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
> >     $mygraph->drawGraph();
> >
> >
> >
> #-----------------------------------------------------------------------------
> >
> > Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> > deste
> > bloco de chamadas, como por exemplo(um simples: print "teste";) o código
> > não
> > funciona.
> > Alguem poderia me dar uma luz !?
> >
> >
> >
> > atenciosamente
> > --
> > Sergio de Andrade Lopes
> > (11) 3244-3580
> > (11) 8168-5560
> > TI - Microinformática
> > Associação Comercial São Paulo
> >
> >
> > [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
> >
> >
> >
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>



--
Sergio de Andrade Lopes
(11) 3244-3580
(11) 8168-5560
TI - Microinformática
Associação Comercial São Paulo

   ----------

<?php
/***********************************************************
* Class:        baaChart
* Version:      1.4
* Date:         Aug 2006
* Author:       Barry Andrew
* Copyright:    © BA Andrew 2003
*               http://members.aol.com/barryaandrew/baaLic.html
***********************************************************
USAGE SAMPLE

     include('baaChart.php');
     $mygraph = new baaChart(600);
     $mygraph->setTitle('Regional Sales','Jan - Jun 2002');
     $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec");
     $mygraph->setXAxis("Month",0);
     $mygraph->setYAxis ('Regional Sales', 0, 100, 20, 0);
     $mygraph->addDataSeries('L',LINE_MARK_X,"25,30,35,40,30,35","South");
     $mygraph->addDataSeries('L',LINE_MARK_CIRCLE,"65,70,80,90,75,48","North");
     $mygraph->addDataSeries('L',LINE_MARK_SQUARE,"12,18,25,20,22,30","West");
     $mygraph->addDataSeries('L',LINE_MARK_DIAMOND ,"50,60,75,80,60,75","East");
     $mygraph->addDataSeries('L',LINE_MARK_NONE,"30,45,50,55,52,60","Europe");
     $mygraph->setBgColor(255,255,255,0);
     $mygraph->drawGraph();

*/
     /********************************************************
     *                      defines                          *
     ********************************************************/
     define ('VERSION', 'baaChart 1.4');

     define ('PIE_NONE',0);
     define ('PIE_LEGEND_PCENT',1);
     define ('PIE_LEGEND_VALUE',2);
     define ('PIE_CHART_VALUE',4);
     define ('PIE_CHART_PCENT',8);
     define ('LINE_MARK_NONE',0);
     define ('LINE_MARK_PLUS',1);
     define ('LINE_MARK_X',2);
     define ('LINE_MARK_CIRCLE',3);
     define ('LINE_MARK_SQUARE',4);
     define ('LINE_MARK_DIAMOND',5);
     define ('COLS_NO_STACK',0);
     define ('COLS_STACKED',1);

class baaChart  {

     /********************************************************
     *                      Variables                        *
     ********************************************************/
     var $image;
     var $title;
     var $subtitle;
     var $bgd;
     var $cbgd,$cbgd2;            // chart band colours
     var $txtcol;
     var $white;
     var $black;
     var $gridcol;
     var $width;
     var $height;
     var $cwidth,$cheight;        // chart dimensions
     var $scolors;
     var $lm,$rm,$tm,$bm;        // margins
     var $ytitle;                // y axis settings
     var $ymin = 0;
     var $ymax = 0;
     var $ygrid = false;
     var $ygridint;
     var $xtitle;                // x axis settings
     var $xgrid = false;
     var $xgridint;
     var $xcount;                // count of values in each series
     var $seriescount;
     var $colwidth;
     var $transparent;
     var $ispiechart;

     var $legends;
     var $stackcount;
     var $xlabels;
     var $data;
     var $xmaxima;                // series max values
     var $xminima;
     var $stypes;                // series types
     var $stacked;                // series stacked?
     var $stackbase;
     var $pic;
     var $clip;
     var $picx;
     var $picy;
     var $picw;
     var $pich;
     var $pict;
     var $pictrans;
     var $bgimage;
     var $bgx;
     var $bgy;
     var $showvals;
     /********************************************************
     *                   public methods                      *
     ********************************************************/
     function baaChart ($awidth, $aheight=0, $pic='', $clip=0, $picx=0, $picy=0)
{
         $this->width = $awidth;
         $this->height = $aheight==0 ? floor($awidth / 1.616) : $aheight;
         $this->pic = $pic;
         $this->clip = $clip;
         $this->picx = $picx;
         $this->picy = $picy;
         $this->picw = 0;
         $this->pich = 0;
         $this->pict = 0;
         $this->pictrans = 100;
         if ($pic != '') {
             $size = getimagesize($pic);
             if ($size == null) {
                 $this->pic = '';
             }
             else {
                   list($this->picw, $this->pich, $this->pict) = $size;
             }
         }
         $this->image = imagecreate($this->width, $this->height);
         $this->bgd = imagecolorallocate($this->image,0xFF,0xFF,0xFF);
         $this->white = imagecolorallocate($this->image,0xFF,0xFF,0xFF);
         $this->cbgd = imagecolorallocate($this->image,0xEE,0xEE,0xEE);
         $this->cbgd2 = imagecolorallocate($this->image,0xDD,0xDD,0xDD);
         $this->txtcol = imagecolorallocate($this->image,0,0,0);
         $this->black = imagecolorallocate($this->image,0,0,0);
         $this->gridcol = imagecolorallocate($this->image,0x66,0x66,0x66);
         $this->scolors = array (
             0 => imagecolorallocate ($this->image,0xFF,0x66,0x66),
             1 => imagecolorallocate ($this->image,0x66,0x66,0xCC),
             2 => imagecolorallocate ($this->image,0x66,0xcc,0x66),
             3 => imagecolorallocate ($this->image,0x99,0x00,0x99),
             4 => imagecolorallocate ($this->image,0xFF,0xCC,0x00)
         );
         $this->tm = 50;
         $this->bm = 50;
         $this->lm = 80;
         $this->rm = 20;
         $this->cwidth = $this->width - ($this->lm + $this->rm);
         $this->cheight = $this->height - ($this->tm + $this->bm);
         $this->seriescount = 0;
         $this->xcount = 0;
         $this->legends = array();
         $this->stackcount = array();
         $this->xlabels = array();
         $this->data = array();
         $this->xmaxima = array();                // series max values
         $this->xminima = array();
         $this->stypes = array();                // series types
         $this->stacked = array();                // series stacked?
         $this->stackbase = array();
         $this->showvals = array();
     }
     function setMargins ($l=0, $t=0, $r=0, $b=0) {
         if ($t>0) $this->tm = $t;
         if ($b>0) $this->bm = $b;
         if ($l>0) $this->lm = $l;
         if ($r>0) $this->rm = $r;
     }
     function setBgColor ($r, $g, $b, $trans=false) {
         $this->bgd = imagecolorallocate($this->image,$r,$g,$b);
         if ($this->pic != '') $trans = 1;
         if ($trans==1)
             imagecolortransparent($this->image,$this->bgd);
         $this->transparent = $trans;
     }
     function setChartBgColor ($r, $g, $b, $asbg=0) {
         if ($this->pic != '') $asbg = 1;
         $this->cbgd = $asbg ? $this->bgd :
imagecolorallocate($this->image,$r,$g,$b);
         $this->cbgd2 = $this->cbgd;
     }
     function setChartBgColor2 ($r, $g, $b) {
         $this->cbgd2 = imagecolorallocate($this->image,$r,$g,$b);
     }
     function setTextColor ($r, $g, $b) {
         $this->txtcol = imagecolorallocate($this->image,$r,$g,$b);
     }
     function setGridColor ($r, $g, $b) {
         $this->gridcol = imagecolorallocate($this->image,$r,$g,$b);
     }
     function setSeriesColor ($n, $r, $g, $b) {
         if ($n<1) $n=1;
         $this->scolors[$n-1] = imagecolorallocate($this->image,$r,$g,$b);
     }
     function setTitle ($aTitle,$aSub='') {
         if ($aTitle) $this->title = $aTitle;
         if ($aSub) $this->subtitle = $aSub;
     }
     function setYAxis($title='',$min=0,$max=0,$gridint=0,$grid=0) {
         $this->ytitle = $title;
         $this->ymin = $min;
         $this->ymax = $max;
         $this->ygrid = $grid;
         $this->ygridint = $gridint < 2 ? 10 : $gridint;
     }
     function setXAxis ($title, $grid=0) {
         $this->xtitle = $title;
         $this->xgrid = $grid;
     }
     function setXLabels ($labs) {
         $this->xlabels = is_array($labs) ? $labs : explode(",",$labs);
         $this->xcount = count($this->xlabels);
     }
     function addDataSeries ($type,$stacked,$vals,$legend) {
         $n = $this->seriescount++;
         $this->stypes[$n] = $type;
         $this->stacked[$n] = $stacked;
         $d = is_array($vals) ? $vals : explode(",",$vals);
         $this->xmaxima[$n] = max($d);
         $this->xminima[$n] = min($d);
         $dc = count($d);
         if ($this->xcount < $dc) {
             for ($i=$this->xcount,$L = 'A'; $i < $dc; $i++, $L++)
                 $this->xlabels[$i] = $L;
             $this->xcount = $dc;
         }
         if ($dc < $this->xcount) array_pad($d,$this->xcount,0);
         $this->data[$n] = $d;
         $this->legends[$n] = $legend=='' ? '_' : $legend;
         $this->showvals[$n] = 0;
     }
     function setBgImagePos($x, $y) {
              $this->bgx = $x;
              $this->bgy = $y;
     }
     function setBgImageAlpha($val) {
              $this->pictrans = $val;
     }
     function showValues($series) {
              $this->showvals[$series] = 1;
     }
     function drawGraph($filename='') {
         header("Content-Type: image/png");
         $this->_draw();
         if ($filename!='') imagepng( $this->image, $filename );
         imagepng( $this->image );
         imagedestroy( $this->image );
         if ($this->bgimage) imagedestroy( $this->bgimage );
         exit();
     }
     function display($filename='') {
              $this->drawGraph($filename);
     }

     /********************************************************
     *                   private methods                     *
     ********************************************************/
     function _draw() {
         $a = array_keys($this->stypes,'P');
         $this->ispiechart = count($a)>0;
         $this->_calcrmargin();
        
imagefilledrectangle($this->image,0,0,$this->width-1,$this->height-1,$this->bgd)\
;
         if ($this->pic != '') $this->_backgroundImage();
         if ($this->pic == '') {
             if (!$this->transparent)
                
imagerectangle($this->image,0,0,$this->width-1,$this->height-1,$this->txtcol);
             imagefilledrectangle($this->image, $this->lm, $this->tm,
$this->width-$this->rm, $this->height-$this->bm, $this->cbgd);
         }
         $this->stackcount=0;
         for ($s=0; $s<$this->seriescount; $s++) {
             if (($this->stypes[$s] == 'C') && ($this->stacked[$s]==1))
$this->stackcount++;
         }
         imagestring($this->image, 1, 2,$this->height-10,VERSION,$this->txtcol);
         $this->_drawtitles();
         $this->_drawaxes();
         $this->_drawlegends();
         $this->stackbase = array_pad($this->stackbase,$this->xcount,0);
         for ($i=0; $i<$this->seriescount; $i++) $this->_plotSeries($i);
     }

     function _drawpieval($i,$alpha,$x,$y,$r) {
         $pietot = 0;
         for ($s=0; $s<$this->seriescount; $s++) {
             if ($this->stypes[$s]=='P') $pietot += array_sum($this->data[$s]);
         }
         $val = array_sum($this->data[$i]);
         $pc = sprintf('%0.1f%%',$val * 100 / $pietot);
         $tx = $x + $r*0.75 * cos(deg2rad($alpha));
         $ty = $y + $r*0.75 * sin(deg2rad($alpha));
         $fw = imagefontwidth(2);
         switch (($this->stacked[$i]>>2) & 0x3) {
         case 1: //plot value
             $tw = strlen($val)*$fw;
             $tx -= $tw/2;
             imagefilledrectangle($this->image,$tx-2,$ty-6,$tx + $tw +
2,$ty+6,$this->white);
             imagestring($this->image,2,$tx,$ty-5,$val,$this->txtcol);
             break;
         case 2: // plot %
         case 3:
             $tw = strlen($pc)*$fw;
             $tx -= $tw/2;
             imagefilledrectangle($this->image,$tx-2,$ty-6,$tx + $tw +
2,$ty+6,$this->white);
             imagestring($this->image,2,$tx,$ty-5,$pc,$this->txtcol);
             break;
         }
     }

     function pielegends() {
         $pietot = 0;
         for ($s=0; $s<$this->seriescount; $s++) {
             if ($this->stypes[$s]=='P') $pietot += array_sum($this->data[$s]);
         }
         $a = array_keys($this->stypes,'P');
         $maxt = $maxv = 0;
         foreach ($a as $pie) {
             $val = array_sum($this->data[$pie]);
             $maxv = max($maxv, strlen($val));
             $txt = $this->legends[$pie];
             $maxt = max($maxt, strlen($txt));
         }
         foreach ($a as $pie) {
             $val = array_sum($this->data[$pie]);
             $pc = $val * 100 / $pietot;
             switch ($this->stacked[$pie] & 0x03) {
             case 1 : $this->legends[$pie] = sprintf("%-{$maxt}s
%4.1f%%",$this->legends[$pie],$pc); break;
             case 2 : $this->legends[$pie] = sprintf("%-{$maxt}s
%{$maxv}s",$this->legends[$pie],$val); break;
             case 3 : $this->legends[$pie] = sprintf("%-{$maxt}s %{$maxv}s
%4.1f%%",$this->legends[$pie],$val,$pc); break;
             }
         }
     }

     function _calcrmargin() {
         if ($this->ispiechart) {
             $this->pielegends();
         }
         $leglen = array();
         foreach($this->legends as $leg) {
             $leglen[] = strlen($leg);
         }
         $maxleglen = max($leglen);
         if ($maxleglen==0) return;
         $legwid = $maxleglen * imagefontwidth(2) + 30;
         $this->rm = max($this->rm, $legwid);
         $this->cwidth = $this->width - $this->lm - $this->rm;
         $this->xgridint = ($this->cwidth / $this->xcount);
         $maxlabwid = $this->_maxlab();
         if ($maxlabwid > $this->xgridint) {
             $this->bm = max($this->bm,$maxlabwid+40);
             $this->cheight = $this->height - $this->tm - $this->bm;
         }
     }

     function _drawlegends() {
         $legx = $this->lm + $this->cwidth + 5;
         $legy = $this->tm;
         if ($this->stackcount>0) {
             $this->legends = array_reverse($this->legends,true);
         }
         foreach ($this->legends as $k=>$leg) {
             if ($leg != '_') {
                 switch ($this->stypes[$k]) {
                 case 'C':
                     if ($this->ispiechart) break;
                 case 'P':
                    
imagefilledrectangle($this->image,$legx,$legy,$legx+15,$legy+15,$this->scolors[$\
k]);
                    
imagerectangle($this->image,$legx,$legy,$legx+15,$legy+15,$this->black);
                    
imagestring($this->image,2,$legx+20,$legy+1,$leg,$this->txtcol);
                     break;
                 case 'L':
                     if ($this->ispiechart) break;
                     if ($this->stacked[$k]>=0) {
                        
imageline($this->image,$legx,$legy+7,$legx+15,$legy+7,$this->scolors[$k]);
                        
imageline($this->image,$legx,$legy+8,$legx+15,$legy+8,$this->scolors[$k]);
                        
imageline($this->image,$legx,$legy+9,$legx+15,$legy+9,$this->scolors[$k]);
                     }
                     $this->_drawmarker($legx+8,$legy+8,$this->stacked[$k],
$this->scolors[$k]);
                    
imagestring($this->image,2,$legx+20,$legy+1,$leg,$this->txtcol);
                 }
                 $legy += 20;
             }
         }
     }

     function _val2y($v, $base=0) {
         $rv = $v + $base - $this->ymin;
         $ppu = $this->cheight/($this->ymax - $this->ymin);
         return $this->tm + $this->cheight - ($rv * $ppu) ;
     }

     function _drawmarker($x,$y,$m, $c) {
         $fill = $m < 0 ? $c : $this->white;
         $line = $m < 0 ? $c : $this->black;
         switch (abs($m)) {
         case 1:
             $x0 = $x-3; $x1 = $x+3; imageline($this->image,$x0,$y,$x1,$y,$line);
             $y0 = $y-3; $y1 = $y+3; imageline($this->image,$x,$y0,$x,$y1,$line);
             break;
         case 2:
             $x0 = $x-3; $x1 = $x+3;
             $y0 = $y-3; $y1 = $y+3;
             imageline($this->image,$x0,$y0,$x1,$y1,$line);
             imageline($this->image,$x1,$y0,$x0,$y1,$line);
             break;
         case 3:
             $w = $h = 8;
             imagearc($this->image,$x,$y,$w,$h,0,361,$this->black);
             imagefill($this->image,$x,$y,$fill);
             break;
         case 4:
             $x0 = $x-3; $x1 = $x+3;
             $y0 = $y-3; $y1 = $y+3;
             imagefilledrectangle($this->image,$x0,$y0,$x1,$y1,$fill);
             imagerectangle($this->image,$x0,$y0,$x1,$y1,$this->black);
             break;
         case 5:
             $p[] = $x; $p[] = $y-4; $p[] = $x+4; $p[] = $y;
             $p[] = $x; $p[] = $y+4; $p[] = $x-4; $p[] = $y;
             imagefilledpolygon($this->image,$p,4,$fill);
             imagepolygon($this->image,$p,4,$this->black);
         }
     }

     function _plotseries($i) {
         $valposArray = array();
         switch ($this->stypes[$i]) {
         case 'L':
             if ($this->ispiechart) break;
             $this->colwidth = $this->xgridint - 4;
             for ($p=0; $p<$this->xcount; $p++) {
                 $pts[$p][0] = $this->lm + $p * $this->xgridint +
$this->xgridint/2;
                 $pts[$p][1] = $this->_val2y($this->data[$i][$p]);
                 $valposArray[$i][$p] = array($pts[$p][0], $pts[$p][1],
$pts[$p][1]);
             }
             for ($p=1; $p<$this->xcount; $p++) {
                 if (!isset($this->data[$i][$p])) continue;
                 if ($this->stacked[$i]<0) continue;
                
imageline($this->image,$pts[$p-1][0],$pts[$p-1][1],$pts[$p][0],$pts[$p][1],$this\
->scolors[$i]);
                
imageline($this->image,$pts[$p-1][0],$pts[$p-1][1]-1,$pts[$p][0],$pts[$p][1]-1,$\
this->scolors[$i]);
                
imageline($this->image,$pts[$p-1][0],$pts[$p-1][1]+1,$pts[$p][0],$pts[$p][1]+1,$\
this->scolors[$i]);
             }
             if ($this->stacked[$i]!=0) {
                 for ($p=0; $p<$this->xcount; $p++) {
                     if (!isset($this->data[$i][$p])) continue;
                    
$this->_drawmarker($pts[$p][0],$pts[$p][1],$this->stacked[$i],
$this->scolors[$i]);
                 }
             }
             $this->_drawVals($valposArray);
             break;
         case 'C':
             if ($this->ispiechart) break;
             $stacked = $this->stackcount>0;
             $b = array_keys($this->stypes,'C');
             $colpos = 0;
             if (!$stacked){
                 while (list($k,$v)=each($b)) {
                     if ($v==$i) break;
                     $colpos++;
                 }
             }
             for ($p=0; $p<$this->xcount; $p++) {

                 $x0 = $this->lm + 5 + $p * $this->xgridint + $colpos *
$this->colwidth;
                 $x1 = $x0 + $this->colwidth;
                 $y0 = $this->_val2y($this->data[$i][$p],$this->stackbase[$p]);
                 $y1 =
$this->_val2y($this->stackbase[$p],(0>$this->ymin)?(0):($this->ymin));
                 if ($stacked) $this->stackbase[$p] += $this->data[$i][$p];
                 if(0 > $this->data[$i][$p])
                 {
                         $t = $y0;
                         $y0 = $y1;
                         $y1 = $t;
                 }
                 $valposArray[$i][$p] = array($x0+($x1-$x0)/2, $y0, $y1);
                
imagefilledrectangle($this->image,$x0,$y0,$x1,$y1,$this->scolors[$i]);
                 imagerectangle($this->image,$x0,$y0,$x1,$y1,$this->black);
             }
             if (!$stacked) $this->_drawVals($valposArray);
             break;
         case 'P':
             $x = ($this->lm + $this->cwidth + $this->lm)/2;
             $y = ($this->tm + $this->cheight + $this->tm)/2;
             $w = $h = min($this->cwidth, $this->cheight) - 10;
             $pietot = 0;
             for ($s=0; $s<$this->seriescount; $s++) {
                 if ($this->stypes[$s]=='P') $pietot +=
array_sum($this->data[$s]);
             }
             $alpha = $this->stackbase[0];
             $theta = array_sum($this->data[$i])*360 / $pietot;
            
imagefilledarc($this->image,$x,$y,$w,$h,$alpha,$alpha+$theta,$this->scolors[$i],\
IMG_ARC_PIE);
             $this->_drawpieval($i,$alpha+$theta/2,$x,$y,$w/2);
             $this->stackbase[0] += $theta;
         }
     }

     function _drawVals($posArray) {
              $marray = array();
              foreach ($this->data as $i => $parray) {
                       foreach ($parray as $v) {
                                $marray[] = strlen($v) * imagefontwidth(1);
                       }
              }
              $maxwidth = max($marray);
              $rotate = 0;
              if ($this->stypes[$i]=='C') {
                  $rotate = $maxwidth > $this->colwidth-4 ? 1 : 0;
              }
              if ($rotate && (imagefontheight(2) > $this->colwidth-4) )
                  return; // insufficient space

              foreach ($this->data as $i => $parray) {
                       if (!$this->showvals[$i+1]) continue;
                       foreach ($parray as $p => $v) {
                                $boxwidth = strlen($v) * imagefontwidth(2) + 2;
                                $boxheight = imagefontheight(2);
                                $posdata = $posArray[$i][$p];
                                $posx = $posdata[0];
                                $posy = $posdata[1]-5;
                                $posy1 = $posdata[2]-5;
                                switch ($rotate) {
                                case 0:
                                     $x0 = $posx - ($boxwidth / 2);
                                     $x1 = $posx + ($boxwidth / 2);
                                     $y0 = $posy - $boxheight;
                                     $y1 = $posy;
                                     imagefilledrectangle($this->image, $x0, $y0,
$x1, $y1, $this->white);
                                     imagerectangle($this->image, $x0, $y0, $x1,
$y1, $this->black);
                                     imagestring($this->image, 2, $x0+2, $y0, $v,
$this->black);
                                     break;

                                case 1:
                                     $x0 = $posx - ($boxheight / 2);
                                     $x1 = $posx + ($boxheight / 2);
                                     $y1 = $v < 0 ? $posy : $posy1;
                                     $y0 = $y1 - $boxwidth;
                                     imagefilledrectangle($this->image, $x0, $y0,
$x1, $y1, $this->white);
                                     imagerectangle($this->image, $x0, $y0, $x1,
$y1, $this->black);
                                     imagestringup($this->image, 2, $x0+2, $y1-2,
$v, $this->black);
                                     break;

                                }
                       }
              }

     }

     function _drawtitles() {
         $cw = imagefontwidth(5);
         $l = strlen($this->title);
         $tw = $cw*$l;
         $x = $this->lm + ($this->cwidth - $tw)/2;
         imagestring ($this->image,5,$x, 5, $this->title, $this->txtcol);
         $cw = imagefontwidth(4);
         $l = strlen($this->subtitle);
         $tw = $cw*$l;
         $x = $this->lm + ($this->cwidth - $tw)/2;
         imagestring ($this->image,4,$x, 25, $this->subtitle, $this->txtcol);

     }

     function _drawaxes() {
         if ($this->ispiechart) return;
         $changed = 0;
         $ym = $this->_calcymax();
         if (isset($this->ygridint)) {
             if ($this->ygridint < 2)
                 $this->ygridint = ($this->ymax - $this->ymin)/4;
         }
         else $this->ygridint = ($this->ymax - $this->ymin)/4;

         $i =  $this->ygridint;

         if ($this->ymax < $ym ) {
             $this->ymax = floor(($ym + $i)/$i) * $i;
             $changed = 1;
         }
         $yn = min($this->xminima);
         if ($this->ymin > $yn) {
             $this->ymin = floor(($yn - $i)/$i) * $i;
             $changed = 1;
         }

         $this->_drawyaxis();
         $this->_drawxaxis();
     }

     function _drawyaxis() {
         $x0 = $this->lm;
         $y0 = $this->tm + $this->cheight;
         $x1 = $x0;
         $y1 = $this->tm;
         $div = $this->ygridint * $this->cheight / ($this->ymax - $this->ymin);
         $grx = $this->ygrid ? $this->lm + $this->cwidth : $this->lm-3;
         for ($y = $y1,$v=$this->ymax,$i=0; $y < $y0-2; $y += $div, $v -=
$this->ygridint, $i++) {
             if ($this->cbgd != $this->cbgd2) {
                 $col = ($i%2) ? $this->cbgd : $this->cbgd2;
                 imagefilledrectangle($this->image,$x0,$y,$this->lm +
$this->cwidth,$y+$div,$col);
             }
             imageline($this->image,$x0,$y,$grx,$y,$this->gridcol);
             $tw = strlen("$v")*imagefontwidth(2);
             imagestring($this->image,2,$x0 - $tw  - 5, $y - 5, $v,
$this->txtcol);
         }
         $tw = strlen("$this->ymin")*imagefontwidth(2);
         $y = $this->tm + $this->cheight;
         imagestring($this->image,2,$x0 - $tw  - 5, $y - 6, $this->ymin,
$this->txtcol);
         imageline($this->image,$x0,$y0,$x1,$y1,$this->gridcol);
         $tw = strlen($this->ytitle) * imagefontwidth(3);
         $y = ($this->tm + $this->height - $this->bm + $tw)/2;
         $x = 10;
         imagestringup($this->image,3,$x,$y,$this->ytitle,$this->txtcol);
     }

     function _maxlab() {
         $max = 0;
         for ($i=0; $i < $this->xcount; $i++) {
             $v = $this->xlabels[$i];
             $tw = strlen("$v")*imagefontwidth(2);
             $max = max ($max, $tw);
         }
         return $max;
     }

     function _drawxaxis() {
         $maxlabwid = $this->_maxlab();
         $x0 = $this->lm;
         $y0 = $this->tm + $this->cheight;
         $x1 = $x0 + $this->cwidth;
         $y1 = $y0;
         $div = $this->xgridint;
         imageline($this->image,$x0,$y0,$x1,$y1,$this->gridcol);
         $gry = $this->xgrid ? $this->tm : $this->tm + $this->cheight + 3 ;
         for ($x=$x1,$i=$this->xcount-1; $x>$x0+3; $x -= $div, $i--) {
             imageline($this->image,$x,$gry,$x,$y0,$this->gridcol);
             $v = $this->xlabels[$i];
             $tw = strlen("$v")*imagefontwidth(2);
             $th = imagefontheight(2);
             if ($maxlabwid < $div) {
                 imagestring($this->image,2,$x - ($div+$tw)/2, $y0 + 5, $v,
$this->txtcol);
             }
             else {
                 imagestringup($this->image,2,$x - ($div+$th)/2, $y0 + 5 + $tw,
$v, $this->txtcol);
             }
         }
         $y = $this->height - 30;
         $tw = strlen($this->xtitle)*imagefontwidth(3);
         $x = ($this->lm + $this->cwidth + $this->lm - $tw)/2;
         imagestring($this->image,3,$x,$y,$this->xtitle,$this->txtcol);
     }

     function _calcymax() {

         $b = array_keys($this->stypes,'C');
         if ($this->stackcount == 0) {
             $m = max($this->xmaxima);
             if (count($b) > 0)
                 $this->colwidth = ($this->xgridint - 10)/count($b);
             else
                 $this->colwidth = 0;
         }
         else {
             $m=0;
             $stacktots = array();
             foreach ($b as $v) {
                 #$m += $this->xmaxima[$v];
                 for ($i=0; $i<$this->xcount; $i++) {
                	 $stacktots[$i] += $this->data[$v][$i];
                 }
                 $this->stacked[$v] = 1;
             }
             $m = max (max($this->xmaxima),max($stacktots));
             $this->colwidth = ($this->xgridint - 10);
         }
         return $m;
     }

     function _backgroundImage() {

         switch ($this->pict) {
             case 1: $this->bgimage = imagecreatefromgif($this->pic); break;
             case 2: $this->bgimage = imagecreatefromjpeg($this->pic); break;
             case 3: $this->bgimage = imagecreatefrompng($this->pic); break;
             default : $this->pic = ''; return;
         }

         switch ($this->clip) {
         case 0:
              if ($this->pictrans == 100) {
              imagecopyresampled($this->image, $this->bgimage, 0,0,0,0,
$this->width,$this->height,$this->picw, $this->pich);
              }
              else {
              $itmp = imagecreatetruecolor($this->width,$this->height);
              imagecopyresampled($itmp, $this->bgimage, 0,0,0,0,
$this->width,$this->height,$this->picw, $this->pich);
             imagecopymerge ($this->image, $itmp, 0, 0, 0,
0,$this->width,$this->height, $this->pictrans );
             imagedestroy($itmp);
              }
              break;
         case 1:
             if (is_null($this->bgx) || is_null($this->bgy)) {
                 $dx = $this->width > $this->picw ? ($this->width -
$this->picw)/2 : 0;
                 $dy = $this->height > $this->pich ? ($this->height -
$this->pich)/2 : 0;
             }
             else {
                 $dx = $this->bgx;
                 $dy = $this->bgy;
             }
             $px = min($this->width, $this->picw);
             $py = min($this->height, $this->pich);
             imagecopymerge ($this->image, $this->bgimage, $dx, $dy, $this->picx,
$this->picy,$px,$py, $this->pictrans );
             break;
         case 2:
             $px = min($this->width, $this->picw);
             $py = min($this->height, $this->pich);
             for ($dx=0; $dx  < $this->width; $dx += $this->picw) {
                 for ($dy=0; $dy  < $this->height; $dy += $this->pich) {
                      imagecopymerge ($this->image, $this->bgimage, $dx, $dy,
$this->picx, $this->picy,$px,$py, $this->pictrans );
                 }
             }
             break;
         }
     }
}

?>
   ----------

<?php

#===============================================================================\
======
#= Script  : Sistema de Graficos
#= Arquivo : graficoColunas.php
#= Versão  : 1.0
#= Autor   : Sergio de Andrade
#= Email   : sergio@...
#= Website : ufac.acsp.com.br
#===============================================================================\
======


   /*
     # Pizza
     include('baaChart.php');
	 $mygraph = new baaChart(600);
	 $mygraph->setTitle('São Paulo','Jan - Jun 2002');
	 $mygraph->addDataSeries('P',PIE_CHART_PCENT +
PIE_LEGEND_VALUE,"25,30,35,40,30,35","South");
	 $mygraph->addDataSeries('P',PIE_CHART_PCENT +
PIE_LEGEND_VALUE,"65,70,80,90,75,48","North");
	 $mygraph->addDataSeries('P',PIE_CHART_PCENT +
PIE_LEGEND_VALUE,"12,18,25,20,22,30","West");
	 $mygraph->addDataSeries('P',PIE_CHART_PCENT +
PIE_LEGEND_VALUE,"50,60,75,80,60,75","East");
	 $mygraph->addDataSeries('P',PIE_CHART_PCENT +
PIE_LEGEND_VALUE,"30,45,50,55,52,60","Europe");
	 $mygraph->drawGraph();

     # LINHAS NA HORIZONTAL

	 include('baaChart.php');
	 $mygraph = new baaChart(600);
	 $mygraph->setTitle('Regional Sales','Jan - Jun 2002');
	 $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
	 $mygraph->addDataSeries('L',LINE_MARK_X,"25,30,35,40,30,35","South");
	 $mygraph->addDataSeries('L',LINE_MARK_CIRCLE,"65,70,80,90,75,48","North");
	 $mygraph->addDataSeries('L',LINE_MARK_SQUARE,"12,18,25,20,22,30","West");
	 $mygraph->addDataSeries('L',LINE_MARK_DIAMOND,"50,60,75,80,60,75","East");
	 $mygraph->addDataSeries('L',LINE_MARK_NONE,"30,45,50,55,52,60","Europe");
	 $mygraph->setBgColor(255,255,255,1); //Transparent
	 $mygraph->setXAxis("Month",1);
	 $mygraph->setYAxis("Sales (£000)",0,100,10,0);
	 $mygraph->drawGraph();
*/
	 # COLUNAS
	 include('baaChart.php');
	 $mygraph = new baaChart(600);
	 $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
	 $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
	 $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
	 $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
	 $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
	 $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
	 $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
	 $mygraph->setBgColor(0,0,0,1);  //transparent background
	 $mygraph->setChartBgColor(0,0,0,1);  //as background
	 $mygraph->setXAxis("Mes",1);
	 $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
	 $mygraph->drawGraph();


	 ?>

[As partes desta mensagem que não continham texto foram removidas]

#3617 De: "Guilherme Messias de Oliveira" <guilherme@...>
Data: Sex, 1 de Set de 2006 8:53 pm
Assunto: Re: [OFF TOPIC] CURSO GRATUITO DE PHP EM SÃO PAULO.
pest_g
Enviar e-mail Enviar e-mail
 
Amigos boa tarde.

Gostaria de agradescer a todos pelo apoio.
O curso abrio as inscrições as 13:00hs e antes das 17:00hs já estava inserrada
as matriculas.
   ----- Original Message -----
   From: Guilherme Messias de Oliveira
   To: php-sp@...
   Cc: php-pt@...
   Sent: Friday, August 18, 2006 3:59 PM
   Subject: [php-sp] [OFF TOPIC] CURSO GRATUITO DE PHP EM SÃO PAULO.



     ----- Original Message -----
     From: Guilherme Messias de Oliveira
     To: php-sp@...
     Cc: php-pt@...
     Sent: Friday, August 18, 2006 3:49 PM
     Subject: [OFF TOPIC] CURSO GRATUITO DE PHP EM SÃO PAULO.


     Boa tarde amigos do php.

     Estou convidando a todos a se inscreverem no curso que estarei ministrando
no SESC SANTANA sobre php e MySQL.

     O curso é gratuito e terá inicio no próximo dia 5 são 3 vezes por semana das
19:30 as 21:30.

     O nivel do curso é basico e intermediário.

     Segue a Grade do curso para que possam havaliar se vale a pena participar ou
não.

     Para maiores informações podem ligar diretamente no sesc e se inscrever.
     São pouquissímas vagas o telefone é:  6971.8793.
     Podem falar com o Paulo que é o responsavel pelo curso.


     Pré-requisito


       Conhecimentos intermediários de HTML uso de tabelas e formulários.



       Conceitos básicos.

           Introdução; Características; Scripts; Programação Orientada a objetos;
Requisitos de instalação.



       Tipos de dados e variáveis.

          A estrutura básica do programa PHP; Tipos de dados; Constantes;
Definindo constantes; Constantes predefinidas; Variáveis; Tipos de variáveis;
Variáveis predefinidas; Escopo de variáveis; Variáveis criadas dinamicamente;
Variáveis de ambiente; Interpolação de variáveis; Conversão de tipos; Type
casting; Convertendo valores.





      Operadores.

          Precedência de operadores; Tipos de operadores; Operadores aritméticos;
Operadores binários; Operadores de comparação; Operadores de atribuição;
Operadores lógicos; Operadores ternários.



      Estruturas de controle.

                Comandos de decisão; if, else, elseif; switch; Comandos de
repetição; while;

           do...while; for; foreach; Comandos de controle de fluxo de execução;
break; continue.



      Funções.

          Passagem de parâmetros



      Incluindo arquivos em páginas PHP.

          A instrução include(); A instrução require(); As diferenças entre
include() e require().



      Classes e objetos

             Construtores; Palavras-chave; Métodos abstratos; Interface.



      Manipulação de arquivos.

         Abrindo um arquivo; Lendo um arquivo; Escrevendo um arquivo; Fechando um
arquivo; Funções para manipulação de arquivos.



      Banco de dados PostgreSQL e MySQL.

         Tipos de dados; Criando um banco de dados; Criando e visualizando
tabelas em um banco de dados; Manipulando dados; Inserindo registro no banco de
dados; Consultando o banco de dados; Ordenando registros; Determinando o número
máximo de registros de uma consulta; Alterando o banco de dados; Excluindo
informações do banco de dados.



       Utilizando banco de dados no PHP.

          Conexão; MySQL; Execução de comandos SQL no PHP; MySQL; Funções para

     tratamento de dados; Gerenciamento do banco de dados.



       Trabalhando com formulários HTML.

           Formulário HTML; Recebendo dados do formulário HTML; Método GET;

      Método POST; Manipulando dados do formulário HTML; Funções especiais;

      Comunicação entre páginas; Conferindo campos; Gerenciando banco de dados

      através de formulários.



       Cookies e sessões.

     Utilizando cookies; Sistema de usuário / senha; Utilizando sessões.





      Correio eletrônico.

         O arquivo php.ini; Função mail; O e-mail em formato HTML; Cabeçalhos de
e-mail.



       Controle de ambiente.

           As variáveis de ambiente; Variável REMOTE_ADDR; Função getenv.

   [As partes desta mensagem que não continham texto foram removidas]






[As partes desta mensagem que não continham texto foram removidas]

#3618 De: "Maximiliano" <folken_max@...>
Data: Qui, 31 de Ago de 2006 7:57 pm
Assunto: Re: Expressões regulares - HELP!!!
folken_max
Enviar e-mail Enviar e-mail
 
Ele removeu tudo que está entre <> hehehehehe
   ----- Original Message -----
   From: Miriam Fernandes (Drika®)
   To: php-sp@...
   Sent: Thursday, August 31, 2006 1:43 PM
   Subject: Re: [php-sp] Expressões regulares - HELP!!!


   Nossa Wellington!!!!
   Funcionou que é uma beleza!!!!!!  Show..

   Me explica o que quer dizer a expressão.. please???

   Obrigada pela ajuda.

   Drika
     ----- Original Message -----
     From: Wellington Rodrigues
     To: php-sp@...
     Sent: Thursday, August 31, 2006 11:40 AM
     Subject: Re: [php-sp] Expressões regulares - HELP!!!




     Ol[a

     $linha = preg_replace('/<.*?>/', "", $linha);

     Experimente por favor.




     Miriam Fernandes (Drika®) escreveu:
     > Hey galera.. bom dia!!!
     >
     > Alguém aqui podia me dar uma ajudinha em Expressões Regulares?
     > Eu tenho uma linha de código HTML que contém tags (óbvio! rsss) e dentro
dessas tags eu tenho um número, como abaixo:
     >
     > 20ºC = representação de temperatura
     >
     > Eu preciso extrair dessa linha de HTML apenas essa temperatura... Imaginei
que usando expressões regulares eu conseguiria isso... Alguém pode me dar um
auxilio?
     >
     > Desde já agradeço
     >
     > Drika ;-)
     >
     >
     > PS: A linha html é assim:
     > <div align=center><strong><font face= "Verdana, Arial, Helvetica,
sans-serif" size=2>22°C</font></strong></div>
     >
     > e eu preciso disso apenas:
     >
     > 22°C
     >
     >
     >
     > [As partes desta mensagem que não continham texto foram removidas]
     >
     >
     >
     >
     > Links do Yahoo! Grupos
     >
     >
     >
     >
     >
     >
     >
     >
     >
     >
     >


     --

     //==========================//
     //  Wellington Rodrigues    //
     //==========================//
     //     (11) 8155 2*1*       //
     //==========================//



     _______________________________________________________
     Novidade no Yahoo! Mail: receba alertas de novas mensagens no seu celular.
Registre seu aparelho agora!
     http://br.mobile.yahoo.com/mailalertas/







   [As partes desta mensagem que não continham texto foram removidas]



   __________ Informação do NOD32 IMON 1.1732 (20060830) __________

   Esta mensagem foi verificada pelo NOD32 sistema antivírus
   http://www.eset.com.br


[As partes desta mensagem que não continham texto foram removidas]

#3619 De: "mbtec" <mariobelolli@...>
Data: Sex, 1 de Set de 2006 5:57 pm
Assunto: elemento novo no array
mariobelolli
Enviar e-mail Enviar e-mail
 
Caros amigos e amigas,

Estou tentando popular a segunda combo a partir da primeira,
utilizando javascript e php.

Funciona ok, com os campos codigo_ngp e nome_ngp.

Preciso incluir mais um campo no array principal que
é "codigo_ngp_seq" para a combo principal e mais um
campo "codigo_ngs_seq" para a combo secundaria.

No compo principal ficou ok, mas no combo secundario ele se perde,
confundindo o resultado da sql.

Por favor, quem puder me auxiliar, agradeço.

Segue código:

<SCRIPT LANGUAGE="JavaScript">
team = new Array(
<?
$sql="select * from tab_ng_principal order by nome_ngp";
$sql_result=mysql_query($sql, $conecta);
$num=mysql_num_rows($sql_result);
while ($row=mysql_fetch_array($sql_result)){
$conta=$conta+1;
	 $codigo_ngp=$row["codigo_ngp"];
         $codigo_ngp_seq=$row["codigo_ngp_seq"]; //foi incluído aqui

		 echo "new Array(\n";
		 $sub_sql="select * from tab_ng_secundaria where
codigo_ngp='$codigo_ngp'";
		 $sub_result=mysql_query($sub_sql, $conecta);
		 $num_sub=mysql_num_rows($sub_result);
		 if ($num_sub>=1){

             // preciso incluir aqui o codigo_ngs_sec neste array

			 echo "new Array(\"-\", 0),\n";
			 while ($rowx=mysql_fetch_array($sub_result)){
				 $codigo_ngs=$rowx["codigo_ngs"];
				 $nome_ngs=$rowx["nome_ngs"];
			 $conta_sub=$conta_sub+1;
				 if ($conta_sub==$num_sub){
					 echo "new Array
(\"$nome_ngs\", $codigo_ngs)\n";
					 $conta_sub="";
				 }else{
					 echo "new Array
(\"$nome_ngs\", $codigo_ngs),\n";
				 }
			 }
		 }else{
			 echo "new Array(\"Nenhuma\", 0)\n";
		 }
	 if ($num>$conta){
		 echo "),\n";
	 }
}
echo ")\n";
echo ");\n";
?>

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt,
badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
    }
}
//  End -->
</script>



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Localiza Fornecedores</title>
</head>

<center>

<body>
<form action="mostra_ngs_mascaras.php" method="post" name="locfor"
id="locfor">
<center>
     <table width="74%" border="1" cellspacing="0" cellpadding="3">
       <tr>

		 <td>
		 <center>
             <p> </p>
			 <table width="90%" border="0"
cellspacing="0" cellpadding="3">
               <tr bgcolor="#009966">
                 <td colspan="2"><div align="center"><strong><font
color="#FFFFFF">ALTERAÇÃO
                      NATUREZA  SECUNDÁRIA
</font></strong></div></td>
  				 </tr>
	             <tr>
					 <td colspan="2"> </td>
  				 </tr>
  				 <tr>
	  				 <td width="262"><div
align="right">Projeto:</div></td>
			    	 <td width="455"><div
align="left"><strong>AHE Salto Pilão</strong></div></td>
  				 </tr>
				 <tr>
					 <td width="262"><div
align="right">Natureza Principal:</div></td>
			 <td>
       <select name="codigo_ngp" onChange="fillSelectFromArray
(this.form.codigo_ngs, ((this.selectedIndex == -1) ? null : team
[this.selectedIndex-1]));">
         <option>-</option>
         <?
		   $sql="select * from tab_ng_principal order by
nome_ngp";
		   $sql_result=mysql_query($sql, $conecta);
		   while ($row=mysql_fetch_array($sql_result)){
		   $codigo_ngp=$row["codigo_ngp"];
		   $nome_ngp=$row["nome_ngp"];
                   // foi incluído neste ponto e esta ok.
		   $codigo_ngp_seq=$row["codigo_ngp_seq"];
		   ?>
         <option value="<? echo $codigo_ngp; ?>">
         <? echo $codigo_ngp_seq." - ".$nome_ngp; ?>
         </option>
         <?
		   }
		   ?>
       </select>
			 </td>
  				 </tr>
				 <tr>
					 <td width="262"><div
align="right">Natureza  Secundária :</div></td>
			 <td>
		       <select name="codigo_ngs">
        		 <option>-</option>
		       </select>
	  		 </td>
				 </tr>

				 <tr>
					 <td colspan="2"><div
align="right">
					   <input type="submit"
name="altngs" value="Alterar"></div></td>
		  		 </tr>
			 </table>
			 </center>
		 <p> </p></td>

	 </tr>
</table>
  </center>
</form>


</BODY>
</html>

#3620 De: "Haroldo CentralSys" <haroldo.passos@...>
Data: Sáb, 2 de Set de 2006 12:25 pm
Assunto: Re: baaChart Dúvida
haroldobpassos
Enviar e-mail Enviar e-mail
 
O resultado dessa classe é uma grande imagem, e o Header trata só isso, por
isso da erro se tentar ecoar algo ao browser, mas com uma alteração na
classe, veja a função que mostra o titulo, você pode criar uma função para
exibir outros textos em posições diferentes, a função é imagestring().
Abraços, Haroldo



2006/9/1, Sergio de Andrade <sergio.ophus@...>:
>
>  Com certeza Aroldo..
> A classe é o arquivo baaChart.php
> O PHP que passa os parametros é o geraGrafico.php.
>
>
>
> muito obrigado pela atenção.
>
>
>
> 2006/9/1, Haroldo CentralSys <haroldo.passos@...>:
>
> >
> > Voce pode enviar a classe para avaliar?
> >
> > Haroldo
> >
> >
> >
> > 2006/8/31, Sergio de Andrade <sergio.ophus@...>:
> >
> > >
> > >  Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> > > trocando informações.
> > >
> > > Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> > > classe baaChart
> > > para gerar gráficos estatísticos.
> > > Para utilizar a a classe estou usando algo do tipo:
> > >
> > >
> > >
> >
>
#-------------------------------------------------------------------------------\
--
> > >
> > > include('baaChart.php');
> > >     $mygraph = new baaChart(600);
> > >     $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
> > >     $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
> > >
> > >
> >
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
> > >     $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
> > >     $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
> > >     $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
> > >     $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
> > >     $mygraph->setBgColor(0,0,0,1);  //transparent background
> > >     $mygraph->setChartBgColor(0,0,0,1);  //as background
> > >     $mygraph->setXAxis("Mes",1);
> > >     $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
> > >     $mygraph->drawGraph();
> > >
> > >
> > >
> >
> #-----------------------------------------------------------------------------
> > >
> > > Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> > > deste
> > > bloco de chamadas, como por exemplo(um simples: print "teste";) o
> código
> > > não
> > > funciona.
> > > Alguem poderia me dar uma luz !?
> > >
> > >
> > >
> > > atenciosamente
> > > --
> > > Sergio de Andrade Lopes
> > > (11) 3244-3580
> > > (11) 8168-5560
> > > TI - Microinformática
> > > Associação Comercial São Paulo
> > >
> > >
> > > [As partes desta mensagem que não continham texto foram removidas]
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
>
>
>
> --
> Sergio de Andrade Lopes
> (11) 3244-3580
> (11) 8168-5560
> TI - Microinformática
> Associação Comercial São Paulo
>
>   ----------
>
> <?php
> /***********************************************************
> * Class:        baaChart
> * Version:      1.4
> * Date:         Aug 2006
> * Author:       Barry Andrew
> * Copyright:    (c) BA Andrew 2003
> *               http://members.aol.com/barryaandrew/baaLic.html
> ***********************************************************
> USAGE SAMPLE
>
>
>     include('baaChart.php');
>     $mygraph = new baaChart(600);
>     $mygraph->setTitle('Regional Sales','Jan - Jun 2002');
>
> $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec");
>     $mygraph->setXAxis("Month",0);
>     $mygraph->setYAxis ('Regional Sales', 0, 100, 20, 0);
>     $mygraph->addDataSeries('L',LINE_MARK_X,"25,30,35,40,30,35","South");
>
> $mygraph->addDataSeries('L',LINE_MARK_CIRCLE,"65,70,80,90,75,48","North");
>
> $mygraph->addDataSeries('L',LINE_MARK_SQUARE,"12,18,25,20,22,30","West");
>     $mygraph->addDataSeries('L',LINE_MARK_DIAMOND
> ,"50,60,75,80,60,75","East");
>
> $mygraph->addDataSeries('L',LINE_MARK_NONE,"30,45,50,55,52,60","Europe");
>     $mygraph->setBgColor(255,255,255,0);
>     $mygraph->drawGraph();
>
> */
>     /********************************************************
>     *                      defines                          *
>     ********************************************************/
>     define ('VERSION', 'baaChart 1.4');
>
>     define ('PIE_NONE',0);
>     define ('PIE_LEGEND_PCENT',1);
>     define ('PIE_LEGEND_VALUE',2);
>     define ('PIE_CHART_VALUE',4);
>     define ('PIE_CHART_PCENT',8);
>     define ('LINE_MARK_NONE',0);
>     define ('LINE_MARK_PLUS',1);
>     define ('LINE_MARK_X',2);
>     define ('LINE_MARK_CIRCLE',3);
>     define ('LINE_MARK_SQUARE',4);
>     define ('LINE_MARK_DIAMOND',5);
>     define ('COLS_NO_STACK',0);
>     define ('COLS_STACKED',1);
>
> class baaChart  {
>
>     /********************************************************
>     *                      Variables                        *
>     ********************************************************/
>     var $image;
>     var $title;
>     var $subtitle;
>     var $bgd;
>     var $cbgd,$cbgd2;            // chart band colours
>     var $txtcol;
>     var $white;
>     var $black;
>     var $gridcol;
>     var $width;
>     var $height;
>     var $cwidth,$cheight;        // chart dimensions
>     var $scolors;
>     var $lm,$rm,$tm,$bm;        // margins
>     var $ytitle;                // y axis settings
>     var $ymin = 0;
>     var $ymax = 0;
>     var $ygrid = false;
>     var $ygridint;
>     var $xtitle;                // x axis settings
>     var $xgrid = false;
>     var $xgridint;
>     var $xcount;                // count of values in each series
>     var $seriescount;
>     var $colwidth;
>     var $transparent;
>     var $ispiechart;
>
>     var $legends;
>     var $stackcount;
>     var $xlabels;
>     var $data;
>     var $xmaxima;                // series max values
>     var $xminima;
>     var $stypes;                // series types
>     var $stacked;                // series stacked?
>     var $stackbase;
>     var $pic;
>     var $clip;
>     var $picx;
>     var $picy;
>     var $picw;
>     var $pich;
>     var $pict;
>     var $pictrans;
>     var $bgimage;
>     var $bgx;
>     var $bgy;
>     var $showvals;
>     /********************************************************
>     *                   public methods                      *
>     ********************************************************/
>     function baaChart ($awidth, $aheight=0, $pic='', $clip=0, $picx=0,
> $picy=0) {
>         $this->width = $awidth;
>         $this->height = $aheight==0 ? floor($awidth / 1.616) : $aheight;
>         $this->pic = $pic;
>         $this->clip = $clip;
>         $this->picx = $picx;
>         $this->picy = $picy;
>         $this->picw = 0;
>         $this->pich = 0;
>         $this->pict = 0;
>         $this->pictrans = 100;
>         if ($pic != '') {
>             $size = getimagesize($pic);
>             if ($size == null) {
>                 $this->pic = '';
>             }
>             else {
>                   list($this->picw, $this->pich, $this->pict) = $size;
>             }
>         }
>         $this->image = imagecreate($this->width, $this->height);
>         $this->bgd = imagecolorallocate($this->image,0xFF,0xFF,0xFF);
>         $this->white = imagecolorallocate($this->image,0xFF,0xFF,0xFF);
>         $this->cbgd = imagecolorallocate($this->image,0xEE,0xEE,0xEE);
>         $this->cbgd2 = imagecolorallocate($this->image,0xDD,0xDD,0xDD);
>         $this->txtcol = imagecolorallocate($this->image,0,0,0);
>         $this->black = imagecolorallocate($this->image,0,0,0);
>         $this->gridcol = imagecolorallocate($this->image,0x66,0x66,0x66);
>         $this->scolors = array (
>             0 => imagecolorallocate ($this->image,0xFF,0x66,0x66),
>             1 => imagecolorallocate ($this->image,0x66,0x66,0xCC),
>             2 => imagecolorallocate ($this->image,0x66,0xcc,0x66),
>             3 => imagecolorallocate ($this->image,0x99,0x00,0x99),
>             4 => imagecolorallocate ($this->image,0xFF,0xCC,0x00)
>         );
>         $this->tm = 50;
>         $this->bm = 50;
>         $this->lm = 80;
>         $this->rm = 20;
>         $this->cwidth = $this->width - ($this->lm + $this->rm);
>         $this->cheight = $this->height - ($this->tm + $this->bm);
>         $this->seriescount = 0;
>         $this->xcount = 0;
>         $this->legends = array();
>         $this->stackcount = array();
>         $this->xlabels = array();
>         $this->data = array();
>         $this->xmaxima = array();                // series max values
>         $this->xminima = array();
>         $this->stypes = array();                // series types
>         $this->stacked = array();                // series stacked?
>         $this->stackbase = array();
>         $this->showvals = array();
>     }
>     function setMargins ($l=0, $t=0, $r=0, $b=0) {
>         if ($t>0) $this->tm = $t;
>         if ($b>0) $this->bm = $b;
>         if ($l>0) $this->lm = $l;
>         if ($r>0) $this->rm = $r;
>     }
>     function setBgColor ($r, $g, $b, $trans=false) {
>         $this->bgd = imagecolorallocate($this->image,$r,$g,$b);
>         if ($this->pic != '') $trans = 1;
>         if ($trans==1)
>             imagecolortransparent($this->image,$this->bgd);
>         $this->transparent = $trans;
>     }
>     function setChartBgColor ($r, $g, $b, $asbg=0) {
>         if ($this->pic != '') $asbg = 1;
>         $this->cbgd = $asbg ? $this->bgd :
> imagecolorallocate($this->image,$r,$g,$b);
>         $this->cbgd2 = $this->cbgd;
>     }
>     function setChartBgColor2 ($r, $g, $b) {
>         $this->cbgd2 = imagecolorallocate($this->image,$r,$g,$b);
>     }
>     function setTextColor ($r, $g, $b) {
>         $this->txtcol = imagecolorallocate($this->image,$r,$g,$b);
>     }
>     function setGridColor ($r, $g, $b) {
>         $this->gridcol = imagecolorallocate($this->image,$r,$g,$b);
>     }
>     function setSeriesColor ($n, $r, $g, $b) {
>         if ($n<1) $n=1;
>         $this->scolors[$n-1] = imagecolorallocate($this->image,$r,$g,$b);
>     }
>     function setTitle ($aTitle,$aSub='') {
>         if ($aTitle) $this->title = $aTitle;
>         if ($aSub) $this->subtitle = $aSub;
>     }
>     function setYAxis($title='',$min=0,$max=0,$gridint=0,$grid=0) {
>         $this->ytitle = $title;
>         $this->ymin = $min;
>         $this->ymax = $max;
>         $this->ygrid = $grid;
>         $this->ygridint = $gridint < 2 ? 10 : $gridint;
>     }
>     function setXAxis ($title, $grid=0) {
>         $this->xtitle = $title;
>         $this->xgrid = $grid;
>     }
>     function setXLabels ($labs) {
>         $this->xlabels = is_array($labs) ? $labs : explode(",",$labs);
>         $this->xcount = count($this->xlabels);
>     }
>     function addDataSeries ($type,$stacked,$vals,$legend) {
>         $n = $this->seriescount++;
>         $this->stypes[$n] = $type;
>         $this->stacked[$n] = $stacked;
>         $d = is_array($vals) ? $vals : explode(",",$vals);
>         $this->xmaxima[$n] = max($d);
>         $this->xminima[$n] = min($d);
>         $dc = count($d);
>         if ($this->xcount < $dc) {
>             for ($i=$this->xcount,$L = 'A'; $i < $dc; $i++, $L++)
>                 $this->xlabels[$i] = $L;
>             $this->xcount = $dc;
>         }
>         if ($dc < $this->xcount) array_pad($d,$this->xcount,0);
>         $this->data[$n] = $d;
>         $this->legends[$n] = $legend=='' ? '_' : $legend;
>         $this->showvals[$n] = 0;
>     }
>     function setBgImagePos($x, $y) {
>              $this->bgx = $x;
>              $this->bgy = $y;
>     }
>     function setBgImageAlpha($val) {
>              $this->pictrans = $val;
>     }
>     function showValues($series) {
>              $this->showvals[$series] = 1;
>     }
>     function drawGraph($filename='') {
>         header("Content-Type: image/png");
>         $this->_draw();
>         if ($filename!='') imagepng( $this->image, $filename );
>         imagepng( $this->image );
>         imagedestroy( $this->image );
>         if ($this->bgimage) imagedestroy( $this->bgimage );
>         exit();
>     }
>     function display($filename='') {
>              $this->drawGraph($filename);
>     }
>
>     /********************************************************
>     *                   private methods                     *
>     ********************************************************/
>     function _draw() {
>         $a = array_keys($this->stypes,'P');
>         $this->ispiechart = count($a)>0;
>         $this->_calcrmargin();
>
>
imagefilledrectangle($this->image,0,0,$this->width-1,$this->height-1,$this->bgd)\
;
>
>         if ($this->pic != '') $this->_backgroundImage();
>         if ($this->pic == '') {
>             if (!$this->transparent)
>
> imagerectangle($this->image,0,0,$this->width-1,$this->height-1,$this->txtcol);
>
>             imagefilledrectangle($this->image, $this->lm, $this->tm,
> $this->width-$this->rm, $this->height-$this->bm, $this->cbgd);
>         }
>         $this->stackcount=0;
>         for ($s=0; $s<$this->seriescount; $s++) {
>             if (($this->stypes[$s] == 'C') && ($this->stacked[$s]==1))
> $this->stackcount++;
>         }
>         imagestring($this->image, 1,
> 2,$this->height-10,VERSION,$this->txtcol);
>         $this->_drawtitles();
>         $this->_drawaxes();
>         $this->_drawlegends();
>         $this->stackbase = array_pad($this->stackbase,$this->xcount,0);
>         for ($i=0; $i<$this->seriescount; $i++) $this->_plotSeries($i);
>     }
>
>     function _drawpieval($i,$alpha,$x,$y,$r) {
>         $pietot = 0;
>         for ($s=0; $s<$this->seriescount; $s++) {
>             if ($this->stypes[$s]=='P') $pietot +=
> array_sum($this->data[$s]);
>         }
>         $val = array_sum($this->data[$i]);
>         $pc = sprintf('%0.1f%%',$val * 100 / $pietot);
>         $tx = $x + $r*0.75 * cos(deg2rad($alpha));
>         $ty = $y + $r*0.75 * sin(deg2rad($alpha));
>         $fw = imagefontwidth(2);
>         switch (($this->stacked[$i]>>2) & 0x3) {
>         case 1: //plot value
>             $tw = strlen($val)*$fw;
>             $tx -= $tw/2;
>             imagefilledrectangle($this->image,$tx-2,$ty-6,$tx + $tw +
> 2,$ty+6,$this->white);
>             imagestring($this->image,2,$tx,$ty-5,$val,$this->txtcol);
>             break;
>         case 2: // plot %
>         case 3:
>             $tw = strlen($pc)*$fw;
>             $tx -= $tw/2;
>             imagefilledrectangle($this->image,$tx-2,$ty-6,$tx + $tw +
> 2,$ty+6,$this->white);
>             imagestring($this->image,2,$tx,$ty-5,$pc,$this->txtcol);
>             break;
>         }
>     }
>
>     function pielegends() {
>         $pietot = 0;
>         for ($s=0; $s<$this->seriescount; $s++) {
>             if ($this->stypes[$s]=='P') $pietot +=
> array_sum($this->data[$s]);
>         }
>         $a = array_keys($this->stypes,'P');
>         $maxt = $maxv = 0;
>         foreach ($a as $pie) {
>             $val = array_sum($this->data[$pie]);
>             $maxv = max($maxv, strlen($val));
>             $txt = $this->legends[$pie];
>             $maxt = max($maxt, strlen($txt));
>         }
>         foreach ($a as $pie) {
>             $val = array_sum($this->data[$pie]);
>             $pc = $val * 100 / $pietot;
>             switch ($this->stacked[$pie] & 0x03) {
>             case 1 : $this->legends[$pie] = sprintf("%-{$maxt}s
> %4.1f%%",$this->legends[$pie],$pc); break;
>             case 2 : $this->legends[$pie] = sprintf("%-{$maxt}s
> %{$maxv}s",$this->legends[$pie],$val); break;
>             case 3 : $this->legends[$pie] = sprintf("%-{$maxt}s %{$maxv}s
> %4.1f%%",$this->legends[$pie],$val,$pc); break;
>             }
>         }
>     }
>
>     function _calcrmargin() {
>         if ($this->ispiechart) {
>             $this->pielegends();
>         }
>         $leglen = array();
>         foreach($this->legends as $leg) {
>             $leglen[] = strlen($leg);
>         }
>         $maxleglen = max($leglen);
>         if ($maxleglen==0) return;
>         $legwid = $maxleglen * imagefontwidth(2) + 30;
>         $this->rm = max($this->rm, $legwid);
>         $this->cwidth = $this->width - $this->lm - $this->rm;
>         $this->xgridint = ($this->cwidth / $this->xcount);
>         $maxlabwid = $this->_maxlab();
>         if ($maxlabwid > $this->xgridint) {
>             $this->bm = max($this->bm,$maxlabwid+40);
>             $this->cheight = $this->height - $this->tm - $this->bm;
>         }
>     }
>
>     function _drawlegends() {
>         $legx = $this->lm + $this->cwidth + 5;
>         $legy = $this->tm;
>         if ($this->stackcount>0) {
>             $this->legends = array_reverse($this->legends,true);
>         }
>         foreach ($this->legends as $k=>$leg) {
>             if ($leg != '_') {
>                 switch ($this->stypes[$k]) {
>                 case 'C':
>                     if ($this->ispiechart) break;
>                 case 'P':
>
>
imagefilledrectangle($this->image,$legx,$legy,$legx+15,$legy+15,$this->scolors[$\
k]);
>
>
> imagerectangle($this->image,$legx,$legy,$legx+15,$legy+15,$this->black);
>
> imagestring($this->image,2,$legx+20,$legy+1,$leg,$this->txtcol);
>                     break;
>                 case 'L':
>                     if ($this->ispiechart) break;
>                     if ($this->stacked[$k]>=0) {
>
> imageline($this->image,$legx,$legy+7,$legx+15,$legy+7,$this->scolors[$k]);
>
> imageline($this->image,$legx,$legy+8,$legx+15,$legy+8,$this->scolors[$k]);
>
> imageline($this->image,$legx,$legy+9,$legx+15,$legy+9,$this->scolors[$k]);
>                     }
>                     $this->_drawmarker($legx+8,$legy+8,$this->stacked[$k],
> $this->scolors[$k]);
>
> imagestring($this->image,2,$legx+20,$legy+1,$leg,$this->txtcol);
>                 }
>                 $legy += 20;
>             }
>         }
>     }
>
>     function _val2y($v, $base=0) {
>         $rv = $v + $base - $this->ymin;
>         $ppu = $this->cheight/($this->ymax - $this->ymin);
>         return $this->tm + $this->cheight - ($rv * $ppu) ;
>     }
>
>     function _drawmarker($x,$y,$m, $c) {
>         $fill = $m < 0 ? $c : $this->white;
>         $line = $m < 0 ? $c : $this->black;
>         switch (abs($m)) {
>         case 1:
>             $x0 = $x-3; $x1 = $x+3;
> imageline($this->image,$x0,$y,$x1,$y,$line);
>             $y0 = $y-3; $y1 = $y+3;
> imageline($this->image,$x,$y0,$x,$y1,$line);
>             break;
>         case 2:
>             $x0 = $x-3; $x1 = $x+3;
>             $y0 = $y-3; $y1 = $y+3;
>             imageline($this->image,$x0,$y0,$x1,$y1,$line);
>             imageline($this->image,$x1,$y0,$x0,$y1,$line);
>             break;
>         case 3:
>             $w = $h = 8;
>             imagearc($this->image,$x,$y,$w,$h,0,361,$this->black);
>             imagefill($this->image,$x,$y,$fill);
>             break;
>         case 4:
>             $x0 = $x-3; $x1 = $x+3;
>             $y0 = $y-3; $y1 = $y+3;
>             imagefilledrectangle($this->image,$x0,$y0,$x1,$y1,$fill);
>             imagerectangle($this->image,$x0,$y0,$x1,$y1,$this->black);
>             break;
>         case 5:
>             $p[] = $x; $p[] = $y-4; $p[] = $x+4; $p[] = $y;
>             $p[] = $x; $p[] = $y+4; $p[] = $x-4; $p[] = $y;
>             imagefilledpolygon($this->image,$p,4,$fill);
>             imagepolygon($this->image,$p,4,$this->black);
>         }
>     }
>
>     function _plotseries($i) {
>         $valposArray = array();
>         switch ($this->stypes[$i]) {
>         case 'L':
>             if ($this->ispiechart) break;
>             $this->colwidth = $this->xgridint - 4;
>             for ($p=0; $p<$this->xcount; $p++) {
>                 $pts[$p][0] = $this->lm + $p * $this->xgridint +
> $this->xgridint/2;
>                 $pts[$p][1] = $this->_val2y($this->data[$i][$p]);
>                 $valposArray[$i][$p] = array($pts[$p][0], $pts[$p][1],
> $pts[$p][1]);
>             }
>             for ($p=1; $p<$this->xcount; $p++) {
>                 if (!isset($this->data[$i][$p])) continue;
>                 if ($this->stacked[$i]<0) continue;
>
>
imageline($this->image,$pts[$p-1][0],$pts[$p-1][1],$pts[$p][0],$pts[$p][1],$this\
->scolors[$i]);
>
>
>
imageline($this->image,$pts[$p-1][0],$pts[$p-1][1]-1,$pts[$p][0],$pts[$p][1]-1,$\
this->scolors[$i]);
>
>
>
imageline($this->image,$pts[$p-1][0],$pts[$p-1][1]+1,$pts[$p][0],$pts[$p][1]+1,$\
this->scolors[$i]);
>
>             }
>             if ($this->stacked[$i]!=0) {
>                 for ($p=0; $p<$this->xcount; $p++) {
>                     if (!isset($this->data[$i][$p])) continue;
>
> $this->_drawmarker($pts[$p][0],$pts[$p][1],$this->stacked[$i],
> $this->scolors[$i]);
>                 }
>             }
>             $this->_drawVals($valposArray);
>             break;
>         case 'C':
>             if ($this->ispiechart) break;
>             $stacked = $this->stackcount>0;
>             $b = array_keys($this->stypes,'C');
>             $colpos = 0;
>             if (!$stacked){
>                 while (list($k,$v)=each($b)) {
>                     if ($v==$i) break;
>                     $colpos++;
>                 }
>             }
>             for ($p=0; $p<$this->xcount; $p++) {
>
>                 $x0 = $this->lm + 5 + $p * $this->xgridint + $colpos *
> $this->colwidth;
>                 $x1 = $x0 + $this->colwidth;
>                 $y0 =
> $this->_val2y($this->data[$i][$p],$this->stackbase[$p]);
>                 $y1 =
> $this->_val2y($this->stackbase[$p],(0>$this->ymin)?(0):($this->ymin));
>                 if ($stacked) $this->stackbase[$p] += $this->data[$i][$p];
>
>                 if(0 > $this->data[$i][$p])
>                 {
>                         $t = $y0;
>                         $y0 = $y1;
>                         $y1 = $t;
>                 }
>                 $valposArray[$i][$p] = array($x0+($x1-$x0)/2, $y0, $y1);
>
> imagefilledrectangle($this->image,$x0,$y0,$x1,$y1,$this->scolors[$i]);
>                 imagerectangle($this->image,$x0,$y0,$x1,$y1,$this->black);
>
>             }
>             if (!$stacked) $this->_drawVals($valposArray);
>             break;
>         case 'P':
>             $x = ($this->lm + $this->cwidth + $this->lm)/2;
>             $y = ($this->tm + $this->cheight + $this->tm)/2;
>             $w = $h = min($this->cwidth, $this->cheight) - 10;
>             $pietot = 0;
>             for ($s=0; $s<$this->seriescount; $s++) {
>                 if ($this->stypes[$s]=='P') $pietot +=
> array_sum($this->data[$s]);
>             }
>             $alpha = $this->stackbase[0];
>             $theta = array_sum($this->data[$i])*360 / $pietot;
>
>
imagefilledarc($this->image,$x,$y,$w,$h,$alpha,$alpha+$theta,$this->scolors[$i],\
IMG_ARC_PIE);
>
>             $this->_drawpieval($i,$alpha+$theta/2,$x,$y,$w/2);
>             $this->stackbase[0] += $theta;
>         }
>     }
>
>     function _drawVals($posArray) {
>              $marray = array();
>              foreach ($this->data as $i => $parray) {
>                       foreach ($parray as $v) {
>                                $marray[] = strlen($v) * imagefontwidth(1);
>
>                       }
>              }
>              $maxwidth = max($marray);
>              $rotate = 0;
>              if ($this->stypes[$i]=='C') {
>                  $rotate = $maxwidth > $this->colwidth-4 ? 1 : 0;
>              }
>              if ($rotate && (imagefontheight(2) > $this->colwidth-4) )
>                  return; // insufficient space
>
>              foreach ($this->data as $i => $parray) {
>                       if (!$this->showvals[$i+1]) continue;
>                       foreach ($parray as $p => $v) {
>                                $boxwidth = strlen($v) * imagefontwidth(2)
> + 2;
>                                $boxheight = imagefontheight(2);
>                                $posdata = $posArray[$i][$p];
>                                $posx = $posdata[0];
>                                $posy = $posdata[1]-5;
>                                $posy1 = $posdata[2]-5;
>                                switch ($rotate) {
>                                case 0:
>                                     $x0 = $posx - ($boxwidth / 2);
>                                     $x1 = $posx + ($boxwidth / 2);
>                                     $y0 = $posy - $boxheight;
>                                     $y1 = $posy;
>                                     imagefilledrectangle($this->image,
> $x0, $y0, $x1, $y1, $this->white);
>                                     imagerectangle($this->image, $x0, $y0,
> $x1, $y1, $this->black);
>                                     imagestring($this->image, 2, $x0+2,
> $y0, $v, $this->black);
>                                     break;
>
>                                case 1:
>                                     $x0 = $posx - ($boxheight / 2);
>                                     $x1 = $posx + ($boxheight / 2);
>                                     $y1 = $v < 0 ? $posy : $posy1;
>                                     $y0 = $y1 - $boxwidth;
>                                     imagefilledrectangle($this->image,
> $x0, $y0, $x1, $y1, $this->white);
>                                     imagerectangle($this->image, $x0, $y0,
> $x1, $y1, $this->black);
>                                     imagestringup($this->image, 2, $x0+2,
> $y1-2, $v, $this->black);
>                                     break;
>
>                                }
>                       }
>              }
>
>     }
>
>     function _drawtitles() {
>         $cw = imagefontwidth(5);
>         $l = strlen($this->title);
>         $tw = $cw*$l;
>         $x = $this->lm + ($this->cwidth - $tw)/2;
>         imagestring ($this->image,5,$x, 5, $this->title, $this->txtcol);
>         $cw = imagefontwidth(4);
>         $l = strlen($this->subtitle);
>         $tw = $cw*$l;
>         $x = $this->lm + ($this->cwidth - $tw)/2;
>         imagestring ($this->image,4,$x, 25, $this->subtitle,
> $this->txtcol);
>
>     }
>
>     function _drawaxes() {
>         if ($this->ispiechart) return;
>         $changed = 0;
>         $ym = $this->_calcymax();
>         if (isset($this->ygridint)) {
>             if ($this->ygridint < 2)
>                 $this->ygridint = ($this->ymax - $this->ymin)/4;
>         }
>         else $this->ygridint = ($this->ymax - $this->ymin)/4;
>
>         $i =  $this->ygridint;
>
>         if ($this->ymax < $ym ) {
>             $this->ymax = floor(($ym + $i)/$i) * $i;
>             $changed = 1;
>         }
>         $yn = min($this->xminima);
>         if ($this->ymin > $yn) {
>             $this->ymin = floor(($yn - $i)/$i) * $i;
>             $changed = 1;
>         }
>
>         $this->_drawyaxis();
>         $this->_drawxaxis();
>     }
>
>     function _drawyaxis() {
>         $x0 = $this->lm;
>         $y0 = $this->tm + $this->cheight;
>         $x1 = $x0;
>         $y1 = $this->tm;
>         $div = $this->ygridint * $this->cheight / ($this->ymax -
> $this->ymin);
>         $grx = $this->ygrid ? $this->lm + $this->cwidth : $this->lm-3;
>         for ($y = $y1,$v=$this->ymax,$i=0; $y < $y0-2; $y += $div, $v -=
> $this->ygridint, $i++) {
>             if ($this->cbgd != $this->cbgd2) {
>                 $col = ($i%2) ? $this->cbgd : $this->cbgd2;
>                 imagefilledrectangle($this->image,$x0,$y,$this->lm +
> $this->cwidth,$y+$div,$col);
>             }
>             imageline($this->image,$x0,$y,$grx,$y,$this->gridcol);
>             $tw = strlen("$v")*imagefontwidth(2);
>             imagestring($this->image,2,$x0 - $tw  - 5, $y - 5, $v,
> $this->txtcol);
>         }
>         $tw = strlen("$this->ymin")*imagefontwidth(2);
>         $y = $this->tm + $this->cheight;
>         imagestring($this->image,2,$x0 - $tw  - 5, $y - 6, $this->ymin,
> $this->txtcol);
>         imageline($this->image,$x0,$y0,$x1,$y1,$this->gridcol);
>         $tw = strlen($this->ytitle) * imagefontwidth(3);
>         $y = ($this->tm + $this->height - $this->bm + $tw)/2;
>         $x = 10;
>         imagestringup($this->image,3,$x,$y,$this->ytitle,$this->txtcol);
>     }
>
>     function _maxlab() {
>         $max = 0;
>         for ($i=0; $i < $this->xcount; $i++) {
>             $v = $this->xlabels[$i];
>             $tw = strlen("$v")*imagefontwidth(2);
>             $max = max ($max, $tw);
>         }
>         return $max;
>     }
>
>     function _drawxaxis() {
>         $maxlabwid = $this->_maxlab();
>         $x0 = $this->lm;
>         $y0 = $this->tm + $this->cheight;
>         $x1 = $x0 + $this->cwidth;
>         $y1 = $y0;
>         $div = $this->xgridint;
>         imageline($this->image,$x0,$y0,$x1,$y1,$this->gridcol);
>         $gry = $this->xgrid ? $this->tm : $this->tm + $this->cheight + 3 ;
>
>         for ($x=$x1,$i=$this->xcount-1; $x>$x0+3; $x -= $div, $i--) {
>             imageline($this->image,$x,$gry,$x,$y0,$this->gridcol);
>             $v = $this->xlabels[$i];
>             $tw = strlen("$v")*imagefontwidth(2);
>             $th = imagefontheight(2);
>             if ($maxlabwid < $div) {
>                 imagestring($this->image,2,$x - ($div+$tw)/2, $y0 + 5, $v,
> $this->txtcol);
>             }
>             else {
>                 imagestringup($this->image,2,$x - ($div+$th)/2, $y0 + 5 +
> $tw, $v, $this->txtcol);
>             }
>         }
>         $y = $this->height - 30;
>         $tw = strlen($this->xtitle)*imagefontwidth(3);
>         $x = ($this->lm + $this->cwidth + $this->lm - $tw)/2;
>         imagestring($this->image,3,$x,$y,$this->xtitle,$this->txtcol);
>     }
>
>     function _calcymax() {
>
>         $b = array_keys($this->stypes,'C');
>         if ($this->stackcount == 0) {
>             $m = max($this->xmaxima);
>             if (count($b) > 0)
>                 $this->colwidth = ($this->xgridint - 10)/count($b);
>             else
>                 $this->colwidth = 0;
>         }
>         else {
>             $m=0;
>             $stacktots = array();
>             foreach ($b as $v) {
>                 #$m += $this->xmaxima[$v];
>                 for ($i=0; $i<$this->xcount; $i++) {
>                       $stacktots[$i] += $this->data[$v][$i];
>                 }
>                 $this->stacked[$v] = 1;
>             }
>             $m = max (max($this->xmaxima),max($stacktots));
>             $this->colwidth = ($this->xgridint - 10);
>         }
>         return $m;
>     }
>
>     function _backgroundImage() {
>
>         switch ($this->pict) {
>             case 1: $this->bgimage = imagecreatefromgif($this->pic);
> break;
>             case 2: $this->bgimage = imagecreatefromjpeg($this->pic);
> break;
>             case 3: $this->bgimage = imagecreatefrompng($this->pic);
> break;
>             default : $this->pic = ''; return;
>         }
>
>         switch ($this->clip) {
>         case 0:
>              if ($this->pictrans == 100) {
>              imagecopyresampled($this->image, $this->bgimage, 0,0,0,0,
> $this->width,$this->height,$this->picw, $this->pich);
>              }
>              else {
>              $itmp = imagecreatetruecolor($this->width,$this->height);
>              imagecopyresampled($itmp, $this->bgimage, 0,0,0,0,
> $this->width,$this->height,$this->picw, $this->pich);
>             imagecopymerge ($this->image, $itmp, 0, 0, 0,
> 0,$this->width,$this->height, $this->pictrans );
>             imagedestroy($itmp);
>              }
>              break;
>         case 1:
>             if (is_null($this->bgx) || is_null($this->bgy)) {
>                 $dx = $this->width > $this->picw ? ($this->width -
> $this->picw)/2 : 0;
>                 $dy = $this->height > $this->pich ? ($this->height -
> $this->pich)/2 : 0;
>             }
>             else {
>                 $dx = $this->bgx;
>                 $dy = $this->bgy;
>             }
>             $px = min($this->width, $this->picw);
>             $py = min($this->height, $this->pich);
>             imagecopymerge ($this->image, $this->bgimage, $dx, $dy,
> $this->picx, $this->picy,$px,$py, $this->pictrans );
>             break;
>         case 2:
>             $px = min($this->width, $this->picw);
>             $py = min($this->height, $this->pich);
>             for ($dx=0; $dx  < $this->width; $dx += $this->picw) {
>                 for ($dy=0; $dy  < $this->height; $dy += $this->pich) {
>                      imagecopymerge ($this->image, $this->bgimage, $dx,
> $dy, $this->picx, $this->picy,$px,$py, $this->pictrans );
>                 }
>             }
>             break;
>         }
>     }
> }
>
> ?>
>   ----------
>
> <?php
>
>
#===============================================================================\
======
>
> #= Script  : Sistema de Graficos
> #= Arquivo : graficoColunas.php
> #= Versão  : 1.0
> #= Autor   : Sergio de Andrade
> #= Email   : sergio@...
> #= Website : ufac.acsp.com.br
>
#===============================================================================\
======
>
>
>
>   /*
>     # Pizza
>
>     include('baaChart.php');
>       $mygraph = new baaChart(600);
>       $mygraph->setTitle('São Paulo','Jan - Jun 2002');
>       $mygraph->addDataSeries('P',PIE_CHART_PCENT +
> PIE_LEGEND_VALUE,"25,30,35,40,30,35","South");
>       $mygraph->addDataSeries('P',PIE_CHART_PCENT +
> PIE_LEGEND_VALUE,"65,70,80,90,75,48","North");
>       $mygraph->addDataSeries('P',PIE_CHART_PCENT +
> PIE_LEGEND_VALUE,"12,18,25,20,22,30","West");
>       $mygraph->addDataSeries('P',PIE_CHART_PCENT +
> PIE_LEGEND_VALUE,"50,60,75,80,60,75","East");
>       $mygraph->addDataSeries('P',PIE_CHART_PCENT +
> PIE_LEGEND_VALUE,"30,45,50,55,52,60","Europe");
>       $mygraph->drawGraph();
>
>     # LINHAS NA HORIZONTAL
>
>
>       include('baaChart.php');
>       $mygraph = new baaChart(600);
>       $mygraph->setTitle('Regional Sales','Jan - Jun 2002');
>
>       $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
>
> $mygraph->addDataSeries('L',LINE_MARK_X,"25,30,35,40,30,35","South");
>
> $mygraph->addDataSeries('L',LINE_MARK_CIRCLE,"65,70,80,90,75,48","North");
>
> $mygraph->addDataSeries('L',LINE_MARK_SQUARE,"12,18,25,20,22,30","West");
>
> $mygraph->addDataSeries('L',LINE_MARK_DIAMOND,"50,60,75,80,60,75","East");
>
> $mygraph->addDataSeries('L',LINE_MARK_NONE,"30,45,50,55,52,60","Europe");
>       $mygraph->setBgColor(255,255,255,1); //Transparent
>       $mygraph->setXAxis("Month",1);
>       $mygraph->setYAxis("Sales (£000)",0,100,10,0);
>       $mygraph->drawGraph();
> */
>       # COLUNAS
>
>       include('baaChart.php');
>       $mygraph = new baaChart(600);
>       $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
>       $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
>
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
>       $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
>       $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
>       $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
>       $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
>       $mygraph->setBgColor(0,0,0,1);  //transparent background
>       $mygraph->setChartBgColor(0,0,0,1);  //as background
>       $mygraph->setXAxis("Mes",1);
>       $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
>       $mygraph->drawGraph();
>
>
>       ?>
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>


[As partes desta mensagem que não continham texto foram removidas]

#3621 De: "Haroldo CentralSys" <haroldo.passos@...>
Data: Sáb, 2 de Set de 2006 12:39 pm
Assunto: Re: baaChart Dúvida
haroldobpassos
Enviar e-mail Enviar e-mail
 
Sergio, copie o código e tentei rodar sem o print ("teste") e deu o erro.

Haroldo



2006/8/31, Sergio de Andrade <sergio.ophus@...>:
>
>  Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> trocando informações.
>
> Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> classe baaChart
> para gerar gráficos estatísticos.
> Para utilizar a a classe estou usando algo do tipo:
>
>
>
#-------------------------------------------------------------------------------\
--
>
> include('baaChart.php');
>     $mygraph = new baaChart(600);
>     $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
>     $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
>
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
>     $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
>     $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
>     $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
>     $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
>     $mygraph->setBgColor(0,0,0,1);  //transparent background
>     $mygraph->setChartBgColor(0,0,0,1);  //as background
>     $mygraph->setXAxis("Mes",1);
>     $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
>     $mygraph->drawGraph();
>
>
> #-----------------------------------------------------------------------------
>
> Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> deste
> bloco de chamadas, como por exemplo(um simples: print "teste";) o código
> não
> funciona.
> Alguem poderia me dar uma luz !?
>
>
>
> atenciosamente
> --
> Sergio de Andrade Lopes
> (11) 3244-3580
> (11) 8168-5560
> TI - Microinformática
> Associação Comercial São Paulo
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>


[As partes desta mensagem que não continham texto foram removidas]

#3622 De: <php2005senac@...>
Data: Sáb, 2 de Set de 2006 1:43 pm
Assunto: Re: Dúvida com Data
php2005senac
Enviar e-mail Enviar e-mail
 
obrigado Claudia.

Eu acabei criando uma outra tabela mais enxuta para fazer os primeiros testes
com a manipulação da data.

Eu coloquei a função na página cadastro_cliente_ok.php só que ela insere na BD a
data como 0000-00-00

Eu estou colocando aqui os arquivos, acho que fica melhor:

O banco de dados está como
============================================
-- Table structure for table `tabela_cliente`
--

DROP TABLE IF EXISTS `tabela_cliente`;
CREATE TABLE `tabela_cliente` (
   `id_cliente` int(3) NOT NULL auto_increment,
   `nome_cliente` varchar(50) NOT NULL,
   `data` date NOT NULL,
   `valor` decimal(10,2) NOT NULL,
   `email_principal` varchar(100) NOT NULL,
   PRIMARY KEY  (`id_cliente`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

--
-- Dumping data for table `tabela_cliente`
--

INSERT INTO `tabela_cliente` VALUES (7, 'Sr. Fabiano', '2006-09-13', '99.90',
'fabiano@...');
INSERT INTO `tabela_cliente` VALUES (8, 'Sra. Carla', '0000-00-00', '39.90',
'carla@...');
========================================


conecta.php
========================================
<?php
$host=localhost;
//$user=root; usuario padrao
//$senha=""; senha padrao
$user=root;
$senha="";
$basedados=sv;
$conecta=mysql_connect($host,$user,$senha) or die("<br><br><font face=verdana
size=2><b>Houve um problema no envio das informações.<br>");
$selectdb=mysql_select_db($basedados,$conecta) or die("<br><br><font
face=verdana size=2><b>Base de dados não localizada.<br>");
?>
========================================


cadastro_cliente.php
=========================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html>
<head>
<title>Cadastro de Cliente</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<table width="80%"  border="1" align="center">
<form action="cadastro_cliente_ok.php" method="post">
   <tr>
     <td width="26%"> </td>
     <td width="74%"><strong> CADASTRO DE CLIENTE </strong></td>
   </tr>
   <tr>
     <td width="26%">Nome</td>
     <td width="74%"><input name="nome" type="text" size="30"
maxlength="50"></td>
   </tr>
   <tr>
     <td>Data</td>
     <td><input name="data" type="text" size="20" maxlength="20"></td>
   </tr>
     <tr>
     <td>Valor</td>
     <td><input name="valor" type="text" id="valor" size="20" maxlength="20">
        Usar . em vez de ,  </td>
   </tr>
   <tr>
     <td>E-mail Principal </td>
     <td><input name="email" type="text" size="30" maxlength="100"></td>
   </tr>
   <tr>
     <td> </td>
     <td> </td>
   </tr>
   <tr>
     <td> </td>
     <td><input type="submit" name="submit" value="Cadastrar Cliente"></td>
   </tr>
   </form>
</table>
</body>
</html>
==========================================


cadastro_cliente_ok.php
==========================================
<?php include_once 'conecta.php'; ?>
<?php //print $_POST["data"]; ?>
<?php
$nome = $_POST["nome"];
$data = $_POST["data"];
$valor = $_POST["valor"];
$email= $_POST["email"];

$erro=0;

// validação do nome
if (empty($nome) OR strstr ($nome, ' ')==FALSE)
{ echo "<center>Favor digitar seu nome corretamente.<br><center>"; $erro=1; }

//validação da data
$data_conv=veri_data($_POST['data']) ;

if( ! $data_conv ) {
     echo " <center>Data informada é inválida, digite  dd/mm/yyyy  </center><br>
"; $erro=1;
    //  break ;  ou retornar....  conforme seu codigo ...
}

function veri_data($data) {
         // verifica se uma data é válida e retorna no formato do mysql
aaaa-mm-dd
         // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
dd\mm\aaaa

   $a= ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
   if(!$a) {
            return false;
   }
         if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
            return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
         else
            return false;
     }

//validação do e-mail
if (strlen($email)<8 || strstr ($email, '@')==FALSE)
{ echo "<center>Favor digitar seu e-mail corretamente.</center><br>"; $erro=1; }

// VERIFICA SE NÃO HOUVE ERRO
if($erro==0)
{ echo "<center>Todos os dados foram digitados corretamente!</center>"; }

//echo "Aqui é a data" . "$data";

?>
<?php
mysql_query("INSERT INTO tabela_cliente (id_cliente, nome_cliente, data, valor,
email_principal) values ('', '$_POST[nome]', '$_POST[data]', '$_POST[valor]',
'$_POST[email]')") or die ("<br><br><center><br><br><font face=verdana
size=2><b>Houve um problema no envio das informações.<br><br><b><a
href=cadastro_cliente.php>VOLTAR</a></b></center>");
?>
<p align="center"><br>
   Cliente cadastrado com sucesso! <a href="cadastro_cliente.php">CADASTRAR NOVO
CLIENTE</a></p>
<p align="center"> </p>
<p align="center"><a href="index.php">MENU PRINCIPAL</a> </p>
====================================================


Pode ser que o erro esteja aqui:

$data_conv=veri_data($_POST['data'])   / / troque o nome do campo pelo campo que
você definiu no seu form.  da primeira página.

Eu até fiz o form com o campo data.

Obrigado,

Roger



   ----- Original Message -----
   From: Claudia A. V. Callegari
   To: php-sp@...
   Sent: Friday, September 01, 2006 11:34 AM
   Subject: Re: [php-sp] Dúvida com Data



   Considerando sua tabela, parece que o campo referente valor  é o 
`valor_plano`  , certo ?
   Então o certo é você alterar este campo ....

   ALTER TABLE  `tabela_cliente`  CHANGE  `valor_plano`  `valor_plano` 
DECIMAL(10,2) ;

   A chamada à função deve estar na segunda página...  cadastro_cliente_ok.php
(página que faz o insert no BD)

   $data_conv=veri_data($_POST['data'])   / / troque o nome do campo pelo campo
que você definiu no seu form.  da primeira página..

   Abraços
   Claudia A. V. Callegari


     ----- Original Message -----
     From: php2005senac@...
     To: php-sp@...
     Sent: Friday, September 01, 2006 9:16 AM
     Subject: Re: [php-sp] Dúvida com Data


     Olá Cláudia,

     Muito obrigado,

     Com relação a sua dica eu fiz isto:

     ALTER TABLE `tabela_cliente` ADD `valor` DECIMAL( 10, 2 ) NOT NULL ;

     Está certo?

     Quanto a função (veri_data), onde eu devo inserir:

     Eu tenho 2 páginas:
     cadastro_cliente.php (formulário)
     cadastro_cliente_ok.php (página que faz o insert no BD)

     Obrigado,

     Roger





     ----- Original Message -----
     From: Claudia A. V. Callegari
     To: php-sp@...
     Sent: Friday, September 01, 2006 8:50 AM
     Subject: Re: [php-sp] Dúvida com Data


     Ola Roger !!

     Seja Bem Vindo !!

     Primeiro uma dica, para sua tabela.
     Sempre que for utilizar campos para guardar valores referente dinheiro , use
     tipo decimal  exemplo  decimal(10,2).
     Isso porque internamente o mysql guarda esses valores como caracter e não
     retornará valores inesperados quando forem  somados.
     Essa dica é de um professor experiente da Mysql Brasil.

     Quanto ao seu problema com a data, você pode fazer o seguinte.
     Usar a função abaixo  (veri_data)  para checar se a data informada é válida
     e ao mesmo tempo converte-la para ser gravada.

     Exemplo:

     $data_conv=veri_data($_POST['data']) ;

     if( ! $data_conv ) {
         echo " Data informada é inválida, digite  dd/mm/yyyy  ";
        //  break ;  ou retornar....  conforme seu codigo ...
     }



     function veri_data($data) {
             // verifica se uma data é válida e retorna no formato do mysql
     aaaa-mm-dd
             // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
     dd\mm\aaaa

       $a= ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
       if(!$a) {
                return false;
       }
             if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
                return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
             else
                return false;
         }

     Abraços

     Claudia A. V. Callegari

       ----- Original Message -----
       From: php2005senac@...
       To: php-sp@...
       Sent: Thursday, August 31, 2006 1:34 PM
       Subject: [php-sp] Dúvida com Data


       Olá está é minha 1ª mensagem. Estou começando a programas com PHP. Começei
     a
       fazer um pequeno script com a seguinte estrutura em sua base de dados:

       Table structure for table `tabela_servidorVirtual`
       --

       DROP TABLE IF EXISTS `tabela_sv`;
       CREATE TABLE IF NOT EXISTS `tabela_sv` (
         `id_cliente` int(5) NOT NULL auto_increment,
         `nome_cliente` varchar(50) NOT NULL default '',
         `dominio_cliente` varchar(60) NOT NULL default '',
         `plano_cliente` varchar(50) NOT NULL default '',
         `espaco_atual` varchar(8) NOT NULL default '',
         `transferencia_atual` varchar(6) NOT NULL default '',
         `valor_plano` float NOT NULL default '0',
         `espaco_novo` varchar(8) NOT NULL default '',
         `transferencia_nova` varchar(6) NOT NULL default '',
         `plano_novo` varchar(50) NOT NULL default '',
         `data` date NOT NULL default '0000-00-00',
         `email_principal` varchar(100) NOT NULL default '',
         `email_secundario` varchar(100) NOT NULL default '',
         PRIMARY KEY  (`id_cliente`)
       ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3


       Se possível vocês poderiam me dizer se eu defini corretamente a minha
       tabale.

       A minha primeira dúvida é com relação a DATA, eu sei que no MySQL a data é
       YYYY-MM-DD como eu devo proceder para que no meu formulário eu coloque por
       exemplo:

       12/09/2006

       e esta data seja gravada no meu bando de dados.

       Obrigado a todos,

       Roger






     [As partes desta mensagem que não continham texto foram removidas]





     No virus found in this incoming message.
     Checked by AVG Free Edition.
     Version: 7.1.405 / Virus Database: 268.11.7/435 - Release Date: 31/8/2006



   [As partes desta mensagem que não continham texto foram removidas]




------------------------------------------------------------------------------


   No virus found in this incoming message.
   Checked by AVG Free Edition.
   Version: 7.1.405 / Virus Database: 268.11.7/435 - Release Date: 31/8/2006


[As partes desta mensagem que não continham texto foram removidas]

#3623 De: "Sergio de Andrade" <sergio.ophus@...>
Data: Sáb, 2 de Set de 2006 2:07 am
Assunto: Re: baaChart Dúvida
xr32004
Enviar e-mail Enviar e-mail
 
André, quer dizer que neste caso não há como eu utilizar esta classe para
gerar meus gráficos, incrementando meus phps....?!?
como eu poderia utilizar este gráfico separado... tipo num pop-up ???

vc conhece alguma outra classe parecida, sem estes headers ??


att

2006/8/31, André Mauricio Garcia <andre.moe@...>:
>
> Nunca utilizei esta classe, mas já utilizei diversas outras.
> Normalmente elas utilizam um "header" de imagem. Então é bem provável que
> vc tenha que usá-la em um arquivo separado (imagem.php, por exemplo).
> Caso vc inprima alguma coisa, como seu simples "print 'teste';" o header
> já não poderá mais ser alterado, logo a classe pára de funcionar.
>
> Att.
> André
>
>
>
> ----- Original Message -----
>   From: Sergio de Andrade
>   To: php-sp@...
>   Sent: Thursday, August 31, 2006 1:51 PM
>   Subject: [php-sp] baaChart Dúvida
>
>
>   Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
>   trocando informações.
>
>   Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
>   classe baaChart
>   para gerar gráficos estatísticos.
>   Para utilizar a a classe estou usando algo do tipo:
>
>
>
#-------------------------------------------------------------------------------\
--
>
>   include('baaChart.php');
>       $mygraph = new baaChart(600);
>       $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
>       $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
>
>
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
>       $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
>       $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
>       $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
>       $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
>       $mygraph->setBgColor(0,0,0,1);  //transparent background
>       $mygraph->setChartBgColor(0,0,0,1);  //as background
>       $mygraph->setXAxis("Mes",1);
>       $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
>       $mygraph->drawGraph();
>
>
> #-----------------------------------------------------------------------------
>
>   Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> deste
>   bloco de chamadas, como por exemplo(um simples: print "teste";) o código
> não
>   funciona.
>   Alguem poderia me dar uma luz !?
>
>
>
>   atenciosamente
>   --
>   Sergio de Andrade Lopes
>   (11) 3244-3580
>   (11) 8168-5560
>   TI - Microinformática
>   Associação Comercial São Paulo
>
>
>   [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>



--
Sergio de Andrade Lopes
(11) 3244-3580
(11) 8168-5560
TI - Microinformática
Associação Comercial São Paulo


[As partes desta mensagem que não continham texto foram removidas]

#3624 De: <php2005senac@...>
Data: Sáb, 2 de Set de 2006 3:37 pm
Assunto: Re: Dúvida com Data
php2005senac
Enviar e-mail Enviar e-mail
 
Consegui Claudia.

Esquece a minha mensagem anterior. Agora esta gravando a data no formato
YYYY-MM-DD no banco de dados.

Como é gostoso estes desafios.

Um bom final de semana a todos ..... Agora vou tomar uma gelada para esfriar os
meus neurônios.



   ----- Original Message -----
   From: php2005senac@...
   To: php-sp@...
   Sent: Saturday, September 02, 2006 10:43 AM
   Subject: Re: [php-sp] Dúvida com Data


   obrigado Claudia.

   Eu acabei criando uma outra tabela mais enxuta para fazer os primeiros testes
com a manipulação da data.

   Eu coloquei a função na página cadastro_cliente_ok.php só que ela insere na BD
a data como 0000-00-00

   Eu estou colocando aqui os arquivos, acho que fica melhor:

   O banco de dados está como
   ============================================
   -- Table structure for table `tabela_cliente`
   --

   DROP TABLE IF EXISTS `tabela_cliente`;
   CREATE TABLE `tabela_cliente` (
     `id_cliente` int(3) NOT NULL auto_increment,
     `nome_cliente` varchar(50) NOT NULL,
     `data` date NOT NULL,
     `valor` decimal(10,2) NOT NULL,
     `email_principal` varchar(100) NOT NULL,
     PRIMARY KEY  (`id_cliente`)
   ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ;

   --
   -- Dumping data for table `tabela_cliente`
   --

   INSERT INTO `tabela_cliente` VALUES (7, 'Sr. Fabiano', '2006-09-13', '99.90',
'fabiano@...');
   INSERT INTO `tabela_cliente` VALUES (8, 'Sra. Carla', '0000-00-00', '39.90',
'carla@...');
   ========================================


   conecta.php
   ========================================
   <?php
   $host=localhost;
   //$user=root; usuario padrao
   //$senha=""; senha padrao
   $user=root;
   $senha="";
   $basedados=sv;
   $conecta=mysql_connect($host,$user,$senha) or die("<br><br><font face=verdana
size=2><b>Houve um problema no envio das informações.<br>");
   $selectdb=mysql_select_db($basedados,$conecta) or die("<br><br><font
face=verdana size=2><b>Base de dados não localizada.<br>");
   ?>
   ========================================


   cadastro_cliente.php
   =========================================
   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   <html>
   <head>
   <title>Cadastro de Cliente</title>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   </head>
   <body>
   <table width="80%"  border="1" align="center">
   <form action="cadastro_cliente_ok.php" method="post">
     <tr>
       <td width="26%"> </td>
       <td width="74%"><strong> CADASTRO DE CLIENTE </strong></td>
     </tr>
     <tr>
       <td width="26%">Nome</td>
       <td width="74%"><input name="nome" type="text" size="30"
maxlength="50"></td>
     </tr>
     <tr>
       <td>Data</td>
       <td><input name="data" type="text" size="20" maxlength="20"></td>
     </tr>
       <tr>
       <td>Valor</td>
       <td><input name="valor" type="text" id="valor" size="20" maxlength="20">
          Usar . em vez de ,  </td>
     </tr>
     <tr>
       <td>E-mail Principal </td>
       <td><input name="email" type="text" size="30" maxlength="100"></td>
     </tr>
     <tr>
       <td> </td>
       <td> </td>
     </tr>
     <tr>
       <td> </td>
       <td><input type="submit" name="submit" value="Cadastrar Cliente"></td>
     </tr>
     </form>
   </table>
   </body>
   </html>
   ==========================================


   cadastro_cliente_ok.php
   ==========================================
   <?php include_once 'conecta.php'; ?>
   <?php //print $_POST["data"]; ?>
   <?php
   $nome = $_POST["nome"];
   $data = $_POST["data"];
   $valor = $_POST["valor"];
   $email= $_POST["email"];

   $erro=0;

   // validação do nome
   if (empty($nome) OR strstr ($nome, ' ')==FALSE)
   { echo "<center>Favor digitar seu nome corretamente.<br><center>"; $erro=1; }

   //validação da data
   $data_conv=veri_data($_POST['data']) ;

   if( ! $data_conv ) {
       echo " <center>Data informada é inválida, digite  dd/mm/yyyy 
</center><br> "; $erro=1;
      //  break ;  ou retornar....  conforme seu codigo ...
   }

   function veri_data($data) {
           // verifica se uma data é válida e retorna no formato do mysql
aaaa-mm-dd
           // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
dd\mm\aaaa

     $a= ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
     if(!$a) {
              return false;
     }
           if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
              return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
           else
              return false;
       }

   //validação do e-mail
   if (strlen($email)<8 || strstr ($email, '@')==FALSE)
   { echo "<center>Favor digitar seu e-mail corretamente.</center><br>"; $erro=1;
}

   // VERIFICA SE NÃO HOUVE ERRO
   if($erro==0)
   { echo "<center>Todos os dados foram digitados corretamente!</center>"; }

   //echo "Aqui é a data" . "$data";

   ?>
   <?php
   mysql_query("INSERT INTO tabela_cliente (id_cliente, nome_cliente, data,
valor, email_principal) values ('', '$_POST[nome]', '$_POST[data]',
'$_POST[valor]', '$_POST[email]')") or die ("<br><br><center><br><br><font
face=verdana size=2><b>Houve um problema no envio das informações.<br><br><b><a
href=cadastro_cliente.php>VOLTAR</a></b></center>");
   ?>
   <p align="center"><br>
     Cliente cadastrado com sucesso! <a href="cadastro_cliente.php">CADASTRAR
NOVO CLIENTE</a></p>
   <p align="center"> </p>
   <p align="center"><a href="index.php">MENU PRINCIPAL</a> </p>
   ====================================================


   Pode ser que o erro esteja aqui:

   $data_conv=veri_data($_POST['data'])   / / troque o nome do campo pelo campo
que você definiu no seu form.  da primeira página.

   Eu até fiz o form com o campo data.

   Obrigado,

   Roger



     ----- Original Message -----
     From: Claudia A. V. Callegari
     To: php-sp@...
     Sent: Friday, September 01, 2006 11:34 AM
     Subject: Re: [php-sp] Dúvida com Data



     Considerando sua tabela, parece que o campo referente valor  é o 
`valor_plano`  , certo ?
     Então o certo é você alterar este campo ....

     ALTER TABLE  `tabela_cliente`  CHANGE  `valor_plano`  `valor_plano` 
DECIMAL(10,2) ;

     A chamada à função deve estar na segunda página...  cadastro_cliente_ok.php
(página que faz o insert no BD)

     $data_conv=veri_data($_POST['data'])   / / troque o nome do campo pelo campo
que você definiu no seu form.  da primeira página..

     Abraços
     Claudia A. V. Callegari


       ----- Original Message -----
       From: php2005senac@...
       To: php-sp@...
       Sent: Friday, September 01, 2006 9:16 AM
       Subject: Re: [php-sp] Dúvida com Data


       Olá Cláudia,

       Muito obrigado,

       Com relação a sua dica eu fiz isto:

       ALTER TABLE `tabela_cliente` ADD `valor` DECIMAL( 10, 2 ) NOT NULL ;

       Está certo?

       Quanto a função (veri_data), onde eu devo inserir:

       Eu tenho 2 páginas:
       cadastro_cliente.php (formulário)
       cadastro_cliente_ok.php (página que faz o insert no BD)

       Obrigado,

       Roger





       ----- Original Message -----
       From: Claudia A. V. Callegari
       To: php-sp@...
       Sent: Friday, September 01, 2006 8:50 AM
       Subject: Re: [php-sp] Dúvida com Data


       Ola Roger !!

       Seja Bem Vindo !!

       Primeiro uma dica, para sua tabela.
       Sempre que for utilizar campos para guardar valores referente dinheiro ,
use
       tipo decimal  exemplo  decimal(10,2).
       Isso porque internamente o mysql guarda esses valores como caracter e não
       retornará valores inesperados quando forem  somados.
       Essa dica é de um professor experiente da Mysql Brasil.

       Quanto ao seu problema com a data, você pode fazer o seguinte.
       Usar a função abaixo  (veri_data)  para checar se a data informada é
válida
       e ao mesmo tempo converte-la para ser gravada.

       Exemplo:

       $data_conv=veri_data($_POST['data']) ;

       if( ! $data_conv ) {
           echo " Data informada é inválida, digite  dd/mm/yyyy  ";
          //  break ;  ou retornar....  conforme seu codigo ...
       }



       function veri_data($data) {
               // verifica se uma data é válida e retorna no formato do mysql
       aaaa-mm-dd
               // $data pode  ser  dd/mm/aaaa  ou dd-mm-aaaa  ou dd.mm.aaaa ou
       dd\mm\aaaa

         $a=
ereg('([0-9]{2})([-.\/])([0-9]{2})([-.\/])([0-9]{4})',$data,$datadiv);
         if(!$a) {
                  return false;
         }
               if(checkdate($datadiv[3],$datadiv[1],$datadiv[5]) )
                  return  $datadiv[5].'-'.$datadiv[3].'-'.$datadiv[1];
               else
                  return false;
           }

       Abraços

       Claudia A. V. Callegari

         ----- Original Message -----
         From: php2005senac@...
         To: php-sp@...
         Sent: Thursday, August 31, 2006 1:34 PM
         Subject: [php-sp] Dúvida com Data


         Olá está é minha 1ª mensagem. Estou começando a programas com PHP.
Começei
       a
         fazer um pequeno script com a seguinte estrutura em sua base de dados:

         Table structure for table `tabela_servidorVirtual`
         --

         DROP TABLE IF EXISTS `tabela_sv`;
         CREATE TABLE IF NOT EXISTS `tabela_sv` (
           `id_cliente` int(5) NOT NULL auto_increment,
           `nome_cliente` varchar(50) NOT NULL default '',
           `dominio_cliente` varchar(60) NOT NULL default '',
           `plano_cliente` varchar(50) NOT NULL default '',
           `espaco_atual` varchar(8) NOT NULL default '',
           `transferencia_atual` varchar(6) NOT NULL default '',
           `valor_plano` float NOT NULL default '0',
           `espaco_novo` varchar(8) NOT NULL default '',
           `transferencia_nova` varchar(6) NOT NULL default '',
           `plano_novo` varchar(50) NOT NULL default '',
           `data` date NOT NULL default '0000-00-00',
           `email_principal` varchar(100) NOT NULL default '',
           `email_secundario` varchar(100) NOT NULL default '',
           PRIMARY KEY  (`id_cliente`)
         ) ENGINE=MyISAM AUTO_INCREMENT=3 DEFAULT CHARSET=latin1 AUTO_INCREMENT=3


         Se possível vocês poderiam me dizer se eu defini corretamente a minha
         tabale.

         A minha primeira dúvida é com relação a DATA, eu sei que no MySQL a data
é
         YYYY-MM-DD como eu devo proceder para que no meu formulário eu coloque
por
         exemplo:

         12/09/2006

         e esta data seja gravada no meu bando de dados.

         Obrigado a todos,

         Roger






       [As partes desta mensagem que não continham texto foram removidas]





       No virus found in this incoming message.
       Checked by AVG Free Edition.
       Version: 7.1.405 / Virus Database: 268.11.7/435 - Release Date: 31/8/2006



     [As partes desta mensagem que não continham texto foram removidas]




   ------------------------------------------------------------------------------


     No virus found in this incoming message.
     Checked by AVG Free Edition.
     Version: 7.1.405 / Virus Database: 268.11.7/435 - Release Date: 31/8/2006


   [As partes desta mensagem que não continham texto foram removidas]




------------------------------------------------------------------------------


   No virus found in this incoming message.
   Checked by AVG Free Edition.
   Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 1/9/2006


[As partes desta mensagem que não continham texto foram removidas]

#3625 De: "mbtec" <mariobelolli@...>
Data: Seg, 4 de Set de 2006 12:44 pm
Assunto: campo no array
mariobelolli
Enviar e-mail Enviar e-mail
 
Caros amigos,

Tenho 2 combos, sendo a segunda carrega a partir do filtro da
primeira.

Preciso incluir mais um campo (codigo_ngp_seq) na primeira e mais um
campo (codigo_ngs_seq) na segunda.

Qualquer tentantiva de mudança que efetivo, a segunda combo se
perde.
Podem me auxiliar ou propor outro script?

Obrigado.

Segue script abaixo:


<SCRIPT LANGUAGE="JavaScript">
team = new Array(
<?
###########################################################
# Caso a sua tabela seja diferente altere apenas a sql e  #
# a array $row e $rowx para que elas apontem para o novo  #
# nome dos campos                                         #
# Todas as categorias terão listadas nelas o item "Todas" #
# com valor '0' e caso a categoria não tenha nenhuma      #
# Sub Categoria ela retorna o ite "Qualquer", também com  #
# valor '0'.                                              #
###########################################################
$sql="select * from tab_ng_principal order by nome_ngp";
$sql_result=mysql_query($sql, $conecta);
$num=mysql_numrows($sql_result);
while ($row=mysql_fetch_array($sql_result)){
$conta=$conta+1;
	 $codigo_ngp=$row["codigo_ngp"];
		 echo "new Array(\n";
		 $sub_sql="select * from tab_ng_secundaria where
codigo_ngp='$codigo_ngp'";
		 $sub_result=mysql_query($sub_sql, $conecta);
		 $num_sub=mysql_numrows($sub_result);
		 if ($num_sub>=1){
			 echo "new Array(\"-\", 0),\n";
			 while ($rowx=mysql_fetch_array($sub_result)){
				 $codigo_ngs=$rowx["codigo_ngs"];
				 $nome_ngs=$rowx["nome_ngs"];
				 $codigo_ngs_seq=$rowx
["codigo_ngs_seq"];
			 $conta_sub=$conta_sub+1;
				 if ($conta_sub==$num_sub){
					 echo "new Array
(\"$nome_ngs\", $codigo_ngs)\n";
					 $conta_sub="";
				 }else{
					 echo "new Array
(\"$nome_ngs\", $codigo_ngs),\n";
				 }
			 }
		 }else{
			 echo "new Array(\"Qualquer\", 0)\n";
		 }
	 if ($num>$conta){
		 echo "),\n";
	 }
}
echo ")\n";
echo ");\n";
?>

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt,
badPrompt, defaultItem) {
var i, j;
var prompt;
// empty existing items
for (i = selectCtrl.options.length; i >= 0; i--) {
selectCtrl.options[i] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (i = 0; i < itemArray.length; i++) {
selectCtrl.options[j] = new Option(itemArray[i][0]);
if (itemArray[i][1] != null) {
selectCtrl.options[j].value = itemArray[i][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
    }
}
//  End -->
</script>


<center>

<html>
<head>
<title>SULCONSULT - SGF</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1">
</head>


<body>
<form action="inserir_nga.php" method="post" name="Cadastro de NGA"
id="cadastra_nga">
<center>
     <table width="75%" border="2" cellspacing="0" cellpadding="3">
       <tr>

		 <td>
		 <center>
             <p> </p>
			 <table width="90%" border="0"
cellspacing="0" cellpadding="3">
               <tr bgcolor="#009966">
                 <td colspan="2"><div align="center"><strong><font
color="#FFFFFF">CADASTRO
                     DE NATUREZA DE GASTO
ANALÍTICA</font></strong></div></td>
  				 </tr>
	             <tr>
					 <td colspan="2"> </td>
  				 </tr>
				 <tr>
					 <td width="262"><div
align="right">Natureza Principal:</div></td>
			 <td>
       <select name="codigo_ngp" onChange="fillSelectFromArray
(this.form.codigo_ngs, ((this.selectedIndex == -1) ? null : team
[this.selectedIndex-1]));">
         <option>-</option>
         <?
		   $sql="select * from tab_ng_principal order by
nome_ngp";
		   //$sql="select * from tab_ng_principal order by
codigo_ngp_seq"; // neste order by dá erro no ngs

		   $sql_result=mysql_query($sql, $conecta);
		   while ($row=mysql_fetch_array($sql_result)){
		   $codigo_ngp=$row["codigo_ngp"];
		   $nome_ngp=$row["nome_ngp"];
		   $codigo_ngp_seq=$row["codigo_ngp_seq"];
		   ?>
         <option value="<? echo $codigo_ngp; ?>">
         <? echo $codigo_ngp_seq. " - ".$nome_ngp; ?>
         </option>
         <?
		   }
		   ?>
       </select>
			 </td>
  				 </tr>
				 <tr>
					 <td width="262"><div
align="right">Natureza Secundária:</div></td>
			 <td>
       <select name="codigo_ngs">
         <option>-</option>
       </select>
	  		 </td>
  				 </tr>

  				 <tr>
					 <td width="262"><div
align="right"> Sequencial:</div></td>

			    	 <td width="420"><input
name="codigo_nga_seq" type="text" id="codigo_nga_seq" size="10"
maxlength=10></td>
  				 </tr>
  				 <tr>
					 <td width="262"><div
align="right"> Natureza Analítica:</div></td>

			    	 <td width="420"><input
name="nome_nga" type="text" id="nome_nga" size="70"
maxlenght=70></td>
  				 </tr>

				 <tr>
					 <td colspan="2"><div
align="right"><input type="submit" name="Cadastrar NGA"
value="Cadastrar"></div></td>
		  		 </tr>
			 </table>
			 </center>
		 <p> </p></td>

	 </tr>
</table>
  </center>
</form>

#3626 De: "André Mauricio Garcia" <andre.moe@...>
Data: Dom, 3 de Set de 2006 8:03 pm
Assunto: Re: baaChart Dúvida
moe_andre
Enviar e-mail Enviar e-mail
 
Você só deev usá-la em u, arquivo separado e chamar este arquivo no src da
tag img (Ex: <img src="imagem.php" />).
Daí fica a seu critério a amneira como irá passar seus parâmetros para
imagem, seja via GET, vias SESSION...
Para gerar imagens somente desta maneira mesmo. Não conheço outras.
Já vi umas classes "malandras" que geram gráficos utilizando tabelas, mas
não recomendo.

Abraço

2006/9/1, Sergio de Andrade <sergio.ophus@...>:
>
> André, quer dizer que neste caso não há como eu utilizar esta classe para
> gerar meus gráficos, incrementando meus phps....?!?
> como eu poderia utilizar este gráfico separado... tipo num pop-up ???
>
> vc conhece alguma outra classe parecida, sem estes headers ??
>
>
> att
>
> 2006/8/31, André Mauricio Garcia <andre.moe@...>:
>
> >
> > Nunca utilizei esta classe, mas já utilizei diversas outras.
> > Normalmente elas utilizam um "header" de imagem. Então é bem provável
> que
> > vc tenha que usá-la em um arquivo separado (imagem.php, por exemplo).
> > Caso vc inprima alguma coisa, como seu simples "print 'teste';" o header
> > já não poderá mais ser alterado, logo a classe pára de funcionar.
> >
> > Att.
> > André
> >
> >
> >
> > ----- Original Message -----
> >   From: Sergio de Andrade
> >   To: php-sp@...
> >   Sent: Thursday, August 31, 2006 1:51 PM
> >   Subject: [php-sp] baaChart Dúvida
> >
> >
> >   Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> >   trocando informações.
> >
> >   Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> >   classe baaChart
> >   para gerar gráficos estatísticos.
> >   Para utilizar a a classe estou usando algo do tipo:
> >
> >
> >
>
#-------------------------------------------------------------------------------\
--
> >
> >   include('baaChart.php');
> >       $mygraph = new baaChart(600);
> >       $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
> >       $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
> >
> >
> >
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
> >       $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
> >       $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
> >       $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
> >       $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
> >       $mygraph->setBgColor(0,0,0,1);  //transparent background
> >       $mygraph->setChartBgColor(0,0,0,1);  //as background
> >       $mygraph->setXAxis("Mes",1);
> >       $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
> >       $mygraph->drawGraph();
> >
> >
> >
> #-----------------------------------------------------------------------------
> >
> >   Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> > deste
> >   bloco de chamadas, como por exemplo(um simples: print "teste";) o
> código
> > não
> >   funciona.
> >   Alguem poderia me dar uma luz !?
> >
> >
> >
> >   atenciosamente
> >   --
> >   Sergio de Andrade Lopes
> >   (11) 3244-3580
> >   (11) 8168-5560
> >   TI - Microinformática
> >   Associação Comercial São Paulo
> >
> >
> >   [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
> >
> >
> >
> > [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
> >
> >
> >
>
>
>
> --
> Sergio de Andrade Lopes
> (11) 3244-3580
> (11) 8168-5560
> TI - Microinformática
> Associação Comercial São Paulo
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>



--
"Primeiro eles o ignoram. Depois riem de você. Então eles o combatem. Aí
você vence!"
--Mohandas Gandhi


[As partes desta mensagem que não continham texto foram removidas]

#3627 De: "Leandro Lopes" <lelopes.br@...>
Data: Sáb, 2 de Set de 2006 10:13 pm
Assunto: Error 404
lelopes.br@...
Enviar e-mail Enviar e-mail
 
Amigos,
Ao escrever em um arquivo esta dando a mensagem:

You don't have permission to access /album.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
------------------------------
Apache/1.3.36 Server at www.kiwii.com.br Port 80   A permissão do arquivo já
esta 777 alguém pode me ajudar?   Obrigado,


[As partes desta mensagem que não continham texto foram removidas]

#3628 De: "Sergio de Andrade" <sergio.ophus@...>
Data: Sáb, 2 de Set de 2006 5:34 pm
Assunto: Re: baaChart Dúvida
xr32004
Enviar e-mail Enviar e-mail
 
Haroldo, nao saquei o bem o que você quiz dizer ... bom aqui sem o print,
rola numa boa ... segue ae um print do gráfico..que por sinal é muito
bonito.





2006/9/2, Haroldo CentralSys <haroldo.passos@...>:
>
> Sergio, copie o código e tentei rodar sem o print ("teste") e deu o erro.
>
>
> Haroldo
>
>
>
> 2006/8/31, Sergio de Andrade <sergio.ophus@...>:
> >
> >  Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> > trocando informações.
> >
> > Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> > classe baaChart
> > para gerar gráficos estatísticos.
> > Para utilizar a a classe estou usando algo do tipo:
> >
> >
> >
>
#-------------------------------------------------------------------------------\
--
> >
> > include('baaChart.php');
> >     $mygraph = new baaChart(600);
> >     $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
> >     $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
> >
> >
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
> >     $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
> >     $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
> >     $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
> >     $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
> >     $mygraph->setBgColor(0,0,0,1);  //transparent background
> >     $mygraph->setChartBgColor(0,0,0,1);  //as background
> >     $mygraph->setXAxis("Mes",1);
> >     $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
> >     $mygraph->drawGraph();
> >
> >
> >
> #-----------------------------------------------------------------------------
> >
> > Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou acima
> > deste
> > bloco de chamadas, como por exemplo(um simples: print "teste";) o código
> > não
> > funciona.
> > Alguem poderia me dar uma luz !?
> >
> >
> >
> > atenciosamente
> > --
> > Sergio de Andrade Lopes
> > (11) 3244-3580
> > (11) 8168-5560
> > TI - Microinformática
> > Associação Comercial São Paulo
> >
> >
> > [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
> >
> >
> >
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>



--
Sergio de Andrade Lopes
(11) 3244-3580
(11) 8168-5560
TI - Microinformática
Associação Comercial São Paulo


[As partes desta mensagem que não continham texto foram removidas]

#3629 De: Miriam Fernandes (Drika®) <tecmaster@...>
Data: Seg, 4 de Set de 2006 6:04 pm
Assunto: MySQL para TXT
ownerlistbr
Enviar e-mail Enviar e-mail
 
Oi galera.. tudo bom?

Alguem aqui já exportou dados do MySQL para um arquivo TXT ?

Alguem poderia me dar uma mãozinha?

Desde já agradeço.


//Drika

[As partes desta mensagem que não continham texto foram removidas]

#3630 De: <php2005senac@...>
Data: Seg, 4 de Set de 2006 5:42 pm
Assunto: Re: Error 404
php2005senac
Enviar e-mail Enviar e-mail
 
Leandro,

Tente colocar permissão 644.
   ----- Original Message -----
   From: Leandro Lopes
   To: php-sp@... ; Kamikaze
   Sent: Saturday, September 02, 2006 7:13 PM
   Subject: [php-sp] Error 404


   Amigos,
   Ao escrever em um arquivo esta dando a mensagem:

   You don't have permission to access /album.php on this server.

   Additionally, a 404 Not Found error was encountered while trying to use an
   ErrorDocument to handle the request.
   ------------------------------
   Apache/1.3.36 Server at www.kiwii.com.br Port 80   A permissão do arquivo já
   esta 777 alguém pode me ajudar?   Obrigado,


   [As partes desta mensagem que não continham texto foram removidas]






------------------------------------------------------------------------------


   No virus found in this incoming message.
   Checked by AVG Free Edition.
   Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 1/9/2006


[As partes desta mensagem que não continham texto foram removidas]

#3631 De: "Claudia A. V. Callegari" <claudia@...>
Data: Ter, 5 de Set de 2006 11:16 am
Assunto: Re: MySQL para TXT
claudiaphp
Enviar e-mail Enviar e-mail
 
Ola Miriam !

É possível fazer isso de várias maneiras, uma delas é fazer um select  com saída
para um arquivo.
Exemplo:
<?php

   $arq=$_SERVER['DOCUMENT_ROOT'].'/arquivo.txt';
   @unlink($arq);

   $sql ="select  * from   tabela   into outfile \"$arq\" FIELDS TERMINATED BY
'\t' ";


$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    if (!$link) {
        die('Não foi possível conectar: ' . mysql_error());
    }

$result = mysql_query($sql);
if (!$result) {
    die('Invalid query: ' . mysql_error());
}

Abraços
Claudia A. V. Callegari :-)


?>



   ----- Original Message -----
   From: Miriam Fernandes (Drika®)
   To: php-sp@...
   Sent: Monday, September 04, 2006 3:04 PM
   Subject: [php-sp] MySQL para TXT


   Oi galera.. tudo bom?

   Alguem aqui já exportou dados do MySQL para um arquivo TXT ?

   Alguem poderia me dar uma mãozinha?

   Desde já agradeço.


   //Drika

   [As partes desta mensagem que não continham texto foram removidas]



[As partes desta mensagem que não continham texto foram removidas]

#3632 De: "Tiago Gigli" <gigli.tiago@...>
Data: Ter, 5 de Set de 2006 11:49 am
Assunto: Re: MySQL para TXT
t_gigli
Enviar e-mail Enviar e-mail
 
vc tb pode fazer um dump dos dados e extrai-los em formato sql.
tb há diversas funcoes csv se precisar exportar em formato txt compativel
com excel, por exemplo.

Em 05/09/06, Claudia A. V. Callegari <claudia@...> escreveu:
>
> Ola Miriam !
>
> É possível fazer isso de várias maneiras, uma delas é fazer um select  com
> saída para um arquivo.
> Exemplo:
> <?php
>
>   $arq=$_SERVER['DOCUMENT_ROOT'].'/arquivo.txt';
>   @unlink($arq);
>
>   $sql ="select  * from   tabela   into outfile \"$arq\" FIELDS TERMINATED
> BY '\t' ";
>
>
> $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
>    if (!$link) {
>        die('Não foi possível conectar: ' . mysql_error());
>    }
>
> $result = mysql_query($sql);
> if (!$result) {
>    die('Invalid query: ' . mysql_error());
> }
>
> Abraços
> Claudia A. V. Callegari :-)
>
>
> ?>
>
>
>
>
>   ----- Original Message -----
>   From: Miriam Fernandes (Drika(r))
>   To: php-sp@...
>   Sent: Monday, September 04, 2006 3:04 PM
>   Subject: [php-sp] MySQL para TXT
>
>
>   Oi galera.. tudo bom?
>
>   Alguem aqui já exportou dados do MySQL para um arquivo TXT ?
>
>   Alguem poderia me dar uma mãozinha?
>
>   Desde já agradeço.
>
>
>   //Drika
>
>   [As partes desta mensagem que não continham texto foram removidas]
>
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>



--
Cyah' round


[As partes desta mensagem que não continham texto foram removidas]

#3633 De: Miriam Fernandes (Drika®) <tecmaster@...>
Data: Ter, 5 de Set de 2006 12:17 pm
Assunto: Re: MySQL para TXT
ownerlistbr
Enviar e-mail Enviar e-mail
 
Obrigada pela ajuda galera!  Foram fundamentais para me dar aquele empurrão...
Bem, na realidade, é o seguinte:

Eu perguntei sobre o assunto, porque tenho um cliente que possui uma base de
dados de emails, em MySQL e ele quer exportar esses emails para o Outlook.

Eu estive olhando a forma como o Outlook importa esses dados, pode ser em
arquivo texto (TXT ou CSV).... e cada dado é separado por ";"
(ponto-e-vírgula)....

Agora.. com as informações que vocês me passaram já deu pra ter uma idéia de que
caminho devo seguir....

Valeuzão!!!

Beijokas
Drika
   ----- Original Message -----
   From: Tiago Gigli
   To: php-sp@...
   Sent: Tuesday, September 05, 2006 8:49 AM
   Subject: Re: [php-sp] MySQL para TXT


   vc tb pode fazer um dump dos dados e extrai-los em formato sql.
   tb há diversas funcoes csv se precisar exportar em formato txt compativel
   com excel, por exemplo.

   Em 05/09/06, Claudia A. V. Callegari <claudia@...> escreveu:
   >
   > Ola Miriam !
   >
   > É possível fazer isso de várias maneiras, uma delas é fazer um select  com
   > saída para um arquivo.
   > Exemplo:
   > <?php
   >
   >   $arq=$_SERVER['DOCUMENT_ROOT'].'/arquivo.txt';
   >   @unlink($arq);
   >
   >   $sql ="select  * from   tabela   into outfile \"$arq\" FIELDS TERMINATED
   > BY '\t' ";
   >
   >
   > $link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
   >    if (!$link) {
   >        die('Não foi possível conectar: ' . mysql_error());
   >    }
   >
   > $result = mysql_query($sql);
   > if (!$result) {
   >    die('Invalid query: ' . mysql_error());
   > }
   >
   > Abraços
   > Claudia A. V. Callegari :-)
   >
   >
   > ?>
   >
   >
   >
   >
   >   ----- Original Message -----
   >   From: Miriam Fernandes (Drika(r))
   >   To: php-sp@...
   >   Sent: Monday, September 04, 2006 3:04 PM
   >   Subject: [php-sp] MySQL para TXT
   >
   >
   >   Oi galera.. tudo bom?
   >
   >   Alguem aqui já exportou dados do MySQL para um arquivo TXT ?
   >
   >   Alguem poderia me dar uma mãozinha?
   >
   >   Desde já agradeço.
   >
   >
   >   //Drika
   >
   >   [As partes desta mensagem que não continham texto foram removidas]
   >
   >
   >
   > [As partes desta mensagem que não continham texto foram removidas]
   >
   >
   >



   --
   Cyah' round


   [As partes desta mensagem que não continham texto foram removidas]



[As partes desta mensagem que não continham texto foram removidas]

#3634 De: "Haroldo CentralSys" <haroldo.passos@...>
Data: Ter, 5 de Set de 2006 3:06 pm
Assunto: Progresso durante processamento
haroldobpassos
Enviar e-mail Enviar e-mail
 
Como vão Colegas?

Tenho um script que processa uma grande quantidade de registros gerando
totalizadores em uma tabela de resultados.

Como posso durante esse processo, exibir o progresso desse processamento?

Grato,

Haroldo


[As partes desta mensagem que não continham texto foram removidas]

#3635 De: Fernando Pereira <nandinho231@...>
Data: Seg, 4 de Set de 2006 9:22 pm
Assunto: Re: MySQL para TXT
nandinho231
Enviar e-mail Enviar e-mail
 
Bom vamos ver se consigo te ajudar Miriam:

  $fsep = ";" ; // pode ser qualquer separador de campo que quiser

  $bd = @mysql_connect( "localhost", "user", "pass" )
                or die(mysql_error());

  @mysql_select_db( "nome_db", $conexao )
                or die(mysql_error());
  $consulta = "select * from nome_tabela";
  $resultado = mysql_query( $consulta, $bd);
  $sai = fopen("arquivo_texto.txt","a+");

  while ($linha = mysql_fetch_row($resultado)) {
       $result = fputs($sai,implode($fsep,$linha));
       echo $conteudo; // se quiser que o conteudo sai na tela tambem.
  }
  fclose($sai)
Bom isso usando PHP, mas você tem inumeras possibilidades já que o própro MySQL
faz esse tipo de tratamento:

mysql> Select *
          -> INTO OUTFILE "C:/pastadeorigem/arquivo.txt" //Observe o uso de barra
'/' e não de '\'.
           ->Nome_da_tabela;

Bom espero ter ajudado T+ (FEPS)

Miriam Fernandes (Drika®) <tecmaster@...> escreveu:    Oi galera..
tudo bom?

  Alguem aqui já exportou dados do MySQL para um arquivo TXT ?

  Alguem poderia me dar uma mãozinha?

  Desde já agradeço.


  //Drika

  [As partes desta mensagem que não continham texto foram removidas]




---------------------------------
  Yahoo! Search
  Música para ver e ouvir: You're Beautiful, do James Blunt

[As partes desta mensagem que não continham texto foram removidas]

#3636 De: <richard_daros@...>
Data: Seg, 4 de Set de 2006 3:13 pm
Assunto: Re: Error 404
richard_daros
Enviar e-mail Enviar e-mail
 
tentou alterar as permissões  do arquivo? ou da pasta que ta o arquivo?
   ----- Original Message -----
   From: Leandro Lopes
   To: php-sp@... ; Kamikaze
   Sent: Saturday, September 02, 2006 7:13 PM
   Subject: [php-sp] Error 404


   Amigos,
   Ao escrever em um arquivo esta dando a mensagem:

   You don't have permission to access /album.php on this server.

   Additionally, a 404 Not Found error was encountered while trying to use an
   ErrorDocument to handle the request.
   ------------------------------
   Apache/1.3.36 Server at www.kiwii.com.br Port 80   A permissão do arquivo já
   esta 777 alguém pode me ajudar?   Obrigado,


   [As partes desta mensagem que não continham texto foram removidas]





[As partes desta mensagem que não continham texto foram removidas]

#3637 De: "Leandro Lopes" <lelopes.br@...>
Data: Seg, 4 de Set de 2006 10:54 pm
Assunto: Re: Error 404
lelopes.br@...
Enviar e-mail Enviar e-mail
 
Amigos,
As permissões estão 777 do arquivo e pasta para todos os usuarios, não estou
entendendo o porque deste erro. e o 644 não funcionou.

Ta dificil viu...

Obrigado.


Em 04/09/06, php2005senac@... <php2005senac@...> escreveu:
>
> Leandro,
>
> Tente colocar permissão 644.
> ----- Original Message -----
> From: Leandro Lopes
> To: php-sp@... ; Kamikaze
> Sent: Saturday, September 02, 2006 7:13 PM
> Subject: [php-sp] Error 404
>
>
> Amigos,
> Ao escrever em um arquivo esta dando a mensagem:
>
> You don't have permission to access /album.php on this server.
>
> Additionally, a 404 Not Found error was encountered while trying to use an
> ErrorDocument to handle the request.
> ------------------------------
> Apache/1.3.36 Server at www.kiwii.com.br Port 80   A permissão do arquivo
> já
> esta 777 alguém pode me ajudar?   Obrigado,
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.11.7/436 - Release Date: 1/9/2006
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
> Links do Yahoo! Grupos
>
>
>
>
>
>
>
>


[As partes desta mensagem que não continham texto foram removidas]

#3638 De: "Sergio de Andrade" <sergio.ophus@...>
Data: Ter, 5 de Set de 2006 1:22 pm
Assunto: Re: baaChart Dúvida
xr32004
Enviar e-mail Enviar e-mail
 
André, muito obrigado pelas dicas.. eu abandonei esta classe, achei ela
muito limitada.. estou encontrei uma outra que está me atendendo
perfeitamente.

:D


valew

2006/9/3, André Mauricio Garcia <andre.moe@...>:
>
> Você só deev usá-la em u, arquivo separado e chamar este arquivo no src da
> tag img (Ex: <img src="imagem.php" />).
> Daí fica a seu critério a amneira como irá passar seus parâmetros para
> imagem, seja via GET, vias SESSION...
> Para gerar imagens somente desta maneira mesmo. Não conheço outras.
> Já vi umas classes "malandras" que geram gráficos utilizando tabelas, mas
> não recomendo.
>
> Abraço
>
> 2006/9/1, Sergio de Andrade <sergio.ophus@...>:
>
> >
> > André, quer dizer que neste caso não há como eu utilizar esta classe
> para
> > gerar meus gráficos, incrementando meus phps....?!?
> > como eu poderia utilizar este gráfico separado... tipo num pop-up ???
> >
> > vc conhece alguma outra classe parecida, sem estes headers ??
> >
> >
> > att
> >
> > 2006/8/31, André Mauricio Garcia <andre.moe@...>:
> >
> > >
> > > Nunca utilizei esta classe, mas já utilizei diversas outras.
> > > Normalmente elas utilizam um "header" de imagem. Então é bem provável
> > que
> > > vc tenha que usá-la em um arquivo separado (imagem.php, por exemplo).
> > > Caso vc inprima alguma coisa, como seu simples "print 'teste';" o
> header
> > > já não poderá mais ser alterado, logo a classe pára de funcionar.
> > >
> > > Att.
> > > André
> > >
> > >
> > >
> > > ----- Original Message -----
> > >   From: Sergio de Andrade
> > >   To: php-sp@...
> > >   Sent: Thursday, August 31, 2006 1:51 PM
> > >   Subject: [php-sp] baaChart Dúvida
> > >
> > >
> > >   Galera, sou novo nesta grupo, parabéns a todos que usam e colaboram,
> > >   trocando informações.
> > >
> > >   Gostaria de saber se alguem de vocês ja utilizaram ou utilizam a
> > >   classe baaChart
> > >   para gerar gráficos estatísticos.
> > >   Para utilizar a a classe estou usando algo do tipo:
> > >
> > >
> > >
> >
>
#-------------------------------------------------------------------------------\
--
> > >
> > >   include('baaChart.php');
> > >       $mygraph = new baaChart(600);
> > >       $mygraph->setTitle('VENDAS UFAC','Jan - Jun 2002');
> > >       $mygraph->setXLabels("Jan,Feb,Mar,Apr,May,Jun");
> > >
> > >
> > >
> >
> $mygraph->addDataSeries('C',COLS_STACKED,"25,30,35,40,30,35","Alimentos");
> > >       $mygraph->addDataSeries('C',0,"65,70,80,90,75,48","Promocoes");
> > >
> $mygraph->addDataSeries('C',0,"12,18,25,20,22,30","Emprestimos");
> > >       $mygraph->addDataSeries('C',0,"50,60,75,80,60,75","Academia");
> > >       $mygraph->addDataSeries('L',3,"30,45,50,55,52,60","Outros");
> > >       $mygraph->setBgColor(0,0,0,1);  //transparent background
> > >       $mygraph->setChartBgColor(0,0,0,1);  //as background
> > >       $mygraph->setXAxis("Mes",1);
> > >       $mygraph->setYAxis("Vendas (R$2.000,00)",0,250,50,1);
> > >       $mygraph->drawGraph();
> > >
> > >
> > >
> >
> #-----------------------------------------------------------------------------
> > >
> > >   Funciona perfeitamente, mas se eu tentar inserir algo abaixo  ou
> acima
> > > deste
> > >   bloco de chamadas, como por exemplo(um simples: print "teste";) o
> > código
> > > não
> > >   funciona.
> > >   Alguem poderia me dar uma luz !?
> > >
> > >
> > >
> > >   atenciosamente
> > >   --
> > >   Sergio de Andrade Lopes
> > >   (11) 3244-3580
> > >   (11) 8168-5560
> > >   TI - Microinformática
> > >   Associação Comercial São Paulo
> > >
> > >
> > >   [As partes desta mensagem que não continham texto foram removidas]
> > >
> > >
> > >
> > >
> > >
> > >
> > > [As partes desta mensagem que não continham texto foram removidas]
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > --
>
> > Sergio de Andrade Lopes
> > (11) 3244-3580
> > (11) 8168-5560
> > TI - Microinformática
> > Associação Comercial São Paulo
> >
> >
> > [As partes desta mensagem que não continham texto foram removidas]
> >
> >
> >
> >
> >
> >
>
>
>
> --
> "Primeiro eles o ignoram. Depois riem de você. Então eles o combatem. Aí
> você vence!"
> --Mohandas Gandhi
>
>
>
> [As partes desta mensagem que não continham texto foram removidas]
>
>
>
>
>
>



--
Sergio de Andrade Lopes
(11) 3244-3580
(11) 8168-5560
TI - Microinformática
Associação Comercial São Paulo


[As partes desta mensagem que não continham texto foram removidas]

#3639 De: Bruno <rokkr@...>
Data: Ter, 5 de Set de 2006 3:30 pm
Assunto: Re: Progresso durante processamento
urge2000
Enviar e-mail Enviar e-mail
 
creio eu, q só usando AJAX...

At 12:06 5/9/2006, you wrote:

>Como vão Colegas?
>
>Tenho um script que processa uma grande quantidade de registros gerando
>totalizadores em uma tabela de resultados.
>
>Como posso durante esse processo, exibir o progresso desse processamento?
>
>Grato,
>
>Haroldo
>
>
>[As partes desta mensagem que não continham texto foram removidas]
>
>


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/437 - Release Date: 4/9/2006

mensagens 3610 - 3639 de 15751   Mais antigos  |  < Mais antigos  |  Mais recentes >  |  Mais recentes
mensagens 3610 - 3639 de 15751   Mais antigos  |  < Mais antigos  |  Mais recentes >  |  Mais recentes
Avançado

Copyright © 2010 Yahoo! do Brasil Internet Ltda. Todos os direitos reservados.
Política de Privacidade - Termos do Serviço - Diretrizes - Ajuda