Clipper On Line • Ver Tópico - Gráfico XY..

Gráfico XY..

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

 

Gráfico XY..

Mensagempor cjp » 15 Fev 2020 23:31

Consegui compilar este teu último exemplo e funcionou.

Só ainda não consegui entender muito bem.

Não vi onde foi definido as linhas, onde estão 2500, 5000, 7500 etc. Preciso mudar os valores.

Também tentei incluir mais valores em aValor. Acresci valores em aValor, mas o gráfico não foi alterado.

Também precisaria incluir novos valores em aMeses, mas deu erro.
Inacio de Carvalho Neto
cjp
Usuário Nível 6

Usuário Nível 6
 
Mensagens: 1527
Data de registro: 19 Nov 2010 21:29
Cidade/Estado: paraná
Curtiu: 10 vezes
Mens.Curtidas: 20 vezes

Gráfico XY..

Mensagempor JoséQuintas » 17 Fev 2020 16:09

   LOCAL aBarras := { "BARRA-1", "BARRA-2", "BARRA-3" }
   LOCAL aMeses := { "JAN", "FEV", "MAR", "ABR", "MAI" }
   LOCAL aValor := { ;
      { 1000, 2000, 3000, 4000, 5000 }, ;
      { 3000, 4000, 5000, 6000, 7000 }, ;
      { 5000, 6000, 7000, 5000, 4000 } }
oGrafico:nGradeCount := 5


Faz tanto tempo que nem lembro mais, mas olhando o fonte, se fosse só um valor:
LOCAL aBarras := { "SO-UM" }
LOCAL aMeses := { "JAN", "FEV", "MAR", "ABR", "MAI" }
aValor := { ;
   { 1000, 2000, 3000, 4000, 5000 } }
oGrafico:nGradeCount := 1


A partir daí, se aumentar a quantidade de meses, precisa ajustar o tamanho dos arrays e nGradeCount.
E se aumentar quantas colunas vai comparar, aumentar os títulos e os arrays.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18013
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Gráfico XY..

Mensagempor cjp » 25 Abr 2020 18:33

Por favor, preciso de ajuda. Estou tentando usar este gráfico, mas estou tendo problema para enquadrá-lo dentro da minha tela de consulta. Preciso colocá-lo num canto específico e pequeno da tela.

Minha função está assim:

function grafico(menorgeral,dtmenorgeral,maiorgeral,dtmaiorgeral,menor30dias,dtmenor30dias,maior30dias,dtmaior30dias,ultima,dtultima)

         LOCAL aBarras := { "SO-UM" }
         LOCAL aMeses := { dtmenorgeral, dtmaiorgeral, dtmenor30dias, dtmaior30dias, dtultima }
         LOCAL aValor := { ;
         { menorgeral, maiorgeral, menor30dias, maior30dias, ultima } }
         LOCAL oGrafico

#ifdef FlagShip
   oGrafico := BarChartClass{}
#else
   oGrafico := BarChartClass():New()
#endif
   ? ValType( oGrafico )
   Inkey(0)
   oGrafico:nTop := 20
   oGrafico:nLeft := 30
   oGrafico:nBottom := MaxRow() - 3
   oGrafico:nRight := MaxCol()
   oGrafico:nGradeCount := 5
   oGrafico:cTxtTitle := "Cotações"
   oGrafico:aTxtSubList := aBarras
   oGrafico:aTxtBarList := aMeses
   oGrafico:aValues := aValor
   oGrafico:Show()
   Inkey(0)

   RETURN
   
   /*
ZE_CHART - Gráfico de barras simples
2016.05 - José Quintas
*/

#ifndef FlagShip
   #include "hbclass.ch"
#else
   #define INIT :=
   #define VAR  EXPORT
#endif

CLASS BarChartClass

   VAR    cTxtTitle            INIT ""
   VAR    aTxtBarList          INIT {}
   VAR    aTxtSubList          INIT {}
   VAR    aValues              INIT {}
   VAR    nTop                 INIT 0
   VAR    nLeft                INIT 0
   VAR    nBottom              INIT MaxRow()
   VAR    nRight               INIT MaxCol()
   VAR    nMaxValue            INIT 10
   VAR    nIncrement           INIT 1
   VAR    nGradeCount          INIT 5
#ifndef FlagShip
   METHOD Show()
   METHOD CalcMaxValue()
   METHOD ShowEmpty()
   METHOD ShowColBar()
   METHOD ShowColSub( nNumBar, nColuna, nLarguraColuna )
   METHOD BarColor( nNumColor )

   ENDCLASS
#endif

METHOD Show() CLASS BarChartClass

   ::CalcMaxValue()
   Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight, 0 )
   ::ShowEmpty()
   ::ShowColBar()

   RETURN NIL

METHOD CalcMaxValue() CLASS BarChartClass

   LOCAL nCont, nCont2

   FOR nCont = 1 TO Len( ::aValues )
      FOR nCont2 = 1 TO Len( ::aValues[ nCont ] )
         ::nMaxValue := Max( ::nMaxValue, ::aValues[ nCont, nCont2 ] )
      NEXT
   NEXT
   DO WHILE .t.
      ::nIncrement *= 10
      IF ::nIncrement * ::nGradeCount > ::nMaxValue
         EXIT
      ENDIF
   ENDDO
   IF ( ::nIncrement * ::nGradeCount / 2 ) > ::nMaxValue
      ::nIncrement := ::nIncrement / 2
   ENDIF
   IF ( ::nIncrement * ::nGradeCount / 2 ) > ::nMaxValue
      ::nIncrement := ::nIncrement / 2
   ENDIF
   ::nMaxValue  := ::nIncrement * ::nGradeCount

   RETURN NIL

METHOD ShowEmpty()  CLASS BarChartClass

   LOCAL nCont

   // Título
   @ ::nTop, Int( ( ::nRight - ::nLeft - 1 - Len( ::cTxtTitle ) ) / 2 ) SAY " " + ::cTxtTitle + " " COLOR "N/W"

   // Linhas horizontal/vertical
   @ ::nTop + 2, ::nLeft + 12 TO ::nBottom - 3, ::nLeft + 12
   @ ::nBottom - 3, ::nLeft + 12 TO ::nBottom - 3, ::nRight - 2

   // Valores da barra vertical
   FOR nCont = 1 TO ::nGradeCount
      @ ::nBottom - 3 - ( ( ::nBottom - ::nTop - 6 ) / ::nGradeCount * nCont ), ::nLeft SAY nCont * ::nIncrement PICTURE "9999999999"
      @ Row(), ::nLeft + 13 TO Row(), ::nRight - 3
   NEXT

   // Legenda
   @ ::nBottom - 1, ::nLeft SAY ""
   FOR nCont = 1 TO Len( ::aTxtSubList )
      @ Row(), Col() + 2 SAY Space(2) COLOR ::BarColor( nCont )
      @ Row(), Col() + 2 SAY ::aTxtSubList[ nCont ]
   NEXT

   RETURN NIL

METHOD ShowColBar()  CLASS BarChartClass

   LOCAL nCont, nLarguraColuna

   nLarguraColuna := Int( ( ::nRight - ::nLeft - 11 ) / ( Len( ::aValues[ 1 ] ) + 1 ) )

   // cada grupo do gráfico
   FOR nCont = 1 TO Len( ::aTxtBarList )
      ::ShowColSub( nCont, 13 + ( ( nCont - 1 ) * nLarguraColuna ), nLarguraColuna )
   NEXT

   RETURN NIL

METHOD ShowColSub( nNumBar, nColuna, nLarguraColuna ) CLASS BarChartClass

   LOCAL nCont, cColorOld, nRow

   cColorOld := SetColor()

   // barras de comparação
   FOR nCont = 1 TO Len( ::aTxtSubList )
      nRow := ::nBottom - ( ( ::nBottom - ::nTop - 2 ) * ::aValues[ nCont, nNumbar ] / ::nMaxValue )
      SetColor( ::BarColor( nCont ) )
      @ nRow, nColuna + nCont CLEAR TO ::nBottom - 4, nColuna + nCont
   NEXT
   SetColor( cColorOld )
   // legenda de cada coluna do gráfico
   @ ::nBottom - 2, nColuna + 1 SAY Pad( ::aTxtBarList[ nNumBar ], nLarguraColuna - 1 )

   RETURN NIL

METHOD BarColor( nNumColor ) CLASS BarChartClass

   DO CASE
   CASE nNumColor == 1 ; RETURN "9/9"
   CASE nNumColor == 2 ; RETURN "14/14"
   CASE nNumColor == 3 ; RETURN "15/15"
   CASE nNumColor == 4 ; RETURN "11/11"
   CASE nNumColor == 5 ; RETURN "12/12"
   ENDCASE

   RETURN "N/W"


O resultado está como no print anexo.

Alguém pode me ajudar?
Anexos
grafico-harbour.png
grafico-harbour.png (7.25 KiB) Visualizado 3916 vezes
Inacio de Carvalho Neto
cjp
Usuário Nível 6

Usuário Nível 6
 
Mensagens: 1527
Data de registro: 19 Nov 2010 21:29
Cidade/Estado: paraná
Curtiu: 10 vezes
Mens.Curtidas: 20 vezes

Gráfico XY..

Mensagempor JoséQuintas » 25 Abr 2020 21:24

Precisou corrigir aqui:

METHOD ShowColBar()  CLASS BarChartClass

   LOCAL nCont, nLarguraColuna

   nLarguraColuna := Int( ( ::nRight - ::nLeft - 11 ) / ( Len( ::aValues[ 1 ] ) + 1 ) )

   // cada grupo do gráfico
   FOR nCont = 1 TO Len( ::aTxtBarList )
      ::ShowColSub( nCont, ::nLeft + 13 + ( ( nCont - 1 ) * nLarguraColuna ), nLarguraColuna )
   NEXT

   RETURN NIL


Teste



PROCEDURE Main

   SetMode( 40, 100 )
   CLS
   Grafico( ;
      "Cotacoes", ;
      { "SOUM" }, ;
      { "01/01/80", "02/02/,80", "03/03/80", "04/04/80", "05/05/80" }, ;
      { { 5, 6, 7, 8, 9 } } )

   RETURN

FUNCTION Grafico( cTitulo, aBarras, aMeses, aValues )

   LOCAL oGrafico

   oGrafico := BarChartClass():New()
   oGrafico:nTop        := 20
   oGrafico:nLeft       := 30
   oGrafico:nBottom     := MaxRow() - 3
   oGrafico:nRight      := MaxCol()
   oGrafico:nGradeCount := 5
   oGrafico:cTxtTitle   := cTitulo
   oGrafico:aTxtSubList := aBarras
   oGrafico:aTxtBarList := aMeses
   oGrafico:aValues     := aValues
   oGrafico:Show()
   Inkey(0)

   RETURN NIL


grafico.png
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18013
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Gráfico XY..

Mensagempor cjp » 26 Abr 2020 01:26

Este código está dando o seguinte erro:

Ocorreu o erro: Error BASE/1093 Erro nos parâmetros: MAX


Imagino que seja nesta linha:

         ::nMaxValue := Max( ::nMaxValue, ::aValues[ nCont, nCont2 ] )
Inacio de Carvalho Neto
cjp
Usuário Nível 6

Usuário Nível 6
 
Mensagens: 1527
Data de registro: 19 Nov 2010 21:29
Cidade/Estado: paraná
Curtiu: 10 vezes
Mens.Curtidas: 20 vezes

Gráfico XY..

Mensagempor JoséQuintas » 26 Abr 2020 13:22

A mensagem é de que o parâmetro não pode ser usado na função max()
Verifique se passou texto ou outra coisa ao invés de número.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18013
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Gráfico XY..

Mensagempor cjp » 26 Abr 2020 15:29

Eu não alterei absolutamente nada do que vc postou.

Veja como está a função inteira:

        SetMode( 40, 100 )
   CLS
   Grafico( ;
      "Cotacoes", ;
      { "SOUM" }, ;
      { "01/01/80", "02/02/,80", "03/03/80", "04/04/80", "05/05/80" }, ;
      { { 5, 6, 7, 8, 9 } } )

FUNCTION Grafico( cTitulo, aBarras, aMeses, aValues )

   LOCAL oGrafico

   oGrafico := BarChartClass():New()
   oGrafico:nTop        := 20
   oGrafico:nLeft       := 30
   oGrafico:nBottom     := MaxRow() - 3
   oGrafico:nRight      := MaxCol()
   oGrafico:nGradeCount := 5
   oGrafico:cTxtTitle   := cTitulo
   oGrafico:aTxtSubList := aBarras
   oGrafico:aTxtBarList := aMeses
   oGrafico:aValues     := aValues
   oGrafico:Show()
   Inkey(0)

   RETURN NIL

#ifndef FlagShip
   #include "hbclass.ch"
#else
   #define INIT :=
   #define VAR  EXPORT
#endif

CLASS BarChartClass

   VAR    cTxtTitle            INIT ""
   VAR    aTxtBarList          INIT {}
   VAR    aTxtSubList          INIT {}
   VAR    aValues              INIT {}
   VAR    nTop                 INIT 0
   VAR    nLeft                INIT 0
   VAR    nBottom              INIT MaxRow()
   VAR    nRight               INIT MaxCol()
   VAR    nMaxValue            INIT 10
   VAR    nIncrement           INIT 0.3
   VAR    nGradeCount          INIT 3
#ifndef FlagShip
   METHOD Show()
   METHOD CalcMaxValue()
   METHOD ShowEmpty()
   METHOD ShowColBar()
   METHOD ShowColSub( nNumBar, nColuna, nLarguraColuna )
   METHOD BarColor( nNumColor )

   ENDCLASS
#endif

METHOD Show() CLASS BarChartClass

   ::CalcMaxValue()
   Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight, 0 )
   ::ShowEmpty()
   ::ShowColBar()

   RETURN NIL

METHOD CalcMaxValue() CLASS BarChartClass

   LOCAL nCont, nCont2

   FOR nCont = 1 TO Len( ::aValues )
      FOR nCont2 = 1 TO Len( ::aValues[ nCont ] )
         ::nMaxValue := Max( ::nMaxValue, ::aValues[ nCont, nCont2 ] )
      NEXT
   NEXT
   DO WHILE .t.
      ::nIncrement *= 10
      IF ::nIncrement * ::nGradeCount > ::nMaxValue
         EXIT
      ENDIF
   ENDDO
   IF ( ::nIncrement * ::nGradeCount / 2 ) > ::nMaxValue
      ::nIncrement := ::nIncrement / 2
   ENDIF
   IF ( ::nIncrement * ::nGradeCount / 2 ) > ::nMaxValue
      ::nIncrement := ::nIncrement / 2
   ENDIF
   ::nMaxValue  := ::nIncrement * ::nGradeCount

   RETURN NIL

METHOD ShowEmpty()  CLASS BarChartClass

   LOCAL nCont

   // Título
   @ ::nTop, Int( ( ::nRight - ::nLeft - 1 - Len( ::cTxtTitle ) ) / 2 ) SAY " " + ::cTxtTitle + " " COLOR "N/W"

   // Linhas horizontal/vertical
   @ ::nTop + 2, ::nLeft + 12 TO ::nBottom - 3, ::nLeft + 12
   @ ::nBottom - 3, ::nLeft + 12 TO ::nBottom - 3, ::nRight - 2

   // Valores da barra vertical
   FOR nCont = 1 TO ::nGradeCount
      @ ::nBottom - 3 - ( ( ::nBottom - ::nTop - 6 ) / ::nGradeCount * nCont ), ::nLeft SAY nCont * ::nIncrement PICTURE "9999999999"
      @ Row(), ::nLeft + 13 TO Row(), ::nRight - 3
   NEXT

*   // Legenda
*   @ ::nBottom - 1, ::nLeft SAY ""
*   FOR nCont = 1 TO Len( ::aTxtSubList )
*      @ Row(), Col() + 2 SAY Space(2) COLOR ::BarColor( nCont )
*      @ Row(), Col() + 2 SAY ::aTxtSubList[ nCont ]
*   NEXT

   RETURN NIL

   
METHOD ShowColBar()  CLASS BarChartClass

   LOCAL nCont, nLarguraColuna

   nLarguraColuna := Int( ( ::nRight - ::nLeft - 11 ) / ( Len( ::aValues[ 1 ] ) + 1 ) )

   // cada grupo do gráfico
   FOR nCont = 1 TO Len( ::aTxtBarList )
      ::ShowColSub( nCont, 13 + ( ( nCont - 1 ) * nLarguraColuna ), nLarguraColuna )
   NEXT

   RETURN NIL

METHOD ShowColSub( nNumBar, nColuna, nLarguraColuna ) CLASS BarChartClass

   LOCAL nCont, cColorOld, nRow

   cColorOld := SetColor()

   // barras de comparação
   FOR nCont = 1 TO Len( ::aTxtSubList )
      nRow := ::nBottom - ( ( ::nBottom - ::nTop - 2 ) * ::aValues[ nCont, nNumbar ] / ::nMaxValue )
      SetColor( ::BarColor( nCont ) )
      @ nRow, nColuna + nCont CLEAR TO ::nBottom - 4, nColuna + nCont
   NEXT
   SetColor( cColorOld )
   // legenda de cada coluna do gráfico
   @ ::nBottom - 2, nColuna + 21 SAY Pad( ::aTxtBarList[ nNumBar ], nLarguraColuna - 1 )

   RETURN NIL

METHOD BarColor( nNumColor ) CLASS BarChartClass

   DO CASE
   CASE nNumColor == 1 ; RETURN "9/9"
   CASE nNumColor == 2 ; RETURN "14/14"
   CASE nNumColor == 3 ; RETURN "15/15"
   CASE nNumColor == 4 ; RETURN "11/11"
   CASE nNumColor == 5 ; RETURN "12/12"
   ENDCASE

   RETURN "N/W"   

   
Inacio de Carvalho Neto
cjp
Usuário Nível 6

Usuário Nível 6
 
Mensagens: 1527
Data de registro: 19 Nov 2010 21:29
Cidade/Estado: paraná
Curtiu: 10 vezes
Mens.Curtidas: 20 vezes

Gráfico XY..

Mensagempor JoséQuintas » 26 Abr 2020 16:40

Baixei de novo o fonte que postou, e fiz a alteração que mencionei.

PROCEDURE Main

   SetMode( 40, 100 )
   CLS
   Grafico( ;
      "Cotacoes", ;
      { "SOUM" }, ;
      { "01/01/80", "02/02/,80", "03/03/80", "04/04/80", "05/05/80" }, ;
      { { 5, 6, 7, 8, 9 } } )

   RETURN

FUNCTION Grafico( cTitulo, aBarras, aMeses, aValues )

   LOCAL oGrafico

   oGrafico := BarChartClass():New()
   oGrafico:nTop        := 20
   oGrafico:nLeft       := 30
   oGrafico:nBottom     := MaxRow() - 3
   oGrafico:nRight      := MaxCol()
   oGrafico:nGradeCount := 5
   oGrafico:cTxtTitle   := cTitulo
   oGrafico:aTxtSubList := aBarras
   oGrafico:aTxtBarList := aMeses
   oGrafico:aValues     := aValues
   oGrafico:Show()
   Inkey(0)

   RETURN NIL

#ifndef FlagShip
   #include "hbclass.ch"
#else
   #define INIT :=
   #define VAR  EXPORT
#endif

CLASS BarChartClass

   VAR    cTxtTitle            INIT ""
   VAR    aTxtBarList          INIT {}
   VAR    aTxtSubList          INIT {}
   VAR    aValues              INIT {}
   VAR    nTop                 INIT 0
   VAR    nLeft                INIT 0
   VAR    nBottom              INIT MaxRow()
   VAR    nRight               INIT MaxCol()
   VAR    nMaxValue            INIT 10
   VAR    nIncrement           INIT 0.3
   VAR    nGradeCount          INIT 3
#ifndef FlagShip
   METHOD Show()
   METHOD CalcMaxValue()
   METHOD ShowEmpty()
   METHOD ShowColBar()
   METHOD ShowColSub( nNumBar, nColuna, nLarguraColuna )
   METHOD BarColor( nNumColor )

   ENDCLASS
#endif

METHOD Show() CLASS BarChartClass

   ::CalcMaxValue()
   Scroll( ::nTop, ::nLeft, ::nBottom, ::nRight, 0 )
   ::ShowEmpty()
   ::ShowColBar()

   RETURN NIL

METHOD CalcMaxValue() CLASS BarChartClass

   LOCAL nCont, nCont2

   FOR nCont = 1 TO Len( ::aValues )
      FOR nCont2 = 1 TO Len( ::aValues[ nCont ] )
         ::nMaxValue := Max( ::nMaxValue, ::aValues[ nCont, nCont2 ] )
      NEXT
   NEXT
   DO WHILE .t.
      ::nIncrement *= 10
      IF ::nIncrement * ::nGradeCount > ::nMaxValue
         EXIT
      ENDIF
   ENDDO
   IF ( ::nIncrement * ::nGradeCount / 2 ) > ::nMaxValue
      ::nIncrement := ::nIncrement / 2
   ENDIF
   IF ( ::nIncrement * ::nGradeCount / 2 ) > ::nMaxValue
      ::nIncrement := ::nIncrement / 2
   ENDIF
   ::nMaxValue  := ::nIncrement * ::nGradeCount

   RETURN NIL

METHOD ShowEmpty()  CLASS BarChartClass

   LOCAL nCont

   // Título
   @ ::nTop, Int( ( ::nRight - ::nLeft - 1 - Len( ::cTxtTitle ) ) / 2 ) SAY " " + ::cTxtTitle + " " COLOR "N/W"

   // Linhas horizontal/vertical
   @ ::nTop + 2, ::nLeft + 12 TO ::nBottom - 3, ::nLeft + 12
   @ ::nBottom - 3, ::nLeft + 12 TO ::nBottom - 3, ::nRight - 2

   // Valores da barra vertical
   FOR nCont = 1 TO ::nGradeCount
      @ ::nBottom - 3 - ( ( ::nBottom - ::nTop - 6 ) / ::nGradeCount * nCont ), ::nLeft SAY nCont * ::nIncrement PICTURE "9999999999"
      @ Row(), ::nLeft + 13 TO Row(), ::nRight - 3
   NEXT

*   // Legenda
*   @ ::nBottom - 1, ::nLeft SAY ""
*   FOR nCont = 1 TO Len( ::aTxtSubList )
*      @ Row(), Col() + 2 SAY Space(2) COLOR ::BarColor( nCont )
*      @ Row(), Col() + 2 SAY ::aTxtSubList[ nCont ]
*   NEXT

   RETURN NIL

METHOD ShowColBar()  CLASS BarChartClass

   LOCAL nCont, nLarguraColuna

   nLarguraColuna := Int( ( ::nRight - ::nLeft - 11 ) / ( Len( ::aValues[ 1 ] ) + 1 ) )

   // cada grupo do gráfico
   FOR nCont = 1 TO Len( ::aTxtBarList )
      ::ShowColSub( nCont, ::nLeft + 13 + ( ( nCont - 1 ) * nLarguraColuna ), nLarguraColuna )
   NEXT

   RETURN NIL

METHOD ShowColSub( nNumBar, nColuna, nLarguraColuna ) CLASS BarChartClass

   LOCAL nCont, cColorOld, nRow

   cColorOld := SetColor()

   // barras de comparação
   FOR nCont = 1 TO Len( ::aTxtSubList )
      nRow := ::nBottom - ( ( ::nBottom - ::nTop - 2 ) * ::aValues[ nCont, nNumbar ] / ::nMaxValue )
      SetColor( ::BarColor( nCont ) )
      @ nRow, nColuna + nCont CLEAR TO ::nBottom - 4, nColuna + nCont
   NEXT
   SetColor( cColorOld )
   // legenda de cada coluna do gráfico
   @ ::nBottom - 2, nColuna + 21 SAY Pad( ::aTxtBarList[ nNumBar ], nLarguraColuna - 1 )

   RETURN NIL

METHOD BarColor( nNumColor ) CLASS BarChartClass

   DO CASE
   CASE nNumColor == 1 ; RETURN "9/9"
   CASE nNumColor == 2 ; RETURN "14/14"
   CASE nNumColor == 3 ; RETURN "15/15"
   CASE nNumColor == 4 ; RETURN "11/11"
   CASE nNumColor == 5 ; RETURN "12/12"
   ENDCASE

   RETURN "N/W"

FUNCTION AppUserName(); RETURN ""
FUNCTION AppVersaoExe(); RETURN ""


Exatamente esse fonte compilado

grafico.png
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18013
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Gráfico XY..

Mensagempor lugab » 27 Abr 2020 08:40

Bom dia....

Inácio, o erro ta nesse parâmetro: "02/02/,80"

Essa vírgula ta aí de gaiata
lugab
lugab
Colaborador

Colaborador
 
Mensagens: 843
Data de registro: 19 Mai 2009 15:58
Curtiu: 126 vezes
Mens.Curtidas: 38 vezes

Gráfico XY..

Mensagempor JoséQuintas » 27 Abr 2020 12:38

lugab escreveu:Inácio, o erro ta nesse parâmetro: "02/02/,80"
Essa vírgula ta aí de gaiata


Esse é um texto comum, usado como legenda.
Pode ver na imagem que saiu exatamente desse jeito.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18013
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Gráfico XY..

Mensagempor cjp » 27 Abr 2020 23:34

Este último código que vc postou funcionou.

Mas eu ainda preciso fazer ajustes para o gráfico ficar ainda menor, mais no canto inferior direito da tela.

Daí, cada mudança que eu faço, bagunça tudo na tela, e eu não sei acertar.

Por favor, me ajude: coloque o gráfico entre as seguintes coordenadas: maxrow()-10,maxcol()-30,maxrow(),maxcol().

Estou usando setmode(41,165) nesta máquina, mas em outras preciso usar diferente. Por isso preciso usar maxrow() e maxcol() como referências, sem valores fixos.
Inacio de Carvalho Neto
cjp
Usuário Nível 6

Usuário Nível 6
 
Mensagens: 1527
Data de registro: 19 Nov 2010 21:29
Cidade/Estado: paraná
Curtiu: 10 vezes
Mens.Curtidas: 20 vezes

Gráfico XY..

Mensagempor JoséQuintas » 29 Abr 2020 14:04

Na prática abro uma janela com o gráfico, e nunca reparei dele não ajustar automático pra área definida.
Vou ter que fazer testes.

Mas de cara, se ele reservar o tamanho pro texto, e o texto for muito grande, não vai caber, aí entra cortar o texto da leganda também.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg, multithread, dbfcdx, ADO+MySql, PNotepad
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar de usuário

JoséQuintas
Membro Master

Membro Master
 
Mensagens: 18013
Data de registro: 26 Fev 2007 11:59
Cidade/Estado: São Paulo-SP
Curtiu: 15 vezes
Mens.Curtidas: 1206 vezes

Gráfico XY..

Mensagempor cjp » 29 Abr 2020 15:50

Sim, a legenda é desnecessária. Se puder me fazer o favor de colocar nas medidas que te pedi, agradeceria muito.
Inacio de Carvalho Neto
cjp
Usuário Nível 6

Usuário Nível 6
 
Mensagens: 1527
Data de registro: 19 Nov 2010 21:29
Cidade/Estado: paraná
Curtiu: 10 vezes
Mens.Curtidas: 20 vezes

Anterior



Retornar para Contribuições, Dicas e Tutoriais

Quem está online

Usuários vendo este fórum: Nenhum usuário registrado online e 19 visitantes


Ola Amigo, espero que meu site e forum tem lhe beneficiado, com exemplos e dicas de programacao.
Entao divulgue o link da Doacao abaixo para seus amigos e redes sociais ou faça uma doacao para o site forum...
MUITO OBRIGADO PELA SUA DOACAO!
Faça uma doação para o forum
cron
v
Olá visitante, seja bem-vindo ao Fórum Clipper On Line!
Efetue o seu login ou faça o seu Registro