'Return the time series as JSON-serializable dict'

def as_dict(self):

    rfields = self.rfields
    fact_data = []
    for fact in self.facts:
        fact_data.append((str(fact.label), fact.method, fact.base, fact.slope, fact.interval))
    rfield = rfields.get('event_start')
    if rfield:
        event_start = rfield.selector
    else:
        event_start = None
    rfield = rfields.get('event_end')
    if rfield:
        event_end = rfield.selector
    else:
        event_end = None
    rows = rfields.get('rows')
    if rows:
        rows_sorted = self._represent_axis(rows, self.rows_keys)
        rows_keys = [row[0] for row in rows_sorted]
        rows_data = {'s': rows.selector, 'l': str(rows.label), 'v': rows_sorted}
    else:
        rows_keys = None
        rows_data = None
    cols = rfields.get('cols')
    if cols:
        cols_sorted = self._represent_axis(cols, self.cols_keys)
        cols_keys = [col[0] for col in cols_sorted]
        cols_data = {'s': cols.selector, 'l': str(cols.label), 'v': cols_sorted}
    else:
        cols_keys = None
        cols_data = None
    event_frame = self.event_frame
    periods_data = []
    append = periods_data.append
    for period in event_frame:
        period.aggregate(self.facts)
        item = period.as_dict(rows=rows_keys, cols=cols_keys)
        append(item)
    rfield = rfields.get('baseline')
    if rfield:
        baseline = (rfield.selector, str(rfield.label), event_frame.baseline)
    else:
        baseline = None
    data = {'f': fact_data, 't': (event_start, event_end), 's': event_frame.slots, 'e': event_frame.empty, 'l': self.title, 'r': rows_data, 'c': cols_data, 'p': periods_data, 'z': baseline}
    return data
