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?