def METHOD_NAME(self, collection_data, categories):
    chart_data = {
        'dataset_labels': [],
        'labels': [],
        'data': {}
    }
    year_labels = []
    category_with_data = dict()
    for category in categories:
        category_with_data[category] = []
    for data in collection_data:
        new_data = False
        if data['year'] not in year_labels:
            new_data = True
            year_labels.append(data['year'])
        if new_data and len(year_labels) > 1:
            # Add 0 to previous
            for category in categories:
                if len(category_with_data[category]) < len(
                        year_labels) - 1:
                    category_with_data[category].insert(
                        len(year_labels) - 2, 0)
        category_with_data[data['name']].append(data['count'])
    chart_data['dataset_labels'] = categories
    chart_data['labels'] = year_labels
    chart_data['data'] = category_with_data
    return chart_data