今天摆弄VS2005,无意中发现,原来VS2005已经内嵌了画饼图的代码,通过Graphics对象的FillPie方法来实现的,代码量更小,执行效率也应该比之前我写的那个Demo要好一些。感慨做应用层的程序员和工人的区别真的不大了~
' Shows how to call the DrawPieChart method
Public Sub DrawPieChartHelper()
Dim percents() As Integer = {10, 20, 70}
Dim colors() As Color = {Color.Red, Color.CadetBlue, Color.Khaki}
Dim graphics As Graphics = Me.CreateGraphics
Dim location As Point = New Point(10, 10)
Dim size As Size = New Size(150, 150)
DrawPieChart(percents, colors, graphics, location, size)
End Sub
' Draws a pie chart.
Public Sub DrawPieChart(ByVal percents() As Integer, ByVal colors() As Color, _
ByVal surface As Graphics, ByVal location As Point, ByVal pieSize As Size)
' Check if sections add up to 100.
Dim sum As Integer = 0
For Each percen
' Shows how to call the DrawPieChart method
Public Sub DrawPieChartHelper()
Dim percents() As Integer = {10, 20, 70}
Dim colors() As Color = {Color.Red, Color.CadetBlue, Color.Khaki}
Dim graphics As Graphics = Me.CreateGraphics
Dim location As Point = New Point(10, 10)
Dim size As Size = New Size(150, 150)
DrawPieChart(percents, colors, graphics, location, size)
End Sub
' Draws a pie chart.
Public Sub DrawPieChart(ByVal percents() As Integer, ByVal colors() As Color, _
ByVal surface As Graphics, ByVal location As Point, ByVal pieSize As Size)
' Check if sections add up to 100.
Dim sum As Integer = 0
For Each percen