Drawing lines with clickable points using JavaScript

青春壹個敷衍的年華 提交于 2019-12-12 01:32:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!