|
-
Apr 14th, 2006, 09:56 AM
#1
Thread Starter
Lively Member
Help with creating a pie chart - Resolved
Hiya
I have a program that creates a circle currently andcan make this a fulll circle by adjusting some scroll bars. I have a width, radius, startt and end scroll bar. When reducing the end scroll, this fills the circle with colour.... but I need to be able to change this into a pie chart and wondered if anyone can help me. This is what I have and I need to add a pie chart of A at 60 degrees (value 1), B at 120 degrees (value 2) and C at 180 degrees ()value 3.
I think I need to add A, B & C as variables but not sure the best way to go abount it. Under the Aend change - can I add this as a if then statement or should I be doing something similar to the end and have the 3 a, b and c set up in a similar way
This is using VB6.
Option Explicit
Dim X As Integer
Dim Y As Integer
Dim AStart As Integer
Dim AEnd As Integer
Dim Radius As Integer
Dim Aspect As Single
Const pi = 3.14159265
Dim Value As Integer
Private Sub cmdClose_Click()
'to end the program
End
End Sub
Private Sub cmdStyle_Click()
'change the Drawstyle property setting of the picture control(0 to 6)
picView.DrawStyle = (picView.DrawStyle + 1) Mod 7
picView.Cls 'redraw the circle
picView.Circle (X, Y), vbBlack, AStart, AEnd, Aspect
End Sub
Private Sub Form_Load()
Show 'Force the form to be made visiable
'otherwise the circle will not be drawn
Initalise ' To establish the start up values
End Sub
Sub Initalise()
X = picView.ScaleWidth / 2 'The circle of the circle
Y = picView.ScaleHeight / 2
Radius = hsbRadius.Value * 20 'scale up the scroll bar
Aspect = hsbAspect.Value / 10 ' Scale down the scroll bar
AStart = hsbStart.Value / 360 * 2 * pi 'convert to radians
AEnd = hsbEnd.Value / 360 * 2 * pi ' convert to radians
picView.Circle (X, Y), Radius, vbBlack, AStart, AEnd, Aspect
End Sub
Private Sub hsbAspect_Change()
Aspect = hsbAspect.Value / 10 'Change the aspect value
txtAspect.Text = Aspect 'update the textbox
picView.Cls 'redraw the circle
picView.Circle (X, Y), Radius, vbBlack, AStart, AEnd, Aspect
End Sub
Private Sub hsbEnd_Change()
AEnd = hsbEnd.Value / 360 * 2 * pi 'Change the end angle value
txtEnd.Text = hsbEnd.Value 'update the textbox
picView.FillColor = vbBlue
picView.FillStyle = 0
picView.Cls 'redraw the circle
picView.Circle (X, Y), Radius, vbBlack, -AStart, -AEnd, Aspect
End Sub
Private Sub hsbRadius_Change()
Radius = hsbRadius.Value * 20 'Change the radius value
txtRadius.Text = Radius 'update the textbox
picView.Cls 'redraw the circle
picView.Circle (X, Y), Radius, vbBlack, AStart, AEnd, Aspect
End Sub
Private Sub hsbStart_Change()
AStart = hsbStart.Value / 360 * 2 * pi 'Change the start angle value
txtStart.Text = hsbStart.Value 'update the textbox
picView.Cls 'redraw the circle
picView.Circle (X, Y), Radius, vbBlack, AStart, AEnd, Aspect
End Sub
Private Sub hsbAspect_Scroll()
hsbAspect_Change
End Sub
Private Sub hsbWidth_Change()
picView.DrawWidth = hsbWidth.Value 'Change the width of the line
txtWidth.Text = picView.DrawWidth 'update the textbox
picView.Cls 'redraw the circle
picView.Circle (X, Y), Radius, vbBlack, AStart, AEnd, Aspect
End Sub
Thanks
Tracey
Last edited by Tazmania; Apr 29th, 2006 at 11:28 AM.
Reason: Resolved
-
Apr 14th, 2006, 12:13 PM
#2
Re: Help with creating a pie chart
I've never used it but have you considered using the Microsoft Chart Control?
You can make your code easier to read if you surround the code with VBCode tags as in this example.
[vbcode]
'Your code
[/vbcode]
which will cause it to show up like this.
-
Apr 17th, 2006, 03:58 AM
#3
Thread Starter
Lively Member
Re: Help with creating a pie chart
Hi Marty
Thanks for his, but I need to be able to create this in vb. This issome course work I am doing for a vb course and I then need to learn how to do this as I need to use a similar thing to mput into an exam in a few weeks......
Any other suggestions?
Thanks
Tracey
-
Apr 17th, 2006, 10:17 AM
#4
Re: Help with creating a pie chart
 Originally Posted by Tazmania
Hi Marty
Thanks for his, but I need to be able to create this in vb....
It is VB. Look in Project|Components|Microsoft Chart Control 6.0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|