'Returns the JSON for the plot with non-data elements stripped.
:param (bool) flatten: {\'a\': {\'b\': \'\'}} --> {\'a.b\': \'\'}
:returns: (dict|list) Depending on (flat|unflat)'

def get_data(self, flatten=False):

    l = list()
    for plotly_dict in self:
        l += [plotly_dict.get_data(flatten=flatten)]
    del_indicies = [index for (index, item) in enumerate(self) if (len(item) == 0)]
    del_ct = 0
    for index in del_indicies:
        del self[(index - del_ct)]
        del_ct += 1
    if flatten:
        d = {}
        for (i, e) in enumerate(l):
            for (k, v) in e.items():
                key = '{0}.{1}'.format(i, k)
                d[key] = v
        return d
    else:
        return l
