| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 691 人关注过本帖
标题:PictureBox绘制实时曲线图,连接后两个点时,前两个点的连线就没了。
取消只看楼主 加入收藏
Xieup1
Rank: 1
等 级:新手上路
威 望:1
帖 子:20
专家分:0
注 册:2014-2-24
结帖率:80%
收藏
 问题点数:0 回复次数:0 
PictureBox绘制实时曲线图,连接后两个点时,前两个点的连线就没了。
Public Class Form1

    Dim PreVoltage As New PointF(0, 0)
    Dim i As Single = 0

    Private Function PlotData(ByVal Voltage As PointF) As PointF
        Dim PicWidth As Integer = PictureBox1.ClientSize.Width
        Dim PicHeight As Integer = PictureBox1.ClientSize.Height
        Dim PicBmp As New Bitmap(PicWidth, PicHeight)
        Dim PicGraphics As Graphics = Graphics.FromImage(PicBmp)
        Dim BluePen As New Pen(Color.Blue)

        '建立坐标
        Dim ScaleFactorX As Integer = 300
        Dim ScaleFactorY As Integer = 150
        Dim PicScaleX As Single
        Dim PicScaleY As Single
        PicScaleX = PictureBox1.Width / ScaleFactorX
        PicScaleY = (PictureBox1.Height * 0.97) / ScaleFactorY

        '测量点的坐标化
        Voltage.X = Voltage.X * PicScaleX
        Voltage.Y = Voltage.Y * PicScaleY

        '绘图
        PicGraphics.DrawLine(BluePen, PreVoltage, Voltage)


        '输出至图框
        PictureBox1.Image = PicBmp
        PictureBox1.Refresh()



        '返回当前点坐标,用做下次绘图
        Return Voltage
    End Function



    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        '取假定测量点
        Dim Voltage As New PointF(i, i)
        PreVoltage = PlotData(Voltage)
        i = i + 1

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Timer1.Enabled = True
    End Sub
End Class


希望是根据测量数据绘制一条实时曲线图,通过连接每个测量的点来实现。
当前代码总是只能显示两个点的连线,无法把之前的连线保存。怎么才能解决呢?
搜索更多相关主题的帖子: 曲线图 
2014-02-27 16:35
快速回复:PictureBox绘制实时曲线图,连接后两个点时,前两个点的连线就没了。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025043 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved