方法一:Excel中就可以實現(xiàn);
10年積累的網(wǎng)站設(shè)計、網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有樂山免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
方法二:通過VB.net將數(shù)據(jù)寫入到Excel中生成趨勢圖;
方法三:直接通過VB.net寫出這種趨勢圖。
具體方法可以參考VB.net操作Excel方法:
可用代碼:
For i = 0 To iRow - 1
pointXY(i) = "'這里你可以直接放上你的數(shù)據(jù)點值在X線上
"
pointYY(i) = "'這里你可以直接放上你的數(shù)據(jù)點值在Y線上
Next
Private Sub DrawRectangle()
Try
Dim oV2Bar As New Graphing.V3.Bar.BarChart()
Dim renderer As New Graphing.V3.Render
PictureBox1.Image = renderer.DrawChart(oV2Bar, Xline,Yline iRow, pointXY, pointYY)
End If
Catch ex As Exception
MsgBox(ex.Message)
Public Class BarChart : Inherits Base.BaseGraph
'This will hold the Bar pieces.
Public BarSliceCollection As New Bar.BarPieceCollection()
Private _Alignment As Base.b_BarTypes = Base.b_BarTypes.HorizontalLeft
Public Property Alignment() As Base.b_BarTypes
Get
Return _Alignment
End Get
Set(ByVal Value As Base.b_BarTypes)
_Alignment = Value
End Set
End Property
'Private _ChartType As Base.b_ChartType = Base.b_ChartType.Bar
Public Shadows ReadOnly Property ChartType() As Base.b_ChartType
Get
Return MyBase.ChartType
End Get
End Property
Sub New()
MyBase.new()
MyBase.ChartType = Base.b_ChartType.Bar
End Sub
Sub New(ByVal BarPieceCollection As BarPieceCollection)
MyBase.new()
MyBase.ChartType = Base.b_ChartType.Bar
BarSliceCollection = BarPieceCollection
End Sub
End Class
End Try
End Sub
。net ?其實還是很好繪制圖形的
你可以看下?Graphics ?類
Dim d As New Bitmap(Me.Width, Me.Height) ?‘一個圖片吧
? Dim g As Graphics = Graphics.FromImage(d)’繪制 ?準備在這個圖片是進行
然后 ?就是你繪制的東西了
線 就是 ??g.DrawLine()
圓 弧度 ?就用 ?g.DrawArc(Pens.Black, New Rectangle(0, 0, 400, 200), 0, 360)
復(fù)雜的就是 ? ? ?g.DrawBezier()
等 ?如果你用的是 VS的 ?編譯 ?上面都有詳細的參數(shù)說明
Dim?d?As?New?Bitmap(Me.Width,?Me.Height)
Dim?g?As?Graphics?=?Graphics.FromImage(d)
g.DrawArc(Pens.Black,?New?Rectangle(0,?0,?200,?200),?0,?360)
g.DrawLine(Pens.Red,?New?Point(0,?0),?New?Point(200,?200))
g.DrawLines(Pens.Green,?New?Point()?{New?Point(0,?0),?New?Point(50,?40),?New?Point(50,?80),?New?Point(90,?70),?New?Point(100,?400)})
g.DrawBezier(Pens.Yellow,?New?Point(0,?100),?New?Point(0,?0),?New?Point(200,?0),?New?Point(200,?200))
g.Dispose()
Me.BackgroundImage?=?d
新建窗口,添加picture控件
利用line()方法畫線
line(開始x坐標,開始y坐標)-(結(jié)束x坐標,結(jié)束y坐標),線的顏色,畫線的方式(默認為線,B為矩形無填充,BF為填充的矩形)
For i = 1 To 16
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(255, 0, 0)
Picture1.Line (0, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(255, 0, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), 0), RGB(0, 255, 0)
Picture1.Line (Picture1.Width, Picture1.Height / 2)-(i * (Picture1.Width / 16), Picture1.Height), RGB(0, 255, 0)
Next i
如果要在窗口上畫也可以調(diào)用窗口的line方法即form.line()
這個要用GDI+畫。要看你.net版本。
以下是VS2005中的一段代碼。
Me.PictureBox1.Height = 450
Me.PictureBox1.Width = 880
Dim gr As Graphics '定義畫布
Dim bp As New Bitmap(880, 450) '定義位圖,并進行賦值
Dim p As New Pen(Color.Black) '定義畫筆
p.Width = 2 '寬度2
p.DashStyle = Drawing2D.DashStyle.Solid '樣式直線
PictureBox1.Image = bp
gr = Graphics.FromImage(PictureBox1.Image)
gr.FillRectangle(Brushes.White, New Rectangle(0, 0, PictureBox1.Width, PictureBox1.Height))
gr.DrawLine(p, a, b, a, .Height - b) '繪制縱坐標
gr.DrawLine(p, a, .Height - b, .Width - a, .Height - b) '繪制橫坐標
可以把所有畫的線都保存在一個列表中,畫的時候全部畫出即可。如下:
Public?Class?Form1
Class?Line? ? ? '直線類
? Public?Point1,?Point2?As?Point? ? ?'成員,直線的兩個端點
? Sub?New(p1?As?Point,?p2?As?Point)? ?'構(gòu)造方法
? ? ? Point1?=?p1
? ? ? Point2?=?p2
? End?Sub
? Public?Sub?Draw(g?As?Graphics)? ? ? '繪制方法
? ? ? g.DrawLine(Pens.Black,?Point1,?Point2)
? End?Sub
End?Class
Private?Lines?As?New?List(Of?Line)? ? ? '列表用于保存所有畫下的直線
Private?Sub?Form1_Load(sender?As?Object,?e?As?EventArgs)?Handles?MyBase.Load
? BackColor?=?Color.White
? DoubleBuffered?=?True? ? ? ?'開啟雙緩沖可有效避免閃爍
End?Sub
Private?Sub?Form1_MouseDown(sender?As?Object,?e?As?MouseEventArgs)?Handles?Me.MouseDown
? Lines.Add(New?Line(e.Location,?e.Location))? ? ?'在直線列表中添加直線
End?Sub
Private?Sub?Form1_MouseMove(sender?As?Object,?e?As?MouseEventArgs)?Handles?Me.MouseMove
? If?e.Button??Windows.Forms.MouseButtons.Left?Then?Return?'左鍵未按下
? '鼠標拖動時改變列表最后一條直線(也即當(dāng)前直線的第二個端點)
? Lines(Lines.Count?-?1).Point2?=?e.Location
? Refresh()? ? ? ?'刷新窗體
End?Sub
'在Form的Paint事件中繪制所有直線,每次Form1重繪時都會觸發(fā)Paint事件
'PS:?也可以通過重寫OnPaint方法來達到類似的效果
Private?Sub?Form1_Paint(sender?As?Object,?e?As?PaintEventArgs)?Handles?Me.Paint
? e.Graphics.SmoothingMode?=?Drawing2D.SmoothingMode.AntiAlias? ? '開啟抗鋸齒
? For?Each?l?In?Lines? ? ?'遍歷所有直線
? ? ? l.Draw(e.Graphics)? '調(diào)用繪制方法,傳入的參數(shù)可以理解為畫布
? Next
End?Sub
End?Class
運行效果: