benpickles/peity — pull request #22 by bengotow (2012-11-05 08:55:18+00:00)
Title: Calling a grapher no longer results in a new canvas being created if one...

Hey Ben, Ben here. I love Peity and I'm using it for an internal product dashboard that updates in realtime to show data moving through a system. Unfortunately, I was calling update() 30 times a minute on a large number of Peity line graphs, and I noticed that the code creates a new Canvas each time a grapher renders. It also nests everything inside of an invisible span, and the spans stack up over time. This was causing Chrome and Safari to lock after sitting on the page for about 5 minutes, because I was creating DOM objects and not getting rid of them.

It turned out to be pretty easy to resolve this problem —I just check for an existing canvas inside the chart, and if one is found I don't create a new one.

Feel free to pull these changes if you find them appropriate. Hopefully they'll solve the problem for others as well.