简体   繁体   English

使用Google Charts API

[英]Using the Google Charts API

I understand that Google Charts API need a numeric input value for the charts to render. 我了解Google Charts API需要数字输入值才能呈现图表。 In their examples I have seen how a particular column will contain this numeric value. 在他们的例子我见过一个特定的列如何将包含此数值。 For example: 例如:

[
    ['Mushrooms', 3],
    ['Onions', 1],
    ['Olives', 1],
    ['Zucchini', 1],
    ['Pepperoni', 2]
]

However, my chart requires me to filter through a dataset to obtain the count (similar to that of SQL) that fits the bill. 但是,我的图表要求我筛选数据集以获得适合账单的计数 (类似于SQL的计数 )。 For example: 例如:

[
    ['Mary', '10/10/1991'],
    ['Peter', '07/12/1991'],
    ['Jacob', '06/05/1992'],
]

I hope then that I can get the Chart API to filter my dataset by year, and render a chart that shows 1991 with 2/3 of the pie , and 1992 with 1/3 of the pie . 希望我能得到Chart API来按年份筛选数据集,并呈现一个图表,显示1991年的饼图为2 / 31992年的饼图为1/3

Is this possible using Google Charts API, or am I required to write specific SQL queries and form my own JSONs to render this sort of chart? 使用Google Charts API是否可以实现此功能,还是我需要编写特定的SQL查询并形成自己的JSON来呈现此类图表? Many thanks... 非常感谢...

Google Chart API does have its own data manipulation methods; Google Chart API确实有自己的数据处理方法; take a look at: http://developers.google.com/chart/interactive/docs/reference#google_visualization_data 看一下: http : //developers.google.com/chart/interactive/docs/reference#google_visualization_data

There are two functions, namely group() and join() . 有两个函数,即group()join() In this case, group() would be the most useful for data manipulation. 在这种情况下, group()对于数据操作将是最有用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM