最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to make a graph with dynamic x,y axis using canvas tag html5 - Stack Overflow

programmeradmin7浏览0评论

I want to make a graph which plots numeric points like (23,45),(32,67) etc using canvas tag in html5. I found this graph in this link / The problem in this graph is that only y-axis works with numeric values.I want to make X-axis work with numeric values as well using the same logic as y-axis...Please help

I want to make a graph which plots numeric points like (23,45),(32,67) etc using canvas tag in html5. I found this graph in this link http://www.worldwidewhat/2011/06/draw-a-line-graph-using-html5-canvas/ The problem in this graph is that only y-axis works with numeric values.I want to make X-axis work with numeric values as well using the same logic as y-axis...Please help

Share Improve this question edited Apr 4, 2013 at 4:09 Lucy asked Mar 29, 2013 at 5:15 LucyLucy 1,85216 gold badges57 silver badges97 bronze badges 2
  • You need to be a bit more clear. The x axis in that example is already dynamic actually. Check out the demo here Live Demo – Loktar Commented Mar 29, 2013 at 13:49
  • i want to make x axis values numeric as well just like y axis.Currently it displays months.I want to plot points in a graph like(55,60) (45,23) using the concepts of the example given in the link i posted. – Lucy Commented Apr 1, 2013 at 3:29
Add a ment  | 

1 Answer 1

Reset to default 4

This is a really easy fix. The as it is graphing, it just references the length of the data instead of the X values. We can work around this easily by adding a getMaxX() function, and referencing the actual X values. Here is a working example.

发布评论

评论列表(0)

  1. 暂无评论