MYZXT_YYH

来源:互联网 发布:淘宝号封了还能解开吗 编辑:程序博客网 时间:2024/06/09 17:15
  Sub createZXG(ByVal arrDataA() As Double, ByVal arrDataC() As Double)        Dim height As Integer = 200    '圖片高度        Dim width As Integer = 200     '圖片寬度        Dim space As Integer = 20      '原点到左边和下边的距离        Dim interval As Integer = 20   'x轴单位长度        Dim max_x As Integer = 8 'x轴刻度個數        Dim max_y As Integer = 5 'y轴刻度個數        Dim bmp As New Bitmap(width, height)        Dim g As Graphics = Graphics.FromImage(bmp)        Dim pen As Pen = New Pen(Color.Black, 1)        Dim pen_chart As Pen = New Pen(Color.Blue, 2)    '在此处设置折线宽度和颜色        Dim i As Integer        g.SmoothingMode = SmoothingMode.AntiAlias        g.Clear(Color.White)        'g.DrawLine(pen,point1,point2)        'Pen 对象,它确定线条的颜色、宽度和样式。         'Point1 结构,它表示要连接的第一个点。         'Point2 结构,它表示要连接的第二个点。         g.DrawLine(pen, New Point(space, height - space), New Point(width, height - space)) 'x轴        g.DrawLine(pen, New Point(space, 0), New Point(space, height - space))  'y轴        g.DrawLine(pen, New Point(180, 0), New Point(180, height - space))  'y轴        'x轴上的刻度        For i = 0 To width - interval Step interval            If i <= max_x * interval Then                'g.DrawString(string,Font,Brush,PointF)                'String对象,要绘制的字符串。                 'Font 对象,它定义字符串的文本格式。                 'Brush 对象,它确定所绘制文本的颜色和纹理。                 'PointF 结构,它指定所绘制文本的左上角。                '可以单独先定义变量drawString, drawFont, drawBrush, drawPoint                g.DrawString(i / interval, New Font("Arail", 9, FontStyle.Regular), SystemBrushes.WindowText, New PointF(space + i - 5, height - space))            End If        Next        'y轴上的刻度        For i = 0 To height - interval Step interval            If i <= max_y * interval Then                g.DrawLine(pen, New Point(space, height - i - space), New Point(space + 5, height - i - space))                If i <> 0 Then                    g.DrawString(i / interval * 50, New Font("Arial", 9, FontStyle.Regular), SystemBrushes.WindowText, New PointF(space - 12, height - space - i - 6))                End If            End If        Next        '画折线图        For i = 0 To UBound(arrDataA) - 1            g.DrawLine(pen_chart, New Point(space + i * interval, height - space - arrDataA(i) * interval), New Point(space + (i + 1) * interval, height - space - arrDataA(i + 1) * interval))        Next        pen_chart.Color = Color.Red        For i = 0 To UBound(arrDataC) - 1            g.DrawLine(pen_chart, New Point(space + i * interval, height - space - arrDataC(i) * interval), New Point(space + (i + 1) * interval, height - space - arrDataC(i + 1) * interval))        Next        bmp.Save("D:/MyPicture_yyh.jpg", ImageFormat.Jpeg)        g.Dispose()        bmp.Dispose()    End Sub
原创粉丝点击