Creating workflow by using JavaScript

I want to create the workflow chart by using the JavaScript open source library so that it can be saved in the database. I also want to edit the workflow items connections so changes can be made in the database. Can I body having any idea to do this task?
