Auto-scroll/pan for real-time data

Oystein Bjorke 10 лет назад обновлен Robert Perez 8 лет назад 1
This discussion was imported from CodePlex

armensg wrote at 2014-02-10 20:11:

Hi before I ask the question I just want to say that I really like OxyPlot! Well done and keep up the great work!

Now down to businessI am using OxyPlot in a C# winforms app. My axese are LinearAxis type.

I am trying to plot some real-time data which i have managed to do by adding points to my series and refreshing the plot as data becomes available. However, I am having trouble figuring out how to make the plot move to the right with the time series.

Each time series data point has an X value incremented by (int) 1 and I have tried to get the auto scrolling to happen using .Pan() like so:

xAxis.Pan(-1);
Obviously this hasn't worked since I am assuming the method takes pixel inputs or something and consequently the panning is much slower than the data incrementation.

I have also tried replacing -1 with -MajorTIckSize and -MajorStepSize with no luck as these are generally too small of a move.

My question is, how can i determine the delta i need to be using to pan with the real-data? I am assuming this will depend on the zoom level and obviously it would be nice if it would continue to work as I zoomed in and out.I imagine the solution involves some sort of function that relies on the pixel width of the tick interval or something but I can't figure it out.

Thanks,

Armen

decatf wrote at 2014-02-11 17:06:

The Transform function in the Axis class will convert data coordinates to screen coordinates. There is an InverseTransform to do the opposite.

So you could try:
double panStep = xAxis.Transform(-1 + xAxis.Offset);
xAxis.Pan(panStep);
There is some offset from the axis zero position (I think?) so we need to account for that in the transform to get a unit step.

armensg wrote at 2014-02-12 12:31:

Thanks decatf, this works perfectly.
Armen

WhizzWr wrote at 2014-03-17 16:14:

Hi,

I am also currently using Oxyplot to display real time data too.. The plot data are coming from serial port per 100 ms.

The auto-pan method suggested above does work but I'm not able to sync panning and plotting speed.

Plotted line appear to accelerate (or the perhaps it's the panning speed that decelerate) and eventually the line end point will be gone from the plot screen. (i.e Panning speed lags behind)

Any pointer?

Thanks in advance.

Hi, the same happens to me, any news about this ? I've tried the

xAxis.Transform(-1 + xAxis.Offset);


but didn't work for me

Сервис поддержки клиентов работает на платформе UserEcho