I am using gviz_api (google-visualization-python) to create some line charts. http://code.google.com/p/google-visualization-python/
I edited a sample diagram taken from Google documentation.
However, I'm not sure how to pass a date to a DataTable
Here is an edited example that I worked with. https://gist.github.com/3941946
In this code, I had a question about
# Creating the data description = {"year": ("string", "Year"), "sales": ("number", "Sales"), "expenses": ("number", "Expenses")} data = [{"year": '2004', "sales": 1000, "expenses": 300}, {"year": '2005', "sales": 1200, "expenses": 400}, {"year": '2006', "sales": 1300, "expenses": 500}, {"year": '2007', "sales": 1400, "expenses": 600}, {"year": '2008', "sales": 1500, "expenses": 800}]
How can I load a date in a DataTable using gviz_api?
The google documentation describes how to create a new Date () using javascript, however I would like to continue using gviz_api.py.
Notes from Google documentation from https://developers.google.com/chart/interactive/docs/dev/implementing_data_source#jsondatatable
* JSON modifications The Google support libraries and all requests sent to Google return a slightly non-standard version of JSON / JSONP. If you do not parse the returned code yourself, it does not matter to you. The visualization API client supports both standard and modified versions of JSON. The following is a brief overview of the differences:
JSON does not support JavaScript Date values (for example, "new Date (2008,1,28,0,31,26)", the implementation of the API does. However, the API now supports a custom JSON representation of the date as a string in the following format: Date (year , month, day [, hour, minute, second [, millisecond]]), where everything the day after tomorrow is optional and the months are based on zero.
JSON uses double quotes for dictionary keys; API implementations use unmentioned keys.
JSON requires double quotes around string values; the API implementation uses single quotes. *