approximation and peak search for java script (jquery flot)