Add filtering/support for min/max range

I suggest to add support to only account for data which is actually visible, i.e. after applying min/max range.

My suggestion is to add a pre-filter. Without that, the graphs will look ugly. 

An example: You have a graph of 4000 data points. You downsample that to a threshold of 800. After zooming in (using e.g. the selection plugin) to a quarter of the graph, you will see only 200 data points, although the range would contain 1000, out of which downsample should rather display 800 data points.
Alternate example: 4000 data points, threshold 800, a 10% range, 80 data points displayed instead of 400.

This way, the point of downsampling is somewhat undermined.

I have prepared a change which fixes that, and skips the added behaviour if min/max are not defined. Note that "out of range" is determined only on x axis, not on y, on purpose - since otherwise threshold plugin might miss some lines to data points outside of the graph.
I tested this only for an ordinary graph (with time series x data), hope that it doesn't break anything else.