frodo Posted May 1, 2008 Share Posted May 1, 2008 (edited) Okay,So ive seen a few references to RMChart on here, which dont work, the read from file method (until now) was no good for dynamic data- who would want to have to write changes in data to file and then read them back to display the graph?, and the COM object method just crashes AutoIT, so i thought id post the workaround i came up with last night.Let me set the scene: Ive been working on my own clone (an almost exact gui clone) of Ghost using Imagex for a long while and hadnt found a good charting control that was usable in AutoIT, id even tried RMChart once before via DllCall and given up as trying to submit the data to it via DllCall failed and crashed the GUI. So i made a pie chart control using the inbuilt GUICtrlSetGraphic/$GUI_GR_PIE gear, and i was fairly happy. I put the project on hold, but then dragged it out last night after months of not looking at it.I looked at it for the first time in ages and thought "i really hate the pie graph, the Ghost 3d one was sweet. Dug up the RMChart.dll and thought id have another crack!So first off i tried the DllCall method to submit the data and as it had failed before i wasnt surprised when it failed again.Decided to approach it from a different angle...wondered if the RMC_CREATECHARTFROMFILE method in the dll was literal, would it only render a graph from file? I decided to try grabbing the data string that RMCDesigner allows you to export (usually its in the output file) and assigning it to a variable and using a DllCall using RMC_CREATECHARTFROMFILE referencing the variable....yay worked!I then started to decipher the parts of the string that related to the data, for a pie graph, theyre at the end of the data string (using a 70/30 pie chart - 2 slices):0000365|0000465|000051|000061|00008-2|00009412|00011Tahoma|100011|1000910|100181|100481|10051-2|10052-1|10053-657956|10063-1|100651|110011|1100251|1100454|110081|110161|110211|110221|110232|11051-65281*-16776961|11053 70*30 Since i created this chart via RMCDesigner specifically to sit in a certian spot and only operate as a simple pie chart for my needs, i didnt need to decode anything else in the string, although:0000365|0000465 - the 65's in this are the chart size.Of course making anything else other than a simple pie chart with this method will require a lot of decoding for x/y plotted graphs etc, all you need to do is design it and then decode the parts of the string that control data input. The string changes to options in RMCDesigner, for my work i used transparent everywhere in the designer and pie 3d, gradient.....So having that sorted out, i hit a new snag....being a control called via DllCall, i had no control on its behaviour on Tabs (the chart can only be attached to the gui (form), not the tab control), it showed on all 4 tabs i had, when i wanted it just on one.....Luckily another DllCall and a bit of Case $msg = $tab work and all was well.Heres the demo script, make sure you grab the RMChart.dll from http://www.rmchart.com/rmc/Downloads.htm , i suggest getting the full package (setup.exe) from there, it copies the Dll to system32 and also gives you RMCDesigner as well.....expandcollapse popup#include <GUIConstants.au3> #Include <GuiTab.au3> ;static values for pie Global $P1 = 70 Global $P2 = 30 ;Open the RMChart dll Global $RMChartDll = DllOpen("rmchart.dll") ;RMChart Object instance 1 Global $RMChartObj = 1 $GUI = GUICreate("My GUI Tab",320,320); will create a dialog box that when displayed is centered $tab=GUICtrlCreateTab (10,10, 300,300) ;Change the tab colour to the same default grey as the normal gui to hide the RMChart surround ;In my example i set the RMChart background to transparent in the RMCDesigner, there wasnt any colour in it that approached the normal tab color _GUICtrlTab_SetBkColor($GUI, $tab, 0xECE9D8) $tab0=GUICtrlCreateTabitem ("tab0") $tab1=GUICtrlCreateTabitem ( "tab1") $tab2=GUICtrlCreateTabitem ("tab2") GUICtrlCreateTabitem (""); end tabitem definition ;Call the func that draws the pie Draw_Pie() ;Show the GUI GUISetState(@SW_SHOW, $GUI) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $tab Select Case GUICtrlread ($tab) = 0 ;Call the func that draws the pie when we go back to tab0 Draw_Pie() Case GUICtrlread ($tab) = 1 ;Destroy the pie when we click on other tabs dllcall($RMChartDll,"long","RMC_DELETECHART","long",$RMChartObj) Case GUICtrlread ($tab) = 2 ;Destroy the pie when we click on other tabs dllcall($RMChartDll,"long","RMC_DELETECHART","long",$RMChartObj) Case GUICtrlread ($tab) = 3 ;Destroy the pie when we click on other tabs dllcall($RMChartDll,"long","RMC_DELETECHART","long",$RMChartObj) EndSelect EndSelect Wend Func Draw_Pie() $RMString = "0000365|0000465|000051|000061|00008-2|00009412|00011Tahoma|100011|1000910|100181|100481|10051-2|10052-1|10053-657956|10063-1|100651|110011|1100251|1100454|110081|110161|110211|110221|110232|11051-65281*-16776961|11053" & $P1 & "*" & $P2 ;Call the createchart method, the 70's in here are where to draw the chart in the GUI.... $RMCreate1 = dllcall($RMChartDll,"long","RMC_CREATECHARTFROMFILE","long",$GUI ,"long",$RMChartObj,"long",70,"long",70,"long",0,"str",$RMString) ;Draw the chart $RMCreate2 = dllcall($RMChartDll,"long","RMC_DRAW","long",$RMChartObj) EndFunc ; Change tab color routine pinched from the forums :) Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) GUICtrlCreateLabel("", $aTabPos[0]+2, $aTabPos[1]+$aTab_Rect[3]+4, $aTabPos[2]-4, $aTabPos[3]-$aTab_Rect[3]-7) GUICtrlSetBkColor(-1, $sBkColor) GUICtrlSetState(-1, $GUI_DISABLE) EndFuncAnd to see where i applied this, heres a pic....in the demo above the values are static, in my script the pie is drawn according the the drive space - used/free and the chart updates accordingly without delay:)Hopefully this is useful to others, and a starting point Edited May 1, 2008 by frodo Link to comment Share on other sites More sharing options...
arcker Posted May 1, 2008 Share Posted May 1, 2008 excellent job ! i will surely use it for my filemonitoring system please continue this work, it's really amazing -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
NELyon Posted May 3, 2008 Share Posted May 3, 2008 Only one post for such cool code. That's kinda sad. I like this alot! Nice job. Link to comment Share on other sites More sharing options...
frodo Posted May 3, 2008 Author Share Posted May 3, 2008 Only one post for such cool code. That's kinda sad. I like this alot! Nice job.Luckily im not that delicate, but thanks for the post Link to comment Share on other sites More sharing options...
MartiniThePilot Posted September 10, 2009 Share Posted September 10, 2009 ...make sure you grab the RMChart.dll from http://www.rmchart.com/rmc/Downloads.htm , i suggest getting the full package (setup.exe) from there, it copies the Dll to system32 and also gives you RMCDesigner as well.....Hi,the rendered graphic within the GUI really looks nice!The rmchart.com domain 'has expired', so you have to pick up the RMChart.dll from the new site www.purebasicpower.de.To display graphics within an AutoIt GUI you may probably also have a look to imbed one of the (flash) graphic engines here. Ciao, Martini Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now