EDIT: I am looking for an example in the layout below. I may be missing something as this is my first time with Google Charts... Thanks for the help!
编辑:我在下面的布局中寻找一个例子。我可能会遗漏一些东西,因为这是我第一次使用Google Charts ...感谢您的帮助!
{
"cols": [
{"id":"","label":"Store 1","pattern":"","type":"number"},
{"id":"","label":"Store 2","pattern":"","type":"number"},
{"id":"","label":"Store 3","pattern":"","type":"number"},...
],
"rows": [
{"c":[{"v":"morning","f":'15'},{"v":"noon","f":'20'},{"v":"night","f":'25'}]},...
]
}
I cannot find anywhere an example of how the JSON record needs to be formatted for a stacked bar chart for Google Charts. I have tried a few combinations but I am struggling visualising it.
我找不到任何关于如何为Google Charts的堆积条形图格式化JSON记录的示例。我尝试了几种组合,但我正在努力想象它。
My data contains:
我的数据包含:
Store 1 Store 2
store_id walk-ins walk-ins
morning 20 25
noon 35 40
night 50 55
There are 20 stores to chart stacking the values of each row.
图表堆叠每行的值有20个商店。
My JSON right now looks like:
我的JSON现在看起来像:
[{"store_id":"Store 1","time":"morning","walk-ins":"20"}, and so on...]
I am happy to share the PHP once I work out what it needs to format the record like! Can someone point me to an example that may exist that I have missed please. Thanks for any help.
一旦我弄清楚它需要格式化记录,我很乐意分享PHP!有人能指出我可能存在的一个例子,我已经错过了。谢谢你的帮助。
1 个解决方案
#1
0
Have you checked the Documentation?
你检查过文档了吗?
The JSON format seems to be an array of arrays :
JSON格式似乎是一个数组数组:
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
that means your data would look like this:
这意味着您的数据将如下所示:
[
["store_id", "time","walk-ins"],
["Store 1","morning","30"],
["Store 2","afternoon","40"],
["Store 3","night","50"]
]
#1
0
Have you checked the Documentation?
你检查过文档了吗?
The JSON format seems to be an array of arrays :
JSON格式似乎是一个数组数组:
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
that means your data would look like this:
这意味着您的数据将如下所示:
[
["store_id", "time","walk-ins"],
["Store 1","morning","30"],
["Store 2","afternoon","40"],
["Store 3","night","50"]
]