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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:09:10  来源:igfitidea点击:

Create pie chart from php using mysql table

phpmysql

提问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

回答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"

In fact this is how it would look: pie chart of sql data

事实上,它的外观是这样的: sql数据饼图

回答by Feralheart

Some more "charting" libraries what you can work with: Chart.JsAmCharts

您可以使用更多“图表”库:Chart.Js AmCharts

And I found an article, too about it.

我也找到了一篇关于它的文章

(Edit: Formating)

(编辑:形成)