求编程高手!VB.NET中根据SQL Server数据库中的数据如何生成曲线??

如何在VB.NET中根据SQLServer数据库中的数据生成曲线,我在SQL中建立了数据库:jiankong;建立了表:quxian;表中有两列分别是time(代表x轴)... 如何在VB.NET中根据SQL Server数据库中的数据生成曲线,我在SQL中建立了数据库:jiankong;建立了表:quxian;表中有两列分别是time(代表x轴)和PH值(代表y轴)。在VB.NET如何能根据表中的数据生成曲线,求源码。我的QQ:94676446,邮箱ljg025718@163.com运行成功另加分。 展开
 我来答
clarkbao
2011-03-21 · 超过53用户采纳过TA的回答
知道小有建树答主
回答量:99
采纳率:0%
帮助的人:106万
展开全部
Public Structure CPictureSet
Public OrignPos As Point
Public LabelFont As Font
Public DataFont As Font
Public XStep As Integer
Public YStep As Integer
Public XAuto As Boolean
Public YAuto As Boolean
Public Width As Integer
Public Height As Integer
Public XScale As Single
Public YScale As Single
Public YLabelStep As Single
Public YLabelAuto As Boolean
Public ShowLabel As Boolean
Public XLabel As String
Public YLabel As String
Public ShowXGrid As Boolean
Public ShowYGrid As Boolean
Public ShowData As Boolean
Public LineWidth As Integer
Public LineWidth2 As Integer
Public LineStyle As Integer
Public LineStyle2 As Integer
Public colLine As Color
Public colLine2 As Color
Public colFill As Color
Public colFill2 As Color
Public colLabel As Color
Public colText As Color
Public colRect As Color
Public colDataMarking As Color
Public DataFormat As String
Public CL As Single
Public Digit As Integer
Public DFStyle As String
End Structure

Public Sub DrawTrendLine(ByVal PictureSetting As CPictureSet, ByVal PicCtl As PictureBox, ByRef TotalPoint As Integer, ByRef YValue() As Single, ByRef XLabel() As String)
Try
If TotalPoint <= 0 Then Exit Sub

Dim i As Integer, j As Integer
Dim StrTemp As String
Dim sigTemp As Single
Dim P1 As Point, P2 As Point
Dim PLine() As Point
Dim X As Integer, Y As Integer
Dim Max As Single, Min As Single

With PictureSetting
ReDim PLine(TotalPoint - 1)
Max = -1000000000
Min = 10000000000

For i = 0 To TotalPoint - 1
If YValue(i) > Max Then Max = YValue(i)
If YValue(i) < Min Then Min = YValue(i)
Next

If Max <= 0 Then Exit Sub
.XStep = .Width / TotalPoint
.YScale = .Height / Max

PLine(0).X = .OrignPos.X + .XStep / 2
For i = 1 To TotalPoint - 1
PLine(i).X = PLine(i - 1).X + .XStep
Next

For i = 0 To TotalPoint - 1
PLine(i).Y = .OrignPos.Y - YValue(i) * .YScale
Next
End With

Dim bmp As New Bitmap(PicCtl.Width, PicCtl.Height)
Dim gPen As New Pen(Color.Black, PictureSetting.LineWidth)
Dim gFont As New Font("Arial", 10)
Dim gBrush As New SolidBrush(Color.Black)
Dim gTemp As Graphics = Graphics.FromImage(bmp)
Dim stringSize As SizeF

'画曲线
gTemp.Clear(Color.White)
With PictureSetting
gPen.Color = .colLine
gPen.Width = .LineWidth
gPen.DashStyle = .LineStyle
gBrush.Color = .colFill
End With

gTemp.DrawLines(gPen, PLine)
For i = 0 To TotalPoint - 1
gTemp.FillEllipse(gBrush, PLine(i).X - 2, PLine(i).Y - 2, 4, 4)
Next

'画管制线
If PictureSetting.CL > 0.00001 Then
With PictureSetting
gPen.Color = .colLine2
gPen.Width = .LineWidth2
gPen.DashStyle = .LineStyle2
gFont = .LabelFont
gBrush.Color = .colLabel
P1.X = .OrignPos.X
If .DFStyle = "Percent" Then
P1.Y = .OrignPos.Y - .CL * 100 * .YScale
Else
P1.Y = .OrignPos.Y - .CL * .YScale
End If

P2.X = P1.X + TotalPoint * .XStep
P2.Y = P1.Y
End With
If PictureSetting.DFStyle = "Percent" Then
StrTemp = "CL=" & Format(PictureSetting.CL, PictureSetting.DataFormat & "%")
Else
StrTemp = "CL=" & Format(PictureSetting.CL, PictureSetting.DataFormat)
End If

stringSize = gTemp.MeasureString(StrTemp, gFont)
X = P2.X + 5
Y = P1.Y - stringSize.Height / 2
gTemp.DrawLine(gPen, P1, P2)
gTemp.DrawString(StrTemp, gFont, gBrush, X, Y)
End If

'显示数据

With PictureSetting
If .ShowData = True Then
gBrush.Color = .colDataMarking
gFont = .DataFont
For i = 0 To TotalPoint - 1
StrTemp = Format(YValue(i), PictureSetting.DataFormat)
If PictureSetting.DFStyle = "Percent" Then StrTemp = StrTemp & "%"
stringSize = gTemp.MeasureString(StrTemp, gFont)
X = PLine(i).X - stringSize.Width / 2
Y = .OrignPos.Y - YValue(i) * .YScale - stringSize.Height - 4
gTemp.DrawString(StrTemp, gFont, gBrush, X, Y)
Next
End If
End With

'画标签
If PictureSetting.ShowLabel Then
With PictureSetting
gBrush.Color = PictureSetting.colLabel
gFont = .LabelFont
gPen.Width = 1
gPen.Color = .colRect
gPen.DashStyle = Drawing2D.DashStyle.Solid
End With

For i = 0 To TotalPoint - 1
stringSize = gTemp.MeasureString(XLabel(i), gFont)
gTemp.DrawString(XLabel(i), gFont, gBrush, PLine(i).X - stringSize.Width / 2, PictureSetting.OrignPos.Y + 2)
P1.X = PLine(i).X
P1.Y = PictureSetting.OrignPos.Y
P2.X = P1.X
P2.Y = P1.Y - 5
gTemp.DrawLine(gPen, P1, P2)
Next
End If

'画图例
With PictureSetting
gPen.Color = .colRect
gPen.Width = 1
gPen.DashStyle = Drawing2D.DashStyle.Solid
gFont = .LabelFont
End With

With PictureSetting
If .YLabelAuto Then
Select Case .DFStyle
Case "PPM"
StrTemp = Format(Max / 5, "0")
If CInt(Right(StrTemp, 1)) > 5 Then
StrTemp = Left(StrTemp, Len(StrTemp) - 1) & "5"
Else
StrTemp = Left(StrTemp, Len(StrTemp) - 1) & "0"
End If
If StrTemp = "0" Then StrTemp = "1"
.YLabelStep = Convert.ToSingle(StrTemp)
Case "Digit"
StrTemp = Format(Max / 5, .DataFormat)
If StrTemp = "0" Then StrTemp = "0.001"
.YLabelStep = Convert.ToSingle(StrTemp)
Case "Percent"
StrTemp = Format(Max / 5, .DataFormat)
If StrTemp = "0" Then StrTemp = "0.001"
.YLabelStep = Convert.ToSingle(StrTemp)
End Select
End If
End With

sigTemp = 0
For i = 0 To 10
If sigTemp > Max Then Exit For
P1.X = PictureSetting.OrignPos.X
P1.Y = PictureSetting.OrignPos.Y - sigTemp * PictureSetting.YScale
P2.Y = P1.Y
P2.X = P1.X + 5
Select Case PictureSetting.DFStyle
Case "PPM"
StrTemp = Format(sigTemp, "0")
Case "Percent"
StrTemp = Format(sigTemp, PictureSetting.DataFormat) & "%"
Case "Digit"
StrTemp = Format(sigTemp, PictureSetting.DataFormat)
End Select

gTemp.DrawLine(gPen, P1, P2)
stringSize = gTemp.MeasureString(StrTemp, gFont)
gTemp.DrawString(StrTemp, gFont, gBrush, P1.X - stringSize.Width - 4, P2.Y - stringSize.Height / 2)
sigTemp = sigTemp + PictureSetting.YLabelStep
Next

'画外框
With PictureSetting
gPen.Color = .colRect
gPen.Width = 1
gPen.DashStyle = Drawing2D.DashStyle.Solid
End With

With PictureSetting

.Height = .Height + 15

P1 = .OrignPos
P2.X = .OrignPos.X + .XStep * TotalPoint
P2.Y = .OrignPos.Y
gTemp.DrawLine(gPen, P1, P2)

P2.X = .OrignPos.X
P2.Y = .OrignPos.Y - .Height
gTemp.DrawLine(gPen, P1, P2)

P1.X = .OrignPos.X + .XStep * TotalPoint
P1.Y = .OrignPos.Y
P2.X = P1.X
gTemp.DrawLine(gPen, P1, P2)

P1.X = .OrignPos.X
P1.Y = .OrignPos.Y - .Height
P2.X = .OrignPos.X + .XStep * TotalPoint
P2.Y = P1.Y
gTemp.DrawLine(gPen, P1, P2)
End With
PicCtl.Image = bmp
PicCtl.Refresh()
gPen.Dispose()
gBrush.Dispose()
gTemp.Dispose()

Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical)
End Try
End Sub
追问
Public Sub DrawTrendLine(ByVal PictureSetting As CPictureSet, ByVal PicCtl As PictureBox, ByRef TotalPoint As Integer, ByRef YValue() As Single, ByRef XLabel() As String)
语句在命名空间中无效!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2011-03-22
展开全部
可以用MSChart控件(Microsoft Chart Contro,l到com组件中添加),示例代码如下,看到效果你就明白了
Dim arrData(2, 2)
arrData(0, 0) = "Jan" ' 在第一列设置标签。
arrData(1, 0) = "Feb"
arrData(2, 0) = "Mar"

arrData(0, 1) = 8
arrData(1, 1) = 18
arrData(2, 1) = 2

With AxMSChart1
.chartType = MSChart20Lib.VtChChartType.VtChChartType2dLine
.ChartData = arrData
End With
追问
好的,我试试!
微软图表控件MsChart需要.Net 3.5 Sp1以及VS 2008的开发环境,我用的是VS2005,没有找到MsChart空间呀
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
snfnyygt
2011-03-21 · TA获得超过1625个赞
知道大有可为答主
回答量:1469
采纳率:0%
帮助的人:1327万
展开全部
使用控件:水晶报表
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
ygn918042354
2011-03-22
知道答主
回答量:29
采纳率:0%
帮助的人:3.9万
展开全部
这个东西需要用到底层的api了,一般的控件和类库都是在它的基础上封装的,
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式