'Helper function to create/draw Chart'

@staticmethod
def drawChart(output, series_id, numeric_question_list, label_question, outputFormat=None):

    T = current.T
    get_answers = survey_getAllAnswersForQuestionInSeries
    gqstn = survey_getQuestionFromName(label_question, series_id)
    gqstn_id = gqstn['qstn_id']
    ganswers = get_answers(gqstn_id, series_id)
    data_list = []
    legend_labels = []
    for numeric_question in numeric_question_list:
        if (numeric_question == 'Count'):
            gqstn_type = gqstn['type']
            analysis_tool = survey_analysis_type[gqstn_type](gqstn_id, ganswers)
            mapdict = analysis_tool.uniqueCount()
            label = mapdict.keys()
            data = mapdict.values()
            legend_labels.append(T('Count    of    Question'))
        else:
            qstn = survey_getQuestionFromCode(numeric_question, series_id)
            qstn_id = qstn['qstn_id']
            qstn_type = qstn['type']
            answers = get_answers(qstn_id, series_id)
            analysis_tool = survey_analysis_type[qstn_type](qstn_id, answers)
            label = analysis_tool.qstnWidget.fullName()
            if (len(label) > 20):
                label = ('%s...' % label[0:20])
            legend_labels.append(label)
            grouped = analysis_tool.groupData(ganswers)
            aggregate = 'Sum'
            filtered = analysis_tool.filter(aggregate, grouped)
            (label, data) = analysis_tool.splitGroupedData(filtered)
        if (data != []):
            data_list.append(data)
    if (data_list == []):
        output['chart'] = H4(T('There    is    insufficient    data    to    draw    a    chart    from    the    questions    selected'))
    else:
        chart_file = S3SurveySeriesModel.getChartName()
        chart = S3Chart(path=chart_file, width=7.2)
        chart.asInt = True
        chart.survey_bar(label_question, data_list, label, legend_labels)
        if (outputFormat is None):
            image = chart.draw()
        else:
            image = chart.draw(output=outputFormat)
        output['chart'] = image
        request = current.request
        chart_link = A(T('Download'), _href=URL(c='survey', f='series', args=request.args, vars=request.vars))
        output['chartDownload'] = chart_link
