问题
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
回答1:
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.
来源:https://stackoverflow.com/questions/35693430/chart-line-graph-in-datalab-based-on-bigquery-data-not-rendering