方法二:通过VB.net将数据写入到Excel中生成趋势图;
方法三:直接通过VB.net写出这种趋势图。
具体方法可以参考VB.net *** 作Excel方法:http://hi.baidu.com/jonesvale/blog/item/3134ff1ecebdfc64f724e44b.html
可用代码:
For i = 0 To iRow - 1
pointXY(i) = "'这里你可以直接放上你的数据点值在X线上
"
pointYY(i) = "'这里你可以直接放上你的数据点值在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
分类: 电脑/网络 >>程序设计 >>其他编程语言解析:
1 新建一个工程。
2 在工程/部件内加载图表控件到工具栏上。在窗体上绘制这个控件。
3 在窗体上绘制一个命令按钮。
在此按钮的Click事件内编写代码给图表控件的数据网格属性赋值,值是一个二维数组,假定为dim X(1 to 3,1 to 4),必须先给每个数组元素赋值。
数据网格属性接收到X的值,即自动绘出图形,此时是默认的柱形图,通过更改图表类型,就可变成折线图。
先加入一个mschart控件插入如下显示代码
Private Sub GraphShowBasic()
With MSChart1.Plot.Backdrop
' 除非将样式属性正确地设置为VtFillStyleBrush
' 否则不会有颜色显示。
.Fill.Style = VtFillStyleBrush
.Fill.Brush.FillColor.Set 100, 255, 200
' 添加边框。
.Frame.Style = VtFrameStyleThickInner
' 将样式设置为显示阴影。
.Shadow.Style = VtShadowStyleDrop
End With
With MSChart1.Plot
' 将样式设置为实心。
.Wall.Brush.Style = VtBrushStyleSolid
' 将颜色设置为。
.Wall.Brush.FillColor.Set 255, 255, 0
End With
With MSChart1.Plot '将绘图底色设置为蓝色。
.PlotBase.BaseHeight = 200
.PlotBase.Brush.Style = VtBrushStyleSolid
.PlotBase.Brush.FillColor.Set 0, 0, 255
End With
With MSChart1.Title.VtFont
.Name = "趋势图"
.Style = VtFontStyleBold
.Effect = VtFontEffectUnderline
.Size = 14
.VtColor.Set 255, 0, 255
End With
End Sub
然后在Private Sub Form_Activate()中加入如下代码
Call GraphShowBasic
Dim show_arr(3, 2)
show_arr(0, 1) = "加"
show_arr(0, 2) = comp1
show_arr(1, 1) = "减"
show_arr(1, 2) = comp2
show_arr(2, 1) = "乘"
show_arr(2, 2) = comp3
show_arr(3, 1) = "除"
show_arr(3, 2) = comp4
'其中comp1—comp4为四种运算的正确率
With MSChart1
.RowCount = 4
.ChartData = show_arr
.Column = 1
.Refresh
End With
试试吧,测试是可以用的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)