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!
{
"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.
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.
My JSON right now looks like:
[{"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.
Have you checked the Documentation ?
The JSON format seems to be an array of arrays :
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"]
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.