如何绘制折线图? [英] How to draw a line graph?

查看:133
本文介绍了如何绘制折线图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好..

我想从我在数据库中的表格中绘制一个图表..

例如,我的数据库中有一个表格年龄..我在html中有一个表格,我将显示图表..我想得到一张图表,显示我在桌子上的不同年龄..

你能帮帮我..

谢谢你..

Hello..
I want to draw a graph from the values i have in my table in database..
E.g, i have a table age in my database.. I have a form in html where i will display the graph.. I want to get a graph displaying the different age i have in my table..
Can you help me..
thank uu..

推荐答案

可能有很多不同的方法。基本上,您可以在服务器端生成数据中的任何图形,将其保存在临时文件中,或者在HTTP响应中随时提供正确的媒体类型的图形内容。使用PHP,它可以是任何东西。它可能类似于image / png,image / jpeg等。请参阅:

http://en.wikipedia.org/wiki/Media_type [ ^ ],

http://www.php.net/ manual / en / function.header.php [ ^ ],

关于可用MIME类型的最终文档就是这个(对于图像): http://www.iana.org/assignments/media-types/media-types.xhtml#image [ ^ ]。



所以,在你的PHP脚本中,它可能类似于

There could be many different ways. Basically, you can generate any graphics out of your data on the server side, save it in a temporary file, or provide graphics content on the fly prescribing proper media type in your HTTP response. With PHP, it can be anything. It could be something like "image/png", "image/jpeg", etc. Please see:
http://en.wikipedia.org/wiki/Media_type[^],
http://www.php.net/manual/en/function.header.php[^],
the ultimate document on available MIME types is this one (for images): http://www.iana.org/assignments/media-types/media-types.xhtml#image[^].

So, in your PHP script, it could be something like
header('Content-type: image/png');
/* or */
header('Content-type: image/jpeg');





为了生成通用图形,有许多库(如ImageMagick, http:// www .php.net / manual / en / book.imagick.php [ ^ ]。



这就是它的工作原理。在实践中,您可以找到一些读取使用的开源图表库: http://bit.ly/OCsZbx [ ^ ]。



有一个非常有吸引力的替代方法:使用HTML5 Canvas功能: http://en.wikipedia.org/wiki/ HTML5_Canvas [ ^ ]。



例如,此产品: http://canvasjs.com [ ^ ]。



你可以找到更多:http://bit.ly/OCww9S [ ^ ]。



如果您使用此方法,您的PHP代码应该用于生成呈现图形所需的数据和Javascript。这种方法的吸引力在于你可以动态地制作图形(特别是改变视图选项,限制等),因为所有这些处理都可以完全在客户端完成。



-SA



For generation of general graphics, there are many libraries (like ImageMagick, http://www.php.net/manual/en/book.imagick.php[^]).

This is how it works. In practice, you can find some read-to-use open-source charting library: http://bit.ly/OCsZbx[^].

There is a very attractive alternative approach: using HTML5 Canvas feature: http://en.wikipedia.org/wiki/HTML5_Canvas[^].

For example, this product: http://canvasjs.com[^].

You can find more: http://bit.ly/OCww9S[^].

If you use this approach, your PHP code should be used to generate data and Javascript needed to present graphics. The attractiveness of this approach is that you can make graphics (especially changing view options, limits, etc.) on the fly with great performance, because all such processing can be done purely on client side.

—SA


这篇关于如何绘制折线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆