网站上的条形图
我绝不是网页设计师,因此我希望获得您愿意提供的尽可能详细的帮助。
我想制作一个网站,使用 0-100% 的条形图跟踪我输入的一些数据。 我会输入图表可以达到的最大数量,然后偶尔会更新一些数据点,完成条形图将反映这一点。
我该怎么做呢?
我了解基本的 HTML 和 PHP,但已经很长时间没有使用它们了。
I'm by no means a web designer, so I'd like as detailed help as you're willing to give.
I'd like to make a website that that tracks some data I enter using a bar graph from 0-100%. I'd enter the maximum number the graph could go to and then some data point would be updated occasionally, which the completion bar graph would reflect.
How would I go about doing this?
I know basic HTML and PHP, but have not used either in a very long time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为大多数建议都是多余的。 当您需要的只是一些简单的条形图时,无需额外的库/依赖项。 纯 HTML/CSS 应该可以...
PS:快速代码示例,仅在 Firefox 3.x 中测试
您可以使用 javascript 轻松更改单个栏的宽度(只需更改宽度)。
I think most of the suggestions are overkill. No need to have an extra library / dependency when all you need is some simple bargraphs. Plain HTML/CSS should do...
PS: quick code sample, only tested in Firefox 3.x
You can change the width of individual bars easily with javascript (just change the width).
我知道你说你是新人,但你应该看看谷歌可视化 API。 它有一些好东西可以做你可能想做的事情。
http://code.google.com/apis/visualization/
I know you said you're new, but you should take a look at the google visualization api. It's got some good stuff to do the kind of thing you might want.
http://code.google.com/apis/visualization/
有两种方法可以解决这个问题; 在后端生成图表(在您的情况下可能使用 PHP)或使用 javascript 在客户端生成图表。
我不确定在 PHP 中执行此操作的具体细节,因为我不太了解该语言,但我确信有很多关于 PHP 中的图形生成的信息。
对于 javascript 方法,我使用了 flot (用于 jquery)和 flotr (用于原型)之前。 我非常喜欢它们,这两个库都有一些很好的文档和示例,介绍如何生成各种图表(包括条形图)。
There are two ways you could tackle this problem; generate the graph on the backend (probably using PHP in your case) or do it on the client side using javascript.
I'm not sure the specifics of doing it in PHP, as I don't really know the language, but I'm sure there is alot of info out there on graph generation in PHP.
For the javascript approach, I've used both flot (for jquery) and flotr (for prototype) before. I like them alot, and there is some good documentation and examples for both libraries on how to generate all kinds of charts, including bar charts.