DmitryBaranovskiy/g.raphael — pull request #158 by greezybacon (2012-06-17 22:38:49+00:00)
Title: Select reasonable values from g.snapEnds()

g.raphael seems to select strange values for the axis limits. This commit edits the code for g.snapEnds to make it simpler and pick sane numbers for the axis limits:

Thanks to Drew Noakes and his algorithm posted at http://stackoverflow.com/questions/326679/choosing-an-attractive-linear-scale-for-a-graphs-y-axis, which I adapted into g.snapEnds(). In my case, with a time-series dataset, the values for the axis were being selected outside the timeframe of the data. Therefore, the graph was plotted outside the graph area on both sides of the graph. This algorithm selects axis ends that are outside the dataset, is simple, and likely much faster.