Sign in to follow this  
Followers 0
BigDaddyO

Pie Chart, Easily updated variables

6 posts in this topic

#1 ·  Posted (edited)

Hello all,

I am working on a reporting tool for some tests that I run with AutoIT and this is what I will be using to display the Pass/Fail/Warnings for each test in a simple Pie chart.

Let me know what you think... I put in a lot of comments because I found the help file on the GUICtrlSetGraphic pretty hard to understand.

Mike

; ----------------------------------------------------------------------------
;
; 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", 240, 200);Create the GUI window
$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, 60, 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, 60, 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, 60, 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
Edited by MikeOsdx

Share this post


Link to post
Share on other sites



Mike

Dont understand why, your code looks ok to me, but when i run this in latest beta and release versions i get 3 errors

ERROR: GUICtrlSetGraphic() [built-in] called with wrong number of args.

GUICtrlSetGraphic($-1,$GUI_GR_PIE, 120,70, 60, 90,$PassP)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Each connected with the 3 setgraphic PIE lines.

if i click continue anyway, the output is as your thumbnail and every thing seems ok.

Any hints? I checked help file and the correct arguments are defined. As i said dont think its your code. Probably me, but im having one of those days!

Thanks for sharing.

HardCopy


Contributions: UDF _DateYearFirstChildren are like Farts, you can just about stand your own.Why am I not a Vegetarian?...Well...my ancestors didn't fight & evolve to the Top of the food chain for me to survive on Salad

Share this post


Link to post
Share on other sites

Mike

Dont understand why, your code looks ok to me, but when i run this in latest beta and release versions i get 3 errors

ERROR: GUICtrlSetGraphic() [built-in] called with wrong number of args.

GUICtrlSetGraphic($-1,$GUI_GR_PIE, 120,70, 60, 90,$PassP)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Each connected with the 3 setgraphic PIE lines.

if i click continue anyway, the output is as your thumbnail and every thing seems ok.

Any hints? I checked help file and the correct arguments are defined. As i said dont think its your code.  Probably me, but im having one of those days!

Thanks for sharing.

HardCopy

<{POST_SNAPBACK}>

I have been getting the same thing, I am just used to ignoring the errors since I have been using alot of the newer functions in the Beta, I think the AU3Check utility does not get updated as often as the Beta AutoIT does.

Share this post


Link to post
Share on other sites

I have been getting the same thing,  I am just used to ignoring the errors since I have been using alot of the newer functions in the Beta,  I think the AU3Check utility does not get updated as often as the Beta AutoIT does.

<{POST_SNAPBACK}>

How can we disable that annoying check when running with beta?

Share this post


Link to post
Share on other sites

How can we disable that annoying check when running with beta?

<{POST_SNAPBACK}>

I just looked it up and if you open the AU3.Properties file in your SCITE directory.

On line 34 just under # 0 Beta RUN there is a commented line, uncomment that line and then comment the next line that shows the ComplieAU3.exe

Save the file and run the script again. Worked for me.

Mike


Share this post


Link to post
Share on other sites

Hi!

I did something very similar (-> http://www.autoitscript.com/forum/index.php?showtopic=14789).

I will have a look at your code, perhaps I can find some tricks.

I would suggest that we could work together evtl.

We could ask CyberSlug who did sth. similar too some time ago.

I would like to hear from you,

peethebee


vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvGerman Forums: http://www.autoit.deGerman Help File: http://autoit.de/hilfe vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv

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  
Followers 0