0

I am running a query against our GAP data in Bigquery and I want to generate a chart from it.

%%sql --module mobileGraph02
SELECT STRFTIME_UTC_USEC(UTC_USEC_TO_DAY((visitStartTime+36000)*1000000),'%Y/%m/%d') AS dateDate,
EXACT_COUNT_DISTINCT(fullVisitorId) AS sessions
FROM TABLE_DATE_RANGE([99949271.ga_sessions_],
TIMESTAMP('2016-02-21'), 
TIMESTAMP('2016-02-25')) 
GROUP BY dateDate
ORDER BY dateDate

I attempted to create a graph from this based on one of the examples in the 'Interactive Charts with Google Charting APIs' file.

%%chart line --fields dateDate,sessions --data mobileGraph02

And this version:

%%chart line -f dateDate,sessions -d mobileGraph02

The help document in the UI is returning the following:

%%chart line -h
usage: %%chart line [-h] [-f FIELDS] -d DATA

optional arguments:
-h, --help            show this help message and exit
-f FIELDS, --fields FIELDS
                      The field(s) to include in the chart
-d DATA, --data DATA  The name of the variable referencing the Table or
                    Query to chart

I found that the chart itself was not rendering and there was no error message as per this post: Charts drawn with %%chart command do not render

Community
  • 1
  • 1

1 Answers1

0

Datalab doesn't do much validation of the data before passing it to the charting library (that might change one day if https://github.com/GoogleCloudPlatform/datalab/pull/676 gets merged). Errors might have been reported in the browser console, as a result, as the chart library is Javascript code.

Graham Wheeler
  • 2,734
  • 1
  • 19
  • 23
  • What exactly resolved it? It turned out I was wrong about the string type; I tried charting this: data = [ {'date': '2016/01/01', 'count': 10}, {'date': '2016/01/02', 'count': 15}, {'date': '2016/01/03', 'count': 12} ] and it worked fine. – Graham Wheeler Mar 01 '16 at 01:06