'Returns formatted data required by graph library on basis of filter'

def get_graph_data(self, question, current_filters=None):

    current_filters = (current_filters if current_filters else [])
    Survey = request.env['survey.survey']
    result = []
    if (question.type == 'multiple_choice'):
        result.append({'key': ustr(question.question), 'values': Survey.prepare_result(question, current_filters)['answers']})
    if (question.type == 'simple_choice'):
        result = Survey.prepare_result(question, current_filters)['answers']
    if (question.type == 'matrix'):
        data = Survey.prepare_result(question, current_filters)
        for answer in data['answers']:
            values = []
            for row in data['rows']:
                values.append({'text': data['rows'].get(row), 'count': data['result'].get((row, answer))})
            result.append({'key': data['answers'].get(answer), 'values': values})
    return json.dumps(result)
