oesmith/morris.js — pull request #40 by msabbott (2012-03-13 23:50:14+00:00)
Title: Performance Enhancement for X-Axis Drawing Code When Data Has a Large Range of X-Axis Values

Hi,

I'm currently implementing the ability to provide time values (e.g. hh:mm:ss.xxxx) values on the X-Axis, and as part of this I identified a major performance problem with the way that the X-Axis values were drawn.

If you have a range of values on the X-Axis that spans a large range, the drawing of the values would take an extremely long amount of time.

This manifests itself most obviously when you are dealing with time values, as I have converted them to seconds. With 3600 seconds in an hour, it would attempt to draw the next X-axis label 3600 times for a range of an hour, many of these drawing calls would then be removed as they overlapped the previous label. When you have a range that then spans many hours, you get a large number of really redundant calls.

To replicate the problem take any of the date examples, and put the year up to something high (e.g. the year 20000) and refresh the page.

My fix changes this code so that calculates when the next time it would be required to draw would be, and therefore cuts out a lot of these calls.

I've got a few things that I need to finish on the time value code, so will send a separate pull request for that when done.

Cheers,
Mark