Generic Javascript functions for use in plotting mathematical objects