RMChart
Enviado: 12 Mai 2016 01:47
Vamos fazer este gráfico sem usar RMChart pra ver quanto tempo demora?
Só vou mexer amanhã no final do dia, mas parece fácil.
Só vou mexer amanhã no final do dia, mas parece fácil.
Código: Selecionar todos
FOR nCont = 1 TO 12
AAdd( oGrafico:aValues[ 1 ], 125 )
AAdd( oGrafico:aValues[ 2 ], 240 )
AAdd( oGrafico:aValues[ 3 ], 215 )
NEXT
Código: Selecionar todos
FOR nCont = 1 TO 12
AAdd( oGrafico:aValues[ 1 ], 125 )
AAdd( oGrafico:aValues[ 2 ], 240 )
AAdd( oGrafico:aValues[ 3 ], 300 )
NEXT
Código: Selecionar todos
PROCEDURE Test
LOCAL nCont, oGrafico
SetMode(40,80)
CLS
oGrafico := BarChart():New()
oGrafico:cTxtTitle := "TESTE DE GRAFICO 2016"
oGrafico:aTxtBarList := { "JANEIRO", "FEVEREIRO", "MARCO", "ABRIL", "MAIO", "JUNHO", "JULHO", "AGOSTO", "SETEMBRO", "OUTUBRO", "NOVEMBRO", "DEZEMBRO" }
oGrafico:aTxtSubList := { "ENTRADA", "SAIDA", "OUTRA" }
oGrafico:aValues := { {}, {}, {} }
FOR nCont = 1 TO 12
AAdd( oGrafico:aValues[ 1 ], 125 )
AAdd( oGrafico:aValues[ 2 ], 240 )
AAdd( oGrafico:aValues[ 3 ], 300 )
NEXT
oGrafico:Show()
Inkey(0)
RETURN
Código: Selecionar todos
#include "inkey.ch"
#include "setcurs.ch"
#include "hbgtinfo.ch"
#include "hbver.ch"
#define RMC_CTRLSTYLEFLAT 0
#define RMC_PIE_GRADIENT 52
#define RMC_FULL 1
#define RMC_EXPLODE_NONE 0
#define RMC_VLABEL_ABSOLUTE 6
#define RMC_HATCHBRUSH_OFF 0
PROCEDURE Main()
LOCAL oCrt, oTBar, oRMChart, oDA, oRegion, oChart, oCaption
oCrt := WvgDialog():new( , , { 30, 30 }, { 800, 600 }, , .T. )
oCrt:closable := .T.
oCrt:create()
oDA := oCrt:drawingArea
oTBar := BuildWvgToolBar( oDA )
oDA:resize := {|| ResizeDialog( oCrt, oTBar, oRMChart ) }
oRMChart := WvgActiveXControl():New( oDA, , { 0, 0 }, { 100, 100 }, , .T. )
hb_gtInfo( HB_GTI_WINTITLE, "RM Chart [ <F12> Attributes <F11> Next Charts ]" )
oRMChart:CLSID := "RMChart.RMChartX"
oRMChart:create()
oCrt:sendMessage( WIN_WM_SIZE, 0, 0 )
oCrt:show()
oRmChart:Font := "Tahoma"
oRmChart:RMCStyle := RMC_CTRLSTYLEFLAT
oRmChart:AddRegion()
oRegion := oRmChart:Region( 1 )
oRegion:Footer := hb_Version( HB_VERSION_URL_BASE )
oRegion:AddCaption()
oCaption := oRegion:Caption()
oCaption:Titel := "RMChart Demo"
oCaption:FontSize := 10
oCaption:Bold := .T.
oRegion:AddGridlessSeries()
oChart := oRegion:GridLessSeries
oChart:SeriesStyle := RMC_PIE_GRADIENT
oChart:Alignment := RMC_FULL
oChart:Explodemode := RMC_EXPLODE_NONE
oChart:Lucent := .F.
oChart:ValueLabelOn := RMC_VLABEL_ABSOLUTE
oChart:HatchMode := RMC_HATCHBRUSH_OFF
oChart:StartAngle := 0
oChart:DataString := "10*5*20*25"
wapi_MessageBox( , "fechar Grafico", "Fechar Grafico", WIN_MB_ICONASTERISK )
oCrt:Destroy()
RETURN
STATIC FUNCTION ResizeDialog( oCrt, oTBar, oRMChart )
LOCAL aCrt := oCrt:currentSize()
LOCAL aTBar := oTBar:currentSize()
LOCAL nT := aTBar[ 2 ]
LOCAL nH := aCrt[ 2 ] - aTBar[ 2 ]
oRMChart:setPosAndSize( { 0, nT }, { aCrt[ 1 ], nH }, .T. )
RETURN 1
FUNCTION BuildWvgToolBar( oDA )
LOCAL oTBar := WvgToolBar():new( oDA, , { 0, 0 }, { oDA:currentSize()[ 1 ], 30 }, , .T. )
oTBar:style := WVGTOOLBAR_STYLE_FLAT
oTBar:borderStyle := WVGFRAME_RECT
oTBar:buttonWidth := 40 // 28
oTBar:buttonHeight := 26
oTBar:imageWidth := 26
oTBar:imageHeight := 24
oTBar:showToolTips := .T.
oTBar:create()
RETURN oTBar
PROCEDURE hb_GTSYS()
REQUEST HB_GT_WVG_DEFAULT
REQUEST HB_GT_WGU
RETURN
Código: Selecionar todos
hb_gtReload( "WVG" )
Código: Selecionar todos
hb_gtReload( "WGU" )
Código: Selecionar todos
hWnd := wapi_CreateWindowEx( ;
::exStyle, ;
::className(), ;
"", ; /* window name */
::style, ;
aPosSz[ 1 ], aPosSz[ 2 ], ;
aPosSz[ 3 ], aPosSz[ 4 ], ;
::oParent:hWnd, ;
::nID, ; /* hMenu */
NIL, ; /* hInstance */
NIL ) /* lParam */
RMC_AddBarSeries function.
Add a bar chart series to a region of an existing chart
--------------------------------------------------------------------------------
Syntax
nResult (LONG) = RMC_AddBarSeries(
ByVal nCtrlId (LONG),
ByVal nRegion (LONG),
Optional ByRef nFirstDataValue (DOUBLE),
Optional ByVal nDataValuesCount (LONG),
Optional ByVal nType (LONG),
Optional ByVal nStyle (LONG),
Optional ByVal nIsLucent (LONG),
Optional Byval nColor (LONG),
Optional ByVal nIsHorizontal (LONG),
Optional ByVal nWhichDataAxis (LONG),
Optional ByVal nValueLabelOn (LONG),
Optional ByVal nPointsPerColumn (LONG),
Optional ByVal nHatchMode (LONG)
)
Parameter
nCtrlId (LONG)
Unique ID of the chart control, to which the series belongs.
nRegion (LONG)
Region to which the series belongs.
nFirstDataValue (DOUBLE)
The first element of an one-dimensional array, which holds the series data. If you want to add the data later with RMC_SetSeriesData(), simply pass 0.
Please note one anomaly: If the type of the series is RMC_FLOATINGBAR or RMC_FLOATINGBARGROUP, you must pass for each single bar a pair of two data values, where the first value holds the starting point of the bar and the second value holds the data which determines the length of the bar. Example: Imagine the data axis has a range from 1 to 10 and you want to draw a floating bar which starts at 2 and ends at 9. In this case you must pass the data pair 2,7 for this bar.
Código: Selecionar todos
sData:=""
sData += "00003600|00004450|000051|000061|000071|00008-984833|00009412|00011Tahoma|100011|"
sData += "100021|100035|100045|10005-5|10006-5|1000910|100101|100111|100131|100181|1002010|"
sData += "10021100|1002211|100238|100331|100341|1003520|100378|100482|100491|10051-8388652|"
sData += "10052-16777216|10053-657956|100541|100558|10056-16777216|10057-16777216|10060-"
sData += "16777216|10061-16777216|10063-1|100651|10181 *** Gráfico Teste ***|10184Em Milhões de Reais|102010.00*10."
sData += "00*20.00*30.00*40.00*50.00*60.00*70.00*80.00*90.00*100.00|110011|1100221|110035|"
sData += "1100424|110051|110062|110071|110091|110121|110131|1101421|110152|110171|11019-16"
sData += "776961|1102115|110221|110235|110261|11053"
sData += "15*25*30*22*75"
sData += "|120011|1200221|1200424|120062|120121|1201421|12019-65536|1202115|120221|120235|120261|12053"
sData += "10*15*40*20*31"
nWidth :=600
nHeight:=450
RmChart22( "Grafico", sData, nWidth, nHeight )
[code]
#include "windows.ch"
#include "hwgui.ch"
#include "common.ch"
#include "guilib.ch"
#include "rmchart.ch"
#include "hbdyn.ch"
#define ID_CHART 1001
#define RMC_DEFAULT 0
#define RMC_PORTRAIT 1
#define RMC_LANDSCAPE 2
FUNCTION RmChart22( cTitulo, sData, nWidth, nHeight )
LOCAL nHandleDLL
LOCAL oIcon := HIcon():AddResource("ICON_A")
hb_Default(@cTitulo, "Gráfico")
nHandleDLL:=hb_LibLoad("rmchart.dll")
oFont := HFont():Add( "Courier New", 9)
nStyle := DS_CENTER + WS_SYSMENU + WS_VISIBLE
INIT DIALOG oModDlg TITLE cTitulo ;
ICON oIcon ;
AT 0, 0 ;
SIZE nWidth + 30, nHeight + 100 ;
STYLE nStyle ;
FONT oFont ;
CLIPPER ;
ON INIT { | oDlg | oDlg:nInitFocus := oSair, ViewChart(oDlg, nHandleDLL, sData) }
x1 := Int( oModDlg:nWidth/2 ) - 110
y1 := Int( oModDlg:nHeight) - 70
@ x1, y1 OWNERBUTTON oOk SIZE 100, 30 ;
TEXT "Imprimir" COORDINATES 35, 0, 0, 0 ;
FONT HFont():Add( "Arial", 0, -13,550 ) ;
BITMAP "IMG\IOK.BMP" COORDINATES 5, 0, 0, 0 TRANSPARENT ;
ON CLICK { || ChartPrint(nHandleDLL), oModDlg:lResult := .T. } ;
TOOLTIP "Ir para a página selecionada." ;
THEMED
@ x1 + 115, y1 OWNERBUTTON oSair SIZE 100, 30 ;
TEXT "RmChart" COORDINATES 35, 0, 0, 0 ;
FONT HFont():Add( "Arial", 0, -13, 550 ) ;
BITMAP "IMG\IEXIT.BMP" COORDINATES 5, 0, 0, 0 TRANSPARENT ;
ON CLICK { || ViewChart(oModDlg, nHandleDLL, sData) } ;
TOOLTIP "Abandonar a seleção." ;
THEMED
oModDlg:Activate(.F.) // .T. = NOMODAL, .F. ou () = MODAL
RETURN oModDlg
FUNCTION ViewChart(oDlg, nHandleDLL, sData)
nRetVal:=hb_dynCall( { "RMC_CREATECHARTFROMFILE", nHandleDLL, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_STDCALL ) }, oDlg:handle, ID_CHART, 10, 10, 0, sData)
nRetVal:=hb_dynCall( { "RMC_DRAW", nHandleDLL, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_STDCALL ) }, ID_CHART)
nRetVal:=hb_dynCall( { "RMC_DRAW2CLIPBOARD", nHandleDLL, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_STDCALL ) }, ID_CHART, RMC_BMP )
RETURN Nil
FUNCTION ChartPrint(nHandleDLL)
// Para imprimir:
nRetVal:=hb_dynCall( { "RMC_DRAW2PRINTER", nHandleDLL, hb_bitOr( HB_DYN_CTYPE_LONG , HB_DYN_CALLCONV_STDCALL ) }, ID_CHART, RMC_LANDSCAPE, 10, 10, 250, 150, RMC_EMF )
RETURN nRetVal