问题
I'm interested in doing some drawing using JavaScript. I'll get straight to an example:
alt text http://img693.imageshack.us/img693/3774/linep.png The green horizontal line would be static, and all the vertical lines would be clickable. An example of a clicked line would be the red one.
I've seen many API's, but they all allow more complexity than I need, making it more complicated than necessary.
Any suggestion for a good API? Make it oneself?
回答1:
You could use CSS and html to make up the lines initially. Then transfer some of this into the JS. To me from what you have described it doesn't look that difficult to do from scratch.
There's probably something else you haven't mentioned though!
回答2:
If there are javascript API's out there that offer what you want but are too complex, dig into one that has everything you need and pull out the stuff you don't need. If the api itself is too complex, use the code to understand how to draw lines and make a simpler one for yourself.
This site seems to have a very simple implementation.
来源:https://stackoverflow.com/questions/2281859/drawing-lines-with-clickable-points-using-javascript