Automan Empire Posted July 23, 2006 Share Posted July 23, 2006 Here is my attempt to create a bar graph within the AutoIt GUI. (I know that it is also possible to graph things externally using excel.com). Any improvements or suggestions are welcome. expandcollapse popup;~ This can be used to create a Graph from the values in an array, using GUICtrlCreateProgress ;~ This only works properly in Windows XP if the style is set to "Windows Classic style" (otherwise the Progress Bar Style will be an ugly segmented type) ;~ To set this: Right mouse click on the Windows Desktop, Properties, Appearance, change "Windows and Buttons" to "Windows Classic style", "OK" ;constants that are required to create a GUI #include <GUIConstants.au3> ;dimensions arrays where some numbers will be stored Dim $arraynums[250] Dim $progressbar[250] ;assigns random numbers to an array, so that we have something to graph For $x = 1 To 249 $arraynums[$x] = Random(41, 76, 1);Random ( [Min [, Max [, Flag]]] );flag 1 = integer Next ;creates a GUI of a specified name, size, and location GUICreate("Graph Some Random Numbers...", 1270, 80, 1, 200) ;parameters for bar positions, maximum height, spacing, width, color $rightcoord = 10 $downcoord = 10 $height = 50 $rightspacing = 5 $barwidth = 12 $color1 = 32250;blue =32250 ;creates the adjacent Progress Bar controls, which will be used to graph the numbers For $x = 1 To 249 $progressbar[$x] = GUICtrlCreateProgress( ($rightcoord) + ($rightspacing * $x), $downcoord, $barwidth, $height, $PBS_SMOOTH + $PBS_VERTICAL) GUICtrlSetColor(-1, $color1) Next ;draws the Progress Bars at heights corresponding to the numbers in the array For $x = 1 To 249 GUICtrlSetData($progressbar[$x], $arraynums[$x]) Next ;displays the GUI GUISetState() ;display until closed Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE "I've seen your work in the past, and it's novice at best..." SmOke_N Link to comment Share on other sites More sharing options...
GaryFrost Posted July 23, 2006 Share Posted July 23, 2006 just add the following near the top of the script DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
CoePSX Posted July 26, 2006 Share Posted July 26, 2006 The DLL Call didn't work here... nothing changed. [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font] Link to comment Share on other sites More sharing options...
james3mg Posted July 27, 2006 Share Posted July 27, 2006 (edited) Here is my attempt to create a bar graph within the AutoIt GUI. (I know that it is also possible to graph things externally using excel.com). Any improvements or suggestions are welcome. I like this script - good job! Consider using Labels instead of Progress bars to avoid that problem with XP progress bars. Just set the Background color to some color (I used blue in the below script). ;~ This can be used to create a Graph from the values in an array, using Labels with their background color set to blue #include <GUIConstants.au3> ;~ It wouldn't be hard to modify this script to pass the numbers from parameters at runtime - In this case replace $NumBars with @NumParams and parse the parameters to find the Maximum parameter's number for $MaxNum $NumBars = InputBox("Number of bars","Enter the number of bars you want","25") $MaxNum = InputBox("Max value","Enter the maximum value you want the random data to have",250) ;~ You could keep this as a prompt before the graph is displayed, have a checkbox in the GUI that turns them on and off (by a for...next loop GUICtrlSetData()'ing each element in $TheBars[]) or by another parameter $Labels = MsgBox(4,"Bar Labels","Do you want to display the data in the bars?") Global $TheData[$NumBars], $TheBars[$NumBars] ;~ If you change the script to take the numbers by parameters, get rid of this section - it just creates random data. For $i=0 To $NumBars-1 $TheData[$i] = Random(0,$MaxNum,1) Next $Graph = GUICreate("Bar Graph",640,480,-1,-1,$WS_MINIMIZEBOX + $WS_MAXIMIZEBOX + $WS_SIZEBOX) For $i=0 To $NumBars-1 If $Labels = 6 Then $ThisLabel = $TheData[$i] Else $ThisLabel = " " EndIf ;~ This builds in a 5 pixel margin on the left and right, but none above and below. It could be changed to include vertical margins, or write another label 20 pixels above each bar that holds the label data - that way 0 would still be a visible data label. $TheBars[$i] = GUICtrlCreateLabel($ThisLabel,Round(5+($i*((640-10)/$NumBars)),0),Round(480-(480*($TheData[$i]/$MaxNum)),0),Round((640-10)/$NumBars,0)-1,Round(480*($TheData[$i]/$MaxNum),0),$SS_CENTER) GUICtrlSetBkColor(-1,0x0000FF) GUICtrlSetColor(-1,0xFFFFFF) Next GUISetState() Do Sleep(100) Until GUIGetMsg() = $GUI_EVENT_CLOSEEdit: Pasting in code between the AutoIt tags seems to work better in a quick edit than the original post (indents are more obvious), so I re-pasted it. :-) Edited July 27, 2006 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110 Link to comment Share on other sites More sharing options...
Automan Empire Posted July 29, 2006 Author Share Posted July 29, 2006 You sir, are a genius! "I've seen your work in the past, and it's novice at best..." SmOke_N Link to comment Share on other sites More sharing options...
RazerM Posted July 30, 2006 Share Posted July 30, 2006 This is a good idea, works far better with the DllCall on XP @james3mg that's a better way of doing it, you should make a udf My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
JonnyThunder Posted July 4, 2008 Share Posted July 4, 2008 (edited) Further to Automan Empires original script, here is a small function using the same method - but with dynamically generated window size etc. expandcollapse popup; Get some constants! #include <GUIConstantsEx.au3> #include <ProgressConstants.au3> ; Some test data Dim $inputdata[50] for $i = 0 to ubound($inputdata)-1 $inputdata[$i] = random(0,100) Next ; Draw the graph drawgraph($inputdata) ; Function to draw a graph (modified Func DrawGraph ($inputdataarray) ; Define colour scheme Local $col_winbackground = 0x424242 ; Windows background colour Local $col_graphbar = 0x338b31 ; Graph bar colour Local $col_graphtext = 0x7b7b7b ; Graph text colour ; Define amount of plots on X axis $x_plots = ubound($inputdataarray) ; Define graph display parameters $margin_x = 10 ; X margin $margin_y = 10 ; Y margin $barheight = 60 ; Height of progress bar $barwidth = 9 ; Width of progress bar $bartrim = 2 ; Overlap for the bars (usually 1 or 2) ; Define array for progress bar handles Dim $progressbar[$x_plots] ; Define array for holding the plot data Dim $plotdata[$x_plots] ; Create the GUI GUICreate("Graph", (($margin_x*2) + (($barwidth-$bartrim)*$x_plots)), 80) GUISetBkColor($col_winbackground) ; Create the bars of the graph For $x = 0 To $x_plots-1 $progressbar[$x] = GuiCtrlCreateProgress ( $margin_x + ( $x * ( $barwidth - $bartrim ) ), $margin_y, $barwidth, $barheight, $PBS_SMOOTH + $PBS_VERTICAL) GuiCtrlSetColor($progressbar[$x], $col_graphbar) GUICtrlSetData($progressbar[$x], random(0,100)) Next ; Display the GUI GUISetState() ; Loop until we close Do $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE EndFunc Edited July 4, 2008 by JonnyThunder Link to comment Share on other sites More sharing options...
Andreik Posted July 4, 2008 Share Posted July 4, 2008 It's a good start to create an advanced bar graph. When the words fail... music speaks. 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