i think i found the problem with the algorithm. sometimes it returns an empty row. the javascript version throws while the python version doesn't. i fixed it in my fork by just reducing the number of rows until it doesn't throw: https://github.com/jonathanong/linear-partition
I've done stuff like this in the past, if you want something that works: https://github.com/ionelmc/jquery-gp-gallery