Jump to content
Sign in to follow this  
Chimaera

Graphic on top of a tab

Recommended Posts

Chimaera

Hi all

Im trying to create a simple pie chart on an 8 tab project that im working on but the issue is the graphic dosent respond to the tabs and stays underneath

This is the example im working with, i chose this because its simple for me to modify

Ive adde the tab so you can see the problem

Is there a way to make it on the tab or are there other options that might be better?

Chimaera

; ----------------------------------------------------------------------------
;
; AutoIt Version: 3.1.1.66
; Author:        MikeOsdx
;
; Script Function: Create a Pie graph of Passed/Failed/Warnings
;   You can change the $Pass, $Fail, $Warnings values to modify the Pie chart
;
; ----------------------------------------------------------------------------
#include <GUIConstants.au3>

$Pass = 16;Total number of Passed
$Fail = 3;Total Number of Failed
$Warnings = 5;Total Number of Warnings

;===== The following functions calculate Percentages and Degrees =====
$TotalTests = $Pass + $Fail + $Warnings;Get the total number of all "for Percentage calculations"

$PassP1 = $Pass / $TotalTests;Get percentage of Total Passed
$PassP =  $PassP1 * 360;Get the Degrees from the Passed Percentage

$FailP1 = $Fail / $TotalTests;Get Percentage of Total Failed
$FailP =  $FailP1 * 360;Get the Degrees from the Failed percentage

$WarningsP1 = $Warnings / $TotalTests;Get Percentage of Total Warnings
$WarningsP = $WarningsP1 * 360;Get the Degrees from the Warning Percentage
;=====================================================================

GUICreate("Reporting Chart", 340, 300);Create the GUI window
$hTab = GUICtrlCreateTab(10,20,300, 280)
$hTab0 = GUICtrlCreateTabItem(" Information ")
$Pie1 = GuiCtrlCreateGraphic(0, 0, 240,140);Create the main graphic area

;=== This section will create the Pie Chart ==========================
;Passed Pie section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xF0F8FF);Set the color of Passed to light blue
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120,70, 80, 90, $PassP);Set the Pie Chart piece Starts at 90^ and sweeps for $PassP number of ^
;Failed Pie section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x8B0000);Set color of Failed to dark red
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120,70, 80, 90 + $PassP, $FailP);Set the Pie Chart piece Starts at 90^ + total ^ of $PassP
;Warnings Pie Section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xFFD700);Set color of warning to dark Yellow
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120,70, 80, 90 + $PassP + $FailP, $WarningsP);Set the Pie Chart piece Start at 90^ + Total ^ of $PassP and $FailP
;=====================================================================


;~ ;=== This section creates the Legend =============================
;~ $Legend = GUICtrlCreateGraphic(0, 140, 200, 60)
;~ ;Passed Legend
;~ GUICtrlSetGraphic($Legend, $GUI_GR_PENSIZE, 5);makes the Dot bigger so you can see the color
;~ GUICtrlSetGraphic($Legend,$GUI_GR_COLOR, 0xF0F8FF,0xF0F8FF)
;~ GUICtrlSetGraphic($Legend, $GUI_GR_DOT, 20, 10)
;~ GUICtrlCreateLabel("Passed", 40, 145, 40, 20)
;~ $PassPercent = GUICtrlCreateLabel(Round($PassP1 * 100, 0) & "%", 80, 145, 30, 20);Calculates the total percentage to display
;~ ;Failed Legend
;~ GUICtrlSetGraphic($Legend, $GUI_GR_PENSIZE, 5);makes the Dot bigger so you can see the color
;~ GUICtrlSetGraphic($Legend,$GUI_GR_COLOR, 0x8B0000,0x8B0000)
;~ GUICtrlSetGraphic($Legend, $GUI_GR_DOT, 20, 40)
;~ GUICtrlCreateLabel("Failed", 40, 175, 40, 20)
;~ $FailPercent = GUICtrlCreateLabel(Round($FailP1 * 100, 0) & "%", 80, 175, 30, 20);Calculates the total percentage to display
;~ ;Warnings legend
;~ GUICtrlSetGraphic($Legend, $GUI_GR_PENSIZE, 5);makes the Dot bigger so you can see the color
;~ GUICtrlSetGraphic($Legend, $GUI_GR_COLOR, 0xFFD700, 0xFFD700)
;~ GUICtrlSetGraphic($Legend, $GUI_GR_DOT, 130, 40)
;~ GUICtrlCreateLabel("Warnings", 150, 175, 70, 20)
;~ $WarningPercent = GUICtrlCreateLabel(Round($WarningsP1 * 100, 0) & "%", 200, 175, 30, 20);Calculates the total percentage to display
;~ ;=================================================================

GUISetState()
while 1
    $msg = GUIGetMsg()
    if $msg = $GUI_EVENT_CLOSE then Exit
WEnd

Share this post


Link to post
Share on other sites
Melba23

Chimaera,

Graphic controls are a law unto themselves when it comes to z-order! ;)

I suggest you create a child GUI to hold the graphic control - but you then have to look after the hiding/showing yourself like this: ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

$Pass = 16;Total number of Passed
$Fail = 3;Total Number of Failed
$Warnings = 5;Total Number of Warnings

;===== The following functions calculate Percentages and Degrees =====
$TotalTests = $Pass + $Fail + $Warnings;Get the total number of all "for Percentage calculations"

$PassP1 = $Pass / $TotalTests;Get percentage of Total Passed
$PassP =  $PassP1 * 360;Get the Degrees from the Passed Percentage

$FailP1 = $Fail / $TotalTests;Get Percentage of Total Failed
$FailP =  $FailP1 * 360;Get the Degrees from the Failed percentage

$WarningsP1 = $Warnings / $TotalTests;Get Percentage of Total Warnings
$WarningsP = $WarningsP1 * 360;Get the Degrees from the Warning Percentage

$hGUI = GUICreate("Test", 500, 500)

$hTab = GUICtrlCreateTab(10, 20, 300, 280)
$hTab0 = GUICtrlCreateTabItem(" Information ")
$hTab1 = GUICtrlCreateTabItem(" Another Tab ")
GUICtrlCreateTabItem("")

GUISetState()

; Create child GUI to hold graphic
$hGraphic_Win = GUICreate("", 280, 240, 20, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)

$Pie1 = GuiCtrlCreateGraphic(0, 00, 280, 240);Create the main graphic area
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xF0F8FF);Set the color of Passed to light blue
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90, $PassP);Set the Pie Chart piece Starts at 90^ and sweeps for $PassP number of ^
;Failed Pie section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x8B0000);Set color of Failed to dark red
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $PassP, $FailP);Set the Pie Chart piece Starts at 90^ + total ^ of $PassP
;Warnings Pie Section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xFFD700);Set color of warning to dark Yellow
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $PassP + $FailP, $WarningsP);Set the Pie Chart piece Start at 90^ + Total ^ of $PassP and $FailP

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Which tab is selected?
            Switch GUICtrlRead($hTab)
                Case 0
                    WinSetState($hGraphic_Win, "", @SW_SHOW)
                Case 1
                    WinSetState($hGraphic_Win, "", @SW_HIDE)
            EndSwitch
    EndSwitch
WEnd

Please ask if you have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
taietel

Or something like this:

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Form1", 348, 266, 192, 114)
$Tab1 = GUICtrlCreateTab(32, 40, 289, 193)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")

$Graphic1 = GUICtrlCreateGraphic(80, 97, 120, 120)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000, 0xFF0000)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 56, 56, 56, 0, 120)
GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFFFF00, 0xFFFF00)
GUICtrlSetGraphic(-1, $GUI_GR_PIE, 56, 56, 56, 120, 240)
GuiCtrlSetState(-1,$GUI_ONTOP)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
While 1
 Sleep(10)
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
 EndSwitch
WEnd

Share this post


Link to post
Share on other sites
Melba23

taietel,

Clever! :)

I would have though that the $GUI_ONTOP style would have placed the graphic on top of the z-order for all tabs. Now I know better - thanks. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
taietel

Thanks Melba! I've learned from one of the best. :)

Here is a variation, slightly 3D:

#include <GUIConstantsEx.au3>

$Form1 = GUICreate("Form1", 348, 266)
$Tab1 = GUICtrlCreateTab(32, 40, 289, 193)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
_SomePie(60,70,160)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

While 1
 Sleep(10)
 $nMsg = GUIGetMsg()
 Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit

 EndSwitch
WEnd

Func _SomePie($iX, $iY, $iW, $iR=0, $iH=0)
 If $iH=0 Then $iH=$iW
 If $iR=0 Then $iR=Round($iW/2.5,1)

 Local $hGraphic = GUICtrlCreateGraphic($iX, $iY, $iW, $iH)

 For $i=0 To 5 Step 0.5
  GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFF0000, 0x990000)
  GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10+$iX-$i, $iY-$i, $iR, 0, 120)
 Next

 For $i=0 To 5
  GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xFFFF00, 0x999900)
  GUICtrlSetGraphic(-1, $GUI_GR_PIE, 10+$iX-$i, 10+$iY-$i, $iR, 120, 240)
 Next
 
 GuiCtrlSetState(-1,$GUI_ONTOP)
EndFunc

Share this post


Link to post
Share on other sites
Chimaera

Thanks for doing those unfortunatly i have input vars that i need it to work from

So these wont do for that, i really liked the slightly 3d one cool

Chim

This is what i have so far

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstants.au3>

$Pie_Income = 16 ; to be replaced by input vars
$Pie_House = 3 ; to be replaced by input vars
$Pie_Living = 5 ; to be replaced by input vars
$Pie_Finance = 6 ; to be replaced by input vars
$Pie_Family = 4 ; to be replaced by input vars
$Pie_Travel = 5 ; to be replaced by input vars
$Pie_Leisure =2 ; to be replaced by input vars
;===== The following functions calculate Percentages and Degrees =====
$TotalTests = $Pie_Income + $Pie_House + $Pie_Living + $Pie_Finance + $Pie_Family + $Pie_Travel + $Pie_Leisure         ;Get the total number of all "for Percentage calculations"

$Pie_Income_Perc = $Pie_Income / $TotalTests      ;Get percentage of Total Passed
$Pie_Income_Deg =  $Pie_Income_Perc * 360      ;Get the Degrees from the Passed Percentage

$Pie_House_Perc = $Pie_House / $TotalTests      ;Get Percentage of Total Failed
$Pie_House_Deg =  $Pie_House_Perc * 360      ;Get the Degrees from the Failed percentage

$Pie_Living_Perc = $Pie_Living / $TotalTests        ;Get Percentage of Total Warnings
$Pie_Living_Deg = $Pie_Living_Perc * 360      ;Get the Degrees from the Warning Percentage

$Pie_Finance_Perc = $Pie_Finance / $TotalTests        ;Get Percentage of Total Warnings
$Pie_Finance_Deg = $Pie_Finance_Perc * 360      ;Get the Degrees from the Warning Percentage

$Pie_Family_Perc = $Pie_Family / $TotalTests        ;Get Percentage of Total Warnings
$Pie_Family_Deg = $Pie_Family_Perc * 360      ;Get the Degrees from the Warning Percentage

$Pie_Travel_Perc = $Pie_Travel / $TotalTests        ;Get Percentage of Total Warnings
$Pie_Travel_Deg = $Pie_Travel_Perc * 360      ;Get the Degrees from the Warning Percentage

$Pie_Leisure_Perc = $Pie_Leisure / $TotalTests        ;Get Percentage of Total Warnings
$Pie_Leisure_Deg = $Pie_Leisure_Perc * 360      ;Get the Degrees from the Warning Percentage


$hGUI = GUICreate("Test", 500, 500)

$hTab = GUICtrlCreateTab(10, 20, 300, 280)
$hTab0 = GUICtrlCreateTabItem(" Information ")
$hTab1 = GUICtrlCreateTabItem(" Another Tab ")
GUICtrlCreateTabItem("")

GUISetState()

; Create child GUI to hold graphic
$hGraphic_Win = GUICreate("", 280, 240, 20, 50, $WS_POPUP, $WS_EX_MDICHILD, $hGUI)

$Pie1 = GuiCtrlCreateGraphic(0, 00, 280, 240);Create the main graphic area
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x736AFF)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90, $Pie_Income_Deg)
;Failed Pie section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x8B0000)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $Pie_Income_Deg, $Pie_House_Deg)
;Warnings Pie Section
GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xFFD700)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $Pie_Income_Deg + $Pie_House_Deg, $Pie_Living_Deg)

GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x4E387E)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $Pie_Income_Deg + $Pie_House_Deg + $Pie_Living_Deg, $Pie_Finance_Deg)

GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x48CCCD)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $Pie_Income_Deg + $Pie_House_Deg + $Pie_Living_Deg + $Pie_Finance_Deg, $Pie_Family_Deg)

GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0x347C17)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $Pie_Income_Deg + $Pie_House_Deg + $Pie_Living_Deg + $Pie_Finance_Deg + $Pie_Family_Deg, $Pie_Travel_Deg)

GUICtrlSetGraphic(-1,$GUI_GR_COLOR, 0x000000,0xF88017)
GUICtrlSetGraphic(-1,$GUI_GR_PIE, 120, 100, 80, 90 + $Pie_Income_Deg + $Pie_House_Deg + $Pie_Living_Deg + $Pie_Finance_Deg + $Pie_Family_Deg + $Pie_Travel_Deg, $Pie_Leisure_Deg)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hTab
            ; Which tab is selected?
            Switch GUICtrlRead($hTab)
                Case 0
                    WinSetState($hGraphic_Win, "", @SW_SHOW)
                Case 1
                    WinSetState($hGraphic_Win, "", @SW_HIDE)
            EndSwitch
    EndSwitch
WEnd

But when i add it into the main script it goes pear shaped and just draws one half of the circle colured in, yet in the example it works fine, so i guess i have a variable problem or something like that.

Edited by Chimaera

Share this post


Link to post
Share on other sites
Melba23

Chimaera,

Have you tried with taietel's simpler solution? :)

As I have suggested to you in another thread, it helps if you post the whole script with which you are having problems - trying to solve your problems via small snippets of code and cryptic "guesses" is not terribly efficient. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
taietel

Or try this sample (instead pie it has graph bars):

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Array.au3>

Global $arNames=StringSplit("January|February|March|April|May|June|July|August|September|October|November|December","|",2)
Global $arValues[12]
;fill the array of values with some random numbers
For $i=0 To 11
 $arValues[$i]=Random(0,200,1)
Next

GUICreate("Form1", 600, 600)

$Tab1 = GUICtrlCreateTab(20, 20, 560, 560)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
_CreateBarChart("3D Bar Chart","Example",40,80,500,400)
GUICtrlCreateTabItem("")

GUISetState(@SW_SHOW)

While 1
 Sleep(10)
 Switch GUIGetMsg()
  Case $GUI_EVENT_CLOSE
   Exit
 EndSwitch
WEnd


; #FUNCTION# ====================================================================================================
; Name...........: _CreateBarChart
; Description....: Create 3D bar graph with native AutoIt functions
; Syntax.........: _CreateBarChart($sTitle1="",$sTitle2="",$iX=20,$iY=20,$iW=400,$iH=400)
; Parameters.....: $sTitle1 - Title of the graph, [Optional]
;     $sTitle2 - Subtitle of the graph, [Optional]
;                  $iX - left margin, [Optional]
;                  $iY - top margin, [Optional]
;                  $iW - width of the graph, [Optional]
;                  $iH - height of the graph, [Optional]
;
; Return values..: none
; Version........:  2
; Author.........: Mihai Iancu (taietel at yahoo dot com)
; ===============================================================================================================
Func _CreateBarChart($sTitle1="",$sTitle2="",$iX=20,$iY=20,$iW=400,$iH=400)
 Local $max=_ArrayMax($arValues,1);compare numerically
 ;Local $values = UBound($arValues)
 Local $arColours[UBound($arNames)]
 Local $color
 For $i=0 To UBound($arValues)-1
  $color = (Random(100, 255, 1) * 0x10000) + (Random(100, 255, 1) * 0x100) + Random(100, 255, 1)

  $arColours[$i]=$color
 Next
 ;set default values for the frame
    If $iX=-1 Then $iX=20
    If $iY=-1 Then $iY=20
    If $iW=-1 Then $iW=400
    If $iH=-1 Then $iH=400
 ;create frame for the chart
    $grp = GUICtrlCreateGroup("", $iX, $iY, $iW, $iH)
    ;title
    GUICtrlCreateLabel($sTitle1,$iX+15, $iY+10,$iW-30,-1,$SS_CENTER)
    GUICtrlSetColor(-1,0x002244)
    GUICtrlSetFont(-1, 9, 800, 0, "Arial")
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
 GUICtrlCreateLabel($sTitle2,$iX+15, $iY+25,$iW-30,-1,$SS_CENTER)
    GUICtrlSetColor(-1,0x002244)
    GUICtrlSetFont(-1, 8, 800, 0, "Arial")
    GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
 Local $Canvas
 If IsString($arNames[1]) Then
  $Canvas = _CreateBarCanvas($iX+15, $iY+15, $iW-110, $iH-60)
  GUICtrlCreateGroup("Legend", $Canvas[0]+$Canvas[2]+10, $Canvas[1]-5, ($iW-$Canvas[2])/2-10, $Canvas[3]+$Canvas[4]+5)
        For $i=0 To UBound($arNames)-1
            GUICtrlCreateLabel($arNames[$i],$Canvas[0]+$Canvas[2]+20, $Canvas[1]+10+(($Canvas[3]+$Canvas[4]-15)/UBound($arNames))*$i,($iW-$Canvas[2])/2-30,13,$SS_CENTER)
            GUICtrlSetColor(-1,$arColours[$i]-0x444444)
            GUICtrlSetFont(-1, 8, 800, 0, "Arial")
            GUICtrlSetBkColor(-1,$arColours[$i])
        Next
        GUICtrlCreateGroup("", -99, -99, 1, 1)
 Else
  $Canvas = _CreateBarCanvas($iX+15, $iY+15, $iW-50, $iH-60)
  For $i=0 To UBound($arNames)-1
            GUICtrlCreateLabel($arNames[$i],$iX+52+(($Canvas[2]/UBound($arNames)))*$i+5, $iY+$iH-30)
            GUICtrlSetColor(-1,0x990000)
            GUICtrlSetFont(-1, 8, 800, 0, "Arial")
            GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
        Next
 EndIf
 ;draw the bars
 GUICtrlCreateGraphic($Canvas[0]-0.5*$Canvas[4], $Canvas[1]+0.5*$Canvas[4], $Canvas[2], $Canvas[3],0)
 For $i=0 To UBound($arValues)-1
        For $j=$Canvas[4]/2.5 To 0 Step -0.5
            GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $arColours[$i]-0x333333, $arColours[$i])
            GUICtrlSetGraphic(-1, $GUI_GR_RECT, 5+($Canvas[2]/UBound($arValues))*$i+$j, -2+$Canvas[3]-$j, 0.6*($Canvas[2]/UBound($arValues)), -($Canvas[3]/_RoundUp($max))*$arValues[$i])
        Next
 Next
 GUICtrlSetGraphic(-1,$GUI_GR_REFRESH)
 GuiCtrlSetState(-1,$GUI_ONTOP)
    For $i=0 To UBound($arValues)-1
        ;values from the top of the bars
  GUICtrlCreateLabel($arValues[$i],$iX+50+($Canvas[2]/UBound($arValues))*$i + $Canvas[4]/2.5 + 0.3*($Canvas[2]/UBound($arValues)), $iY+35+$Canvas[3]+ $Canvas[4]/2.5 -($Canvas[3]/_RoundUp($max))*$arValues[$i])
        GUICtrlSetColor(-1,0x002244)
        GUICtrlSetFont(-1, 7, 800, 0, "Arial")
        GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
    Next
 ;Y Axis
 For $i=0 To $Canvas[3] Step $Canvas[3]/5
  GUICtrlCreateLabel(($i/$Canvas[3])*_RoundUp($max),$Canvas[0]-65,$Canvas[1]+$Canvas[3]+$Canvas[4]-$i,30,-1,$SS_RIGHT)
  GUICtrlSetColor(-1,0x990000)
  GUICtrlSetFont(-1, 8, 800, 0, "Arial")
  GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
 Next
 GUICtrlCreateGroup("", -99, -99, 1, 1)
EndFunc
#Region INTERNAL USE ONLY
Func _RoundUp($m)
 Local $rv = Round(Ceiling($m/10)*10,-1)
 Return $rv
EndFunc

Func _CreateBarCanvas($iX=0, $iY=0, $iW=400, $iH=400, $iDepthCanvas=30, $BgColor=0xD4D4D4)
 Local $iXCanvas=$iX+$iDepthCanvas
 Local $iYCanvas=$iY+10+2*$iDepthCanvas
 Local $iWCanvas=$iW-2*$iDepthCanvas
 Local $iHCanvas=$iH-2*$iDepthCanvas
 Local $BgColor2 = $BgColor - 0x333333
 ;create bg for the bars
    For $i=0 To $iDepthCanvas
        GUICtrlCreateGraphic($iXCanvas+$i, $iYCanvas-$i, $iWCanvas, $iHCanvas, 0)
        GUICtrlSetBkColor(-1, $BgColor)
        GUICtrlSetColor(-1, $BgColor2)
  GuiCtrlSetState(-1,$GUI_ONTOP)
    Next
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $iHCanvas)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $BgColor)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, -$iDepthCanvas-1, $iHCanvas+$iDepthCanvas+1)
    ;horizontal grid
    For $i=0 To $iHCanvas Step $iHCanvas/5
        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $BgColor2)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, $iWCanvas, $i)

        GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i)
        GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $BgColor)
        GUICtrlSetGraphic(-1, $GUI_GR_LINE, -$iDepthCanvas, $i+$iDepthCanvas)
    Next
 Local $Canvas = StringSplit($iXCanvas+$iDepthCanvas &"|"& $iYCanvas-$iDepthCanvas&"|"&$iWCanvas&"|"&$iHCanvas&"|"&$iDepthCanvas,"|",2)
 Return $Canvas
EndFunc
#EndRegion INTERNAL USE ONLY

Modify it to fit your needs.

Regards,

taietel

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×