如何在PHP中绘制这种类型的图像
I want to draw an image in PHP, which looks like the circle in the following image -
How should I proceed with this? Is there any available PHP plugin or something that I can use to generate this type of image, or should I use GD library and hand-code it myself?
EDIT
I am looking for some library that is open-source.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
不要自己手动编码,因为那会非常痛苦。我曾经不得不编写一个饼图生成器。
有很多图形引擎:
看看他们为您提供了什么。可能不完全相同,但非常接近。
Do not handcode it yourself as that would be very painful. I once had to code a pie-chart generator.
There are plenty of graph engines out there:
Have a look at what they offer you. Might not be the exact same but something very close.
我不知道你想在该图像中显示什么,但它看起来像某种图表,所以我会寻找一个图表库,例如 JpGraph,然后再重新编码:
http://jpgraph.net/
I don't know what you're trying to display in that image but it looks like some kind of graph, so I'd look for a chart-library, e.g. JpGraph, before coding it all again:
http://jpgraph.net/
这看起来像转换为极坐标的条形图。
这是生成此类图片的简单方法:
绘制条形图(使用图表库或您自己),没有任何间隙
酒吧之间。确保条形图的左侧和右侧没有空格。
使用 GD 的
gdImageSquareToCircle()
函数将您可能必须在转换图像之前,将条形图旋转 180°(即条形图应从上到下增长)。
This looks like a bar chart converted to polar coordinates.
Here's an easy way to generate such a picture:
Draw your bars (either using a chart library or on your own) without any gaps
between the bars. Make sure there is no whitespace to the left and right of your bars.
Transform the image to polar coordinates using GD's
gdImageSquareToCircle()
functionYou probably might have to rotate your bars by 180° (i.e. the bars should grow from top to bottom) before transforming the image.
这个:
制作这个:
This:
Makes this:
您可能正在寻找 SVG 库。
raphael 也是一个不错的选择
your probably looking for an SVG library.
raphael is also a good choice
imagefilledarc
是你的朋友!< /强>imagefilledarc
is your friend!