nikosliapis Posted December 20, 2009 Share Posted December 20, 2009 Hello everybody. I need a function that will produce a graph from a 2D array. I believe that i am doing pretty well with simple scripts but when i must create a GUI window i suck, therefore i ask for your help. I would really appreciate any help provided. Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 20, 2009 Moderators Share Posted December 20, 2009 nikosliapis, You may want to look at this topic. The "Search" button is at the top on the right, by the way. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
nikosliapis Posted December 20, 2009 Author Share Posted December 20, 2009 I would like to apologise if i caused you any disconvinience. I have allready checked this UDF but i couldn't understand how to import my data so that the graph will be created. Thanks for your time. Coding can be fun when you do it your own. Link to comment Share on other sites More sharing options...
Yashied Posted December 20, 2009 Share Posted December 20, 2009 (edited) Simple example. expandcollapse popup#Include <GDIPlus.au3> #Include <GUIConstantsEx.au3> #Include <Math.au3> #Include <WinAPI.au3> Opt('MustDeclareVars', 1) Dim $aPoints[300][2] For $i = 0 To UBound($aPoints) - 1 $aPoints[$i][0] = ($i - 150) / 1.7 $aPoints[$i][1] = 20 * Sin($aPoints[$i][0] / 20) * Sin($aPoints[$i][0] / 2) Next _ViewGraph($aPoints) Func _ViewGraph($aPoints) Local $hForm, $Pic, $hPic Local $Scale, $Xi, $Yi, $Xp, $Yp, $XOffset, $YOffset, $Xmin = $aPoints[0][0], $Ymin = $aPoints[0][1], $Xmax = $Xmin, $Ymax = $Ymin Local $hBitmap, $hObj, $hGraphic, $hImage, $hBrush, $hPen For $i = 1 To UBound($aPoints) - 1 If $aPoints[$i][0] < $Xmin Then $Xmin = $aPoints[$i][0] Else If $aPoints[$i][0] > $Xmax Then $Xmax = $aPoints[$i][0] EndIf EndIf If $aPoints[$i][1] < $Ymin Then $Ymin = $aPoints[$i][1] Else If $aPoints[$i][1] > $Ymax Then $Ymax = $aPoints[$i][1] EndIf EndIf Next $Scale = 600 / _Max($Xmax - $Xmin, $Ymax - $Ymin) $XOffset = Floor(($Xmin + $Xmax) * $Scale / 2) $YOffset = Floor(($Ymin + $Ymax) * $Scale / 2) _GDIPlus_Startup() $hBitmap = _WinAPI_CreateBitmap(601, 601, 1, 32) $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap) _WinAPI_DeleteObject($hBitmap) $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) $hBrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $hPen = _GDIPlus_PenCreate(0xFFFF0000) _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, 601, 601, $hBrush) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 2) If Abs($XOffset) <= 300 Then _GDIPlus_GraphicsDrawLine($hGraphic, 300 - $XOffset, 0, 300 - $XOffset, 601, $hPen) EndIf If Abs($YOffset) <= 300 Then _GDIPlus_GraphicsDrawLine($hGraphic, 0, 300 + $YOffset, 601, 300 + $YOffset, $hPen) EndIf _GDIPlus_PenDispose($hPen) $hPen = _GDIPlus_PenCreate(0xFF000000) For $i = 0 To UBound($aPoints) - 1 $Xi = 300 - $XOffset + $Scale * $aPoints[$i][0] $Yi = 300 + $YOffset - $Scale * $aPoints[$i][1] If $i Then _GDIPlus_GraphicsDrawLine($hGraphic, $Xp, $Yp, $Xi, $Yi, $hPen) EndIf $Xp = $Xi $Yp = $Yi Next $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_ImageDispose($hImage) _GDIPlus_BrushDispose($hBrush) _GDIPlus_PenDispose($hPen) _GDIPlus_Shutdown() $hForm = GUICreate('My Graph', 601, 601) $Pic = GUICtrlCreatePic('', 0, 0, 601, 601) $hPic = GUICtrlGetHandle(-1) _WinAPI_DeleteObject(_SendMessage($hPic, 0x0172, 0, $hBitmap)) $hObj = _SendMessage($hPic, 0x0173) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState(@SW_SHOW, $hForm) Do Until GUIGetMsg() = -3 GUIDelete($hForm) EndFunc ;==>_ViewGraph Edited February 7, 2010 by Yashied AnonymousX 1 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... 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