gráfico con efecto scrolling
Publicado por josejoa (6 intervenciones) el 13/01/2007 16:57:45
Haber si alguién me puede echar un cable, quisiera un gráfico con efecto scrolling que empezara desde la izquierda y no desde la derecha como me sale en el ejemplo adjunto. O sea que empezara a acumular hasta llegar al final donde continuaría con el efecto scrolling ¿alguna idea? En el ejemplo hay un picturebox (Pbox) y un timer:
Option Explicit
'variables de niveles
Private BAR_HEIGHT As Integer
Private GraphPoints(1 To 100) As Long
Private Sub Form_Load()
'comenzar generador aleatorio
Randomize
End Sub
Private Sub Timer1_Timer()
'Este Timer es para probar
Dim Random_Seed As Long
On Error Resume Next
'Generar número aleatorio para probar
Random_Seed = Int((100 * Rnd) + 1)
'Mostrar Scrolling
Call UpdateGraph(Pbox, Random_Seed, True)
End Sub
Public Sub UpdateGraph(Pbox As PictureBox, BAR_HEIGHT As Long, isScrollStyle As Boolean)
Dim Cnt As Long
On Error Resume Next
'Preparamos estilo picture
Pbox.ScaleLeft = 0
Pbox.ScaleTop = 100
Pbox.ScaleWidth = 100
Pbox.ScaleHeight = -100
Call ShiftPoints 'rutina desplazar a la izquierda
GraphPoints(100) = BAR_HEIGHT
Pbox.Cls
'Redibujamos el gráfico usando nuevos valores
For Cnt = 1 To 100 - 1
Pbox.Line (Cnt, 0)-(Cnt, GraphPoints(Cnt))
Next Cnt
End Sub
Private Sub ShiftPoints()
Dim CntShift As Long
On Error Resume Next
'Desplazamos barra gráfico a la izquierda para mostrar efecto scrolling,
'desplazamos todos los puntos del gráfico un lugar a la izquierda
For CntShift = 1 To 100 - 1
GraphPoints(CntShift) = GraphPoints(CntShift + 1)
Next CntShift
End Sub
Option Explicit
'variables de niveles
Private BAR_HEIGHT As Integer
Private GraphPoints(1 To 100) As Long
Private Sub Form_Load()
'comenzar generador aleatorio
Randomize
End Sub
Private Sub Timer1_Timer()
'Este Timer es para probar
Dim Random_Seed As Long
On Error Resume Next
'Generar número aleatorio para probar
Random_Seed = Int((100 * Rnd) + 1)
'Mostrar Scrolling
Call UpdateGraph(Pbox, Random_Seed, True)
End Sub
Public Sub UpdateGraph(Pbox As PictureBox, BAR_HEIGHT As Long, isScrollStyle As Boolean)
Dim Cnt As Long
On Error Resume Next
'Preparamos estilo picture
Pbox.ScaleLeft = 0
Pbox.ScaleTop = 100
Pbox.ScaleWidth = 100
Pbox.ScaleHeight = -100
Call ShiftPoints 'rutina desplazar a la izquierda
GraphPoints(100) = BAR_HEIGHT
Pbox.Cls
'Redibujamos el gráfico usando nuevos valores
For Cnt = 1 To 100 - 1
Pbox.Line (Cnt, 0)-(Cnt, GraphPoints(Cnt))
Next Cnt
End Sub
Private Sub ShiftPoints()
Dim CntShift As Long
On Error Resume Next
'Desplazamos barra gráfico a la izquierda para mostrar efecto scrolling,
'desplazamos todos los puntos del gráfico un lugar a la izquierda
For CntShift = 1 To 100 - 1
GraphPoints(CntShift) = GraphPoints(CntShift + 1)
Next CntShift
End Sub
Valora esta pregunta


0