Line chart scroll bar

ejleiss

Active member
Joined
Oct 1, 2012
Messages
37
Programming Experience
1-3
Hello,

I have a line chart that is taking in data from a serial port and plotting it in as close to real time as I can get. Right now I am saving 1000 values to a DataGridView chart and once the data reaches the 1000th value, it starts overwriting the oldest data first. I can stop the chart plotting and receive the row number in the DataGridView where the data has left off. Once the charting is stopped I set the HScrollmax to the row number and the HScrollmin to the next row (which is the oldest value saved). I am plotting 400 values at a time, so what I would like to be able to do is click the left arrow on the scrollbar and scroll through the DataGridView data, shifting back one row on each click of the arrow until I have gone through the 1000 saved values. Could anyone help with this idea? I have tried this a few ways and one issue is when the row number stops on a row less than 400, because I am plotting 400 values it has a data out of range type error. I need to be able to jump back to the 1000th row after I reach row 0.
 
Hi,

When we first looked at this solution we achieved the scrolling of the chart by synchronising the value of the HScrollBar to the index of a list of chart data points. I am guessing that your DataGridView has now been substituted for the list of data points but the principal should remain the same, whereby the HScrollBar should now be synchronised with the index of the DataGridView.

If this is the case then your answer should be just a simple math function being called when the row value becomes less that 400 to make sure that you do not try and access any indexes less than 0 within the DataGridView.

Hope that helps.

Cheers,

Ian
 
Back
Top