Down sample incoming stream of data to plot a dynamic graph
Downsampling

Let's define our downsampling factor : 
$$r = \frac{F_s'}{F_s}$$

Where $F_s$ is the original sampling frequency and $F_s'$ the reduced one.

If $F_s$ is a multiple of $F_s'$ (i.e. $1/r$ is an integer), then the dowsampling is straightforward : you just take one sample out of $1/r$. For example, if you want to half your sampling frequency, just discard every $2^{nd}$ sample and that's all (well not really, see next paragraph).

However, if that's not the case, you're going to have to interpolate between the samples. To make it simple, interpolating means trying to guess the value of a sample by knowing the value of the surrounding samples. You brain does interpolation all the time : when you see several points forming a line you instinctively draw the line in your head. Several types of interpolation exist, the more simple beeing the less precise. It usually depends on your application.

But there's more...

You've maybe heard of Shannon-Nyquist sampling theorem, which states that to sample a signal, you have to have a sampling frequency at least twice as big as your signal's highest harmonic. If you don't, it's going to cause something called aliasing. I won't explain this theorem here because there is plenty of information available everywhere.

But keeping this theorem in mind, you can probably understand that downsampling your signal might cause aliasing if you're not careful. The simple solution to that is to filter the signal prior to downsampling, at a cutoff frequency of $\frac{F_s'}{2}$. The steeper the filter's transition band, the less aliasing.

Back to your application

From what I understood, you have a signal that you want to map to a screen. For that, you need to downsample the signal to your screen's horizontal resolution. Let's call this resolution $H_x$ and your signal's sampling frequency $F_s$. For the sake of the example, let's fix $H_x=240\text{px}$ and $F_s=5\text{kHz}$.

You also have a time parameter (let's call it $t_r$) which sets the "zooming" of your scope, ie how long of a signal corresponds the length of the screen. Let's set it to $t_r=100\text{ms}$ (Disclaimer : I have absolutely no idea about the frequency of ECG so this is completely arbitrary).

That gives you :
$$
F_s' = \frac{H_x}{t_r} = \frac{240}{0.100}=2400\text{Hz}
$$
Note that that is not a multiple of $F_s$.

Applying what I said before, you have :
$$ r = \frac{F_s'}{F_s} = \frac{2400}{5000} = 0.48 $$

So first, you filter your signal with a brickwall at $f_c=\frac{F_s'}{2} = 1.2\text{kHz}$, then you downsample it by a factor of $0.48$ using interpolation.



Another thing to consider is the vertical resolution. For that it is a bit different as you are not downsampling the signal but quantizing it. However, the process is similar and I think you can extrapolate without our help.