RMChart

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Encontrei nos exemplos do Harbour.
a := 567.89 ; ? ">", a, b := hb_DynCall( { "TESTD" , cFileName, hb_bitOr( HB_DYN_CTYPE_DOUBLE , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_DOUBLE }, a ), _ISOK_( a, b )
a := 567.89 ; ? ">", a, b := hb_DynCall( { "TESTF" , cFileName, hb_bitOr( HB_DYN_CTYPE_FLOAT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_FLOAT }, a ), _ISOK_( a, b )
a := -( 2 ^ 7 ) ; ? ">", a, b := hb_DynCall( { "TESTC" , cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_CHAR }, a ), _ISOK_( a, b )
a := ( 2 ^ 8 ) - 1 ; ? ">", a, b := hb_DynCall( { "TESTUC", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_CHAR_UNSIGNED }, a ), _ISOK_( a, b )
a := -( 2 ^ 15 ) ; ? ">", a, b := hb_DynCall( { "TESTS" , cFileName, hb_bitOr( HB_DYN_CTYPE_SHORT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_SHORT }, a ), _ISOK_( a, b )
a := ( 2 ^ 16 ) - 1 ; ? ">", a, b := hb_DynCall( { "TESTUS", cFileName, hb_bitOr( HB_DYN_CTYPE_SHORT_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_SHORT_UNSIGNED }, a ), _ISOK_( a, b )
a := -( 2 ^ 31 ) ; ? ">", a, b := hb_DynCall( { "TESTI" , cFileName, hb_bitOr( HB_DYN_CTYPE_INT , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_INT }, a ), _ISOK_( a, b )
a := ( 2 ^ 32 ) - 1 ; ? ">", a, b := hb_DynCall( { "TESTUI", cFileName, hb_bitOr( HB_DYN_CTYPE_INT_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_INT_UNSIGNED }, a ), _ISOK_( a, b )
a := -( 2 ^ 31 ) ; ? ">", a, b := hb_DynCall( { "TESTL" , cFileName, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LONG }, a ), _ISOK_( a, b )
a := ( 2 ^ 32 ) - 1 ; ? ">", a, b := hb_DynCall( { "TESTUL", cFileName, hb_bitOr( HB_DYN_CTYPE_LONG_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LONG_UNSIGNED }, a ), _ISOK_( a, b )
a := -( 2 ^ 63 ) ; ? ">", a, b := hb_DynCall( { "TEST6" , cFileName, hb_bitOr( HB_DYN_CTYPE_LLONG , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LLONG }, a ), _ISOK_( a, b )
a := 18446744073709600000 ; ? ">", a, b := hb_DynCall( { "TESTU6", cFileName, hb_bitOr( HB_DYN_CTYPE_LLONG_UNSIGNED , HB_DYN_CALLCONV_CDECL ), HB_DYN_CTYPE_LLONG_UNSIGNED }, a ), _ISOK_( a, b )
a := "hello world!" ; ? ">", a, b := hb_DynCall( { "TESTST", cFileName, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL ) }, a ), _ISOK_( a, b )
O mais estranho é que não tem #define em lugar nenhum pra isso tudo.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Tem sim, eu estava procurando tudo como *CALL_CONV*
Em hbdyn.ch

Código: Selecionar todos

#define HB_DYN_CTYPE_DOUBLE                 0x0000007
#define HB_DYN_CTYPE_DOUBLE_PTR             0x0000107
Ao que parece, não é converter antes, e sim converter durante a chamada.
Não tenho idéia de como isso funciona.... rs
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Deixando a parte técnica de lado, e usando chutes, conclui-se que os autores dos exemplos são uma bost.
Não usei porr. nenhuma de double., só uma rotina vinda do Clipper.

Ainda não conferi os valores.
teste.png
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

RMChart

Mensagem por asimoes »

Quintas,

Você tá me animando de novo, já estava pensando em usar aquela string maluca, como é que você chegou a esse resultado, é por dll mesmo?
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Função da antiga CTTools, hoje hbct FToc()

Código: Selecionar todos

#include "hbclass.ch"
#include "rmchart.ch"
#include "hbgtinfo.ch"
#include "hbdyn.ch"

FUNCTION Main

   LOCAL oCrt, cLegenda, cLabels, cTitulo, aDados, cImagem, cUnidade, cTextoVert, nMax, id_Chart, ctrgra1
   LOCAL oGrafico := RMChart():New(), nCont

   oCrt := WvgCrt():New( , , { -1, -1 }, { 25, 85 }, , .T. )
   oCrt:lModal := .T.
   oCrt:icon := "demo.ico"
   oCrt:create()
   oCrt:resizable := .F.
   hb_gtInfo( HB_GTI_WINTITLE, "Grafico com RmChart - Dll" )
   cLegenda := "Entradas*Saidas*Mais Um"
   cLabels := "Janeiro*Fevereiro*Março*Abril*Maio*Junho*Julho*Agosto*Setembro*Outubro*Novembro*Dezembro"
   cTitulo := "Gráfico de Teste"
   aDados := { { 225.25, 100.00, 100.00, 150.00, 250.00, 300.00, 25.00, 75.00, 300.00, 200.00, 325.00, 300.00 }, { 220.00, 100.00, 125.00, 300.00, 150.00, 125.00, 85.00, 50.00, 285.00, 275.00, 295.00, 280.00 }, { 125.25, 100.00, 100.00, 150.00, 250.00, 300.00, 25.00, 75.00, 300.00, 200.00, 325.00, 300.00 } }
   cImagem := ""
   cUnidade := "R$ "
   cTextoVert := ""
   nMax := 0
   id_Chart := 1

   FOR cTrGra1 := 1 TO Len( aDados )
      nMax := Max( nMax, aMax( aDados[ cTrGra1 ] ) )
   NEXT

   nMax := Round( ( Int( nMax / 10 ) * 10 ) + 10, 2 )

   oGrafico:CreateChart( hb_gtInfo( HB_GTI_WINHANDLE ), ID_CHART, 0, 0, 770, 400, Azure, RMC_CTRLSTYLE3DLIGHT, .F., cImagem, "", 0, 0 )
   oGrafico:AddRegion( ID_CHART, 0, 0, 760, 400, "RmChart", .F. )
   oGrafico:AddCaption( ID_CHART, 1, cTitulo, Transparent, Red, 9, .T. )
   oGrafico:AddGrid( ID_CHART, 1, LightBlue, .F., 20, 20, 685, 330, RMC_BICOLOR_LABELAXIS )
   oGrafico:AddLabelAxis( ID_CHART, 1, cLabels, 1, Len( aDados[ 1 ] ), RMC_LABELAXISBOTTOM, 8, Black, RMC_TEXTCENTER, Black, RMC_LINESTYLENONE, "" )
   oGrafico:AddDataAxis( ID_CHART, 1, RMC_DATAAXISRIGHT, 0.0, nMax, Len( aDados[ 1 ] ), 8, Black, Black, RMC_LINESTYLESOLID, 1, cUnidade, cTextoVert, "", RMC_TEXTCENTER )
   oGrafico:AddLegend( ID_CHART, 1, cLegenda, RMC_LEGEND_BOTTOM, Transparent, RMC_LEGENDNORECT, Red, 8, .T. )

   FOR nCont = 1 TO Len( aDados )
      oGrafico:AddBarSeries( ID_CHART, 1, aDados[ nCont ], 12, RMC_BARGROUP, RMC_BAR_FLAT_GRADIENT2, .F., 0, .F., 1, RMC_VLABEL_NONE, nCont, RMC_HATCHBRUSH_ONPRINTING )
   NEXT

   oGrafico:Draw( ID_CHART )

   Inkey( 0 )
   oCrt:destroy()
   oGrafico:Destroy()

   RETURN NIL

CREATE CLASS RmChart

   VAR  nHandle
   METHOD New()                    INLINE ::nHandle := hb_libLoad( "RMChart.dll" ), SELF
   METHOD Destroy()                INLINE hb_libFree( ::nHandle )
   METHOD CallDllStd( cName, ... ) INLINE hb_DynCall( { cName, ::nHandle, HB_DYN_CALLCONV_STDCALL }, ... )
   METHOD CreateChart( nCtrlId, nX, nY, nWidth, nHeight, nBackColor, nCtrlStyle, nExportOnly, sBgImage, sFontName, nBitmapBKColor, ... )
   METHOD AddRegion( nCtrlId, nLeft, nTop, nWidth, nHeight, sFooter, nShowBorder, ... )
   METHOD AddCaption( nCtrlId, nRegion, sCaption, nTitelBackColor, nTitelTextColor, nTitelFontSize, nTitelIsBold, ... )
   METHOD AddGrid( nCtrlId, nRegion, nBackColor, nAsGradient, nLeft, nTop, nWidth, nHeight, nBiColor, ... )
   METHOD AddLabelAxis( nCtrlId, nRegion, sLabels, nCont, nTickCount, nAlignment, nFontSize, nTextColor, nTextAlignment, nLineColor, nLineStyle, sText, ... )
   METHOD AddDataAxis( nCtrlId, nRegion, nAligment, nMinValue, nMaxValue, nTickCount, nFontSize, nTextColor, nLineColor, nLineStyle, nDecimalDigits, ;
      sUnit, sText, sLabels, nLabelAlignment, ... )
   METHOD AddLegend( nCtrlId, nRegion, sLegend, nLegendAlign, nLegendBackColor, nLegendStyle, nLegendTextColor, nLegendFontSize, nLegendIsBold, ... )
   METHOD AddBarSeries( nCtrlId, nRegion, nFirstDataValue, nDataValuesCount, nType, nStyle, ;
      nIsLucent, nColor, nIsHorizontal, nWhichDataAxis, nValueLabelOn, nPointsPerColumn, nHatchMode, ... )
   METHOD Draw( nCtrlId )

ENDCLASS

METHOD RMChart:CreateChart( nCtrlId, nX, nY, nWidth, nHeight, nBackColor, nCtrlStyle, nExportOnly, sBgImage, sFontName, nBitmapBKColor, ... )

   RETURN ::CallDllStd( "RMC_CREATECHART", nCtrlId, nX, nY, nWidth, nHeight, nBackColor, nCtrlStyle, nExportOnly, sBgImage, sFontName, nBitmapBKColor, ... )

METHOD RMChart:AddRegion( nCtrlId, nLeft, nTop, nWidth, nHeight, sFooter, nShowBorder, ... )

   RETURN ::CallDllStd( "RMC_ADDREGION", nCtrlId, nLeft, nTop, nWidth, nHeight, sFooter, nShowBorder, ... )

METHOD RMChart:AddCaption( nCtrlId, nRegion, sCaption, nTitelBackColor, nTitelTextColor, nTitelFontSize, nTitelIsBold, ... )

   RETURN ::CallDllStd( "RMC_ADDCAPTION", nCtrlId, nRegion, sCaption, nTitelBackColor, nTitelTextColor, nTitelFontSize, nTitelIsBold, ... )

METHOD RMChart:AddGrid( nCtrlId, nRegion, nBackColor, nAsGradient, nLeft, nTop, nWidth, nHeight, nBiColor, ... )

   RETURN ::CallDllStd( "RMC_ADDGRID", nCtrlId, nRegion, nBackColor, nAsGradient, nLeft, nTop, nWidth, nHeight, nBiColor, ... )

METHOD RMChart:AddLabelAxis( nCtrlId, nRegion, sLabels, nCont, nTickCount, nAlignment, nFontSize, nTextColor, nTextAlignment, nLineColor, nLineStyle, sText, ... )

   RETURN ::CallDllStd( "RMC_ADDLABELAXIS", nCtrlId, nRegion, sLabels, nCont, nTickCount, nAlignment, nFontSize, nTextColor, nTextAlignment, nLineColor, nLineStyle, sText, ... )

METHOD RMChart:AddDataAxis( nCtrlId, nRegion, nAligment, nMinValue, nMaxValue, nTickCount, nFontSize, nTextColor, nLineColor, nLineStyle, nDecimalDigits, ;
      sUnit, sText, sLabels, nLabelAlignment, ... )

   RETURN ::CallDllStd( "RMC_ADDDATAAXIS",   nCtrlId, nRegion, nAligment, nMinValue, nMaxValue, nTickCount, nFontSize, nTextColor, nLineColor, nLineStyle, nDecimalDigits, ;
      sUnit, sText, sLabels, nLabelAlignment, ... )

METHOD RMChart:AddLegend( nCtrlId, nRegion, sLegend, nLegendAlign, nLegendBackColor, nLegendStyle, nLegendTextColor, nLegendFontSize, nLegendIsBold, ... )

   RETURN ::CallDllStd( "RMC_ADDLEGEND", nCtrlId, nRegion, sLegend, nLegendAlign, nLegendBackColor, nLegendStyle, nLegendTextColor, nLegendFontSize, nLegendIsBold, ... )

METHOD RMChart:Draw( nCtrlId )

   RETURN ::CallDllStd( "RMC_DRAW", nCtrlId )

METHOD RMChart:AddBarSeries( nCtrlId, nRegion, nFirstDataValue, nDataValuesCount, nType, nStyle, ;
      nIsLucent, nColor, nIsHorizontal, nWhichDataAxis, nValueLabelOn, nPointsPerColumn, nHatchMode, ... )

   LOCAL cDouble := "", oElement

   FOR EACH oElement IN nFirstDataValue
      cDouble += FToC( oElement )
   NEXT

   RETURN ::CallDllStd( "RMC_ADDBARSERIES", nCtrlId, nRegion, @cDouble, nDataValuesCount, nType, nStyle, ;
      nIsLucent, nColor, nIsHorizontal, nWhichDataAxis, nValueLabelOn, nPointsPerColumn, nHatchMode, ... )

FUNCTION AMax( x )

   LOCAL nVal, oElement

   nVal := x[ 1 ]
   FOR EACH oElement IN x
      IF oElement > nVal
         nVal := oElement
      ENDIF
   NEXT

   RETURN nVal
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Destacando a parte que alterei:

Código: Selecionar todos

METHOD RMChart:AddBarSeries( nCtrlId, nRegion, nFirstDataValue, nDataValuesCount, nType, nStyle, ;
      nIsLucent, nColor, nIsHorizontal, nWhichDataAxis, nValueLabelOn, nPointsPerColumn, nHatchMode, ... )

   LOCAL cDouble := "", oElement

   FOR EACH oElement IN nFirstDataValue
      cDouble += FToC( oElement )
   NEXT

   RETURN ::CallDllStd( "RMC_ADDBARSERIES", nCtrlId, nRegion, @cDouble, nDataValuesCount, nType, nStyle, ;
      nIsLucent, nColor, nIsHorizontal, nWhichDataAxis, nValueLabelOn, nPointsPerColumn, nHatchMode, ... )
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

RMChart

Mensagem por asimoes »

Quintas,

Maravilha, parabéns!

Já fiz o teste aqui, agora fica mais fácil montar o gráfico. Aos usuários de sData ou sTemp com RMC_CREATECHARTFROMFILE vai facilitar a vida.
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar do usuário
asimoes
Colaborador
Colaborador
Mensagens: 4919
Registrado em: 26 Abr 2007 16:48
Localização: RIO DE JANEIRO-RJ

RMChart

Mensagem por asimoes »

Quintas,

2 métodos que ficaram faltando:

#define RMC_PORTRAIT 1
#define RMC_LANDSCAPE 2

Código: Selecionar todos

oGrafico:Draw2Clipboard( ID_CHART, RMC_BMP )
oGrafico:Draw2Printer( ID_CHART, RMC_LANDSCAPE, 10, 10, 250, 150, RMC_EMF  )

METHOD RMChart:Draw2Clipboard( nCtrlId, ... )
   RETURN ::CallDllStd( "RMC_DRAW2CLIPBOARD", nCtrlId, ... )

METHOD RMChart:Draw2Printer( nCtrlId, nPrinterDC, nLeft, nTop, nWidth, nHeight, nType)
  RETURN ::CallDllStd( "RMC_DRAW2PRINTER", nCtrlId, nPrinterDC, nLeft, nTop, nWidth, nHeight, nType)

►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Acabei alterando de novo, porque achei que a classe ficou muito poluída.
Dá uma ohada, pra ver o que acha.

Código: Selecionar todos

#include "hbclass.ch"
#include "rmchart.ch"
#include "hbgtinfo.ch"
#include "hbdyn.ch"

FUNCTION Main

   LOCAL oCrt, cLegenda, cLabels, cTitulo, aDados, cImagem, cUnidade, cTextoVert, nMax, nIdChart
   LOCAL oGrafico := RMChart():New(), nCont, oElement

   oCrt           := WvgCrt():New( , , { -1, -1 }, { 25, 85 }, , .T. )
   oCrt:lModal    := .T.
   oCrt:icon      := "demo.ico"
   oCrt:resizable := .F.
   oCrt:create()
   hb_gtInfo( HB_GTI_WINTITLE, "Grafico com RmChart - Dll" )
   cLegenda   := "Entradas*Saidas*Mais Um"
   cLabels    := "Janeiro*Fevereiro*Março*Abril*Maio*Junho*Julho*Agosto*Setembro*Outubro*Novembro*Dezembro"
   cTitulo    := "Gráfico de Teste"
   aDados     := { ;
                 { 225.25, 100.00, 100.00, 150.00, 250.00, 300.00, 25.00, 75.00, 300.00, 200.00, 325.00, 300.00 }, ;
                 { 220.00, 100.00, 125.00, 300.00, 150.00, 125.00, 85.00, 50.00, 285.00, 275.00, 295.00, 280.00 }, ;
                 { 125.25, 100.00, 100.00, 150.00, 250.00, 300.00, 25.00, 75.00, 300.00, 200.00, 325.00, 300.00 } }
   cImagem    := ""
   cUnidade   := "R$ "
   cTextoVert := ""
   nMax       := 0
   nIdChart   := 1

   FOR EACH oElement IN aDados
      nMax := Max( nMax, aMax( oElement ) )
   NEXT

   nMax := Round( ( Int( nMax / 10 ) * 10 ) + 10, 2 )

   oGrafico:CreateChart( hb_gtInfo( HB_GTI_WINHANDLE ), nIdChart, 0, 0, 770, 400, Azure, RMC_CTRLSTYLE3DLIGHT, .F., cImagem, "", 0, 0 )
   oGrafico:AddRegion( nIdChart, 0, 0, 760, 400, "RmChart", .F. )
   oGrafico:AddCaption( nIdChart, 1, cTitulo, Transparent, Red, 9, .T. )
   oGrafico:AddGrid( nIdChart, 1, LightBlue, .F., 20, 20, 685, 330, RMC_BICOLOR_LABELAXIS )
   oGrafico:AddLabelAxis( nIdChart, 1, cLabels, 1, Len( aDados[ 1 ] ), RMC_LABELAXISBOTTOM, 8, Black, RMC_TEXTCENTER, Black, RMC_LINESTYLENONE, "" )
   oGrafico:AddDataAxis( nIdChart, 1, RMC_DATAAXISRIGHT, 0.0, nMax, Len( aDados[ 1 ] ), 8, Black, Black, RMC_LINESTYLESOLID, 1, cUnidade, cTextoVert, "", RMC_TEXTCENTER )
   oGrafico:AddLegend( nIdChart, 1, cLegenda, RMC_LEGEND_BOTTOM, Transparent, RMC_LEGENDNORECT, Red, 8, .T. )

   FOR nCont = 1 TO Len( aDados )
      oGrafico:AddBarSeries( nIdChart, 1, aDados[ nCont ], 12, RMC_BARGROUP, RMC_BAR_FLAT_GRADIENT2, .F., 0, .F., 1, RMC_VLABEL_NONE, nCont, RMC_HATCHBRUSH_ONPRINTING )
   NEXT

   oGrafico:Draw( nIdChart )

   Inkey( 0 )
   oCrt:destroy()
   oGrafico:Destroy()

   RETURN NIL

FUNCTION AMax( x )

   LOCAL nVal, oElement

   nVal := x[ 1 ]
   FOR EACH oElement IN x
      IF oElement > nVal
         nVal := oElement
      ENDIF
   NEXT

   RETURN nVal

CREATE CLASS RmChart

   VAR    nHandle

   METHOD New()                        INLINE ::nHandle := hb_libLoad( "RMChart.dll" ), SELF
   METHOD Destroy()                    INLINE hb_libFree( ::nHandle )
   METHOD CallDllStd( cName, ... )     INLINE hb_DynCall( { cName, ::nHandle, HB_DYN_CALLCONV_STDCALL }, ... )
   METHOD CreateChart( ... )           INLINE ::CallDllStd( "RMC_CREATECHART", ... )
   METHOD AddRegion( ... )             INLINE ::CallDllStd( "RMC_ADDREGION", ... )
   METHOD AddCaption( ... )            INLINE ::CallDllStd( "RMC_ADDCAPTION", ... )
   METHOD AddGrid( ... )               INLINE ::CallDllStd( "RMC_ADDGRID", ... )
   METHOD AddLabelAxis( ... )          INLINE ::CallDllStd( "RMC_ADDLABELAXIS", ... )
   METHOD AddDataAxis( ... )           INLINE ::CallDllStd( "RMC_ADDDATAAXIS", ... )
   METHOD AddLegend( ... )             INLINE ::CallDllStd( "RMC_ADDLEGEND", ... )
   METHOD AddBarSeries( a, b, c, ... ) INLINE ::CallDllStd( "RMC_ADDBARSERIES", a, b, ::ToDouble( c ), ... )
   METHOD Draw( ... )                  INLINE ::CallDllStd( "RMC_DRAW", ... )
   METHOD Draw2Clipboard( ... )        INLINE ::CallDllStd( "RMC_DRAW2CLIPBOARD", ... )
   METHOD Draw2Printer( ... )          INLINE ::CallDllStd( "RMC_DRAW2PRINTER", ... )
   METHOD ToDouble( c )

ENDCLASS

METHOD ToDouble( c )

   LOCAL cDouble := "", oElement

   FOR EACH oElement IN c
      cDouble += FToC( oElement )
   NEXT

   RETURN cDouble

/*
RMChart:CreateChart( nIdChart, nX, nY, nWidth, nHeight, nBackColor, nCtrlStyle, nExportOnly, sBgImage, sFontName, nBitmapBKColor, ... )
RMChart:AddRegion( nIdChart, nLeft, nTop, nWidth, nHeight, sFooter, nShowBorder, ... )
RMChart:AddCaption( nIdChart, nRegion, sCaption, nTitelBackColor, nTitelTextColor, nTitelFontSize, nTitelIsBold, ... )
RMChart:AddGrid( nIdChart, nRegion, nBackColor, nAsGradient, nLeft, nTop, nWidth, nHeight, nBiColor, ... )
RMChart:AddLabelAxis( nIdChart, nRegion, sLabels, nCont, nTickCount, nAlignment, nFontSize, nTextColor, nTextAlignment, nLineColor, nLineStyle, sText, ... )
RMChart:AddDataAxis( nIdChart, nRegion, nAligment, nMinValue, nMaxValue, nTickCount, nFontSize, nTextColor, nLineColor, nLineStyle, nDecimalDigits, ;
      sUnit, sText, sLabels, nLabelAlignment, ... )
RMChart:AddLegend( nIdChart, nRegion, sLegend, nLegendAlign, nLegendBackColor, nLegendStyle, nLegendTextColor, nLegendFontSize, nLegendIsBold, ... )
RMChart:AddBarSeries( nIdChart, nRegion, nFirstDataValue, nDataValuesCount, nType, nStyle, ;
      nIsLucent, nColor, nIsHorizontal, nWhichDataAxis, nValueLabelOn, nPointsPerColumn, nHatchMode, ... )
RMChart:Draw( nIdChart )
RMChart:Draw2Clipboard( nIdChart, RMC_BMP )
RMCHart:Draw2Printer( nIdChart, RMC_LANDSCAPE, 10, 10, 250, 150, RMC_EMF )
*/
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Do outro jeito só será interessante no dia que existir uma IDE que faça uso dos parâmetros.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

E ainda falta acrescentar os métodos pra gráficos de pizza, barra, etc.
Agora que funcionou, dá pra pensar nisso.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Mais uma coisa, se comparar o primeiro exemplo com o do VB6, vai ver claramente que tiraram do VB6.

Código: Selecionar todos

Private Sub mnGroupedBars_Click()
    Dim i As Long
    Dim nC As Long
    Dim nDataCount As Long
    Dim nRetVal As Long
    Dim sTemp As String
    ReDim aData(0) As Double
    ReDim aData2(0) As Double
    ReDim aPPC(0) As Long
    ReDim aColor(0) As Long
    
    DoSettings
    
    '************** Create the chart **********************
    nRetVal = RMC_CreateChartOnDC(Picture1.hDC, ID_RMC1, 0, 0, 597, 447, AliceBlue, RMC_CTRLSTYLEFLATSHADOW, False, "", "Tahoma")
    If nRetVal < 0 Then GoTo IsError
    '************** Add Region 1 *****************************
    nRetVal = RMC_AddRegion(ID_RMC1, 5, 5, -5, -5, "\0C", False)
    If nRetVal < 0 Then GoTo IsError
    '************** Add grid to region 1 *****************************
    nRetVal = RMC_AddGrid(ID_RMC1, 1, WhiteSmoke, False, 0, 0, 0, 0, RMC_BICOLOR_NONE)
    If nRetVal < 0 Then GoTo IsError
    '************** Add data axis to region 1 *****************************
    nRetVal = RMC_AddDataAxis(ID_RMC1, 1, RMC_DATAAXISLEFT, 0, 100, 11, 8, Black, Black, RMC_LINESTYLESOLID, 0, "", "", "", RMC_TEXTCENTER)
    If nRetVal < 0 Then GoTo IsError
    '************** Add label axis to region 1 *****************************
    sTemp = "2000*2001*2002*2003*2004"
    nRetVal = RMC_AddLabelAxis(ID_RMC1, 1, sTemp, 1, 5, RMC_LABELAXISBOTTOM, 8, Black, RMC_TEXTCENTER, Black, RMC_LINESTYLESOLID, "")
    If nRetVal < 0 Then GoTo IsError
    '************** Add legend to region 1 *******************************
    sTemp = "Bananas*Apples*Cherries"
    nRetVal = RMC_AddLegend(ID_RMC1, 1, sTemp, RMC_LEGEND_TOP, LightYellow, RMC_LEGENDRECT, Black, 8, False)
    If nRetVal < 0 Then GoTo IsError
    '************** Add Series 1 to region 1 *******************************
    '****** Read data values ******
    ReDim aData(4)
    aData(0) = 30#: aData(1) = 20#: aData(2) = 40#: aData(3) = 60#: aData(4) = 10#
    nRetVal = RMC_AddBarSeries(ID_RMC1, 1, aData(0), 5, RMC_BARGROUP, RMC_BAR_HOVER, False, Gold, False, 1, RMC_VLABEL_NONE, 1, RMC_HATCHBRUSH_OFF)
    If nRetVal < 0 Then GoTo IsError
    '************** Add Series 2 to region 1 *******************************
    '****** Read data values ******
    ReDim aData(4)
    aData(0) = 50#: aData(1) = 70#: aData(2) = 10#: aData(3) = 40#: aData(4) = 30#
    nRetVal = RMC_AddBarSeries(ID_RMC1, 1, aData(0), 5, RMC_BARGROUP, RMC_BAR_HOVER, False, LightGreen, False, 1, RMC_VLABEL_NONE, 2, RMC_HATCHBRUSH_OFF)
    If nRetVal < 0 Then GoTo IsError
    '************** Add Series 3 to region 1 *******************************
    '****** Read data values ******
    ReDim aData(4)
    aData(0) = 40#: aData(1) = 10#: aData(2) = 30#: aData(3) = 20#: aData(4) = 80#
    nRetVal = RMC_AddBarSeries(ID_RMC1, 1, aData(0), 5, RMC_BARGROUP, RMC_BAR_HOVER, False, Salmon, False, 1, RMC_VLABEL_NONE, 3, RMC_HATCHBRUSH_OFF)
    If nRetVal < 0 Then GoTo IsError
 
    nRetVal = RMC_Draw(ID_RMC1)
    If nRetVal < 0 Then GoTo IsError
    Exit Sub
 
O ponto que mostra que tiraram do VB6 é justamente nRetVal =
Isso no VB6 é porque senão não dá pra usar como função (acontecia com foxpro também).

No que isso é importante?
Tem exemplo de outros tipos de gráfico em VB6, usando a dll.
Anexos
grafico6.png
grafico4.png
grafico3.png
grafico2.png
grafico2.png (8.12 KiB) Exibido 9727 vezes
grafico1.png
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Todos tem fonte disponível.
Anexos
grafico13.png
grafico12.png
grafico11.png
grafico11.png (8.12 KiB) Exibido 9727 vezes
grafico10.png
grafico9.png
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20267
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP

RMChart

Mensagem por JoséQuintas »

Agora a brincadeira dá pra ir longe... rs
Pensando nisso que procurei simplificar a classe, pra acrescentar mais opções.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"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 do usuário
janio
Colaborador
Colaborador
Mensagens: 1846
Registrado em: 06 Jul 2004 07:43
Localização: UBAJARA - CE

RMChart

Mensagem por janio »

Esses gráficos é usando alguma dll ou lib? Qual(is)

Janio
fui...
e-mail:janioaguiar@yahoo.com.br
msn: janio_aguiar@hotmail.com
xHarbour1.2.1/Harbour3.2 + wvg + hwgui + Mediator + MySql
Responder