如何从MySQL数据库表中获取数据并使用Google Charts Tool在该数据上绘制折线图?

时间:2022-02-21 07:24:33

I want to draw a line chart based upon the fetched data from the MySQL database table. I'm having users table with following fields:

我想根据MySQL数据库表中提取的数据绘制折线图。我有以下字段的用户表:

  • user_id varchar(32)
  • user_first_name varchar(50)
  • user_reg_date bigint(12)

I'm storing the date in UNIX timestamp format, so taken the data type 'bigint'. Now I want to draw a line chart based upon the fetched data from the MySql database depending on specific criteria.

我以UNIX时间戳格式存储日期,因此采用数据类型'bigint'。现在我想根据具体标准,根据MySql数据库中提取的数据绘制折线图。

Suppose users_stats.php is my PHP page on which I'm going to show the line chart using Google Charts tool. The URL of the page should be like this http://localhost/users_stats.php?to_date=1-6-2013&from_date=26-6-2013.

假设users_stats.php是我的PHP页面,我将使用Google Charts工具显示折线图。页面的URL应该是这样的http://localhost/users_stats.php?to_date = 1-6-2013&from_date = 26-6-2013。

Now I want to generate a query to fetch the no.of registered users between these two dates and want to show that data in Line Chart. I googled about this but only found examples having static data which is already set in the data array of Google Charts library. No example of line chart on dynamic data from database.

现在我想生成一个查询来获取这两个日期之间的注册用户数,并希望在折线图中显示该数据。我搜索了这个,但只找到了已经在Google Charts库的数据数组中设置静态数据的示例。没有关于来自数据库的动态数据的折线图的示例。

So would you help me in drawing this line chart depending upon the data received from the database? Thanks in Advance.

那么根据从数据库收到的数据,您能帮我绘制这个折线图吗?提前致谢。

1 个解决方案

#1


0  

you can't set the Google Chart data directly from the database (unless your database has a DataSource interface). Here is a question that was recently asked on our mailing list that is similar to yours, and here is an enormous thread on the same topic.

您无法直接从数据库设置Google Chart数据(除非您的数据库具有DataSource接口)。这是最近在我们的邮件列表中提出的与您类似的问题,这是一个关于同一主题的巨大帖子。

#1


0  

you can't set the Google Chart data directly from the database (unless your database has a DataSource interface). Here is a question that was recently asked on our mailing list that is similar to yours, and here is an enormous thread on the same topic.

您无法直接从数据库设置Google Chart数据(除非您的数据库具有DataSource接口)。这是最近在我们的邮件列表中提出的与您类似的问题,这是一个关于同一主题的巨大帖子。