Изобразить динамичный график - Visual Basic .NET
Формулировка задачи:
Всем привет, как с помощью ZedGraph или что то другого сделать живой график. К примеру есть некий баланс, он меняется каждую секунду, как это отобразить на графике.
Решение задачи: «Изобразить динамичный график»
textual
Листинг программы
- Public Class Form1
- Dim dx As Integer
- Dim old, cur As Integer
- Dim rnd As Random
- Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
- dx = 5
- old = PictureBox1.Height / 2
- Dim bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
- PictureBox1.Image = bmp
- End Sub
- Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
- rnd = New Random
- Timer1.Start()
- End Sub
- Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
- Timer1.Stop()
- End Sub
- Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
- Dim bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
- Dim gr As Graphics = Graphics.FromImage(bmp)
- gr.DrawImage(PictureBox1.Image, -dx, 0)
- cur = rnd.Next(1, PictureBox1.Height - 1) 'моделирование данных
- gr.DrawLine(Pens.Red, PictureBox1.Width - 1 - dx, old, PictureBox1.Width - 1, cur)
- old = cur
- PictureBox1.Image = bmp
- End Sub
- End Class
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д