sveinn-steinarsson/flot-downsample

Volatility in results

Closed this issue · 3 comments

The resulting path seems to jump a little bit around when changing threshold, probably because different points get picked each time.

Here is a slightly different take on the same, using Visvalingam’s algorithm. Here there is less volatility, as the points are in specific order based on information content. Not sure if it's correctly implemented or even whether it's better or worse:

http://bl.ocks.org/ZJONSSON/raw/5581551/
code: https://gist.github.com/ZJONSSON/5581551#file-simplify-js

I think both algorithms have their strong and their weak points. The algorithm I am using is based on the Visvalingam algorithm. Your „pure“ Visvalingam implementation produces some really nice charts and it certainly gives you a lot better transition when using the slider! The downside is perhaps when the threshold is set quite low, it tends to jump over many points, turning big chunks into straight line segments (which is probably acceptable for maps).
This is all just a matter of opinion. Maybe it would be a good idea to incorporate both algorithms into one plugin (and also maybe some other algorithms).

Yes, that was my feeling as well after a quick comparison, i.e. smoother transitions might come at the expense of optimal point selection for a given threshold. Might be worthwhile adding a short note (in the README.md) that highlights the key differences between your implementation and the "vanilla".

That is a good idea. I am definitely going to describe the algorithm better soon and discuss its limitations.