先在“部件”里選上“Microsoft Chart Control 6.0”,并添加一個MSChart1。
公司主營業(yè)務(wù):網(wǎng)站設(shè)計、成都網(wǎng)站制作、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)推出阿克蘇免費做網(wǎng)站回饋大家。
Private Sub Form_Load()
With MSChart1
.chartType = VtChChartType2dPie '表示餅圖
.ColumnCount = 3 '這里是每個餅圖的數(shù)據(jù)個數(shù)
.ColumnLabel = "你的數(shù)據(jù)名稱"
.RandomFill = True '暫且用隨機數(shù)填圖,數(shù)據(jù)請自己輸入
.RowCount = 2 '你說的“畫兩部分的餅狀圖就成”
.RowLabel = "你的數(shù)據(jù)標簽"
.TitleText = "你的圖表名稱"
End With
End Sub
Dim MyGraphics As Graphics = Me.PictureBox1.CreateGraphics
Dim MyBrush As New SolidBrush(Color.Red)
Dim MyProportion As Single
Dim MyRect As New Rectangle
Dim MyPoint As New PointF
Dim R As Single
Const PI = 3.1415926
MyGraphics.Clear(Color.White)
Dim MyStartAngel As Double
Dim MySweepAngel As Double
R = Math.Min(Me.PictureBox1.Width, Me.PictureBox1.Height) / 2 - 15
MyPoint.X = Me.PictureBox1.Width / 2
MyPoint.Y = Me.PictureBox1.Height / 2
MyRect.X = MyPoint.X - R
MyRect.Y = MyPoint.Y - R
MyRect.Width = R * 2
MyRect.Height = R * 2
MyStartAngel = 0
MyProportion = Val(TextBox7.Text)
MySweepAngel = MyProportion * 360 / PI
MyBrush.Color = Color.Red
MyGraphics.FillPie(MyBrush, MyRect, MyStartAngel, MySweepAngel)
' MyStartAngel = MyStartAngel + MySweepAngel
MyProportion = 0.75
MySweepAngel = 360 * MyProportion
MyBrush.Color = Color.Blue
MyGraphics.FillPie(MyBrush, MyRect, MyStartAngel, MySweepAngel)
新建一個Winform,拖兩個圖片框。圖片框1在設(shè)計器中選擇一個圖片(尺寸在圖片框容納為佳)。如下代碼測試通過:
private?void?button1_Click(object?sender,?EventArgs?e)
{
Image?img1?=?this.pictureBox1.Image;
Image?img2?=?CropToCircle(img1);
this.pictureBox2.Image?=?img2;
}
public?Image?CropToCircle(Image?img1)
{
Image?img2?=?new?Bitmap(img1.Width,?img1.Height,?
img1.PixelFormat);
Graphics?g?=?Graphics.FromImage(img2);
using?(Brush?br?=?
new?SolidBrush(SystemColors.Control))//背景色
{
g.FillRectangle(br,?0,?0,?
img2.Width,?img2.Height);
}
GraphicsPath?path?=?new?GraphicsPath();
path.AddEllipse(0,?0,?img2.Width,?img2.Height);
g.SetClip(path);
g.DrawImage(img1,?0,?0);
return?img2;
}
用宏功能啊,然后把宏代碼(vb6.0)轉(zhuǎn)化為Vb.net代碼,有一個關(guān)鍵問題,就是VBA中的枚舉類型在Vb.net中不適用,比如.End(xlUp)更改為.End(3)就能運行,另外vb.net中運行Excel對象不一定在點后會出現(xiàn)智能提示(即使你引用后也一樣)你只要確定有該方法或者屬性,直接寫就是了,生成或者調(diào)試都是可以通過的
給你一個步驟吧.
設(shè)立一個圓心(即定一個點)
再按照用PI轉(zhuǎn)角來畫就行了.
最后加上你需要的顏色
我自己寫的控件,里面有示例程序,很簡單的。不過餅圖只設(shè)置了12種顏色。。。只能顯示12項
分享題目:vb.net圓餅圖,winform餅圖
標題路徑:http://chinadenli.net/article2/heehic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、ChatGPT、App設(shè)計、網(wǎng)站維護、做網(wǎng)站、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)