views:

81

answers:

1

I am developing a rails application where I need a "success rate" system similar to RetailMeNot. I noticed that they use jQuery Sparkline library (http://omnipotent.net/jquery.sparkline/) to generate a success rate trend for each coupon.

For example, in their source code:

<em>84%</em> Success<br/><span class="trend">14,18,18,22,19,16,15,28,21,17</span>

<em>20%</em> Success<br/><span class="trend">-1,1,-1,-1,-2,-2,1,-1,1,-1</span>

Can someone explain to me the best way to develop a similar trending system for success rate?

+1  A: 

A trend is just a number calculated at regular intervals. In this case it looks like the site is just binning the data they get from the "Did this coupon work for you?" question, and then plotting those values in the chart. In other words, they take the number of (successes - failures) in some time interval (e.g. 12 hours) and plot that number for each interval.

As time passes, they probably rebin to keep the number of bars on the x axis acceptable. For example, if they only want to show 8 bars on the plot, then after 4 hours they'll have to widen the bins.

ire_and_curses
I see--that makes sense. Thank you for the sincere reply.
jimsung
No problem - and welcome to Stack Overflow!
ire_and_curses