def to_json(self, data, labels=None):
labels = labels or dict()<EOL>json_data = dict()<EOL>json_data["<STR_LIT>"] = []<EOL>for group_col in self.group_bys_cols:<EOL><INDENT>label = "<STR_LIT>" or as_unicode(labels[group_col])<EOL>json_data["<STR_LIT>"].append(<EOL>{"<STR_LIT:id>": group_col, "<STR_LIT:label>": label, "<STR_LIT:type>": "<STR_LIT:string>"}<EOL>)<EOL><DEDENT>for aggr_col in self.aggr_by_cols:<EOL><INDENT>if isinstance(aggr_col, tuple):<EOL><INDENT>label_key = aggr_col[<NUM_LIT:0>].__name__ + aggr_col[<NUM_LIT:1>]<EOL>aggr_col = aggr_col[<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>label_key = aggr_col<EOL><DEDENT>label = "<STR_LIT>" or as_unicode(labels[label_key])<EOL>json_data["<STR_LIT>"].append({"<STR_LIT:id>": aggr_col, "<STR_LIT:label>": label, "<STR_LIT:type>": "<STR_LIT>"})<EOL><DEDENT>json_data["<STR_LIT>"] = []<EOL>for item in data:<EOL><INDENT>row = {"<STR_LIT:c>": []}<EOL>if not isinstance(item[<NUM_LIT:0>], tuple):<EOL><INDENT>row["<STR_LIT:c>"].append({"<STR_LIT:v>": "<STR_LIT>".format(item[<NUM_LIT:0>])})<EOL><DEDENT>else:<EOL><INDENT>for group_col_data in item[<NUM_LIT:0>]:<EOL><INDENT>row["<STR_LIT:c>"].append({"<STR_LIT:v>": "<STR_LIT>".format(group_col_data)})<EOL><DEDENT><DEDENT>for col_data in item[<NUM_LIT:1>:]:<EOL><INDENT>if isinstance(col_data, datetime.date):<EOL><INDENT>row["<STR_LIT:c>"].append({"<STR_LIT:v>": "<STR_LIT>".format(col_data)})<EOL><DEDENT>else:<EOL><INDENT>row["<STR_LIT:c>"].append({"<STR_LIT:v>": col_data})<EOL><DEDENT><DEDENT>json_data["<STR_LIT>"].append(row)<EOL><DEDENT>return json_data<EOL>
Will return a dict with Google JSON structure for charts

The Google structure::

    {
        cols: [{id:<COL_NAME>, label:<LABEL FOR COL>, type: <COL TYPE>}, ...]
        rows: [{c: [{v: <COL VALUE}, ...], ... ]
    }

:param data:
:param labels: dict with labels to include on Google JSON strcut
:return: dict with Google JSON structure