How often will the graph be redrawn?
In addition to Cor's reply, here's another option:
Use a linked list. Something like the following [psuedocode]:
public struct StockHistoryItem
Dim price as double
Dim timestamp as DateTime
end struct
class StockHistory
Private data() as StockHistoryItem
Private startData as Long = 0
Private endData as Long = 0
Private maxSize as Long = 0
public Sub New(byref size as Long)
if Size>0 then
maxSize = size
Redim data(maxSize) As StockHistoryItem
else
throw new Exception - invalid
end if
end sub
public sub AddItem(ByVal newItem as StockHistoryItem)
if endData = maxSize then
endData = 0
else
endData += 1
end if
data(endData) = newItem
if endData = maxSize Then
startData = 0
else
startData += 1
end if
end sub
end class
Bear in mind I don't think the upper bound stuff is correct - you might need
(endData + 1) in the "If" statements involving it. You obviously need
functions to retrieve data - you could implement IEnumerable or have
something like:
public sub GetItem(byref index as Long)
if index >=0 AND index <= maxsize - 1 then
' You also need to check in case you haven't yet filled the
structure with values.
GetItem = data(Dim item As Long = (index + startData) Mod
maxSize)
end if
end sub
If you took Cor's route, you don't necessarily need an entirely separate
program, you could clean up old rows each time you draw the graph.
Jevon
"Mike" <my***@pearcey2001.freeserve.co.uk> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi,
I'm new to vb.net and would be grateful if anyone could offer some
advice on the best way to approach this problem:
I wish to dynamically capture pricing information e.g. 10 stock prices
and use this data to generate a number of graphs over time (in real
time) of each share price. This means for each share I need to store a
price and a timestamp.
I would need to collect around 600 pairs of data per stock (once per
second for 10 mins), so around 6000 in total, then roll the data
forward so that I only ever keep 600 records i.e. always have the last
10 minutes worth of data for each stock.
I would therefore like to know the best method to store this data on
the fly. I can only think of an array or dataset as a way to do this
but maybe there are better solutions I am unaware of?
Thanks for any help,
Mike