Wasim Sayyed King
Member
- Joined
- Mar 24, 2012
- Messages
- 7
- Location
- Mumbai, Maharashtra, India, India
- Programming Experience
- 1-3
i want to make this pae chart but output is not proper as i want my values for lblTotalBuying.Text and lblTotalSelling.Text are to big in thousands
if i set the values of these labels under 100 then output is proper
Public Sub DrawPieChart(ByVal percents() As Integer, ByVal colors() As Color, _
ByVal surface As Graphics, ByVal location As Point, ByVal pieSize As Size)
Dim sum As Integer = 0
For Each percent As Integer In percents
sum += percent
Next
Dim percentTotal As Integer = 0
For percent As Integer = 0 To percents.Length() - 1
surface.FillPie( _
New SolidBrush(colors(percent)), _
New Rectangle(location, pieSize), CType(percentTotal * 360 / 100, Single), _
CType(percents(percent) * 360 / 100, Single))
percentTotal += percents(percent)
Next
Return
End Sub
Private Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGenerate.Click
Dim mycon7 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\My Project\My Project\Stone Crusher\myproject.accdb")
mycon7.Open()
Dim cmd7 As New OleDb.OleDbCommand("select sum(total_price) from Transaction_table where Type='Buying'", mycon7)
Dim i As Integer = cmd7.ExecuteScalar
mycon7.Close()
lblTotalBuying.Text = i
mycon7.Open()
Dim cmd As New OleDb.OleDbCommand("select sum(total_price) from Transaction_table where Type='Selling'", mycon7)
Dim j As Integer = cmd.ExecuteScalar
mycon7.Close()
lblTotalSelling.Text = j
lblGrossAmount.Text = j - i
If j > i Then
lblStatusProfit.Visible = True
lblStatusProfit.Text = "You are in Profit"
Else
lblStatusLoss.Visible = True
lblStatusLoss.Text = "You are in Loss"
End If
Dim percents() As Integer = {lblTotalBuying.Text, lblTotalSelling.Text}
Dim colors() As Color = {Color.Blue, Color.Green, Color.Red}
Dim graphics As Graphics = Me.CreateGraphics
Dim location As Point = New Point(470, 180)
Dim size As Size = New Size(200, 200)
DrawPieChart(percents, colors, graphics, location, size)
End Sub
if i set the values of these labels under 100 then output is proper
Public Sub DrawPieChart(ByVal percents() As Integer, ByVal colors() As Color, _
ByVal surface As Graphics, ByVal location As Point, ByVal pieSize As Size)
Dim sum As Integer = 0
For Each percent As Integer In percents
sum += percent
Next
Dim percentTotal As Integer = 0
For percent As Integer = 0 To percents.Length() - 1
surface.FillPie( _
New SolidBrush(colors(percent)), _
New Rectangle(location, pieSize), CType(percentTotal * 360 / 100, Single), _
CType(percents(percent) * 360 / 100, Single))
percentTotal += percents(percent)
Next
Return
End Sub
Private Sub cmdGenerate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdGenerate.Click
Dim mycon7 As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\My Project\My Project\Stone Crusher\myproject.accdb")
mycon7.Open()
Dim cmd7 As New OleDb.OleDbCommand("select sum(total_price) from Transaction_table where Type='Buying'", mycon7)
Dim i As Integer = cmd7.ExecuteScalar
mycon7.Close()
lblTotalBuying.Text = i
mycon7.Open()
Dim cmd As New OleDb.OleDbCommand("select sum(total_price) from Transaction_table where Type='Selling'", mycon7)
Dim j As Integer = cmd.ExecuteScalar
mycon7.Close()
lblTotalSelling.Text = j
lblGrossAmount.Text = j - i
If j > i Then
lblStatusProfit.Visible = True
lblStatusProfit.Text = "You are in Profit"
Else
lblStatusLoss.Visible = True
lblStatusLoss.Text = "You are in Loss"
End If
Dim percents() As Integer = {lblTotalBuying.Text, lblTotalSelling.Text}
Dim colors() As Color = {Color.Blue, Color.Green, Color.Red}
Dim graphics As Graphics = Me.CreateGraphics
Dim location As Point = New Point(470, 180)
Dim size As Size = New Size(200, 200)
DrawPieChart(percents, colors, graphics, location, size)
End Sub