php 使用mysql表从php创建饼图
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13319806/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Create pie chart from php using mysql table
提问by user1793864
I have a mysql table like below
我有一个如下所示的 mysql 表
buy_trader qty
--------------------
abc 48000
xyz 40000
pqr 35000
Others 88000
I need to create a pie chart from these values using PHP code. Can someone please help me with this. I need to show the percentages of qty out from the total value in the pie chart.
我需要使用 PHP 代码从这些值创建饼图。有人可以帮我解决这个问题。我需要在饼图中显示数量占总价值的百分比。
please help me with this
请在这件事上给予我帮助
回答by Ravi
Use either Google Chart, JpGraph, or GraPHPite
回答by Ryan Hamilton
You could generate an image of the chart from the command line using sqlchart http://www.sqldashboards.com/sqlchart#example-chartsallows generating a pie chart straight from your mysql query like so:
sqlchart --host dbserver --servertype mysql --user ryan --pass 123abc --chart piechart --execute "select * from tbl"
您可以使用 sqlchart 从命令行生成图表的图像http://www.sqldashboards.com/sqlchart#example-charts允许直接从您的 mysql 查询生成饼图,如下所示:
sqlchart --host dbserver --servertype mysql --user ryan --pass 123abc --chart piechart --execute "select * from tbl"


